Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dc-java
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
huluobin
dc-java
Commits
252f5ec1
Commit
252f5ec1
authored
May 13, 2019
by
wutong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自动周转预计缺货预计冗余规则修改.
parent
9ebaa48e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
21 deletions
+50
-21
AutoTurnoverJob.java
...over/src/main/java/com/bailuntec/job/AutoTurnoverJob.java
+49
-20
AutoTurnoverTest.java
...ow/show-auto-turnover/src/test/java/AutoTurnoverTest.java
+1
-1
No files found.
data-show/show-auto-turnover/src/main/java/com/bailuntec/job/AutoTurnoverJob.java
View file @
252f5ec1
...
@@ -376,7 +376,9 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -376,7 +376,9 @@ public class AutoTurnoverJob extends PointJob {
/*
/*
* 自动下单管理的冗余-缺货等异常提醒
* 自动下单管理的冗余-缺货等异常提醒
*/
*/
unusualFluctuation
(
dcAutoConfigSkuWarehouse
,
turnoverSku
,
warehouseCode
,
dcAutoTurnover
,
avgHistoryThreedaySales
,
forecastFluctuationList
);
if
(
hasMonitorFluctuation
)
{
unusualFluctuation
(
totalSafeInventory
,
turnoverDays
,
recordTime
,
dcAutoConfigSkuWarehouse
,
turnoverSku
,
warehouseCode
,
dcAutoTurnover
,
avgHistoryThreedaySales
,
forecastFluctuationList
,
forecastShortSupplyList
,
forecastInventoryList
);
}
//拿一下2倍周转期内的入库总数
//拿一下2倍周转期内的入库总数
Integer
quantityInbound
=
0
;
Integer
quantityInbound
=
0
;
...
@@ -445,7 +447,7 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -445,7 +447,7 @@ public class AutoTurnoverJob extends PointJob {
dcAutoTurnover
.
setStockUpDays
(
stockUpDays
);
dcAutoTurnover
.
setStockUpDays
(
stockUpDays
);
dcAutoTurnover
.
setStockUpSales
(
stockUpSales
);
dcAutoTurnover
.
setStockUpSales
(
stockUpSales
);
dcAutoTurnover
.
setQuantityBeginAdvise
(
forecastPurchaseAdvisedList
.
get
(
0
));
dcAutoTurnover
.
setQuantityBeginAdvise
(
forecastPurchaseAdvisedList
.
get
(
0
));
dcAutoTurnover
.
setForecastTurnoverdaySales
(
avgForecast
Fourteend
aySales
.
divide
(
BigDecimal
.
valueOf
(
turnoverDays
),
3
,
RoundingMode
.
HALF_EVEN
));
dcAutoTurnover
.
setForecastTurnoverdaySales
(
avgForecast
TurnoverD
aySales
.
divide
(
BigDecimal
.
valueOf
(
turnoverDays
),
3
,
RoundingMode
.
HALF_EVEN
));
dcAutoTurnover
.
setSalesExplainDetails
(
forecastSalesExplainList
.
toString
());
dcAutoTurnover
.
setSalesExplainDetails
(
forecastSalesExplainList
.
toString
());
dcAutoTurnover
.
setHistorySevendaySales
(
avgHistorySevendaySales
);
dcAutoTurnover
.
setHistorySevendaySales
(
avgHistorySevendaySales
);
dcAutoTurnover
.
setHistoryFourteendaySales
(
avgHistoryFourteendaySales
);
dcAutoTurnover
.
setHistoryFourteendaySales
(
avgHistoryFourteendaySales
);
...
@@ -602,13 +604,42 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -602,13 +604,42 @@ public class AutoTurnoverJob extends PointJob {
/**
/**
* 不正常的波动
* 不正常的波动
* 实际缺货的,预计缺货
* 实际缺货的,预计缺货
* 实际冗余的,预计冗余
* 实际冗余的,预计冗余(库存> 销量 + 安全库存)
*
* 波动提醒优先级 --> 实际缺货-实际冗余-预计缺货-预计冗余
* @param warehouseCode
* @param dcAutoTurnover
* @param forecastFluctuationList
*/
*/
private
void
unusualFluctuation
(
DcAutoConfigSkuWarehouse
dcAutoConfigSkuWarehouse
,
DcBaseSku
turnoverSku
,
String
warehouseCode
,
DcAutoTurnover
dcAutoTurnover
,
BigDecimal
avgHistoryThreedaySales
,
List
<
DcAutoForecastFluctuation
>
forecastFluctuationList
)
{
private
void
unusualFluctuation
(
BigDecimal
totalSafeInventory
,
Integer
turnoverDays
,
LocalDate
recordTime
,
DcAutoConfigSkuWarehouse
dcAutoConfigSkuWarehouse
,
DcBaseSku
turnoverSku
,
String
warehouseCode
,
DcAutoTurnover
dcAutoTurnover
,
BigDecimal
avgHistoryThreedaySales
,
List
<
DcAutoForecastFluctuation
>
forecastFluctuationList
,
List
<
BigDecimal
>
forecastShortSupplyList
,
List
<
BigDecimal
>
forecastInventoryList
)
{
int
days
=
0
;
int
index
=
-
1
;
for
(
int
i
=
0
;
i
<=
turnoverDays
;
i
++)
{
if
(
forecastShortSupplyList
.
get
(
i
).
compareTo
(
BigDecimal
.
ZERO
)
==
1
)
{
if
(
forecastShortSupplyList
.
get
(
i
).
compareTo
(
BigDecimal
.
ZERO
)
==
1
)
{
days
++;
if
(
index
<
0
)
{
index
=
i
;
}
}
else
if
(
index
>
0
)
{
handleForecastFluctuation
(
2
,
forecastFluctuationList
,
recordTime
,
days
,
index
);
days
=
0
;
index
=
-
1
;
break
;
}
}
}
for
(
int
i
=
0
;
i
<=
turnoverDays
;
i
++)
{
if
(
forecastInventoryList
.
get
(
i
).
compareTo
(
BigDecimal
.
ZERO
)
==
1
)
{
if
(
i
<
turnoverDays
&&
forecastInventoryList
.
get
(
i
).
compareTo
(
totalSafeInventory
)
==
1
)
{
days
++;
if
(
index
<
0
)
{
index
=
i
;
}
}
else
if
(
index
>
0
)
{
handleForecastFluctuation
(
4
,
forecastFluctuationList
,
recordTime
,
days
,
index
);
break
;
}
}
}
//status` '监控状态, 默认0监控, 停止监控1',
//status` '监控状态, 默认0监控, 停止监控1',
try
{
try
{
DcAutoForecastFluctuationMapper
mapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoForecastFluctuationMapper
.
class
);
DcAutoForecastFluctuationMapper
mapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoForecastFluctuationMapper
.
class
);
...
@@ -619,16 +650,14 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -619,16 +650,14 @@ public class AutoTurnoverJob extends PointJob {
if
(
forecastFluctuationList
!=
null
&&
forecastFluctuationList
.
size
()
>
0
)
{
if
(
forecastFluctuationList
!=
null
&&
forecastFluctuationList
.
size
()
>
0
)
{
//拿最早的时间 + 最晚的时间, SKU-仓库维度只放一条
//拿最早的时间 + 最晚的时间, SKU-仓库维度只放一条
DcAutoForecastFluctuation
dcAutoForecastFluctuation
=
forecastFluctuationList
.
get
(
0
);
DcAutoForecastFluctuation
dcAutoForecastFluctuation
=
forecastFluctuationList
.
get
(
0
);
dcAutoForecastFluctuation
.
setEndTime
(
forecastFluctuationList
.
get
(
forecastFluctuationList
.
size
()
-
1
).
getEndTime
());
dcAutoForecastFluctuation
.
setStartTime
(
forecastFluctuationList
.
get
(
0
).
getStartTime
());
dcAutoForecastFluctuation
.
setEndTime
(
forecastFluctuationList
.
get
(
0
).
getEndTime
());
dcAutoForecastFluctuation
.
setBailunSku
(
turnoverSku
.
getBailunSku
());
dcAutoForecastFluctuation
.
setBailunSku
(
turnoverSku
.
getBailunSku
());
dcAutoForecastFluctuation
.
setWarehouseCode
(
warehouseCode
);
dcAutoForecastFluctuation
.
setWarehouseCode
(
warehouseCode
);
dcAutoForecastFluctuation
.
setWarehouseName
(
dcAutoTurnover
.
getWarehouseName
());
dcAutoForecastFluctuation
.
setWarehouseName
(
dcAutoTurnover
.
getWarehouseName
());
dcAutoForecastFluctuation
.
setAvgSalesThree
(
avgHistoryThreedaySales
);
dcAutoForecastFluctuation
.
setAvgSalesThree
(
avgHistoryThreedaySales
);
DcAutoForecastFluctuation
dcAutoForecastFluctuationSelected
=
mapper
.
selectOneByExample
(
DcAutoForecastFluctuationExample
.
newAndCreateCriteria
().
andBailunSkuEqualTo
(
turnoverSku
.
getBailunSku
()).
andWarehouseCodeEqualTo
(
warehouseCode
).
example
());
int
i
=
mapper
.
updateByExampleSelective
(
dcAutoForecastFluctuation
,
DcAutoForecastFluctuationExample
.
newAndCreateCriteria
().
andBailunSkuEqualTo
(
dcAutoForecastFluctuation
.
getBailunSku
()).
andWarehouseCodeEqualTo
(
dcAutoForecastFluctuation
.
getWarehouseCode
()).
example
());
if
(
dcAutoForecastFluctuationSelected
!=
null
)
{
if
(
i
==
0
)
{
dcAutoForecastFluctuation
.
setStartTime
(
dcAutoForecastFluctuationSelected
.
getStartTime
());
mapper
.
updateByExampleSelective
(
dcAutoForecastFluctuation
,
DcAutoForecastFluctuationExample
.
newAndCreateCriteria
().
andBailunSkuEqualTo
(
dcAutoForecastFluctuation
.
getBailunSku
()).
andWarehouseCodeEqualTo
(
dcAutoForecastFluctuation
.
getWarehouseCode
()).
example
());
}
else
{
mapper
.
insertSelective
(
dcAutoForecastFluctuation
);
mapper
.
insertSelective
(
dcAutoForecastFluctuation
);
}
}
}
}
...
@@ -1213,7 +1242,7 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -1213,7 +1242,7 @@ public class AutoTurnoverJob extends PointJob {
* 如果forecastShortSupplyList.get(j) > 0, 就是预测断货
* 如果forecastShortSupplyList.get(j) > 0, 就是预测断货
* 1实际断货2预计断货3实际冗余4预计冗余
* 1实际断货2预计断货3实际冗余4预计冗余
*/
*/
if
(
j
<=
turnoverDays
&&
hasMonitorFluctuation
)
{
/*
if (j <= turnoverDays && hasMonitorFluctuation) {
BigDecimal forecastShortSupplyDayJ = j == 0 ? forecastShortSupplyList.get(j) : forecastShortSupplyList.get(j).subtract(forecastShortSupplyList.get(j - 1));
BigDecimal forecastShortSupplyDayJ = j == 0 ? forecastShortSupplyList.get(j) : forecastShortSupplyList.get(j).subtract(forecastShortSupplyList.get(j - 1));
if (forecastInventory.compareTo(totalSafeInventory.add(forecastSalesList.get(j))) == -1) {
if (forecastInventory.compareTo(totalSafeInventory.add(forecastSalesList.get(j))) == -1) {
//预测断货, 需要检查前一天有没有预测冗余
//预测断货, 需要检查前一天有没有预测冗余
...
@@ -1248,7 +1277,7 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -1248,7 +1277,7 @@ public class AutoTurnoverJob extends PointJob {
forecastFluctuationDays = 0;
forecastFluctuationDays = 0;
forecastFluctuationIndex = -1;
forecastFluctuationIndex = -1;
}
}
}
}
*/
//--------- 预测冗余, 预测断货 ---end
//--------- 预测冗余, 预测断货 ---end
forecastInventoryList
.
set
(
j
,
forecastInventory
.
compareTo
(
BigDecimal
.
ZERO
)
==
-
1
?
BigDecimal
.
ZERO
:
forecastInventory
.
setScale
(
3
,
RoundingMode
.
HALF_EVEN
));
forecastInventoryList
.
set
(
j
,
forecastInventory
.
compareTo
(
BigDecimal
.
ZERO
)
==
-
1
?
BigDecimal
.
ZERO
:
forecastInventory
.
setScale
(
3
,
RoundingMode
.
HALF_EVEN
));
//在两倍周转期内, 如果预测销量 <= 库存, 那么又是可用的一天
//在两倍周转期内, 如果预测销量 <= 库存, 那么又是可用的一天
...
@@ -1330,8 +1359,8 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -1330,8 +1359,8 @@ public class AutoTurnoverJob extends PointJob {
private
void
handleForecastFluctuation
(
Integer
type
,
List
<
DcAutoForecastFluctuation
>
forecastFluctuationList
,
LocalDate
recordTime
,
int
forecastFluctuationDays
,
int
forecastFluctuationIndex
)
{
private
void
handleForecastFluctuation
(
Integer
type
,
List
<
DcAutoForecastFluctuation
>
forecastFluctuationList
,
LocalDate
recordTime
,
int
forecastFluctuationDays
,
int
forecastFluctuationIndex
)
{
DcAutoForecastFluctuation
forecastFluctuation
=
new
DcAutoForecastFluctuation
();
DcAutoForecastFluctuation
forecastFluctuation
=
new
DcAutoForecastFluctuation
();
forecastFluctuation
.
setStartTime
(
recordTime
.
plusDays
(
forecastFluctuationIndex
+
1
));
forecastFluctuation
.
setStartTime
(
recordTime
.
plusDays
(
forecastFluctuationIndex
));
forecastFluctuation
.
setEndTime
(
forecastFluctuation
.
getStartTime
().
plusDays
(
Math
.
abs
(
forecastFluctuationDays
)
-
2
));
forecastFluctuation
.
setEndTime
(
forecastFluctuation
.
getStartTime
().
plusDays
(
Math
.
abs
(
forecastFluctuationDays
)));
forecastFluctuation
.
setType
(
type
);
forecastFluctuation
.
setType
(
type
);
forecastFluctuationList
.
add
(
forecastFluctuation
);
forecastFluctuationList
.
add
(
forecastFluctuation
);
}
}
...
@@ -1427,7 +1456,7 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -1427,7 +1456,7 @@ public class AutoTurnoverJob extends PointJob {
* 如果库存数量 > 安全库存 + 预计销量, 就是预测冗余;
* 如果库存数量 > 安全库存 + 预计销量, 就是预测冗余;
* 如果forecastShortSupplyList.get(j) > 0, 就是预测断货
* 如果forecastShortSupplyList.get(j) > 0, 就是预测断货
*/
*/
if
(
j
<=
turnoverDays
&&
hasMonitorFluctuation
)
{
/*
if (j <= turnoverDays && hasMonitorFluctuation) {
if (forecastInventory.compareTo(totalSafeInventory.add(forecastSalesList.get(j))) == -1) {
if (forecastInventory.compareTo(totalSafeInventory.add(forecastSalesList.get(j))) == -1) {
//预测断货, 需要检查前一天有没有预测冗余
//预测断货, 需要检查前一天有没有预测冗余
if (forecastFluctuationDays > 0) {
if (forecastFluctuationDays > 0) {
...
@@ -1461,7 +1490,7 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -1461,7 +1490,7 @@ public class AutoTurnoverJob extends PointJob {
forecastFluctuationDays = 0;
forecastFluctuationDays = 0;
forecastFluctuationIndex = -1;
forecastFluctuationIndex = -1;
}
}
}
}
*/
//--------- 预测冗余, 预测断货 ---end
//--------- 预测冗余, 预测断货 ---end
}
}
return
inventoryAvailableDays
;
return
inventoryAvailableDays
;
...
...
data-show/show-auto-turnover/src/test/java/AutoTurnoverTest.java
View file @
252f5ec1
...
@@ -52,7 +52,7 @@ public class AutoTurnoverTest {
...
@@ -52,7 +52,7 @@ public class AutoTurnoverTest {
// dcBaseStock = mapper.selectOneByExample(DcBaseStockExample.newAndCreateCriteria().andBailunSkuEqualTo("322572421").andWarehouseCodeEqualTo("QYBLZZ").example());
// dcBaseStock = mapper.selectOneByExample(DcBaseStockExample.newAndCreateCriteria().andBailunSkuEqualTo("322572421").andWarehouseCodeEqualTo("QYBLZZ").example());
// dcBaseStock = mapper.selectOneByExample(DcBaseStockExample.newAndCreateCriteria().andBailunSkuEqualTo("232232601").andWarehouseCodeEqualTo("CHUKFBA").example());
// dcBaseStock = mapper.selectOneByExample(DcBaseStockExample.newAndCreateCriteria().andBailunSkuEqualTo("232232601").andWarehouseCodeEqualTo("CHUKFBA").example());
// dcBaseStock = mapper.selectOneByExample(DcBaseStockExample.newAndCreateCriteria().andBailunSkuEqualTo("213789601").andWarehouseCodeEqualTo("GZBLWH").example());
// dcBaseStock = mapper.selectOneByExample(DcBaseStockExample.newAndCreateCriteria().andBailunSkuEqualTo("213789601").andWarehouseCodeEqualTo("GZBLWH").example());
dcBaseStock
=
mapper
.
selectOneByExample
(
DcBaseStockExample
.
newAndCreateCriteria
().
andBailunSkuEqualTo
(
"
435611919"
).
andWarehouseCodeEqualTo
(
"GB4PXBL
"
).
example
());
dcBaseStock
=
mapper
.
selectOneByExample
(
DcBaseStockExample
.
newAndCreateCriteria
().
andBailunSkuEqualTo
(
"
ND016"
).
andWarehouseCodeEqualTo
(
"GZBLWH
"
).
example
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
}
finally
{
...
...
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