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
694d7e27
Commit
694d7e27
authored
Aug 12, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
亚马逊广告切json从fastJson换成gson
parent
ad71f085
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
AmazonAdDownloadReportJob.java
...ain/java/com/bailuntec/job/AmazonAdDownloadReportJob.java
+14
-7
No files found.
data-base/base-sync-amazon-ad/src/main/java/com/bailuntec/job/AmazonAdDownloadReportJob.java
View file @
694d7e27
package
com
.
bailuntec
.
job
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
com.bailuntec.domain.entity.DcBaseCompanyAccount
;
import
com.bailuntec.domain.entity.DcBaseFinanceAmazonAdProduct
;
import
com.bailuntec.domain.entity.JobAmazonAdLog
;
...
...
@@ -19,6 +18,8 @@ import com.bailuntec.utils.OkHttpUtil;
import
com.bailuntec.utils.SessionUtil
;
import
com.dangdang.ddframe.job.api.ShardingContext
;
import
com.dangdang.ddframe.job.api.simple.SimpleJob
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
...
...
@@ -26,6 +27,9 @@ import okhttp3.Response;
import
org.apache.commons.beanutils.BeanUtils
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.Reader
;
import
java.lang.reflect.Type
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.List
;
...
...
@@ -73,10 +77,13 @@ public class AmazonAdDownloadReportJob implements SimpleJob {
response
=
client
.
newCall
(
request
).
execute
();
if
(
response
.
isSuccessful
())
{
gzin
=
new
GZIPInputStream
(
response
.
body
().
byteStream
());
log
.
warn
(
"开始解析账号Id为"
+
jobAmazonAdLog
.
getAccountId
()
+
"的Report----"
+
jobAmazonAdLog
.
getReportId
()
+
", 文件大小为"
+
response
.
body
().
contentLength
());
List
<
AmazonAdProduct
>
amazonAdProductList
=
JSON
.
parseObject
(
gzin
,
new
TypeReference
<
List
<
AmazonAdProduct
>>()
{
}.
getType
());
log
.
warn
(
"账号Id"
+
jobAmazonAdLog
.
getAccountId
()
+
"的Report解析完成"
);
log
.
warn
(
"开始解析账号Id为"
+
jobAmazonAdLog
.
getAccountId
()
+
"的Report----"
+
jobAmazonAdLog
.
getReportId
()
+
", 文件大小为"
+
response
.
body
().
contentLength
());
Gson
gson
=
new
Gson
();
Reader
reader
=
new
InputStreamReader
(
response
.
body
().
byteStream
());
Type
type
=
new
TypeToken
<
List
<
AmazonAdProduct
>>()
{
}.
getType
();
List
<
AmazonAdProduct
>
amazonAdProductList
=
gson
.
fromJson
(
new
InputStreamReader
(
response
.
body
().
byteStream
()),
type
);
log
.
warn
(
"账号Id"
+
jobAmazonAdLog
.
getAccountId
()
+
"的Report解析完成"
);
gzin
.
close
();
response
.
close
();
JobAmazonAdLogMapper
jobAmazonAdLogMapper
=
SessionUtil
.
getSession
().
getMapper
(
JobAmazonAdLogMapper
.
class
);
...
...
@@ -108,11 +115,11 @@ public class AmazonAdDownloadReportJob implements SimpleJob {
break
;
}
else
{
String
s
=
response
.
body
().
string
();
log
.
warn
(
"账号Id"
+
jobAmazonAdLog
.
getAccountId
()+
",第"
+
i
+
"次下载报告不成功: "
+
s
);
log
.
warn
(
"账号Id"
+
jobAmazonAdLog
.
getAccountId
()
+
",第"
+
i
+
"次下载报告不成功: "
+
s
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"账号Id"
+
jobAmazonAdLog
.
getAccountId
()+
",第"
+
i
+
"次调用获取AmazonADReportLocation错误:"
,
e
);
log
.
error
(
"账号Id"
+
jobAmazonAdLog
.
getAccountId
()
+
",第"
+
i
+
"次调用获取AmazonADReportLocation错误:"
,
e
);
}
finally
{
SessionUtil
.
closeSession
();
if
(
gzin
!=
null
)
{
...
...
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