|
@@ -5,6 +5,7 @@ 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.*;
|
|
import cn.com.ctop.job.bytedance.data.utils.*;
|
|
|
|
|
+import cn.com.ctop.job.bytedance.utils.doris.sink.DorisMultiTableStreamLoadManager;
|
|
|
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;
|
|
@@ -29,6 +30,9 @@ import java.util.*;
|
|
|
@Service
|
|
@Service
|
|
|
public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectService {
|
|
public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+ private DorisMultiTableStreamLoadManager dorisLoadManager;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
private BytedanceCdpProjectMapper bytedanceCdpProjectMapper;
|
|
private BytedanceCdpProjectMapper bytedanceCdpProjectMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -109,15 +113,13 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
}
|
|
|
JSONArray array = data.getJSONArray("list");
|
|
JSONArray array = data.getJSONArray("list");
|
|
|
for (int i = 0; i < array.size(); i++) {
|
|
for (int i = 0; i < array.size(); i++) {
|
|
|
- checkPromotionInfo(array.getJSONObject(i), advertiserId);
|
|
|
|
|
|
|
+ JSONObject jsonObject = array.getJSONObject(i);
|
|
|
|
|
+ checkPromotionInfo(jsonObject, advertiserId);
|
|
|
|
|
+ dorisLoadManager.add("media_api", "bytedance_promotion_list", jsonObject);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!Check.isNull(array)) {
|
|
if (!Check.isNull(array)) {
|
|
|
- try {
|
|
|
|
|
- bytedanceCdpProjectMapper.replaceBytedancePromotionListSD(array);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("", e);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //bytedanceCdpProjectMapper.replaceBytedancePromotionListSD(array);
|
|
|
if (bytedanceCdpProjectMapper.replaceBytedancePromotionList(array) > 0)
|
|
if (bytedanceCdpProjectMapper.replaceBytedancePromotionList(array) > 0)
|
|
|
log.info("---账户({})广告更新成功", advertiserId);
|
|
log.info("---账户({})广告更新成功", advertiserId);
|
|
|
}
|
|
}
|
|
@@ -201,13 +203,11 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
for (int i = 0; i < array.size(); i++) {
|
|
for (int i = 0; i < array.size(); i++) {
|
|
|
BytedanceCdpProject advertiserToolsSite = new BytedanceCdpProject(array.getJSONObject(i));
|
|
BytedanceCdpProject advertiserToolsSite = new BytedanceCdpProject(array.getJSONObject(i));
|
|
|
projectList.add(advertiserToolsSite);
|
|
projectList.add(advertiserToolsSite);
|
|
|
|
|
+
|
|
|
|
|
+ dorisLoadManager.add("media_api", "bytedance_cdp_project_list", advertiserToolsSite);
|
|
|
}
|
|
}
|
|
|
if (!Check.isNull(projectList)) {
|
|
if (!Check.isNull(projectList)) {
|
|
|
- try {
|
|
|
|
|
- bytedanceCdpProjectMapper.replaceBytedanceCdpProjectListSD(projectList);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("replaceBytedanceCdpProjectListSD", e);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //bytedanceCdpProjectMapper.replaceBytedanceCdpProjectListSD(projectList);
|
|
|
if (bytedanceCdpProjectMapper.replaceBytedanceCdpProjectList(projectList) > 0)
|
|
if (bytedanceCdpProjectMapper.replaceBytedanceCdpProjectList(projectList) > 0)
|
|
|
log.info("---账户({})项目信息更新成功", advertiserId);
|
|
log.info("---账户({})项目信息更新成功", advertiserId);
|
|
|
}
|
|
}
|
|
@@ -326,11 +326,8 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
}
|
|
|
JSONArray list = data.getJSONArray("list");
|
|
JSONArray list = data.getJSONArray("list");
|
|
|
if (!Check.isNull(list)) {
|
|
if (!Check.isNull(list)) {
|
|
|
- try {
|
|
|
|
|
- bytedanceCdpProjectMapper.replaceBytedanceByteAppLinkInfoSD(list);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("", e);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ dorisLoadManager.add("media_api", "bytedance_tools_asset_link_list", list);
|
|
|
|
|
+ //bytedanceCdpProjectMapper.replaceBytedanceByteAppLinkInfoSD(list);
|
|
|
if (bytedanceCdpProjectMapper.replaceBytedanceByteAppLinkInfo(list) > 0)
|
|
if (bytedanceCdpProjectMapper.replaceBytedanceByteAppLinkInfo(list) > 0)
|
|
|
log.info("---账户({})抖小详情信息更新成功", advertiserId);
|
|
log.info("---账户({})抖小详情信息更新成功", advertiserId);
|
|
|
}
|
|
}
|
|
@@ -394,13 +391,15 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
}
|
|
|
JSONArray list = data.getJSONArray("list");
|
|
JSONArray list = data.getJSONArray("list");
|
|
|
if (!Check.isNull(list)) {
|
|
if (!Check.isNull(list)) {
|
|
|
- try {
|
|
|
|
|
- bytedanceCdpProjectMapper.replaceBytedanceWxAppInfoSD(list, advertiserId);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("", e);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //bytedanceCdpProjectMapper.replaceBytedanceWxAppInfoSD(list, advertiserId);
|
|
|
if (bytedanceCdpProjectMapper.replaceBytedanceWxAppInfo(list, advertiserId) > 0)
|
|
if (bytedanceCdpProjectMapper.replaceBytedanceWxAppInfo(list, advertiserId) > 0)
|
|
|
log.info("---账户({})微小信息更新成功", advertiserId);
|
|
log.info("---账户({})微小信息更新成功", advertiserId);
|
|
|
|
|
+
|
|
|
|
|
+ for (Object o : list) {
|
|
|
|
|
+ JSONObject json = (JSONObject) o;
|
|
|
|
|
+ json.put("advertiser_id", advertiserId);
|
|
|
|
|
+ dorisLoadManager.add("media_api", "bytedance_wx_app_info", json);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -435,7 +434,7 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void getAdqCreatives(Long advertiserId, String startDate,String endDate) {
|
|
|
|
|
|
|
+ public void getAdqCreatives(Long advertiserId, String startDate, String endDate) {
|
|
|
try {
|
|
try {
|
|
|
String accessToken = tokenMapper.onlyGetADQToken(advertiserId);
|
|
String accessToken = tokenMapper.onlyGetADQToken(advertiserId);
|
|
|
if (Check.isNull(accessToken)) {
|
|
if (Check.isNull(accessToken)) {
|
|
@@ -507,13 +506,13 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
for (int i = 0; i < array.size(); i++) {
|
|
for (int i = 0; i < array.size(); i++) {
|
|
|
JSONObject object = array.getJSONObject(i);
|
|
JSONObject object = array.getJSONObject(i);
|
|
|
getAppId(object);
|
|
getAppId(object);
|
|
|
|
|
+
|
|
|
|
|
+ object.put("advertiser_id", accountId);
|
|
|
|
|
+ object.put("creative_create_time", object.getString("created_time"));
|
|
|
|
|
+ dorisLoadManager.add("media_api", "adq_dynamic_createive_list", object);
|
|
|
}
|
|
}
|
|
|
if (!Check.isNull(array)) {
|
|
if (!Check.isNull(array)) {
|
|
|
- try {
|
|
|
|
|
- bytedanceCdpProjectMapper.replaceAdqDynamicCreateivesSD(array, accountId);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("", e);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //bytedanceCdpProjectMapper.replaceAdqDynamicCreateivesSD(array, accountId);
|
|
|
if (bytedanceCdpProjectMapper.replaceAdqDynamicCreateives(array, accountId) > 0)
|
|
if (bytedanceCdpProjectMapper.replaceAdqDynamicCreateives(array, accountId) > 0)
|
|
|
log.info("---账户({})广点通创意更新成功", accountId);
|
|
log.info("---账户({})广点通创意更新成功", accountId);
|
|
|
}
|
|
}
|
|
@@ -529,19 +528,19 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (nextPage) {
|
|
if (nextPage) {
|
|
|
- rebackadqCreativesVo(accountId, accessToken, startDate ,endDate, page + 1, isDeleted, 1);
|
|
|
|
|
|
|
+ rebackadqCreativesVo(accountId, accessToken, startDate, endDate, page + 1, isDeleted, 1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void getAdqWechatPages(Long advertiserId,Long pageId) {
|
|
|
|
|
|
|
+ public void getAdqWechatPages(Long advertiserId, Long pageId) {
|
|
|
try {
|
|
try {
|
|
|
String accessToken = tokenMapper.onlyGetADQToken(advertiserId);
|
|
String accessToken = tokenMapper.onlyGetADQToken(advertiserId);
|
|
|
if (Check.isNull(accessToken)) {
|
|
if (Check.isNull(accessToken)) {
|
|
|
log.error("账户({})accessToken is null", advertiserId);
|
|
log.error("账户({})accessToken is null", advertiserId);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- this.getAdqWechatPagesVo(advertiserId,pageId, accessToken, 1, true, 1);
|
|
|
|
|
|
|
+ this.getAdqWechatPagesVo(advertiserId, pageId, accessToken, 1, true, 1);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
log.error("账户({})获取原生落地页异常", e.getMessage());
|
|
log.error("账户({})获取原生落地页异常", e.getMessage());
|
|
@@ -549,7 +548,7 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- private void getAdqWechatPagesVo(Long accountId,Long pageId, String accessToken, Integer page, Boolean isDeleted, int count) throws Exception {
|
|
|
|
|
|
|
+ private void getAdqWechatPagesVo(Long accountId, Long pageId, String accessToken, Integer page, Boolean isDeleted, int count) throws Exception {
|
|
|
boolean nextPage = false;
|
|
boolean nextPage = false;
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
long timestamp = Instant.now().getEpochSecond();
|
|
long timestamp = Instant.now().getEpochSecond();
|
|
@@ -588,13 +587,12 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
for (int i = 0; i < array.size(); i++) {
|
|
for (int i = 0; i < array.size(); i++) {
|
|
|
JSONObject object = array.getJSONObject(i);
|
|
JSONObject object = array.getJSONObject(i);
|
|
|
getPageAppId(object);
|
|
getPageAppId(object);
|
|
|
|
|
+
|
|
|
|
|
+ object.put("advertiser_id", accountId);
|
|
|
|
|
+ dorisLoadManager.add("media_api", "adq_dynamic_page_list", object);
|
|
|
}
|
|
}
|
|
|
if (!Check.isNull(array)) {
|
|
if (!Check.isNull(array)) {
|
|
|
- try {
|
|
|
|
|
- bytedanceCdpProjectMapper.replaceAdqDynamicPagesSD(array, accountId);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("", e);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //bytedanceCdpProjectMapper.replaceAdqDynamicPagesSD(array, accountId);
|
|
|
if (bytedanceCdpProjectMapper.replaceAdqDynamicPages(array, accountId) > 0)
|
|
if (bytedanceCdpProjectMapper.replaceAdqDynamicPages(array, accountId) > 0)
|
|
|
log.info("---账户({})广点通落地页更新成功", accountId);
|
|
log.info("---账户({})广点通落地页更新成功", accountId);
|
|
|
}
|
|
}
|
|
@@ -603,14 +601,14 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
|
|
|
} else {
|
|
} else {
|
|
|
if (count <= 4) {
|
|
if (count <= 4) {
|
|
|
Thread.sleep(500);
|
|
Thread.sleep(500);
|
|
|
- getAdqWechatPagesVo(accountId,pageId, accessToken, page, isDeleted, count + 1);
|
|
|
|
|
|
|
+ getAdqWechatPagesVo(accountId, pageId, accessToken, page, isDeleted, count + 1);
|
|
|
} else {
|
|
} else {
|
|
|
log.error("账户({})获取动态创意失败,入参:{}\n,结果:{}", accountId, JSONObject.toJSONString(param), obj);
|
|
log.error("账户({})获取动态创意失败,入参:{}\n,结果:{}", accountId, JSONObject.toJSONString(param), obj);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (nextPage) {
|
|
if (nextPage) {
|
|
|
- getAdqWechatPagesVo(accountId,pageId, accessToken, page + 1, isDeleted, 1);
|
|
|
|
|
|
|
+ getAdqWechatPagesVo(accountId, pageId, accessToken, page + 1, isDeleted, 1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|