Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
data-center-auto
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bltdc
data-center-auto
Commits
18d3b183
Commit
18d3b183
authored
Dec 03, 2020
by
泽锋 李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
动态导出销量预测模板
parent
2834ce15
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
148 additions
and
32 deletions
+148
-32
dc_auto_turnover.cs
AutoTurnOver.DB/dc_auto_turnover.cs
+1
-0
dc_auto_turnover.cs
AutoTurnOver.Models/dc_auto_turnover.cs
+1
-0
ConfigServices.cs
AutoTurnOver.Services/ConfigServices.cs
+50
-32
EPPlusHelper.cs
AutoTurnOver.Utility/EPPlusHelper.cs
+24
-0
SkuAutoTurnController.cs
AutoTurnOver/Controllers/SkuAutoTurnController.cs
+67
-0
Dockerfile
AutoTurnOver/Dockerfile
+5
-0
No files found.
AutoTurnOver.DB/dc_auto_turnover.cs
View file @
18d3b183
...
...
@@ -55,6 +55,7 @@ where 1=1 ";
{
sql
=
@"select dat.*,t2.oneday_sales,t2.forecast_oneday_sales as 'forecast_oneday_sales2',
t4.bailun_category_name,
t3.hq_type as 'warehouse_type',
( case when t5.`status`=0 or t5.`status` is null then 0 else 1 end ) as 'monitor_status',
( case when t12.`status`=0 or t12.`status` is null then 0 else 1 end ) as 'returngoodspush_state',
t4.suppliers_link,
...
...
AutoTurnOver.Models/dc_auto_turnover.cs
View file @
18d3b183
...
...
@@ -435,6 +435,7 @@ namespace AutoTurnOver.Models
public
class
dc_auto_turnover_list_dto
{
public
string
area_name
{
get
;
set
;
}
public
string
warehouse_type
{
get
;
set
;
}
public
string
head_transport_type
{
get
;
set
;
}
public
string
head_transport_logistics_code
{
get
;
set
;
}
/// <summary>
...
...
AutoTurnOver.Services/ConfigServices.cs
View file @
18d3b183
...
...
@@ -730,11 +730,8 @@ namespace AutoTurnOver.Services
index
++;
try
{
var
bailun_sku
=
row
[
"
sku
"
].
ToString
();
var
bailun_sku
=
row
[
"
SKU
"
].
ToString
();
var
warehouse_code
=
row
[
"仓库编码"
].
ToString
();
var
date_str
=
row
[
"日期"
].
ToString
();
var
sales_str
=
row
[
"销量"
].
ToString
();
var
action
=
row
[
"操作"
].
ToString
();
if
(
string
.
IsNullOrWhiteSpace
(
bailun_sku
))
throw
new
Exception
(
"SKU必填"
);
if
(
string
.
IsNullOrWhiteSpace
(
warehouse_code
))
throw
new
Exception
(
"warehouse_code必填"
);
...
...
@@ -742,39 +739,60 @@ namespace AutoTurnOver.Services
if
(
warehouse_data
==
null
)
{
throw
new
Exception
(
"仓库在系统中找不到"
);
}
var
warehouse_name
=
warehouse_data
.
warehouse_name
;
if
(
action
==
"作废"
)
//if (action == "作废")
//{
// var count = MyMySqlConnection._connection.Execute(" delete from sales_day_config where bailun_sku_warehouse_code=@bailun_sku_warehouse_code ",new {
// bailun_sku_warehouse_code = $"{bailun_sku}{warehouse_code}"
// });
// if (count <= 0)
// {
// throw new Exception("数据不存在");
// }
//}
//else
{
var
count
=
MyMySqlConnection
.
_connection
.
Execute
(
" delete from sales_day_config where bailun_sku_warehouse_code=@bailun_sku_warehouse_code "
,
new
{
bailun_sku_warehouse_code
=
$"
{
bailun_sku
}{
warehouse_code
}
"
});
if
(
count
<=
0
)
{
throw
new
Exception
(
"数据不存在"
);
}
}
else
{
decimal
sales
=
0
;
if
(!
decimal
.
TryParse
(
sales_str
,
out
sales
))
{
throw
new
Exception
(
"销量格式异常"
);
}
DateTime
date
=
DateTime
.
Now
;
if
(!
DateTime
.
TryParse
(
date_str
,
out
date
))
{
throw
new
Exception
(
"时间格式异常"
);
}
var
new_data
=
new
sales_day_config_input_dto
var
cols
=
table
.
Columns
;
foreach
(
DataColumn
col
in
cols
)
{
bailun_sku
=
bailun_sku
,
warehouse_code
=
warehouse_code
,
sales
=
sales
,
date
=
date
};
if
(
col
.
ColumnName
.
Contains
(
"销量"
)
&&
col
.
ColumnName
.
Length
>
20
)
{
decimal
sales
=
0
;
var
salesObj
=
row
[
col
.
ColumnName
];
if
(
salesObj
!=
null
)
{
if
(!
decimal
.
TryParse
(
salesObj
.
ToString
(),
out
sales
))
{
throw
new
Exception
(
"销量格式异常"
);
}
// 取开始结束时间
var
btime
=
DateTime
.
Parse
(
col
.
ColumnName
.
Substring
(
2
,
10
));
var
etime
=
DateTime
.
Parse
(
col
.
ColumnName
.
Substring
(
13
,
10
));
var
s_sales
=
(
sales
/
((
int
)
Math
.
Ceiling
((
etime
-
btime
).
TotalDays
)));
while
(
btime
.
ToDayHome
()<=
etime
.
ToDayEnd
())
{
var
new_data
=
new
sales_day_config_input_dto
{
bailun_sku
=
bailun_sku
,
warehouse_code
=
warehouse_code
,
sales
=
s_sales
,
date
=
btime
};
DB
.
db_config
.
SaveSalesDayConfig
(
new_data
,
user
);
btime
=
btime
.
AddDays
(
1
);
}
}
}
}
DB
.
db_config
.
SaveSalesDayConfig
(
new_data
,
user
);
}
...
...
AutoTurnOver.Utility/EPPlusHelper.cs
View file @
18d3b183
...
...
@@ -113,5 +113,29 @@ namespace AutoTurnOver.Utility
}
return
data_set
;
}
public
static
void
ExportExcel
(
DataTable
dt
,
string
fileName
,
string
sheetName
=
null
)
{
FileInfo
newFile
=
new
FileInfo
(
fileName
);
if
(!
newFile
.
Directory
.
Exists
)
{
newFile
.
Directory
.
Create
();
}
if
(
newFile
.
Exists
)
{
newFile
.
Delete
();
newFile
=
new
FileInfo
(
fileName
);
}
using
(
ExcelPackage
pck
=
new
ExcelPackage
(
newFile
))
{
ExcelWorksheet
worksheet
=
pck
.
Workbook
.
Worksheets
.
Add
(
"Sheet1"
);
worksheet
.
Cells
[
"A1"
].
LoadFromDataTable
(
dt
,
true
);
worksheet
.
Cells
.
Style
.
HorizontalAlignment
=
ExcelHorizontalAlignment
.
Center
;
//水平居中
worksheet
.
Cells
.
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
//垂直居中
worksheet
.
Cells
.
AutoFitColumns
();
pck
.
Save
();
}
}
}
}
AutoTurnOver/Controllers/SkuAutoTurnController.cs
View file @
18d3b183
...
...
@@ -95,6 +95,70 @@ namespace AutoTurnOver.Controllers
}
/// <summary>
/// 导出销量模板
/// </summary>
/// <returns></returns>
public
ActionResult
ExportSalesTemplate
([
FromQuery
]
Condition_AutoTurnOver
m
,
[
FromQuery
]
int
offset
,
[
FromQuery
]
int
limit
,
[
FromQuery
]
string
order
,
[
FromQuery
]
string
sort
)
{
try
{
var
service
=
new
Services
.
SkuAutoTurnServices
();
int
total
=
0
;
var
list
=
service
.
List
(
m
,
0
,
int
.
MaxValue
,
ref
total
,
""
,
""
);
var
fileName
=
AppContext
.
BaseDirectory
+
$@"Result\RealtimeStock\销量导入模板.xlsx"
;
var
table
=
new
DataTable
();
table
.
Columns
.
Add
(
"SKU"
);
table
.
Columns
.
Add
(
"标题"
);
table
.
Columns
.
Add
(
"仓库"
);
table
.
Columns
.
Add
(
"仓库编码"
);
table
.
Columns
.
Add
(
"仓库类型"
);
table
.
Columns
.
Add
(
"昨日销量"
);
table
.
Columns
.
Add
(
"7日日均"
);
table
.
Columns
.
Add
(
"14日日均"
);
table
.
Columns
.
Add
(
"30日日均"
);
var
thisDate
=
DateTime
.
Now
;
for
(
int
i
=
0
;
i
<
8
;
i
++)
{
var
btime
=
thisDate
.
GetWeekFirstDayMon
();
var
etime
=
thisDate
.
AddDays
(
7
);
table
.
Columns
.
Add
(
$"预测
{
btime
.
ToString
(
"yyyy-MM-dd"
)}
~
{
etime
.
ToString
(
"yyyy-MM-dd"
)}
销量"
);
thisDate
=
thisDate
.
AddDays
(
7
);
}
foreach
(
var
item
in
list
)
{
var
row
=
table
.
NewRow
();
row
[
"SKU"
]
=
item
.
bailun_sku
;
row
[
"标题"
]
=
item
.
sku_title
;
row
[
"仓库"
]
=
item
.
warehouse_name
;
row
[
"仓库编码"
]
=
item
.
warehouse_code
;
row
[
"仓库类型"
]
=
item
.
warehouse_type
;
row
[
"昨日销量"
]
=
item
.
oneday_sales
;
row
[
"7日日均"
]
=
item
.
history_sevenday_sales
;
row
[
"14日日均"
]
=
item
.
history_fourteenday_sales
;
row
[
"30日日均"
]
=
item
.
history_thirtyday_sales
;
table
.
Rows
.
Add
(
row
);
}
EPPlusHelper
.
ExportExcel
(
table
,
fileName
);
var
memory
=
new
MemoryStream
();
using
(
var
stream
=
new
FileStream
(
fileName
,
FileMode
.
Open
))
{
stream
.
CopyTo
(
memory
);
}
memory
.
Position
=
0
;
return
File
(
memory
,
"text/csv"
,
$"销量导入模板.xlsx"
);
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
ex
.
Message
+
"----"
+
ex
.
StackTrace
);
return
new
ContentResult
()
{
Content
=
ex
.
Message
+
"----"
+
ex
.
StackTrace
};
}
}
#
region
特殊销售设置
/// <summary>
...
...
@@ -471,5 +535,7 @@ namespace AutoTurnOver.Controllers
memory
.
Position
=
0
;
return
File
(
memory
,
"text/csv"
,
"最新预计交期.csv"
);
}
}
}
\ No newline at end of file
AutoTurnOver/Dockerfile
View file @
18d3b183
...
...
@@ -4,6 +4,11 @@ RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shang
EXPOSE
80
EXPOSE
443
# RUN ln -s /lib/x86_64-linux-gnu/libdl-2.24.so /lib/x86_64-linux-gnu/libdl.so
RUN
apt-get update
RUN
apt-get install
-y
--no-install-recommends
libgdiplus libc6-dev
FROM
microsoft/dotnet:2.1-sdk-alpine AS build
WORKDIR
/src
COPY
["AutoTurnOver/AutoTurnOver.csproj", "AutoTurnOver/"]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment