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
2806c3a3
Commit
2806c3a3
authored
Aug 11, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
1c15608d
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
649 additions
and
410 deletions
+649
-410
AccountPlatformType.java
...a/com/bailuntec/domain/enumerate/AccountPlatformType.java
+7
-1
DcAutoUprushConfigMapper.java
...n/java/com/bailuntec/mapper/DcAutoUprushConfigMapper.java
+10
-2
DcBaseStockMapper.java
...src/main/java/com/bailuntec/mapper/DcBaseStockMapper.java
+66
-10
DcBaseStockMapper.xml
.../src/main/java/com/bailuntec/mapper/DcBaseStockMapper.xml
+0
-0
PointJob.java
...-common/src/main/java/com/bailuntec/support/PointJob.java
+4
-3
DcBaseStockMapperTest.java
...test/java/com/bailuntec/mapper/DcBaseStockMapperTest.java
+38
-0
Application.java
...uto-turnover/src/main/java/com/bailuntec/Application.java
+23
-14
AutoTurnoverJob.java
...over/src/main/java/com/bailuntec/job/AutoTurnoverJob.java
+409
-353
AutoTurnoverJobListener.java
.../java/com/bailuntec/listener/AutoTurnoverJobListener.java
+1
-17
job.properties
...show/show-auto-turnover/src/main/resources/job.properties
+14
-8
log4j.properties
...ow/show-auto-turnover/src/main/resources/log4j.properties
+75
-0
AutoTurnoverTest.java
...ow/show-auto-turnover/src/test/java/AutoTurnoverTest.java
+2
-2
No files found.
data-common/src/main/java/com/bailuntec/domain/enumerate/AccountPlatformType.java
View file @
2806c3a3
...
...
@@ -2,7 +2,7 @@ package com.bailuntec.domain.enumerate;
public
enum
AccountPlatformType
{
Amazon
(
15
,
"AMAZON"
),
Amazon
(
15
,
"AMAZON"
),
Wish
(
8
,
"WISH"
),
Cdiscount
(
10
,
"CDISCOUNT"
),
Ebay
(
12
,
"EBAY"
),
...
...
@@ -30,4 +30,10 @@ public enum AccountPlatformType {
public
int
code
()
{
return
code
;
}
public
static
class
Shopify
{
public
static
Integer
code
()
{
return
1
;
}
}
}
data-common/src/main/java/com/bailuntec/mapper/DcAutoUprushConfigMapper.java
View file @
2806c3a3
...
...
@@ -56,6 +56,15 @@ public interface DcAutoUprushConfigMapper {
*/
DcAutoUprushConfig
selectOneByExample
(
DcAutoUprushConfigExample
example
);
/**
* <p>
* 不知道什么鸡巴
* </p>
*
* @param warehouseCode 仓库编码
* @param hqType 环球仓库类型
* @return 销量突增检测
*/
DcAutoUprushConfig
selectOneByWarehouse
(
@Param
(
"warehouseCode"
)
String
warehouseCode
,
@Param
(
"hqType"
)
String
hqType
);
/**
...
...
@@ -123,4 +132,4 @@ public interface DcAutoUprushConfigMapper {
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int
upsertSelective
(
DcAutoUprushConfig
record
);
}
\ No newline at end of file
}
data-common/src/main/java/com/bailuntec/mapper/DcBaseStockMapper.java
View file @
2806c3a3
...
...
@@ -2,8 +2,10 @@ package com.bailuntec.mapper;
import
com.bailuntec.domain.entity.DcBaseStock
;
import
com.bailuntec.domain.example.DcBaseStockExample
;
import
com.dangdang.ddframe.job.api.ShardingContext
;
import
org.apache.ibatis.annotations.Param
;
import
java.time.LocalDateTime
;
import
java.util.List
;
public
interface
DcBaseStockMapper
{
...
...
@@ -130,23 +132,78 @@ public interface DcBaseStockMapper {
void
insertDailyStock
();
List
<
DcBaseStock
>
listStockById
(
@Param
(
"v1"
)
int
v1
,
@Param
(
"v2"
)
int
v2
);
List
<
DcBaseStock
>
listStockById
(
ShardingContext
shardingContext
,
@Param
(
"v1"
)
int
v1
,
@Param
(
"v2"
)
int
v2
);
List
<
DcBaseStock
>
listStockWarehouseById
(
@Param
(
"v1"
)
int
v1
,
@Param
(
"v2"
)
int
v2
,
@Param
(
"warehouseCode"
)
String
warehouseCode
);
List
<
DcBaseStock
>
listParameterStockById
(
@Param
(
"
jobParameter"
)
String
jobParameter
,
@Param
(
"v1"
)
int
v1
,
@Param
(
"v2"
)
int
v2
);
List
<
DcBaseStock
>
listParameterStockById
(
@Param
(
"
shardingContext"
)
ShardingContext
shardingContext
,
@Param
(
"v1"
)
int
v1
,
@Param
(
"v2"
)
int
v2
);
List
<
DcBaseStock
>
listAllStock
(
@Param
(
"v1"
)
int
v1
,
@Param
(
"v2"
)
int
v2
);
List
<
DcBaseStock
>
listAllStock
(
@Param
(
"
shardingContext"
)
ShardingContext
shardingContext
,
@Param
(
"
v1"
)
int
v1
,
@Param
(
"v2"
)
int
v2
);
List
<
DcBaseStock
>
listWarehouseStockById
(
@Param
(
"
warehouseCode"
)
String
warehouseCode
,
@Param
(
"v1"
)
int
v1
,
@Param
(
"v2"
)
int
v2
);
List
<
DcBaseStock
>
listWarehouseStockById
(
@Param
(
"
shardingContext"
)
ShardingContext
shardingContext
,
@Param
(
"warehouseCode"
)
String
warehouseCode
,
@Param
(
"v1"
)
int
v1
,
@Param
(
"v2"
)
int
v2
);
List
<
DcBaseStock
>
listInStockNotInAutoTurnover
();
long
countByParam
(
@Param
(
"jobParameter"
)
String
jobParameter
);
// long countByParam(@Param("jobParameter") String jobParameter);
//
// long countAll();
//
// long countByWarehouseCode(@Param("warehouseCode") String warehouseCode);
long
countAll
();
void
updateSkuUnitPrice
();
long
countByWarehouseCode
(
@Param
(
"warehouseCode"
)
String
warehouseCode
);
// /**
// * <p>
// * 自动周转列表普通同步数量
// * </p>
// *
// * @return count
// */
// long countNormal();
void
updateSkuUnitPrice
();
}
\ No newline at end of file
/**
* <p>
* 自动周转列表普通同步库存列表
* </p>
*
* @param shardingContext shardingContext
* @param pageStart pageStart
* @param pageOffset pageOffset
* @return 库存列表
*/
List
<
DcBaseStock
>
listNormal
(
@Param
(
"shardingContext"
)
ShardingContext
shardingContext
,
@Param
(
"pageStart"
)
int
pageStart
,
@Param
(
"pageOffset"
)
int
pageOffset
);
long
countByParam
(
@Param
(
"shardingContext"
)
ShardingContext
shardingContext
);
long
countAll
(
@Param
(
"shardingContext"
)
ShardingContext
shardingContext
);
long
countNormal
(
@Param
(
"shardingContext"
)
ShardingContext
shardingContext
);
long
countByWarehouseCode
(
@Param
(
"shardingContext"
)
ShardingContext
shardingContext
);
/**
* <p>
* 补充晚上定时任务的数据 count
* </p>
*
* @param shardingContext shardingContext
* @param v1 当天凌晨三点
* @param v2 当天往前一周的零点
* @return count
*/
long
countIncrement
(
@Param
(
"shardingContext"
)
ShardingContext
shardingContext
,
@Param
(
"v1"
)
LocalDateTime
v1
,
@Param
(
"v2"
)
LocalDateTime
v2
);
/**
* <p>
* 补充晚上定时任务的数据
* </p>
*
* @param shardingContext shardingContext
* @param v1 当天凌晨三点
* @param v2 当天往前一周的零点
* @param pageStart pageStart
* @param pageOffset pageOffset
* @return 补充晚上定时任务的数据
*/
List
<
DcBaseStock
>
increment
(
@Param
(
"shardingContext"
)
ShardingContext
shardingContext
,
@Param
(
"v1"
)
LocalDateTime
v1
,
@Param
(
"v2"
)
LocalDateTime
v2
,
@Param
(
"pageStart"
)
int
pageStart
,
@Param
(
"pageOffset"
)
int
pageOffset
);
}
data-common/src/main/java/com/bailuntec/mapper/DcBaseStockMapper.xml
View file @
2806c3a3
This source diff could not be displayed because it is too large. You can
view the blob
instead.
data-common/src/main/java/com/bailuntec/support/PointJob.java
View file @
2806c3a3
...
...
@@ -11,7 +11,8 @@ import lombok.extern.slf4j.Slf4j;
import
java.time.LocalDateTime
;
@Slf4j
public
class
PointJob
implements
SimpleJob
{
public
abstract
class
PointJob
implements
SimpleJob
{
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
JobPointLog
jobPointLog
=
jobInit
(
shardingContext
);
...
...
@@ -38,6 +39,7 @@ public class PointJob implements SimpleJob {
JobPointLog
jobPointLog
=
null
;
try
{
JobPointLogMapper
mapper
=
SessionUtil
.
getSession
().
getMapper
(
JobPointLogMapper
.
class
);
jobPointLog
=
mapper
.
selectOneByExample
(
JobPointLogExample
.
newAndCreateCriteria
().
andJobNameEqualTo
(
shardingContext
.
getJobName
()).
example
());
if
(
jobPointLog
==
null
)
{
jobPointLog
=
new
JobPointLog
(
shardingContext
.
getJobName
(),
1
,
100
,
0
,
1
,
LocalDateTime
.
now
().
minusDays
(
1
),
LocalDateTime
.
now
());
...
...
@@ -51,8 +53,7 @@ public class PointJob implements SimpleJob {
return
jobPointLog
;
}
public
void
executeJob
(
ShardingContext
shardingContext
,
JobPointLog
jobPointLog
)
{
public
abstract
void
executeJob
(
ShardingContext
shardingContext
,
JobPointLog
jobPointLog
);
}
}
data-mid/mid-duration-stock/src/test/java/com/bailuntec/mapper/DcBaseStockMapperTest.java
0 → 100644
View file @
2806c3a3
package
com
.
bailuntec
.
mapper
;
import
com.bailuntec.utils.SessionUtil
;
import
com.dangdang.ddframe.job.api.ShardingContext
;
import
com.dangdang.ddframe.job.executor.ShardingContexts
;
import
org.junit.jupiter.api.Test
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.util.HashMap
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/8/11 5:00 下午
*/
class
DcBaseStockMapperTest
{
@Test
void
countIncrement
()
{
}
@Test
void
increment
()
{
DcBaseStockMapper
dcBaseStockMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcBaseStockMapper
.
class
);
ShardingContexts
shardingContexts
=
new
ShardingContexts
(
"1"
,
"jobName"
,
8
,
"INCREMENT"
,
new
HashMap
<>(),
1
);
LocalDateTime
v1
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
).
plusHours
(
3
);
LocalDateTime
v2
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
).
minusDays
(
7
);
dcBaseStockMapper
.
increment
(
new
ShardingContext
(
shardingContexts
,
1
),
v1
,
v2
,
0
,
100
);
}
}
data-show/show-auto-turnover/src/main/java/com/bailuntec/Application.java
View file @
2806c3a3
package
com
.
bailuntec
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.bailuntec.listener.AutoTurnoverJobListener
;
import
com.bailuntec.job.AutoTurnoverJob
;
import
com.bailuntec.listener.AutoTurnoverJobListener
;
import
com.bailuntec.utils.PropertiesUtil
;
import
com.dangdang.ddframe.job.config.JobCoreConfiguration
;
import
com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration
;
...
...
@@ -24,33 +24,42 @@ public class Application {
private
static
final
String
EVENT_RDB_STORAGE_URL
=
propertiesUtil
.
getPropertyAsString
(
"EVENT_RDB_STORAGE_URL"
);
private
static
final
String
EVENT_RDB_STORAGE_USERNAME
=
propertiesUtil
.
getPropertyAsString
(
"EVENT_RDB_STORAGE_USERNAME"
);
private
static
final
String
EVENT_RDB_STORAGE_PASSWORD
=
propertiesUtil
.
getPropertyAsString
(
"EVENT_RDB_STORAGE_PASSWORD"
);
public
static
void
main
(
String
[]
args
)
{
new
JobScheduler
(
createRegistryCenter
(),
createJobConfiguration
(),
createJobEventConfiguration
(),
new
AutoTurnoverJobListener
()).
init
();
new
JobScheduler
(
createRegistryCenter
(),
createJobConfiguration
Param
(),
createJobEventConfiguration
(),
new
AutoTurnoverJobListener
()).
init
();
new
JobScheduler
(
createRegistryCenter
(),
createJobConfiguration
Normal
(),
createJobEventConfiguration
(),
new
AutoTurnoverJobListener
()).
init
();
new
JobScheduler
(
createRegistryCenter
(),
createJobConfiguration
Increment
(),
createJobEventConfiguration
(),
new
AutoTurnoverJobListener
()).
init
();
}
private
static
CoordinatorRegistryCenter
createRegistryCenter
()
{
CoordinatorRegistryCenter
regCenter
=
new
ZookeeperRegistryCenter
(
new
ZookeeperConfiguration
(
propertiesUtil
.
getPropertyAsString
(
"ZOOKEEPER_SERVER"
),
propertiesUtil
.
getPropertyAsString
(
"NAME_SPACE"
)));
CoordinatorRegistryCenter
regCenter
=
new
ZookeeperRegistryCenter
(
new
ZookeeperConfiguration
(
propertiesUtil
.
getPropertyAsString
(
"ZOOKEEPER_SERVER"
),
propertiesUtil
.
getPropertyAsString
(
"NAME_SPACE"
)));
regCenter
.
init
();
return
regCenter
;
}
private
static
LiteJobConfiguration
createJobConfiguration
()
{
JobCoreConfiguration
simpleCoreConfig
=
JobCoreConfiguration
.
newBuilder
(
propertiesUtil
.
getPropertyAsString
(
"JOB_NAME"
),
propertiesUtil
.
getPropertyAsString
(
"JOB_CRON"
),
propertiesUtil
.
getPropertyAsInt
(
"SHARDING_TOTAL_COUNT"
)).
build
();
private
static
LiteJobConfiguration
createJobConfigurationNormal
()
{
JobCoreConfiguration
simpleCoreConfig
=
JobCoreConfiguration
.
newBuilder
(
propertiesUtil
.
getPropertyAsString
(
"JOB_NAME"
),
propertiesUtil
.
getPropertyAsString
(
"JOB_CRON"
),
propertiesUtil
.
getPropertyAsInt
(
"SHARDING_TOTAL_COUNT"
))
.
jobParameter
(
"NORMAL"
)
.
build
();
SimpleJobConfiguration
simpleJobConfig
=
new
SimpleJobConfiguration
(
simpleCoreConfig
,
AutoTurnoverJob
.
class
.
getCanonicalName
());
LiteJobConfiguration
simpleJobRootConfig
=
LiteJobConfiguration
.
newBuilder
(
simpleJobConfig
).
build
();
return
simpleJobRootConfig
;
return
LiteJobConfiguration
.
newBuilder
(
simpleJobConfig
).
build
();
}
private
static
LiteJobConfiguration
createJobConfigurationParam
()
{
JobCoreConfiguration
simpleCoreConfig
=
JobCoreConfiguration
.
newBuilder
(
propertiesUtil
.
getPropertyAsString
(
"JOB_NAME_PARAM"
),
propertiesUtil
.
getPropertyAsString
(
"JOB_CRON_PARAM"
),
propertiesUtil
.
getPropertyAsInt
(
"SHARDING_TOTAL_COUNT_PARAM"
)).
build
();
private
static
LiteJobConfiguration
createJobConfigurationIncrement
()
{
JobCoreConfiguration
simpleCoreConfig
=
JobCoreConfiguration
.
newBuilder
(
propertiesUtil
.
getPropertyAsString
(
"JOB_NAME_INCREMENT"
),
propertiesUtil
.
getPropertyAsString
(
"JOB_CRON_INCREMENT"
),
propertiesUtil
.
getPropertyAsInt
(
"SHARDING_TOTAL_COUNT_INCREMENT"
))
.
jobParameter
(
"INCREMENT"
)
.
build
();
SimpleJobConfiguration
simpleJobConfig
=
new
SimpleJobConfiguration
(
simpleCoreConfig
,
AutoTurnoverJob
.
class
.
getCanonicalName
());
LiteJobConfiguration
simpleJobRootConfig
=
LiteJobConfiguration
.
newBuilder
(
simpleJobConfig
).
build
();
return
simpleJobRootConfig
;
return
LiteJobConfiguration
.
newBuilder
(
simpleJobConfig
).
build
();
}
private
static
JobEventConfiguration
createJobEventConfiguration
()
{
JobEventConfiguration
jobEventRdbConfig
=
new
JobEventRdbConfiguration
(
setUpEventTraceDataSource
());
return
jobEventRdbConfig
;
return
new
JobEventRdbConfiguration
(
setUpEventTraceDataSource
());
}
private
static
DataSource
setUpEventTraceDataSource
()
{
...
...
data-show/show-auto-turnover/src/main/java/com/bailuntec/job/AutoTurnoverJob.java
View file @
2806c3a3
...
...
@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
import
com.alibaba.fastjson.TypeReference
;
import
com.bailuntec.domain.constant.CommonConstant
;
import
com.bailuntec.domain.constant.Constant
;
import
com.bailuntec.domain.dto.CatagoryDTO
;
import
com.bailuntec.domain.dto.SalesVolumeAvgDTO
;
import
com.bailuntec.domain.dto.SalesVolumeDTO
;
import
com.bailuntec.domain.entity.*
;
...
...
@@ -30,9 +29,12 @@ import java.math.RoundingMode;
import
java.net.URLDecoder
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.time.Period
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.concurrent.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
@Slf4j
public
class
AutoTurnoverJob
extends
PointJob
{
...
...
@@ -42,93 +44,119 @@ public class AutoTurnoverJob extends PointJob {
@Override
public
void
executeJob
(
ShardingContext
shardingContext
,
JobPointLog
jobPointLog
)
{
long
count
=
getTotalCount
(
shardingContext
.
getJobParameter
());
//分片需要处理的总条数
long
count
=
getTotalCount
(
shardingContext
);
log
.
info
(
"当前分片需要处理的总条数:{}"
,
count
);
//分片需要处理数据总页数
int
totalPage
=
getTotalPage
(
count
,
jobPointLog
.
getPageSize
());
/*
* 根据不同分片
* 再分页去处理数据
*/
int
shardingSize
=
totalPage
%
shardingContext
.
getShardingTotalCount
()
==
0
?
totalPage
/
shardingContext
.
getShardingTotalCount
()
:
totalPage
/
shardingContext
.
getShardingTotalCount
()
+
1
;
if
(
shardingContext
.
getShardingItem
()
+
1
<
shardingContext
.
getShardingTotalCount
())
{
totalPage
=
shardingSize
*
(
shardingContext
.
getShardingItem
()
+
1
);
}
if
(
totalPage
>
0
)
{
int
page
=
0
;
if
(
shardingContext
.
getShardingItem
()
>
0
)
{
page
=
shardingSize
*
shardingContext
.
getShardingItem
();
}
String
queryTime
=
DateTimeFormatter
.
ofPattern
(
CommonConstant
.
DATE_FORMAT
).
format
(
LocalDate
.
now
());
do
{
List
<
DcBaseStock
>
dcBaseStockList
=
null
;
//分页查SKU_仓库
try
{
DcBaseStockMapper
baseStockMapperFor
=
SessionUtil
.
getSession
().
getMapper
(
DcBaseStockMapper
.
class
);
//这里是根据id排序,方法名没改了
if
(
StringUtils
.
isBlank
(
shardingContext
.
getJobParameter
()))
{
dcBaseStockList
=
baseStockMapperFor
.
listStockById
(
page
*
jobPointLog
.
getPageSize
(),
jobPointLog
.
getPageSize
());
}
else
{
switch
(
shardingContext
.
getJobParameter
())
{
case
"国内仓"
:
case
"FBA仓"
:
case
"海外仓"
:
case
"第三方仓库"
:
case
"耗材仓"
:
dcBaseStockList
=
baseStockMapperFor
.
listParameterStockById
(
shardingContext
.
getJobParameter
(),
page
*
jobPointLog
.
getPageSize
(),
jobPointLog
.
getPageSize
());
break
;
case
"ALL"
:
dcBaseStockList
=
baseStockMapperFor
.
listAllStock
(
page
*
jobPointLog
.
getPageSize
(),
jobPointLog
.
getPageSize
());
break
;
default
:
dcBaseStockList
=
baseStockMapperFor
.
listWarehouseStockById
(
shardingContext
.
getJobParameter
(),
page
*
jobPointLog
.
getPageSize
(),
jobPointLog
.
getPageSize
());
}
}
log
.
info
(
"当前分片分页任务分页查询页码大小:{}"
,
jobPointLog
.
getPageSize
());
log
.
info
(
"当前分片需要处理的总页数:{}"
,
totalPage
);
AtomicInteger
countItem
=
new
AtomicInteger
(
0
);
ExecutorService
executorService
=
new
ThreadPoolExecutor
(
20
,
100
,
2
,
TimeUnit
.
MINUTES
,
new
LinkedBlockingQueue
<>(),
Executors
.
defaultThreadFactory
(),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"Mybatis操作DB分页查询失败"
,
e
);
}
finally
{
SessionUtil
.
closeSession
();
for
(
int
page
=
1
;
page
<=
totalPage
;
page
++)
{
//分页查SKU_仓库
List
<
DcBaseStock
>
dcBaseStockList
;
try
{
DcBaseStockMapper
baseStockMapperFor
=
SessionUtil
.
getSession
().
getMapper
(
DcBaseStockMapper
.
class
);
//这里是根据id排序,方法名没改了
if
(
StringUtils
.
isBlank
(
shardingContext
.
getJobParameter
()))
{
dcBaseStockList
=
baseStockMapperFor
.
listStockById
(
shardingContext
,
(
page
-
1
)
*
jobPointLog
.
getPageSize
(),
jobPointLog
.
getPageSize
());
}
else
{
switch
(
shardingContext
.
getJobParameter
())
{
case
"国内仓"
:
case
"FBA仓"
:
case
"海外仓"
:
case
"第三方仓库"
:
case
"耗材仓"
:
dcBaseStockList
=
baseStockMapperFor
.
listParameterStockById
(
shardingContext
,
(
page
-
1
)
*
jobPointLog
.
getPageSize
(),
jobPointLog
.
getPageSize
());
break
;
case
"ALL"
:
dcBaseStockList
=
baseStockMapperFor
.
listAllStock
(
shardingContext
,
(
page
-
1
)
*
jobPointLog
.
getPageSize
(),
jobPointLog
.
getPageSize
());
break
;
case
"NORMAL"
:
dcBaseStockList
=
baseStockMapperFor
.
listNormal
(
shardingContext
,
(
page
-
1
)
*
jobPointLog
.
getPageSize
(),
jobPointLog
.
getPageSize
());
break
;
case
"INCREMENT"
:
LocalDateTime
v1
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
).
plusHours
(
3
);
LocalDateTime
v2
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
).
minusDays
(
7
);
dcBaseStockList
=
baseStockMapperFor
.
increment
(
shardingContext
,
v1
,
v2
,
(
page
-
1
)
*
jobPointLog
.
getPageSize
(),
jobPointLog
.
getPageSize
());
default
:
dcBaseStockList
=
baseStockMapperFor
.
listWarehouseStockById
(
shardingContext
,
shardingContext
.
getJobParameter
(),
(
page
-
1
)
*
jobPointLog
.
getPageSize
(),
jobPointLog
.
getPageSize
());
}
}
if
(
dcBaseStockList
!=
null
&&
dcBaseStockList
.
size
()
>
0
)
{
for
(
DcBaseStock
dcBaseStock
:
dcBaseStockList
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"Mybatis操作DB分页查询失败"
,
e
);
}
finally
{
SessionUtil
.
closeSession
();
}
if
(
dcBaseStockList
!=
null
&&
dcBaseStockList
.
size
()
>
0
)
{
int
finalPage1
=
page
;
dcBaseStockList
.
stream
().
parallel
().
forEach
(
dcBaseStock
->
{
Integer
finalPage
=
finalPage1
;
log
.
info
(
"当前页码:{},当前线程:{},当前sku:{},当前记录数:{}"
,
finalPage
,
Thread
.
currentThread
().
getName
()
,
dcBaseStock
.
getBailunSku
()
+
"_"
+
dcBaseStock
.
getWarehouseCode
()
,
countItem
.
incrementAndGet
());
try
{
String
queryTime
=
DateTimeFormatter
.
ofPattern
(
CommonConstant
.
DATE_FORMAT
).
format
(
LocalDate
.
now
());
this
.
autoTurnoverFromStock
(
queryTime
,
dcBaseStock
);
}
catch
(
Exception
e
)
{
//错误记录到日志表, 任务跑完了再跑一次错误SKU
try
{
autoTurnoverFromStock
(
queryTime
,
dcBaseStock
);
}
catch
(
Exception
e
)
{
//错误记录到日志表, 任务跑完了再跑一次错误SKU
try
{
DcAutoExceptionMapper
dcAutoExceptionMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoExceptionMapper
.
class
);
DcAutoException
dcAutoException
=
new
DcAutoException
(
dcBaseStock
.
getBailunSku
(),
dcBaseStock
.
getWarehouseCode
(),
e
.
toString
());
dcAutoExceptionMapper
.
insertSelective
(
dcAutoException
);
}
catch
(
Exception
ex
)
{
log
.
error
(
"保存错误SKU失败,sku="
+
dcBaseStock
.
getBailunSku
()
+
",仓库="
+
dcBaseStock
.
getWarehouseCode
());
}
finally
{
SessionUtil
.
closeSession
();
}
DcAutoExceptionMapper
dcAutoExceptionMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoExceptionMapper
.
class
);
DcAutoException
dcAutoException
=
new
DcAutoException
(
dcBaseStock
.
getBailunSku
(),
dcBaseStock
.
getWarehouseCode
(),
e
.
toString
());
dcAutoExceptionMapper
.
insertSelective
(
dcAutoException
);
}
catch
(
Exception
ex
)
{
log
.
error
(
"保存错误SKU失败,sku="
+
dcBaseStock
.
getBailunSku
()
+
",仓库="
+
dcBaseStock
.
getWarehouseCode
());
}
finally
{
SessionUtil
.
closeSession
();
}
}
}
page
++;
}
while
(
page
<=
totalPage
);
});
}
}
}
private
long
getTotalCount
(
S
tring
jobParameter
)
{
private
long
getTotalCount
(
S
hardingContext
shardingContext
)
{
try
{
DcBaseStockMapper
baseStockMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcBaseStockMapper
.
class
);
if
(
StringUtils
.
isBlank
(
jobParameter
))
{
if
(
StringUtils
.
isBlank
(
shardingContext
.
getJobParameter
()
))
{
return
baseStockMapper
.
countByExample
(
DcBaseStockExample
.
newAndCreateCriteria
().
example
());
}
else
{
switch
(
jobParameter
)
{
switch
(
shardingContext
.
getJobParameter
()
)
{
case
"国内仓"
:
case
"FBA仓"
:
case
"海外仓"
:
case
"第三方仓库"
:
case
"耗材仓"
:
return
baseStockMapper
.
countByParam
(
jobParameter
);
return
baseStockMapper
.
countByParam
(
shardingContext
);
case
"ALL"
:
return
baseStockMapper
.
countAll
();
return
baseStockMapper
.
countAll
(
shardingContext
);
//普通任务
case
"NORMAL"
:
return
baseStockMapper
.
countNormal
(
shardingContext
);
case
"INCREMENT"
:
LocalDateTime
v1
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
).
plusHours
(
3
);
LocalDateTime
v2
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
).
minusDays
(
7
);
return
baseStockMapper
.
countIncrement
(
shardingContext
,
v1
,
v2
);
default
:
return
baseStockMapper
.
countByWarehouseCode
(
jobParameter
);
return
baseStockMapper
.
countByWarehouseCode
(
shardingContext
);
}
}
}
catch
(
Exception
e
)
{
...
...
@@ -138,43 +166,60 @@ public class AutoTurnoverJob extends PointJob {
}
}
/**
* 基于库存
* 计算自动周转
* <p>
* 核心方法
* 基于库存计算自动周转
* </p>
*
* @param queryTime
* @throws Exception
* @param queryTime 时间
* @param dcBaseStock 库存
* @throws Exception ex
*/
public
void
autoTurnoverFromStock
(
String
queryTime
,
DcBaseStock
dcBaseStock
)
throws
Exception
{
//sku
String
bailunSku
=
dcBaseStock
.
getBailunSku
();
//仓库编码
String
warehouseCode
=
dcBaseStock
.
getWarehouseCode
();
DcAutoSales
dcAutoSales
=
null
;
DcBaseWarehouse
dcBaseWarehouse
=
null
;
DcAutoWarehouseweekSales
dcAutoWarehouseweekSales
=
null
;
//销量
DcAutoSales
dcAutoSales
;
//仓库
DcBaseWarehouse
dcBaseWarehouse
;
//自动周转周系数
DcAutoWarehouseweekSales
dcAutoWarehouseweekSales
;
try
{
//库存mapper
DcBaseWarehouseMapper
baseWarehouseMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcBaseWarehouseMapper
.
class
);
//库存对应的仓库
dcBaseWarehouse
=
baseWarehouseMapper
.
selectOneByExample
(
DcBaseWarehouseExample
.
newAndCreateCriteria
().
andWarehouseCodeEqualTo
(
warehouseCode
).
example
());
BigDecimal
incrementalRatio
=
BigDecimal
.
ONE
;
int
compareSales
=
0
;
DcAutoSalesMapper
autoSalesMapper
=
null
;
SalesVolumeDTO
salesVolumeDTO
=
null
;
//销量
DcAutoSalesMapper
autoSalesMapper
;
//jb
SalesVolumeDTO
salesVolumeDTO
;
//销量mapper
autoSalesMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoSalesMapper
.
class
);
// 获取7、14日均销量
BigDecimal
agvSales
=
autoSalesMapper
.
getSalesAvg
(
queryTime
,
bailunSku
,
warehouseCode
);
BigDecimal
agvSales
=
autoSalesMapper
.
getSalesAvg
(
queryTime
,
bailunSku
,
warehouseCode
);
//销量突增检测mapper
DcAutoUprushConfigMapper
dcAutoUprushConfigMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoUprushConfigMapper
.
class
);
DcAutoUprushConfig
dcAutoUprushConfig
=
null
;
if
(
dcBaseWarehouse
!=
null
)
{
dcAutoUprushConfig
=
dcAutoUprushConfigMapper
.
selectOneByWarehouse
(
warehouseCode
,
dcBaseWarehouse
.
getHqType
());
//如果仓库不为空
if
(
dcBaseWarehouse
!=
null
)
{
//销量突增检测
dcAutoUprushConfig
=
dcAutoUprushConfigMapper
.
selectOneByWarehouse
(
warehouseCode
,
dcBaseWarehouse
.
getHqType
());
}
if
(
dcAutoUprushConfig
!=
null
&&
agvSales
!=
null
)
{
if
(
dcAutoUprushConfig
!=
null
&&
agvSales
!=
null
)
{
// 突增销量 = (7+14日均销量)/2 * 突增率
incrementalRatio
=
incrementalRatio
.
add
(
dcAutoUprushConfig
.
getPercentage
());
compareSales
=
agvSales
.
multiply
(
incrementalRatio
).
setScale
(
0
,
RoundingMode
.
UP
).
intValue
();
}
autoSalesMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoSalesMapper
.
class
);
if
(
compareSales
==
0
)
{
if
(
compareSales
==
0
)
{
salesVolumeDTO
=
autoSalesMapper
.
getSalesVolumeDTONoCompare
(
queryTime
,
bailunSku
,
warehouseCode
);
}
else
{
}
else
{
salesVolumeDTO
=
autoSalesMapper
.
getSalesVolumeDTO
(
queryTime
,
bailunSku
,
warehouseCode
,
compareSales
);
}
if
(
StringUtils
.
isEmpty
(
salesVolumeDTO
.
getHistorySales
().
trim
()))
{
...
...
@@ -188,6 +233,7 @@ public class AutoTurnoverJob extends PointJob {
dcAutoSales
=
autoSalesServiceImpl
.
forecastSalesBySalesVolumeDTO
(
salesVolumeDTO
);
}
DcAutoWarehouseweekSalesMapper
dcAutoWarehouseweekSalesMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoWarehouseweekSalesMapper
.
class
);
dcAutoWarehouseweekSales
=
dcAutoWarehouseweekSalesMapper
.
selectOneByWeekDay
(
warehouseCode
);
}
catch
(
Exception
e
)
{
...
...
@@ -199,15 +245,38 @@ public class AutoTurnoverJob extends PointJob {
autoTurnoverUseDcAutoSales
(
bailunSku
,
warehouseCode
,
dcAutoSales
,
dcBaseStock
,
dcBaseWarehouse
,
dcAutoWarehouseweekSales
);
}
/*
/**
* <p>
* 将历史销量,dcAutoSales
* 根据历史销量拟合的销量函数曲线,dcAutoSales
* 库存信息传入,dcBaseStock
* 计算自动周转
* </p>
*
* @param bailunSku 百伦sku
* @param warehouseCode 仓库编码
* @param dcAutoSales 销量
* @param dcBaseStock 库存
* @param dcBaseWarehouse 仓库
* @param dcAutoWarehouseweekSales 自动周转系数
*/
private
void
autoTurnoverUseDcAutoSales
(
String
bailunSku
,
String
warehouseCode
,
DcAutoSales
dcAutoSales
,
DcBaseStock
dcBaseStock
,
DcBaseWarehouse
dcBaseWarehouse
,
DcAutoWarehouseweekSales
dcAutoWarehouseweekSales
)
throws
Exception
{
private
void
autoTurnoverUseDcAutoSales
(
String
bailunSku
,
String
warehouseCode
,
DcAutoSales
dcAutoSales
,
DcBaseStock
dcBaseStock
,
DcBaseWarehouse
dcBaseWarehouse
,
DcAutoWarehouseweekSales
dcAutoWarehouseweekSales
)
throws
Exception
{
//记录时间
LocalDate
recordTime
=
LocalDate
.
now
();
DcAutoTurnover
dcAutoTurnover
=
new
DcAutoTurnover
();
DcAutoTurnoverMapper
dcAutoTurnoverMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoTurnoverMapper
.
class
);
DcAutoTurnover
dcAutoTurnover
=
dcAutoTurnoverMapper
.
selectOneByExample
(
DcAutoTurnoverExample
.
newAndCreateCriteria
()
.
andBailunSkuEqualTo
(
bailunSku
)
.
andWarehouseCodeEqualTo
(
warehouseCode
).
example
());
if
(
dcAutoTurnover
==
null
)
{
dcAutoTurnover
=
new
DcAutoTurnover
();
}
dcAutoTurnover
.
setBailunSku
(
bailunSku
);
dcAutoTurnover
.
setWarehouseCode
(
warehouseCode
);
/*
...
...
@@ -268,9 +337,9 @@ public class AutoTurnoverJob extends PointJob {
saveDays = BigDecimal.valueOf(4);
}*/
// JIT 周转天数默认为2、4天
if
(
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_2
))
{
if
(
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_2
))
{
turnoverDays
=
2
;
}
else
{
}
else
{
turnoverDays
=
4
;
}
}
...
...
@@ -372,7 +441,7 @@ 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
();
/*
...
...
@@ -451,7 +520,7 @@ public class AutoTurnoverJob extends PointJob {
* 自动下单管理的冗余-缺货等异常提醒
*/
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倍周转期内的入库总数
...
...
@@ -521,9 +590,9 @@ public class AutoTurnoverJob extends PointJob {
dcAutoTurnover
.
setStockUpDays
(
stockUpDays
);
dcAutoTurnover
.
setStockUpSales
(
stockUpSales
);
dcAutoTurnover
.
setQuantityBeginAdvise
(
forecastPurchaseAdvisedList
.
get
(
0
));
if
(
turnoverDays
==
0
)
{
if
(
turnoverDays
==
0
)
{
dcAutoTurnover
.
setForecastTurnoverdaySales
(
avgForecastTurnoverDaySales
);
}
else
{
}
else
{
dcAutoTurnover
.
setForecastTurnoverdaySales
(
avgForecastTurnoverDaySales
.
divide
(
BigDecimal
.
valueOf
(
turnoverDays
),
3
,
RoundingMode
.
HALF_EVEN
));
}
dcAutoTurnover
.
setSalesExplainDetails
(
forecastSalesExplainList
.
toString
());
...
...
@@ -548,7 +617,7 @@ public class AutoTurnoverJob extends PointJob {
dcAutoTurnover
.
setPromotions
(
promotionsBuilder
.
toString
());
if
((
warehouseCode
.
equals
(
Constant
.
WAREHOUSE_JIT
)
&&
(
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_1
)
||
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUYER_JIT_2
)))
||
(
warehouseCode
.
equals
(
Constant
.
WAREHOUSE_JIT1
)
&&
(
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUTER_JIT_5
))))
{
dcAutoTurnover
.
setQuantityInitAdvise
(
forecastPurchaseAdvisedList
.
get
(
0
));
}
else
{
}
else
{
dcAutoTurnover
.
setQuantityInitAdvise
(
forecastPurchaseAdvisedList
.
get
(
0
).
add
(
stockUpSales
));
}
//如果初始建议数 + 备货数 > moq建议数, 那么moq建议数 + 备货数, 否则, 还是取moq建议数
...
...
@@ -580,24 +649,13 @@ public class AutoTurnoverJob extends PointJob {
* 断货=前一天还有库存,但是今天库存为0了则是已经断货
* */
dcAutoTurnover
.
setIs_out_stock
(
0
);
// if(dcBaseStock.getUsableStock()==0)
// {
// //获取前一天库存
// Integer yesterdayStock = autoTurnoverMapper.yesterdayStock(dcAutoTurnover.getBailunSku(),dcAutoTurnover.getWarehouseCode());
// if(yesterdayStock!=null && yesterdayStock>0)
// {
// dcAutoTurnover.setIs_out_stock(1);
// }
// }
//End Add
// DcBaseStockMapper dcBaseStockMapper = SessionUtil.getSession().getMapper(DcBaseStockMapper.class);
dcAutoTurnover
.
setGmtModified
(
LocalDateTime
.
now
());
int
i
=
autoTurnoverMapper
.
updateByExampleSelective
(
dcAutoTurnover
,
DcAutoTurnoverExample
.
newAndCreateCriteria
().
andBailunSkuEqualTo
(
dcAutoTurnover
.
getBailunSku
()).
andWarehouseCodeEqualTo
(
dcAutoTurnover
.
getWarehouseCode
()).
example
());
if
(
i
==
0
)
{
autoTurnoverMapper
.
insertSelective
(
dcAutoTurnover
);
}
// dcBaseStockMapper.updateByExampleSelective(dcBaseStock, DcBaseStockExample.newAndCreateCriteria().andBailunSkuEqualTo(dcAutoTurnover.getBailunSku()).andWarehouseCodeEqualTo(dcAutoTurnover.getWarehouseCode()).example());
// dcBaseStockMapper.updateByExampleSelective(dcBaseStock, DcBaseStockExample.newAndCreateCriteria().andBailunSkuEqualTo(dcAutoTurnover.getBailunSku()).andWarehouseCodeEqualTo(dcAutoTurnover.getWarehouseCode()).example());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"Mybatis操作DB失败"
,
e
);
...
...
@@ -733,7 +791,7 @@ public class AutoTurnoverJob extends PointJob {
* 实际冗余的,预计冗余(库存> 销量 + 安全库存)
* 波动提醒优先级 --> 实际缺货-实际断货-实际冗余-预计缺货-预计冗余
*/
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
)
{
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
;
//冗余或缺货天数索引
...
...
@@ -797,12 +855,10 @@ public class AutoTurnoverJob extends PointJob {
* Add by Allan at 2020-07-23 10:58
* 断货=前一天还有库存,但是今天库存为0了则是已经断货
* */
if
(
forecastFluctuationList
.
get
(
0
).
getType
()!=
1
&&
dcBaseStock
.
getUsableStock
()==
0
)
{
if
(
forecastFluctuationList
.
get
(
0
).
getType
()
!=
1
&&
dcBaseStock
.
getUsableStock
()
==
0
)
{
//获取前一天库存
Integer
yesterdayStock
=
mapper
.
yesterdayStock
(
dcAutoTurnover
.
getBailunSku
(),
dcAutoTurnover
.
getWarehouseCode
());
if
(
yesterdayStock
!=
null
&&
yesterdayStock
>
0
)
{
Integer
yesterdayStock
=
mapper
.
yesterdayStock
(
dcAutoTurnover
.
getBailunSku
(),
dcAutoTurnover
.
getWarehouseCode
());
if
(
yesterdayStock
!=
null
&&
yesterdayStock
>
0
)
{
dcAutoForecastFluctuation
.
setType
(
5
);
//实际断货
dcAutoForecastFluctuation
.
setStartTime
(
LocalDate
.
now
());
//保存当天日期
dcAutoForecastFluctuation
.
setEndTime
(
LocalDate
.
now
());
//保存当天日期
...
...
@@ -1080,7 +1136,7 @@ public class AutoTurnoverJob extends PointJob {
}*/
// 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
)))
{
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);*/
...
...
@@ -1089,24 +1145,24 @@ public class AutoTurnoverJob extends PointJob {
Integer
historySevenSales
=
0
;
Integer
historyThreeSales
=
0
;
for
(
int
i
=
0
;
i
<
7
;
i
++)
{
historySevenSales
+=
historySalesList
.
get
(
23
+
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
++)
{
for
(
int
j
=
0
;
j
<
autoForecastDay
;
j
++)
{
forecastSalesList
.
set
(
j
,
avgHistorySevendaySales
);
}
}
else
{
}
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
)
{
if
(
dcAutoWarehouseweekSales
==
null
)
{
hasValue
=
false
;
}
else
{
weekRateList
=
JSON
.
parseObject
(
"["
+
dcAutoWarehouseweekSales
.
getRateDetail
()+
"]"
,
new
TypeReference
<
List
<
Integer
>>()
{
}
else
{
weekRateList
=
JSON
.
parseObject
(
"["
+
dcAutoWarehouseweekSales
.
getRateDetail
()
+
"]"
,
new
TypeReference
<
List
<
Integer
>>()
{
});
weekTime
=
Integer
.
valueOf
(
dcAutoWarehouseweekSales
.
getWeekTime
());
}
...
...
@@ -1123,54 +1179,54 @@ public class AutoTurnoverJob extends PointJob {
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
)
{
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
)
{
}
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
)
{
}
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
)
{
}
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
)
{
}
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
)));
...
...
@@ -1300,11 +1356,11 @@ public class AutoTurnoverJob extends PointJob {
}
}
private
BigDecimal
calculateSafeInventory
(
DcBaseSku
turnoverSku
,
String
bailunSku
,
String
warehouseCode
,
Integer
private
BigDecimal
calculateSafeInventory
(
DcBaseSku
turnoverSku
,
String
bailunSku
,
String
warehouseCode
,
Integer
bailunFirstLevelCatagoryId
,
DcAutoSales
dcAutoSales
,
String
forecastSalesListJson
,
DcAutoTurnover
dcAutoTurnover
,
Map
<
String
,
BigDecimal
>
saveDaysMap
)
{
/*
* 先判断是否JIT 仓库是广州01 warehouse_code 且是那三个销售员 turnoversku
*
* 先判断是否JIT 仓库是广州01 warehouse_code 且是那三个销售员 turnoversku
*
*/
DcAutoStockUpRangeMapper
dcAutoStockUpRangeMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoStockUpRangeMapper
.
class
);
DcAutoStockUpRange
dcAutoStockUpRange
=
dcAutoStockUpRangeMapper
.
selectOneByExample
(
DcAutoStockUpRangeExample
.
newAndCreateCriteria
().
andBailunSkuEqualTo
(
bailunSku
).
andWarehouseCodeEqualTo
(
warehouseCode
).
example
());
...
...
@@ -1312,7 +1368,7 @@ public class AutoTurnoverJob extends PointJob {
List
<
BigDecimal
>
historyThirtySalesList
=
JSON
.
parseObject
(
dcAutoSales
.
getHistorySalesDetails
(),
new
TypeReference
<
List
<
BigDecimal
>>()
{
});
BigDecimal
weightingAvgSales
=
caculateWeightingAvgSales
(
BigDecimal
.
valueOf
(
0.3
),
BigDecimal
.
valueOf
(
0.3
),
BigDecimal
.
valueOf
(
0.4
),
historyThirtySalesList
);
if
(
dcAutoStockUpRange
==
null
&&
(
warehouseCode
.
equals
(
Constant
.
WAREHOUSE_JIT1
)
&&
(
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUTER_JIT_5
))))
{
if
(
dcAutoStockUpRange
==
null
&&
(
warehouseCode
.
equals
(
Constant
.
WAREHOUSE_JIT1
)
&&
(
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUTER_JIT_5
))))
{
dcAutoStockUpRange
=
new
DcAutoStockUpRange
();
dcAutoStockUpRange
.
setBailunSku
(
bailunSku
);
dcAutoStockUpRange
.
setGroupId
(
2
);
...
...
@@ -1325,86 +1381,86 @@ public class AutoTurnoverJob extends PointJob {
dcAutoTurnover
.
setDailyWeightedSales
(
weightingAvgSales
);
weightingAvgSales
=
weightingAvgSales
.
multiply
(
saveDays
);
return
weightingAvgSales
;
}
else
{
/*
* 手动设置
* 1. 根据仓库 + SKU在表里找dc_auto_config_safe_inventory
* 2. 根据仓库 + 类目在表里找dc_auto_config_safe_inventory
* 当手动设置的值不为null, 就返回;
* 当手动设置的值为null, 就自动计算加权平均销量
*
* 自动计算
* 计算7天平均销量14天平均销量30天平均销量
* 1. 先找按预测计算是否存在表
* a. 有就取出权重
* b. 没有就找按历史计算是否存在表
* 2. 找按历史计算是否存在表
* a. 有就取出权重
* b. 没有就将7天平均销量14天平均销量30天平均销量再平均
*
* 最终
* 平均交期 - 供应商交期 > 0 就是平均逾期天数
* 平均逾期天数 * 加权平均销量(去最大值最小值)
*
* 新增一种算法(优先级别最低的),直接配置仓库。根据历史销量加权计算。最后可以乘以一个倍数
*/
DcAutoConfigSafeInventoryMapper
autoConfigSafeInventoryMapper
=
null
;
DcAutoConfigSafeInventory
dcAutoConfigSafeInventory
=
null
;
try
{
autoConfigSafeInventoryMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoConfigSafeInventoryMapper
.
class
);
dcAutoConfigSafeInventory
=
autoConfigSafeInventoryMapper
.
selectOneByExample
(
DcAutoConfigSafeInventoryExample
.
newAndCreateCriteria
().
andVariableCodeEqualTo
(
bailunSku
).
andWarehouseCodeEqualTo
(
warehouseCode
).
andStatusEqualTo
(
1
).
andTypeEqualTo
(
1
).
example
());
}
else
{
/*
* 手动设置
* 1. 根据仓库 + SKU在表里找dc_auto_config_safe_inventory
* 2. 根据仓库 + 类目在表里找dc_auto_config_safe_inventory
* 当手动设置的值不为null, 就返回;
* 当手动设置的值为null, 就自动计算加权平均销量
*
* 自动计算
* 计算7天平均销量14天平均销量30天平均销量
* 1. 先找按预测计算是否存在表
* a. 有就取出权重
* b. 没有就找按历史计算是否存在表
* 2. 找按历史计算是否存在表
* a. 有就取出权重
* b. 没有就将7天平均销量14天平均销量30天平均销量再平均
*
* 最终
* 平均交期 - 供应商交期 > 0 就是平均逾期天数
* 平均逾期天数 * 加权平均销量(去最大值最小值)
*
* 新增一种算法(优先级别最低的),直接配置仓库。根据历史销量加权计算。最后可以乘以一个倍数
*/
DcAutoConfigSafeInventoryMapper
autoConfigSafeInventoryMapper
=
null
;
DcAutoConfigSafeInventory
dcAutoConfigSafeInventory
=
null
;
try
{
autoConfigSafeInventoryMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoConfigSafeInventoryMapper
.
class
);
dcAutoConfigSafeInventory
=
autoConfigSafeInventoryMapper
.
selectOneByExample
(
DcAutoConfigSafeInventoryExample
.
newAndCreateCriteria
().
andVariableCodeEqualTo
(
bailunSku
).
andWarehouseCodeEqualTo
(
warehouseCode
).
andStatusEqualTo
(
1
).
andTypeEqualTo
(
1
).
example
());
if
(
dcAutoConfigSafeInventory
==
null
)
{
if
(
bailunFirstLevelCatagoryId
!=
null
)
{
//部分SKU没有百伦分类Id
dcAutoConfigSafeInventory
=
autoConfigSafeInventoryMapper
.
selectOneByExample
(
DcAutoConfigSafeInventoryExample
.
newAndCreateCriteria
().
andVariableCodeEqualTo
(
bailunFirstLevelCatagoryId
.
toString
()).
andWarehouseCodeEqualTo
(
warehouseCode
).
andStatusEqualTo
(
1
).
andTypeEqualTo
(
2
).
example
());
if
(
dcAutoConfigSafeInventory
==
null
)
{
if
(
bailunFirstLevelCatagoryId
!=
null
)
{
//部分SKU没有百伦分类Id
dcAutoConfigSafeInventory
=
autoConfigSafeInventoryMapper
.
selectOneByExample
(
DcAutoConfigSafeInventoryExample
.
newAndCreateCriteria
().
andVariableCodeEqualTo
(
bailunFirstLevelCatagoryId
.
toString
()).
andWarehouseCodeEqualTo
(
warehouseCode
).
andStatusEqualTo
(
1
).
andTypeEqualTo
(
2
).
example
());
}
}
}
if
(
dcAutoConfigSafeInventory
==
null
)
{
BigDecimal
weightingAvgSales
=
null
;
//预测
dcAutoConfigSafeInventory
=
autoConfigSafeInventoryMapper
.
selectOneByExample
(
DcAutoConfigSafeInventoryExample
.
newAndCreateCriteria
().
andVariableCodeEqualTo
(
bailunSku
).
andWarehouseCodeEqualTo
(
warehouseCode
).
andStatusEqualTo
(
1
).
andTypeEqualTo
(
12
).
example
());
if
(
dcAutoConfigSafeInventory
!=
null
)
{
List
<
BigDecimal
>
forecastSalesList
=
JSON
.
parseObject
(
forecastSalesListJson
,
new
TypeReference
<
List
<
BigDecimal
>>()
{
});
forecastSalesList
.
remove
(
forecastSalesList
.
size
()
-
1
);
weightingAvgSales
=
caculateWeightingAvgSales
(
dcAutoConfigSafeInventory
.
getWeightingCoefficientSeven
(),
dcAutoConfigSafeInventory
.
getWeightingCoefficientFourteen
(),
dcAutoConfigSafeInventory
.
getWeightingCoefficientThirty
(),
forecastSalesList
);
}
else
{
//历史
dcAutoConfigSafeInventory
=
autoConfigSafeInventoryMapper
.
selectOneByExample
(
DcAutoConfigSafeInventoryExample
.
newAndCreateCriteria
().
andVariableCodeEqualTo
(
bailunSku
).
andWarehouseCodeEqualTo
(
warehouseCode
).
andStatusEqualTo
(
1
).
andTypeEqualTo
(
11
).
example
());
List
<
BigDecimal
>
historyThirtySalesList
=
JSON
.
parseObject
(
dcAutoSales
.
getHistorySalesDetails
(),
new
TypeReference
<
List
<
BigDecimal
>>()
{
});
if
(
dcAutoConfigSafeInventory
==
null
)
{
BigDecimal
weightingAvgSales
=
null
;
//预测
dcAutoConfigSafeInventory
=
autoConfigSafeInventoryMapper
.
selectOneByExample
(
DcAutoConfigSafeInventoryExample
.
newAndCreateCriteria
().
andVariableCodeEqualTo
(
bailunSku
).
andWarehouseCodeEqualTo
(
warehouseCode
).
andStatusEqualTo
(
1
).
andTypeEqualTo
(
12
).
example
());
if
(
dcAutoConfigSafeInventory
!=
null
)
{
weightingAvgSales
=
caculateWeightingAvgSales
(
dcAutoConfigSafeInventory
.
getWeightingCoefficientSeven
(),
dcAutoConfigSafeInventory
.
getWeightingCoefficientFourteen
(),
dcAutoConfigSafeInventory
.
getWeightingCoefficientThirty
(),
historyThirtySalesList
);
List
<
BigDecimal
>
forecastSalesList
=
JSON
.
parseObject
(
forecastSalesListJson
,
new
TypeReference
<
List
<
BigDecimal
>>()
{
});
forecastSalesList
.
remove
(
forecastSalesList
.
size
()
-
1
);
weightingAvgSales
=
caculateWeightingAvgSales
(
dcAutoConfigSafeInventory
.
getWeightingCoefficientSeven
(),
dcAutoConfigSafeInventory
.
getWeightingCoefficientFourteen
(),
dcAutoConfigSafeInventory
.
getWeightingCoefficientThirty
(),
forecastSalesList
);
}
else
{
//仓库。根据历史销量加权计算。最后可以乘以一个倍数
dcAutoConfigSafeInventory
=
autoConfigSafeInventoryMapper
.
selectOneByExample
(
DcAutoConfigSafeInventoryExample
.
newAndCreateCriteria
().
andVariableCodeEqualTo
(
""
).
andWarehouseCodeEqualTo
(
warehouseCode
).
andStatusEqualTo
(
1
).
andTypeEqualTo
(
3
).
example
());
//历史
dcAutoConfigSafeInventory
=
autoConfigSafeInventoryMapper
.
selectOneByExample
(
DcAutoConfigSafeInventoryExample
.
newAndCreateCriteria
().
andVariableCodeEqualTo
(
bailunSku
).
andWarehouseCodeEqualTo
(
warehouseCode
).
andStatusEqualTo
(
1
).
andTypeEqualTo
(
11
).
example
());
List
<
BigDecimal
>
historyThirtySalesList
=
JSON
.
parseObject
(
dcAutoSales
.
getHistorySalesDetails
(),
new
TypeReference
<
List
<
BigDecimal
>>()
{
});
if
(
dcAutoConfigSafeInventory
!=
null
)
{
weightingAvgSales
=
caculateWeightingAvgSales
(
dcAutoConfigSafeInventory
.
getWeightingCoefficientSeven
(),
dcAutoConfigSafeInventory
.
getWeightingCoefficientFourteen
(),
dcAutoConfigSafeInventory
.
getWeightingCoefficientThirty
(),
historyThirtySalesList
);
dcAutoTurnover
.
setDailyWeightedSales
(
weightingAvgSales
);
//乘倍数后的加权日均销量,小于0.8就置0 0.8-1 之间就置1
weightingAvgSales
=
weightingAvgSales
.
multiply
(
dcAutoConfigSafeInventory
.
getParam
()).
setScale
(
3
,
RoundingMode
.
HALF_EVEN
);
if
(
weightingAvgSales
.
compareTo
(
BigDecimal
.
valueOf
(
0.8
))
==
-
1
)
{
weightingAvgSales
=
BigDecimal
.
ZERO
;
}
else
if
(
weightingAvgSales
.
compareTo
(
BigDecimal
.
ONE
)
<=
0
)
{
weightingAvgSales
=
BigDecimal
.
ONE
;
}
}
else
{
//啥配置都没有就给个默认取值
weightingAvgSales
=
caculateWeightingAvgSales
(
BigDecimal
.
valueOf
(
0.3
),
BigDecimal
.
valueOf
(
0.3
),
BigDecimal
.
valueOf
(
0.4
),
historyThirtySalesList
);
dcAutoTurnover
.
setDailyWeightedSales
(
weightingAvgSales
);
//仓库。根据历史销量加权计算。最后可以乘以一个倍数
dcAutoConfigSafeInventory
=
autoConfigSafeInventoryMapper
.
selectOneByExample
(
DcAutoConfigSafeInventoryExample
.
newAndCreateCriteria
().
andVariableCodeEqualTo
(
""
).
andWarehouseCodeEqualTo
(
warehouseCode
).
andStatusEqualTo
(
1
).
andTypeEqualTo
(
3
).
example
());
if
(
dcAutoConfigSafeInventory
!=
null
)
{
weightingAvgSales
=
caculateWeightingAvgSales
(
dcAutoConfigSafeInventory
.
getWeightingCoefficientSeven
(),
dcAutoConfigSafeInventory
.
getWeightingCoefficientFourteen
(),
dcAutoConfigSafeInventory
.
getWeightingCoefficientThirty
(),
historyThirtySalesList
);
dcAutoTurnover
.
setDailyWeightedSales
(
weightingAvgSales
);
//乘倍数后的加权日均销量,小于0.8就置0 0.8-1 之间就置1
weightingAvgSales
=
weightingAvgSales
.
multiply
(
dcAutoConfigSafeInventory
.
getParam
()).
setScale
(
3
,
RoundingMode
.
HALF_EVEN
);
if
(
weightingAvgSales
.
compareTo
(
BigDecimal
.
valueOf
(
0.8
))
==
-
1
)
{
weightingAvgSales
=
BigDecimal
.
ZERO
;
}
else
if
(
weightingAvgSales
.
compareTo
(
BigDecimal
.
ONE
)
<=
0
)
{
weightingAvgSales
=
BigDecimal
.
ONE
;
}
}
else
{
//啥配置都没有就给个默认取值
weightingAvgSales
=
caculateWeightingAvgSales
(
BigDecimal
.
valueOf
(
0.3
),
BigDecimal
.
valueOf
(
0.3
),
BigDecimal
.
valueOf
(
0.4
),
historyThirtySalesList
);
dcAutoTurnover
.
setDailyWeightedSales
(
weightingAvgSales
);
}
}
}
return
weightingAvgSales
;
}
else
{
return
dcAutoConfigSafeInventory
.
getParam
();
}
return
weightingAvgSales
;
}
else
{
return
dcAutoConfigSafeInventory
.
getParam
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"Mybatis操作DB失败"
,
e
);
}
finally
{
SessionUtil
.
closeSession
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"Mybatis操作DB失败"
,
e
);
}
finally
{
SessionUtil
.
closeSession
();
}
}
}
...
...
@@ -1581,7 +1637,7 @@ public class AutoTurnoverJob extends PointJob {
totalSales
=
dcAutoTurnover
.
getDailyWeightedSales
().
multiply
(
BigDecimal
.
valueOf
(
turnoverDays
));
totalSales
=
dcAutoTurnover
.
getDailyWeightedSales
().
multiply
(
BigDecimal
.
valueOf
(
turnoverDays
));
dcAutoTurnover
.
setTurnoverSales
(
totalSales
);
}
else
{
}
else
{
dcAutoTurnover
.
setTurnoverSales
(
totalSales
);
}
}
...
...
@@ -1690,7 +1746,7 @@ public class AutoTurnoverJob extends PointJob {
dcAutoTurnover
.
setTurnoverSales
(
totalSales
);
BigDecimal
transNumber
=
BigDecimal
.
ZERO
;
BigDecimal
forecastInbound
=
BigDecimal
.
ZERO
;
if
(
saveDays
!=
null
)
{
if
(
saveDays
!=
null
)
{
for
(
int
trans
=
0
;
trans
<
autoForecastDay
;
trans
++)
{
forecastInbound
=
BigDecimal
.
valueOf
(
forecastInboundList
.
get
(
trans
));
transNumber
=
transNumber
.
add
(
forecastInbound
);
...
...
@@ -1701,7 +1757,7 @@ public class AutoTurnoverJob extends PointJob {
.
add
(
BigDecimal
.
valueOf
(
outStock
.
longValue
()));
//今天的实际缺货
firstAdvice
=
false
;
}
}
else
if
(
warehouseCode
.
equals
(
Constant
.
WAREHOUSE_JIT1
)
&&
(
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUTER_JIT_5
)))
{
}
else
if
(
warehouseCode
.
equals
(
Constant
.
WAREHOUSE_JIT1
)
&&
(
turnoverSku
.
getBuyerName
().
equals
(
Constant
.
BUTER_JIT_5
)))
{
DcBaseStockMapper
dcBaseStockMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcBaseStockMapper
.
class
);
DcBaseStock
dcBaseStock
=
dcBaseStockMapper
.
selectOneByExample
(
DcBaseStockExample
.
newAndCreateCriteria
().
andBailunSkuEqualTo
(
bailunSku
).
andWarehouseCodeEqualTo
(
Constant
.
WAREHOUSE_JIT
).
example
());
...
...
@@ -1727,18 +1783,18 @@ public class AutoTurnoverJob extends PointJob {
totalSales
=
dcAutoTurnover
.
getDailyWeightedSales
().
multiply
(
BigDecimal
.
valueOf
(
turnoverDays
));
dcAutoTurnover
.
setTurnoverSales
(
totalSales
);
BigDecimal
forecastInbound
=
BigDecimal
.
ZERO
;
if
(
saveDays
!=
null
)
{
if
(
saveDays
!=
null
)
{
totalSales
=
dcAutoTurnover
.
getDailyWeightedSales
().
multiply
(
saveDays
);
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
(
BigDecimal
.
valueOf
(
purchase
+
transfer
));
//广州001仓在途数
firstAdvice
=
false
;
}
}
else
{
}
else
{
dcAutoTurnover
.
setTurnoverSales
(
totalSales
);
}
}
if
(
firstAdvice
)
{
if
(
firstAdvice
)
{
//采购建议 = 安全库存缺少值 + 今日的实际缺货 + 本次采购到货日期前一天的累计销量 - 本次采购到货日期累计到货数量 + 预计销量
totalAdvised
=
totalSafeInventory
.
subtract
(
forecastInventoryList
.
get
(
j
>
0
?
j
-
1
:
0
))
//安全库存缺少值= 理论安全库存 - 预测库存
.
add
(
BigDecimal
.
valueOf
(
outStock
.
longValue
()))
//今天的实际缺货
...
...
@@ -2125,134 +2181,134 @@ public class AutoTurnoverJob extends PointJob {
}
BigDecimal
saveDays
=
BigDecimal
.
ZERO
;
if
(
dcAutoJitTags
!=
null
)
{
for
(
DcAutoJitTag
dcAutoJitTag
:
dcAutoJitTags
)
{
if
(
dcAutoJitTag
.
getEnable7
()
==
1
)
{
switch
(
dcAutoJitTag
.
getIsGt7
())
{
case
1
:
if
(
avgHistorySevendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales7
())
==
1
)
{
break
;
}
else
{
continue
;
}
case
2
:
if
(
avgHistorySevendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales7
())
==
0
)
{
break
;
}
else
{
continue
;
}
case
3
:
if
(
avgHistorySevendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales7
())
==
-
1
)
{
break
;
}
else
{
continue
;
}
case
4
:
if
(
avgHistorySevendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales7
())
>
-
1
)
{
break
;
}
else
{
continue
;
}
case
5
:
if
(
avgHistorySevendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales7
())
<
1
)
{
break
;
}
else
{
for
(
DcAutoJitTag
dcAutoJitTag
:
dcAutoJitTags
)
{
if
(
dcAutoJitTag
.
getEnable7
()
==
1
)
{
switch
(
dcAutoJitTag
.
getIsGt7
())
{
case
1
:
if
(
avgHistorySevendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales7
())
==
1
)
{
break
;
}
else
{
continue
;
}
case
2
:
if
(
avgHistorySevendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales7
())
==
0
)
{
break
;
}
else
{
continue
;
}
case
3
:
if
(
avgHistorySevendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales7
())
==
-
1
)
{
break
;
}
else
{
continue
;
}
case
4
:
if
(
avgHistorySevendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales7
())
>
-
1
)
{
break
;
}
else
{
continue
;
}
case
5
:
if
(
avgHistorySevendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales7
())
<
1
)
{
break
;
}
else
{
continue
;
}
default
:
continue
;
}
default
:
continue
;
}
}
}
if
(
dcAutoJitTag
.
getEnable14
()
==
1
)
{
switch
(
dcAutoJitTag
.
getIsGt14
())
{
case
1
:
if
(
avgHistoryFourteendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales14
())
==
1
)
{
break
;
}
else
{
continue
;
}
case
2
:
if
(
avgHistoryFourteendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales14
())
==
0
)
{
break
;
}
else
{
continue
;
}
case
3
:
if
(
avgHistoryFourteendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales14
())
==
-
1
)
{
break
;
}
else
{
continue
;
}
case
4
:
if
(
avgHistoryFourteendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales14
())
>
-
1
)
{
break
;
}
else
{
continue
;
}
case
5
:
if
(
avgHistoryFourteendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales14
())
<
1
)
{
break
;
}
else
{
if
(
dcAutoJitTag
.
getEnable14
()
==
1
)
{
switch
(
dcAutoJitTag
.
getIsGt14
())
{
case
1
:
if
(
avgHistoryFourteendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales14
())
==
1
)
{
break
;
}
else
{
continue
;
}
case
2
:
if
(
avgHistoryFourteendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales14
())
==
0
)
{
break
;
}
else
{
continue
;
}
case
3
:
if
(
avgHistoryFourteendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales14
())
==
-
1
)
{
break
;
}
else
{
continue
;
}
case
4
:
if
(
avgHistoryFourteendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales14
())
>
-
1
)
{
break
;
}
else
{
continue
;
}
case
5
:
if
(
avgHistoryFourteendaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales14
())
<
1
)
{
break
;
}
else
{
continue
;
}
default
:
continue
;
}
default
:
continue
;
}
}
}
if
(
dcAutoJitTag
.
getEnable30
()
==
1
)
{
switch
(
dcAutoJitTag
.
getIsGt30
())
{
case
1
:
if
(
avgHistoryThirtydaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales30
())
==
1
)
{
break
;
}
else
{
continue
;
}
case
2
:
if
(
avgHistoryThirtydaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales30
())
==
0
)
{
break
;
}
else
{
continue
;
}
case
3
:
if
(
avgHistoryThirtydaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales30
())
==
-
1
)
{
break
;
}
else
{
continue
;
}
case
4
:
if
(
avgHistoryThirtydaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales30
())
>
-
1
)
{
break
;
}
else
{
continue
;
}
case
5
:
if
(
avgHistoryThirtydaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales30
())
<
1
)
{
break
;
}
else
{
if
(
dcAutoJitTag
.
getEnable30
()
==
1
)
{
switch
(
dcAutoJitTag
.
getIsGt30
())
{
case
1
:
if
(
avgHistoryThirtydaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales30
())
==
1
)
{
break
;
}
else
{
continue
;
}
case
2
:
if
(
avgHistoryThirtydaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales30
())
==
0
)
{
break
;
}
else
{
continue
;
}
case
3
:
if
(
avgHistoryThirtydaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales30
())
==
-
1
)
{
break
;
}
else
{
continue
;
}
case
4
:
if
(
avgHistoryThirtydaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales30
())
>
-
1
)
{
break
;
}
else
{
continue
;
}
case
5
:
if
(
avgHistoryThirtydaySales
.
compareTo
(
dcAutoJitTag
.
getQuantitySales30
())
<
1
)
{
break
;
}
else
{
continue
;
}
default
:
continue
;
}
default
:
continue
;
}
}
if
(
StringUtils
.
isNotBlank
(
buyerName
)
&&
StringUtils
.
isNotBlank
(
dcAutoJitTag
.
getBuyerName
())
&&
!
buyerName
.
equals
(
dcAutoJitTag
.
getBuyerName
()))
continue
;
saveDays
=
dcAutoJitTag
.
getQuantitySafeInventory
();
if
(
"weightingAvgSales"
.
equals
(
autoForecastDay
))
{
DcAutoJitTagLogMapper
dcAutoJitTagLogMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoJitTagLogMapper
.
class
);
DcAutoJitTagLog
dcAutoJitTagLog
=
new
DcAutoJitTagLog
();
dcAutoJitTagLog
.
setBailunSku
(
bailunSku
);
dcAutoJitTagLog
.
setDate
(
LocalDate
.
now
());
dcAutoJitTagLog
.
setQuantitySales7
(
avgHistorySevendaySales
);
dcAutoJitTagLog
.
setQuantitySales14
(
avgHistoryFourteendaySales
);
dcAutoJitTagLog
.
setQuantitySales30
(
avgHistoryThirtydaySales
);
dcAutoJitTagLog
.
setTagId
(
dcAutoJitTag
.
getId
());
dcAutoJitTagLog
.
setTagJson
(
JSONObject
.
toJSONString
(
dcAutoJitTag
));
dcAutoJitTagLogMapper
.
upsertSelective
(
dcAutoJitTagLog
);
dcAutoTurnover
.
setTagId
(
dcAutoJitTag
.
getId
());
}
break
;
}
if
(
StringUtils
.
isNotBlank
(
buyerName
)
&&
StringUtils
.
isNotBlank
(
dcAutoJitTag
.
getBuyerName
())
&&
!
buyerName
.
equals
(
dcAutoJitTag
.
getBuyerName
()))
continue
;
saveDays
=
dcAutoJitTag
.
getQuantitySafeInventory
();
if
(
"weightingAvgSales"
.
equals
(
autoForecastDay
))
{
DcAutoJitTagLogMapper
dcAutoJitTagLogMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoJitTagLogMapper
.
class
);
DcAutoJitTagLog
dcAutoJitTagLog
=
new
DcAutoJitTagLog
();
dcAutoJitTagLog
.
setBailunSku
(
bailunSku
);
dcAutoJitTagLog
.
setDate
(
LocalDate
.
now
());
dcAutoJitTagLog
.
setQuantitySales7
(
avgHistorySevendaySales
);
dcAutoJitTagLog
.
setQuantitySales14
(
avgHistoryFourteendaySales
);
dcAutoJitTagLog
.
setQuantitySales30
(
avgHistoryThirtydaySales
);
dcAutoJitTagLog
.
setTagId
(
dcAutoJitTag
.
getId
());
dcAutoJitTagLog
.
setTagJson
(
JSONObject
.
toJSONString
(
dcAutoJitTag
));
dcAutoJitTagLogMapper
.
upsertSelective
(
dcAutoJitTagLog
);
dcAutoTurnover
.
setTagId
(
dcAutoJitTag
.
getId
());
}
break
;
}
}
return
saveDays
;
}
}
data-show/show-auto-turnover/src/main/java/com/bailuntec/listener/AutoTurnoverJobListener.java
View file @
2806c3a3
...
...
@@ -7,7 +7,6 @@ import com.bailuntec.domain.example.DcAutoExceptionExample;
import
com.bailuntec.domain.example.DcBaseStockExample
;
import
com.bailuntec.job.AutoTurnoverJob
;
import
com.bailuntec.mapper.DcAutoExceptionMapper
;
import
com.bailuntec.mapper.DcAutoTurnoverMapper
;
import
com.bailuntec.mapper.DcBaseStockMapper
;
import
com.bailuntec.utils.SessionUtil
;
import
com.dangdang.ddframe.job.executor.ShardingContexts
;
...
...
@@ -23,22 +22,7 @@ import java.util.List;
public
class
AutoTurnoverJobListener
implements
ElasticJobListener
{
@Override
public
void
beforeJobExecuted
(
ShardingContexts
shardingContexts
)
{
try
{
DcAutoTurnoverMapper
autoTurnoverMapper
=
SessionUtil
.
getSession
().
getMapper
(
DcAutoTurnoverMapper
.
class
);
if
(
shardingContexts
.
getJobName
().
equals
(
"show-auto-turnover"
))
{
autoTurnoverMapper
.
truncateAutoInboundTable
();
autoTurnoverMapper
.
truncateAutoInventoryTable
();
autoTurnoverMapper
.
truncateAutoShortSupplyTable
();
autoTurnoverMapper
.
truncateAutoTurnoverTable
();
autoTurnoverMapper
.
truncateAutoSalesTable
();
autoTurnoverMapper
.
truncateAutoExceptionTable
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"Mybatis操作DB失败"
,
e
);
}
finally
{
SessionUtil
.
closeSession
();
}
}
@Override
...
...
data-show/show-auto-turnover/src/main/resources/job.properties
View file @
2806c3a3
#
EVENT_RDB_STORAGE_DRIVER=com.mysql.jdbc.Driver
#
EVENT_RDB_STORAGE_URL=jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8
EVENT_RDB_STORAGE_DRIVER
=
com.mysql.jdbc.Driver
EVENT_RDB_STORAGE_URL
=
jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/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
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_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_USERNAME
=
root
EVENT_RDB_STORAGE_PASSWORD
=
#7kfnymAM$Y9-Ntf
ZOOKEEPER_SERVER=172.31.255.120:2181
NAME_SPACE
=
data-center
JOB_NAME
=
show-auto-turnover
JOB_CRON
=
0
30 0 * * ? *
JOB_CRON
=
0
0 3 * * ?
SHARDING_TOTAL_COUNT
=
8
JOB_NAME_PARAM
=
show-auto-turnover-param
JOB_CRON_PARAM
=
0 30 0 * * ? 2099
SHARDING_TOTAL_COUNT_PARAM
=
8
\ No newline at end of file
JOB_CRON_PARAM
=
0 0 14 * * ?
SHARDING_TOTAL_COUNT_PARAM
=
8
JOB_NAME_INCREMENT
=
show-auto-turnover-param
JOB_CRON_INCREMENT
=
0 0 14 * * ?
SHARDING_TOTAL_COUNT_INCREMENT
=
8
data-show/show-auto-turnover/src/main/resources/log4j.properties
0 → 100644
View file @
2806c3a3
#log4j.rootLogger=DEBUG,console,dailyFile,im
#log4j.additivity.org.apache=true
## 控制台(console)
#log4j.appender.console=org.apache.log4j.ConsoleAppender
#log4j.appender.console.Threshold=DEBUG
#log4j.appender.console.ImmediateFlush=true
#log4j.appender.console.Target=System.err
#log4j.appender.console.layout=org.apache.log4j.PatternLayout
#log4j.appender.console.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n
## 日志文件(logFile)
#log4j.appender.logFile=org.apache.log4j.FileAppender
#log4j.appender.logFile.Threshold=DEBUG
#log4j.appender.logFile.ImmediateFlush=true
#log4j.appender.logFile.Append=true
#log4j.appender.logFile.File=/logs/log.log4j
#log4j.appender.logFile.layout=org.apache.log4j.PatternLayout
#log4j.appender.logFile.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n
## 回滚文件(rollingFile)
#log4j.appender.rollingFile=org.apache.log4j.RollingFileAppender
#log4j.appender.rollingFile.Threshold=DEBUG
#log4j.appender.rollingFile.ImmediateFlush=true
#log4j.appender.rollingFile.Append=true
#log4j.appender.rollingFile.File=/logs/log.log4j
#log4j.appender.rollingFile.MaxFileSize=200KB
#log4j.appender.rollingFile.MaxBackupIndex=50
#log4j.appender.rollingFile.layout=org.apache.log4j.PatternLayout
#log4j.appender.rollingFile.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n
## 定期回滚日志文件(dailyFile)
#log4j.appender.dailyFile=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.dailyFile.Threshold=DEBUG
#log4j.appender.dailyFile.ImmediateFlush=true
#log4j.appender.dailyFile.Append=true
#log4j.appender.dailyFile.File=/logs/log.log4j
#log4j.appender.dailyFile.DatePattern='.'yyyy-MM-dd
#log4j.appender.dailyFile.layout=org.apache.log4j.PatternLayout
#log4j.appender.dailyFile.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n
## 应用于socket
#log4j.appender.socket=org.apache.log4j.RollingFileAppender
#log4j.appender.socket.RemoteHost=localhost
#log4j.appender.socket.Port=5001
#log4j.appender.socket.LocationInfo=true
## Set up for Log Factor 5
#log4j.appender.socket.layout=org.apache.log4j.PatternLayout
#log4j.appender.socket.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n
## Log Factor 5 Appender
#log4j.appender.LF5_APPENDER=org.apache.log4j.lf5.LF5Appender
#log4j.appender.LF5_APPENDER.MaxNumberOfRecords=2000
## 发送日志到指定邮件
#log4j.appender.mail=org.apache.log4j.net.SMTPAppender
#log4j.appender.mail.Threshold=FATAL
#log4j.appender.mail.BufferSize=10
#log4j.appender.mail.From = xxx@mail.com
#log4j.appender.mail.SMTPHost=mail.com
#log4j.appender.mail.Subject=Log4J Message
#log4j.appender.mail.To= xxx@mail.com
#log4j.appender.mail.layout=org.apache.log4j.PatternLayout
#log4j.appender.mail.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n
## 应用于数据库
#log4j.appender.database=org.apache.log4j.jdbc.JDBCAppender
#log4j.appender.database.URL=jdbc:mysql://localhost:3306/test
#log4j.appender.database.driver=com.mysql.jdbc.Driver
#log4j.appender.database.user=root
#log4j.appender.database.password=
#log4j.appender.database.sql=INSERT INTO LOG4J (Message) VALUES('=[%-5p] %d(%r) --> [%t] %l: %m %x %n')
#log4j.appender.database.layout=org.apache.log4j.PatternLayout
#log4j.appender.database.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n
#
## 自定义Appender
#log4j.appender.im = net.cybercorlin.util.logger.appender.IMAppender
#log4j.appender.im.host = mail.cybercorlin.net
#log4j.appender.im.username = username
#log4j.appender.im.password = password
#log4j.appender.im.recipient = corlin@cybercorlin.net
#log4j.appender.im.layout=org.apache.log4j.PatternLayout
#log4j.appender.im.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n
data-show/show-auto-turnover/src/test/java/AutoTurnoverTest.java
View file @
2806c3a3
...
...
@@ -98,8 +98,8 @@ public class AutoTurnoverTest {
AutoTurnoverJob
autoTurnoverJob
=
new
AutoTurnoverJob
();
HashMap
<
Integer
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
1
,
""
);
ShardingContext
shardingContext
=
new
ShardingContext
(
new
ShardingContexts
(
""
,
""
,
4
,
""
,
map
),
3
);
JobPointLog
jobPointLog
=
new
JobPointLog
(
""
,
1
,
20
00
,
1
,
1
,
LocalDateTime
.
now
().
minusSeconds
(
1
),
LocalDateTime
.
now
());
ShardingContext
shardingContext
=
new
ShardingContext
(
new
ShardingContexts
(
""
,
""
,
8
,
"NORMAL"
,
map
),
5
);
JobPointLog
jobPointLog
=
new
JobPointLog
(
""
,
1
,
4
00
,
1
,
1
,
LocalDateTime
.
now
().
minusSeconds
(
1
),
LocalDateTime
.
now
());
autoTurnoverJob
.
executeJob
(
shardingContext
,
jobPointLog
);
}
...
...
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