Prechádzať zdrojové kódy

修正账户授权以后,头条、快手拉取数据时的上次提交的bug。

huangxuechao 4 rokov pred
rodič
commit
f2e6c63a10

+ 7 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -781,12 +781,13 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     @Override
     public void loadKuaishouDataSingle(CtopOauthToken token) throws java.text.ParseException {
         String beginDateStr = allocationMapper.getUserAllocation(token.getAccountId()).getAuthBeginTime();
+        beginDateStr = Check.isNull(beginDateStr) ? DateUtils.formatDate(DateUtils.addDay(new Date(),-180),"yyyy-MM-dd") : beginDateStr;
         Date beginDate = DateUtils.parseDate(beginDateStr,DateUtils.WEB_FORMAT);
         Date endDate = DateUtils.addDay(new Date(),-1);
         while (!beginDate.after(endDate)){
             beginDate = DateUtils.addDay(beginDate,1);
-            getAdvertiserReportHourly(token, beginDate, endDate);
-            getAdvertiserReportDaily(token, beginDate, endDate, null);
+            getAdvertiserReportHourly(token, beginDate, beginDate);
+            getAdvertiserReportDaily(token, beginDate, beginDate, null);
         }
 //        Date endDate = new Date();
 //        for (int i = 0; i < 7; i++) {
@@ -795,7 +796,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 //            getAdvertiserReportHourly(token, beginDate, endDate);
 //            getAdvertiserReportDaily(token, beginDate, endDate, null);
             //2:获取广告计划信息数据
-            // getAdvertiserCampaignReportHourly(token, getStartDate, getStartDate);
+            //getAdvertiserCampaignReportHourly(token, getStartDate, getStartDate);
             //3:获取广告组信息数据
             // getAdvertiserGroupReportHourly(token, getStartDate, getStartDate);
             //4: 获取广告创意信息数据
@@ -809,9 +810,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         getCreativeList(token, null, null);
         getAppList(token.getAccountId(), token.getAccessToken());
         log.info("----------------开始历史数据获取,accountId:{}", token.getAccountId());
-        String endDateStr = DateUtils.getDate("yyyy-MM-dd");
-        String startDate = DateUtils.addMonth(endDateStr, -1);
-        historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
+        String endDateStr = DateUtils.formatDate(endDate,"yyyy-MM-dd");
+//        String startDate = DateUtils.addMonth(endDateStr, -1);
+        historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), beginDateStr, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
         getVideoList(token, null, null);
         //   getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");

+ 40 - 22
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java

@@ -74,7 +74,7 @@ public class ReportServiceImpl implements IReportService {
     private IByteDanceAdvertiserDataService advertiserDataService;
     @Autowired
     private IBytedanceInterfaceService bytedanceInterfaceService;
-    @Autowired
+    @Resource
     private UserAllocationMapper allocationMapper;
 
     @Override
@@ -444,31 +444,36 @@ public class ReportServiceImpl implements IReportService {
 
     @Override
     public void loadBytedanceHistoryData(CtopOauthToken token) {
-        String beginDateStr = allocationMapper.getUserAllocation(token.getAccountId()).getAuthBeginTime();
-        Date beginDate = DateUtils.parseDate(beginDateStr,DateUtils.WEB_FORMAT);
-        Date endDate2 = DateUtils.addDay(new Date(),-1);
-        while (!beginDate.after(endDate2)){
-            beginDate = DateUtils.addDay(beginDate,1);
-//        for (int i = 1; i < 180; i++) {
-            Date getDate = DateUtils.addDay(new Date(),1);
-            this.getAdvertiserCreativeReport(token, beginDate, endDate2, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-            this.getAdvertiserPlanReport(token, beginDate, endDate2, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-            this.getAdvertiserReport(token, beginDate, endDate2, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-//        }
+        try {
+            String beginDateStr = allocationMapper.getUserAllocation(token.getAccountId()).getAuthBeginTime();
+            beginDateStr = Check.isNull(beginDateStr) ? DateUtils.formatDate(DateUtils.addDay(new Date(),-180),"yyyy-MM-dd") : beginDateStr;
+            Date beginDate = DateUtils.parseDate(beginDateStr,DateUtils.WEB_FORMAT);
+            Date endDate2 = DateUtils.addDay(new Date(),-1);
+            while (!beginDate.after(endDate2)){
+                beginDate = DateUtils.addDay(beginDate,1);
+    //        for (int i = 1; i < 180; i++) {
+    //            Date getDate = DateUtils.addDay(new Date(),1);
+                this.getAdvertiserCreativeReport(token, beginDate, beginDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                this.getAdvertiserPlanReport(token, beginDate, beginDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                this.getAdvertiserReport(token, beginDate, beginDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+    //        }
+
+            }
 
-        }
 
-        try {
             advertiserDataService.getMaterialList(token);
             log.info("获取历史素材报表:accountId:{}", token.getAccountId());
-            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-            String endDate = DateUtils.addDay(nowDate, -180);
+//            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+//            String endDate = DateUtils.addDay(nowDate, -180);
             SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-            Date end = simpleDateFormat.parse(nowDate);
-            Date start = simpleDateFormat.parse(endDate);
-            List<Date> dates = DateUtils.findDates(start, end);
-            for (int i = 0; i < dates.size(); i++) {
-                String formatDate = simpleDateFormat.format(dates.get(i));
+//            Date end = simpleDateFormat.parse(nowDate);
+//            Date start = simpleDateFormat.parse(endDate);
+//            List<Date> dates = DateUtils.findDates(start, end);
+
+            beginDate = DateUtils.parseDate(beginDateStr,DateUtils.WEB_FORMAT);
+            while (!beginDate.after(endDate2)){
+                beginDate = DateUtils.addDay(beginDate,1);
+                String formatDate = simpleDateFormat.format(beginDate);
                 //试玩报表
                 bytedanceInterfaceService.bytedancePlayableReport(token,formatDate,formatDate);
                 //
@@ -479,8 +484,21 @@ public class ReportServiceImpl implements IReportService {
                     byteDanceVideoReportDailyService.videoInfoListByAccountId(formatDate, formatDate, token.getAccountId());
                 }
 
-                //
             }
+//            for (int i = 0; i < dates.size(); i++) {
+//                String formatDate = simpleDateFormat.format(dates.get(i));
+//                //试玩报表
+//                bytedanceInterfaceService.bytedancePlayableReport(token,formatDate,formatDate);
+//                //
+//                //素材报表
+//                int code = bytedanceReportService.bytedanceMaterialReport(token, formatDate, formatDate);
+//                //如果成功的话跑视频清洗数据方法,失败会进入重试库,重试成功后再清洗数据
+//                if (code == 200 || code == 1) {
+//                    byteDanceVideoReportDailyService.videoInfoListByAccountId(formatDate, formatDate, token.getAccountId());
+//                }
+//
+//                //
+//            }
         } catch (Exception e) {
             e.printStackTrace();
         }