Browse Source

调整token方式

yumeng 5 năm trước cách đây
mục cha
commit
dcbe735de6
28 tập tin đã thay đổi với 211 bổ sung64 xóa
  1. 6 9
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/DailyFlowsJob.java
  2. 9 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouAppListJob.java
  3. 2 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCampaignGroupJob.java
  4. 1 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportLoadJob.java
  5. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCampaignReportLoadJob.java
  6. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCreativeReportLoadJob.java
  7. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyGroupReportLoadJob.java
  8. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyLoadFileJob.java
  9. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyReportTaskJob.java
  10. 57 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouGroupJob.java
  11. 1 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyAccountReportLoadJob.java
  12. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyAccountWarningLoadJob.java
  13. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCampaignReportLoadJob.java
  14. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCreativeReportLoadJob.java
  15. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyGroupReportLoadJob.java
  16. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouMaterialsLoadJob.java
  17. 66 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouNowDateCampaignJob.java
  18. 15 15
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCreativeLoadJob.java
  19. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouNowDateGroupJob.java
  20. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouSuZaoLoadJob.java
  21. 7 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java
  22. 4 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CpaBidWarningServiceImpl.java
  23. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/CtopOauthTokenMapper.java
  24. 10 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml
  25. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java
  26. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  27. 3 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/AccountWarningServiceImpl.java
  28. 3 2
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/ByteDanceHourlyAccountWarningServiceImpl.java

+ 6 - 9
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/DailyFlowsJob.java

@@ -1,10 +1,9 @@
 package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
@@ -16,7 +15,8 @@ public class DailyFlowsJob implements Job {
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
     @Autowired
-    private CtopOauthTokenMapper oauthTokenMapper;
+    private ICtopOauthTokenService oauthTokenService;
+
 
     /**
      * 刷新token
@@ -26,12 +26,9 @@ public class DailyFlowsJob implements Job {
      */
     @Override
     public void execute(JobExecutionContext jobExecutionContext) {
-        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("media_id", "2");
-        queryWrapper.groupBy("account_id");
-        List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(queryWrapper);
-        if (!Check.isNull(ctopOauthTokens)) {
-            for (CtopOauthToken ctopOauthToken : ctopOauthTokens) {
+        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        if (!Check.isNull(tokens)) {
+            for (CtopOauthToken ctopOauthToken : tokens) {
                 kuaishouInterfaceService.getDailyFlows(ctopOauthToken);
             }
 

+ 9 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouAppListJob.java

@@ -2,8 +2,9 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
@@ -21,8 +22,10 @@ import java.util.concurrent.Executors;
 public class KuaishouAppListJob implements Job {
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
+
     @Autowired
-    private CtopOauthTokenMapper oauthTokenMapper;
+    private ICtopOauthTokenService oauthTokenService;
+
 
     static ExecutorService executorService = Executors.newFixedThreadPool(2);
 
@@ -32,10 +35,11 @@ public class KuaishouAppListJob implements Job {
         Thread thread = new Thread() {
             @Override
             public void run() {
-                QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
-                oauthTokenQueryWrapper.eq("media_id", 2);
-                List<CtopOauthToken> tokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);
+                List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
                 for (CtopOauthToken token : tokens) {
+                    if (Check.isNull(token)) {
+                        continue;
+                    }
                     executorService.submit(new Runnable() {
                         @Override
                         public void run() {

+ 2 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCampaignGroupJob.java

@@ -2,7 +2,6 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import lombok.extern.slf4j.Slf4j;
 import org.quartz.Job;
@@ -15,7 +14,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 @Slf4j
-public class KuaishouCampaignGroupJob implements Job {
+public class KuaishouCampaignJob implements Job {
     @Autowired
     private ICtopOauthTokenService tokenService;
     @Autowired
@@ -31,7 +30,7 @@ public class KuaishouCampaignGroupJob implements Job {
             @Override
             public void run() {
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 executorService = Executors.newFixedThreadPool(3);
                 tokens.forEach(token -> {
                     executorService.submit(new Runnable() {
@@ -40,8 +39,6 @@ public class KuaishouCampaignGroupJob implements Job {
                             try {
                                 //1:获取全量广告计划数据
                                 kuaishouInterfaceService.getCampaignList(token, null, null);
-                                //1:获取全量广告组数据
-                                kuaishouInterfaceService.getGroupList(token, null, null);
                             } catch (Exception e) {
                                 e.printStackTrace();
                             } finally {

+ 1 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportLoadJob.java

@@ -2,7 +2,6 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -38,7 +37,7 @@ public class KuaishouDailyAccountReportLoadJob implements Job {
                 kuaishouInterfaceService.deleteHourlyReport(deleteDate);
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCampaignReportLoadJob.java

@@ -38,7 +38,7 @@ public class KuaishouDailyCampaignReportLoadJob implements Job {
                 kuaishouInterfaceService.deleteHourlyReport(deleteDate);
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCreativeReportLoadJob.java

@@ -46,7 +46,7 @@ public class KuaishouDailyCreativeReportLoadJob implements Job {
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
                 executorService = Executors.newFixedThreadPool(4);
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyGroupReportLoadJob.java

@@ -38,7 +38,7 @@ public class KuaishouDailyGroupReportLoadJob implements Job {
                 kuaishouInterfaceService.deleteHourlyReport(deleteDate);
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyLoadFileJob.java

@@ -40,7 +40,7 @@ public class KuaishouDailyLoadFileJob implements Job {
                 String nowDate = DateUtils.getDate("yyyy-MM-dd");
                 String statDate = getAnotherDay("yyyy-MM-dd", nowDate, -1);
                 //  查询快手token
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyReportTaskJob.java

@@ -26,7 +26,7 @@ public class KuaishouDailyReportTaskJob implements Job {
         log.info("快手获取日报数据任务执行开始");
         Long start = System.currentTimeMillis();
         Date getDate = DateUtils.addDay(new Date(), -1);
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
         if (null == tokens || tokens.size() <= 0) {
             log.info("快手获取日报数据任务执行失败:未获取到可用的token");
             return;

+ 57 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouGroupJob.java

@@ -0,0 +1,57 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+public class KuaishouGroupJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    static ExecutorService executorService = null;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+                executorService = Executors.newFixedThreadPool(3);
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+
+                                kuaishouInterfaceService.getGroupList(token, null, null);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                            }
+                        }
+                    });
+                });
+                log.info("快手物料数据同步完成");
+            }
+
+        };
+        thread.start();
+
+
+    }
+}

+ 1 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyAccountReportLoadJob.java

@@ -2,7 +2,6 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -46,7 +45,7 @@ public class KuaishouHourlyAccountReportLoadJob implements Job {
                     getDate = DateUtils.addDay(getDate, -1);
                 }
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyAccountWarningLoadJob.java

@@ -38,7 +38,7 @@ public class KuaishouHourlyAccountWarningLoadJob implements Job {
                 log.info("开始时段消耗预警定时任务");
                 long l = System.currentTimeMillis();
                 try {
-                    List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                    List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                     if (null == tokens || tokens.size() <= 0) {
                         log.info("定时获取快手数据异常:未获取到可用的token");
                         return;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCampaignReportLoadJob.java

@@ -47,7 +47,7 @@ public class KuaishouHourlyCampaignReportLoadJob implements Job {
                     getDate = DateUtils.addDay(getDate, -1);
                 }
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCreativeReportLoadJob.java

@@ -46,7 +46,7 @@ public class KuaishouHourlyCreativeReportLoadJob implements Job {
                     getDate = DateUtils.addDay(getDate, -1);
                 }
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyGroupReportLoadJob.java

@@ -46,7 +46,7 @@ public class KuaishouHourlyGroupReportLoadJob implements Job {
                     getDate = DateUtils.addDay(getDate, -1);
                 }
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouMaterialsLoadJob.java

@@ -34,7 +34,7 @@ public class KuaishouMaterialsLoadJob implements Job {
                 Date startDate = DateUtils.addDay(new Date(), -1);
                 Date endDate = new Date();
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 executorService = Executors.newFixedThreadPool(8);
                 tokens.forEach(token -> {
                     executorService.submit(new Runnable() {

+ 66 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouNowDateCampaignJob.java

@@ -0,0 +1,66 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+public class KuaishouNowDateCampaignJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    static ExecutorService executorService = null;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+
+        Thread thread = new Thread() {
+            @SneakyThrows
+            @Override
+            public void run() {
+                //1:查询当日数据
+                Date endDate  = DateUtils.getDate();
+                String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
+                SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
+                Date startDate = sim.parse(anotherDay);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+                executorService = Executors.newFixedThreadPool(5);
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                kuaishouInterfaceService.getCampaignList(token, startDate, endDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                            }
+                        }
+                    });
+                });
+                log.info("快手物料数据同步完成");
+            }
+
+        };
+        thread.start();
+
+
+    }
+
+}

+ 15 - 15
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCreativeLoadJob.java

@@ -2,8 +2,8 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.quartz.Job;
@@ -11,13 +11,14 @@ import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 @Slf4j
-public class KuaishouCreativeLoadJob implements Job {
+public class KuaishouNowDateCreativeJob implements Job {
     @Autowired
     private ICtopOauthTokenService tokenService;
     @Autowired
@@ -25,30 +26,26 @@ public class KuaishouCreativeLoadJob implements Job {
 
     static ExecutorService executorService = null;
 
-    /**
-     * 获取全量创意
-     *
-     * @param jobExecutionContext
-     * @throws JobExecutionException
-     */
-
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+
         Thread thread = new Thread() {
+            @SneakyThrows
             @Override
             public void run() {
-                //增加接口的开始和结束日期
-                Date startDate = DateUtils.addDay(new Date(), -1);
-                Date endDate = new Date();
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-                executorService = Executors.newFixedThreadPool(4);
+                Date endDate  = DateUtils.getDate();
+                String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
+                SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
+                Date startDate = sim.parse(anotherDay);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+                executorService = Executors.newFixedThreadPool(5);
                 tokens.forEach(token -> {
                     executorService.submit(new Runnable() {
                         @Override
                         public void run() {
                             try {
-                                //1:获取全量创意数据
                                 kuaishouInterfaceService.getCreativeList(token, startDate, endDate);
                             } catch (Exception e) {
                                 e.printStackTrace();
@@ -59,8 +56,11 @@ public class KuaishouCreativeLoadJob implements Job {
                 });
                 log.info("快手物料数据同步完成");
             }
+
         };
         thread.start();
 
+
     }
+
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouNowDateGroupJob.java

@@ -41,7 +41,7 @@ public class KuaishouNowDateGroupJob implements Job {
                 String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
                 SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
                 Date startDate = sim.parse(anotherDay);
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 executorService = Executors.newFixedThreadPool(5);
                 tokens.forEach(token -> {
                     executorService.submit(new Runnable() {

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouSuZaoLoadJob.java

@@ -28,7 +28,7 @@ public class KuaishouSuZaoLoadJob implements Job {
         Thread thread = new Thread() {
             @Override
             public void run() {
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 executorService = Executors.newFixedThreadPool(8);
                 tokens.forEach(token -> {
                     executorService.submit(new Runnable() {

+ 7 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java

@@ -68,13 +68,16 @@ public class BidWarningServiceImpl implements IBidWarningService {
                     List<UserAllocation> userAllocations = getUserAllocationsByProjectId(projectId);
                     if (!Check.isNull(userAllocations)) {
                         for (UserAllocation userAllocation : userAllocations) {
+                            if (userAllocation.getAccountStatus() == 1) {
+                                continue;
+                            }
                             Long accountId = userAllocation.getAccountId();
                             List<String> unitWarning = new ArrayList<>();
-                            if("1".equals(userAllocation.getMediaId())){
+                            if ("1".equals(userAllocation.getMediaId())) {
                                 BigDecimal bid = new BigDecimal(maxBid);
                                 BigDecimal bigDecimal = BigDecimalUtil.divideBigDecimal(bid, new BigDecimal(1000));
-                                unitWarning = byteDanceAdvertisePlanService.selectWarningGroup(accountId,bigDecimal);
-                            }else if("2".equals(userAllocation.getMediaId())){
+                                unitWarning = byteDanceAdvertisePlanService.selectWarningGroup(accountId, bigDecimal);
+                            } else if ("2".equals(userAllocation.getMediaId())) {
                                 unitWarning = groupMapper.selectWarningGroup(accountId, maxBid);
                             }
 
@@ -93,6 +96,7 @@ public class BidWarningServiceImpl implements IBidWarningService {
 
 
     }
+
     private List<UserAllocation> getUserAllocationsByProjectId(Long projectId) {
         QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
         userAllocationQueryWrapper.eq("project_id", projectId);

+ 4 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CpaBidWarningServiceImpl.java

@@ -58,6 +58,9 @@ public class CpaBidWarningServiceImpl implements ICpaBidWarningService {
             List<UserAllocation> userAllocations = getUserAllocationsByProjectId(project.getId());
             if (!Check.isNull(userAllocations)) {
                 for (UserAllocation userAllocation : userAllocations) {
+                    if (userAllocation.getAccountStatus() == 1) {
+                        continue;
+                    }
                     Long accountId = userAllocation.getAccountId();
                     List<String> unitWarning = new ArrayList<>();
                     if ("1".equals(userAllocation.getMediaId())) {
@@ -68,7 +71,7 @@ public class CpaBidWarningServiceImpl implements ICpaBidWarningService {
                     }
 
                     if (!Check.isNull(unitWarning)) {
-                        sendMessage(project.getMediaId(), accountId, project.getId(), project.getProjectName(), userAllocation.getAuthName(), unitWarning,maxDeepCpaBid );
+                        sendMessage(project.getMediaId(), accountId, project.getId(), project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxDeepCpaBid);
                     }
                 }
             }

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/CtopOauthTokenMapper.java

@@ -32,4 +32,6 @@ public interface CtopOauthTokenMapper extends BaseMapper<CtopOauthToken> {
      * @return
      */
     CtopOauthToken selectByAccountId(Long accountId);
+
+    List<CtopOauthToken> selectKuaiShouToken();
 }

+ 10 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml

@@ -75,4 +75,14 @@
         limit 1
     </select>
 
+
+    <select id="selectKuaiShouToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
+        select  t1.*
+        from ctop_oauth_token t1
+        left join ctop_user_allocation t2
+        on t1.account_id = t2.account_id
+        where t2.account_status = 0
+        and t1.media_id = 2
+
+    </select>
 </mapper>

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java

@@ -23,4 +23,6 @@ public interface ICtopOauthTokenService extends IService<CtopOauthToken> {
     Map<String, Object> getKuaiShouRefreshToken(Long accountId, String refreshToken);
 
     List<CtopOauthToken> getTokenListByType(String platformTypeBytedance);
+
+    List<CtopOauthToken> selectKuaiShouToken();
 }

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -157,4 +157,15 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
         queryWrapper.eq("media_id", platformType).orderByDesc("account_id");
         return this.list(queryWrapper);
     }
+
+    /**
+     * 获取快手有效账户列表
+     *
+     * @return
+     */
+
+    @Override
+    public List<CtopOauthToken> selectKuaiShouToken() {
+        return cTopOauthTokenMapper.selectKuaiShouToken();
+    }
 }

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

@@ -50,6 +50,9 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
             if (Check.isNull(userAllocation)) {
                 return;
             }
+            if (userAllocation.getAccountStatus() == 1) {
+                return;
+            }
             BigDecimal warningAmount = userAllocation.getWarningAmount();
             BigDecimal warningProportion = userAllocation.getWarningProportion();
             BigDecimal nowCost = hourlyAccountMapper.getCost(accountId, maxHour, statDate);
@@ -167,12 +170,4 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
     }
 
 
-
-
-
-
-
-
-
-
 }

+ 3 - 2
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/ByteDanceHourlyAccountWarningServiceImpl.java

@@ -6,7 +6,6 @@ import cn.com.ctop.common.module.entity.MailLog;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
-import cn.com.ctop.common.module.utils.BigDecimalUtil;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CorpWexinUtils;
 import cn.com.ctop.common.module.utils.SendMailUtil;
@@ -23,7 +22,6 @@ import java.util.List;
 public class ByteDanceHourlyAccountWarningServiceImpl implements IByteDanceHourlyAccountWarningService {
 
 
-
     @Autowired
     private BytedanceAdvertiserHourlyReportMapper bytedanceAdvertiserHourlyReportMapper;
     @Autowired
@@ -53,6 +51,9 @@ public class ByteDanceHourlyAccountWarningServiceImpl implements IByteDanceHourl
             if (Check.isNull(userAllocation)) {
                 return;
             }
+            if (userAllocation.getAccountStatus() == 1) {
+                return;
+            }
             BigDecimal warningAmount = userAllocation.getWarningAmount();
             BigDecimal warningProportion = userAllocation.getWarningProportion();
             BigDecimal nowCost = bytedanceAdvertiserHourlyReportMapper.getCost(accountId, maxHour, statDate);