|
@@ -711,19 +711,25 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
|
/////////////////////////////////////////////////////////\
|
|
|
//素材报表
|
|
|
@Override
|
|
|
- public int bytedanceMaterialReportRetry(CtopOauthToken token, String startDate, String endDate) {
|
|
|
+ public int bytedanceMaterialReportRetry(Integer type, CtopOauthToken token, String startDate, String endDate) {
|
|
|
Long accountId = token.getAccountId();
|
|
|
- // log.info("头条素材报表当前accountId为:" + accountId);
|
|
|
+ log.info("头条素材报表重试开始 当前accountId:{} {}~{},type:{}" , accountId, startDate,endDate,type);
|
|
|
Integer page = 1;
|
|
|
Integer pageSize = 100;
|
|
|
- int code = bytedanceMaterialReportByPage(page, pageSize, token, accountId, startDate, endDate);
|
|
|
+ Integer code = null;
|
|
|
+ if(type == 1){
|
|
|
+ code = bytedanceMaterialReportByPage(page, pageSize, token, accountId, startDate, endDate);
|
|
|
+
|
|
|
+ }else if(type == 2){
|
|
|
+ code = bytedanceVideoMaterialReportByPage(page, pageSize, token, accountId, startDate, endDate);
|
|
|
+ }
|
|
|
|
|
|
BytedanceReportMaterialRetry retry = new BytedanceReportMaterialRetry();
|
|
|
retry.setAccountId(accountId);
|
|
|
retry.setStartDate(startDate);
|
|
|
retry.setEndDate(endDate);
|
|
|
retry.setStatusCode(code);
|
|
|
- retry.setType(1);
|
|
|
+ retry.setType(type);
|
|
|
if (code != 200 && code != 1) {
|
|
|
retry.setStatus(0);
|
|
|
bytedanceReportMaterialDailyMapper.replaceMaterialRetry(retry);
|
|
@@ -731,13 +737,14 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
|
retry.setStatus(1);
|
|
|
bytedanceReportMaterialDailyMapper.replaceMaterialRetry(retry);
|
|
|
}
|
|
|
+ log.info("头条素材报表重试结束 当前accountId:{} {}~{},type:{},code:{}" , accountId, startDate,endDate,type,code);
|
|
|
return code;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int bytedanceMaterialReport(CtopOauthToken token, String startDate, String endDate) {
|
|
|
Long accountId = token.getAccountId();
|
|
|
- log.info("头条素材报表当前accountId为:" + accountId);
|
|
|
+ log.info("头条素材报表开始 当前accountId:{} {}~{}" , accountId, startDate,endDate);
|
|
|
Integer page = 1;
|
|
|
Integer pageSize = 100;
|
|
|
int code = bytedanceMaterialReportByPage(page, pageSize, token, accountId, startDate, endDate);
|
|
@@ -751,7 +758,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
|
retry.setType(1);
|
|
|
bytedanceReportMaterialDailyMapper.replaceMaterialRetry(retry);
|
|
|
}
|
|
|
- log.info("头条素材报表当前accountId为:{} {}~{}" , accountId, startDate,endDate);
|
|
|
+ log.info("头条素材报表结束 当前accountId为:{} {}~{}" , accountId, startDate,endDate);
|
|
|
return code;
|
|
|
}
|
|
|
|
|
@@ -777,8 +784,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
|
|
|
|
JSONObject json = HttpUtils.bytedanceGetRequest(access_token, open_api_domain + path, JSONObject.parseObject(JSONObject.toJSONString(data)));
|
|
|
if (json == null) {
|
|
|
- //insertMaterialRetry(accountId, startDate, endDate, -2);
|
|
|
- log.error("请求有误:" + JSONObject.toJSONString(data));
|
|
|
+ log.error("返回为空,请求有误:" + JSONObject.toJSONString(data));
|
|
|
return -2;
|
|
|
}
|
|
|
|
|
@@ -787,13 +793,13 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
|
if (!Check.isNull(json)) {
|
|
|
Integer code = json.getInteger("code");
|
|
|
if (code != 0) {
|
|
|
- log.error("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + ";返回json为:" + JSONObject.toJSONString(data));
|
|
|
+ log.error("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + ";返回json为" + json + "请求为:" + JSONObject.toJSONString(data));
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
JSONObject jsonData = json.getJSONObject("data");
|
|
|
if (Check.isNull(jsonData)) {
|
|
|
- log.error("获取任务列表返回信息data内容为空,头条accountId:" + accountId + ";返回json为:" + JSONObject.toJSONString(data));
|
|
|
+ log.error("获取任务列表返回信息data内容为空,头条accountId:" + accountId + ";返回json为" + json + "请求为:" + JSONObject.toJSONString(data));
|
|
|
return -1;
|
|
|
}
|
|
|
JSONObject pageInfo = jsonData.getJSONObject("page_info");
|
|
@@ -803,7 +809,6 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
|
JSONArray jsonArrayay = jsonData.getJSONArray("list");
|
|
|
if (jsonArrayay.size() == 0) {
|
|
|
log.info("accountId:" + accountId + ";没有数据。总页数为:" + totalPage + "当前页数为:" + currentPage);
|
|
|
- //returnCode = 1;
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -915,19 +920,15 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
|
bytedanceReportMaterialDailyList.add(daily);
|
|
|
}
|
|
|
}
|
|
|
- //Long insertStartTime = System.currentTimeMillis();
|
|
|
bytedanceReportMaterialDailyMapper.replaceIntoBatch(bytedanceReportMaterialDailyList);
|
|
|
- //Long insertEndTime = System.currentTimeMillis();
|
|
|
- //log.info("头条获取素材报表插入数据结束,执行耗时:{}秒", (insertEndTime - insertStartTime) / 1000);
|
|
|
if (currentPage >= totalPage) {
|
|
|
- //log.info("accountId:" + accountId + "数据同步完成,开始时间:" + startDate + ",结束时间:"+ endDate);
|
|
|
+ log.info("头条素材报表当前accountId为:{} {}~{},接口数据拉取成功" , accountId, startDate,endDate);
|
|
|
return 1;
|
|
|
} else {
|
|
|
int pageCode = bytedanceMaterialReportByPage(page + 1, pageSize, token, accountId, startDate, endDate);
|
|
|
return pageCode;
|
|
|
}
|
|
|
} else {
|
|
|
- //returnCode = -1;
|
|
|
log.error("服务器返回为空,json:" + JSONObject.toJSONString(data));
|
|
|
return -1;
|
|
|
}
|
|
@@ -992,7 +993,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
|
|
|
|
JSONObject json = HttpUtils.bytedanceGetRequest(access_token, open_api_domain + path, JSONObject.parseObject(JSONObject.toJSONString(data)));
|
|
|
if (json == null) {
|
|
|
- log.error("请求有误:" + JSONObject.toJSONString(data));
|
|
|
+ log.error("返回为空,请求有误:" + JSONObject.toJSONString(data));
|
|
|
return -2;
|
|
|
}
|
|
|
|
|
@@ -1001,13 +1002,13 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
|
if (!Check.isNull(json)) {
|
|
|
Integer code = json.getInteger("code");
|
|
|
if (code != 0) {
|
|
|
- log.error("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + ";返回json为:" + JSONObject.toJSONString(data));
|
|
|
+ log.error("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + ";返回json为:" + json + "请求为:" + JSONObject.toJSONString(data));
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
JSONObject jsonData = json.getJSONObject("data");
|
|
|
if (Check.isNull(jsonData)) {
|
|
|
- log.error("获取任务列表返回信息data内容为空,头条accountId:" + accountId + ";返回json为:" + JSONObject.toJSONString(data));
|
|
|
+ log.error("获取任务列表返回信息data内容为空,头条accountId:" + accountId + ";返回json为:" + json + "请求为:" + JSONObject.toJSONString(data));
|
|
|
return -1;
|
|
|
}
|
|
|
JSONObject pageInfo = jsonData.getJSONObject("page_info");
|
|
@@ -1030,18 +1031,18 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
|
}
|
|
|
bytedanceReportMaterialDailyMapper.replaceIntoVideoMaterialBatch(bytedanceReportVideoMaterialDailyList);
|
|
|
if (currentPage >= totalPage) {
|
|
|
+ log.info("头条视频素材报表当前accountId为:{} {}~{},接口数据拉取成功" , accountId, startDate,endDate);
|
|
|
return 1;
|
|
|
} else {
|
|
|
- int pageCode = bytedanceVideoMaterialReportByPage(page + 1, pageSize, token, accountId, startDate, endDate);
|
|
|
- return pageCode;
|
|
|
+ return bytedanceVideoMaterialReportByPage(page + 1, pageSize, token, accountId, startDate, endDate);
|
|
|
}
|
|
|
} else {
|
|
|
- log.error("服务器返回为空,json:" + JSONObject.toJSONString(data));
|
|
|
+ log.error("头条视频素材报表服务器返回为空,accountId:" + accountId + ",json:" + json + "请求为:" + JSONObject.toJSONString(data));
|
|
|
return -1;
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- log.error("头条报表其他错误,accountId:" + accountId + ",json:" + JSONObject.toJSONString(data));
|
|
|
+ log.error("头条视频素材报表其他错误,accountId:" + accountId + ",json:" + json + "请求为:" + JSONObject.toJSONString(data));
|
|
|
returnCode = -3;
|
|
|
}
|
|
|
return returnCode;
|