浏览代码

修改定时任务

syh 5 年之前
父节点
当前提交
cd815627eb

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

@@ -2,11 +2,13 @@ package org.jeecg.modules.ctop.controller;
 
 
 import cn.com.ctop.bytedance.entity.BytedancePlanDailyReport;
 import cn.com.ctop.bytedance.entity.BytedancePlanDailyReport;
 import cn.com.ctop.bytedance.service.IBytedancePlanDailyReportService;
 import cn.com.ctop.bytedance.service.IBytedancePlanDailyReportService;
+import cn.com.ctop.bytedance.service.IReportService;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
@@ -309,6 +311,50 @@ public class TestController {
         return result;
         return result;
     }
     }
 
 
+    @Autowired
+    private IReportService reportService;
+
+    @GetMapping("bytedanceHourReport")
+    public Map<String, Object> testReport() {
+        Map<String, Object> result = new HashMap<>();
+        log.info("头条时报数据获取开始");
+        Date getDate = new Date();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
+        String hour = simpleDateFormat.format(getDate);
+        if (null != hour && "00".equals(hour)) {
+            getDate = DateUtils.addDay(getDate, -1);
+        }
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取头条小时数据异常:未获取到可用的token");
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        executorService = Executors.newFixedThreadPool(4);
+        Date finalGetDate = getDate;
+        tokens.forEach(token -> {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    //1: 获取广告主信息数据
+                    reportService.getAdvertiserReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                    //2:获取广告组信息数据
+                    //reportService.getAdvertiserCampaignReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                    //3:获取广告计划信息数据
+                    //reportService.getAdvertiserPlanReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                    //4: 获取广告创意信息数据
+                    //reportService.getAdvertiserCreativeReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                }
+
+            });
+
+        });
+        log.info("头条时报数据获取结束");
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
     @GetMapping("formatYddData")
     @GetMapping("formatYddData")
     public Map<String, Object> formatYddData() throws Exception {
     public Map<String, Object> formatYddData() throws Exception {
         Map<String, Object> result = new HashMap<>();
         Map<String, Object> result = new HashMap<>();

+ 1 - 1
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/ReportServiceImpl.java

@@ -870,7 +870,7 @@ public class ReportServiceImpl implements IReportService {
      */
      */
     public JSONObject getAdvertiserStat(CtopOauthToken token, JSONObject conditions) {
     public JSONObject getAdvertiserStat(CtopOauthToken token, JSONObject conditions) {
         // 请求地址
         // 请求地址
-        String url = PropertiesUtils.getConfig("bytedance_api_url") + PropertiesUtils.getConfig("bytedance_v2_advertiser_report_get");
+        String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_advertiser_report_get");
         JSONArray groupBy = new JSONArray();
         JSONArray groupBy = new JSONArray();
         groupBy.add("STAT_GROUP_BY_FIELD_ID");
         groupBy.add("STAT_GROUP_BY_FIELD_ID");
         groupBy.add("STAT_GROUP_BY_FIELD_STAT_TIME");
         groupBy.add("STAT_GROUP_BY_FIELD_STAT_TIME");