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
2a833c89
Commit
2a833c89
authored
Feb 03, 2021
by
泽锋 李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init 平均值计算
parent
98b9dadb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
5 deletions
+49
-5
AverageTargetBackgrounService.cs
...r.Purchase.AverageTarget/AverageTargetBackgrounService.cs
+15
-0
PurchaseAverageTargetServices.cs
AutoTurnOver.Services/PurchaseAverageTargetServices.cs
+34
-5
No files found.
AutoTurnOver.Purchase.AverageTarget/AverageTargetBackgrounService.cs
View file @
2a833c89
...
...
@@ -34,6 +34,21 @@ namespace AutoTurnOver.Purchase.AverageTarget
Task
.
Factory
.
StartNew
(()
=>
{
try
{
Console
.
WriteLine
(
$"开始 init2 ,线程Id:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
,
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
);
PurchaseAverageTargetServices
.
Calculation
(
360
);
Console
.
WriteLine
(
$"结束 init2,线程Id:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
,
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
);
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
"周销售系数计算异常"
+
ex
.
Message
);
Console
.
WriteLine
(
"周销售系数计算异常"
+
ex
.
StackTrace
);
}
});
Task
.
Factory
.
StartNew
(()
=>
{
while
(
true
)
{
try
...
...
AutoTurnOver.Services/PurchaseAverageTargetServices.cs
View file @
2a833c89
...
...
@@ -19,7 +19,7 @@ namespace AutoTurnOver.Services
/// </summary>
public
static
int
_seed_count
=
5
;
public
static
void
Calculation
()
public
static
void
Calculation
(
int
day
=
30
)
{
MyMySqlConnection
conn
=
connectionHelper
.
_connection
;
...
...
@@ -37,9 +37,16 @@ namespace AutoTurnOver.Services
{
// 获取最近2天发送变化的SKU 用于计算
var
chageSkuList
=
AveragePurchase
.
GetChangeSku
(
30
);
var
chageSkuList
=
AveragePurchase
.
GetChangeSku
(
day
);
foreach
(
var
skuItem
in
chageSkuList
)
{
// 清空记录,重新记录数据源
conn
.
Execute
(
" delete from dc_base_order_data_source where bailun_sku_warehouse_code=@bailun_sku_warehouse_code and order_type=@order_type "
,
new
{
bailun_sku_warehouse_code
=
$"
{
skuItem
.
bailun_sku
}{
skuItem
.
warehouse_code
}
"
,
order_type
=
"采购单-签收天数计算"
});
// 判断是否jit
var
has_jit
=
((
skuItem
.
buyer_name
==
"张莹霞"
||
skuItem
.
buyer_name
==
"张莹霞1"
)
&&
skuItem
.
warehouse_code
==
"GZBLWH"
);
...
...
@@ -75,24 +82,46 @@ namespace AutoTurnOver.Services
foreach
(
var
itemArrivalList
in
arrivalList
.
GroupBy
(
s
=>
s
.
purchase_id
))
{
var
tempPurchase
=
purchaseList
.
SingleOrDefault
(
s
=>
s
.
purchase_id
==
itemArrivalList
.
Key
);
var
temp_s_delivery_days
=
0
;
if
(
tempPurchase
.
pay_type
==
1
)
{
delivery_days
+=
(
int
)
Math
.
Ceiling
((
itemArrivalList
.
Min
(
s
=>
s
.
update_time
)
-
tempPurchase
.
pay_time
).
Value
.
TotalHours
/
24
);
temp_s_delivery_days
=
(
int
)
Math
.
Ceiling
((
itemArrivalList
.
Min
(
s
=>
s
.
update_time
)
-
tempPurchase
.
pay_time
).
Value
.
TotalHours
/
24
);
}
else
{
delivery_days
+
=
(
int
)
Math
.
Ceiling
((
itemArrivalList
.
Min
(
s
=>
s
.
update_time
)
-
tempPurchase
.
confirm_time
).
Value
.
TotalHours
/
24
);
temp_s_delivery_days
=
(
int
)
Math
.
Ceiling
((
itemArrivalList
.
Min
(
s
=>
s
.
update_time
)
-
tempPurchase
.
confirm_time
).
Value
.
TotalHours
/
24
);
}
delivery_days
+=
temp_s_delivery_days
;
conn
.
Insert
(
new
dc_base_order_data_source
{
bailun_sku
=
skuItem
.
bailun_sku
,
warehouse_code
=
skuItem
.
warehouse_code
,
logistics_code
=
""
,
bailun_sku_warehouse_code
=
$"
{
skuItem
.
bailun_sku
}{
skuItem
.
warehouse_code
}
"
,
bale_days
=
1
,
logistics_name
=
""
,
order_no
=
itemArrivalList
.
Key
,
order_type
=
"采购单-签收天数计算"
,
put_days
=
0
,
sign_days
=
temp_s_delivery_days
,
transport_type
=
""
});
}
// 平均采购交期
var
temp_delivery_days
=
delivery_days
/
purchaseList
.
Count
;
//够5个单才算平均值给系统用
// 如果是海外仓暂时不算,否则算出来30几天的平均值,影响计划单交期调整的推进
if
(
purchase_order_count
>=
5
&&
skuItem
.
hq_type
==
"国内仓"
)
{
data
.
delivery_days
=
temp_delivery_days
;
}
else
{
...
...
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