zhaoxian 4 lat temu
rodzic
commit
b5c60c292d

+ 33 - 88
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -24,6 +24,7 @@ import cn.com.ctop.toutiao.modules.report.service.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xxl.job.core.context.XxlJobHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.annotations.Param;
@@ -1395,93 +1396,37 @@ public class TestController {
     @Autowired
     IETLReportBytedanceVideoService etlReportBytedanceVideoService;
 
-    @GetMapping("execute")
-    public Map<String, Object> execute(String date) throws Exception {
-        Map<String, Object> result = new HashMap<>();
-//        List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
-//        countDownLatch = new CountDownLatch(tokens.size());
-//        tokens.forEach(token -> executor.submit(() -> {
-//            try {
-//                bytedanceVideoReportService.pullVideoReport(token,date,date,1);
-//            } catch (Exception e) {
-//                XxlJobHelper.log("头条视频报表基础数据拉取异常:{}",e.getMessage());
-//            } finally {
-//                countDownLatch.countDown();
-//            }
-//        }));
-//        try {
-//            countDownLatch.await();
-//        } catch (InterruptedException e) {
-//            e.printStackTrace();
+//    @GetMapping("execute")
+//    public Map<String, Object> execute(String date) throws Exception {
+//        Map<String, Object> result = new HashMap<>();
+////        List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
+////        countDownLatch = new CountDownLatch(tokens.size());
+////        tokens.forEach(token -> executor.submit(() -> {
+////            try {
+////                bytedanceVideoReportService.pullVideoReport(token,date,date,1);
+////            } catch (Exception e) {
+////                XxlJobHelper.log("头条视频报表基础数据拉取异常:{}",e.getMessage());
+////            } finally {
+////                countDownLatch.countDown();
+////            }
+////        }));
+////        try {
+////            countDownLatch.await();
+////        } catch (InterruptedException e) {
+////            e.printStackTrace();
+////        }
+//        Map<String, Object> params = new HashMap<>();
+//        params.put("stat_datetime", date);
+//        etlReportBytedanceVideoService.removeByMap(params);
+//        etlReportBytedanceVideoService.cleanETL(date);
+//        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+//        public Map<String, Object> execute (Long accountId) throws Exception {
+//            Map<String, Object> result = new HashMap<>();
+//            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+//            kuaishouInterfaceService.getGroupList(token, new Date(), new Date());
+//            kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, new Date(), new Date());
+//            ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+//            return result;
 //        }
-        Map<String, Object> params = new HashMap<>();
-        params.put("stat_datetime", date);
-        etlReportBytedanceVideoService.removeByMap(params);
-        etlReportBytedanceVideoService.cleanETL(date);
-        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
-    public Map<String,Object> execute(Long accountId) throws Exception {
-        Map<String,Object>result = new HashMap<>();
-        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
-        kuaishouInterfaceService.getGroupList(token,new Date(),new Date());
-        kuaishouInterfaceService.getAdvertiserGroupReportDaily(token,new Date(),new Date());
-        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
-        return result;
-    }
-
-
-    @Autowired
-    private IKuaishouAudienceReportDailyService kuaishouAudienceReportDailyService;
-    @Autowired
-    private IKuaiShouGroupService kuaiShouGroupService;
-    @Autowired
-    private IKuaishouStrategyService kuaishouStrategyService;
-
-    @GetMapping("reportDaily")
-    public void ReportDaily() throws Exception {
-        CtopOauthToken token1 = tokenService.getTokenByAccountId(9743738L);
-        CtopOauthToken token2 = tokenService.getTokenByAccountId(9743727L);
-        CtopOauthToken token3 = tokenService.getTokenByAccountId(9556344L);
-        List<CtopOauthToken> tokens = new ArrayList<>();
-        tokens.add(token1);
-        tokens.add(token2);
-        tokens.add(token3);
-        //查询两天前数据  策略
-        List<String> dates = new ArrayList<>();
-        for (int i = 2; i < 33; i++) {
-            String dat = DateUtils.getLastDay(DateUtils.date2Str(), i);
-            dates.add(dat);
-        }
-
-        ExecutorService executorServic1e = Executors.newFixedThreadPool(30);
-        CtopOauthToken token = tokenService.getTokenByAccountId(9743738L);
-        dates.forEach(date -> executorServic1e.submit(() -> {
-            if (null == tokens || tokens.isEmpty()) {
-                XxlJobHelper.log("定时获取人群分析报表数据异常:未获取到可用的token");
-                XxlJobHelper.handleFail();
-                return;
-            }
-            int page = 1;
-            int pageSize = 2000;
-            getAudienceReportData(token, date, "ageSegment", page, pageSize);
-            getAudienceReportData(token, date, "gender", page, pageSize);
-            getAudienceReportData(token, date, "businessInterestTags", page, pageSize);
-            getAudienceReportData(token, date, "city", page, pageSize);
-            getAudienceReportData(token, date, "clientId", page, pageSize);
-            getAudienceReportData(token, date, "province", page, pageSize);
-        }));
-    }
-
-    private void getAudienceReportData(CtopOauthToken token, String date, String type, Integer page, Integer pageSize) {
-        System.out.println(date + "————:" + token.getAccountId());
-        try {
-            List<KuaiShouGroup> kuaiShouGroups = kuaiShouGroupService.queryUnitInfoByAccountId(token.getAccountId());
-            for (KuaiShouGroup kuaiShouGroup : kuaiShouGroups) {
-                kuaishouAudienceReportDailyService.crowdAnalysisReport(token, date, type, kuaiShouGroup.getCampaignId(), kuaiShouGroup.getUnitId(), page, pageSize);
-                Thread.sleep(410);
-            }
-        } catch (Exception e) {
-            XxlJobHelper.log("定时获取人群分析报表数据异常", e);
-        }
-    }
-
+//    }
 }