Commit 34a59135 by wutong

调整try catch代码范围

parent 8866309e
...@@ -2,18 +2,18 @@ package com.bailuntec.job; ...@@ -2,18 +2,18 @@ package com.bailuntec.job;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.bailuntec.domain.enumerate.CurrencyType;
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.domain.entity.DcBaseCompanyAccount; import com.bailuntec.domain.entity.DcBaseCompanyAccount;
import com.bailuntec.domain.entity.DcBaseFinanceAmazonAdProduct; import com.bailuntec.domain.entity.DcBaseFinanceAmazonAdProduct;
import com.bailuntec.domain.entity.JobAccountLog; import com.bailuntec.domain.entity.JobAccountLog;
import com.bailuntec.domain.entity.JobPointLog; import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.domain.enumerate.CurrencyType;
import com.bailuntec.domain.example.DcBaseCompanyAccountExample; import com.bailuntec.domain.example.DcBaseCompanyAccountExample;
import com.bailuntec.domain.example.DcBaseFinanceAmazonAdProductExample; import com.bailuntec.domain.example.DcBaseFinanceAmazonAdProductExample;
import com.bailuntec.domain.example.JobAccountLogExample; import com.bailuntec.domain.example.JobAccountLogExample;
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.DcBaseCompanyAccountMapper;
import com.bailuntec.mapper.DcBaseFinanceAmazonAdProductMapper; import com.bailuntec.mapper.DcBaseFinanceAmazonAdProductMapper;
import com.bailuntec.mapper.JobAccountLogMapper; import com.bailuntec.mapper.JobAccountLogMapper;
...@@ -32,7 +32,6 @@ import org.apache.commons.lang3.StringUtils; ...@@ -32,7 +32,6 @@ import org.apache.commons.lang3.StringUtils;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -175,12 +174,16 @@ public class AmazonAdProductJob extends PointJob { ...@@ -175,12 +174,16 @@ public class AmazonAdProductJob extends PointJob {
.build(); .build();
response = client.newCall(request).execute(); response = client.newCall(request).execute();
if (response.isSuccessful()) { if (response.isSuccessful()) {
GZIPInputStream gzin = new GZIPInputStream(response.body().byteStream()); GZIPInputStream gzin = null;
InputStreamReader isr = new InputStreamReader(gzin, "utf8"); InputStreamReader isr = null;
BufferedReader bufferedReader = new BufferedReader(isr); BufferedReader bufferedReader = null;
try {
gzin = new GZIPInputStream(response.body().byteStream());
isr = new InputStreamReader(gzin, "utf8");
bufferedReader = new BufferedReader(isr);
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
String str = null; String str = null;
try {
while ((str = bufferedReader.readLine()) != null) { while ((str = bufferedReader.readLine()) != null) {
sb.append(str); sb.append(str);
} }
...@@ -209,10 +212,16 @@ public class AmazonAdProductJob extends PointJob { ...@@ -209,10 +212,16 @@ public class AmazonAdProductJob extends PointJob {
e.printStackTrace(); e.printStackTrace();
jobAccountLog.setMessage("解析Gzip格式的Report错误:" + ExceptionUtil.transform(e)); jobAccountLog.setMessage("解析Gzip格式的Report错误:" + ExceptionUtil.transform(e));
} finally { } finally {
if(bufferedReader != null) {
bufferedReader.close(); bufferedReader.close();
}
if(isr != null) {
isr.close(); isr.close();
}
if(gzin != null) {
gzin.close(); gzin.close();
} }
}
/* /*
* 今天只能拿到昨天的广告费, 不然不完整 * 今天只能拿到昨天的广告费, 不然不完整
* 如果开始时间比今天0点晚, 就设为22点(或者你随便减几个小时都可以) * 如果开始时间比今天0点晚, 就设为22点(或者你随便减几个小时都可以)
......
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