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
67d8e7e6
Commit
67d8e7e6
authored
Aug 29, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
亚马逊广告
parent
0f93a03e
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
333 additions
and
362 deletions
+333
-362
AmazonAdDownloadReportJob.java
...ain/java/com/bailuntec/job/AmazonAdDownloadReportJob.java
+3
-1
AmazonAdGenerateReportIdJob.java
...n/java/com/bailuntec/job/AmazonAdGenerateReportIdJob.java
+3
-2
AmazonAdDownloadReportJobTest.java
...java/com/bailuntec/job/AmazonAdDownloadReportJobTest.java
+19
-4
DcBaseFinanceAmazonAdProduct.java
...bailuntec/domain/entity/DcBaseFinanceAmazonAdProduct.java
+15
-3
JobAmazonAdLog.java
...main/java/com/bailuntec/domain/entity/JobAmazonAdLog.java
+13
-11
DcBaseFinanceAmazonAdProductExample.java
...c/domain/example/DcBaseFinanceAmazonAdProductExample.java
+62
-1
JobAmazonAdLogExample.java
...a/com/bailuntec/domain/example/JobAmazonAdLogExample.java
+62
-1
DcAutoSalesForecastStageConfigMapper.xml
...bailuntec/mapper/DcAutoSalesForecastStageConfigMapper.xml
+1
-2
DcBaseFinanceAmazonAdProductMapper.xml
...m/bailuntec/mapper/DcBaseFinanceAmazonAdProductMapper.xml
+35
-8
DcBaseOmsSkuMapper.java
...rc/main/java/com/bailuntec/mapper/DcBaseOmsSkuMapper.java
+2
-1
DcBaseOmsSkuMapper.xml
...src/main/java/com/bailuntec/mapper/DcBaseOmsSkuMapper.xml
+8
-1
JobAmazonAdLogMapper.xml
...c/main/java/com/bailuntec/mapper/JobAmazonAdLogMapper.xml
+59
-39
init.properties
data-common/src/main/resources/init.properties
+1
-1
AutoTurnoverServiceImpl.java
...a/com/bailuntec/service/impl/AutoTurnoverServiceImpl.java
+50
-287
No files found.
data-base/base-sync-amazon-ad/src/main/java/com/bailuntec/job/AmazonAdDownloadReportJob.java
View file @
67d8e7e6
...
...
@@ -90,7 +90,8 @@ public class AmazonAdDownloadReportJob implements SimpleJob {
.
andReportDateEqualTo
(
jobAmazonAdLog
.
getReportDate
())
.
andCampaignIdEqualTo
(
amazonAdProduct
.
getCampaignId
())
.
andAdGroupIdEqualTo
(
amazonAdProduct
.
getAdGroupId
())
.
andSkuEqualTo
(
amazonAdProduct
.
getSku
())
// .andSkuEqualTo(amazonAdProduct.getSku())
.
andTypeEqualTo
(
jobAmazonAdLog
.
getType
())
.
example
();
DcBaseFinanceAmazonAdProduct
dcBaseFinanceAmazonAdProduct
=
dcBaseFinanceAmazonAdProductMapper
.
selectOneByExample
(
example
);
...
...
@@ -104,6 +105,7 @@ public class AmazonAdDownloadReportJob implements SimpleJob {
dcBaseFinanceAmazonAdProduct
.
setExchangeRate
(
CallBailunSystem
.
getExchangeRate
(
dcBaseFinanceAmazonAdProduct
.
getCurrency
(),
CurrencyType
.
CNY
.
value
(),
jobAmazonAdLog
.
getReportDate
().
atStartOfDay
()));
dcBaseFinanceAmazonAdProduct
.
setExchangeRateUsd
(
CallBailunSystem
.
getExchangeRate
(
dcBaseFinanceAmazonAdProduct
.
getCurrency
(),
CurrencyType
.
USD
.
value
(),
jobAmazonAdLog
.
getReportDate
().
atStartOfDay
()));
dcBaseFinanceAmazonAdProduct
.
setBjModifyTime
(
LocalDateTime
.
now
());
dcBaseFinanceAmazonAdProduct
.
setType
(
jobAmazonAdLog
.
getType
());
if
(
dcBaseFinanceAmazonAdProduct
.
getId
()
==
null
)
{
dcBaseFinanceAmazonAdProductMapper
.
insertSelective
(
dcBaseFinanceAmazonAdProduct
,
null
);
...
...
data-base/base-sync-amazon-ad/src/main/java/com/bailuntec/job/AmazonAdGenerateReportIdJob.java
View file @
67d8e7e6
...
...
@@ -50,7 +50,6 @@ public class AmazonAdGenerateReportIdJob implements SimpleJob {
.
forEach
(
dcBaseCompanyAccount
->
{
try
{
LocalDateTime
reportDate
=
LocalDateTime
.
now
().
minusDays
(
1
).
minusHours
(
12
);
// LocalDateTime reportDate = LocalDateTime.of(2020, 8, finalI, 0, 0);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"reportDate"
,
reportDate
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyyMMdd"
)));
jsonObject
.
put
(
"metrics"
,
propertiesUtil
.
getPropertyAsString
(
"METRICS"
));
...
...
@@ -91,7 +90,8 @@ public class AmazonAdGenerateReportIdJob implements SimpleJob {
LocalDateTime
.
now
(),
LocalDateTime
.
now
(),
dcBaseCompanyAccount
.
getSiteEn
(),
dcBaseCompanyAccount
.
getCompanyId
());
dcBaseCompanyAccount
.
getCompanyId
(),
1
);
}
//如果已经生成了报告 是否设置为需要重新下载?//yes
else
{
...
...
@@ -103,6 +103,7 @@ public class AmazonAdGenerateReportIdJob implements SimpleJob {
jobAmazonAdLogMapper
.
upsert
(
jobAmazonAdLog
);
log
.
info
(
"生成报告成功,报告日志:{}"
,
JSON
.
toJSONString
(
jobAmazonAdLog
));
}
else
{
log
.
error
(
JSON
.
toJSONString
(
response
));
throw
new
RuntimeException
(
"生成报告失败"
);
...
...
data-base/base-sync-amazon-ad/src/test/java/com/bailuntec/job/AmazonAdDownloadReportJobTest.java
View file @
67d8e7e6
...
...
@@ -11,11 +11,11 @@ import okhttp3.Request;
import
okhttp3.Response
;
import
org.junit.jupiter.api.Test
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.*
;
import
java.lang.reflect.Type
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Scanner
;
import
java.util.zip.GZIPInputStream
;
/**
...
...
@@ -47,12 +47,27 @@ class AmazonAdDownloadReportJobTest {
.
build
();
Response
response
=
new
OkHttpClient
().
newCall
(
request
).
execute
();
// File file = new File("/Users/huluobin/Downloads/adProfile")
GZIPInputStream
inputStream
=
new
GZIPInputStream
(
response
.
body
().
byteStream
());
Type
type
=
new
TypeToken
<
List
<
AmazonAdProduct
>>()
{
}.
getType
();
List
<
AmazonAdProduct
>
amazonAdProductList
=
new
Gson
().
fromJson
(
new
InputStreamReader
(
inputStream
),
type
);
log
.
warn
(
"的Report解析完成"
);
StringBuilder
html
=
new
StringBuilder
();
Scanner
sc
=
new
Scanner
(
inputStream
);
while
(
sc
.
hasNextLine
())
{
html
.
append
(
sc
.
nextLine
().
toString
()
+
"\r\n"
);
}
System
.
out
.
println
(
html
);
// List<AmazonAdProduct> amazonAdProductList = new Gson().fromJson(new InputStreamReader(inputStream), type);
// log.warn("的Report解析完成");
}
}
data-common/src/main/java/com/bailuntec/domain/entity/DcBaseFinanceAmazonAdProduct.java
View file @
67d8e7e6
package
com
.
bailuntec
.
domain
.
entity
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
lombok.Data
;
@Data
public
class
DcBaseFinanceAmazonAdProduct
{
...
...
@@ -396,6 +395,15 @@ public class DcBaseFinanceAmazonAdProduct {
private
BigDecimal
exchangeRateUsd
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_amazon_ad_product.type
*
* @mbg.generated
*/
private
Integer
type
;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_amazon_ad_product
*
...
...
@@ -450,6 +458,7 @@ public class DcBaseFinanceAmazonAdProduct {
sb
.
append
(
", reportType="
).
append
(
reportType
);
sb
.
append
(
", exchangeRate="
).
append
(
exchangeRate
);
sb
.
append
(
", exchangeRateUsd="
).
append
(
exchangeRateUsd
);
sb
.
append
(
", type="
).
append
(
type
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
}
...
...
@@ -514,7 +523,8 @@ public class DcBaseFinanceAmazonAdProduct {
&&
(
this
.
getReportDate
()
==
null
?
other
.
getReportDate
()
==
null
:
this
.
getReportDate
().
equals
(
other
.
getReportDate
()))
&&
(
this
.
getReportType
()
==
null
?
other
.
getReportType
()
==
null
:
this
.
getReportType
().
equals
(
other
.
getReportType
()))
&&
(
this
.
getExchangeRate
()
==
null
?
other
.
getExchangeRate
()
==
null
:
this
.
getExchangeRate
().
equals
(
other
.
getExchangeRate
()))
&&
(
this
.
getExchangeRateUsd
()
==
null
?
other
.
getExchangeRateUsd
()
==
null
:
this
.
getExchangeRateUsd
().
equals
(
other
.
getExchangeRateUsd
()));
&&
(
this
.
getExchangeRateUsd
()
==
null
?
other
.
getExchangeRateUsd
()
==
null
:
this
.
getExchangeRateUsd
().
equals
(
other
.
getExchangeRateUsd
()))
&&
(
this
.
getType
()
==
null
?
other
.
getType
()
==
null
:
this
.
getType
().
equals
(
other
.
getType
()));
}
/**
...
...
@@ -570,6 +580,7 @@ public class DcBaseFinanceAmazonAdProduct {
result
=
prime
*
result
+
((
getReportType
()
==
null
)
?
0
:
getReportType
().
hashCode
());
result
=
prime
*
result
+
((
getExchangeRate
()
==
null
)
?
0
:
getExchangeRate
().
hashCode
());
result
=
prime
*
result
+
((
getExchangeRateUsd
()
==
null
)
?
0
:
getExchangeRateUsd
().
hashCode
());
result
=
prime
*
result
+
((
getType
()
==
null
)
?
0
:
getType
().
hashCode
());
return
result
;
}
}
\ No newline at end of file
data-common/src/main/java/com/bailuntec/domain/entity/JobAmazonAdLog.java
View file @
67d8e7e6
...
...
@@ -8,11 +8,10 @@ import java.time.LocalDate;
import
java.time.LocalDateTime
;
@Data
@NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
public
class
JobAmazonAdLog
{
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column job_amazon_ad_log.id
*
...
...
@@ -21,7 +20,6 @@ public class JobAmazonAdLog {
private
Integer
id
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column job_amazon_ad_log.account_id
*
...
...
@@ -30,7 +28,6 @@ public class JobAmazonAdLog {
private
Integer
accountId
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column job_amazon_ad_log.report_id
*
...
...
@@ -39,7 +36,6 @@ public class JobAmazonAdLog {
private
String
reportId
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column job_amazon_ad_log.report_date
*
...
...
@@ -48,7 +44,6 @@ public class JobAmazonAdLog {
private
LocalDate
reportDate
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column job_amazon_ad_log.status
*
...
...
@@ -57,7 +52,6 @@ public class JobAmazonAdLog {
private
Boolean
status
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column job_amazon_ad_log.bj_create
*
...
...
@@ -66,7 +60,6 @@ public class JobAmazonAdLog {
private
LocalDateTime
bjCreate
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column job_amazon_ad_log.bj_modified
*
...
...
@@ -75,7 +68,6 @@ public class JobAmazonAdLog {
private
LocalDateTime
bjModified
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column job_amazon_ad_log.site_en
*
...
...
@@ -84,7 +76,6 @@ public class JobAmazonAdLog {
private
String
siteEn
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column job_amazon_ad_log.company_id
*
...
...
@@ -93,6 +84,14 @@ public class JobAmazonAdLog {
private
Integer
companyId
;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column job_amazon_ad_log.type
*
* @mbg.generated
*/
private
Integer
type
;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table job_amazon_ad_log
*
...
...
@@ -113,6 +112,7 @@ public class JobAmazonAdLog {
sb
.
append
(
", bjModified="
).
append
(
bjModified
);
sb
.
append
(
", siteEn="
).
append
(
siteEn
);
sb
.
append
(
", companyId="
).
append
(
companyId
);
sb
.
append
(
", type="
).
append
(
type
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
}
...
...
@@ -143,7 +143,8 @@ public class JobAmazonAdLog {
&&
(
this
.
getBjCreate
()
==
null
?
other
.
getBjCreate
()
==
null
:
this
.
getBjCreate
().
equals
(
other
.
getBjCreate
()))
&&
(
this
.
getBjModified
()
==
null
?
other
.
getBjModified
()
==
null
:
this
.
getBjModified
().
equals
(
other
.
getBjModified
()))
&&
(
this
.
getSiteEn
()
==
null
?
other
.
getSiteEn
()
==
null
:
this
.
getSiteEn
().
equals
(
other
.
getSiteEn
()))
&&
(
this
.
getCompanyId
()
==
null
?
other
.
getCompanyId
()
==
null
:
this
.
getCompanyId
().
equals
(
other
.
getCompanyId
()));
&&
(
this
.
getCompanyId
()
==
null
?
other
.
getCompanyId
()
==
null
:
this
.
getCompanyId
().
equals
(
other
.
getCompanyId
()))
&&
(
this
.
getType
()
==
null
?
other
.
getType
()
==
null
:
this
.
getType
().
equals
(
other
.
getType
()));
}
/**
...
...
@@ -165,6 +166,7 @@ public class JobAmazonAdLog {
result
=
prime
*
result
+
((
getBjModified
()
==
null
)
?
0
:
getBjModified
().
hashCode
());
result
=
prime
*
result
+
((
getSiteEn
()
==
null
)
?
0
:
getSiteEn
().
hashCode
());
result
=
prime
*
result
+
((
getCompanyId
()
==
null
)
?
0
:
getCompanyId
().
hashCode
());
result
=
prime
*
result
+
((
getType
()
==
null
)
?
0
:
getType
().
hashCode
());
return
result
;
}
}
data-common/src/main/java/com/bailuntec/domain/example/DcBaseFinanceAmazonAdProductExample.java
View file @
67d8e7e6
...
...
@@ -3171,6 +3171,66 @@ public class DcBaseFinanceAmazonAdProductExample {
addCriterion
(
"exchange_rate_usd not between"
,
value1
,
value2
,
"exchangeRateUsd"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeIsNull
()
{
addCriterion
(
"type is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeIsNotNull
()
{
addCriterion
(
"type is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeEqualTo
(
Integer
value
)
{
addCriterion
(
"type ="
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeNotEqualTo
(
Integer
value
)
{
addCriterion
(
"type <>"
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeGreaterThan
(
Integer
value
)
{
addCriterion
(
"type >"
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeGreaterThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"type >="
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeLessThan
(
Integer
value
)
{
addCriterion
(
"type <"
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeLessThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"type <="
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"type in"
,
values
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeNotIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"type not in"
,
values
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"type between"
,
value1
,
value2
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeNotBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"type not between"
,
value1
,
value2
,
"type"
);
return
(
Criteria
)
this
;
}
}
/**
...
...
@@ -3402,6 +3462,6 @@ public class DcBaseFinanceAmazonAdProductExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
void
example
(
DcBaseFinanceAmazonAdProductExample
example
);
void
example
(
com
.
bailuntec
.
domain
.
example
.
DcBaseFinanceAmazonAdProductExample
example
);
}
}
\ No newline at end of file
data-common/src/main/java/com/bailuntec/domain/example/JobAmazonAdLogExample.java
View file @
67d8e7e6
...
...
@@ -930,6 +930,66 @@ public class JobAmazonAdLogExample {
addCriterion
(
"company_id not between"
,
value1
,
value2
,
"companyId"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeIsNull
()
{
addCriterion
(
"type is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeIsNotNull
()
{
addCriterion
(
"type is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeEqualTo
(
Integer
value
)
{
addCriterion
(
"type ="
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeNotEqualTo
(
Integer
value
)
{
addCriterion
(
"type <>"
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeGreaterThan
(
Integer
value
)
{
addCriterion
(
"type >"
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeGreaterThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"type >="
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeLessThan
(
Integer
value
)
{
addCriterion
(
"type <"
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeLessThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"type <="
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"type in"
,
values
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeNotIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"type not in"
,
values
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"type between"
,
value1
,
value2
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeNotBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"type not between"
,
value1
,
value2
,
"type"
);
return
(
Criteria
)
this
;
}
}
/**
...
...
@@ -1161,6 +1221,6 @@ public class JobAmazonAdLogExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
void
example
(
JobAmazonAdLogExample
example
);
void
example
(
com
.
bailuntec
.
domain
.
example
.
JobAmazonAdLogExample
example
);
}
}
\ No newline at end of file
data-common/src/main/java/com/bailuntec/mapper/DcAutoSalesForecastStageConfigMapper.xml
View file @
67d8e7e6
...
...
@@ -53,7 +53,7 @@
and (t4.config_id = t5.id or t5.id not in (select config_id
from dc_auto_sales_forecast_product_code_config
where product_code = t1.product_code))
and (t6.warehouse_code = t5.warehouse_code or length(trim(t5.warehouse_code)) = 0)
and (t6.warehouse_code = t5.ware
ListenerContainer
house_code or length(trim(t5.warehouse_code)) = 0)
and (t6.hq_type = t5.warehouse_type or length(trim(t5.warehouse_type)) = 0)
and (t2.product_type = t5.category or length(trim(t5.category)) = 0)
and (t6.area_id = t5.warehouse_area_id or length(trim(t5.warehouse_area_id)) = 0)
...
...
@@ -66,7 +66,6 @@
t1.daily_weighted_sales
<
= t7.sales_upper_limit or
t1.daily_weighted_sales
>
= t7.sales_lower_limit or t1.daily_weighted_sales is null or
length(trim(t1.daily_weighted_sales)) = 0))
-- where t1.bailun_sku ='sku' and t1.warehouse_code = 'wa'
where t5.id is not null
ORDER BY t5.`level` desc) aaa
GROUP BY bailun_sku, warehouse_code;
...
...
data-common/src/main/java/com/bailuntec/mapper/DcBaseFinanceAmazonAdProductMapper.xml
View file @
67d8e7e6
...
...
@@ -64,6 +64,7 @@
<result
column=
"report_type"
jdbcType=
"VARCHAR"
property=
"reportType"
/>
<result
column=
"exchange_rate"
jdbcType=
"DECIMAL"
property=
"exchangeRate"
/>
<result
column=
"exchange_rate_usd"
jdbcType=
"DECIMAL"
property=
"exchangeRateUsd"
/>
<result
column=
"type"
jdbcType=
"INTEGER"
property=
"type"
/>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<!--
...
...
@@ -150,7 +151,7 @@
attributed_units_ordered_sevenday_same_sku,
attributed_units_ordered_fourteenday_same_sku, attributed_units_ordered_thirtyday_same_sku,
account_id, company_id, bj_create_time, bj_modify_time, report_date, report_type,
exchange_rate, exchange_rate_usd
exchange_rate, exchange_rate_usd
,type
</sql>
<select
id=
"selectByExample"
parameterType=
"com.bailuntec.domain.example.DcBaseFinanceAmazonAdProductExample"
resultMap=
"BaseResultMap"
>
...
...
@@ -230,7 +231,7 @@
attributed_units_ordered_thirtyday_same_sku, account_id,
company_id, bj_create_time, bj_modify_time,
report_date, report_type, exchange_rate,
exchange_rate_usd)
exchange_rate_usd
,type
)
values (#{id,jdbcType=INTEGER}, #{campaignName,jdbcType=VARCHAR}, #{campaignId,jdbcType=VARCHAR},
#{adGroupName,jdbcType=VARCHAR}, #{adGroupId,jdbcType=VARCHAR}, #{impressions,jdbcType=INTEGER},
#{clicks,jdbcType=INTEGER}, #{cost,jdbcType=DECIMAL}, #{currency,jdbcType=VARCHAR},
...
...
@@ -251,7 +252,7 @@
#{attributedUnitsOrderedThirtydaySameSku,jdbcType=VARCHAR}, #{accountId,jdbcType=INTEGER},
#{companyId,jdbcType=INTEGER}, #{bjCreateTime,jdbcType=TIMESTAMP}, #{bjModifyTime,jdbcType=TIMESTAMP},
#{reportDate,jdbcType=DATE}, #{reportType,jdbcType=VARCHAR}, #{exchangeRate,jdbcType=DECIMAL},
#{exchangeRateUsd,jdbcType=DECIMAL})
#{exchangeRateUsd,jdbcType=DECIMAL}
,#{type,jdbctype=INTEGER}
)
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.bailuntec.domain.entity.DcBaseFinanceAmazonAdProduct"
>
<!--
...
...
@@ -396,6 +397,9 @@
<if
test=
"record.exchangeRateUsd != null"
>
exchange_rate_usd,
</if>
<if
test=
"record.type != null"
>
type,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"record.id != null"
>
...
...
@@ -527,6 +531,9 @@
<if
test=
"record.exchangeRateUsd != null"
>
#{record.exchangeRateUsd,jdbcType=DECIMAL},
</if>
<if
test=
"record.type != null"
>
#{record.type,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select
id=
"countByExample"
parameterType=
"com.bailuntec.domain.example.DcBaseFinanceAmazonAdProductExample"
...
...
@@ -690,6 +697,9 @@
<if
test=
"record.exchangeRateUsd != null"
>
exchange_rate_usd = #{record.exchangeRateUsd,jdbcType=DECIMAL},
</if>
<if
test=
"record.type != null"
>
type = #{record.type,jdbcType=INTEGER},
</if>
</set>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
...
...
@@ -745,7 +755,8 @@
report_date = #{record.reportDate,jdbcType=DATE},
report_type = #{record.reportType,jdbcType=VARCHAR},
exchange_rate = #{record.exchangeRate,jdbcType=DECIMAL},
exchange_rate_usd = #{record.exchangeRateUsd,jdbcType=DECIMAL}
exchange_rate_usd = #{record.exchangeRateUsd,jdbcType=DECIMAL},
type = #{record.type,jdbcType=INTEGER}
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
...
...
@@ -886,6 +897,9 @@
<if
test=
"exchangeRateUsd != null"
>
exchange_rate_usd = #{exchangeRateUsd,jdbcType=DECIMAL},
</if>
<if
test=
"type != null"
>
type = #{type,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
...
...
@@ -936,7 +950,8 @@
report_date = #{reportDate,jdbcType=DATE},
report_type = #{reportType,jdbcType=VARCHAR},
exchange_rate = #{exchangeRate,jdbcType=DECIMAL},
exchange_rate_usd = #{exchangeRateUsd,jdbcType=DECIMAL}
exchange_rate_usd = #{exchangeRateUsd,jdbcType=DECIMAL},
type = #{type,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<insert
id=
"upsertSelective"
parameterType=
"com.bailuntec.domain.entity.DcBaseFinanceAmazonAdProduct"
>
...
...
@@ -1076,6 +1091,9 @@
<if
test=
"exchangeRateUsd != null"
>
exchange_rate_usd,
</if>
<if
test=
"type != null"
>
type,
</if>
</trim>
values
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
...
...
@@ -1208,6 +1226,9 @@
<if
test=
"exchangeRateUsd != null"
>
#{exchangeRateUsd,jdbcType=DECIMAL},
</if>
<if
test=
"type != null"
>
#{type,jdbcType=INTEGER},
</if>
</trim>
on duplicate key update
<trim
suffixOverrides=
","
>
...
...
@@ -1343,6 +1364,9 @@
<if
test=
"exchangeRateUsd != null"
>
exchange_rate_usd = #{exchangeRateUsd,jdbcType=DECIMAL},
</if>
<if
test=
"type != null"
>
type = #{type,jdbcType=INTEGER},
</if>
</trim>
</insert>
<insert
id=
"upsert"
parameterType=
"com.bailuntec.domain.entity.DcBaseFinanceAmazonAdProduct"
>
...
...
@@ -1363,7 +1387,7 @@
attributed_sales_thirtyday_same_sku, attributed_units_ordered_oneday_same_sku,
attributed_units_ordered_sevenday_same_sku, attributed_units_ordered_fourteenday_same_sku,
attributed_units_ordered_thirtyday_same_sku, account_id, company_id, bj_create_time,
bj_modify_time, report_date, report_type, exchange_rate, exchange_rate_usd)
bj_modify_time, report_date, report_type, exchange_rate, exchange_rate_usd
,type
)
values
(#{id,jdbcType=INTEGER}, #{campaignName,jdbcType=VARCHAR}, #{campaignId,jdbcType=VARCHAR},
#{adGroupName,jdbcType=VARCHAR}, #{adGroupId,jdbcType=VARCHAR}, #{impressions,jdbcType=INTEGER},
...
...
@@ -1385,7 +1409,7 @@
#{attributedUnitsOrderedThirtydaySameSku,jdbcType=VARCHAR}, #{accountId,jdbcType=INTEGER},
#{companyId,jdbcType=INTEGER}, #{bjCreateTime,jdbcType=TIMESTAMP}, #{bjModifyTime,jdbcType=TIMESTAMP},
#{reportDate,jdbcType=DATE}, #{reportType,jdbcType=VARCHAR}, #{exchangeRate,jdbcType=DECIMAL},
#{exchangeRateUsd,jdbcType=DECIMAL})
#{exchangeRateUsd,jdbcType=DECIMAL}
,#{type,jdbcType=INTEGER}
)
on duplicate key update
id = #{id,jdbcType=INTEGER},
campaign_name = #{campaignName,jdbcType=VARCHAR},
...
...
@@ -1429,7 +1453,8 @@
report_date = #{reportDate,jdbcType=DATE},
report_type = #{reportType,jdbcType=VARCHAR},
exchange_rate = #{exchangeRate,jdbcType=DECIMAL},
exchange_rate_usd = #{exchangeRateUsd,jdbcType=DECIMAL}
exchange_rate_usd = #{exchangeRateUsd,jdbcType=DECIMAL},
type = #{type,jdbcType=INTEGER}
</insert>
<select
id=
"selectOneByExample"
parameterType=
"com.bailuntec.domain.example.DcBaseFinanceAmazonAdProductExample"
resultMap=
"BaseResultMap"
>
...
...
@@ -1474,6 +1499,7 @@
ofType=
"com.bailuntec.domain.dto.DcBaseSkuMappingItemDto"
select=
"selectSkuMapping"
>
</collection>
</resultMap>
<select
id=
"selectSkuMapping"
resultType=
"com.bailuntec.domain.dto.DcBaseSkuMappingItemDto"
>
select dc0.*, dc1.unit_price
from dc_base_sku_mapping dc0
...
...
@@ -1482,6 +1508,7 @@
and dc0.site = #{siteEn}
and dc0.has_deleted = 0
</select>
<select
id=
"selectAmazonItem"
resultMap=
"BaseResultMap1"
>
select dc0.*, dc1.site_en
from dc_base_finance_amazon_ad_product dc0
...
...
data-common/src/main/java/com/bailuntec/mapper/DcBaseOmsSkuMapper.java
View file @
67d8e7e6
...
...
@@ -148,5 +148,6 @@ public interface DcBaseOmsSkuMapper {
Integer
omsSkuSellerCount
(
@Param
(
"lowerTime"
)
LocalDateTime
lowerTime
,
@Param
(
"upperTime"
)
LocalDateTime
upperTime
,
@Param
(
"bailunSku"
)
String
bailunSku
,
@Param
(
"warehouseCode"
)
String
warehouseCode
,
@Param
(
"dyas"
)
Integer
days
);
@Param
(
"warehouseCode"
)
String
warehouseCode
,
@Param
(
"days"
)
Integer
days
);
}
data-common/src/main/java/com/bailuntec/mapper/DcBaseOmsSkuMapper.xml
View file @
67d8e7e6
...
...
@@ -3711,12 +3711,19 @@
</select>
<select
id=
"omsSkuSellerCount"
resultType=
"java.lang.Integer"
>
select coalesce(sum(bailun_sku_quantity_ordered), 0)
select
(select
coalesce(sum(bailun_sku_quantity_ordered), 0)
from dc_base_oms_sku
where paid_time
>
= #{lowerTime}
and paid_time
<
= #{upperTime}
and bailun_sku = #{bailunSku}
and warehouse_code = #{warehouseCode}
and has_fba_s = 0
and has_delete = 0
and has_scalp = 0
and has_buyer_remark = 0
and has_platsku_remark = 0
and has_innersale = 0
) / #{days}
</select>
...
...
data-common/src/main/java/com/bailuntec/mapper/JobAmazonAdLogMapper.xml
View file @
67d8e7e6
...
...
@@ -6,15 +6,16 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"account_id"
jdbcType=
"INTEGER"
property=
"accountId"
/>
<result
column=
"report_id"
jdbcType=
"VARCHAR"
property=
"reportId"
/>
<result
column=
"report_date"
jdbcType=
"DATE"
property=
"reportDate"
/>
<result
column=
"status"
jdbcType=
"BIT"
property=
"status"
/>
<result
column=
"bj_create"
jdbcType=
"TIMESTAMP"
property=
"bjCreate"
/>
<result
column=
"bj_modified"
jdbcType=
"TIMESTAMP"
property=
"bjModified"
/>
<result
column=
"site_en"
jdbcType=
"VARCHAR"
property=
"siteEn"
/>
<result
column=
"company_id"
jdbcType=
"INTEGER"
property=
"companyId"
/>
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"account_id"
jdbcType=
"INTEGER"
property=
"accountId"
/>
<result
column=
"report_id"
jdbcType=
"VARCHAR"
property=
"reportId"
/>
<result
column=
"report_date"
jdbcType=
"DATE"
property=
"reportDate"
/>
<result
column=
"status"
jdbcType=
"BIT"
property=
"status"
/>
<result
column=
"bj_create"
jdbcType=
"TIMESTAMP"
property=
"bjCreate"
/>
<result
column=
"bj_modified"
jdbcType=
"TIMESTAMP"
property=
"bjModified"
/>
<result
column=
"site_en"
jdbcType=
"VARCHAR"
property=
"siteEn"
/>
<result
column=
"company_id"
jdbcType=
"INTEGER"
property=
"companyId"
/>
<result
column=
"type"
jdbcType=
"INTEGER"
property=
"type"
/>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<!--
...
...
@@ -38,8 +39,7 @@
</when>
<when
test=
"criterion.listValue"
>
and ${criterion.condition}
<foreach
close=
")"
collection=
"criterion.value"
item=
"listItem"
open=
"("
separator=
","
>
<foreach
close=
")"
collection=
"criterion.value"
item=
"listItem"
open=
"("
separator=
","
>
#{listItem}
</foreach>
</when>
...
...
@@ -72,8 +72,7 @@
</when>
<when
test=
"criterion.listValue"
>
and ${criterion.condition}
<foreach
close=
")"
collection=
"criterion.value"
item=
"listItem"
open=
"("
separator=
","
>
<foreach
close=
")"
collection=
"criterion.value"
item=
"listItem"
open=
"("
separator=
","
>
#{listItem}
</foreach>
</when>
...
...
@@ -90,10 +89,9 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, account_id, report_id, report_date, status, bj_create, bj_modified, site_en,
company_id
company_id, type
</sql>
<select
id=
"selectByExample"
parameterType=
"com.bailuntec.domain.example.JobAmazonAdLogExample"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByExample"
parameterType=
"com.bailuntec.domain.example.JobAmazonAdLogExample"
resultMap=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
...
...
@@ -102,10 +100,10 @@
<if
test=
"distinct"
>
distinct
</if>
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from job_amazon_ad_log
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
<include
refid=
"Example_Where_Clause"
/>
</if>
<if
test=
"orderByClause != null"
>
order by ${orderByClause}
...
...
@@ -125,7 +123,7 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from job_amazon_ad_log
where id = #{id,jdbcType=INTEGER}
</select>
...
...
@@ -144,7 +142,7 @@
-->
delete from job_amazon_ad_log
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
<include
refid=
"Example_Where_Clause"
/>
</if>
</delete>
<insert
id=
"insert"
parameterType=
"com.bailuntec.domain.entity.JobAmazonAdLog"
>
...
...
@@ -154,12 +152,12 @@
-->
insert into job_amazon_ad_log (id, account_id, report_id,
report_date, status, bj_create,
bj_modified, site_en, company_id
)
bj_modified, site_en, company_id,
type
)
values (#{id,jdbcType=INTEGER}, #{accountId,jdbcType=INTEGER}, #{reportId,jdbcType=VARCHAR},
#{reportDate,jdbcType=DATE}, #{status,jdbcType=BIT}, #{bjCreate,jdbcType=TIMESTAMP},
#{bjModified,jdbcType=TIMESTAMP}, #{siteEn,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER}
)
#{bjModified,jdbcType=TIMESTAMP}, #{siteEn,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER},
#{type,jdbcType=INTEGER}
)
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.bailuntec.domain.entity.JobAmazonAdLog"
>
<!--
...
...
@@ -195,6 +193,9 @@
<if
test=
"companyId != null"
>
company_id,
</if>
<if
test=
"type != null"
>
type,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
...
...
@@ -224,17 +225,19 @@
<if
test=
"companyId != null"
>
#{companyId,jdbcType=INTEGER},
</if>
<if
test=
"type != null"
>
#{type,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select
id=
"countByExample"
parameterType=
"com.bailuntec.domain.example.JobAmazonAdLogExample"
resultType=
"java.lang.Long"
>
<select
id=
"countByExample"
parameterType=
"com.bailuntec.domain.example.JobAmazonAdLogExample"
resultType=
"java.lang.Long"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from job_amazon_ad_log
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
<include
refid=
"Example_Where_Clause"
/>
</if>
</select>
<update
id=
"updateByExampleSelective"
parameterType=
"map"
>
...
...
@@ -271,9 +274,12 @@
<if
test=
"record.companyId != null"
>
company_id = #{record.companyId,jdbcType=INTEGER},
</if>
<if
test=
"record.type != null"
>
type = #{record.type,jdbcType=INTEGER},
</if>
</set>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByExample"
parameterType=
"map"
>
...
...
@@ -290,9 +296,10 @@
bj_create = #{record.bjCreate,jdbcType=TIMESTAMP},
bj_modified = #{record.bjModified,jdbcType=TIMESTAMP},
site_en = #{record.siteEn,jdbcType=VARCHAR},
company_id = #{record.companyId,jdbcType=INTEGER}
company_id = #{record.companyId,jdbcType=INTEGER},
type = #{record.type,jdbcType=INTEGER}
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.bailuntec.domain.entity.JobAmazonAdLog"
>
...
...
@@ -326,6 +333,9 @@
<if
test=
"companyId != null"
>
company_id = #{companyId,jdbcType=INTEGER},
</if>
<if
test=
"type != null"
>
type = #{type,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
...
...
@@ -342,7 +352,8 @@
bj_create = #{bjCreate,jdbcType=TIMESTAMP},
bj_modified = #{bjModified,jdbcType=TIMESTAMP},
site_en = #{siteEn,jdbcType=VARCHAR},
company_id = #{companyId,jdbcType=INTEGER}
company_id = #{companyId,jdbcType=INTEGER},
type = #{type,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<insert
id=
"upsertSelective"
parameterType=
"com.bailuntec.domain.entity.JobAmazonAdLog"
>
...
...
@@ -380,6 +391,9 @@
<if
test=
"companyId != null"
>
company_id,
</if>
<if
test=
"type != null"
>
type,
</if>
</trim>
values
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
...
...
@@ -410,6 +424,9 @@
<if
test=
"companyId != null"
>
#{companyId,jdbcType=INTEGER},
</if>
<if
test=
"type != null"
>
#{type,jdbcType=INTEGER},
</if>
</trim>
on duplicate key update
<trim
suffixOverrides=
","
>
...
...
@@ -440,6 +457,9 @@
<if
test=
"companyId != null"
>
company_id = #{companyId,jdbcType=INTEGER},
</if>
<if
test=
"type != null"
>
type = #{type,jdbcType=INTEGER},
</if>
</trim>
</insert>
<insert
id=
"upsert"
parameterType=
"com.bailuntec.domain.entity.JobAmazonAdLog"
>
...
...
@@ -450,12 +470,12 @@
-->
insert into job_amazon_ad_log
(id, account_id, report_id, report_date, status, bj_create, bj_modified, site_en,
company_id
)
company_id, type
)
values
(#{id,jdbcType=INTEGER}, #{accountId,jdbcType=INTEGER}, #{reportId,jdbcType=VARCHAR},
#{reportDate,jdbcType=DATE}, #{status,jdbcType=BIT}, #{bjCreate,jdbcType=TIMESTAMP},
#{bjModified,jdbcType=TIMESTAMP}, #{siteEn,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER}
)
#{bjModified,jdbcType=TIMESTAMP}, #{siteEn,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER},
#{type,jdbcType=INTEGER}
)
on duplicate key update
id = #{id,jdbcType=INTEGER},
account_id = #{accountId,jdbcType=INTEGER},
...
...
@@ -465,20 +485,20 @@
bj_create = #{bjCreate,jdbcType=TIMESTAMP},
bj_modified = #{bjModified,jdbcType=TIMESTAMP},
site_en = #{siteEn,jdbcType=VARCHAR},
company_id = #{companyId,jdbcType=INTEGER}
company_id = #{companyId,jdbcType=INTEGER},
type = #{type,jdbcType=INTEGER}
</insert>
<select
id=
"selectOneByExample"
parameterType=
"com.bailuntec.domain.example.JobAmazonAdLogExample"
resultMap=
"BaseResultMap"
>
<select
id=
"selectOneByExample"
parameterType=
"com.bailuntec.domain.example.JobAmazonAdLogExample"
resultMap=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from job_amazon_ad_log
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
<include
refid=
"Example_Where_Clause"
/>
</if>
<if
test=
"orderByClause != null"
>
order by ${orderByClause}
...
...
data-common/src/main/resources/init.properties
View file @
67d8e7e6
table-name
=
dc_base_
oms_sku_exception
table-name
=
dc_base_
finance_amazon_ad_product
data-show/show-auto-turnover/src/main/java/com/bailuntec/service/impl/AutoTurnoverServiceImpl.java
View file @
67d8e7e6
package
com
.
bailuntec
.
service
.
impl
;
import
com.bailuntec.domain.constant.CommonConstant
;
import
com.bailuntec.domain.constant.Constant
;
import
com.bailuntec.domain.entity.*
;
import
com.bailuntec.domain.enumerate.PlatformType
;
import
com.bailuntec.domain.example.*
;
import
com.bailuntec.mapper.*
;
import
com.bailuntec.domain.entity.DcAutoSalesForecastStageConfig
;
import
com.bailuntec.domain.entity.DcAutoTurnover
;
import
com.bailuntec.mapper.DcAutoSalesForecastStageConfigMapper
;
import
com.bailuntec.mapper.DcBaseOmsSkuMapper
;
import
com.bailuntec.service.AutoTurnoverService
;
import
com.bailuntec.utils.SessionUtil
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -34,8 +32,6 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
SqlSession
session
=
SessionUtil
.
getFactory
().
openSession
(
true
);
try
{
Queue
<
BigDecimal
>
forecastSalesDetails
=
new
LinkedList
<>();
//销量公式
Queue
<
String
>
forecastSalesDetailsFormula
=
new
LinkedList
<>();
for
(
int
j
=
0
;
j
<
new
BigDecimal
(
autoForecastDay
).
divide
(
new
BigDecimal
(
turnoverDays
),
0
,
BigDecimal
.
ROUND_UP
).
intValue
();
j
++)
{
...
...
@@ -46,7 +42,6 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
//命中的预测规则
DcAutoSalesForecastStageConfig
dcAutoSalesForecastStageConfig
=
dcAutoSalesForecastStageConfigMapper
.
selectMatchStage
(
dcAutoTurnover
.
getBailunSku
(),
dcAutoTurnover
.
getWarehouseCode
());
//周转天数
/*
* 每个时间段的销量预测是dcAutoSalesForecastStageConfig对应时间段的三个参数对应的过去时间段的销量的加权平均*/
...
...
@@ -66,67 +61,56 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
int
duration3
=
turnoverDays
-
duration1
-
duration2
;
int
oneN1
=
dcAutoSalesForecastStageConfig
.
getOneN1
().
intValue
();
int
oneN3
=
dcAutoSalesForecastStageConfig
.
getOneN3
().
intValue
();
int
oneN5
=
dcAutoSalesForecastStageConfig
.
getOneN5
().
intValue
();
int
twoN1
=
dcAutoSalesForecastStageConfig
.
getTwoN1
().
intValue
();
int
twoN3
=
dcAutoSalesForecastStageConfig
.
getTwoN3
().
intValue
();
int
twoN5
=
dcAutoSalesForecastStageConfig
.
getTwoN5
().
intValue
();
int
threeN1
=
dcAutoSalesForecastStageConfig
.
getThreeN1
().
intValue
();
int
threeN3
=
dcAutoSalesForecastStageConfig
.
getThreeN3
().
intValue
();
int
threeN5
=
dcAutoSalesForecastStageConfig
.
getThreeN5
().
intValue
();
/*第一部分预测*/
BigDecimal
duration1ForecastSellerNum
=
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getOneN1
().
intValue
()
)).
orElse
(
0
))
BigDecimal
duration1ForecastSellerNum
=
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
oneN1
==
0
?
1
:
oneN1
)).
orElse
(
0
))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getOneN2
())
.
add
(
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getOneN3
().
intValue
()
)).
orElse
(
0
))
.
add
(
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
oneN3
==
0
?
1
:
oneN3
)).
orElse
(
0
))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getOneN4
()))
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getOneN5
().
intValue
()
))
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
oneN5
==
0
?
1
:
oneN5
))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getOneN6
()));
for
(
int
i
=
0
;
i
<
duration1
;
i
++)
{
if
(
autoForecastDay
>=
forecastSalesDetails
.
size
())
{
forecastSalesDetails
.
offer
(
duration1ForecastSellerNum
);
forecastSalesDetailsFormula
.
offer
(
"("
+
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getOneN1
().
intValue
())
+
"*"
+
dcAutoSalesForecastStageConfig
.
getOneN2
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getOneN3
().
intValue
())).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getOneN4
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getOneN5
().
intValue
())).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getOneN6
()
+
")"
);
}
}
/*第二部分预测*/
BigDecimal
duration2ForecastSellerNum
=
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getTwoN1
().
intValue
()
))
BigDecimal
duration2ForecastSellerNum
=
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
twoN1
==
0
?
1
:
twoN1
))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getTwoN2
())
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getTwoN3
().
intValue
()
))
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
twoN3
==
0
?
1
:
twoN3
))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getTwoN4
()))
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getTwoN5
().
intValue
()
))
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
twoN5
==
0
?
1
:
twoN5
))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getTwoN6
()));
for
(
int
i
=
0
;
i
<
duration2
;
i
++)
{
if
(
autoForecastDay
>=
forecastSalesDetails
.
size
())
{
forecastSalesDetails
.
offer
(
duration2ForecastSellerNum
);
forecastSalesDetailsFormula
.
offer
(
"("
+
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getTwoN1
().
intValue
())
+
"*"
+
dcAutoSalesForecastStageConfig
.
getTwoN2
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getTwoN3
().
intValue
())).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getTwoN4
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getTwoN5
().
intValue
())).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getTwoN6
()
+
")"
);
}
}
/*第三部分预测*/
BigDecimal
duration3ForecastSellerNum
=
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getThreeN1
().
intValue
()
))
BigDecimal
duration3ForecastSellerNum
=
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
threeN1
==
0
?
1
:
threeN1
))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getThreeN2
())
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getThreeN3
().
intValue
()
))
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
threeN3
==
0
?
1
:
threeN3
))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getThreeN4
()))
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getThreeN5
().
intValue
()
))
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
threeN5
==
0
?
1
:
threeN5
))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getThreeN6
()));
for
(
int
i
=
0
;
i
<
duration3
;
i
++)
{
if
(
autoForecastDay
>=
forecastSalesDetails
.
size
())
{
forecastSalesDetails
.
offer
(
duration3ForecastSellerNum
);
forecastSalesDetailsFormula
.
offer
(
"("
+
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getThreeN1
().
intValue
())
+
"*"
+
dcAutoSalesForecastStageConfig
.
getThreeN2
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getThreeN3
().
intValue
())).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getThreeN4
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getThreeN5
().
intValue
())).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getThreeN6
()
+
")"
);
}
}
...
...
@@ -153,26 +137,16 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
SqlSession
session
=
SessionUtil
.
getFactory
().
openSession
(
true
);
try
{
Queue
<
BigDecimal
>
forecastSalesDetails
=
new
LinkedList
<>();
//销量公式
Queue
<
String
>
forecastSalesDetailsFormula
=
new
LinkedList
<>();
for
(
int
j
=
0
;
j
<
new
BigDecimal
(
autoForecastDay
).
divide
(
new
BigDecimal
(
turnoverDays
),
0
,
BigDecimal
.
ROUND_UP
).
intValue
();
j
++)
{
DcAutoSalesForecastStageConfigMapper
dcAutoSalesForecastStageConfigMapper
=
session
.
getMapper
(
DcAutoSalesForecastStageConfigMapper
.
class
);
DcAutoTurnoverMapper
dcAutoTurnoverMapper
=
session
.
getMapper
(
DcAutoTurnoverMapper
.
class
);
DcBaseOmsSkuMapper
dcBaseOmsSkuMapper
=
session
.
getMapper
(
DcBaseOmsSkuMapper
.
class
);
//命中的预测规则
DcAutoSalesForecastStageConfig
dcAutoSalesForecastStageConfig
=
dcAutoSalesForecastStageConfigMapper
.
selectMatchStage
(
dcAutoTurnover
.
getBailunSku
(),
dcAutoTurnover
.
getWarehouseCode
());
// if (dcAutoSalesForecastStageConfig == null) {
// return;
// }
//周转天数
/*
* 每个时间段的销量预测是dcAutoSalesForecastStageConfig对应时间段的三个参数对应的过去时间段的销量的加权平均*/
//今天0点
LocalDateTime
midNight
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
);
String
bailunSku
=
dcAutoTurnover
.
getBailunSku
();
...
...
@@ -180,84 +154,64 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
if
(
dcAutoSalesForecastStageConfig
!=
null
)
{
log
.
info
(
"匹配到一条规则 id:{}"
,
dcAutoSalesForecastStageConfig
.
getConfigId
());
int
duration1
=
BigDecimal
.
valueOf
(
turnoverDays
).
multiply
(
dcAutoSalesForecastStageConfig
.
getOneRatio
()).
intValue
();
int
duration2
=
BigDecimal
.
valueOf
(
turnoverDays
).
multiply
(
dcAutoSalesForecastStageConfig
.
getTwoRatio
()).
intValue
();
int
duration3
=
turnoverDays
-
duration1
-
duration2
;
/*第一部分预测*/
BigDecimal
duration1ForecastSellerNum
=
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getOneN1
().
intValue
())).
orElse
(
0
))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getOneN2
())
.
add
(
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getOneN3
().
intValue
())).
orElse
(
0
))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getOneN4
()))
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getOneN5
().
intValue
()))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getOneN6
()));
int
oneN1
=
dcAutoSalesForecastStageConfig
.
getOneN1
().
intValue
();
int
oneN3
=
dcAutoSalesForecastStageConfig
.
getOneN3
().
intValue
();
int
oneN5
=
dcAutoSalesForecastStageConfig
.
getOneN5
().
intValue
();
int
twoN1
=
dcAutoSalesForecastStageConfig
.
getTwoN1
().
intValue
();
int
twoN3
=
dcAutoSalesForecastStageConfig
.
getTwoN3
().
intValue
();
int
twoN5
=
dcAutoSalesForecastStageConfig
.
getTwoN5
().
intValue
();
int
threeN1
=
dcAutoSalesForecastStageConfig
.
getThreeN1
().
intValue
();
int
threeN3
=
dcAutoSalesForecastStageConfig
.
getThreeN3
().
intValue
();
int
threeN5
=
dcAutoSalesForecastStageConfig
.
getThreeN5
().
intValue
();
for
(
int
i
=
0
;
i
<
duration1
;
i
++)
{
if
(
autoForecastDay
>=
forecastSalesDetails
.
size
())
{
forecastSalesDetails
.
offer
(
duration1ForecastSellerNum
);
forecastSalesDetailsFormula
.
offer
(
"("
+
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getOneN1
().
intValue
())
+
"*"
+
dcAutoSalesForecastStageConfig
.
getOneN2
()
+
")"
if
(
autoForecastDay
>=
forecastSalesDetailsFormula
.
size
())
{
forecastSalesDetailsFormula
.
offer
(
"("
+
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
oneN1
==
0
?
1
:
oneN1
)
+
"*"
+
dcAutoSalesForecastStageConfig
.
getOneN2
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getOneN3
().
intValue
()
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getOneN4
()
+
")"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
oneN3
==
0
?
1
:
oneN3
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getOneN4
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getOneN5
().
intValue
())).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getOneN6
()
+
")"
);
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getOneN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
oneN5
==
0
?
1
:
oneN5
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getOneN6
()
+
")"
);
}
}
/*第二部分预测*/
BigDecimal
duration2ForecastSellerNum
=
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getTwoN1
().
intValue
()))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getTwoN2
())
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getTwoN3
().
intValue
()))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getTwoN4
()))
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getTwoN5
().
intValue
()))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getTwoN6
()));
for
(
int
i
=
0
;
i
<
duration2
;
i
++)
{
if
(
autoForecastDay
>=
forecastSalesDetails
.
size
())
{
if
(
autoForecastDay
>=
forecastSalesDetails
Formula
.
size
())
{
forecastSalesDetails
.
offer
(
duration2ForecastSellerNum
);
forecastSalesDetailsFormula
.
offer
(
"("
+
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getTwoN1
().
intValue
())
+
"*"
+
dcAutoSalesForecastStageConfig
.
getTwoN2
()
+
")"
forecastSalesDetailsFormula
.
offer
(
"("
+
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
twoN1
==
0
?
1
:
twoN1
)
+
"*"
+
dcAutoSalesForecastStageConfig
.
getTwoN2
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getTwoN3
().
intValue
()
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getTwoN4
()
+
")"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
twoN3
==
0
?
1
:
twoN3
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getTwoN4
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getTwoN5
().
intValue
()
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getTwoN6
()
+
")"
);
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getTwoN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
twoN5
==
0
?
1
:
twoN5
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getTwoN6
()
+
")"
);
}
}
/*第三部分预测*/
BigDecimal
duration3ForecastSellerNum
=
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getThreeN1
().
intValue
()))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getThreeN2
())
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getThreeN3
().
intValue
()))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getThreeN4
()))
.
add
(
BigDecimal
.
valueOf
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getThreeN5
().
intValue
()))
.
multiply
(
dcAutoSalesForecastStageConfig
.
getThreeN6
()));
for
(
int
i
=
0
;
i
<
duration3
;
i
++)
{
if
(
autoForecastDay
>=
forecastSalesDetails
.
size
())
{
forecastSalesDetails
.
offer
(
duration3ForecastSellerNum
);
if
(
autoForecastDay
>=
forecastSalesDetailsFormula
.
size
())
{
forecastSalesDetailsFormula
.
offer
(
"("
+
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getThreeN1
().
intValue
()
)
+
"*"
+
dcAutoSalesForecastStageConfig
.
getThreeN2
()
+
")"
forecastSalesDetailsFormula
.
offer
(
"("
+
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN1
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
threeN1
==
0
?
1
:
threeN1
)
+
"*"
+
dcAutoSalesForecastStageConfig
.
getThreeN2
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getThreeN3
().
intValue
()
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getThreeN4
()
+
")"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN3
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
threeN3
==
0
?
1
:
threeN3
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getThreeN4
()
+
")"
+
"+"
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
dcAutoSalesForecastStageConfig
.
getThreeN5
().
intValue
()
)).
orElse
(
0
))
+
"*"
+
dcAutoSalesForecastStageConfig
.
getThreeN6
()
+
")"
);
+
"("
+
BigDecimal
.
valueOf
(
Optional
.
ofNullable
(
dcBaseOmsSkuMapper
.
omsSkuSellerCount
(
midNight
.
minusDays
(
dcAutoSalesForecastStageConfig
.
getThreeN5
().
intValue
()),
midNight
,
bailunSku
,
warehouseCode
,
threeN5
==
0
?
1
:
threeN5
)).
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
++)
{
if
(
autoForecastDay
>=
forecastSalesDetails
.
size
())
{
forecastSalesDetails
.
offer
(
dcAutoTurnover
.
getDailyWeightedSales
());
if
(
autoForecastDay
>=
forecastSalesDetailsFormula
.
size
())
{
forecastSalesDetailsFormula
.
add
(
""
);
}
}
}
...
...
@@ -270,195 +224,4 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
}
public
void
autoTurnoverFromStock
(
DcBaseStock
dcBaseStock
)
{
SqlSession
session
=
SessionUtil
.
getFactory
().
openSession
(
true
);
try
{
/*mapper*/
//仓库mapper
DcBaseWarehouseMapper
baseWarehouseMapper
=
session
.
getMapper
(
DcBaseWarehouseMapper
.
class
);
//周转mapper
DcAutoTurnoverMapper
dcAutoTurnoverMapper
=
session
.
getMapper
(
DcAutoTurnoverMapper
.
class
);
//sku mapper
DcBaseSkuMapper
baseSkuMapper
=
session
.
getMapper
(
DcBaseSkuMapper
.
class
);
//平均采购指标mapper
DcAveragePurchaseMapper
dcAveragePurchaseMapper
=
session
.
getMapper
(
DcAveragePurchaseMapper
.
class
);
//仓库平均指标mapper
DcAverageWarehouseMapper
dcAverageWarehouseMapper
=
session
.
getMapper
(
DcAverageWarehouseMapper
.
class
);
//采购在途mapper
DcMidTransitMapper
dcMidTransitMapper
=
session
.
getMapper
(
DcMidTransitMapper
.
class
);
//海外仓FBA仓入库天数设定 mapper
DcAutoConfigDeliveryMapper
dcAutoConfigDeliveryMapper
=
session
.
getMapper
(
DcAutoConfigDeliveryMapper
.
class
);
//库存对应的周转记录
DcAutoTurnover
dcAutoTurnover
=
dcAutoTurnoverMapper
.
selectOneByExample
(
DcAutoTurnoverExample
.
newAndCreateCriteria
()
.
andBailunSkuEqualTo
(
dcBaseStock
.
getBailunSku
())
.
andWarehouseCodeEqualTo
(
dcBaseStock
.
getWarehouseCode
())
.
example
());
if
(
dcAutoTurnover
==
null
)
{
dcAutoTurnover
=
new
DcAutoTurnover
();
//设置百伦sku
dcAutoTurnover
.
setBailunSku
(
dcBaseStock
.
getBailunSku
());
dcAutoTurnover
.
setWarehouseCode
(
dcBaseStock
.
getWarehouseCode
());
}
//周转记录对应的仓库编码
DcBaseWarehouse
dcBaseWarehouse
=
baseWarehouseMapper
.
selectOneByExample
(
DcBaseWarehouseExample
.
newAndCreateCriteria
()
.
andWarehouseCodeEqualTo
(
dcAutoTurnover
.
getWarehouseCode
())
.
example
());
if
(
dcBaseWarehouse
!=
null
)
{
//设置仓库名称
dcAutoTurnover
.
setWarehouseName
(
dcBaseWarehouse
.
getWarehouseName
());
if
(
dcBaseWarehouse
.
getSystemFlag
().
toUpperCase
().
equals
(
PlatformType
.
FBA
.
value
()))
{
dcAutoTurnover
.
setWarehouseName
(
dcBaseWarehouse
.
getBailunAccount
());
}
}
//周转记录对应的基础sku
DcBaseSku
dcBaseSku
=
baseSkuMapper
.
selectOneByExample
(
DcBaseSkuExample
.
newAndCreateCriteria
()
.
andBailunSkuEqualTo
(
dcAutoTurnover
.
getBailunSku
())
.
example
());
//sku对应的采购平均指标
DcAveragePurchase
dcAveragePurchase
=
dcAveragePurchaseMapper
.
selectOneByExample
(
DcAveragePurchaseExample
.
newAndCreateCriteria
()
.
andBailunSkuEqualTo
(
dcAutoTurnover
.
getBailunSku
())
.
andWarehouseCodeEqualTo
(
dcAutoTurnover
.
getWarehouseCode
())
.
andSupplierIdEqualTo
(
dcBaseSku
.
getSuppliersId
())
.
example
());
//sku对应的仓库平均指标
DcAverageWarehouse
dcAverageWarehouse
=
dcAverageWarehouseMapper
.
selectOneByExample
(
DcAverageWarehouseExample
.
newAndCreateCriteria
()
.
andBailunSkuEqualTo
(
dcAutoTurnover
.
getBailunSku
())
.
andWarehouseCodeEqualTo
(
dcAutoTurnover
.
getWarehouseCode
())
.
example
());
//是否先款后货? 先款后货供应链长度加一天 或者 没有采购平均指标这数据也要加一天 paymentBeforeDelivery = 1
Integer
paymentBeforeDelivery
=
null
;
if
(
dcAveragePurchase
==
null
||
(
dcAveragePurchase
.
getPaymentType
()
!=
null
&&
dcAveragePurchase
.
getPaymentType
().
equals
(
1
)))
{
paymentBeforeDelivery
=
1
;
}
//百伦sku一级分类
Integer
bailunFirstLevelCategoryId
=
null
;
//海外仓FBA仓入库天数设定 (调拨头程 + 调拨打包 + 海外仓入库天数)
DcAutoConfigDelivery
dcAutoConfigDelivery
;
//如果不是国内仓 就读配置表
if
(
dcBaseWarehouse
!=
null
&&
!
dcBaseWarehouse
.
getHqType
().
equals
(
CommonConstant
.
DOMESTIC_WAREHOUSE
))
{
dcAutoConfigDelivery
=
dcAutoConfigDeliveryMapper
.
selectOneByExample
(
DcAutoConfigDeliveryExample
.
newAndCreateCriteria
()
.
andVariableCodeEqualTo
(
dcAutoTurnover
.
getWarehouseCode
())
.
andBailunSkuEqualTo
(
dcAutoTurnover
.
getBailunSku
())
.
andStatusEqualTo
(
1
)
.
andTypeEqualTo
(
1
)
.
example
());
if
(
dcAutoConfigDelivery
==
null
)
{
dcAutoConfigDelivery
=
dcAutoConfigDeliveryMapper
.
selectOneByExample
(
DcAutoConfigDeliveryExample
.
newAndCreateCriteria
()
.
andVariableCodeEqualTo
(
dcBaseWarehouse
.
getHqType
())
.
andBailunSkuEqualTo
(
dcAutoTurnover
.
getBailunSku
())
.
andStatusEqualTo
(
1
)
.
andTypeEqualTo
(
2
)
.
example
());
}
if
(
dcAutoConfigDelivery
==
null
)
{
dcAutoConfigDelivery
=
dcAutoConfigDeliveryMapper
.
selectOneByExample
(
DcAutoConfigDeliveryExample
.
newAndCreateCriteria
()
.
andVariableCodeEqualTo
(
dcAutoTurnover
.
getWarehouseCode
())
.
andStatusEqualTo
(
1
)
.
andTypeEqualTo
(
3
)
.
example
());
}
if
(
dcAutoConfigDelivery
==
null
)
{
dcAutoConfigDelivery
=
dcAutoConfigDeliveryMapper
.
selectOneByExample
(
DcAutoConfigDeliveryExample
.
newAndCreateCriteria
()
.
andVariableCodeEqualTo
(
dcBaseWarehouse
.
getHqType
())
.
andStatusEqualTo
(
1
)
.
andTypeEqualTo
(
4
)
.
example
());
}
if
(
dcAutoConfigDelivery
==
null
)
{
dcAutoConfigDelivery
=
new
DcAutoConfigDelivery
(
0
,
0
,
0
);
}
/*
* 供应商交期
* 先取dc_average_purchase,如果平均交期没有
* 再去SKUMS取, 取SKUMS数据的时候如果是国内仓,就还取dc_base_sku原来那个字段,否则就要取dc_base_sku原新字段(调拨交期)
*/
Integer
turnoverSupplierDelivery
=
dcAveragePurchase
!=
null
&&
dcAveragePurchase
.
getDeliveryDays
()
>=
0
?
dcAveragePurchase
.
getDeliveryDays
()
:
-
1
;
if
(
turnoverSupplierDelivery
.
equals
(-
1
)
||
turnoverSupplierDelivery
>
100
)
{
turnoverSupplierDelivery
=
dcBaseSku
.
getSupplierDelivery
();
//如果非国内仓且是JIT,就取调拨交期
if
(!
dcBaseWarehouse
.
getHqType
().
equals
(
CommonConstant
.
DOMESTIC_WAREHOUSE
)
&&
(
Constant
.
BUYER_JIT_1
.
equals
(
dcBaseSku
.
getBuyerName
())
||
Constant
.
BUYER_JIT_2
.
equals
(
dcBaseSku
.
getBuyerName
())))
{
turnoverSupplierDelivery
=
dcBaseSku
.
getTransferDelivery
();
}
}
//入库天数
Integer
turnoverInboundDelivery
=
Constant
.
INSPECTION_DELIVE
;
//设置质检入库天数-配置值(实际还没用上)
dcAutoTurnover
.
setInspectionConfigDelivery
(
turnoverInboundDelivery
);
//设置调拨头程
Integer
turnoverTransferHeadDelivery
=
dcAutoConfigDelivery
.
getTranferHead
();
dcAutoTurnover
.
setTransferConfigDelivery
(
turnoverTransferHeadDelivery
);
//设置调拨打包
Integer
turnoverTransferBaleDelivery
=
dcAutoConfigDelivery
.
getTranferBale
();
dcAutoTurnover
.
setTransferBaleConfigDelivery
(
turnoverTransferBaleDelivery
);
//设置海外仓入库
Integer
turnoverAbroadInboundDelivery
=
dcAutoConfigDelivery
.
getAbroadInbound
();
dcAutoTurnover
.
setAbroadInboundConfigDelivery
(
turnoverAbroadInboundDelivery
);
if
(
dcAverageWarehouse
!=
null
)
{
if
(
dcAverageWarehouse
.
getInboundDays
()
!=
null
&&
dcAverageWarehouse
.
getInboundDays
()
>
0
)
{
turnoverInboundDelivery
=
dcAverageWarehouse
.
getInboundDays
();
}
if
(
dcAverageWarehouse
.
getTransferDelivery
()
!=
null
&&
dcAverageWarehouse
.
getTransferDelivery
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
turnoverTransferHeadDelivery
=
dcAverageWarehouse
.
getTransferDelivery
().
intValue
();
}
if
(
dcAverageWarehouse
.
getTransferBaleDelivery
()
!=
null
&&
dcAverageWarehouse
.
getTransferBaleDelivery
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
turnoverTransferBaleDelivery
=
dcAverageWarehouse
.
getTransferBaleDelivery
().
intValue
();
}
if
(
dcAverageWarehouse
.
getAbroadInboundDelivery
()
!=
null
&&
dcAverageWarehouse
.
getAbroadInboundDelivery
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
turnoverAbroadInboundDelivery
=
dcAverageWarehouse
.
getAbroadInboundDelivery
().
intValue
();
}
}
//设置供应商交期天数
dcAutoTurnover
.
setSupplierDelivery
(
turnoverSupplierDelivery
);
//设置质检入库天数 最终取值
dcAutoTurnover
.
setInspectionDelivery
(
turnoverInboundDelivery
);
//设置调拨头程天数 最终取值
dcAutoTurnover
.
setTransferDelivery
(
turnoverTransferHeadDelivery
);
//设置调拨打包天数 平均取值
dcAutoTurnover
.
setTransferBaleDelivery
(
turnoverTransferBaleDelivery
);
//设置海外仓哭茹天数 最终取值
dcAutoTurnover
.
setAbroadInboundDelivery
(
turnoverAbroadInboundDelivery
);
//周转期
Integer
turnoverDays
=
turnoverSupplierDelivery
+
turnoverInboundDelivery
+
turnoverTransferHeadDelivery
+
turnoverTransferBaleDelivery
+
turnoverAbroadInboundDelivery
;
if
(
paymentBeforeDelivery
!=
null
)
{
}
}
}
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