Browse Source

数据获取

yumeng 4 năm trước cách đây
mục cha
commit
108bc0a8e4

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

@@ -75,6 +75,27 @@ public class TestController {
     static ExecutorService suzhaoService = Executors.newFixedThreadPool(5);
 
 
+    @GetMapping(value = "/getDailyDataByAccountId")
+    public String getDailyDataByAccountId(Long accountId) {
+        Result<String> result = new Result<>();
+        try {
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            String statDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+            QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+            tokenQueryWrapper.eq("media_id", 2);
+            tokenQueryWrapper.eq("account_id", accountId);
+            CtopOauthToken ctopOauthTokens = oauthTokenMapper.selectOne(tokenQueryWrapper);
+            if (!Check.isNull(ctopOauthTokens)) {
+                historyReportTaskService.createTask(ctopOauthTokens.getAccountId(), ctopOauthTokens.getAccessToken(), statDate, statDate, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_DAILY);
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return "success";
+    }
+
 
     @GetMapping(value = "/getCut")
     public void getCut() {
@@ -113,11 +134,6 @@ public class TestController {
     }
 
 
-
-
-
-
-
     @GetMapping(value = "/t")
     public String test() {
         Result<String> result = new Result<>();
@@ -821,7 +837,6 @@ public class TestController {
     }
 
 
-
     @GetMapping(value = "/getAppList")
     public void getAppList() throws JobExecutionException {
         try {
@@ -837,7 +852,7 @@ public class TestController {
 
             tokens.forEach(token -> {
 
-                kuaishouInterfaceService.getAppList(token.getAccountId(),token.getAccessToken());
+                kuaishouInterfaceService.getAppList(token.getAccountId(), token.getAccessToken());
                 //suzhaoService.submit(new Runnable() {
                 //    @Override
                 //    public void run() {
@@ -856,22 +871,22 @@ public class TestController {
 
 
     @GetMapping(value = "/getOperationRecord")
-    public Result getOperationRecord(@Param("accountId")Long accountId, @Param("operationTarget")Integer operationTarget, @Param("startDate")String startDate, @Param("endDate")String endDate){
+    public Result getOperationRecord(@Param("accountId") Long accountId, @Param("operationTarget") Integer operationTarget, @Param("startDate") String startDate, @Param("endDate") String endDate) {
         Result result = new Result();
         try {
-            if(StringUtils.isBlank(startDate) || StringUtils.isBlank(endDate)){
+            if (StringUtils.isBlank(startDate) || StringUtils.isBlank(endDate)) {
                 result.setSuccess(false);
                 result.setMessage("时间参数不能为空");
                 return result;
             }
 
-            if(operationTarget == null){
+            if (operationTarget == null) {
                 result.setSuccess(false);
                 result.setMessage("类型不能为空");
                 return result;
             }
 
-            if(accountId == null){
+            if (accountId == null) {
                 //1:查询当日数据
                 QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
                 queryWrapper.eq("media_id", 2);
@@ -895,7 +910,7 @@ public class TestController {
                         }
                     });
                 });
-            }else{
+            } else {
                 QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
                 queryWrapper.eq("account_id", accountId);
                 CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(accountId));
@@ -922,10 +937,10 @@ public class TestController {
     public IBytedanceInterfaceService bytedanceInterfaceService;
 
     @GetMapping(value = "/searchLog")
-    public Result searchLog(@Param("accountId")Long accountId, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("operationTarget")Integer operationTarget) {
+    public Result searchLog(@Param("accountId") Long accountId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("operationTarget") Integer operationTarget) {
         Result result = new Result();
 
-        if(accountId == null){
+        if (accountId == null) {
             //1:查询当日数据
             QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("media_id", 1);
@@ -944,12 +959,12 @@ public class TestController {
                     @Override
                     public void run() {
                         log.info("获取操作记录开始:accountId:{},startDate:{},endDate:{}", token.getAccountId(), startDate, endDate);
-                        bytedanceInterfaceService.searchLog(token.getAccountId(), token, operationTarget,startDate, endDate);
+                        bytedanceInterfaceService.searchLog(token.getAccountId(), token, operationTarget, startDate, endDate);
                         log.info("获取快手操作记录结束:accountId:{},startDate:{},endDate:{}", token.getAccountId(), startDate, endDate);
                     }
                 });
             });
-        }else{
+        } else {
             QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("account_id", accountId);
             CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(accountId));
@@ -960,7 +975,7 @@ public class TestController {
                 return result;
             }
             log.info("获取快手操作记录开始:accountId:{},startDate:{},endDate:{}", token.getAccountId(), startDate, endDate);
-            bytedanceInterfaceService.searchLog(accountId, token, operationTarget,startDate, endDate);
+            bytedanceInterfaceService.searchLog(accountId, token, operationTarget, startDate, endDate);
             log.info("获取快手操作记录结束:accountId:{},startDate:{},endDate:{}", token.getAccountId(), startDate, endDate);
         }