Commit 78465be7 by wutong

再试一次OOM

parent b2ec4dfb
......@@ -11,7 +11,10 @@ import com.bailuntec.domain.enumerate.CurrencyType;
import com.bailuntec.domain.example.DcBaseCompanyAccountExample;
import com.bailuntec.domain.example.DcBaseFinanceAmazonAdProductExample;
import com.bailuntec.domain.example.JobAccountLogExample;
import com.bailuntec.domain.pojo.*;
import com.bailuntec.domain.pojo.AmazonAdAuth;
import com.bailuntec.domain.pojo.AmazonAdProduct;
import com.bailuntec.domain.pojo.AmazonAdReportLocationResult;
import com.bailuntec.domain.pojo.AmazonAdSuccessResult;
import com.bailuntec.mapper.DcBaseCompanyAccountMapper;
import com.bailuntec.mapper.DcBaseFinanceAmazonAdProductMapper;
import com.bailuntec.mapper.JobAccountLogMapper;
......@@ -27,10 +30,7 @@ import okhttp3.*;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
......@@ -162,9 +162,9 @@ public class AmazonAdProductJob extends PointJob {
return propertiesUtil.getPropertyAsString(siteUrl) + propertiesUtil.getPropertyAsString("GET_PRODUCT_ADS_REPORT_LOCATION");
}
private void handleReport(String reportLocationUrl, JobAccountLog jobAccountLog, AmazonAdAuth amazonAdAuth) {
private void handleReport(String reportLocationUrl, JobAccountLog jobAccountLog, AmazonAdAuth amazonAdAuth){
Response response = null;
try{
GZIPInputStream gzin = null;
Request request = new Request.Builder()
.url(reportLocationUrl)
.addHeader("Authorization", amazonAdAuth.getAccessToken())
......@@ -172,12 +172,11 @@ public class AmazonAdProductJob extends PointJob {
.addHeader("Amazon-Advertising-API-Scope", amazonAdAuth.getProfileId())
.addHeader("Content-Type", "application/json")
.build();
try{
response = client.newCall(request).execute();
if (response.isSuccessful()) {
GZIPInputStream gzin = null;
try {
gzin = new GZIPInputStream(response.body().byteStream());
List<AmazonAdProduct> amazonAdProductList = JSON.parseObject(gzin,new TypeReference<List<AmazonAdProduct>>(){}.getType());
List<AmazonAdProduct> amazonAdProductList = JSON.parseObject(gzin, new TypeReference<List<AmazonAdProduct>>(){}.getType());
gzin.close();
response.close();
if (amazonAdProductList != null && amazonAdProductList.size() > 0) {
......@@ -201,14 +200,6 @@ public class AmazonAdProductJob extends PointJob {
}
amazonAdProductList = null;
}
} catch (Exception e) {
e.printStackTrace();
jobAccountLog.setMessage("解析Gzip格式的Report错误:" + ExceptionUtil.transform(e));
} finally {
if(gzin != null) {
gzin.close();
}
}
/*
* 今天只能拿到昨天的广告费, 不然不完整
* 如果开始时间比今天0点晚, 就设为22点(或者你随便减几个小时都可以)
......@@ -225,8 +216,17 @@ public class AmazonAdProductJob extends PointJob {
}
}catch (Exception e){
e.printStackTrace();
log.error("调用获取AmazonADReportLocation错误:", e);
jobAccountLog.setMessage("调用获取AmazonADReportLocation错误:" + ExceptionUtil.transform(e));
} finally {
if(gzin != null) {
try {
gzin.close();
} catch (IOException e) {
e.printStackTrace();
log.error("gzin关闭错误:", e);
}
}
if (response != null) {
response.close();
}
......
......@@ -616,6 +616,6 @@
<select id="getListByPage" resultType="com.bailuntec.domain.entity.JobAccountLog">
SELECT t2.message,t2.id,t1.company_id, t1.account_id, t2.job_name,t2.page_index,t2.page_size,t2.type,t2.interval_time,t2.start_time,t2.end_time, t2.task_ids FROM
(SELECT * FROM dc_base_company_account WHERE 1=1 and platform_id=15) t1 LEFT JOIN job_account_log t2 on t1.account_id = t2.account_id WHERE t2.message != '授权信息为空'order by id limit 1,24
(SELECT * FROM dc_base_company_account WHERE 1=1 and platform_id=15) t1 LEFT JOIN job_account_log t2 on t1.account_id = t2.account_id WHERE t2.message != '授权信息为空'order by id limit 1,2
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment