|
@@ -11,7 +11,6 @@ import cn.com.ctop.job.bytedance.data.entity.BytedanceAdReportHourly;
|
|
import cn.com.ctop.job.bytedance.data.entity.BytedanceAdvertiserReportDaily;
|
|
import cn.com.ctop.job.bytedance.data.entity.BytedanceAdvertiserReportDaily;
|
|
import cn.com.ctop.job.bytedance.data.entity.BytedanceAdvertiserReportHourly;
|
|
import cn.com.ctop.job.bytedance.data.entity.BytedanceAdvertiserReportHourly;
|
|
import cn.com.ctop.job.bytedance.data.entity.BytedanceAgentReportDaily;
|
|
import cn.com.ctop.job.bytedance.data.entity.BytedanceAgentReportDaily;
|
|
-import cn.com.ctop.job.bytedance.data.entity.BytedanceAgentReportHourly;
|
|
|
|
import cn.com.ctop.job.bytedance.data.entity.BytedanceV3ProjectReportDaily;
|
|
import cn.com.ctop.job.bytedance.data.entity.BytedanceV3ProjectReportDaily;
|
|
import cn.com.ctop.job.bytedance.data.entity.BytedanceV3ProjectReportHourly;
|
|
import cn.com.ctop.job.bytedance.data.entity.BytedanceV3ProjectReportHourly;
|
|
import cn.com.ctop.job.bytedance.data.entity.BytedanceV3PromotionProjectReportDaily;
|
|
import cn.com.ctop.job.bytedance.data.entity.BytedanceV3PromotionProjectReportDaily;
|
|
@@ -50,7 +49,6 @@ import javax.annotation.Resource;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
-import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -387,7 +385,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
|
|
config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
|
|
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
|
|
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
|
|
JSONObject getObject = getAdvertiserStat(token, jsonObject);
|
|
JSONObject getObject = getAdvertiserStat(token, jsonObject);
|
|
-// System.out.println("返回结果:" + getObject);
|
|
|
|
|
|
+ System.out.println("返回结果:" + getObject);
|
|
if (null == getObject) {
|
|
if (null == getObject) {
|
|
XxlJobHelper.log("头条广告主数据获取异常");
|
|
XxlJobHelper.log("头条广告主数据获取异常");
|
|
log.error("头条广告主数据获取信息为空==》accountId:{}", token.getAccountId());
|
|
log.error("头条广告主数据获取信息为空==》accountId:{}", token.getAccountId());
|
|
@@ -640,21 +638,13 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void getAgentReport(
|
|
public void getAgentReport(
|
|
- OauthToken token, String startDate, String endDate, String bytedanceReportTypePl) {
|
|
|
|
|
|
+ OauthToken token, String startDate, String endDate) {
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
- if (CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY.equals(bytedanceReportTypePl)) {
|
|
|
|
- // 日报
|
|
|
|
- jsonObject.put("agent_id", token.getAccountId());
|
|
|
|
- jsonObject.put("start_date", startDate);
|
|
|
|
- jsonObject.put("end_date", endDate);
|
|
|
|
- jsonObject.put("page_size", 1000);
|
|
|
|
- jsonObject.put("timeGranularity", bytedanceReportTypePl);
|
|
|
|
- } else {
|
|
|
|
- // 时报
|
|
|
|
- jsonObject.put("agent_id", token.getAccountId());
|
|
|
|
- jsonObject.put("page_size", 1000);
|
|
|
|
- jsonObject.put("timeGranularity", bytedanceReportTypePl);
|
|
|
|
- }
|
|
|
|
|
|
+ // 日报
|
|
|
|
+ jsonObject.put("agent_id", token.getAccountId());
|
|
|
|
+ jsonObject.put("start_date", startDate);
|
|
|
|
+ jsonObject.put("end_date", endDate);
|
|
|
|
+ jsonObject.put("page_size", 1000);
|
|
|
|
|
|
getAgentReportByPage(token, jsonObject, 1);
|
|
getAgentReportByPage(token, jsonObject, 1);
|
|
}
|
|
}
|
|
@@ -663,61 +653,41 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
* 获取代理商
|
|
* 获取代理商
|
|
*/
|
|
*/
|
|
private void getAgentReportByPage(OauthToken token, JSONObject conditions, Integer page) {
|
|
private void getAgentReportByPage(OauthToken token, JSONObject conditions, Integer page) {
|
|
- log.info("获取代理商数据 accountID:{},page:{}", token.getAccountId(), page);
|
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
|
|
|
|
- String hour = simpleDateFormat.format(new Date());
|
|
|
|
- String nowDate = DateUtils.getNowDate("yyyyMMdd");
|
|
|
|
conditions.put("page", page);
|
|
conditions.put("page", page);
|
|
SerializeConfig config = new SerializeConfig();
|
|
SerializeConfig config = new SerializeConfig();
|
|
config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
|
|
config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
|
|
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
|
|
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
|
|
|
|
+// System.out.println("----------------入参:" + jsonObject);
|
|
|
|
+// System.out.println("-");
|
|
JSONObject getObject = getAgentStat(token, jsonObject);
|
|
JSONObject getObject = getAgentStat(token, jsonObject);
|
|
|
|
+// System.out.println("----------------结果:" + getObject);
|
|
if (null == getObject) {
|
|
if (null == getObject) {
|
|
XxlJobHelper.log("头条代理商数据获取异常");
|
|
XxlJobHelper.log("头条代理商数据获取异常");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
Integer code = getObject.getInteger("code");
|
|
Integer code = getObject.getInteger("code");
|
|
- String message = getObject.getString("message");
|
|
|
|
- if (null == code || code != 0) {
|
|
|
|
- XxlJobHelper.log("头条代理商数据获取异常:{}", message);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- JSONArray dataArray = getObject.getJSONObject("data").getJSONArray("list");
|
|
|
|
- if (null == dataArray || dataArray.isEmpty()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- List<BytedanceAgentReportHourly> hourlyList = new ArrayList<>();
|
|
|
|
- List<BytedanceAgentReportDaily> dailyList = new ArrayList<>();
|
|
|
|
- try {
|
|
|
|
- for (int i = 0; i < dataArray.size(); i++) {
|
|
|
|
- JSONObject data = dataArray.getJSONObject(i);
|
|
|
|
- if (null != conditions.get("timeGranularity")
|
|
|
|
- && conditions
|
|
|
|
- .get("timeGranularity")
|
|
|
|
- .equals(CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY)) {
|
|
|
|
- // 时报
|
|
|
|
- BytedanceAgentReportHourly hourlyReport =
|
|
|
|
- JSONObject.parseObject(data.toJSONString(), BytedanceAgentReportHourly.class);
|
|
|
|
- hourlyReport.setStatDatetime(nowDate);
|
|
|
|
- hourlyReport.setHour(Integer.parseInt(hour));
|
|
|
|
- hourlyList.add(hourlyReport);
|
|
|
|
- } else {
|
|
|
|
|
|
+ if (code == 0) {
|
|
|
|
+ JSONArray dataArray = getObject.getJSONObject("data").getJSONArray("list");
|
|
|
|
+ if (null == dataArray || dataArray.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ List<BytedanceAgentReportDaily> dailyList = new ArrayList<>();
|
|
|
|
+ try {
|
|
|
|
+ Integer startDate = DateUtils.getDateInteger(conditions.getString("start_date"));
|
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
|
+ JSONObject data = dataArray.getJSONObject(i);
|
|
// 日报
|
|
// 日报
|
|
- BytedanceAgentReportDaily dailyReport =
|
|
|
|
- JSONObject.parseObject(data.toJSONString(), BytedanceAgentReportDaily.class);
|
|
|
|
- dailyReport.setStatDatetime(((String) conditions.get("start_date")).replace("-", ""));
|
|
|
|
|
|
+ BytedanceAgentReportDaily dailyReport = JSONObject.parseObject(data.toJSONString(), BytedanceAgentReportDaily.class);
|
|
|
|
+ dailyReport.setStatDatetime(String.valueOf(startDate));
|
|
dailyList.add(dailyReport);
|
|
dailyList.add(dailyReport);
|
|
}
|
|
}
|
|
|
|
+ if (dailyList.size() > 0) {
|
|
|
|
+ bytedanceAgentReportDailyMapper.insert(dailyList);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ log.info("获取代理商数据错误:{}", e.toString());
|
|
}
|
|
}
|
|
- if (hourlyList.size() > 0) {
|
|
|
|
- bytedanceAgentReportHourlyMapper.insert(hourlyList);
|
|
|
|
- }
|
|
|
|
- if (dailyList.size() > 0) {
|
|
|
|
- bytedanceAgentReportDailyMapper.insert(dailyList);
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- log.info("获取代理商数据错误:{}", e.toString());
|
|
|
|
}
|
|
}
|
|
page++;
|
|
page++;
|
|
int totalPage =
|
|
int totalPage =
|
|
@@ -725,6 +695,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
if (page <= totalPage) {
|
|
if (page <= totalPage) {
|
|
getAgentReportByPage(token, conditions, page);
|
|
getAgentReportByPage(token, conditions, page);
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|