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
a4cbb1d1
Commit
a4cbb1d1
authored
Jan 16, 2021
by
泽锋 李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
采购建议,新增字段,导出切换到离线下载
parent
74cdd815
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
146 deletions
+118
-146
dc_auto_purchase_advise.cs
AutoTurnOver.Models/dc_auto_purchase_advise.cs
+16
-3
PurchaseAdviseServices.cs
AutoTurnOver.Services/PurchaseAdviseServices.cs
+69
-0
TaskDownloadServices.cs
AutoTurnOver.Services/TaskDownloadServices.cs
+17
-0
PurchaseAdviseController.cs
AutoTurnOver/Controllers/PurchaseAdviseController.cs
+16
-143
No files found.
AutoTurnOver.Models/dc_auto_purchase_advise.cs
View file @
a4cbb1d1
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Text
;
namespace
AutoTurnOver.Models
...
...
@@ -439,33 +440,41 @@ namespace AutoTurnOver.Models
/// </summary>
public
int
main_id
{
get
;
set
;
}
[
Description
(
"sku"
)]
public
string
sku
{
get
;
set
;
}
[
Description
(
"仓库编码"
)]
public
string
warehouse_code
{
get
;
set
;
}
[
Description
(
"开始时间"
)]
public
DateTime
?
start_date
{
get
;
set
;
}
[
Description
(
"结束时间"
)]
public
DateTime
?
end_date
{
get
;
set
;
}
[
Description
(
"仓库类型"
)]
public
string
warehousetype
{
get
;
set
;
}
[
Description
(
"仓库国家"
)]
public
int
?
warehousearea
{
get
;
set
;
}
/// <summary>
/// 是否推送
/// </summary>
[
Description
(
"是否已推送"
)]
public
bool
?
ispush
{
get
;
set
;
}
[
Description
(
"类型"
)]
public
int
?
type
{
get
;
set
;
}
/// <summary>
/// 采购员
/// </summary>
[
Description
(
"采购员"
)]
public
string
purchase_user
{
get
;
set
;
}
/// <summary>
/// 供应商
/// </summary>
[
Description
(
"供应商"
)]
public
string
supplier_name
{
get
;
set
;
}
[
Description
(
"商品内部编码"
)]
public
string
product_inner_code
{
get
;
set
;
}
public
bool
isSum
{
get
;
set
;
}
...
...
@@ -474,12 +483,16 @@ namespace AutoTurnOver.Models
/// 是否是同区多仓的sku
/// </summary>
public
bool
is_multiple_warehouse
{
get
;
set
;
}
[
Description
(
"是否有换物流切换建议"
)]
public
int
?
is_replace_logistics
{
get
;
set
;
}
[
Description
(
"是否有换物流切换建议"
)]
public
decimal
?
quantity_final_advise_price_min
{
get
;
set
;
}
public
decimal
?
quantity_final_advise_price_max
{
get
;
set
;
}
[
Description
(
"jit备货类型"
)]
public
int
?
purchase_type_jit
{
get
;
set
;
}
}
...
...
AutoTurnOver.Services/PurchaseAdviseServices.cs
View file @
a4cbb1d1
...
...
@@ -6,6 +6,7 @@ using Bailun.ServiceFabric;
using
Dapper
;
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Linq
;
using
System.Text.RegularExpressions
;
...
...
@@ -92,6 +93,74 @@ namespace AutoTurnOver.Services
return
purchase_advise
.
DetailList
(
m
,
offset
,
limit
,
ref
total
,
order
,
sort
);
}
public
string
Export
(
dc_auto_purchase_advise_detailed_search_dto
searchData
)
{
var
total
=
0
;
var
list
=
PurchaseAdviseServices
.
DetailList
(
searchData
,
0
,
int
.
MaxValue
,
ref
total
);
DataTable
table
=
new
DataTable
();
string
[]
cols
=
new
string
[]
{
"初始建议数"
,
"系统建议数"
,
"采购数量"
,
"是否已推送"
,
"jit备货类型"
,
"时间"
,
"sku"
,
"产品名称"
,
"产品14日日均"
,
"仓库编码"
,
"仓库名称"
,
"源仓库"
,
"内部商品编码"
,
"商品建议采购"
,
"商品14日日均"
,
"商品moq"
,
"日均加权销量"
,
"安全库存"
,
"缺货"
,
"实时缺货"
,
"调拨在途"
,
"调拨单在途"
,
"调拨在途(采购临时数据)"
,
"调拨在途(暂存)"
,
"采购在途"
,
"库存数"
,
"采购金额"
,
"供应链长度"
,
"供应商名称"
,
"采购类型"
,
"采购员"
,
"突增关注"
,
"待发货百伦单号"
,
"7日日均"
,
"14日日均"
,
"30日日均"
,
"海外仓入库天数"
,
"采购单价"
,
"历史7天日均"
,
"历史14日均"
,
"历史30日均"
,
"加权日均"
,
"安全库存"
,
"今日实际缺货"
,
"供应链累积销量"
,
"供应链到货当天的销量"
,
"预测销量"
,
"累积入库数量"
,
"实际库存"
,
"moq"
,
"多备天数"
,
"预测销量公式"
};
foreach
(
var
item
in
cols
)
{
table
.
Columns
.
Add
(
item
);
}
foreach
(
var
itemData
in
list
)
{
DataRow
row
=
table
.
NewRow
();
row
[
"调拨单在途"
]
=
itemData
.
quantity_transfer_order
;
row
[
"调拨在途(采购临时数据)"
]
=
itemData
.
quantity_transfer_temp_schedule
;
row
[
"调拨在途(暂存)"
]
=
itemData
.
quantity_transfer_temporary_storage
;
row
[
"7日日均"
]
=
itemData
.
t_history_sevenday_sales
;
row
[
"14日日均"
]
=
itemData
.
t_history_fourteenday_sales
;
row
[
"30日日均"
]
=
itemData
.
t_history_thirtyday_sales
;
row
[
"源仓库"
]
=
itemData
.
source_warehouse_code_name_str
;
row
[
"初始建议数"
]
=
itemData
.
quantity_init_advise
;
row
[
"系统建议数"
]
=
itemData
.
quantity_final_advise
;
row
[
"采购数量"
]
=
itemData
.
quantity_actual
;
row
[
"是否已推送"
]
=
itemData
.
ispush
==
1
?
"是"
:
"否"
;
row
[
"jit备货类型"
]
=
itemData
.
purchase_type_jit_str
;
row
[
"时间"
]
=
itemData
.
create_time_str
;
row
[
"sku"
]
=
itemData
.
bailun_sku
;
row
[
"产品名称"
]
=
itemData
.
sku_name
;
row
[
"产品14日日均"
]
=
itemData
.
history_fourteenday_sales
;
row
[
"仓库编码"
]
=
itemData
.
warehouse_code
;
row
[
"仓库名称"
]
=
itemData
.
warehouse_name
;
row
[
"内部商品编码"
]
=
itemData
.
product_inner_code
;
row
[
"商品建议采购"
]
=
itemData
.
goods_quantity_init_advise
;
row
[
"商品14日日均"
]
=
itemData
.
goods_history_fourteenday_sales
;
row
[
"商品moq"
]
=
itemData
.
goods_moq
;
row
[
"日均加权销量"
]
=
itemData
.
daily_weighted_sales
;
row
[
"安全库存"
]
=
itemData
.
quantity_safe_inventory
;
row
[
"缺货"
]
=
itemData
.
quantity_out_stock
;
row
[
"实时缺货"
]
=
itemData
.
realtime_quantity_out_stock
;
row
[
"调拨在途"
]
=
itemData
.
quantity_transfer
;
row
[
"采购在途"
]
=
itemData
.
quantity_purchase
;
row
[
"库存数"
]
=
itemData
.
quantity_inventory
;
row
[
"采购金额"
]
=
itemData
.
quantity_final_advise_price
;
row
[
"供应链长度"
]
=
itemData
.
turnover_days
;
row
[
"供应商名称"
]
=
itemData
.
suppliers_name
;
row
[
"采购类型"
]
=
itemData
.
type_str
;
row
[
"采购员"
]
=
itemData
.
buyer_name
;
row
[
"突增关注"
]
=
itemData
.
sudden_increase
;
row
[
"待发货百伦单号"
]
=
itemData
.
bailun_order_ids
;
row
[
"海外仓入库天数"
]
=
itemData
.
abroad_inbound_config_delivery
;
table
.
Rows
.
Add
(
row
);
}
var
fileName
=
AppContext
.
BaseDirectory
+
@"Result\RealtimeStock\采购建议.csv"
;
CsvFileHelper
.
SaveCSV
(
table
,
fileName
);
return
fileName
;
}
/// <summary>
/// 设置采购数量
/// </summary>
...
...
AutoTurnOver.Services/TaskDownloadServices.cs
View file @
a4cbb1d1
...
...
@@ -53,6 +53,9 @@ namespace AutoTurnOver.Services
case
"转仓日志"
:
item
.
result_file_url
=
await
DownloadTransferWarehouseLog
(
item
.
parameter
,
item
);
break
;
case
"采购建议"
:
item
.
result_file_url
=
await
DownloadPurchaseAdvise
(
item
.
parameter
,
item
);
break
;
default
:
throw
new
Exception
(
"无法识别的任务"
);
}
item
.
end_date
=
DateTime
.
Now
;
...
...
@@ -130,6 +133,20 @@ namespace AutoTurnOver.Services
return
fileData
;
}
/// <summary>
/// 下载采购建议
/// </summary>
public
async
Task
<
string
>
DownloadPurchaseAdvise
(
string
par_json
,
dc_task_download
download_data
)
{
dc_auto_purchase_advise_detailed_search_dto
search_data
=
par_json
.
ToObject
<
dc_auto_purchase_advise_detailed_search_dto
>();
Console
.
WriteLine
(
"DownloadStock - 开始生成文件"
);
var
memory
=
new
PurchaseAdviseServices
().
Export
(
search_data
);
Console
.
WriteLine
(
"DownloadStock - 开始生成上传文件"
);
var
fileData
=
await
AutoTurnOver
.
Utility
.
QiNiuCloudHelper
.
UploadSectioningAsync
(
memory
);
Console
.
WriteLine
(
"DownloadStock - 上传完毕"
);
return
fileData
;
}
/// <summary>
/// 下载库存
/// </summary>
public
async
Task
<
string
>
DownloadFbaStock
(
string
par_json
,
dc_task_download
download_data
)
...
...
AutoTurnOver/Controllers/PurchaseAdviseController.cs
View file @
a4cbb1d1
...
...
@@ -10,6 +10,7 @@ using AutoTurnOver.Utility;
using
System.Data
;
using
AutoTurnOver.Common
;
using
System.IO
;
using
AutoTurnOver.DB
;
namespace
AutoTurnOver.Controllers
{
...
...
@@ -60,31 +61,9 @@ namespace AutoTurnOver.Controllers
/// <param name="start_date"></param>
/// <returns></returns>
[
HttpGet
]
public
string
DetailList
(
int
limit
,
int
offset
,
int
main_id
,
string
sort
,
string
sku
,
string
warehousecode
,
DateTime
?
end_date
,
DateTime
?
start_date
,
string
warehousetype
,
int
?
warehousearea
,
string
order
,
bool
?
ispush
=
null
,
int
?
type
=
null
,
string
supplier_name
=
null
,
string
purchase_user
=
null
,
string
product_inner_code
=
null
,
bool
?
is_multiple_warehouse
=
false
,
int
?
is_replace_logistics
=
null
,
decimal
?
quantity_final_advise_price_max
=
null
,
decimal
?
quantity_final_advise_price_min
=
null
,
int
?
purchase_type_jit
=
null
)
public
string
DetailList
([
FromQuery
]
dc_auto_purchase_advise_detailed_search_dto
m
,
[
FromQuery
]
int
limit
,
[
FromQuery
]
int
offset
,
[
FromQuery
]
string
sort
,
[
FromQuery
]
string
order
)
{
var
m
=
new
dc_auto_purchase_advise_detailed_search_dto
{
main_id
=
main_id
,
sku
=
sku
,
warehouse_code
=
warehousecode
,
end_date
=
end_date
,
start_date
=
start_date
,
warehousearea
=
warehousearea
,
warehousetype
=
warehousetype
,
ispush
=
ispush
,
type
=
type
,
supplier_name
=
supplier_name
,
purchase_user
=
purchase_user
,
product_inner_code
=
product_inner_code
,
is_multiple_warehouse
=
is_multiple_warehouse
.
Value
,
is_replace_logistics
=
is_replace_logistics
,
quantity_final_advise_price_max
=
quantity_final_advise_price_max
,
quantity_final_advise_price_min
=
quantity_final_advise_price_min
,
purchase_type_jit
=
purchase_type_jit
};
var
total
=
0
;
var
list
=
PurchaseAdviseServices
.
DetailList
(
m
,
offset
,
limit
,
ref
total
,
order
,
sort
);
...
...
@@ -108,33 +87,9 @@ namespace AutoTurnOver.Controllers
/// <returns></returns>
[
HttpGet
]
[
BrowseLog
(
"Bailun_aims"
,
"访问【百伦自动周转系统】->【自动下单管理】->【采购建议列表】->【搜索】页面"
,
0
)]
public
JsonResult
DetailListSumFooter
(
int
limit
,
int
offset
,
int
main_id
,
string
sort
,
string
sku
,
string
warehousecode
,
DateTime
?
end_date
,
DateTime
?
start_date
,
string
warehousetype
,
int
?
warehousearea
,
bool
?
ispush
=
null
,
int
?
type
=
null
,
string
supplier_name
=
null
,
string
purchase_user
=
null
,
string
product_inner_code
=
null
,
bool
is_multiple_warehouse
=
false
,
int
?
is_replace_logistics
=
null
,
decimal
?
quantity_final_advise_price_max
=
null
,
decimal
?
quantity_final_advise_price_min
=
null
,
int
?
purchase_type_jit
=
null
)
public
JsonResult
DetailListSumFooter
([
FromQuery
]
dc_auto_purchase_advise_detailed_search_dto
m
,
[
FromQuery
]
int
limit
,
[
FromQuery
]
int
offset
,
[
FromQuery
]
string
sort
,
[
FromQuery
]
string
order
)
{
var
m
=
new
dc_auto_purchase_advise_detailed_search_dto
{
main_id
=
main_id
,
sku
=
sku
,
warehouse_code
=
warehousecode
,
end_date
=
end_date
,
start_date
=
start_date
,
warehousearea
=
warehousearea
,
warehousetype
=
warehousetype
,
ispush
=
ispush
,
type
=
type
,
supplier_name
=
supplier_name
,
purchase_user
=
purchase_user
,
product_inner_code
=
product_inner_code
,
isSum
=
true
,
is_multiple_warehouse
=
is_multiple_warehouse
,
is_replace_logistics
=
is_replace_logistics
,
quantity_final_advise_price_max
=
quantity_final_advise_price_max
,
quantity_final_advise_price_min
=
quantity_final_advise_price_min
,
purchase_type_jit
=
purchase_type_jit
};
m
.
isSum
=
true
;
var
total
=
0
;
var
list
=
PurchaseAdviseServices
.
DetailList
(
m
,
offset
,
limit
,
ref
total
);
...
...
@@ -148,102 +103,23 @@ namespace AutoTurnOver.Controllers
/// <param name="sku"></param>
/// <param name="warehousecode"></param>
/// <returns></returns>
public
FileResult
Export
(
int
limit
,
int
offset
,
int
main_id
,
string
sort
,
string
sku
,
string
warehousecode
,
DateTime
?
end_date
,
DateTime
?
start_date
,
string
warehousetype
,
int
?
warehousearea
,
bool
?
ispush
=
null
,
int
?
type
=
null
,
string
supplier_name
=
null
,
string
purchase_user
=
null
,
string
product_inner_code
=
null
,
bool
is_multiple_warehouse
=
false
,
int
?
is_replace_logistics
=
null
,
decimal
?
quantity_final_advise_price_max
=
null
,
decimal
?
quantity_final_advise_price_min
=
null
,
int
?
purchase_type_jit
=
null
)
public
JsonResult
Export
([
FromQuery
]
dc_auto_purchase_advise_detailed_search_dto
m
,
[
FromQuery
]
int
limit
,
[
FromQuery
]
int
offset
,
[
FromQuery
]
string
sort
,
[
FromQuery
]
string
order
)
{
var
m
=
new
dc_auto_purchase_advise_detailed_search_dto
{
main_id
=
main_id
,
sku
=
sku
,
warehouse_code
=
warehousecode
,
end_date
=
end_date
,
start_date
=
start_date
,
warehousearea
=
warehousearea
,
warehousetype
=
warehousetype
,
ispush
=
ispush
,
type
=
type
,
supplier_name
=
supplier_name
,
purchase_user
=
purchase_user
,
product_inner_code
=
product_inner_code
,
isSum
=
false
,
is_multiple_warehouse
=
is_multiple_warehouse
,
is_replace_logistics
=
is_replace_logistics
,
quantity_final_advise_price_max
=
quantity_final_advise_price_max
,
quantity_final_advise_price_min
=
quantity_final_advise_price_min
,
purchase_type_jit
=
purchase_type_jit
};
var
total
=
0
;
var
list
=
PurchaseAdviseServices
.
DetailList
(
m
,
0
,
int
.
MaxValue
,
ref
total
);
DataTable
table
=
new
DataTable
();
string
[]
cols
=
new
string
[]
{
"初始建议数"
,
"系统建议数"
,
"采购数量"
,
"是否已推送"
,
"jit备货类型"
,
"时间"
,
"sku"
,
"产品名称"
,
"产品14日日均"
,
"仓库编码"
,
"仓库名称"
,
"源仓库"
,
"内部商品编码"
,
"商品建议采购"
,
"商品14日日均"
,
"商品moq"
,
"日均加权销量"
,
"安全库存"
,
"缺货"
,
"实时缺货"
,
"调拨在途"
,
"调拨单在途"
,
"调拨在途(采购临时数据)"
,
"调拨在途(暂存)"
,
"采购在途"
,
"库存数"
,
"采购金额"
,
"供应链长度"
,
"供应商名称"
,
"采购类型"
,
"采购员"
,
"突增关注"
,
"待发货百伦单号"
,
"7日日均"
,
"14日日均"
,
"30日日均"
,
"海外仓入库天数"
};
foreach
(
var
item
in
cols
)
{
table
.
Columns
.
Add
(
item
);
}
foreach
(
var
itemData
in
list
)
try
{
DataRow
row
=
table
.
NewRow
();
row
[
"调拨单在途"
]
=
itemData
.
quantity_transfer_order
;
row
[
"调拨在途(采购临时数据)"
]
=
itemData
.
quantity_transfer_temp_schedule
;
row
[
"调拨在途(暂存)"
]
=
itemData
.
quantity_transfer_temporary_storage
;
row
[
"7日日均"
]
=
itemData
.
t_history_sevenday_sales
;
row
[
"14日日均"
]
=
itemData
.
t_history_fourteenday_sales
;
row
[
"30日日均"
]
=
itemData
.
t_history_thirtyday_sales
;
row
[
"源仓库"
]
=
itemData
.
source_warehouse_code_name_str
;
row
[
"初始建议数"
]
=
itemData
.
quantity_init_advise
;
row
[
"系统建议数"
]
=
itemData
.
quantity_final_advise
;
row
[
"采购数量"
]
=
itemData
.
quantity_actual
;
row
[
"是否已推送"
]
=
itemData
.
ispush
==
1
?
"是"
:
"否"
;
row
[
"jit备货类型"
]
=
itemData
.
purchase_type_jit_str
;
row
[
"时间"
]
=
itemData
.
create_time_str
;
row
[
"sku"
]
=
itemData
.
bailun_sku
;
row
[
"产品名称"
]
=
itemData
.
sku_name
;
row
[
"产品14日日均"
]
=
itemData
.
history_fourteenday_sales
;
row
[
"仓库编码"
]
=
itemData
.
warehouse_code
;
row
[
"仓库名称"
]
=
itemData
.
warehouse_name
;
row
[
"内部商品编码"
]
=
itemData
.
product_inner_code
;
row
[
"商品建议采购"
]
=
itemData
.
goods_quantity_init_advise
;
row
[
"商品14日日均"
]
=
itemData
.
goods_history_fourteenday_sales
;
row
[
"商品moq"
]
=
itemData
.
goods_moq
;
row
[
"日均加权销量"
]
=
itemData
.
daily_weighted_sales
;
row
[
"安全库存"
]
=
itemData
.
quantity_safe_inventory
;
row
[
"缺货"
]
=
itemData
.
quantity_out_stock
;
row
[
"实时缺货"
]
=
itemData
.
realtime_quantity_out_stock
;
row
[
"调拨在途"
]
=
itemData
.
quantity_transfer
;
row
[
"采购在途"
]
=
itemData
.
quantity_purchase
;
row
[
"库存数"
]
=
itemData
.
quantity_inventory
;
row
[
"采购金额"
]
=
itemData
.
quantity_final_advise_price
;
row
[
"供应链长度"
]
=
itemData
.
turnover_days
;
row
[
"供应商名称"
]
=
itemData
.
suppliers_name
;
row
[
"采购类型"
]
=
itemData
.
type_str
;
row
[
"采购员"
]
=
itemData
.
buyer_name
;
row
[
"突增关注"
]
=
itemData
.
sudden_increase
;
row
[
"待发货百伦单号"
]
=
itemData
.
bailun_order_ids
;
row
[
"海外仓入库天数"
]
=
itemData
.
abroad_inbound_config_delivery
;
table
.
Rows
.
Add
(
row
);
var
user
=
AutoUtility
.
GetUser
();
dc_task_download_dao
.
PushData
<
dc_auto_purchase_advise_detailed_search_dto
>(
new
dc_task_download
{
parameter
=
m
.
ToJson
(),
task_name
=
"采购建议"
},
user
);
return
new
JsonResult
(
new
{
success
=
true
});
}
var
fileName
=
AppContext
.
BaseDirectory
+
@"Result\RealtimeStock\采购建议.csv"
;
DataTableHelper
.
SaveCSV
(
table
,
fileName
);
var
memory
=
new
MemoryStream
();
using
(
var
stream
=
new
FileStream
(
fileName
,
FileMode
.
Open
))
catch
(
Exception
ex
)
{
stream
.
CopyTo
(
memory
);
return
new
JsonResult
(
new
{
success
=
false
,
message
=
ex
.
Message
}
);
}
memory
.
Position
=
0
;
return
File
(
memory
,
"text/csv"
,
"采购建议.csv"
);
}
/// <summary>
...
...
@@ -406,7 +282,5 @@ namespace AutoTurnOver.Controllers
}
}
}
}
\ No newline at end of file
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