|
|
@@ -1,7 +1,9 @@
|
|
|
package cn.com.ctop.job.bytedance.data.service.impl;
|
|
|
|
|
|
import cn.com.ctop.job.bytedance.data.entity.BytedanceCdpProject;
|
|
|
+import cn.com.ctop.job.bytedance.data.entity.BytedanceErrorLog;
|
|
|
import cn.com.ctop.job.bytedance.data.mapper.BytedanceCdpProjectMapper;
|
|
|
+import cn.com.ctop.job.bytedance.data.mapper.BytedancePromoterReportMapper;
|
|
|
import cn.com.ctop.job.bytedance.data.mapper.BytedanceRefreshTokenMapper;
|
|
|
import cn.com.ctop.job.bytedance.data.service.IBytedanceCdpProjectService;
|
|
|
import cn.com.ctop.job.bytedance.data.utils.*;
|
|
|
@@ -39,6 +41,9 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
@Autowired
|
|
|
private BytedanceRefreshTokenMapper tokenMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BytedancePromoterReportMapper promoterReportMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public List<Long> queryAllAdverIdList(String type) {
|
|
|
return bytedanceCdpProjectMapper.queryAllAdverIdList(type);
|
|
|
@@ -75,11 +80,11 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void getpromotionList(Long advertiserId, JSONArray ids, String date) {
|
|
|
- this.getpromotionListVo(advertiserId, ids, date, 1, 1);
|
|
|
+ public void getPromotionList(Long advertiserId, JSONArray ids, String date, Long errorId, Integer isLog) {
|
|
|
+ this.getPromotionListVo(advertiserId, ids, date, 1, 1, errorId, isLog);
|
|
|
}
|
|
|
|
|
|
- private void getpromotionListVo(Long advertiserId, JSONArray ids, String date, Integer page, int count) {
|
|
|
+ private void getPromotionListVo(Long advertiserId, JSONArray ids, String date, Integer page, int count, Long errorId, Integer isLog) {
|
|
|
try {
|
|
|
log.info("执行id:{}", advertiserId);
|
|
|
boolean nextPage = false;
|
|
|
@@ -126,18 +131,21 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
log.info("---账户({})广告更新成功", advertiserId);
|
|
|
}*/
|
|
|
} else {
|
|
|
- //40100请求超频
|
|
|
- if (40100 == code && count <= 5) {
|
|
|
+ //40100请求超频 (40100 == code || 40110 == code || 40130 == code) &&
|
|
|
+ if (count <= 5) {
|
|
|
Thread.sleep(800);
|
|
|
- getpromotionListVo(advertiserId, ids, date, page, count + 1);
|
|
|
+ getPromotionListVo(advertiserId, ids, date, page, count + 1, errorId, isLog);
|
|
|
} else {
|
|
|
+ insertErrorLog(isLog, advertiserId, "-", "-", "promotion_list", results);
|
|
|
log.error("获取广告列表失败(url:{}),入参:{}\n结果:{}", url, JSONObject.toJSONString(params), obj);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
if (nextPage) {
|
|
|
- getpromotionListVo(advertiserId, ids, date, page + 1, 1);
|
|
|
+ getPromotionListVo(advertiserId, ids, date, page + 1, 1, errorId, isLog);
|
|
|
+ } else if (errorId != null) {
|
|
|
+ promoterReportMapper.deleteInfoByErrorId(errorId);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -149,6 +157,7 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
entity.put("advertiser_id", advertiserId);
|
|
|
JSONObject promotionMaterials = entity.getJSONObject("promotion_materials");
|
|
|
if (!Check.isNull(promotionMaterials)) {
|
|
|
+ entity.put("external_url_material_list", promotionMaterials.getString("external_url_material_list"));
|
|
|
entity.put("playlet_series_url_list", promotionMaterials.getString("playlet_series_url_list"));
|
|
|
JSONObject miniProgramInfo = promotionMaterials.getJSONObject("mini_program_info");
|
|
|
if (!Check.isNull(miniProgramInfo)) {
|
|
|
@@ -164,12 +173,11 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void getProjectList(Long advertiserId, JSONArray ids, String type, String date) {
|
|
|
- this.getProjectListVo(advertiserId, ids, type, date, 1, 1);
|
|
|
-// this.getProjectListVo(advertiserId, "del", date, 1, 1);
|
|
|
+ public void getProjectList(Long advertiserId, JSONArray ids, String type, String date, Long errorId, Integer isLog) {
|
|
|
+ this.getProjectListVo(advertiserId, ids, type, date, 1, 1, errorId, isLog);
|
|
|
}
|
|
|
|
|
|
- private void getProjectListVo(Long advertiserId, JSONArray ids, String type, String date, Integer page, int count) {
|
|
|
+ private void getProjectListVo(Long advertiserId, JSONArray ids, String type, String date, Integer page, int count, Long errorId, Integer isLog) {
|
|
|
try {
|
|
|
boolean nextPage = false;
|
|
|
String accessToken = tokenMapper.onlyGetToken(advertiserId);
|
|
|
@@ -219,18 +227,21 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
log.info("---账户({})项目信息更新成功", advertiserId);
|
|
|
}
|
|
|
} else {
|
|
|
- //40100请求超频
|
|
|
- if (40100 == code && count <= 5) {
|
|
|
+ //40100请求超频 (40100 == code || 40110 == code || 40130 == code) &&
|
|
|
+ if (count <= 5) {
|
|
|
Thread.sleep(800);
|
|
|
- getProjectListVo(advertiserId, ids, type, date, page, count + 1);
|
|
|
+ getProjectListVo(advertiserId, ids, type, date, page, count + 1, errorId, isLog);
|
|
|
} else {
|
|
|
+ insertErrorLog(isLog, advertiserId, "-", "-", "project_list", results);
|
|
|
log.error("获取项目列表失败(url:{}),入参:{}\n结果:{}", url, JSONObject.toJSONString(params), obj);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
if (nextPage) {
|
|
|
- getProjectListVo(advertiserId, ids, type, date, page + 1, 1);
|
|
|
+ getProjectListVo(advertiserId, ids, type, date, page + 1, 1, errorId, isLog);
|
|
|
+ } else if (errorId != null) {
|
|
|
+ promoterReportMapper.deleteInfoByErrorId(errorId);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -543,7 +554,7 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
|
if (nextPage) {
|
|
|
rebackadqCreativesVo(accountId, accessToken, startDate, endDate, page + 1, isDeleted, 1);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
log.info("账户({})获取动态创意完成", accountId);
|
|
|
}
|
|
|
}
|
|
|
@@ -651,7 +662,7 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
List<String> imageIds = new ArrayList<>();
|
|
|
List<String> videoIds = new ArrayList<>();
|
|
|
JSONArray videoArr = creativeComponents.getJSONArray("video");
|
|
|
- if(!Check.isNull(videoArr)) {
|
|
|
+ if (!Check.isNull(videoArr)) {
|
|
|
for (int i = 0; i < videoArr.size(); i++) {
|
|
|
JSONObject obj = videoArr.getJSONObject(i);
|
|
|
JSONObject value = obj.getJSONObject("value");
|
|
|
@@ -662,7 +673,7 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
|
}
|
|
|
JSONArray imageArr = creativeComponents.getJSONArray("image");
|
|
|
- if(!Check.isNull(imageArr)) {
|
|
|
+ if (!Check.isNull(imageArr)) {
|
|
|
for (int i = 0; i < imageArr.size(); i++) {
|
|
|
JSONObject obj = imageArr.getJSONObject(i);
|
|
|
JSONObject value = obj.getJSONObject("value");
|
|
|
@@ -673,7 +684,7 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
|
}
|
|
|
JSONArray imageListArr = creativeComponents.getJSONArray("image_list");
|
|
|
- if(!Check.isNull(imageListArr)) {
|
|
|
+ if (!Check.isNull(imageListArr)) {
|
|
|
for (int i = 0; i < imageListArr.size(); i++) {
|
|
|
JSONObject obj = imageListArr.getJSONObject(i);
|
|
|
JSONObject value = obj.getJSONObject("value");
|
|
|
@@ -691,10 +702,10 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (!Check.isNull(videoIds)){
|
|
|
+ if (!Check.isNull(videoIds)) {
|
|
|
object.put("video_list", StringUtils.join(videoIds, ","));
|
|
|
}
|
|
|
- if (!Check.isNull(imageIds)){
|
|
|
+ if (!Check.isNull(imageIds)) {
|
|
|
object.put("image_list", StringUtils.join(imageIds, ","));
|
|
|
}
|
|
|
|
|
|
@@ -766,4 +777,17 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void insertErrorLog(Integer isLog, Long advertiserId, String startDate, String endDate, String dataDimension, String msg) {
|
|
|
+ if (isLog != null && 1 == isLog) {
|
|
|
+ BytedanceErrorLog errorInfo = new BytedanceErrorLog();
|
|
|
+ errorInfo.setAdvertiserId(advertiserId);
|
|
|
+ errorInfo.setStartDate(startDate);
|
|
|
+ errorInfo.setEndDate(endDate);
|
|
|
+ errorInfo.setMsg(msg);
|
|
|
+ errorInfo.setDataDimension(dataDimension);
|
|
|
+ errorInfo.setDataType("daily");
|
|
|
+ promoterReportMapper.replaceErrorInfo(errorInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|