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
9d807385
Commit
9d807385
authored
Feb 20, 2021
by
泽锋 李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
063cc67b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
176 additions
and
1 deletion
+176
-1
report.cs
AutoTurnOver.DB/report.cs
+43
-0
dc_report_goods_platform.cs
AutoTurnOver.Models/Report/dc_report_goods_platform.cs
+11
-0
dc_report_goods.cs
AutoTurnOver.Models/dc_report_goods.cs
+2
-0
ReportServices.cs
AutoTurnOver.Services/ReportServices.cs
+52
-0
TaskDownloadServices.cs
AutoTurnOver.Services/TaskDownloadServices.cs
+17
-0
ReportsController.cs
AutoTurnOver/Controllers/ReportsController.cs
+51
-1
No files found.
AutoTurnOver.DB/report.cs
View file @
9d807385
...
...
@@ -4481,5 +4481,48 @@ truncate table dc_report_goods_platform_temp;
Console
.
WriteLine
(
ex
.
StackTrace
);
}
}
/// <summary>
/// 查询商品报表数据
/// </summary>
/// <param name="searchData"></param>
/// <param name="offset"></param>
/// <param name="limit"></param>
/// <param name="total"></param>
/// <returns></returns>
public
static
List
<
dc_report_goods_platform
>
GetReportPlatformGoodsPage
(
dc_report_goods_platform_search_dto
searchData
,
int
offset
,
int
limit
,
ref
int
total
,
string
order
=
""
,
string
sort
=
""
)
{
var
sql
=
" select t1.* from dc_report_goods_platform as t1 where 1=1 "
;
var
countSql
=
" select count(1) from dc_report_goods_platform as t1 where 1=1 "
;
DynamicParameters
parameters
=
new
DynamicParameters
();
if
(!
string
.
IsNullOrWhiteSpace
(
searchData
.
product_code
))
{
sql
+=
" and t1.product_code=@product_code "
;
countSql
+=
" and t1.product_code=@product_code "
;
parameters
.
Add
(
"product_code"
,
searchData
.
product_code
);
}
if
(!
string
.
IsNullOrWhiteSpace
(
searchData
.
platform_type
))
{
sql
+=
" and t1.platform_type=@platform_type "
;
countSql
+=
" and t1.platform_type=@platform_type "
;
parameters
.
Add
(
"platform_type"
,
searchData
.
platform_type
);
}
if
(!
string
.
IsNullOrEmpty
(
sort
))
{
sql
+=
" order by "
+
sort
;
if
(!
string
.
IsNullOrEmpty
(
order
))
{
sql
+=
" "
+
order
;
}
else
{
sql
+=
" asc"
;
}
}
sql
+=
" limit "
+
offset
+
","
+
limit
;
total
=
_connection
.
QueryFirstOrDefault
<
int
>(
countSql
,
parameters
);
return
_connection
.
Query
<
dc_report_goods_platform
>(
sql
,
parameters
).
AsList
();
}
}
}
...
...
AutoTurnOver.Models/Report/dc_report_goods_platform.cs
View file @
9d807385
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Text
;
namespace
AutoTurnOver.Models.Report
...
...
@@ -28,4 +29,14 @@ namespace AutoTurnOver.Models.Report
{
}
public
class
dc_report_goods_platform_search_dto
{
[
Description
(
"商品编码"
)]
public
string
product_code
{
get
;
set
;
}
[
Description
(
"平台类型"
)]
public
string
platform_type
{
get
;
set
;
}
}
}
AutoTurnOver.Models/dc_report_goods.cs
View file @
9d807385
...
...
@@ -57,4 +57,6 @@ namespace AutoTurnOver.Models
[
Description
(
"仓库编码"
)]
public
string
warehouse_code
{
get
;
set
;
}
}
}
AutoTurnOver.Services/ReportServices.cs
View file @
9d807385
...
...
@@ -1041,6 +1041,10 @@ namespace AutoTurnOver.Services
{
return
report
.
GetReportGoodsPage
(
m
,
offset
,
limit
,
ref
total
,
order
,
sort
);
}
public
List
<
dc_report_goods_platform
>
GetReportPlatformGoodsPage
(
dc_report_goods_platform_search_dto
m
,
int
offset
,
int
limit
,
ref
int
total
,
string
order
=
""
,
string
sort
=
""
)
{
return
report
.
GetReportPlatformGoodsPage
(
m
,
offset
,
limit
,
ref
total
,
order
,
sort
);
}
public
string
ReportGoodsExport
(
dc_report_goods_search_dto
m
,
string
order
,
string
sort
)
{
...
...
@@ -1099,6 +1103,54 @@ namespace AutoTurnOver.Services
//return memory;
return
fileName
;
}
public
string
ReportPlatformGoodsExport
(
dc_report_goods_platform_search_dto
m
,
string
order
,
string
sort
)
{
var
fileName
=
AppContext
.
BaseDirectory
+
$@"商品销量报表(平台维度)-
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
)}{
Guid
.
NewGuid
()}
.csv"
;
var
total
=
0
;
int
page
=
1
;
int
rows
=
250000
;
while
(
true
)
{
var
list
=
GetReportPlatformGoodsPage
(
m
,
(
page
-
1
)
*
rows
,
rows
,
ref
total
,
order
,
sort
);
if
(
list
==
null
||
list
.
Count
<=
0
)
break
;
DataTable
table
=
new
DataTable
();
string
[]
cols
=
new
string
[]
{
"商品编码"
,
"产品类型"
,
"平台"
,
"单价"
,
"重量"
,
"采购"
,
"中文名称"
,
"昨日销量"
,
"昨日销售额"
,
"近7天销量"
,
"近7天销售额"
,
"近30天销量"
,
"近30天销售额"
,
};
foreach
(
var
item
in
cols
)
{
table
.
Columns
.
Add
(
item
);
}
foreach
(
var
itemData
in
list
)
{
DataRow
row
=
table
.
NewRow
();
row
[
"商品编码"
]
=
itemData
.
product_code
;
row
[
"产品类型"
]
=
itemData
.
product_type
;
row
[
"平台"
]
=
itemData
.
platform_type
;
row
[
"单价"
]
=
itemData
.
unit_price
;
row
[
"重量"
]
=
itemData
.
weight
;
row
[
"采购"
]
=
itemData
.
buyer_name
;
row
[
"中文名称"
]
=
itemData
.
product_title
;
row
[
"昨日销量"
]
=
itemData
.
sales_yesterday
;
row
[
"昨日销售额"
]
=
itemData
.
sales_yesterday_amount_usd
;
row
[
"近7天销量"
]
=
itemData
.
sales_yesterday_7
;
row
[
"近7天销售额"
]
=
itemData
.
sales_yesterday_amount_usd_7
;
row
[
"近30天销量"
]
=
itemData
.
sales_yesterday_30
;
row
[
"近30天销售额"
]
=
itemData
.
sales_yesterday_amount_usd_30
;
table
.
Rows
.
Add
(
row
);
}
CsvFileHelper
.
SaveCSV
(
table
,
fileName
,
page
==
1
);
page
++;
}
return
fileName
;
}
}
}
AutoTurnOver.Services/TaskDownloadServices.cs
View file @
9d807385
...
...
@@ -71,6 +71,9 @@ namespace AutoTurnOver.Services
case
"商品销量报表(仓库维度)"
:
item
.
result_file_url
=
await
DownloadReportGoods
(
item
.
parameter
,
item
);
break
;
case
"商品销量报表(平台维度)"
:
item
.
result_file_url
=
await
DownloadPlatformReportGoods
(
item
.
parameter
,
item
);
break
;
default
:
throw
new
Exception
(
"无法识别的任务"
);
}
item
.
end_date
=
DateTime
.
Now
;
...
...
@@ -119,6 +122,20 @@ namespace AutoTurnOver.Services
Console
.
WriteLine
(
"DownloadStock - 上传完毕"
);
return
fileData
;
}
/// <summary>
/// 商品销售情况统计
/// </summary>
public
async
Task
<
string
>
DownloadPlatformReportGoods
(
string
par_json
,
dc_task_download
download_data
)
{
dc_report_goods_platform_search_dto
search_data
=
par_json
.
ToObject
<
dc_report_goods_platform_search_dto
>();
Console
.
WriteLine
(
"DownloadStock - 开始生成文件"
);
var
memory
=
new
ReportServices
().
ReportPlatformGoodsExport
(
search_data
,
""
,
""
);
Console
.
WriteLine
(
"DownloadStock - 开始生成上传文件"
);
var
fileData
=
await
AutoTurnOver
.
Utility
.
QiNiuCloudHelper
.
UploadSectioningAsync
(
memory
);
Console
.
WriteLine
(
"DownloadStock - 上传完毕"
);
return
fileData
;
}
/// <summary>
/// 下载改在线记录
...
...
AutoTurnOver/Controllers/ReportsController.cs
View file @
9d807385
...
...
@@ -1386,7 +1386,7 @@ namespace AutoTurnOver.Controllers
[
HttpGet
]
[
BrowseLog
(
"Bailun_aims"
,
"触发【百伦自动周转系统】->【报表】->【商品销量报表】->【搜索】页面"
,
0
)]
[
BrowseLog
(
"Bailun_aims"
,
"触发【百伦自动周转系统】->【报表】->【商品销量报表
(仓库维度)
】->【搜索】页面"
,
0
)]
public
JsonResult
GetReportGoodsPage
([
FromQuery
]
dc_report_goods_search_dto
m
,
[
FromQuery
]
int
offset
,
[
FromQuery
]
int
limit
,
[
FromQuery
]
string
order
,
[
FromQuery
]
string
sort
)
{
try
...
...
@@ -1412,7 +1412,38 @@ namespace AutoTurnOver.Controllers
});
}
}
[
HttpGet
]
[
BrowseLog
(
"Bailun_aims"
,
"触发【百伦自动周转系统】->【报表】->【商品销量报表(平台维度)】->【搜索】页面"
,
0
)]
public
JsonResult
GetReportPlatformGoodsPage
([
FromQuery
]
dc_report_goods_platform_search_dto
m
,
[
FromQuery
]
int
offset
,
[
FromQuery
]
int
limit
,
[
FromQuery
]
string
order
,
[
FromQuery
]
string
sort
)
{
try
{
var
total
=
0
;
var
service
=
new
Services
.
ReportServices
();
var
list
=
service
.
GetReportPlatformGoodsPage
(
m
,
offset
,
limit
,
ref
total
,
order
,
sort
);
return
new
JsonResult
(
new
{
rows
=
list
,
total
=
total
,
pagecount
=
(
total
/
limit
+
(
total
%
limit
>
0
?
1
:
0
))
});
}
catch
(
Exception
ex
)
{
return
new
JsonResult
(
new
{
message
=
ex
.
Message
,
stack_trace
=
ex
.
StackTrace
});
}
}
public
ActionResult
GetReportGoodsExport
([
FromQuery
]
dc_report_goods_search_dto
m
,
[
FromQuery
]
int
offset
,
[
FromQuery
]
int
limit
,
[
FromQuery
]
string
order
,
[
FromQuery
]
string
sort
)
{
try
...
...
@@ -1431,5 +1462,23 @@ namespace AutoTurnOver.Controllers
}
}
public
ActionResult
GetReportPlatformGoodsExport
([
FromQuery
]
dc_report_goods_search_dto
m
,
[
FromQuery
]
int
offset
,
[
FromQuery
]
int
limit
,
[
FromQuery
]
string
order
,
[
FromQuery
]
string
sort
)
{
try
{
var
user
=
AutoUtility
.
GetUser
();
dc_task_download_dao
.
PushData
<
dc_report_goods_search_dto
>(
new
dc_task_download
{
parameter
=
m
.
ToJson
(),
task_name
=
"商品销量报表(平台维度)"
},
user
);
return
new
JsonResult
(
new
{
success
=
true
});
}
catch
(
Exception
ex
)
{
return
new
JsonResult
(
new
{
success
=
false
,
message
=
ex
.
Message
});
}
}
}
}
\ 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