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
58071f30
Commit
58071f30
authored
Jan 12, 2021
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
# 数据中心 prod
parent
778b7488
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
217 deletions
+18
-217
db-dev.properties
data-common/src/main/resources/db-dev.properties
+0
-4
mybatis-config.xml
data-common/src/main/resources/mybatis-config.xml
+2
-2
mybatis-readonly-config.xml
data-common/src/main/resources/mybatis-readonly-config.xml
+0
-40
AutoTurnoverJob.java
...over/src/main/java/com/bailuntec/job/AutoTurnoverJob.java
+12
-164
AutoTurnoverServiceImpl.java
...a/com/bailuntec/service/impl/AutoTurnoverServiceImpl.java
+2
-5
AutoTurnoverTest.java
...ow/show-auto-turnover/src/test/java/AutoTurnoverTest.java
+2
-2
No files found.
data-common/src/main/resources/db-dev.properties
View file @
58071f30
...
...
@@ -2,7 +2,3 @@ driver=com.mysql.jdbc.Driver
url
=
jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true
username
=
root
password
=
#7kfnymAM$Y9-Ntf
readonly-url
=
jdbc:mysql://gz-cdbrg-qdyec2j3.sql.tencentcdb.com:59667/bailun_datacenter?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
readonly-username
=
root
readonly-password
=
#7kfnymAM$Y9-Ntf
data-common/src/main/resources/mybatis-config.xml
View file @
58071f30
...
...
@@ -5,8 +5,8 @@
<configuration>
<!--<properties resource="db-tj.properties"/>-->
<
properties
resource=
"db-dev.properties"
/
>
<
!-- <properties resource="db-prod.properties"/>--
>
<
!-- <properties resource="db-dev.properties"/>--
>
<
properties
resource=
"db-prod.properties"
/
>
<settings>
<setting
name=
"mapUnderscoreToCamelCase"
value=
"true"
/>
</settings>
...
...
data-common/src/main/resources/mybatis-readonly-config.xml
deleted
100644 → 0
View file @
778b7488
<!--<?xml version="1.0" encoding="UTF-8" ?>-->
<!--<!DOCTYPE configuration-->
<!-- PUBLIC "-//mybatis.org//DTD Config 3.0//EN"-->
<!-- "http://mybatis.org/dtd/mybatis-3-config.dtd">-->
<!--<configuration>-->
<!-- <!–<properties resource="db-tj.properties"/>–>-->
<!-- <properties resource="readonly-db-dev.properties"/>-->
<!-- <!– <properties resource="readonly-db-prod.properties"/>–>-->
<!-- <settings>-->
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/>-->
<!-- </settings>-->
<!-- <typeAliases>-->
<!-- <typeAlias type="com.bailuntec.support.DruidDataSourceFactory" alias="DRUID"/>-->
<!-- <package name="com.bailuntec.domain"/>-->
<!-- </typeAliases>-->
<!-- <!– <plugins>–>-->
<!-- <!– <plugin interceptor="com.bailuntec.support.SqlCostInterceptor"/>–>-->
<!-- <!– </plugins>–>-->
<!-- <environments default="work">-->
<!-- <environment id="work">-->
<!-- <transactionManager type="JDBC"/>-->
<!-- <dataSource type="DRUID">-->
<!-- <property name="driver" value="${driver}"/>-->
<!-- <property name="url" value="${url}"/>-->
<!-- <property name="username" value="${username}"/>-->
<!-- <property name="password" value="${password}"/>-->
<!-- </dataSource>-->
<!-- </environment>-->
<!-- </environments>-->
<!-- <mappers>-->
<!-- <package name="com.bailuntec.mapper"/>-->
<!-- </mappers>-->
<!--</configuration>-->
data-show/show-auto-turnover/src/main/java/com/bailuntec/job/AutoTurnoverJob.java
View file @
58071f30
...
...
@@ -1178,16 +1178,7 @@ public class AutoTurnoverJob extends PointJob {
}
}
//自定义Comparator对象,自定义排序
Comparator
c
=
new
Comparator
<
BigDecimal
>()
{
@Override
public
int
compare
(
BigDecimal
o1
,
BigDecimal
o2
)
{
if
(
o1
.
compareTo
(
o2
)
==
-
1
)
return
1
;
//注意!!返回值必须是一对相反数
// ,否则无效。jdk1.7以后就是这样。
else
return
-
1
;
}
};
Comparator
<
BigDecimal
>
c
=
(
o1
,
o2
)
->
Integer
.
compare
(
0
,
o1
.
compareTo
(
o2
));
salesList
.
sort
(
c
);
historyFourteenSalesList
.
sort
(
c
);
historySevenSalesList
.
sort
(
c
);
...
...
@@ -1206,8 +1197,7 @@ public class AutoTurnoverJob extends PointJob {
BigDecimal
weightingSevenAvgSales
=
thirtyHistorySales
.
divide
(
BigDecimal
.
valueOf
(
salesList
.
size
()
-
2
),
3
,
RoundingMode
.
HALF_EVEN
);
BigDecimal
weightingFourteenAvgSales
=
fourteenHistorySales
.
divide
(
BigDecimal
.
valueOf
(
historyFourteenSalesList
.
size
()
-
2
),
3
,
RoundingMode
.
HALF_EVEN
);
BigDecimal
weightingThirtyAvgSales
=
sevenHistorySales
.
divide
(
BigDecimal
.
valueOf
(
historySevenSalesList
.
size
()
-
2
),
3
,
RoundingMode
.
HALF_EVEN
);
BigDecimal
weightingAvgSales
=
weightingSevenAvgSales
.
multiply
(
weightingCoefficientSeven
).
add
(
weightingFourteenAvgSales
.
multiply
(
weightingCoefficientFourteen
)).
add
(
weightingThirtyAvgSales
.
multiply
(
weightingCoefficientThirty
)).
setScale
(
3
,
RoundingMode
.
HALF_EVEN
);
return
weightingAvgSales
;
return
weightingSevenAvgSales
.
multiply
(
weightingCoefficientSeven
).
add
(
weightingFourteenAvgSales
.
multiply
(
weightingCoefficientFourteen
)).
add
(
weightingThirtyAvgSales
.
multiply
(
weightingCoefficientThirty
)).
setScale
(
3
,
RoundingMode
.
HALF_EVEN
);
}
/**
...
...
@@ -1230,7 +1220,7 @@ public class AutoTurnoverJob extends PointJob {
*/
//拿采购单流水
if
(
purchase
>
0
)
{
List
<
DcBasePurchase
>
dcBasePurchaseList
=
null
;
List
<
DcBasePurchase
>
dcBasePurchaseList
;
// 找采购在途的采购单
try
{
DcBasePurchaseMapper
dcBasePurchaseMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcBasePurchaseMapper
.
class
);
...
...
@@ -1244,14 +1234,14 @@ public class AutoTurnoverJob extends PointJob {
if
(
dcBasePurchaseList
!=
null
&&
dcBasePurchaseList
.
size
()
>
0
)
{
for
(
DcBasePurchase
dcBasePurchase
:
dcBasePurchaseList
)
{
if
(
dcBasePurchase
.
getCount
()
>
0
)
{
LocalDateTime
finalEstimatedArrivalTime
=
null
;
LocalDateTime
finalEstimatedArrivalTime
;
if
(
dcBasePurchase
.
getHasTransfer
()
==
1
)
{
//调拨采购单
finalEstimatedArrivalTime
=
dcBasePurchase
.
getEstimatedArrivalTime
().
plusDays
(
dcAutoTurnover
.
getInspectionDelivery
()).
plusDays
(
dcAutoTurnover
.
getTransferBaleDelivery
()).
plusDays
(
dcAutoTurnover
.
getTransferDelivery
()).
plusDays
(
dcAutoTurnover
.
getAbroadInboundDelivery
());
}
else
{
//普通采购单
finalEstimatedArrivalTime
=
dcBasePurchase
.
getEstimatedArrivalTime
().
plusDays
(
dcAutoTurnover
.
getInspectionDelivery
());
}
int
interval
=
Period
.
between
(
recordTime
,
finalEstimatedArrivalTime
.
toLocalDate
()).
getDays
();
int
index
=
interval
<=
0
?
0
:
interval
;
int
index
=
Math
.
max
(
interval
,
0
)
;
forecastInboundRelationList
.
set
(
index
,
forecastInboundRelationList
.
get
(
index
).
equals
(
Constant
.
NAN_STRING
)
?
Constant
.
PURCHASE_SIGN
+
dcBasePurchase
.
getPurchaseId
()
+
"_"
+
dcBasePurchase
.
getCount
()
:
forecastInboundRelationList
.
get
(
index
)
+
"*"
+
Constant
.
PURCHASE_SIGN
+
dcBasePurchase
.
getPurchaseId
()
+
"_"
+
dcBasePurchase
.
getCount
());
forecastPurchaseInboundList
.
set
(
index
,
forecastPurchaseInboundList
.
get
(
index
)
+
dcBasePurchase
.
getCount
());
forecastInboundList
.
set
(
index
,
forecastPurchaseInboundList
.
get
(
index
)
+
forecastTransferInboundList
.
get
(
index
));
...
...
@@ -1261,7 +1251,7 @@ public class AutoTurnoverJob extends PointJob {
}
//拿调拨单流水
if
(
transfer
>
0
)
{
List
<
DcBaseTransferVerify
>
dcBaseTransferVerifyList
=
null
;
List
<
DcBaseTransferVerify
>
dcBaseTransferVerifyList
;
try
{
DcBaseTransferVerifyMapper
dcBaseTransferVerifyMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcBaseTransferVerifyMapper
.
class
);
// 找调拨在途的采购单
...
...
@@ -1275,7 +1265,7 @@ public class AutoTurnoverJob extends PointJob {
if
(
dcBaseTransferVerifyList
!=
null
&&
dcBaseTransferVerifyList
.
size
()
>
0
)
{
for
(
DcBaseTransferVerify
dcBaseTransferVerify
:
dcBaseTransferVerifyList
)
{
if
(
dcBaseTransferVerify
.
getCount
()
>
0
)
{
LocalDateTime
finalEstimatedArrivalTime
=
null
;
LocalDateTime
finalEstimatedArrivalTime
;
if
(
dcBaseTransferVerify
.
getEstimatedArrivalTime
()
!=
null
&&
dcBaseTransferVerify
.
getEstimatedArrivalTime
().
isAfter
(
Constant
.
INIT_DATE_TIME
))
{
finalEstimatedArrivalTime
=
dcBaseTransferVerify
.
getEstimatedArrivalTime
().
plusDays
(
dcAutoTurnover
.
getInspectionConfigDelivery
());
}
else
{
...
...
@@ -1292,9 +1282,7 @@ public class AutoTurnoverJob extends PointJob {
.
newAndCreateCriteria
()
.
andWarehouseCodeEqualTo
(
dcAutoTurnover
.
getWarehouseCode
())
.
example
());
if
(
dcBaseWarehouse
.
getSystemFlag
().
toUpperCase
().
equals
(
PlatformType
.
FBA
.
value
()))
{
}
else
{
if
(!
dcBaseWarehouse
.
getSystemFlag
().
toUpperCase
().
equals
(
PlatformType
.
FBA
.
value
()))
{
forecastTransferInboundList
.
set
(
index
,
forecastTransferInboundList
.
get
(
index
)
+
dcBaseTransferVerify
.
getCount
());
forecastInboundList
.
set
(
index
,
forecastPurchaseInboundList
.
get
(
index
)
+
forecastTransferInboundList
.
get
(
index
));
}
...
...
@@ -1351,7 +1339,7 @@ public class AutoTurnoverJob extends PointJob {
private
StringBuilder
promotionForecastSales
(
LocalDate
recordTime
,
Integer
autoForecastDay
,
DcAutoSales
dcAutoSales
,
List
<
BigDecimal
>
forecastSalesList
)
{
//周转周期里有活动,可能有多个
Integer
promotionCount
=
0
;
int
promotionCount
=
0
;
StringBuilder
promotionsBuilder
=
new
StringBuilder
();
List
<
DcAutoConfigPromotion
>
autoSalesConfigList
=
null
;
try
{
...
...
@@ -1364,16 +1352,16 @@ public class AutoTurnoverJob extends PointJob {
SessionUtil
.
closeSession
();
}
if
(
autoSalesConfigList
!=
null
&&
autoSalesConfigList
.
size
()
>
0
)
{
for
(
int
j
=
0
;
j
<
autoSalesConfigList
.
size
();
j
++)
{
DcAutoConfigPromotion
dcAutoConfigPromotion
=
autoSalesConfigList
.
get
(
j
);
for
(
DcAutoConfigPromotion
dcAutoConfigPromotion
:
autoSalesConfigList
)
{
if
(
promotionsBuilder
.
length
()
>
0
)
{
promotionsBuilder
.
append
(
","
);
}
promotionsBuilder
.
append
(
dcAutoConfigPromotion
.
getId
());
//看促销日期和recordTime相差多少天
int
interval
=
Period
.
between
(
recordTime
,
dcAutoConfigPromotion
.
getPromotionTime
()).
getDays
();
if
(
interval
>=
0
&&
interval
<
autoForecastDay
)
{
promotionCount
=
promotionCount
+
dcAutoConfigPromotion
.
getCount
()
.
intValue
()
;
promotionCount
=
promotionCount
+
dcAutoConfigPromotion
.
getCount
();
forecastSalesList
.
set
(
interval
,
forecastSalesList
.
get
(
interval
).
add
(
BigDecimal
.
valueOf
(
dcAutoConfigPromotion
.
getCount
())));
}
}
...
...
@@ -1382,146 +1370,6 @@ public class AutoTurnoverJob extends PointJob {
}
/**
* 销量表只有31天的预测销量, 2倍周转期超过这个时间的不满足要求
* 只能根据公式算好放list里
* x 的取值从31开始
*
* @param salesUpperLimit 预测销量上限
* @param autoForecastDay
* @param dcAutoSales
* @param forecastSalesList
*/
private
void
calculateForecastSales
(
BigDecimal
salesUpperLimit
,
Integer
autoForecastDay
,
DcAutoSales
dcAutoSales
,
List
<
BigDecimal
>
forecastSalesList
,
DcBaseSku
turnoverSku
,
LocalDate
recordTime
,
String
bailunSku
,
String
warehouseCode
,
DcAutoWarehouseweekSales
dcAutoWarehouseweekSales
)
{
/*DcConfigForecastSalesMapper dcConfigForecastSalesMapper = SessionUtil.getSession().getMapper(DcConfigForecastSalesMapper.class);
List<DcConfigForecastSales> configForecastSalesList = dcConfigForecastSalesMapper.selectByExample(DcConfigForecastSalesExample.newAndCreateCriteria().andBailunSkuEqualTo(bailunSku).andWarehouseCodeEqualTo(warehouseCode).example());
DcBasePurchase dcBasePurchase = null;
if(configForecastSalesList != null && configForecastSalesList.size() > 0) {
DcBasePurchaseMapper dcBasePurchaseMapper = SessionUtil.getSession().getMapper(DcBasePurchaseMapper.class);
dcBasePurchase = dcBasePurchaseMapper.selectOneByExample(DcBasePurchaseExample.newAndCreateCriteria().andBailunSkuEqualTo(bailunSku).andWarehouseCodeEqualTo(warehouseCode).example());
}*/
// JIT 推送时间21天之内的sku 预测销量为最近7天均值
if
(
turnoverSku
.
getPushTime
()
!=
null
&&
recordTime
.
minusDays
(
21L
).
isBefore
(
turnoverSku
.
getPushTime
().
toLocalDate
())
&&
!(
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_1
))
&&
!(
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_2
))
&&
!(
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_4
)))
{
/*DcBaseOmsSkuMapper dcBaseOmsSkuMapper = SessionUtil.getSession().getMapper(DcBaseOmsSkuMapper.class);
DcBaseOmsSku dcBaseOmsSku = dcBaseOmsSkuMapper.selectOneByCreateTime(bailunSku);*/
List
<
Integer
>
historySalesList
=
JSON
.
parseObject
(
dcAutoSales
.
getHistorySalesDetails
(),
new
TypeReference
<
List
<
Integer
>>()
{
});
Integer
historySevenSales
=
0
;
Integer
historyThreeSales
=
0
;
for
(
int
i
=
0
;
i
<
7
;
i
++)
{
historySevenSales
+=
historySalesList
.
get
(
23
+
i
);
}
BigDecimal
avgHistorySevendaySales
=
BigDecimal
.
valueOf
(
historySevenSales
.
longValue
()).
divide
(
Constant
.
BIGDECIMAL_SEVEN
,
3
,
RoundingMode
.
HALF_EVEN
);
for
(
int
j
=
0
;
j
<
autoForecastDay
;
j
++)
{
forecastSalesList
.
set
(
j
,
avgHistorySevendaySales
);
}
}
else
{
BigDecimal
forecastSales
=
BigDecimal
.
ZERO
;
List
<
Integer
>
historySalesList
=
JSON
.
parseObject
(
dcAutoSales
.
getHistorySalesDetails
(),
new
TypeReference
<
List
<
Integer
>>()
{
});
List
<
Integer
>
weekRateList
=
null
;
int
weekTime
=
0
;
boolean
hasValue
=
true
;
if
(
dcAutoWarehouseweekSales
==
null
)
{
hasValue
=
false
;
}
else
{
weekRateList
=
JSON
.
parseObject
(
"["
+
dcAutoWarehouseweekSales
.
getRateDetail
()
+
"]"
,
new
TypeReference
<
List
<
Integer
>>()
{
});
weekTime
=
Integer
.
valueOf
(
dcAutoWarehouseweekSales
.
getWeekTime
());
}
for
(
int
j
=
0
;
j
<
autoForecastDay
;
j
++)
{
// y = ae^bx
/*double v;
if (dcAutoSales.getFitForecastFormula().contains("ln(x)")) {
//y = aln(x) + b
v = dcAutoSales.getFitAVariable().doubleValue() * Math.log1p((j + 31)) + dcAutoSales.getFitBVariable().doubleValue();
} else {
v = dcAutoSales.getFitAVariable().doubleValue() * Math.exp(dcAutoSales.getFitBVariable().doubleValue() * (j + 31));
}
BigDecimal forecastSales = BigDecimal.valueOf(v < 0 ? 0 : v).setScale(0, RoundingMode.HALF_EVEN);
forecastSalesList.set(j, forecastSales.compareTo(salesUpperLimit) == 1 ? salesUpperLimit : forecastSales);*/
//20191127 预测销量更改为:(过去第四周*0.1 + 过去第三周*0.1 + 过去第二周*0.3 + 过去第一周*0.5)* 周系数
if
(
0
<=
j
&&
j
<
7
)
{
forecastSales
=
BigDecimal
.
valueOf
(
historySalesList
.
get
(
2
+
j
)).
multiply
(
BigDecimal
.
valueOf
(
0.1
)).
add
(
BigDecimal
.
valueOf
(
historySalesList
.
get
(
9
+
j
)).
multiply
(
BigDecimal
.
valueOf
(
0.1
))).
add
(
BigDecimal
.
valueOf
(
historySalesList
.
get
(
16
+
j
)).
multiply
(
BigDecimal
.
valueOf
(
0.3
))).
add
(
BigDecimal
.
valueOf
(
historySalesList
.
get
(
23
+
j
)).
multiply
(
BigDecimal
.
valueOf
(
0.5
)));
if
(
hasValue
)
{
forecastSales
=
forecastSales
.
multiply
(
BigDecimal
.
valueOf
(
weekRateList
.
get
(
weekTime
)).
compareTo
(
BigDecimal
.
ZERO
)
==
0
?
BigDecimal
.
ONE
:
BigDecimal
.
valueOf
(
weekRateList
.
get
(
weekTime
)));
}
}
else
if
(
7
<=
j
&&
j
<
14
)
{
forecastSales
=
(
BigDecimal
.
valueOf
(
historySalesList
.
get
(
2
+
j
)).
multiply
(
BigDecimal
.
valueOf
(
0.1
))).
add
(
BigDecimal
.
valueOf
(
historySalesList
.
get
(
9
+
j
)).
multiply
(
BigDecimal
.
valueOf
(
0.1
))).
add
(
BigDecimal
.
valueOf
(
historySalesList
.
get
(
16
+
j
)).
multiply
(
BigDecimal
.
valueOf
(
0.3
))).
add
(
forecastSalesList
.
get
(
j
-
7
).
multiply
(
BigDecimal
.
valueOf
(
0.5
)));
if
(
hasValue
)
{
if
(
weekTime
>
51
)
{
weekTime
=
weekTime
-
51
;
}
forecastSales
=
forecastSales
.
multiply
(
BigDecimal
.
valueOf
(
weekRateList
.
get
(
weekTime
)).
compareTo
(
BigDecimal
.
ZERO
)
==
0
?
BigDecimal
.
ONE
:
BigDecimal
.
valueOf
(
weekRateList
.
get
(
weekTime
)));
}
}
else
if
(
14
<=
j
&&
j
<
21
)
{
forecastSales
=
(
BigDecimal
.
valueOf
(
historySalesList
.
get
(
2
+
j
)).
multiply
(
BigDecimal
.
valueOf
(
0.1
))).
add
(
BigDecimal
.
valueOf
(
historySalesList
.
get
(
9
+
j
)).
multiply
(
BigDecimal
.
valueOf
(
0.1
))).
add
(
forecastSalesList
.
get
(
j
-
14
).
multiply
(
BigDecimal
.
valueOf
(
0.3
))).
add
(
forecastSalesList
.
get
(
j
-
7
).
multiply
(
BigDecimal
.
valueOf
(
0.5
)));
if
(
hasValue
)
{
if
(
weekTime
>
50
)
{
weekTime
=
weekTime
-
50
;
}
forecastSales
=
forecastSales
.
multiply
(
BigDecimal
.
valueOf
(
weekRateList
.
get
(
weekTime
)).
compareTo
(
BigDecimal
.
ZERO
)
==
0
?
BigDecimal
.
ONE
:
BigDecimal
.
valueOf
(
weekRateList
.
get
(
weekTime
)));
}
}
else
if
(
21
<=
j
&&
j
<
27
)
{
forecastSales
=
(
BigDecimal
.
valueOf
(
historySalesList
.
get
(
2
+
j
)).
multiply
(
BigDecimal
.
valueOf
(
0.1
))).
add
(
forecastSalesList
.
get
(
j
-
21
).
multiply
(
BigDecimal
.
valueOf
(
0.1
))).
add
(
forecastSalesList
.
get
(
j
-
14
).
multiply
(
BigDecimal
.
valueOf
(
0.3
))).
add
(
forecastSalesList
.
get
(
j
-
7
).
multiply
(
BigDecimal
.
valueOf
(
0.5
)));
if
(
hasValue
)
{
if
(
weekTime
>
49
)
{
weekTime
=
weekTime
-
49
;
}
forecastSales
=
forecastSales
.
multiply
(
BigDecimal
.
valueOf
(
weekRateList
.
get
(
weekTime
)).
compareTo
(
BigDecimal
.
ZERO
)
==
0
?
BigDecimal
.
ONE
:
BigDecimal
.
valueOf
(
weekRateList
.
get
(
weekTime
)));
}
}
else
if
(
27
<=
j
&&
j
<
autoForecastDay
)
{
forecastSales
=
(
forecastSalesList
.
get
(
j
-
27
).
multiply
(
BigDecimal
.
valueOf
(
0.1
))).
add
(
forecastSalesList
.
get
(
j
-
21
).
multiply
(
BigDecimal
.
valueOf
(
0.1
))).
add
(
forecastSalesList
.
get
(
j
-
14
).
multiply
(
BigDecimal
.
valueOf
(
0.3
))).
add
(
forecastSalesList
.
get
(
j
-
7
).
multiply
(
BigDecimal
.
valueOf
(
0.5
)));
if
(
hasValue
)
{
if
(
weekTime
>
48
)
{
weekTime
=
weekTime
-
48
;
}
forecastSales
=
forecastSales
.
multiply
(
BigDecimal
.
valueOf
(
weekRateList
.
get
(
weekTime
)).
compareTo
(
BigDecimal
.
ZERO
)
==
0
?
BigDecimal
.
ONE
:
BigDecimal
.
valueOf
(
weekRateList
.
get
(
weekTime
)));
}
}
forecastSalesList
.
set
(
j
,
forecastSales
.
compareTo
(
salesUpperLimit
)
==
1
?
salesUpperLimit
:
forecastSales
);
}
}
/*if(dcBasePurchase == null) {
for(DcConfigForecastSales dcConfigForecastSales : configForecastSalesList) {
LocalDate localDate = LocalDate.now();
for(int j = 0; j < autoForecastDay; j++) {
Long i = dcConfigForecastSales.getStartDate().toLocalDate().toEpochDay() - localDate.toEpochDay();
}
}
}*/
}
/**
* 去数据库查出矫正曲线配置
* 用配置的参数乘以指定销量
* dcAutoConfigCorrection.getStartTime() 要大于等于queryTime
...
...
data-show/show-auto-turnover/src/main/java/com/bailuntec/service/impl/AutoTurnoverServiceImpl.java
View file @
58071f30
...
...
@@ -31,9 +31,8 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
@Override
public
List
<
BigDecimal
>
getAutoTurnoverSaleDetails
(
DcAutoTurnover
dcAutoTurnover
,
int
turnoverDays
,
int
autoForecastDay
)
{
SqlSession
session
=
SessionUtil
.
getFactory
().
openSession
(
true
);
// SqlSession readOnlySession = ReadSessionUtil.getFactory().openSession(true);
try
{
try
(
SqlSession
session
=
SessionUtil
.
getFactory
().
openSession
(
true
))
{
Queue
<
BigDecimal
>
forecastSalesDetails
=
new
LinkedList
<>();
...
...
@@ -140,8 +139,6 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
}
return
new
ArrayList
<>(
forecastSalesDetails
);
}
finally
{
session
.
close
();
}
}
...
...
data-show/show-auto-turnover/src/test/java/AutoTurnoverTest.java
View file @
58071f30
...
...
@@ -268,8 +268,8 @@ public class AutoTurnoverTest {
public
void
testXX2
()
{
DcBaseStock
dcBaseStock
=
SessionUtil
.
getSession
().
getMapper
(
DcBaseStockMapper
.
class
)
.
selectOneByExample
(
DcBaseStockExample
.
newAndCreateCriteria
()
.
andBailunSkuEqualTo
(
"
2237233
01"
)
.
andWarehouseCodeEqualTo
(
"
ESFBABLEM
"
)
.
andBailunSkuEqualTo
(
"
9448700
01"
)
.
andWarehouseCodeEqualTo
(
"
GB4PXBL
"
)
.
example
());
try
{
...
...
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