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
ce253bdd
Commit
ce253bdd
authored
Aug 18, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实际冗余修改
parent
a448e629
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
11 deletions
+56
-11
AutoTurnoverJob.java
...over/src/main/java/com/bailuntec/job/AutoTurnoverJob.java
+26
-11
AutoTurnoverTest.java
...ow/show-auto-turnover/src/test/java/AutoTurnoverTest.java
+30
-0
No files found.
data-show/show-auto-turnover/src/main/java/com/bailuntec/job/AutoTurnoverJob.java
View file @
ce253bdd
...
@@ -65,7 +65,6 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -65,7 +65,6 @@ public class AutoTurnoverJob extends PointJob {
2
,
2
,
TimeUnit
.
MINUTES
,
TimeUnit
.
MINUTES
,
new
LinkedBlockingQueue
<>(),
new
LinkedBlockingQueue
<>(),
Executors
.
defaultThreadFactory
(),
Executors
.
defaultThreadFactory
(),
...
@@ -540,7 +539,13 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -540,7 +539,13 @@ public class AutoTurnoverJob extends PointJob {
* 3. 如果到货后有真实销量,迅速用真实销量的曲线替代这个7%递减的曲线,这个递减曲线的影响马上清0
* 3. 如果到货后有真实销量,迅速用真实销量的曲线替代这个7%递减的曲线,这个递减曲线的影响马上清0
* 4. 通常缺货后,我们会用一个sku跟卖,这个sku销量会很高 我们的处理方法是,对这个sku做特殊销售规则 (这个人为做就行)
* 4. 通常缺货后,我们会用一个sku跟卖,这个sku销量会很高 我们的处理方法是,对这个sku做特殊销售规则 (这个人为做就行)
*/
*/
inventoryAvailableDays
=
fbaAdvise
(
turnoverSku
,
warehouseCode
,
hasMonitorFluctuation
,
forecastFluctuationList
,
recordTime
,
dcAutoTurnover
,
turnoverDays
,
autoForecastDay
,
forecastInventoryList
,
forecastInboundList
,
forecastSalesList
,
forecastShortSupplyList
,
forecastPurchaseAdvisedList
,
moqPurchaseAdvisedList
,
realInventory
,
totalSafeInventory
,
outStock
,
inventoryAvailableDays
,
totalSales
,
totalInbound
,
moqDecimal
,
historySalesList
,
forecastSalesExplainList
);
inventoryAvailableDays
=
fbaAdvise
(
turnoverSku
,
warehouseCode
,
hasMonitorFluctuation
,
forecastFluctuationList
,
recordTime
,
dcAutoTurnover
,
turnoverDays
,
autoForecastDay
,
forecastInventoryList
,
forecastInboundList
,
forecastSalesList
,
forecastShortSupplyList
,
forecastPurchaseAdvisedList
,
moqPurchaseAdvisedList
,
realInventory
,
totalSafeInventory
,
outStock
,
inventoryAvailableDays
,
totalSales
,
totalInbound
,
moqDecimal
,
historySalesList
,
forecastSalesExplainList
);
}
else
{
}
else
{
/*
/*
* 获取采购建议-普通仓库
* 获取采购建议-普通仓库
...
@@ -579,11 +584,11 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -579,11 +584,11 @@ public class AutoTurnoverJob extends PointJob {
if
(
forecastPurchaseAdvise
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
if
(
forecastPurchaseAdvise
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
//实际冗余
//实际冗余
if
(
forecastPurchaseAdvise
.
add
(
totalInbound
).
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
if
(
forecastPurchaseAdvise
.
add
(
dcAutoTurnover
.
getTurnoverInbound
()
).
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
dcAutoForecastFluctuationActual
=
new
DcAutoForecastFluctuation
();
dcAutoForecastFluctuationActual
=
new
DcAutoForecastFluctuation
();
//实际冗余
//实际冗余
dcAutoForecastFluctuationActual
.
setType
(
3
);
dcAutoForecastFluctuationActual
.
setType
(
3
);
dcAutoForecastFluctuationActual
.
setQuantity
(
Math
.
abs
(
forecastPurchaseAdvise
.
add
(
totalInbound
).
intValue
()));
dcAutoForecastFluctuationActual
.
setQuantity
(
Math
.
abs
(
forecastPurchaseAdvise
.
add
(
dcAutoTurnover
.
getTurnoverInbound
()
).
intValue
()));
}
}
//预计冗余
//预计冗余
else
{
else
{
...
@@ -1789,8 +1794,14 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -1789,8 +1794,14 @@ public class AutoTurnoverJob extends PointJob {
dcAutoTurnover
.
setTurnoverSales
(
totalSales
);
dcAutoTurnover
.
setTurnoverSales
(
totalSales
);
}
}
}
}
//采购建议 = 安全库存缺少值 + 今日的实际缺货 + 本次采购到货日期前一天的累计销量 - 本次采购到货日期累计到货数量 + 预计销量 - 今日的实际库存
BigDecimal
totalAdvised
=
totalSafeInventory
.
subtract
(
forecastInventoryList
.
get
(
j
>
0
?
j
-
1
:
0
))
//安全库存缺少值= 理论安全库存 - 预测库存
/*@deprecated 采购建议 = 安全库存缺少值 + 今日的实际缺货 + 本次采购到货日期前一天的累计销量 - 本次采购到货日期累计到货数量 + 预计销量 - 今日的实际库存 */
/*采购建议 = 安全库存 + 今日的实际缺货 + 本次采购到货日期前一天的累计销量 - 本次采购到货日期累计到货数量 + 预计销量 - 今日的实际库存 */
BigDecimal
totalAdvised
=
totalSafeInventory
//20200818
/*@deprecated 安全库存缺少值= 理论安全库存 - 预测库存*/
// .subtract(forecastInventoryList.get(j > 0 ? j - 1 : 0))
.
add
(
BigDecimal
.
valueOf
(
outStock
.
longValue
()))
//今天的实际缺货
.
add
(
BigDecimal
.
valueOf
(
outStock
.
longValue
()))
//今天的实际缺货
.
add
(
totalSales
)
//累计销量
.
add
(
totalSales
)
//累计销量
.
subtract
(
BigDecimal
.
valueOf
(
totalInbound
.
doubleValue
()))
//累计到货
.
subtract
(
BigDecimal
.
valueOf
(
totalInbound
.
doubleValue
()))
//累计到货
...
@@ -1920,7 +1931,7 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -1920,7 +1931,7 @@ public class AutoTurnoverJob extends PointJob {
//库存 - 销量, 继续跑
//库存 - 销量, 继续跑
if
(
j
>=
turnoverDays
)
{
if
(
j
>=
turnoverDays
)
{
BigDecimal
totalAdvised
=
BigDecimal
.
ZERO
;
BigDecimal
totalAdvised
=
BigDecimal
.
ZERO
;
B
oolean
firstAdvice
=
true
;
b
oolean
firstAdvice
=
true
;
if
(
j
==
turnoverDays
)
{
if
(
j
==
turnoverDays
)
{
if
(
warehouseCode
.
equals
(
Constant
.
WAREHOUSE_JIT
)
&&
(
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_1
)
||
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_2
)))
{
if
(
warehouseCode
.
equals
(
Constant
.
WAREHOUSE_JIT
)
&&
(
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_1
)
||
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_2
)))
{
BigDecimal
saveDays
=
saveDaysMap
.
get
(
"saveDays"
);
BigDecimal
saveDays
=
saveDaysMap
.
get
(
"saveDays"
);
...
@@ -1967,7 +1978,9 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -1967,7 +1978,9 @@ public class AutoTurnoverJob extends PointJob {
BigDecimal
forecastInbound
=
BigDecimal
.
ZERO
;
BigDecimal
forecastInbound
=
BigDecimal
.
ZERO
;
if
(
saveDays
!=
null
)
{
if
(
saveDays
!=
null
)
{
totalSales
=
dcAutoTurnover
.
getDailyWeightedSales
().
multiply
(
saveDays
);
totalSales
=
dcAutoTurnover
.
getDailyWeightedSales
().
multiply
(
saveDays
);
totalAdvised
=
totalSales
.
subtract
(
outStock
>
0
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
realInventory
.
longValue
()))
//真实库存,如果缺货就不减
totalAdvised
=
totalSales
//真实库存,如果缺货就不减
.
subtract
(
outStock
>
0
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
realInventory
.
longValue
()))
.
subtract
(
outStock01
>
0
?
BigDecimal
.
ZERO
:
((
dcBaseStock
!=
null
&&
dcBaseStock
.
getUsableStock
()
!=
null
)
?
BigDecimal
.
valueOf
(
dcBaseStock
.
getUsableStock
())
:
BigDecimal
.
ZERO
))
//广州014仓库存
.
subtract
(
outStock01
>
0
?
BigDecimal
.
ZERO
:
((
dcBaseStock
!=
null
&&
dcBaseStock
.
getUsableStock
()
!=
null
)
?
BigDecimal
.
valueOf
(
dcBaseStock
.
getUsableStock
())
:
BigDecimal
.
ZERO
))
//广州014仓库存
.
subtract
(
BigDecimal
.
valueOf
(
purchase
+
transfer
));
//广州001仓在途数
.
subtract
(
BigDecimal
.
valueOf
(
purchase
+
transfer
));
//广州001仓在途数
firstAdvice
=
false
;
firstAdvice
=
false
;
...
@@ -1977,8 +1990,10 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -1977,8 +1990,10 @@ public class AutoTurnoverJob extends PointJob {
}
}
}
}
if
(
firstAdvice
)
{
if
(
firstAdvice
)
{
//采购建议 = 安全库存缺少值 + 今日的实际缺货 + 本次采购到货日期前一天的累计销量 - 本次采购到货日期累计到货数量 + 预计销量
//采购建议 = 安全库存 + 今日的实际缺货 + 本次采购到货日期前一天的累计销量 - 本次采购到货日期累计到货数量 + 预计销量
totalAdvised
=
totalSafeInventory
.
subtract
(
forecastInventoryList
.
get
(
j
>
0
?
j
-
1
:
0
))
//安全库存缺少值= 理论安全库存 - 预测库存
/*@deprecated 采购建议 = 安全库存缺少值 + 今日的实际缺货 + 本次采购到货日期前一天的累计销量 - 本次采购到货日期累计到货数量 + 预计销量*/
totalAdvised
=
totalSafeInventory
// .subtract(forecastInventoryList.get(j > 0 ? j - 1 : 0))//安全库存缺少值= 理论安全库存 - 预测库存
.
add
(
BigDecimal
.
valueOf
(
outStock
.
longValue
()))
//今天的实际缺货
.
add
(
BigDecimal
.
valueOf
(
outStock
.
longValue
()))
//今天的实际缺货
.
add
(
totalSales
)
//累计销量
.
add
(
totalSales
)
//累计销量
.
subtract
(
BigDecimal
.
valueOf
(
totalInbound
.
doubleValue
()))
//累计到货
.
subtract
(
BigDecimal
.
valueOf
(
totalInbound
.
doubleValue
()))
//累计到货
...
@@ -1993,7 +2008,7 @@ public class AutoTurnoverJob extends PointJob {
...
@@ -1993,7 +2008,7 @@ public class AutoTurnoverJob extends PointJob {
totalAdvised
=
totalAdvised
.
setScale
(
0
,
RoundingMode
.
HALF_EVEN
);
totalAdvised
=
totalAdvised
.
setScale
(
0
,
RoundingMode
.
HALF_EVEN
);
}
}
forecastPurchaseAdvisedList
.
add
(
totalAdvised
);
forecastPurchaseAdvisedList
.
add
(
totalAdvised
);
if
(
totalAdvised
.
compareTo
(
moqDecimal
)
==
1
)
{
if
(
totalAdvised
.
compareTo
(
moqDecimal
)
>
0
)
{
moqPurchaseAdvisedList
.
add
(
totalAdvised
);
moqPurchaseAdvisedList
.
add
(
totalAdvised
);
}
else
if
(
totalAdvised
.
compareTo
(
BigDecimal
.
ZERO
)
!=
1
)
{
}
else
if
(
totalAdvised
.
compareTo
(
BigDecimal
.
ZERO
)
!=
1
)
{
moqPurchaseAdvisedList
.
add
(
BigDecimal
.
ZERO
);
moqPurchaseAdvisedList
.
add
(
BigDecimal
.
ZERO
);
...
...
data-show/show-auto-turnover/src/test/java/AutoTurnoverTest.java
View file @
ce253bdd
...
@@ -13,6 +13,7 @@ import com.dangdang.ddframe.job.api.ShardingContext;
...
@@ -13,6 +13,7 @@ import com.dangdang.ddframe.job.api.ShardingContext;
import
com.dangdang.ddframe.job.executor.ShardingContexts
;
import
com.dangdang.ddframe.job.executor.ShardingContexts
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.Period
;
import
java.time.Period
;
...
@@ -137,4 +138,33 @@ public class AutoTurnoverTest {
...
@@ -137,4 +138,33 @@ public class AutoTurnoverTest {
EasyExcel
.
read
(
filePath
,
DcAutoTurnoverExcel
.
class
,
new
ExcelListener
()).
sheet
().
doRead
();
EasyExcel
.
read
(
filePath
,
DcAutoTurnoverExcel
.
class
,
new
ExcelListener
()).
sheet
().
doRead
();
}
}
@Test
public
void
testXX
()
{
DcBaseStock
dcBaseStock
=
SessionUtil
.
getSession
().
getMapper
(
DcBaseStockMapper
.
class
)
.
selectOneByExample
(
DcBaseStockExample
.
newAndCreateCriteria
()
.
andBailunSkuEqualTo
(
"N-10ML-MX-TOP-JSP"
)
.
andWarehouseCodeEqualTo
(
"GZBLWH"
)
.
example
());
try
{
AutoTurnoverJob
autoTurnoverJob
=
new
AutoTurnoverJob
();
autoTurnoverJob
.
autoTurnoverFromStock
(
DateTimeFormatter
.
ofPattern
(
CommonConstant
.
DATE_FORMAT
).
format
(
LocalDate
.
now
()),
dcBaseStock
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
testBigDecimal
()
{
DcBaseStock
dcBaseStock
=
new
DcBaseStock
();
dcBaseStock
.
setInWarehouse
(
1
);
this
.
add
(
dcBaseStock
);
System
.
out
.
println
(
dcBaseStock
.
getInWarehouse
());
}
public
void
add
(
DcBaseStock
dcBaseStock
)
{
dcBaseStock
.
setInWarehouse
(
2
);
}
}
}
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