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
078077ba
Commit
078077ba
authored
Apr 23, 2019
by
lizefeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化无库仓商品日均算法
parent
b5cc4f3d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
184 additions
and
3 deletions
+184
-3
dc_not_stock.cs
AutoTurnOver.DB/dc_not_stock.cs
+126
-0
report.cs
AutoTurnOver.DB/report.cs
+9
-2
dc_not_stock.cs
AutoTurnOver.Models/dc_not_stock.cs
+49
-1
No files found.
AutoTurnOver.DB/dc_not_stock.cs
0 → 100644
View file @
078077ba
using
AutoTurnOver.Models
;
using
Dapper
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
AutoTurnOver.DB
{
public
class
dc_not_stock
:
connectionHelper
{
public
static
List
<
Models
.
dc_not_stock
>
List
(
dc_not_stock_search_dto
search
,
int
offset
,
int
limit
,
ref
int
total
,
string
order
=
""
,
string
sort
=
""
,
bool
isSum
=
false
)
{
try
{
var
sql
=
""
;
sql
=
@"select
t2.source,
t2.bailun_sku,
t_not_stock.product_inner_code,
t2.sku_title_cn as 'sku_title',
t2.suppliers_link,
t2.suppliers_name,
t3.oneday_sales,
t1.history_sevenday_sales,
t4.quantity_out_stock,
t5.usable_stock,
t4.quantity_purchase,
t2.moq,
t_not_stock.test_sales,
t_not_stock.success_sales,
t2.push_time
from dc_not_stock_goods_sales as t_not_stock
left join dc_base_sku as t2 on t_not_stock.product_inner_code = t2.product_inner_code
left join dc_auto_turnover as t1 on t2.bailun_sku =t1.bailun_sku and t_not_stock.warehouse_code = t1.warehouse_code
left join dc_auto_sales as t3 on t1.bailun_sku=t3.bailun_sku and t1.warehouse_code = t3.warehouse_code
left join dc_mid_transit as t4 on t1.bailun_sku = t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
left join dc_base_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
where 1=1
"
;
string
sqlCount
=
@"
select
count(1)
from dc_not_stock_goods_sales as t_not_stock
left join dc_base_sku as t2 on t_not_stock.product_inner_code = t2.product_inner_code
left join dc_auto_turnover as t1 on t2.bailun_sku =t1.bailun_sku and t_not_stock.warehouse_code = t1.warehouse_code
left join dc_auto_sales as t3 on t1.bailun_sku=t3.bailun_sku and t1.warehouse_code = t3.warehouse_code
left join dc_mid_transit as t4 on t1.bailun_sku = t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
left join dc_base_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
where 1=1
"
;
DynamicParameters
parameters
=
new
DynamicParameters
();
if
(
search
!=
null
)
{
if
(
search
.
goods_sales_min
!=
null
)
{
sql
+=
" and t_not_stock.success_sales>=@goods_sales_min "
;
sqlCount
+=
" and t_not_stock.success_sales>=@goods_sales_min "
;
parameters
.
Add
(
"goods_sales_min"
,
search
.
goods_sales_min
);
}
if
(
search
.
goods_sales_max
!=
null
)
{
sql
+=
" and t_not_stock.success_sales<@goods_sales_max "
;
sqlCount
+=
" and t_not_stock.success_sales<@goods_sales_max "
;
parameters
.
Add
(
"goods_sales_max"
,
search
.
goods_sales_max
);
}
if
(
search
.
is_distribution
==
true
)
{
sql
+=
" and t2.source in (5,9,10) "
;
sqlCount
+=
" and t2.source in (5,9,10) "
;
}
if
(
search
.
success_states
!=
null
)
{
if
(
search
.
success_states
==
1
)
{
// 成功
sql
+=
" and ( t_not_stock.success_sales>=1 and TIMESTAMPDIFF(day,t2.push_time,now())>=7 ) "
;
}
}
}
if
(
limit
>
10000
)
{
total
=
0
;
}
else
{
total
=
_connection
.
ExecuteScalar
<
int
>(
sqlCount
,
parameters
);
//设置默认排序字段
if
(
string
.
IsNullOrWhiteSpace
(
sort
))
sort
=
"t_not_stock.id"
;
if
(!
string
.
IsNullOrEmpty
(
sort
))
{
sql
+=
" order by "
+
sort
;
if
(!
string
.
IsNullOrEmpty
(
order
))
{
sql
+=
" "
+
order
;
}
else
{
sql
+=
" asc"
;
}
}
sql
+=
" limit "
+
offset
+
","
+
limit
;
}
var
obj
=
_connection
.
Query
<
Models
.
dc_not_stock
>(
sql
,
parameters
,
commandTimeout
:
0
);
return
obj
.
AsList
();
}
catch
(
Exception
ex
)
{
return
new
List
<
Models
.
dc_not_stock
>();
}
}
}
}
AutoTurnOver.DB/report.cs
View file @
078077ba
...
@@ -388,7 +388,7 @@ INSERT into dc_not_stock_goods_sales_temp(`product_inner_code`,`warehouse_code`,
...
@@ -388,7 +388,7 @@ INSERT into dc_not_stock_goods_sales_temp(`product_inner_code`,`warehouse_code`,
select
select
t2.product_inner_code,t1.warehouse_code,
t2.product_inner_code,t1.warehouse_code,
sum(case when TIMESTAMPDIFF(day,t2.push_time,now())<21 then t1.bailun_sku_quantity_ordered else 0 end) as 'test_sales', -- 推送之后 21 日的销量
sum(case when TIMESTAMPDIFF(day,t2.push_time,now())<21 then t1.bailun_sku_quantity_ordered else 0 end) as 'test_sales', -- 推送之后 21 日的销量
sum(case when TIMESTAMPDIFF(day,t
2.push
_time,now())<7 then t1.bailun_sku_quantity_ordered else 0 end) as 'success_sales' -- 最近7日销量
sum(case when TIMESTAMPDIFF(day,t
1.pay
_time,now())<7 then t1.bailun_sku_quantity_ordered else 0 end) as 'success_sales' -- 最近7日销量
from dc_base_oms_sku as t1
from dc_base_oms_sku as t1
left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
left join dc_auto_config_sku_warehouse as t3 on t1.bailun_sku = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code
left join dc_auto_config_sku_warehouse as t3 on t1.bailun_sku = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code
...
@@ -399,7 +399,14 @@ GROUP BY t2.product_inner_code,t1.warehouse_code
...
@@ -399,7 +399,14 @@ GROUP BY t2.product_inner_code,t1.warehouse_code
alter table dc_not_stock_goods_sales rename dc_not_stock_goods_salesTemp;
alter table dc_not_stock_goods_sales rename dc_not_stock_goods_salesTemp;
alter table dc_not_stock_goods_sales_temp rename dc_not_stock_goods_sales;
alter table dc_not_stock_goods_sales_temp rename dc_not_stock_goods_sales;
alter table dc_not_stock_goods_salesTemp rename dc_not_stock_goods_sales_temp;
alter table dc_not_stock_goods_salesTemp rename dc_not_stock_goods_sales_temp;
truncate table dc_not_stock_goods_sales_temp; "
,
commandTimeout
:
0
);
truncate table dc_not_stock_goods_sales_temp;
"
,
commandTimeout
:
0
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
...
...
AutoTurnOver.Models/dc_not_stock.cs
View file @
078077ba
...
@@ -52,17 +52,65 @@ namespace AutoTurnOver.Models
...
@@ -52,17 +52,65 @@ namespace AutoTurnOver.Models
public
int
moq
{
get
;
set
;
}
public
int
moq
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 推送之后21日的总销量
/// </summary>
public
decimal
test_sales
{
get
;
set
;
}
/// <summary>
/// 最近7日的销量
/// </summary>
public
decimal
success_sales
{
get
;
set
;
}
/// <summary>
/// 推送时间
/// </summary>
public
DateTime
?
push_time
{
get
;
set
;
}
/// <summary>
/// 是否成功
/// 是否成功
/// 推送超过7天,且日均大于等于1
/// </summary>
/// </summary>
public
bool
is_success
public
bool
is_success
{
{
get
get
{
{
return
history_sevenday_sales
>=
1
;
return
success_sales
>=
1
&&
(
DateTime
.
Now
-
push_time
.
Value
).
TotalDays
>=
7
;
}
}
/// <summary>
/// 是否失败
/// 推送超过21天 且没有出过单
/// </summary>
public
bool
is_fail
{
get
{
return
test_sales
<=
0
&&
(
DateTime
.
Now
-
push_time
.
Value
).
TotalDays
>=
21
;
}
}
}
}
}
}
public
class
dc_not_stock_search_dto
{
public
int
?
success_states
{
get
;
set
;
}
public
decimal
?
goods_sales_min
{
get
;
set
;
}
public
decimal
?
goods_sales_max
{
get
;
set
;
}
/// <summary>
/// 是否供应商推荐
/// </summary>
public
bool
?
is_supplier
{
get
;
set
;
}
/// <summary>
/// 是否分销
/// </summary>
public
bool
?
is_distribution
{
get
;
set
;
}
}
public
enum
source_enum
public
enum
source_enum
{
{
线上
=
1
,
线上
=
1
,
...
...
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