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
39892e90
Commit
39892e90
authored
Aug 14, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
销量预测公式
parent
18e212c5
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
261 additions
and
141 deletions
+261
-141
SyncCostFirstJob.java
...rst/src/main/java/com/bailuntec/job/SyncCostFirstJob.java
+45
-16
job.properties
...se/base-sync-cost-first/src/main/resources/job.properties
+4
-4
SyncCostFirstTest.java
...base-sync-cost-first/src/test/java/SyncCostFirstTest.java
+3
-3
DcAutoTurnover.java
...main/java/com/bailuntec/domain/entity/DcAutoTurnover.java
+2
-74
AutoTurnoverJob.java
...over/src/main/java/com/bailuntec/job/AutoTurnoverJob.java
+172
-41
AutoSalesServiceImpl.java
...java/com/bailuntec/service/impl/AutoSalesServiceImpl.java
+2
-2
AutoTurnoverServiceImpl.java
...a/com/bailuntec/service/impl/AutoTurnoverServiceImpl.java
+32
-1
AutoTurnoverServiceImplTest.java
...m/bailuntec/service/impl/AutoTurnoverServiceImplTest.java
+1
-0
No files found.
data-base/base-sync-cost-first/src/main/java/com/bailuntec/job/SyncCostFirstJob.java
View file @
39892e90
...
...
@@ -14,6 +14,8 @@ import com.bailuntec.utils.OkHttpUtil;
import
com.bailuntec.utils.PropertiesUtil
;
import
com.bailuntec.utils.SessionUtil
;
import
com.dangdang.ddframe.job.api.ShardingContext
;
import
com.google.gson.Gson
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.Response
;
...
...
@@ -27,6 +29,7 @@ import java.time.format.DateTimeFormatter;
import
java.util.HashMap
;
import
java.util.List
;
@Slf4j
public
class
SyncCostFirstJob
extends
PointJob
{
private
PropertiesUtil
propertiesUtil
=
PropertiesUtil
.
getInstance
(
"const"
);
...
...
@@ -46,43 +49,59 @@ public class SyncCostFirstJob extends PointJob {
.
addHeader
(
"cache-control"
,
"no-cache"
)
.
build
();
Response
response
=
null
;
String
result
;
try
{
log
.
info
(
"调用头程费用接口 starting"
);
response
=
client
.
newCall
(
request
).
execute
();
result
=
response
.
body
().
string
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"调用头程费接口失败"
,
e
);
}
finally
{
if
(
response
!=
null
)
{
response
.
close
();
}
}
String
result
=
response
.
body
().
string
();
if
(
StringUtils
.
isNotBlank
(
result
))
{
log
.
info
(
"序列化头程费用头程费用 starting"
);
CostFirstResult
costFirstResult
=
JSON
.
parseObject
(
result
,
CostFirstResult
.
class
);
log
.
info
(
"序列化头程费用头程费用 end"
);
log
.
info
(
"头程费用当前请求页数 :{}"
,
jobPointLog
.
getPageIndex
());
log
.
info
(
"头程费用当前总页数 :{}"
,
costFirstResult
.
getPageCount
());
log
.
info
(
"头程费用当前页码大小 :{}"
,
costFirstResult
.
getData
().
size
());
totalPage
=
costFirstResult
.
getPageCount
();
if
(
costFirstResult
.
getData
()
!=
null
&&
costFirstResult
.
getData
().
size
()
>
0
)
{
handleCostFirstData
(
costFirstResult
.
getData
());
}
}
else
{
throw
new
RuntimeException
(
"调用头程费接口失败,返回200"
);
log
.
error
(
"调用头程费接口失败,返回200,param:{}"
,
new
Gson
().
toJson
(
map
));
}
}
catch
(
IOException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
"调用头程费接口失败,param:{}"
,
new
Gson
().
toJson
(
map
));
}
finally
{
if
(
response
!=
null
)
{
response
.
close
();
}
}
log
.
info
(
"调用头程费用接口 end"
);
jobPointLog
.
setPageIndex
(
jobPointLog
.
getPageIndex
()
+
1
);
if
(
jobPointLog
.
getPageIndex
()
%
8
==
0
)
{
JobPointLogMapper
mapper
=
SessionUtil
.
getSession
().
getMapper
(
JobPointLogMapper
.
class
);
mapper
.
upsertSelective
(
jobPointLog
);
}
}
while
(
jobPointLog
.
getPageIndex
()
<=
totalPage
);
jobPointLog
.
setPageIndex
(
1
);
jobPointLog
.
setStartTime
(
jobPointLog
.
getEndTime
());
jobPointLog
.
setEndTime
(
jobPointLog
.
getStartTime
().
plusDays
(
jobPointLog
.
getIntervalTime
().
longValue
()).
isAfter
(
LocalDateTime
.
now
())
?
LocalDateTime
.
now
()
:
jobPointLog
.
getStartTime
().
plusDays
(
jobPointLog
.
getIntervalTime
().
longValue
()));
jobPointLog
.
setEndTime
(
jobPointLog
.
getStartTime
().
plusDays
(
jobPointLog
.
getIntervalTime
().
longValue
()).
isAfter
(
LocalDateTime
.
now
())
?
LocalDateTime
.
now
()
:
jobPointLog
.
getStartTime
().
plusDays
(
jobPointLog
.
getIntervalTime
().
longValue
()));
}
private
void
handleCostFirstData
(
List
<
CostFirstData
>
costFirstDataList
)
{
try
{
DcBaseCostFirstMapper
baseCostFirstMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcBaseCostFirstMapper
.
class
);
for
(
CostFirstData
costFirstData
:
costFirstDataList
)
{
//将费用处理一下, 给过来的数据很长的小数
costFirstDataList
.
forEach
(
costFirstData
->
{
costFirstData
.
setCostDuty
(
costFirstData
.
getCostDuty
().
setScale
(
3
,
RoundingMode
.
HALF_EVEN
));
costFirstData
.
setCostCustomsClearance
(
costFirstData
.
getCostCustomsClearance
().
setScale
(
3
,
RoundingMode
.
HALF_EVEN
));
costFirstData
.
setCostGoodsClearance
(
costFirstData
.
getCostGoodsClearance
().
setScale
(
3
,
RoundingMode
.
HALF_EVEN
));
...
...
@@ -101,16 +120,26 @@ public class SyncCostFirstJob extends PointJob {
throw
new
RuntimeException
(
"BeanUtils.copyProperties失败, ChannelId是"
+
costFirstData
.
getChannelId
());
}
if
(
StringUtils
.
isNotBlank
(
dcBaseCostFirst
.
getBailunSku
())
&&
StringUtils
.
isNotBlank
(
dcBaseCostFirst
.
getChannelOrderId
())
&&
StringUtils
.
isNotBlank
(
dcBaseCostFirst
.
getBoxId
())
&&
StringUtils
.
isNotBlank
(
dcBaseCostFirst
.
getTransferOrderId
())
&&
StringUtils
.
isNotBlank
(
dcBaseCostFirst
.
getWarehouseCode
()))
{
int
i
=
baseCostFirstMapper
.
updateByExampleSelective
(
dcBaseCostFirst
,
DcBaseCostFirstExample
.
newAndCreateCriteria
().
andBailunSkuEqualTo
(
dcBaseCostFirst
.
getBailunSku
()).
andChannelOrderIdEqualTo
(
dcBaseCostFirst
.
getChannelOrderId
()).
andBoxIdEqualTo
(
dcBaseCostFirst
.
getBoxId
()).
andTransferOrderIdEqualTo
(
dcBaseCostFirst
.
getTransferOrderId
()).
andWarehouseCodeEqualTo
(
dcBaseCostFirst
.
getWarehouseCode
()).
example
());
int
i
=
baseCostFirstMapper
.
updateByExampleSelective
(
dcBaseCostFirst
,
DcBaseCostFirstExample
.
newAndCreateCriteria
()
.
andBailunSkuEqualTo
(
dcBaseCostFirst
.
getBailunSku
())
.
andChannelOrderIdEqualTo
(
dcBaseCostFirst
.
getChannelOrderId
())
.
andBoxIdEqualTo
(
dcBaseCostFirst
.
getBoxId
()).
andTransferOrderIdEqualTo
(
dcBaseCostFirst
.
getTransferOrderId
())
.
andWarehouseCodeEqualTo
(
dcBaseCostFirst
.
getWarehouseCode
())
.
example
());
if
(
i
==
0
)
{
baseCostFirstMapper
.
upsertSelective
(
dcBaseCostFirst
);
log
.
info
(
"百伦头程费信息, 是WMS根据线路估算而来 新增同步成功 "
);
}
else
{
log
.
info
(
"百伦头程费信息, 是WMS根据线路估算而来 更新同步成功 "
);
}
}
}
}
}
}
);
}
catch
(
RuntimeException
e
)
{
throw
new
RuntimeException
(
"MYBATIS操作DB更新插入数据失败"
,
e
);
// throw new RuntimeException("MYBATIS操作DB更新插入数据失败", e);
log
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
SessionUtil
.
closeSession
();
}
...
...
data-base/base-sync-cost-first/src/main/resources/job.properties
View file @
39892e90
#EVENT_RDB_STORAGE_DRIVER=com.mysql.jdbc.Driver
#
EVENT_RDB_STORAGE_URL=jdbc:mysql://192.168.6.140:3306/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8
EVENT_RDB_STORAGE_URL
=
jdbc:mysql://192.168.6.140:3306/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8
#EVENT_RDB_STORAGE_USERNAME=root
#EVENT_RDB_STORAGE_PASSWORD=123456
#
ZOOKEEPER_SERVER=127.0.0.1:2181
ZOOKEEPER_SERVER
=
127.0.0.1:2181
EVENT_RDB_STORAGE_DRIVER
=
com.mysql.jdbc.Driver
EVENT_RDB_STORAGE_URL
=
jdbc:mysql://10.0.8.15:3306/bailun_datacenter?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
#
EVENT_RDB_STORAGE_URL=jdbc:mysql://10.0.8.15:3306/bailun_datacenter?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
EVENT_RDB_STORAGE_USERNAME
=
root
EVENT_RDB_STORAGE_PASSWORD
=
#7kfnymAM$Y9-Ntf
ZOOKEEPER_SERVER=172.31.255.120:2181
#
ZOOKEEPER_SERVER=172.31.255.120:2181
NAME_SPACE=data-center
JOB_NAME
=
base-sync-cost-first
JOB_CRON
=
0 10 0/1 * * ? *
...
...
data-base/base-sync-cost-first/src/test/java/SyncCostFirstTest.java
View file @
39892e90
...
...
@@ -9,9 +9,9 @@ public class SyncCostFirstTest {
@Test
public
void
test
()
{
SyncCostFirstJob
syncCostFirstJob
=
new
SyncCostFirstJob
();
JobPointLog
jobPointLog
=
new
JobPointLog
(
"base-sync-cost-first"
,
1
,
1
,
1
,
1
,
LocalDateTime
.
of
(
2020
,
8
,
11
,
0
,
3
,
22
),
LocalDateTime
.
of
(
2020
,
8
,
1
2
,
16
,
3
,
22
));
JobPointLog
jobPointLog
=
new
JobPointLog
(
"base-sync-cost-first"
,
1
01
,
1
,
1
,
1
,
LocalDateTime
.
of
(
2020
,
5
,
1
,
0
,
0
,
0
),
LocalDateTime
.
of
(
2020
,
8
,
1
4
,
9
,
0
,
0
));
syncCostFirstJob
.
executeJob
(
null
,
jobPointLog
);
}
}
data-common/src/main/java/com/bailuntec/domain/entity/DcAutoTurnover.java
View file @
39892e90
...
...
@@ -8,7 +8,6 @@ import java.time.LocalDateTime;
@Data
public
class
DcAutoTurnover
{
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.id
*
...
...
@@ -17,7 +16,6 @@ public class DcAutoTurnover {
private
Integer
id
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.purchase_advice_id
*
...
...
@@ -26,7 +24,6 @@ public class DcAutoTurnover {
private
String
purchaseAdviceId
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.bailun_sku
*
...
...
@@ -35,7 +32,6 @@ public class DcAutoTurnover {
private
String
bailunSku
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.warehouse_code
*
...
...
@@ -44,7 +40,6 @@ public class DcAutoTurnover {
private
String
warehouseCode
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.quantity_init_advise
*
...
...
@@ -53,7 +48,6 @@ public class DcAutoTurnover {
private
BigDecimal
quantityInitAdvise
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.quantity_minimum_order
*
...
...
@@ -62,7 +56,6 @@ public class DcAutoTurnover {
private
Integer
quantityMinimumOrder
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.quantity_final_advise
*
...
...
@@ -71,7 +64,6 @@ public class DcAutoTurnover {
private
BigDecimal
quantityFinalAdvise
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.warehouse_name
*
...
...
@@ -80,7 +72,6 @@ public class DcAutoTurnover {
private
String
warehouseName
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.quantity_promotion
*
...
...
@@ -89,7 +80,6 @@ public class DcAutoTurnover {
private
Integer
quantityPromotion
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.quantity_inventory
*
...
...
@@ -98,7 +88,6 @@ public class DcAutoTurnover {
private
Integer
quantityInventory
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.quantity_transfer
*
...
...
@@ -107,7 +96,6 @@ public class DcAutoTurnover {
private
Integer
quantityTransfer
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.quantity_purchase
*
...
...
@@ -116,7 +104,6 @@ public class DcAutoTurnover {
private
Integer
quantityPurchase
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.turnover_days
*
...
...
@@ -125,7 +112,6 @@ public class DcAutoTurnover {
private
Integer
turnoverDays
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.quantity_safe_inventory
*
...
...
@@ -134,7 +120,6 @@ public class DcAutoTurnover {
private
BigDecimal
quantitySafeInventory
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.remark
*
...
...
@@ -143,7 +128,6 @@ public class DcAutoTurnover {
private
String
remark
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.gmt_create
*
...
...
@@ -152,7 +136,6 @@ public class DcAutoTurnover {
private
LocalDateTime
gmtCreate
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.gmt_modified
*
...
...
@@ -161,7 +144,6 @@ public class DcAutoTurnover {
private
LocalDateTime
gmtModified
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.status
*
...
...
@@ -170,7 +152,6 @@ public class DcAutoTurnover {
private
Integer
status
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.quantity_out_stock
*
...
...
@@ -179,7 +160,6 @@ public class DcAutoTurnover {
private
Integer
quantityOutStock
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.sku_title
*
...
...
@@ -188,7 +168,6 @@ public class DcAutoTurnover {
private
String
skuTitle
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.promotions
*
...
...
@@ -197,7 +176,6 @@ public class DcAutoTurnover {
private
String
promotions
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.supplier_delivery
*
...
...
@@ -206,7 +184,6 @@ public class DcAutoTurnover {
private
Integer
supplierDelivery
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.inventory_available_days
*
...
...
@@ -215,7 +192,6 @@ public class DcAutoTurnover {
private
Integer
inventoryAvailableDays
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.quantity_inbound
*
...
...
@@ -224,7 +200,6 @@ public class DcAutoTurnover {
private
Integer
quantityInbound
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.forecast_oneday_sales
*
...
...
@@ -233,7 +208,6 @@ public class DcAutoTurnover {
private
BigDecimal
forecastOnedaySales
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.forecast_sevenday_sales
*
...
...
@@ -242,7 +216,6 @@ public class DcAutoTurnover {
private
BigDecimal
forecastSevendaySales
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.forecast_fourteenday_sales
*
...
...
@@ -251,7 +224,6 @@ public class DcAutoTurnover {
private
BigDecimal
forecastFourteendaySales
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.sales_details
*
...
...
@@ -260,7 +232,6 @@ public class DcAutoTurnover {
private
String
salesDetails
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.inbound_details
*
...
...
@@ -269,7 +240,6 @@ public class DcAutoTurnover {
private
String
inboundDetails
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.inventory_details
*
...
...
@@ -278,7 +248,6 @@ public class DcAutoTurnover {
private
String
inventoryDetails
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.short_supply_details
*
...
...
@@ -287,7 +256,6 @@ public class DcAutoTurnover {
private
String
shortSupplyDetails
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.advised_details
*
...
...
@@ -296,7 +264,6 @@ public class DcAutoTurnover {
private
String
advisedDetails
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.sales_upper_limit
*
...
...
@@ -305,7 +272,6 @@ public class DcAutoTurnover {
private
BigDecimal
salesUpperLimit
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.average_overdue
*
...
...
@@ -314,7 +280,6 @@ public class DcAutoTurnover {
private
BigDecimal
averageOverdue
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.average_supplier_delivery
*
...
...
@@ -323,7 +288,6 @@ public class DcAutoTurnover {
private
Integer
averageSupplierDelivery
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.transfer_config_delivery
*
...
...
@@ -332,7 +296,6 @@ public class DcAutoTurnover {
private
Integer
transferConfigDelivery
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.transfer_bale_config_delivery
*
...
...
@@ -341,7 +304,6 @@ public class DcAutoTurnover {
private
Integer
transferBaleConfigDelivery
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.abroad_inbound_config_delivery
*
...
...
@@ -350,7 +312,6 @@ public class DcAutoTurnover {
private
Integer
abroadInboundConfigDelivery
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.inspection_config_delivery
*
...
...
@@ -359,7 +320,6 @@ public class DcAutoTurnover {
private
Integer
inspectionConfigDelivery
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.inspection_delivery
*
...
...
@@ -368,7 +328,6 @@ public class DcAutoTurnover {
private
Integer
inspectionDelivery
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.transfer_delivery
*
...
...
@@ -377,7 +336,6 @@ public class DcAutoTurnover {
private
Integer
transferDelivery
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.transfer_bale_delivery
*
...
...
@@ -386,7 +344,6 @@ public class DcAutoTurnover {
private
Integer
transferBaleDelivery
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.abroad_inbound_delivery
*
...
...
@@ -395,7 +352,6 @@ public class DcAutoTurnover {
private
Integer
abroadInboundDelivery
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.supplementary_sales
*
...
...
@@ -404,7 +360,6 @@ public class DcAutoTurnover {
private
BigDecimal
supplementarySales
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.turnover_sales
*
...
...
@@ -413,7 +368,6 @@ public class DcAutoTurnover {
private
BigDecimal
turnoverSales
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.turnover_inbound
*
...
...
@@ -422,7 +376,6 @@ public class DcAutoTurnover {
private
BigDecimal
turnoverInbound
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.history_sevenday_sales
*
...
...
@@ -431,7 +384,6 @@ public class DcAutoTurnover {
private
BigDecimal
historySevendaySales
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.history_fourteenday_sales
*
...
...
@@ -440,7 +392,6 @@ public class DcAutoTurnover {
private
BigDecimal
historyFourteendaySales
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.history_thirtyday_sales
*
...
...
@@ -449,7 +400,6 @@ public class DcAutoTurnover {
private
BigDecimal
historyThirtydaySales
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.sales_explain_details
*
...
...
@@ -458,7 +408,6 @@ public class DcAutoTurnover {
private
String
salesExplainDetails
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.forecast_turnoverday_sales
*
...
...
@@ -467,7 +416,6 @@ public class DcAutoTurnover {
private
BigDecimal
forecastTurnoverdaySales
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.stock_up_sales
*
...
...
@@ -476,7 +424,6 @@ public class DcAutoTurnover {
private
BigDecimal
stockUpSales
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.quantity_begin_advise
*
...
...
@@ -485,7 +432,6 @@ public class DcAutoTurnover {
private
BigDecimal
quantityBeginAdvise
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.stock_up_days
*
...
...
@@ -494,7 +440,6 @@ public class DcAutoTurnover {
private
Integer
stockUpDays
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.payment_before_delivery
*
...
...
@@ -503,7 +448,6 @@ public class DcAutoTurnover {
private
Integer
paymentBeforeDelivery
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.product_code
*
...
...
@@ -512,7 +456,6 @@ public class DcAutoTurnover {
private
String
productCode
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.product_inner_code
*
...
...
@@ -521,7 +464,6 @@ public class DcAutoTurnover {
private
String
productInnerCode
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.bailun_category_id
*
...
...
@@ -530,7 +472,6 @@ public class DcAutoTurnover {
private
Integer
bailunCategoryId
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.buyer_name
*
...
...
@@ -539,7 +480,6 @@ public class DcAutoTurnover {
private
String
buyerName
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.suppliers_name
*
...
...
@@ -548,7 +488,6 @@ public class DcAutoTurnover {
private
String
suppliersName
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.history_sevenday_sales_ebay
*
...
...
@@ -557,7 +496,6 @@ public class DcAutoTurnover {
private
BigDecimal
historySevendaySalesEbay
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.history_fourteenday_sales_ebay
*
...
...
@@ -566,7 +504,6 @@ public class DcAutoTurnover {
private
BigDecimal
historyFourteendaySalesEbay
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.history_thirtyday_sales_ebay
*
...
...
@@ -575,7 +512,6 @@ public class DcAutoTurnover {
private
BigDecimal
historyThirtydaySalesEbay
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.history_sevenday_sales_aliexpress
*
...
...
@@ -584,7 +520,6 @@ public class DcAutoTurnover {
private
BigDecimal
historySevendaySalesAliexpress
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.history_fourteenday_sales_aliexpress
*
...
...
@@ -593,7 +528,6 @@ public class DcAutoTurnover {
private
BigDecimal
historyFourteendaySalesAliexpress
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.history_thirtyday_sales_aliexpress
*
...
...
@@ -602,7 +536,6 @@ public class DcAutoTurnover {
private
BigDecimal
historyThirtydaySalesAliexpress
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.daily_weighted_sales
*
...
...
@@ -611,7 +544,6 @@ public class DcAutoTurnover {
private
BigDecimal
dailyWeightedSales
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.original_quantity_init_advise
*
...
...
@@ -620,7 +552,6 @@ public class DcAutoTurnover {
private
Integer
originalQuantityInitAdvise
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.is_modify_quantity_init_advise
*
...
...
@@ -629,7 +560,6 @@ public class DcAutoTurnover {
private
Integer
isModifyQuantityInitAdvise
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.tag_id
*
...
...
@@ -638,7 +568,6 @@ public class DcAutoTurnover {
private
Integer
tagId
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.hq_type
*
...
...
@@ -647,7 +576,6 @@ public class DcAutoTurnover {
private
String
hqType
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.history_sevenday_sales_amazon
*
...
...
@@ -656,7 +584,6 @@ public class DcAutoTurnover {
private
BigDecimal
historySevendaySalesAmazon
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.history_fourteenday_sales_amazon
*
...
...
@@ -665,7 +592,6 @@ public class DcAutoTurnover {
private
BigDecimal
historyFourteendaySalesAmazon
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.history_thirtyday_sales_amazon
*
...
...
@@ -675,6 +601,8 @@ public class DcAutoTurnover {
private
Integer
is_out_stock
;
private
String
salesDetailsFormula
;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_turnover
...
...
data-show/show-auto-turnover/src/main/java/com/bailuntec/job/AutoTurnoverJob.java
View file @
39892e90
...
...
@@ -278,7 +278,8 @@ public class AutoTurnoverJob extends PointJob {
DcAutoTurnoverMapper
dcAutoTurnoverMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoTurnoverMapper
.
class
);
DcAutoTurnover
dcAutoTurnover
=
dcAutoTurnoverMapper
.
selectOneByExample
(
DcAutoTurnoverExample
.
newAndCreateCriteria
()
.
andBailunSkuEqualTo
(
bailunSku
)
.
andWarehouseCodeEqualTo
(
warehouseCode
).
example
());
.
andWarehouseCodeEqualTo
(
warehouseCode
)
.
example
());
if
(
dcAutoTurnover
==
null
)
{
dcAutoTurnover
=
new
DcAutoTurnover
();
...
...
@@ -349,7 +350,7 @@ public class AutoTurnoverJob extends PointJob {
turnoverDays
=
4
;
}
}
Integer
autoForecastDay
=
turnoverDays
*
Constant
.
TURNOVER_MULTIPLE
<
Constant
.
MIN_AUTO_FORECAST_DAY
?
Constant
.
MIN_AUTO_FORECAST_DAY
:
turnoverDays
*
2
;
int
autoForecastDay
=
turnoverDays
*
Constant
.
TURNOVER_MULTIPLE
<
Constant
.
MIN_AUTO_FORECAST_DAY
?
Constant
.
MIN_AUTO_FORECAST_DAY
:
turnoverDays
*
2
;
/*
* 初始化预测容器, 用来存放预测销量, 库存等数据
...
...
@@ -360,17 +361,17 @@ public class AutoTurnoverJob extends PointJob {
* forecastSalesList
* forecastShortSupplyList
*/
List
<
Integer
>
forecastPurchaseInboundList
=
new
ArrayList
<
Integer
>(
autoForecastDay
);
List
<
Integer
>
forecastTransferInboundList
=
new
ArrayList
<
Integer
>(
autoForecastDay
);
List
<
BigDecimal
>
forecastInventoryList
=
new
ArrayList
<
BigDecimal
>(
autoForecastDay
);
List
<
Integer
>
forecastInboundList
=
new
ArrayList
<
Integer
>(
autoForecastDay
);
List
<
String
>
forecastInboundRelationList
=
new
ArrayList
<
String
>(
autoForecastDay
);
List
<
BigDecimal
>
forecastSalesList
=
new
ArrayList
<
BigDecimal
>(
autoForecastDay
);
List
<
String
>
forecastSalesExplainList
=
new
ArrayList
<
String
>(
forecastSalesList
.
size
());
List
<
BigDecimal
>
forecastShortSupplyList
=
new
ArrayList
<
BigDecimal
>(
autoForecastDay
);
List
<
BigDecimal
>
forecastPurchaseAdvisedList
=
new
ArrayList
<
BigDecimal
>(
autoForecastDay
);
List
<
BigDecimal
>
moqPurchaseAdvisedList
=
new
ArrayList
<
BigDecimal
>(
autoForecastDay
);
Map
<
String
,
BigDecimal
>
saveDaysMap
=
new
HashMap
<
String
,
BigDecimal
>();
List
<
Integer
>
forecastPurchaseInboundList
=
new
ArrayList
<>(
autoForecastDay
);
List
<
Integer
>
forecastTransferInboundList
=
new
ArrayList
<>(
autoForecastDay
);
List
<
BigDecimal
>
forecastInventoryList
=
new
ArrayList
<>(
autoForecastDay
);
List
<
Integer
>
forecastInboundList
=
new
ArrayList
<>(
autoForecastDay
);
List
<
String
>
forecastInboundRelationList
=
new
ArrayList
<>(
autoForecastDay
);
List
<
BigDecimal
>
forecastSalesList
=
new
ArrayList
<>(
autoForecastDay
);
List
<
String
>
forecastSalesExplainList
=
new
ArrayList
<>(
forecastSalesList
.
size
());
List
<
BigDecimal
>
forecastShortSupplyList
=
new
ArrayList
<>(
autoForecastDay
);
List
<
BigDecimal
>
forecastPurchaseAdvisedList
=
new
ArrayList
<>(
autoForecastDay
);
List
<
BigDecimal
>
moqPurchaseAdvisedList
=
new
ArrayList
<>(
autoForecastDay
);
Map
<
String
,
BigDecimal
>
saveDaysMap
=
new
HashMap
<>();
initForecaseList
(
forecastInboundRelationList
,
forecastInventoryList
,
forecastPurchaseInboundList
,
forecastTransferInboundList
,
forecastInboundList
,
forecastSalesList
,
forecastShortSupplyList
,
autoForecastDay
,
forecastSalesExplainList
);
/*
...
...
@@ -447,7 +448,14 @@ public class AutoTurnoverJob extends PointJob {
* 可以支持配置
* 2019-04-22更新 不管逾期
*/
BigDecimal
totalSafeInventory
=
calculateSafeInventory
(
turnoverSku
,
bailunSku
,
warehouseCode
,
bailunFirstLevelCatagoryId
,
dcAutoSales
,
JSON
.
toJSONString
(
forecastSalesList
),
dcAutoTurnover
,
saveDaysMap
);
BigDecimal
totalSafeInventory
=
calculateSafeInventory
(
turnoverSku
,
bailunSku
,
warehouseCode
,
bailunFirstLevelCatagoryId
,
dcAutoSales
,
JSON
.
toJSONString
(
forecastSalesList
),
dcAutoTurnover
,
saveDaysMap
);
Integer
moq
=
turnoverSku
.
getMoq
();
/*
...
...
@@ -494,11 +502,13 @@ public class AutoTurnoverJob extends PointJob {
/*
* forecastFluctuationList 用于存放预计缺货 实际缺货 预计冗余 实际冗余的数据
* dcAutoConfigSkuWarehouse
看是否监控状态
* dcAutoConfigSkuWarehouse
* hasMonitorFluctuation 是否停止监控波动功能
*/
List
<
DcAutoForecastFluctuation
>
forecastFluctuationList
=
new
ArrayList
<>(
turnoverDays
);
DcAutoConfigSkuWarehouse
dcAutoConfigSkuWarehouse
=
getAutoConfigSkuWarehouse
(
bailunSku
,
warehouseCode
);
//看是否监控状态
DcAutoConfigSkuWarehouse
dcAutoConfigSkuWarehouse
=
this
.
getAutoConfigSkuWarehouse
(
bailunSku
,
warehouseCode
);
//是否开启监控波动功能
boolean
hasMonitorFluctuation
=
actualForecastFluctuations
(
dcAutoTurnover
,
recordTime
,
forecastSalesList
,
realInventory
,
totalSafeInventory
,
outStock
,
dcAutoConfigSkuWarehouse
,
avgHistoryFourteendaySales
,
avgHistoryThreedaySales
,
forecastFluctuationList
);
/*
...
...
@@ -519,14 +529,47 @@ public class AutoTurnoverJob extends PointJob {
* 获取采购建议-普通仓库
* 实际缺货 + 总销量 - 总预计入库 + (安全库存 - 预测库存) + 周转天的销量
*/
inventoryAvailableDays
=
commonAdvise
(
turnoverSku
,
bailunSku
,
warehouseCode
,
hasMonitorFluctuation
,
forecastFluctuationList
,
recordTime
,
dcAutoTurnover
,
turnoverDays
,
autoForecastDay
,
forecastInventoryList
,
forecastInboundList
,
forecastSalesList
,
forecastShortSupplyList
,
forecastPurchaseAdvisedList
,
moqPurchaseAdvisedList
,
realInventory
,
totalSafeInventory
,
outStock
,
inventoryAvailableDays
,
totalSales
,
totalInbound
,
moqDecimal
,
saveDaysMap
);
inventoryAvailableDays
=
commonAdvise
(
turnoverSku
,
bailunSku
,
warehouseCode
,
hasMonitorFluctuation
,
forecastFluctuationList
,
recordTime
,
dcAutoTurnover
,
turnoverDays
,
autoForecastDay
,
forecastInventoryList
,
forecastInboundList
,
forecastSalesList
,
forecastShortSupplyList
,
forecastPurchaseAdvisedList
,
moqPurchaseAdvisedList
,
realInventory
,
totalSafeInventory
,
outStock
,
inventoryAvailableDays
,
totalSales
,
totalInbound
,
moqDecimal
,
saveDaysMap
);
}
/*
* 自动下单管理的冗余-缺货等异常提醒
*/
if
(
hasMonitorFluctuation
)
{
unusualFluctuation
(
totalSafeInventory
,
turnoverDays
,
recordTime
,
dcAutoConfigSkuWarehouse
,
turnoverSku
,
warehouseCode
,
dcAutoTurnover
,
avgHistoryThreedaySales
,
forecastFluctuationList
,
forecastShortSupplyList
,
forecastInventoryList
,
dcBaseStock
);
unusualFluctuation
(
totalSafeInventory
,
turnoverDays
,
recordTime
,
dcAutoConfigSkuWarehouse
,
turnoverSku
,
warehouseCode
,
dcAutoTurnover
,
avgHistoryThreedaySales
,
forecastFluctuationList
,
forecastShortSupplyList
,
forecastInventoryList
,
dcBaseStock
);
}
//拿一下2倍周转期内的入库总数
...
...
@@ -794,18 +837,47 @@ public class AutoTurnoverJob extends PointJob {
}
/**
* <p>
* 不正常的波动
* 实际缺货的,预计缺货
* 实际冗余的,预计冗余(库存> 销量 + 安全库存)
* 波动提醒优先级 --> 实际缺货-实际断货-实际冗余-预计缺货-预计冗余
* </p>
*
* @param totalSafeInventory
* @param turnoverDays
* @param recordTime
* @param dcAutoConfigSkuWarehouse
* @param turnoverSku
* @param warehouseCode
* @param dcAutoTurnover
* @param avgHistoryThreedaySales
* @param forecastFluctuationList
* @param forecastShortSupplyList
* @param forecastInventoryList
* @param dcBaseStock
*/
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
,
DcBaseStock
dcBaseStock
)
{
int
days
=
0
;
//连续冗余或缺货天数
int
index
=
-
1
;
//冗余或缺货天数索引
if
(
forecastShortSupplyList
.
get
(
turnoverDays
).
compareTo
(
BigDecimal
.
ZERO
)
==
1
)
{
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
,
DcBaseStock
dcBaseStock
)
{
//连续冗余或缺货天数
int
days
=
0
;
//冗余或缺货天数索引
int
index
=
-
1
;
if
(
forecastShortSupplyList
.
get
(
turnoverDays
).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
for
(
int
i
=
0
;
i
<=
turnoverDays
;
i
++)
{
if
(
forecastShortSupplyList
.
get
(
i
).
compareTo
(
BigDecimal
.
ZERO
)
==
1
)
{
if
(
forecastShortSupplyList
.
get
(
i
).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
days
++;
if
(
index
<
0
)
{
index
=
i
;
...
...
@@ -824,14 +896,15 @@ public class AutoTurnoverJob extends PointJob {
}
}
if
(
forecastInventoryList
.
get
(
turnoverDays
).
compareTo
(
totalSafeInventory
)
==
1
)
{
if
(
forecastInventoryList
.
get
(
turnoverDays
).
compareTo
(
totalSafeInventory
)
>
0
)
{
for
(
int
i
=
0
;
i
<=
turnoverDays
;
i
++)
{
if
(
i
<
turnoverDays
&&
forecastInventoryList
.
get
(
i
).
compareTo
(
totalSafeInventory
)
==
1
)
{
days
++;
if
(
index
<
0
)
{
index
=
i
;
}
if
(
i
==
turnoverDays
&&
index
>=
0
)
{
//如果是最后一天
//如果是最后一天
if
(
i
==
turnoverDays
&&
index
>=
0
)
{
handleForecastFluctuation
(
4
,
forecastFluctuationList
,
recordTime
,
days
,
index
);
}
}
else
if
(
index
>=
0
)
{
...
...
@@ -845,7 +918,10 @@ public class AutoTurnoverJob extends PointJob {
DcAutoForecastFluctuationMapper
mapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoForecastFluctuationMapper
.
class
);
//JIT的 可以不做 冗余 和 缺货预测 实际冗余和实际缺货也不用提醒
//如果仓库是广州01 且 是这三个销售员, 就不提醒
if
(!
warehouseCode
.
equals
(
Constant
.
WAREHOUSE_JIT
)
||
!
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_1
)
&&
!
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_2
)
&&
!
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_3
))
{
if
(!
warehouseCode
.
equals
(
Constant
.
WAREHOUSE_JIT
)
||
!
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_1
)
&&
!
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_2
)
&&
!
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_3
))
{
if
(
dcAutoConfigSkuWarehouse
==
null
||
dcAutoConfigSkuWarehouse
.
getStatus
().
equals
(
0
))
{
if
(
forecastFluctuationList
!=
null
&&
forecastFluctuationList
.
size
()
>
0
)
{
...
...
@@ -880,10 +956,14 @@ public class AutoTurnoverJob extends PointJob {
mapper
.
insertSelective
(
dcAutoForecastFluctuation
);
}
}
else
{
mapper
.
deleteByExample
(
DcAutoForecastFluctuationExample
.
newAndCreateCriteria
().
andBailunSkuEqualTo
(
turnoverSku
.
getBailunSku
()).
andWarehouseCodeEqualTo
(
warehouseCode
).
example
());
mapper
.
deleteByExample
(
DcAutoForecastFluctuationExample
.
newAndCreateCriteria
()
.
andBailunSkuEqualTo
(
turnoverSku
.
getBailunSku
())
.
andWarehouseCodeEqualTo
(
warehouseCode
).
example
());
}
}
else
if
(
dcAutoConfigSkuWarehouse
!=
null
&&
dcAutoConfigSkuWarehouse
.
getStatus
().
equals
(
1
))
{
mapper
.
deleteByExample
(
DcAutoForecastFluctuationExample
.
newAndCreateCriteria
().
andBailunSkuEqualTo
(
turnoverSku
.
getBailunSku
()).
andWarehouseCodeEqualTo
(
warehouseCode
).
example
());
mapper
.
deleteByExample
(
DcAutoForecastFluctuationExample
.
newAndCreateCriteria
()
.
andBailunSkuEqualTo
(
turnoverSku
.
getBailunSku
())
.
andWarehouseCodeEqualTo
(
warehouseCode
).
example
());
}
}
}
catch
(
Exception
e
)
{
...
...
@@ -1473,12 +1553,29 @@ public class AutoTurnoverJob extends PointJob {
}
private
Integer
fbaAdvise
(
DcBaseSku
turnoverSku
,
String
warehouseCode
,
boolean
hasMonitorFluctuation
,
List
<
DcAutoForecastFluctuation
>
forecastFluctuationList
,
LocalDate
recordTime
,
DcAutoTurnover
dcAutoTurnover
,
Integer
turnoverDays
,
Integer
autoForecastDay
,
List
<
BigDecimal
>
forecastInventoryList
,
List
<
Integer
>
forecastInboundList
,
List
<
BigDecimal
>
forecastSalesList
,
List
<
BigDecimal
>
forecastShortSupplyList
,
List
<
BigDecimal
>
forecastPurchaseAdvisedList
,
List
<
BigDecimal
>
moqPurchaseAdvisedList
,
Integer
realInventory
,
BigDecimal
totalSafeInventory
,
Integer
outStock
,
Integer
inventoryAvailableDays
,
BigDecimal
totalSales
,
BigDecimal
totalInbound
,
BigDecimal
moqDecimal
,
List
<
Integer
>
historySalesList
,
List
<
String
>
forecastSalesExplainList
)
{
private
Integer
fbaAdvise
(
DcBaseSku
turnoverSku
,
String
warehouseCode
,
boolean
hasMonitorFluctuation
,
List
<
DcAutoForecastFluctuation
>
forecastFluctuationList
,
LocalDate
recordTime
,
DcAutoTurnover
dcAutoTurnover
,
Integer
turnoverDays
,
Integer
autoForecastDay
,
List
<
BigDecimal
>
forecastInventoryList
,
List
<
Integer
>
forecastInboundList
,
List
<
BigDecimal
>
forecastSalesList
,
List
<
BigDecimal
>
forecastShortSupplyList
,
List
<
BigDecimal
>
forecastPurchaseAdvisedList
,
List
<
BigDecimal
>
moqPurchaseAdvisedList
,
Integer
realInventory
,
BigDecimal
totalSafeInventory
,
Integer
outStock
,
Integer
inventoryAvailableDays
,
BigDecimal
totalSales
,
BigDecimal
totalInbound
,
BigDecimal
moqDecimal
,
List
<
Integer
>
historySalesList
,
List
<
String
>
forecastSalesExplainList
)
{
BigDecimal
inboundDecimal
;
//入库数量
BigDecimal
forecastInventory
;
//预测库存
BigDecimal
shortSupply
;
//缺货数量
...
...
@@ -1678,7 +1775,23 @@ public class AutoTurnoverJob extends PointJob {
}
private
void
handleForecastFluctuation
(
Integer
type
,
List
<
DcAutoForecastFluctuation
>
forecastFluctuationList
,
LocalDate
recordTime
,
int
forecastFluctuationDays
,
int
forecastFluctuationIndex
)
{
/**
* <p>
* jb
* </p>
*
* @param type 1实际缺货2预计缺货3实际冗余4预计冗余5断
* @param forecastFluctuationList 自动周转预测断货和冗余波动结果容器
* @param recordTime 记录时间
* @param forecastFluctuationDays jb
* @param forecastFluctuationIndex jb
*/
private
void
handleForecastFluctuation
(
Integer
type
,
List
<
DcAutoForecastFluctuation
>
forecastFluctuationList
,
LocalDate
recordTime
,
int
forecastFluctuationDays
,
int
forecastFluctuationIndex
)
{
DcAutoForecastFluctuation
forecastFluctuation
=
new
DcAutoForecastFluctuation
();
forecastFluctuation
.
setStartTime
(
recordTime
.
plusDays
(
forecastFluctuationIndex
));
forecastFluctuation
.
setEndTime
(
forecastFluctuation
.
getStartTime
().
plusDays
(
Math
.
abs
(
forecastFluctuationDays
)));
...
...
@@ -1686,11 +1799,29 @@ public class AutoTurnoverJob extends PointJob {
forecastFluctuationList
.
add
(
forecastFluctuation
);
}
private
Integer
commonAdvise
(
DcBaseSku
turnoverSku
,
String
bailunSku
,
String
warehouseCode
,
boolean
hasMonitorFluctuation
,
List
<
DcAutoForecastFluctuation
>
forecastFluctuationList
,
LocalDate
recordTime
,
DcAutoTurnover
dcAutoTurnover
,
Integer
turnoverDays
,
Integer
autoForecastDay
,
List
<
BigDecimal
>
forecastInventoryList
,
List
<
Integer
>
forecastInboundList
,
List
<
BigDecimal
>
forecastSalesList
,
List
<
BigDecimal
>
forecastShortSupplyList
,
List
<
BigDecimal
>
forecastPurchaseAdvisedList
,
List
<
BigDecimal
>
moqPurchaseAdvisedList
,
Integer
realInventory
,
BigDecimal
totalSafeInventory
,
Integer
outStock
,
Integer
inventoryAvailableDays
,
BigDecimal
totalSales
,
BigDecimal
totalInbound
,
BigDecimal
moqDecimal
,
Map
<
String
,
BigDecimal
>
saveDaysMap
)
{
private
Integer
commonAdvise
(
DcBaseSku
turnoverSku
,
String
bailunSku
,
String
warehouseCode
,
boolean
hasMonitorFluctuation
,
List
<
DcAutoForecastFluctuation
>
forecastFluctuationList
,
LocalDate
recordTime
,
DcAutoTurnover
dcAutoTurnover
,
Integer
turnoverDays
,
Integer
autoForecastDay
,
List
<
BigDecimal
>
forecastInventoryList
,
List
<
Integer
>
forecastInboundList
,
List
<
BigDecimal
>
forecastSalesList
,
List
<
BigDecimal
>
forecastShortSupplyList
,
List
<
BigDecimal
>
forecastPurchaseAdvisedList
,
List
<
BigDecimal
>
moqPurchaseAdvisedList
,
Integer
realInventory
,
BigDecimal
totalSafeInventory
,
Integer
outStock
,
Integer
inventoryAvailableDays
,
BigDecimal
totalSales
,
BigDecimal
totalInbound
,
BigDecimal
moqDecimal
,
Map
<
String
,
BigDecimal
>
saveDaysMap
)
{
BigDecimal
inboundDecimal
;
BigDecimal
forecastInventory
;
BigDecimal
shortSupply
;
...
...
data-show/show-auto-turnover/src/main/java/com/bailuntec/service/impl/AutoSalesServiceImpl.java
View file @
39892e90
...
...
@@ -56,9 +56,9 @@ public class AutoSalesServiceImpl implements AutoSalesService {
dcAutoSales
.
setBVariable
(
beta
);
dcAutoSales
.
setRVariable
(
r2
);
dcAutoSales
.
setForecastFormula
(
formula
);
BeanUtils
.
copyProperties
(
dcAutoSales
,
salesVolumeDTO
);
BeanUtils
.
copyProperties
(
dcAutoSales
,
salesVolumeDTO
);
//将历史销量详细,存入销量表
dcAutoSales
.
setHistorySalesDetails
(
"["
+
historySales
+
"]"
);
dcAutoSales
.
setHistorySalesDetails
(
"["
+
historySales
+
"]"
);
dcAutoSales
.
setAverageSales
(
avgSales
);
/*
* 根据不同的历史销量和趋势选择不同的预测算法
...
...
data-show/show-auto-turnover/src/main/java/com/bailuntec/service/impl/AutoTurnoverServiceImpl.java
View file @
39892e90
...
...
@@ -8,6 +8,7 @@ import com.bailuntec.mapper.DcBaseOmsSkuMapper;
import
com.bailuntec.service.AutoTurnoverService
;
import
com.bailuntec.utils.SessionUtil
;
import
com.google.gson.Gson
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.ibatis.session.SqlSession
;
import
java.math.BigDecimal
;
...
...
@@ -53,6 +54,8 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
String
warehouseCode
=
dcAutoTurnover
.
getWarehouseCode
();
Queue
<
BigDecimal
>
forecastSalesDetails
=
new
LinkedList
<>();
//销量公式
Queue
<
String
>
forecastSalesDetailsFormula
=
new
LinkedList
<>();
//获取过去7天的销量
BigDecimal
last1DaySellerNum
=
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
1
),
midNight
,
bailunSku
,
warehouseCode
)).
orElse
(
0
));
...
...
@@ -65,12 +68,20 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
forecastSalesDetails
.
offer
(
last1DaySellerNum
);
forecastSalesDetailsFormula
.
offer
(
StringUtils
.
SPACE
);
forecastSalesDetails
.
offer
(
last2DaySellerNum
);
forecastSalesDetailsFormula
.
offer
(
StringUtils
.
SPACE
);
forecastSalesDetails
.
offer
(
last3DaySellerNum
);
forecastSalesDetailsFormula
.
offer
(
StringUtils
.
SPACE
);
forecastSalesDetails
.
offer
(
last4DaySellerNum
);
forecastSalesDetailsFormula
.
offer
(
StringUtils
.
SPACE
);
forecastSalesDetails
.
offer
(
last5DaySellerNum
);
forecastSalesDetailsFormula
.
offer
(
StringUtils
.
SPACE
);
forecastSalesDetails
.
offer
(
last6DaySellerNum
);
forecastSalesDetailsFormula
.
offer
(
StringUtils
.
SPACE
);
forecastSalesDetails
.
offer
(
last7DaySellerNum
);
forecastSalesDetailsFormula
.
offer
(
StringUtils
.
SPACE
);
if
(
dcAutoSalesForecastStageConfig
!=
null
)
{
int
duration1
=
BigDecimal
.
valueOf
(
turnoverDays
).
multiply
(
dcAutoSalesForecastStageConfig
.
getOneRatio
()).
intValue
();
...
...
@@ -88,6 +99,11 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
for
(
int
i
=
0
;
i
<
duration1
;
i
++)
{
forecastSalesDetails
.
offer
(
duration1ForecastSellerNum
);
forecastSalesDetailsFormula
.
offer
(
"("
+
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
)
+
"*"
+
dcAutoSalesForecastStageConfig
.
getOneN2
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getOneN4
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getOneN6
()
+
")"
);
}
/*第二部分预测*/
...
...
@@ -100,6 +116,13 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
for
(
int
i
=
0
;
i
<
duration2
;
i
++)
{
forecastSalesDetails
.
offer
(
duration2ForecastSellerNum
);
forecastSalesDetailsFormula
.
offer
(
"("
+
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
)
+
"*"
+
dcAutoSalesForecastStageConfig
.
getTwoN2
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getTwoN4
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getTwoN6
()
+
")"
);
}
...
...
@@ -113,14 +136,22 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
for
(
int
i
=
0
;
i
<
duration3
;
i
++)
{
forecastSalesDetails
.
offer
(
duration3ForecastSellerNum
);
forecastSalesDetailsFormula
.
offer
(
"("
+
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
)
+
"*"
+
dcAutoSalesForecastStageConfig
.
getThreeN2
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getThreeN4
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getThreeN6
()
+
")"
);
}
dcAutoTurnover
.
setSalesDetails
(
new
Gson
().
toJson
(
forecastSalesDetails
));
dcAutoTurnover
.
setSalesDetailsFormula
(
new
Gson
().
toJson
(
forecastSalesDetailsFormula
));
// dcAutoTurnoverMapper.updateByPrimaryKey(dcAutoTurnover);
}
else
{
for
(
int
i
=
0
;
i
<
turnoverDays
;
i
++)
{
forecastSalesDetails
.
offer
(
dcAutoTurnover
.
getDailyWeightedSales
())
forecastSalesDetails
.
offer
(
dcAutoTurnover
.
getDailyWeightedSales
())
;
}
}
...
...
data-show/show-auto-turnover/src/test/java/com/bailuntec/service/impl/AutoTurnoverServiceImplTest.java
View file @
39892e90
...
...
@@ -29,6 +29,7 @@ class AutoTurnoverServiceImplTest {
DcAutoTurnover
dcAutoTurnover
=
dcAutoTurnoverMapper
.
selectByPrimaryKey
(
58845
);
autoTurnoverService
.
setAutoTurnoverSaleDetails
(
dcAutoTurnover
);
System
.
out
.
println
(
dcAutoTurnover
.
getSalesDetails
());
System
.
out
.
println
(
dcAutoTurnover
.
getSalesDetailsFormula
());
}
finally
{
SessionUtil
.
closeSession
();
}
...
...
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