|
@@ -4,11 +4,7 @@ import cn.com.ctop.job.bytedance.data.entity.BytedanceCdpProject;
|
|
|
import cn.com.ctop.job.bytedance.data.mapper.BytedanceCdpProjectMapper;
|
|
import cn.com.ctop.job.bytedance.data.mapper.BytedanceCdpProjectMapper;
|
|
|
import cn.com.ctop.job.bytedance.data.mapper.BytedanceRefreshTokenMapper;
|
|
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.service.IBytedanceCdpProjectService;
|
|
|
-import cn.com.ctop.job.bytedance.data.utils.Check;
|
|
|
|
|
-import cn.com.ctop.job.bytedance.data.utils.DateUtils;
|
|
|
|
|
-import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
|
|
|
|
|
-import cn.com.ctop.job.bytedance.data.utils.Okhttp3Utils;
|
|
|
|
|
-import cn.com.ctop.job.bytedance.data.utils.RandomStringGenerator;
|
|
|
|
|
|
|
+import cn.com.ctop.job.bytedance.data.utils.*;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -77,11 +73,11 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void getpromotionList(Long advertiserId, String date) {
|
|
|
|
|
- this.getpromotionListVo(advertiserId, date, 1, 1);
|
|
|
|
|
|
|
+ public void getpromotionList(Long advertiserId, JSONArray ids, String date) {
|
|
|
|
|
+ this.getpromotionListVo(advertiserId, ids, date, 1, 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void getpromotionListVo(Long advertiserId, String date, Integer page, int count) {
|
|
|
|
|
|
|
+ private void getpromotionListVo(Long advertiserId, JSONArray ids, String date, Integer page, int count) {
|
|
|
try {
|
|
try {
|
|
|
log.info("执行id:{}", advertiserId);
|
|
log.info("执行id:{}", advertiserId);
|
|
|
boolean nextPage = false;
|
|
boolean nextPage = false;
|
|
@@ -97,6 +93,9 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
filtering.put("promotion_modify_time", date);
|
|
filtering.put("promotion_modify_time", date);
|
|
|
}
|
|
}
|
|
|
filtering.put("status_first", "PROMOTION_STATUS_ALL");
|
|
filtering.put("status_first", "PROMOTION_STATUS_ALL");
|
|
|
|
|
+ if (!Check.isNull(ids)) {
|
|
|
|
|
+ filtering.put("ids", ids);
|
|
|
|
|
+ }
|
|
|
params.put("filtering", filtering);
|
|
params.put("filtering", filtering);
|
|
|
params.put("page", page);
|
|
params.put("page", page);
|
|
|
params.put("page_size", 20);//最大20
|
|
params.put("page_size", 20);//最大20
|
|
@@ -116,11 +115,11 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
checkPromotionInfo(array.getJSONObject(i), advertiserId);
|
|
checkPromotionInfo(array.getJSONObject(i), advertiserId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!Check.isNull(array)){
|
|
|
|
|
|
|
+ if (!Check.isNull(array)) {
|
|
|
try {
|
|
try {
|
|
|
bytedanceCdpProjectMapper.replaceBytedancePromotionListSD(array);
|
|
bytedanceCdpProjectMapper.replaceBytedancePromotionListSD(array);
|
|
|
- }catch (Exception e){
|
|
|
|
|
- log.error("",e);
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("", e);
|
|
|
}
|
|
}
|
|
|
if (bytedanceCdpProjectMapper.replaceBytedancePromotionList(array) > 0)
|
|
if (bytedanceCdpProjectMapper.replaceBytedancePromotionList(array) > 0)
|
|
|
log.info("---账户({})广告更新成功", advertiserId);
|
|
log.info("---账户({})广告更新成功", advertiserId);
|
|
@@ -129,14 +128,14 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
//40100请求超频
|
|
//40100请求超频
|
|
|
if (40100 == code && count <= 5) {
|
|
if (40100 == code && count <= 5) {
|
|
|
Thread.sleep(800);
|
|
Thread.sleep(800);
|
|
|
- getpromotionListVo(advertiserId, date, page, count + 1);
|
|
|
|
|
|
|
+ getpromotionListVo(advertiserId, ids, date, page, count + 1);
|
|
|
} else {
|
|
} else {
|
|
|
log.error("获取广告列表失败(url:{}),入参:{}\n结果:{}", url, JSONObject.toJSONString(params), obj);
|
|
log.error("获取广告列表失败(url:{}),入参:{}\n结果:{}", url, JSONObject.toJSONString(params), obj);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (nextPage) {
|
|
if (nextPage) {
|
|
|
- getpromotionListVo(advertiserId, date, page + 1, 1);
|
|
|
|
|
|
|
+ getpromotionListVo(advertiserId, ids, date, page + 1, 1);
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -159,13 +158,14 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void getProjectList(Long advertiserId, String date) {
|
|
|
|
|
- this.getProjectListVo(advertiserId, null, date, 1, 1);
|
|
|
|
|
|
|
+ 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);
|
|
// this.getProjectListVo(advertiserId, "del", date, 1, 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void getProjectListVo(Long advertiserId, String type, String date, Integer page, int count) {
|
|
|
|
|
|
|
+ private void getProjectListVo(Long advertiserId, JSONArray ids, String type, String date, Integer page, int count) {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ System.out.println("advertiserId:" + advertiserId);
|
|
|
boolean nextPage = false;
|
|
boolean nextPage = false;
|
|
|
String accessToken = tokenMapper.onlyGetToken(advertiserId);
|
|
String accessToken = tokenMapper.onlyGetToken(advertiserId);
|
|
|
if (Check.isNull(accessToken)) {
|
|
if (Check.isNull(accessToken)) {
|
|
@@ -183,11 +183,15 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
filtering.put("project_modify_time", date);
|
|
filtering.put("project_modify_time", date);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (!Check.isNull(ids)) {
|
|
|
|
|
+ filtering.put("ids", ids);
|
|
|
|
|
+ }
|
|
|
params.put("filtering", filtering);
|
|
params.put("filtering", filtering);
|
|
|
params.put("page", page);
|
|
params.put("page", page);
|
|
|
params.put("page_size", 100);//最大100
|
|
params.put("page_size", 100);//最大100
|
|
|
String url = "https://api.oceanengine.com/open_api/v3.0/project/list/";
|
|
String url = "https://api.oceanengine.com/open_api/v3.0/project/list/";
|
|
|
String results = HttpUtils.httpGet(url, params, HttpUtils.postMHeaders(accessToken));
|
|
String results = HttpUtils.httpGet(url, params, HttpUtils.postMHeaders(accessToken));
|
|
|
|
|
+ System.out.println(results);
|
|
|
JSONObject obj = JSONObject.parseObject(results);
|
|
JSONObject obj = JSONObject.parseObject(results);
|
|
|
if (!Check.isNull(obj)) {
|
|
if (!Check.isNull(obj)) {
|
|
|
Integer code = obj.getInteger("code");
|
|
Integer code = obj.getInteger("code");
|
|
@@ -203,11 +207,12 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
BytedanceCdpProject advertiserToolsSite = new BytedanceCdpProject(array.getJSONObject(i));
|
|
BytedanceCdpProject advertiserToolsSite = new BytedanceCdpProject(array.getJSONObject(i));
|
|
|
projectList.add(advertiserToolsSite);
|
|
projectList.add(advertiserToolsSite);
|
|
|
}
|
|
}
|
|
|
- if (!Check.isNull(projectList)){
|
|
|
|
|
|
|
+ if (!Check.isNull(projectList)) {
|
|
|
|
|
+ System.out.println(projectList);
|
|
|
try {
|
|
try {
|
|
|
bytedanceCdpProjectMapper.replaceBytedanceCdpProjectListSD(projectList);
|
|
bytedanceCdpProjectMapper.replaceBytedanceCdpProjectListSD(projectList);
|
|
|
- }catch (Exception e) {
|
|
|
|
|
- log.error("replaceBytedanceCdpProjectListSD",e);
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("replaceBytedanceCdpProjectListSD", e);
|
|
|
}
|
|
}
|
|
|
if (bytedanceCdpProjectMapper.replaceBytedanceCdpProjectList(projectList) > 0)
|
|
if (bytedanceCdpProjectMapper.replaceBytedanceCdpProjectList(projectList) > 0)
|
|
|
log.info("---账户({})项目信息更新成功", advertiserId);
|
|
log.info("---账户({})项目信息更新成功", advertiserId);
|
|
@@ -216,14 +221,14 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
//40100请求超频
|
|
//40100请求超频
|
|
|
if (40100 == code && count <= 5) {
|
|
if (40100 == code && count <= 5) {
|
|
|
Thread.sleep(800);
|
|
Thread.sleep(800);
|
|
|
- getProjectListVo(advertiserId, type, date, page, count + 1);
|
|
|
|
|
|
|
+ getProjectListVo(advertiserId, ids, type, date, page, count + 1);
|
|
|
} else {
|
|
} else {
|
|
|
log.error("获取项目列表失败(url:{}),入参:{}\n结果:{}", url, JSONObject.toJSONString(params), obj);
|
|
log.error("获取项目列表失败(url:{}),入参:{}\n结果:{}", url, JSONObject.toJSONString(params), obj);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (nextPage) {
|
|
if (nextPage) {
|
|
|
- getProjectListVo(advertiserId, type, date, page + 1, 1);
|
|
|
|
|
|
|
+ getProjectListVo(advertiserId, ids, type, date, page + 1, 1);
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -326,11 +331,11 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
nextPage = true;
|
|
nextPage = true;
|
|
|
}
|
|
}
|
|
|
JSONArray list = data.getJSONArray("list");
|
|
JSONArray list = data.getJSONArray("list");
|
|
|
- if (!Check.isNull(list)){
|
|
|
|
|
|
|
+ if (!Check.isNull(list)) {
|
|
|
try {
|
|
try {
|
|
|
bytedanceCdpProjectMapper.replaceBytedanceByteAppLinkInfoSD(list);
|
|
bytedanceCdpProjectMapper.replaceBytedanceByteAppLinkInfoSD(list);
|
|
|
- }catch (Exception e) {
|
|
|
|
|
- log.error("",e);
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("", e);
|
|
|
}
|
|
}
|
|
|
if (bytedanceCdpProjectMapper.replaceBytedanceByteAppLinkInfo(list) > 0)
|
|
if (bytedanceCdpProjectMapper.replaceBytedanceByteAppLinkInfo(list) > 0)
|
|
|
log.info("---账户({})抖小详情信息更新成功", advertiserId);
|
|
log.info("---账户({})抖小详情信息更新成功", advertiserId);
|
|
@@ -394,11 +399,11 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
nextPage = true;
|
|
nextPage = true;
|
|
|
}
|
|
}
|
|
|
JSONArray list = data.getJSONArray("list");
|
|
JSONArray list = data.getJSONArray("list");
|
|
|
- if (!Check.isNull(list)){
|
|
|
|
|
|
|
+ if (!Check.isNull(list)) {
|
|
|
try {
|
|
try {
|
|
|
bytedanceCdpProjectMapper.replaceBytedanceWxAppInfoSD(list, advertiserId);
|
|
bytedanceCdpProjectMapper.replaceBytedanceWxAppInfoSD(list, advertiserId);
|
|
|
- }catch (Exception e) {
|
|
|
|
|
- log.error("",e);
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("", e);
|
|
|
}
|
|
}
|
|
|
if (bytedanceCdpProjectMapper.replaceBytedanceWxAppInfo(list, advertiserId) > 0)
|
|
if (bytedanceCdpProjectMapper.replaceBytedanceWxAppInfo(list, advertiserId) > 0)
|
|
|
log.info("---账户({})微小信息更新成功", advertiserId);
|
|
log.info("---账户({})微小信息更新成功", advertiserId);
|
|
@@ -502,11 +507,11 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
JSONObject object = array.getJSONObject(i);
|
|
JSONObject object = array.getJSONObject(i);
|
|
|
getAppId(object);
|
|
getAppId(object);
|
|
|
}
|
|
}
|
|
|
- if (!Check.isNull(array)){
|
|
|
|
|
|
|
+ if (!Check.isNull(array)) {
|
|
|
try {
|
|
try {
|
|
|
bytedanceCdpProjectMapper.replaceAdqDynamicCreateivesSD(array, accountId);
|
|
bytedanceCdpProjectMapper.replaceAdqDynamicCreateivesSD(array, accountId);
|
|
|
- }catch (Exception e) {
|
|
|
|
|
- log.error("",e);
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("", e);
|
|
|
}
|
|
}
|
|
|
if (bytedanceCdpProjectMapper.replaceAdqDynamicCreateives(array, accountId) > 0)
|
|
if (bytedanceCdpProjectMapper.replaceAdqDynamicCreateives(array, accountId) > 0)
|
|
|
log.info("---账户({})广点通创意更新成功", accountId);
|
|
log.info("---账户({})广点通创意更新成功", accountId);
|
|
@@ -578,11 +583,11 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
JSONObject object = array.getJSONObject(i);
|
|
JSONObject object = array.getJSONObject(i);
|
|
|
getPageAppId(object);
|
|
getPageAppId(object);
|
|
|
}
|
|
}
|
|
|
- if (!Check.isNull(array)){
|
|
|
|
|
|
|
+ if (!Check.isNull(array)) {
|
|
|
try {
|
|
try {
|
|
|
bytedanceCdpProjectMapper.replaceAdqDynamicPagesSD(array, accountId);
|
|
bytedanceCdpProjectMapper.replaceAdqDynamicPagesSD(array, accountId);
|
|
|
- }catch (Exception e) {
|
|
|
|
|
- log.error("",e);
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("", e);
|
|
|
}
|
|
}
|
|
|
if (bytedanceCdpProjectMapper.replaceAdqDynamicPages(array, accountId) > 0)
|
|
if (bytedanceCdpProjectMapper.replaceAdqDynamicPages(array, accountId) > 0)
|
|
|
log.info("---账户({})广点通落地页更新成功", accountId);
|
|
log.info("---账户({})广点通落地页更新成功", accountId);
|