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
bltdc
dc-java
Commits
094a48b1
Commit
094a48b1
authored
Aug 31, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
广告!!!!!
parent
4e5c0351
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
145 additions
and
26 deletions
+145
-26
AmazonURI.java
...ad/src/main/java/com/bailuntec/domain/pojo/AmazonURI.java
+43
-0
AmazonAdGenerateReportIdJob.java
...n/java/com/bailuntec/job/AmazonAdGenerateReportIdJob.java
+72
-0
DcAutoSalesForecastStageConfigMapper.xml
...bailuntec/mapper/DcAutoSalesForecastStageConfigMapper.xml
+1
-1
JobAmazonAdLogMapper.xml
...c/main/java/com/bailuntec/mapper/JobAmazonAdLogMapper.xml
+29
-25
No files found.
data-base/base-sync-amazon-ad/src/main/java/com/bailuntec/domain/pojo/AmazonURI.java
0 → 100644
View file @
094a48b1
package
com
.
bailuntec
.
domain
.
pojo
;
import
java.net.URI
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/8/24 10:29 上午
*/
public
class
AmazonURI
{
public
static
final
URI
NA_AMAZON_AD_URL
=
URI
.
create
(
"https://advertising-api.amazon.com"
);
public
static
final
URI
EU_AMAZON_AD_URL
=
URI
.
create
(
"https://advertising-api-eu.amazon.com"
);
public
static
final
URI
FE_AMAZON_AD_URL
=
URI
.
create
(
"https://advertising-api-fe.amazon.com"
);
public
static
final
Map
<
String
,
URI
>
amazonUriMap
=
new
HashMap
<>();
public
static
URI
getAmazonAdSiteUri
(
String
siteEn
)
{
switch
(
siteEn
.
toUpperCase
())
{
case
"UK"
:
case
"FR"
:
case
"IT"
:
case
"ES"
:
case
"DE"
:
return
EU_AMAZON_AD_URL
;
case
"AU"
:
case
"JP"
:
case
"IN"
:
return
FE_AMAZON_AD_URL
;
case
"US"
:
case
"CA"
:
case
"MX"
:
default
:
return
NA_AMAZON_AD_URL
;
}
}
}
data-base/base-sync-amazon-ad/src/main/java/com/bailuntec/job/AmazonAdGenerateReportIdJob.java
View file @
094a48b1
...
...
@@ -8,6 +8,7 @@ import com.bailuntec.domain.example.DcBaseCompanyAccountExample;
import
com.bailuntec.domain.example.JobAmazonAdLogExample
;
import
com.bailuntec.domain.pojo.AmazonAdAuth
;
import
com.bailuntec.domain.pojo.AmazonAdSuccessResult
;
import
com.bailuntec.domain.pojo.AmazonURI
;
import
com.bailuntec.mapper.DcBaseCompanyAccountMapper
;
import
com.bailuntec.mapper.JobAmazonAdLogMapper
;
import
com.bailuntec.utils.OkHttpUtil
;
...
...
@@ -48,7 +49,12 @@ public class AmazonAdGenerateReportIdJob implements SimpleJob {
// .stream()
// .filter(dcBaseCompanyAccount -> dcBaseCompanyAccount.getAccountId() == 671)
.
forEach
(
dcBaseCompanyAccount
->
{
//productAds
try
{
// LocalDateTime reportDate = LocalDateTime.of(2020, 8, 30, 0, 0);
LocalDateTime
reportDate
=
LocalDateTime
.
now
().
minusDays
(
1
).
minusHours
(
12
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"reportDate"
,
reportDate
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyyMMdd"
)));
...
...
@@ -78,7 +84,9 @@ public class AmazonAdGenerateReportIdJob implements SimpleJob {
JobAmazonAdLog
jobAmazonAdLog
=
jobAmazonAdLogMapper
.
selectOneByExample
(
JobAmazonAdLogExample
.
newAndCreateCriteria
()
.
andAccountIdEqualTo
(
dcBaseCompanyAccount
.
getAccountId
())
.
andCompanyIdEqualTo
(
dcBaseCompanyAccount
.
getCompanyId
())
.
andReportDateEqualTo
(
reportDate
.
toLocalDate
())
.
andTypeEqualTo
(
1
)
.
example
());
if
(
jobAmazonAdLog
==
null
)
{
...
...
@@ -113,6 +121,70 @@ public class AmazonAdGenerateReportIdJob implements SimpleJob {
log
.
error
(
ex
.
getMessage
(),
ex
);
log
.
error
(
"帐号id :{} 下载报告失败"
,
dcBaseCompanyAccount
.
getAccountId
());
}
//display
try
{
AmazonAdAuth
amazonAdAuth
=
JSON
.
parseObject
(
dcBaseCompanyAccount
.
getAmazonAdAuthJson
(),
AmazonAdAuth
.
class
);
LocalDateTime
reportDate
=
LocalDateTime
.
now
().
minusDays
(
1
).
minusHours
(
12
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"reportDate"
,
reportDate
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyyMMdd"
)));
jsonObject
.
put
(
"metrics"
,
"campaignName,campaignId,impressions,adGroupId,adGroupName,asin,sku,adId,clicks,cost,currency,attributedConversions1d,attributedConversions7d,attributedConversions14d,attributedConversions30d,attributedConversions1dSameSKU,attributedConversions7dSameSKU,attributedConversions14dSameSKU,attributedConversions30dSameSKU,attributedUnitsOrdered1d,attributedUnitsOrdered7d,attributedUnitsOrdered14d,attributedUnitsOrdered30d,attributedSales1d,attributedSales7d,attributedSales14d,attributedSales30d,attributedSales1dSameSKU,attributedSales7dSameSKU,attributedSales14dSameSKU,attributedSales30dSameSKU"
);
;
MediaType
mediaType
=
MediaType
.
parse
(
"application/json"
);
Response
response
;
RequestBody
body
=
RequestBody
.
create
(
mediaType
,
jsonObject
.
toJSONString
());
Request
request
=
new
Request
.
Builder
()
.
url
(
AmazonURI
.
getAmazonAdSiteUri
(
dcBaseCompanyAccount
.
getSiteEn
()).
toString
()
+
"/sd/productAds/report"
)
.
post
(
body
)
.
addHeader
(
"Authorization"
,
amazonAdAuth
.
getAccessToken
())
.
addHeader
(
"Amazon-Advertising-API-ClientId"
,
amazonAdAuth
.
getClientId
())
.
addHeader
(
"Amazon-Advertising-API-Scope"
,
amazonAdAuth
.
getProfileId
())
.
addHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
response
=
client
.
newCall
(
request
).
execute
();
String
string
=
response
.
body
().
string
();
if
(
response
.
isSuccessful
())
{
AmazonAdSuccessResult
reportResp
=
JSON
.
parseObject
(
string
,
AmazonAdSuccessResult
.
class
);
JobAmazonAdLog
jobAmazonAdLog
=
jobAmazonAdLogMapper
.
selectOneByExample
(
JobAmazonAdLogExample
.
newAndCreateCriteria
()
.
andAccountIdEqualTo
(
dcBaseCompanyAccount
.
getAccountId
())
.
andCompanyIdEqualTo
(
dcBaseCompanyAccount
.
getCompanyId
())
.
andReportDateEqualTo
(
reportDate
.
toLocalDate
())
.
andTypeEqualTo
(
4
)
.
example
());
if
(
jobAmazonAdLog
==
null
)
{
jobAmazonAdLog
=
new
JobAmazonAdLog
();
jobAmazonAdLog
.
setAccountId
(
dcBaseCompanyAccount
.
getAccountId
());
jobAmazonAdLog
.
setCompanyId
(
dcBaseCompanyAccount
.
getCompanyId
());
jobAmazonAdLog
.
setBjCreate
(
LocalDateTime
.
now
());
jobAmazonAdLog
.
setBjModified
(
LocalDateTime
.
now
());
jobAmazonAdLog
.
setReportDate
(
reportDate
.
toLocalDate
());
jobAmazonAdLog
.
setType
(
4
);
jobAmazonAdLog
.
setSiteEn
(
dcBaseCompanyAccount
.
getSiteEn
());
jobAmazonAdLog
.
setReportId
(
reportResp
.
getReportId
());
jobAmazonAdLog
.
setStatus
(
false
);
jobAmazonAdLogMapper
.
insert
(
jobAmazonAdLog
);
}
else
{
jobAmazonAdLog
.
setStatus
(
false
);
jobAmazonAdLog
.
setReportId
(
reportResp
.
getReportId
());
jobAmazonAdLogMapper
.
updateByPrimaryKeySelective
(
jobAmazonAdLog
);
}
}
else
{
log
.
error
(
JSON
.
toJSONString
(
response
));
throw
new
RuntimeException
(
"生成报告失败"
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
});
}
...
...
data-common/src/main/java/com/bailuntec/mapper/DcAutoSalesForecastStageConfigMapper.xml
View file @
094a48b1
...
...
@@ -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.ware
ListenerContainer
house_code or length(trim(t5.warehouse_code)) = 0)
and (t6.warehouse_code = t5.warehouse_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)
...
...
data-common/src/main/java/com/bailuntec/mapper/JobAmazonAdLogMapper.xml
View file @
094a48b1
...
...
@@ -6,16 +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"
/>
<result
column=
"type"
jdbcType=
"INTEGER"
property=
"type"
/>
<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"
>
<!--
...
...
@@ -39,7 +39,8 @@
</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,7 +73,8 @@
</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>
...
...
@@ -91,7 +93,8 @@
id, account_id, report_id, report_date, status, bj_create, bj_modified, site_en,
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.
...
...
@@ -100,10 +103,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}
...
...
@@ -123,7 +126,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>
...
...
@@ -142,7 +145,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"
>
...
...
@@ -230,14 +233,15 @@
</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"
>
...
...
@@ -279,7 +283,7 @@
</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"
>
...
...
@@ -299,7 +303,7 @@
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"
>
...
...
@@ -488,17 +492,18 @@
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}
...
...
@@ -514,6 +519,5 @@
and bj_create
<
#{localDateTime}
and id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
order by bj_modified desc
limit 60
</select>
</mapper>
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