Browse Source

报表文件下载

yumeng 5 năm trước cách đây
mục cha
commit
39d8800b40

+ 6 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ByteDanceAdvertiserPostController.java

@@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.text.ParseException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -276,7 +277,11 @@ public class ByteDanceAdvertiserPostController {
         Map<String, Object> result = new HashMap<>();
         CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
         if (null != token && token.getMediaId() == CtopAdConstant.PLATFORM_TYPE_KUAISHOU) {
-            kuaishouInterfaceService.loadKuaishouDataSingle(token);
+            try {
+                kuaishouInterfaceService.loadKuaishouDataSingle(token);
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
         } else {
             log.info("token异常");
         }

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

@@ -16,6 +16,7 @@ import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCreativeMapper;
@@ -55,6 +56,8 @@ public class TestController {
 
     @Autowired
     private CtopOauthTokenMapper oauthTokenMapper;
+    @Autowired
+    private IKuaiShouHistoryReportTaskService historyReportTaskService;
 
     @PostMapping(value = "/create")
     public Map<String, Object> authorization(@RequestBody JSONObject jsonObject) {
@@ -86,6 +89,57 @@ public class TestController {
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
 
+
+
+    @GetMapping(value = "/getHistoryData")
+    public String getHistoryData() {
+        Result<String> result = new Result<String>();
+        try {
+            String endDateStr = DateUtils.getDate("yyyy-MM-dd");
+            String startDate = DateUtils.addMonth(endDateStr, -6);
+            QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+            tokenQueryWrapper.eq("media_id", 2);
+            System.err.println(startDate);
+            System.err.println(endDateStr);
+
+
+            List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(tokenQueryWrapper);
+            if (!Check.isNull(ctopOauthTokens)) {
+                for (CtopOauthToken token : ctopOauthTokens) {
+                    historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
+                }
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return "success";
+    }
+
+
+    @GetMapping(value = "/getTaskList")
+    public String getTaskList() {
+        Result<String> result = new Result<String>();
+        try {
+            String endDateStr = DateUtils.getDate("yyyy-MM-dd");
+            String startDate = DateUtils.addMonth(endDateStr, -6);
+            QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+            tokenQueryWrapper.eq("media_id", 2);
+            System.err.println(startDate);
+            System.err.println(endDateStr);
+
+
+            historyReportTaskService.getTaskList();
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return "success";
+    }
+
     @GetMapping(value = "/getGroupData")
     public String getGroupData() {
 

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouDailyReportTaskServiceImpl.java

@@ -37,7 +37,7 @@ public class KuaiShouDailyReportTaskServiceImpl extends ServiceImpl<KuaiShouDail
 
 
     @Value("${jeecg.path.report-daily}")
-    private static String downloadPath;
+    private String downloadPath;
     @Autowired
     private KuaishouReportDailyCampaignMapper reportDailyCampaignMapper;
 

+ 3 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouHistoryReportTaskServiceImpl.java

@@ -40,7 +40,7 @@ import java.util.concurrent.Executors;
 @Service
 public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHistoryReportTaskMapper, KuaiShouHistoryReportTask> implements IKuaiShouHistoryReportTaskService {
     @Value("${jeecg.path.report-history}")
-    private static String downloadPath;
+    private String downloadPath;
     static List<Integer> historyTypeList;
     static List<Integer> dailyTypeList;
     static ExecutorService executorService = Executors.newFixedThreadPool(3);
@@ -121,6 +121,7 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
                     param.put("task_params", taskParams);
                     String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
                     JSONObject resultJson = JSONObject.parseObject(result);
+                    System.err.println(resultJson);
                     if (!Check.isNull(resultJson)) {
                         Integer code = resultJson.getInteger("code");
                         if (code == 0) {
@@ -209,7 +210,7 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
             Map<String, Object> requestMap = new HashMap<>();
             requestMap.put("advertiser_id", task.getAccountId());
             requestMap.put("task_id", task.getTaskId());
-            String localPath = DownloadUtils.downloadByUrl(requestMap, "D://report//", url, token, fileName);
+            String localPath = DownloadUtils.downloadByUrl(requestMap, downloadPath, url, token, fileName);
             if (!Check.isNull(localPath)) {
                 if (task.getViewType() == 1) {
                     reportDailyAccountMapper.loadAccountDailyReport(task.getAccountId(), localPath);