Browse Source

Merge branch 'master' into test

# Conflicts:
#	module-common/src/main/java/cn/com/ctop/common/module/service/ISysUserService.java
huangxuechao 4 năm trước cách đây
mục cha
commit
c84d6e664d
100 tập tin đã thay đổi với 2621 bổ sung1289 xóa
  1. 6 0
      jeecg-boot-module-system/pom.xml
  2. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/JeecgApplication.java
  3. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  4. 75 326
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  5. 20 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  6. 7 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java
  7. 6 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CpaBidWarningServiceImpl.java
  8. 19 17
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/orderplatform/util/ApprovalNodeNoticeHandler.java
  9. 17 11
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java
  10. 10 10
      jeecg-boot-module-system/src/main/resources/application-wps.yml
  11. 81 115
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  12. 5 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java
  13. 27 23
      module-check/src/main/java/cn/com/ctop/notice/handler/SendWeChatHandle.java
  14. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/CtopCorpWexinUser.java
  15. 3 4
      module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialInfo.java
  16. 10 1
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDateUnitKuaishou.java
  17. 86 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/WexinConfig.java
  18. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/CtopOauthTokenMapper.java
  19. 4 3
      module-common/src/main/java/cn/com/ctop/common/module/mapper/MailLogMapper.java
  20. 15 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/WexinConfigMapper.java
  21. 22 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml
  22. 6 6
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MailLogMapper.xml
  23. 2 3
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml
  24. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/WexinConfigMapper.xml
  25. 10 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java
  26. 2 1
      module-common/src/main/java/cn/com/ctop/common/module/service/ISysUserService.java
  27. 16 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IWexinConfigService.java
  28. 10 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  29. 7 4
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MailLogServiceImpl.java
  30. 10 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java
  31. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RefreshTokenServiceImpl.java
  32. 6 2
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/SendMessageServiceImpl.java
  33. 22 6
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysDepartServiceImpl.java
  34. 6 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysUserServiceImpl.java
  35. 29 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/WexinConfigServiceImpl.java
  36. 45 31
      module-common/src/main/java/cn/com/ctop/common/module/utils/CorpWexinUtils.java
  37. 146 146
      module-common/src/main/java/cn/com/ctop/common/module/utils/JavacvUtil.java
  38. 1 1
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ByteDancePlanRuleDataJob.java
  39. 21 1
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ByteDanceRefreshTokenJob.java
  40. 68 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceCheckAccountReportJob.java
  41. 19 1
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceEtlVideoJob.java
  42. 1 1
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/RuleDataAccountCleanJob.java
  43. 11 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEtlVideoJob.java
  44. 49 4
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouProjectVideoGetJob.java
  45. 0 50
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouSupplierVideoGetJob.java
  46. 1 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataAccountCleanJob.java
  47. 1 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataPlanCleanJob.java
  48. 1 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataTargetCleanJob.java
  49. 1 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataUnitCleanJob.java
  50. 93 44
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouVideoDirectionalPackageController.java
  51. 8 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAdvertiserStrategy.java
  52. 4 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouVideoDirectionalPackage.java
  53. 13 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java
  54. 4 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouLandpagePackageServiceImpl.java
  55. 36 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouVideoGetController.java
  56. 89 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouProjectVideoGetController.java
  57. 6 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouProjectVideoGet.java
  58. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCreativeMapper.java
  59. 9 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouReportDailyMaterialMapper.java
  60. 7 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouVideoGetMapper.java
  61. 2 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouProjectVideoGetMapper.java
  62. 51 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml
  63. 451 79
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml
  64. 122 121
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml
  65. 96 90
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouProjectVideoGetMapper.xml
  66. 3 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouReportDailyMaterialService.java
  67. 6 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java
  68. 9 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouProjectVideoGetService.java
  69. 7 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/AccountWarningServiceImpl.java
  70. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java
  71. 5 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java
  72. 74 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouProjectVideoGetServiceImpl.java
  73. 10 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/EtlKuaishouVideoInfoServiceImpl.java
  74. 6 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/KuaishouBidWarningServiceImpl.java
  75. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaishouAccountMaterialReportDailyMapper.java
  76. 85 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouAccountMaterialReportDailyMapper.xml
  77. 2 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportAccountDailyMapper.xml
  78. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IEtlKuaishouAccountMaterialReportDailyService.java
  79. 13 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaishouAccountMaterialReportDailyServiceImpl.java
  80. 3 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouPlanServiceImpl.java
  81. 8 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/ETLReportBytedanceVideoMapper.java
  82. 55 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/xml/ETLReportBytedanceVideoMapper.xml
  83. 6 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/service/IETLReportBytedanceVideoService.java
  84. 30 51
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/service/impl/ETLReportBytedanceVideoServiceImpl.java
  85. 6 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceBidWarningServiceImpl.java
  86. 166 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceCheckReportTaskInfoController.java
  87. 67 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/BytedanceCheckReportTaskInfo.java
  88. 7 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceCampaignDailyReportMapper.java
  89. 14 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceCheckReportTaskInfoMapper.java
  90. 5 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceReportMaterialDailyMapper.java
  91. 12 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceCampaignDailyReportMapper.xml
  92. 5 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceCheckReportTaskInfoMapper.xml
  93. 24 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceReportMaterialDailyMapper.xml
  94. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceAdvertiserDailyReportService.java
  95. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceCampaignDailyReportService.java
  96. 24 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceCheckReportTaskInfoService.java
  97. 5 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceReportMaterialDailyService.java
  98. 7 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ByteDanceHourlyAccountWarningServiceImpl.java
  99. 11 39
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAdvertiserDailyReportServiceImpl.java
  100. 0 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceCampaignDailyReportServiceImpl.java

+ 6 - 0
jeecg-boot-module-system/pom.xml

@@ -270,5 +270,11 @@
                 <activatedProperties>wps</activatedProperties>
             </properties>
         </profile>
+        <profile>
+            <id>jiaoyang</id>
+            <properties>
+                <activatedProperties>jiaoyang</activatedProperties>
+            </properties>
+        </profile>
     </profiles>
 </project>

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/JeecgApplication.java

@@ -7,6 +7,8 @@ import org.apache.tomcat.util.scan.StandardJarScanner;
 import org.jeecg.common.constant.AccountReportConstants;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
+import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
 import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.context.annotation.Bean;

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -103,6 +103,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ctop/byteDance/homePage/report/*", "anon");
         filterChainDefinitionMap.put("/ctop/material/top/cost", "anon");
         filterChainDefinitionMap.put("/dimension/report/*", "anon");
+        filterChainDefinitionMap.put("/userAllocation/updateAuthName", "anon");
 
         filterChainDefinitionMap.put("/v1/**", "anon");
 

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

@@ -2,6 +2,7 @@ package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.entity.*;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.common.module.mapper.MailLogMapper;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.*;
@@ -29,10 +30,12 @@ import cn.com.ctop.manage.modules.material.service.IMaterialUploadService;
 import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo;
 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;
@@ -118,18 +121,19 @@ public class TestController {
     private IUserAllocationService allocationService;
     @Autowired
     private ICtopOauthTokenService tokenService;
-
     @Autowired
     private IKuaiShouProjectDataService kuaiShouProjectDataService;
     @Autowired
-    private IKuaishouReportHourlyGroupService hourlyGroupService;
-    @Autowired
     private IKuaiShouReportDailyMaterialService kuaiShouReportDailyMaterialService;
 
     @Autowired
     private IKuaiShouCreativeService creativeService;
     @Autowired
     private IKuaiShouGroupService groupService;
+    @Autowired
+    private MailLogMapper mailLogMapper;
+    @Autowired
+    private CorpWexinUtils corpWexinUtils;
 
     @Autowired
     private IBatchService batchService;
@@ -140,6 +144,18 @@ public class TestController {
     @Value("${xxl-job.requestUrl}")
     private String jobUrl;
 
+    @GetMapping("/testSend")
+    public void testSend(String userId) {
+
+        JSONObject weChatId = mailLogMapper.getWChatIdByUserId(userId);
+        if (weChatId.isEmpty()) {
+            log.error(String.format("User WeChat not found. userId =%s", userId));
+            //TODO 通知管理员添加邮箱
+        } else {
+            corpWexinUtils.sendMessageByWeChatId(weChatId, "hahahahahahah");
+        }
+    }
+
     @GetMapping("/uploadVideo")
     public String uploadVideo(Long projectId) {
 
@@ -159,207 +175,6 @@ public class TestController {
         return "success";
     }
 
-
-    @GetMapping(value = "/getProgramCreative")
-    public void getProgramCreative() {
-        List<Long> list = new ArrayList();
-        list.add(10045052L);
-        list.add(10045823L);
-        list.add(10045830L);
-        list.add(10045831L);
-
-        for (int i = 0; i < list.size(); i++) {
-            Long accountId = list.get(i);
-            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
-            creativeService.getProgramCreative(oauthToken, 1);
-        }
-
-
-    }
-
-
-    @GetMapping(value = "/campaignList")
-    public void campaignList() {
-        List<Long> list = new ArrayList();
-        list.add(10045052L);
-        list.add(10045823L);
-        list.add(10045830L);
-        list.add(10045831L);
-        for (int i = 0; i < list.size(); i++) {
-            Long accountId = list.get(i);
-            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
-            // kuaishouInterfaceService.getCampaignList(oauthToken, null, null);
-            videoService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        kuaishouInterfaceService.getCampaignList(oauthToken, null, null);
-                        //   kuaishouInterfaceService.getGroupList(oauthToken, null, null);
-                        //     kuaishouInterfaceService.getCreativeList(oauthToken, null, null);
-                        Thread.sleep(1500);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    }
-                }
-            });
-
-        }
-
-    }
-
-
-    @GetMapping(value = "/creativeList")
-    public void creativeList() {
-        List<Long> list = new ArrayList();
-        list.add(10045052L);
-        list.add(10045823L);
-        list.add(10045830L);
-        list.add(10045831L);
-        for (int i = 0; i < list.size(); i++) {
-            Long accountId = list.get(i);
-            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
-            QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
-            campaignQueryWrapper.eq("account_id", accountId);
-
-            List<KuaiShouCampaign> list1 = campaignService.list(campaignQueryWrapper);
-            for (KuaiShouCampaign campaign : list1) {
-                executorService.submit(new Runnable() {
-                    @Override
-                    public void run() {
-                        kuaishouInterfaceService.getCreativeList(oauthToken, null, null);
-                    }
-                });
-                try {
-                    Thread.sleep(400L);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-            }
-
-
-        }
-
-    }
-
-
-    @GetMapping(value = "/updateUnit")
-    public void updateUnit() throws Exception {
-        List<Long> list = new ArrayList();
-        list.add(9556344L);
-        list.add(9743738L);
-        list.add(9743727L);
-        list.add(9812671L);
-        list.add(9838554L);
-        list.add(9743746L);
-        list.add(9767055L);
-        list.add(9556274L);
-        list.add(9767096L);
-        list.add(9792538L);
-        list.add(9766952L);
-        list.add(9677440L);
-        list.add(9677334L);
-        list.add(9556465L);
-        list.add(9677236L);
-        list.add(9556227L);
-        list.add(9556188L);
-        list.add(9556431L);
-        list.add(9677408L);
-        list.add(9677284L);
-
-        for (int i = 0; i < list.size(); i++) {
-            Long accountId = list.get(i);
-            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
-            QueryWrapper<KuaiShouGroup> groupQueryWrapper = new QueryWrapper<>();
-            groupQueryWrapper.eq("account_id", accountId);
-            //      groupQueryWrapper.ne("schedule_time","000000111111111111111111000000111111111111111111000000111111111111111111000000111111111111111111000000111111111111111111000000111111111111111111000000111111111111111111");
-            //     groupQueryWrapper.eq("use_app_market", 1);
-            //    groupQueryWrapper.gt("cpa_bid", 19000);
-
-
-            List<KuaiShouGroup> list1 = groupService.list(groupQueryWrapper);
-          /*  for (KuaiShouGroup group : list1) {
-
-                JSONObject json = new JSONObject();
-                json.put("unitId", group.getUnitId());
-                json.put("useAppMarket", 0);
-                json.put("appStore", new JSONArray());
-                batchService.updateUnit(json, oauthToken);
-            }*/
-
-            for (KuaiShouGroup group : list1) {
-                executorService.submit(new Runnable() {
-                    @Override
-                    public void run() {
-                        try {
-                            JSONObject json = new JSONObject();
-                            json.put("unitId", group.getUnitId());
-                            json.put("cpaBid", 18 * 1000);
-                            //     json.put("gender", "2");
-                            batchService.updateUnit(json, oauthToken);
-                            Thread.sleep(1500);
-                        } catch (Exception e) {
-                            e.printStackTrace();
-                        }
-                    }
-                });
-
-
-            }
-
-
-        }
-
-
-    }
-
-
-    @GetMapping(value = "/updateCreative")
-    public void updateCreative() {
-        List<Long> list = new ArrayList();
-        list.add(10045052L);
-        list.add(10045823L);
-        list.add(10045830L);
-        list.add(10045831L);
-
-        for (int i = 0; i < list.size(); i++) {
-            Long accountId = list.get(i);
-            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
-
-
-            QueryWrapper<KuaiShouCreative> creativeQueryWrapper = new QueryWrapper<>();
-            creativeQueryWrapper.eq("account_id", accountId);
-
-
-            List<KuaiShouCreative> creativeList = creativeService.list(creativeQueryWrapper);
-            for (KuaiShouCreative creative : creativeList) {
-                executorService.submit(new Runnable() {
-                    @Override
-                    public void run() {
-                        try {
-                            JSONObject json = new JSONObject();
-                            json.put("creativeId", creative.getCreativeId());
-                            String url = "https://click-wailaxin.1sapp.com/vendor/feedback/reportClick?platform=kuaishou&feedback_type=android&account_id=19&plan_id=__DID__&adgroup_id=__AID__&creative_id=__CID__&imei=__IMEI2__&mac=__MAC__&androidid=__ANDROIDID2__&ts=__TS__&ip=__IP__&ua=__UA__&callback=__CALLBACK__&oaid=__OAID__&app=dxqlb";
-
-                            if (creative.getCreativeMaterialType() == 1) {
-                                json.put("clickTrackUrl", url);
-                            } else if (creative.getCreativeMaterialType() == 4) {
-                                json.put("impressionUrl", url);
-                                json.put("clickTrackUrl", url);
-
-                            }
-                            JSONObject jsonObject = batchService.updateCreative(json, oauthToken);
-                            log.info("修改创意返回信息:creative:{},结果:{}", creative.getCreativeId(), jsonObject);
-                            Thread.sleep(1000L);
-                        } catch (Exception e) {
-                            e.printStackTrace();
-                        }
-                    }
-                });
-            }
-        }
-    }
-
-
     @GetMapping("/cleanNewlyData")
     public void cleanNewlyData(String startDate, String endDate) throws ParseException {
 
@@ -405,19 +220,6 @@ public class TestController {
 
     }
 
-    @GetMapping("/getVideoByProjectId")
-    public String getVideoByProjectId(Long projectId) {
-        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("project_id", projectId);
-        List<UserAllocation> list = allocationService.list(queryWrapper);
-        for (UserAllocation allocation : list) {
-            CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
-            kuaishouInterfaceService.getVideoList(token, null, null);
-        }
-        return "success";
-    }
-
-
     @GetMapping("/testKuaishou")
     public String kuaishouCallback(@RequestParam("auth_code") String authCode, @RequestParam("state") String state) {
         try {
@@ -527,115 +329,6 @@ public class TestController {
         return "授权绑定失败!";
     }
 
-
-    @GetMapping("/getBytedanceMatReport")
-    public Map<String, Object> getData() {
-        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
-        executorService = Executors.newFixedThreadPool(10);
-        CountDownLatch countDownLatch = new CountDownLatch(tokens.size());
-        tokens.forEach(record -> executorService.submit(() -> {
-            try {
-                reportService.getAdvertiserReport(record, DateUtils.parseDate("2021-01-01", "yyyy-MM-dd"), DateUtils.parseDate("2021-01-31", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-                log.info("账户数据获取完成:account:{},时间:{}-{}", record.getAccountId(), "2021-01-01", "2020-01-31");
-            } catch (Exception e) {
-
-            } finally {
-                countDownLatch.countDown();
-            }
-        }));
-        try {
-            countDownLatch.await();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-        Map<String, Object> result = new HashMap<>();
-        ResultMapUtils.setResultMap(new HashMap<>(), StatusCode.COMMON_SUCCESS);
-        return result;
-    }
-
-
-    @GetMapping(value = "/updateTemplate")
-    public void updateTemplate(Long projectId, String startDate, String endDate) {
-
-        List<Long> list = new ArrayList();
-        list.add(7022550L);
-        list.add(7409586L);
-        list.add(5473041L);
-        list.add(5852766L);
-        list.add(6962896L);
-        list.add(7409919L);
-        for (int i = 0; i < list.size(); i++) {
-            Long accountId = list.get(i);
-            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
-            templateService.getTemplateByAccountId(oauthToken.getAccountId(), oauthToken.getAccessToken(), 1);
-
-            QueryWrapper<KuaishouTemplate> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("account_id", accountId);
-            List<KuaishouTemplate> list1 = templateService.list(queryWrapper);
-            if (!Check.isNull(list1)) {
-                for (KuaishouTemplate template : list1) {
-                    JSONObject param = new JSONObject();
-                    param.put("templateId", template.getTemplateId());
-                    param.put("accountId", template.getAccountId());
-                    param.put("templateName", template.getTemplateName());
-                    param.put("filterConvertedLevel", 5);
-                    templateService.updateTemplate(oauthToken.getAccountId(), oauthToken.getAccessToken(), param);
-
-                }
-
-            }
-
-
-        }
-
-
-    }
-
-
-    @GetMapping(value = "/getCreativeByProjectId")
-    public void gerCreative(Long projectId, String startDate, String endDate) {
-
-        Result<String> result = new Result<>();
-        try {
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-            Date start = simpleDateFormat.parse(startDate);
-            Date end = simpleDateFormat.parse(endDate);
-            QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
-            userAllocationQueryWrapper.eq("project_id", projectId);
-            List<UserAllocation> list = userAllocationService.list(userAllocationQueryWrapper);
-            if (!Check.isNull(list)) {
-                for (UserAllocation allocation : list) {
-                    Long accountId = allocation.getAccountId();
-                    QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
-                    tokenQueryWrapper.eq("media_id", 2);
-                    tokenQueryWrapper.eq("account_id", accountId);
-                    CtopOauthToken token = tokenMapper.selectOne(tokenQueryWrapper);
-                    if (!Check.isNull(token)) {
-                        suzhaoService.submit(new Runnable() {
-                            @Override
-                            public void run() {
-                                JSONArray arr = new JSONArray();
-                                kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, start, end, arr, arr);
-
-                            }
-                        });
-
-
-                    }
-                }
-
-            }
-
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            result.setSuccess(false);
-        }
-
-
-    }
-
-
     @GetMapping(value = "/agentReport")
     public void agentReport(String startDate, String endDate) {
         dailyAgentService.getAgentReportByPage(startDate, endDate);
@@ -1459,6 +1152,7 @@ public class TestController {
     @Autowired
     private IKuaishouStrategyService kuaishouStrategyService;
     static ExecutorService executorServic1e = Executors.newFixedThreadPool(5);
+
     /**
      * 勿动勿删,煜一人群报表数据拉取接口。
      *
@@ -1541,4 +1235,59 @@ public class TestController {
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
     }
+
+    @Autowired
+    private IBytedanceCheckReportTaskInfoService checkReportTaskInfoService;
+
+    @GetMapping("testInitCheckDataTask")
+    public Map<String, Object> testInitCheckDataTask(String date) throws ParseException {
+        Map<String, Object> result = new HashMap<>();
+        checkReportTaskInfoService.initTask(date);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
+
+    @GetMapping("testCheckCost")
+    public Map<String, Object> testCheckCost(String date) throws ParseException {
+        Map<String, Object> result = new HashMap<>();
+        List<BytedanceCheckReportTaskInfo> taskInfos = checkReportTaskInfoService.getListByParams(null, "2021-06-01", 0);
+        if (null != taskInfos && !taskInfos.isEmpty()) {
+            for (BytedanceCheckReportTaskInfo taskInfo : taskInfos) {
+                checkReportTaskInfoService.checkCost(taskInfo);
+            }
+        }
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
+    @GetMapping("checkCostData")
+    public void checkCostData(String date){
+            //1:初始化
+            checkReportTaskInfoService.initTask(date);
+            //2: checkCost
+            List<BytedanceCheckReportTaskInfo>taskInfos = checkReportTaskInfoService.getListByParams(null,date,0);
+            if(null!=taskInfos&&!taskInfos.isEmpty()){
+                for (BytedanceCheckReportTaskInfo task:taskInfos) {
+                    checkReportTaskInfoService.checkCost(task);
+                }
+                log.info("{}:数据获取完成",date);
+            }
+    }
+
+    @GetMapping("refreshReportData")
+    public void refreshReportData()throws Exception{
+        //1:查询异常任务数据
+        List<BytedanceCheckReportTaskInfo>taskInfos = checkReportTaskInfoService.getListByParams(null,null,50001);
+        if(null!=taskInfos&&!taskInfos.isEmpty()){
+            taskInfos.forEach(taskInfo -> {
+                try {
+                    checkReportTaskInfoService.reloadData(taskInfo);
+                    checkReportTaskInfoService.checkCost(taskInfo);
+                }catch (Exception e) {
+                }
+            });
+            log.info("数据更新完成");
+        }
+    }
 }

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

@@ -356,6 +356,26 @@ public class UserAllocationController {
         return result;
     }
 
+    /**
+     * 查询项目下账户集合
+     *
+     * @param
+     * @return
+     */
+    @GetMapping(value = "/queryAccountIdsByProjectId")
+    public Result<Object> queryAccountIdsByProjectId(Long projectId) {
+        if(Check.isNull(projectId)){
+            return Result.error("请选择项目");
+        }
+        try {
+            List<JSONObject> accountListByProject = userAllocationService.getAccountListByProject(projectId);
+            return Result.ok(accountListByProject);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return  Result.error("查询失败");
+    }
+
 
     @GetMapping(value = "/getAccountIdListByUserId")
     public Result<List<JSONObject>> getAccountIdListByUserId(String userId) {

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

@@ -13,6 +13,7 @@ import cn.com.ctop.common.module.utils.SendMailUtil;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -42,6 +43,8 @@ public class BidWarningServiceImpl implements IBidWarningService {
     private MailLogMapper mailLogMapper;
     @Autowired
     private IByteDanceAdvertisePlanService byteDanceAdvertisePlanService;
+    @Autowired
+    private CorpWexinUtils corpWexinUtils;
 
 
     /**
@@ -62,7 +65,7 @@ public class BidWarningServiceImpl implements IBidWarningService {
                     }
                     Long maxBid = project.getMaxBid();
                     Long projectId = project.getId();
-                    List<UserAllocation> userAllocations = userAllocationService.getByParams(projectId,null,null);
+                    List<UserAllocation> userAllocations = userAllocationService.getByParams(projectId, null, null);
                     if (!Check.isNull(userAllocations)) {
                         for (UserAllocation userAllocation : userAllocations) {
                             if (userAllocation.getAccountStatus() == 1) {
@@ -91,6 +94,7 @@ public class BidWarningServiceImpl implements IBidWarningService {
             e.printStackTrace();
         }
     }
+
     private void sendMessage(String mediaId, Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) {
         String createTime = DateUtils.getNowDate("yyyy-MM-dd");
         Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime, 1);
@@ -125,8 +129,8 @@ public class BidWarningServiceImpl implements IBidWarningService {
             }
         }
 
-        List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
-        CorpWexinUtils.sendMessage(wexinIds, text.toString());
+        List<JSONObject> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+        corpWexinUtils.sendMessage(wexinIds, text.toString());
     }
 
 

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

@@ -12,6 +12,7 @@ import cn.com.ctop.common.module.utils.SendMailUtil;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.service.ICpaBidWarningService;
@@ -37,6 +38,8 @@ public class CpaBidWarningServiceImpl implements ICpaBidWarningService {
     private MailLogMapper mailLogMapper;
     @Autowired
     private IByteDanceAdvertisePlanService byteDanceAdvertisePlanService;
+    @Autowired
+    private CorpWexinUtils corpWexinUtils;
 
     /**
      * 预警
@@ -45,7 +48,7 @@ public class CpaBidWarningServiceImpl implements ICpaBidWarningService {
     public void cpaBidWarning(Project project) {
         try {
             BigDecimal maxDeepCpaBid = project.getMaxDeepCpaBid();
-            List<UserAllocation> userAllocations = userAllocationService.getByParams(project.getId(),null,null);
+            List<UserAllocation> userAllocations = userAllocationService.getByParams(project.getId(), null, null);
             if (!Check.isNull(userAllocations)) {
                 for (UserAllocation userAllocation : userAllocations) {
                     if (userAllocation.getAccountStatus() == 1) {
@@ -109,8 +112,8 @@ public class CpaBidWarningServiceImpl implements ICpaBidWarningService {
             }
         }
 
-        List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
-        CorpWexinUtils.sendMessage(wexinIds, text.toString());
+        List<JSONObject> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+        corpWexinUtils.sendMessage(wexinIds, text.toString());
     }
 
 

+ 19 - 17
jeecg-boot-module-system/src/main/java/org/jeecg/modules/orderplatform/util/ApprovalNodeNoticeHandler.java

@@ -21,18 +21,20 @@ public class ApprovalNodeNoticeHandler {
 
     @Autowired
     IPlatformMaterialService platformMaterialService;
+    @Autowired
+    private CorpWexinUtils corpWexinUtils;
 
     /**
-     *  企业微信通知
+     * 企业微信通知
      */
-    public void NOTICE_WE_CHAT_ORDER(String operate, String orderCode){
-        Map<String, JSONObject> relatePerson=relatePerson(orderCode,null);
-        message(operate,null, relatePerson.get("orderRelatePerson"));
+    public void NOTICE_WE_CHAT_ORDER(String operate, String orderCode) {
+        Map<String, JSONObject> relatePerson = relatePerson(orderCode, null);
+        message(operate, null, relatePerson.get("orderRelatePerson"));
     }
 
-    public void NOTICE_WE_CHAT_MATERIAL(String operate, String materialCode){
-        Map<String, JSONObject> relatePerson=relatePerson(null,materialCode);
-        message(operate,relatePerson.get("materialRelatePerson"),null);
+    public void NOTICE_WE_CHAT_MATERIAL(String operate, String materialCode) {
+        Map<String, JSONObject> relatePerson = relatePerson(null, materialCode);
+        message(operate, relatePerson.get("materialRelatePerson"), null);
     }
 
     /**
@@ -40,7 +42,7 @@ public class ApprovalNodeNoticeHandler {
      */
     private Map<String, JSONObject> relatePerson(String orderCode, String materialCode) {
         Map<String, JSONObject> result = new HashMap<>();
-        if (null==materialCode) {
+        if (null == materialCode) {
             result.put("orderRelatePerson", platformMaterialService.getOrderRelatePersonByMaterialCode(orderCode));
         } else {
             result.put("materialRelatePerson", platformMaterialService.getMaterialRelatePersonByMaterialCode(materialCode));
@@ -166,12 +168,12 @@ public class ApprovalNodeNoticeHandler {
      */
     private void sendWeChat(Set<String> users, String message) {
         users.forEach(userId -> {
-            String weChatId = mailLogMapper.getWChatIdByUserId(userId);
+            JSONObject weChatId = mailLogMapper.getWChatIdByUserId(userId);
             if (weChatId.isEmpty()) {
                 log.error(String.format("User WeChat not found. userId =%s", userId));
                 //TODO 通知管理员添加邮箱
             } else {
-                CorpWexinUtils.sendMessageByWeChatId(weChatId, message);
+                corpWexinUtils.sendMessageByWeChatId(weChatId, message);
             }
         });
     }
@@ -180,12 +182,12 @@ public class ApprovalNodeNoticeHandler {
      * 发送通知消息到多人企业微信
      */
     private void sendWeChat(String userId, String message) {
-            String weChatId = mailLogMapper.getWChatIdByUserId(userId);
-            if (weChatId.isEmpty()) {
-                log.error(String.format("User WeChat not found. userId =%s", userId));
-                //TODO 通知管理员添加邮箱
-            } else {
-                CorpWexinUtils.sendMessageByWeChatId(weChatId, message);
-            }
+        JSONObject weChatId = mailLogMapper.getWChatIdByUserId(userId);
+        if (weChatId.isEmpty()) {
+            log.error(String.format("User WeChat not found. userId =%s", userId));
+            //TODO 通知管理员添加邮箱
+        } else {
+            corpWexinUtils.sendMessageByWeChatId(weChatId, message);
+        }
     }
 }

+ 17 - 11
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java

@@ -1,11 +1,9 @@
 package org.jeecg.modules.system.controller;
 
-import cn.com.ctop.common.module.entity.CorpFeishuUser;
-import cn.com.ctop.common.module.entity.CtopCorpWexinUser;
-import cn.com.ctop.common.module.entity.SysDepart;
-import cn.com.ctop.common.module.entity.SysUser;
+import cn.com.ctop.common.module.entity.*;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.AesEncryptUtil;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.feishu.provider.AuthProvider;
@@ -69,6 +67,8 @@ public class LoginController {
     private ICorpFeishuUserService corpFeishuUserService;
     @Autowired
     private ICtopCorpWexinUserService ctopCorpWexinUserService;
+    @Autowired
+    private IWexinConfigService wexinConfigService;
     private static final String BASE_CHECK_CODES = "qwertyuiplkjhgfdsazxcvbnmQWERTYUPLKJHGFDSAZXCVBNM1234567890";
 
     @GetMapping("feishu/url")
@@ -152,18 +152,23 @@ public class LoginController {
         }
     }
 
+
     @RequestMapping(value = "/wxlogin", method = RequestMethod.POST)
     @ApiOperation("企业微信登录接口")
-    public Result<JSONObject> wxlogin(@RequestParam(name = "code") String code) throws Exception {
+    public Result<JSONObject> wxlogin(@RequestParam(name = "code") String code, @RequestParam(name = "corpId") String corpId) throws Exception {
         Result<JSONObject> result = new Result<>();
+        WexinConfig wexinConfig = wexinConfigService.getInfoByCorpId(corpId);
+        if (Check.isNull(wexinConfig)) {
+            result.error500("未找到用户配置,请联系管理员");
+            return result;
+        }
         val configStorage = new WxCpDefaultConfigImpl();
-        configStorage.setCorpId("ww24b8a47826f5875f");
-        configStorage.setAgentId(1000002);
-        configStorage.setCorpSecret("MJIlySADGPlgvADnkFQPUpfZD4yV-4WN6066OgNnb0s");
-        configStorage.setToken("hcst2019");
-        configStorage.setAesKey("hcst2019");
+        configStorage.setCorpId(wexinConfig.getCorpId());
+        configStorage.setAgentId(wexinConfig.getAgentId());
+        configStorage.setCorpSecret(wexinConfig.getCorpSecret());
+        configStorage.setToken(wexinConfig.getToken());
+        configStorage.setAesKey(wexinConfig.getAesKey());
         val service = new WxCpServiceImpl();
-
         service.setWxCpConfigStorage(configStorage);
         WxCpOAuth2Service wxCpOAuth2Service = service.getOauth2Service();
         try {
@@ -193,6 +198,7 @@ public class LoginController {
                 CtopCorpWexinUser ctopCorpWexinUser = ctopCorpWexinUserService.getById(sysUser.getId());
                 if (ctopCorpWexinUser == null) {
                     ctopCorpWexinUser = new CtopCorpWexinUser();
+                    ctopCorpWexinUser.setCorpId(corpId);
                     ctopCorpWexinUser.setUserId(sysUser.getId());
                     ctopCorpWexinUser.setWexinEmail(user.getEmail());
                     ctopCorpWexinUser.setWexinGender(user.getGender().getGenderName());

+ 10 - 10
jeecg-boot-module-system/src/main/resources/application-wps.yml

@@ -95,21 +95,21 @@ spring:
         # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
-        master:
-          url: jdbc:mysql://139.186.27.96:4000/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
-          username: data
-          password: hcst@2021
-          driver-class-name: com.mysql.jdbc.Driver
+#        master:
+#          url: jdbc:mysql://139.186.27.96:4000/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+#          username: data
+#          password: hcst@2021
+#          driver-class-name: com.mysql.jdbc.Driver
 #        master:
 #          url: jdbc:mysql://139.186.151.174:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true
 #          username: hcst
 #          password: hcst@2020
 #          driver-class-name: com.mysql.jdbc.Driver
-#        master:
-#          url: jdbc:mysql://139.186.27.96:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
-#          username: data
-#          password: hcst@2021
-#          driver-class-name: com.mysql.jdbc.Driver
+        master:
+          url: jdbc:mysql://139.186.27.96:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          username: data
+          password: hcst@2021
+          driver-class-name: com.mysql.jdbc.Driver
   #redis 配置
   redis:
     database: 0

+ 81 - 115
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -5,20 +5,18 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
 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 cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
+import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouAccountMaterialReportDaily;
 import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouAccountMaterialReportDailyMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyImageService;
-import cn.com.ctop.oa.modules.service.IAppchatCreateService;
 import cn.com.ctop.oa.modules.service.IWechatNoListService;
-import cn.com.ctop.oa.modules.service.IWechatUserListService;
 import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
-import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo;
 import cn.com.ctop.toutiao.modules.report.service.*;
+import com.xxl.job.core.context.XxlJobHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.common.util.RedisUtil;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,81 +39,55 @@ import java.util.concurrent.Executors;
 @Slf4j
 public class SampleTest {
     @Autowired
+    private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
+    @Autowired
+    IBytedanceVideoReportService bytedanceVideoReportService;
+    @Autowired
+    IETLReportBytedanceVideoService ietlReportBytedanceVideoService;
+    @Autowired
+    IKuaishouReportDailyImageService kuaishouReportDailyImageService;
+    @Autowired
+    IRuleByteDanceAccountService ruleByteDanceAccountService;
+    @Autowired
     private ICtopOauthTokenService tokenService;
     @Autowired
     private IBindAccountLoginService bindAccountLoginService;
     @Autowired
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
     @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
+    private IByteDanceAdvertiserDataService advertiserDataService;
     @Autowired
-    private RedisUtil redisUtil;
+    private IWechatNoListService wechatNoListService;
     @Autowired
-    private IAppchatCreateService appchatCreateService;
+    private IETLReportBytedanceVideoService bytedanceVideoService;
     @Autowired
-    private IWechatUserListService wechatUserInfoService;
-
+    private IByteDanceVideoReportDailyService videoReportDailyService;
+    @Resource
+    private EtlKuaishouAccountMaterialReportDailyMapper etlKuaishouAccountMaterialReportDailyMapper;
+    @Autowired
+    private IReportService reportService;
+    @Resource
+    private IBytedanceCheckReportTaskInfoService checkReportTaskInfoService;
+    @Autowired
+    private IEtlBytedanceReportVideoDailyService etlBytedanceReportVideoDailyService;
+    static ExecutorService executorService = null;
+    static CountDownLatch countDownLatch = null;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+    @Autowired
+    private IETLReportBytedanceVideoService etlReportBytedanceVideoService;
 
     @Test
     public void loadKuaishouCookie() throws ParseException {
-
         CtopOauthToken tokenByAccountId = tokenService.getTokenByAccountId(1700996735138951L);
         advertiserDataService.getMaterialList(tokenByAccountId);
 
-
-
         CtopOauthToken tokenByAccountId1 = tokenService.getTokenByAccountId(1700996735589383L);
         advertiserDataService.getMaterialList(tokenByAccountId1);
-
-/*
-        wechatUserInfoService.getUserList();*/
-
-        // appchatCreateService.createAppChat(null, null, null);
-   //     appchatCreateService.getChatInfo(null);
-       /* redisUtil.set("11sdfhgjksdhfjksdhfjksdhfkjsjkfhkjsddhfjksdhfkjhsjkfhjkshfjksdhfjksdhfjkshdjkfhsjkdfhkjsd1","hahahaha",5);
-        Object o = redisUtil.get("11sdfhgjksdhfjksdhfjksdhfkjsjkfhkjsddhfjksdhfkjhsjkfhjkshfjksdhfjksdhfjkshdjkfhsjkdfhkjsd1");
-        System.err.println(o);*/
-
-
-        /*try {
-            // 用来保存数据
-            ArrayList<String[]> csvFileList = new ArrayList<String[]>();
-            // 定义一个CSV路径
-            String csvFilePath = "D:\\test\\123.csv";
-            // 创建CSV读对象 例如:CsvReader(文件路径,分隔符,编码格式);
-            CsvReader reader = new CsvReader(csvFilePath, ',', Charset.forName("UTF-8"));
-            // 跳过表头 如果需要表头的话,这句可以忽略
-            reader.readHeaders();
-            // 逐行读入除表头的数据
-            while (reader.readRecord()) {
-                System.out.println(reader.getRawRecord());
-                csvFileList.add(reader.getValues());
-            }
-            reader.close();
-
-            // 遍历读取的CSV文件
-            for (int row = 0; row < csvFileList.size(); row++) {
-                // 取得第row行第0列的数据
-                String cell = csvFileList.get(row)[0];
-                System.out.println("------------>" + cell);
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }*/
-
-
-
-
-
-       /* CtopOauthToken tokenByAccountId = tokenService.getTokenByAccountId(9792526L);
-        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-        Date parse = dateFormat.parse("2021-04-02");
-        kuaishouInterfaceService.getAdvertiserReportDaily(tokenByAccountId, parse, parse, null);*/
     }
 
 
-    static ExecutorService executorService = null;
-    static CountDownLatch countDownLatch = null;
+
 
     @Test
     public void deleteKuaishouComment() {
@@ -143,11 +115,6 @@ public class SampleTest {
         }
     }
 
-    @Autowired
-    private IBytedanceReportService bytedanceReportService;
-
-    @Autowired
-    private IByteDanceAdvertiserDataService advertiserDataService;
 
     @Test
     public void loadBytedanceVideoReportData() {
@@ -155,10 +122,7 @@ public class SampleTest {
         advertiserDataService.getMaterialList(token);
     }
 
-    @Autowired
-    private IWechatNoListService wechatNoListService;
-    @Autowired
-    private IETLReportBytedanceVideoService bytedanceVideoService;
+
 
     @Test
     public void etlBytedanceVideoInfo() {
@@ -183,8 +147,6 @@ public class SampleTest {
     }
 
 
-    @Autowired
-    private IByteDanceVideoReportDailyService videoReportDailyService;
 
     @Test
     public void formatVideoReportData() {
@@ -195,17 +157,6 @@ public class SampleTest {
         }
     }
 
-    @Autowired
-    private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
-    @Autowired
-    IBytedanceVideoReportService bytedanceVideoReportService;
-    @Autowired
-    IETLReportBytedanceVideoService ietlReportBytedanceVideoService;
-    @Autowired
-    IKuaishouReportDailyImageService kuaishouReportDailyImageService;
-    @Autowired
-    IRuleByteDanceAccountService ruleByteDanceAccountService;
-
     @Test
     public void loadBDAccoutData() {
         Date startDate = DateUtils.addDay(new Date(), -2000);
@@ -215,58 +166,73 @@ public class SampleTest {
         }
     }
 
-    @Resource
-    private EtlKuaishouAccountMaterialReportDailyMapper etlKuaishouAccountMaterialReportDailyMapper;
 
     @Test
     public void etlKuaishouVideoInfo() {
         etlKuaishouAccountMaterialReportDailyMapper.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate());
     }
 
-    @Autowired
-    private IByteDanceCampaignService campaignService;
 
     @Test
     public void testLoadBytedanceCampaign() {
-        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
-        for (CtopOauthToken token : tokens) {
-            campaignService.getAdvertiserCampaign(token, null, null);
-        }
+        CtopOauthToken token = tokenService.getTokenByAccountId(1681669009084429L);
+        bytedanceReportService.bytedanceMaterialReport(token, "2021-05-01", "2021-05-06");
     }
 
-    @Autowired
-    private IEtlBytedanceReportVideoDailyService etlBytedanceReportVideoDailyService;
 
     @Test
     public void etlBytedanceVideoReportInfo() throws Exception {
         etlBytedanceReportVideoDailyService.etlBytedanceVideo();
     }
 
-    @Autowired
-    private IReportService reportService;
-
     @Test
     public void loadBytedanceAccountReport() {
-        /**
-         * 1692555408132110
-         * 1692555631713287
-         * 1696734332089352
-         * 1696734333251598
-         */
-        CtopOauthToken token1 = tokenService.getTokenByAccountId(1692555408132110L);
-        reportService.getAdvertiserReport(token1, DateUtils.parseDate("2021-05-01", "yyyy-MM-dd"), DateUtils.parseDate("2021-05-12", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-        CtopOauthToken token2 = tokenService.getTokenByAccountId(1692555631713287L);
-        reportService.getAdvertiserReport(token2, DateUtils.parseDate("2021-05-01", "yyyy-MM-dd"), DateUtils.parseDate("2021-05-12", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-        CtopOauthToken token3 = tokenService.getTokenByAccountId(1696734332089352L);
-        reportService.getAdvertiserReport(token3, DateUtils.parseDate("2021-05-01", "yyyy-MM-dd"), DateUtils.parseDate("2021-05-12", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-        CtopOauthToken token4 = tokenService.getTokenByAccountId(1696734333251598L);
-        reportService.getAdvertiserReport(token4, DateUtils.parseDate("2021-05-01", "yyyy-MM-dd"), DateUtils.parseDate("2021-05-12", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        CtopOauthToken token1 = tokenService.getTokenByAccountId(1693648201498637L);
+        reportService.getAdvertiserReport(token1, DateUtils.parseDate("2021-04-01", "yyyy-MM-dd"), DateUtils.parseDate("2021-04-12", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+    }
 
-        CtopOauthToken token5 = tokenService.getTokenByAccountId(10129666L);
-        kuaishouInterfaceService.getAdvertiserReportDaily(token5, DateUtils.parseDate("2021-05-07", "yyyy-MM-dd"), DateUtils.parseDate("2021-05-11", "yyyy-MM-dd"), null);
-        CtopOauthToken token6 = tokenService.getTokenByAccountId(10097961L);
-        kuaishouInterfaceService.getAdvertiserReportDaily(token6, DateUtils.parseDate("2021-05-07", "yyyy-MM-dd"), DateUtils.parseDate("2021-05-11", "yyyy-MM-dd"), null);
-        CtopOauthToken token7 = tokenService.getTokenByAccountId(10098039L);
-        kuaishouInterfaceService.getAdvertiserReportDaily(token7, DateUtils.parseDate("2021-05-07", "yyyy-MM-dd"), DateUtils.parseDate("2021-05-11", "yyyy-MM-dd"), null);
+    @Test
+    public void checkCostData(){
+        String date = "2021-06-11";
+        for (int i=0;i<7;i++){
+            String getDate = DateUtils.addDay(date,i);
+            //1:初始化
+            checkReportTaskInfoService.initTask(getDate);
+            //2: checkCost
+            List<BytedanceCheckReportTaskInfo>taskInfos = checkReportTaskInfoService.getListByParams(null,getDate,0);
+            if(null!=taskInfos&&!taskInfos.isEmpty()){
+                for (BytedanceCheckReportTaskInfo task:taskInfos) {
+                    checkReportTaskInfoService.checkCost(task);
+                }
+                log.info("{}:数据获取完成",getDate);
+            }
+        }
+    }
+
+    @Test
+    public void refreshReportData()throws Exception{
+        //1:查询异常任务数据
+        List<BytedanceCheckReportTaskInfo>taskInfos = checkReportTaskInfoService.getListByParams(null,null,50001);
+        if(null!=taskInfos&&!taskInfos.isEmpty()){
+            countDownLatch = new CountDownLatch(taskInfos.size());
+            taskInfos.forEach(taskInfo -> {
+                try {
+                    checkReportTaskInfoService.reloadData(taskInfo);
+                    checkReportTaskInfoService.checkCost(taskInfo);
+                }catch (Exception e){
+                }finally {
+                    countDownLatch.countDown();
+                }
+            });
+            countDownLatch.await();
+            XxlJobHelper.log("{}数据更新完成");
+        }
+    }
+
+    @Test
+    public void testfreshBytedanceUrl(){
+        etlReportBytedanceVideoService.etlBytedanceVideoClipIdJob();
+        etlReportBytedanceVideoService.etlBytedanceVideoPlanInfoJob();
+        etlReportBytedanceVideoService.etlBytedanceVideoShotInfoJob();
     }
 }

+ 5 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java

@@ -574,6 +574,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
             return;
         }
         JSONObject user = getUserByAccountId(accountId);
+        if (Check.isNull(user)) {
+            return;
+        }
         StringJoiner creativeJoiner = new StringJoiner(",");
         StringJoiner unitJoiner = new StringJoiner(",");
         StringJoiner planJoiner = new StringJoiner(",");
@@ -1102,6 +1105,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                 ruleGroup.setRemark(groupJson.getString("remark"));
                 ruleGroup.setIsCopy(groupJson.getInteger("isCopy"));
                 ruleGroup.setIsRequired(groupJson.getInteger("isRequired"));
+                ruleGroup.setOperate(groupJson.getString("operate"));
+                ruleGroup.setSendType(groupJson.getString("sendType"));
                 boolean save = ruleGroupService.save(ruleGroup); // 新增规则组
                 if (save) {
                     for (int j = 0; j < ruleIds.size(); j++) {

+ 27 - 23
module-check/src/main/java/cn/com/ctop/notice/handler/SendWeChatHandle.java

@@ -2,6 +2,7 @@ package cn.com.ctop.notice.handler;
 
 import cn.com.ctop.common.module.mapper.MailLogMapper;
 import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -16,43 +17,46 @@ public class SendWeChatHandle {
 
     @Autowired
     MailLogMapper mailLogMapper;
+    @Autowired
+    private CorpWexinUtils corpWexinUtils;
 
-    public void sendWeChatByMail(String mail,String message){
-        String weChatId=mailLogMapper.getWeChatByMail(mail);
-        if(weChatId.isEmpty()){
-        log.error(String.format("mail's WeChat not found. mail =%s", mail));
-        //TODO 通知管理员添加邮箱
-    }else{
-        List<String> messageList= splitMessage(message);
-        messageList.forEach(it->CorpWexinUtils.sendMessageByWeChatId(weChatId,it));
+    public void sendWeChatByMail(String mail, String message) {
+        JSONObject weChatId = mailLogMapper.getWeChatByMail(mail);
+        if (weChatId.isEmpty()) {
+            log.error(String.format("mail's WeChat not found. mail =%s", mail));
+            //TODO 通知管理员添加邮箱
+        } else {
+            List<String> messageList = splitMessage(message);
+            messageList.forEach(it -> corpWexinUtils.sendMessageByWeChatId(weChatId, it));
+        }
     }
-}
 
     /**
      * 发送多人,邮箱逗号隔开
+     *
      * @param mails
      * @param message
      */
-    public void sendWeChatByMails(String mails,String message){
-        List<String> mail= Arrays.asList(mails.split(","));
-        mail.forEach(m-> this.sendWeChatByMail(m,message));
+    public void sendWeChatByMails(String mails, String message) {
+        List<String> mail = Arrays.asList(mails.split(","));
+        mail.forEach(m -> this.sendWeChatByMail(m, message));
     }
 
     /**
-     *  消息切割
+     * 消息切割
      */
-    private List<String> splitMessage(String message){
-        List<String> messageList=new ArrayList<>();
-        if(message.length()>1006){
-            int number=message.length()/1006;
-            for(int i=0;i<number;i++){
-                if(i!=number-1){
-                    messageList.add(message.substring(i*1006,(i+1)*1006-1));
-                }else {
-                    messageList.add(message.substring((i+1)*1006));
+    private List<String> splitMessage(String message) {
+        List<String> messageList = new ArrayList<>();
+        if (message.length() > 1006) {
+            int number = message.length() / 1006;
+            for (int i = 0; i < number; i++) {
+                if (i != number - 1) {
+                    messageList.add(message.substring(i * 1006, (i + 1) * 1006 - 1));
+                } else {
+                    messageList.add(message.substring((i + 1) * 1006));
                 }
             }
-        }else {
+        } else {
             messageList.add(message);
         }
         return messageList;

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/CtopCorpWexinUser.java

@@ -37,6 +37,7 @@ public class CtopCorpWexinUser {
     @Excel(name = "userId", width = 15)
     @ApiModelProperty(value = "userId")
     private String userId;
+
     /**
      * wexinId
      */
@@ -67,6 +68,7 @@ public class CtopCorpWexinUser {
     @Excel(name = "wexinGender", width = 15)
     @ApiModelProperty(value = "wexinGender")
     private String wexinGender;
+    private String corpId;
     /**
      * createTime
      */

+ 3 - 4
module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialInfo.java

@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -126,13 +125,13 @@ public class MaterialInfo implements Serializable {
      * createTime
      */
     @ApiModelProperty(value = "createTime")
-    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
-    private Object createTime;
+    // @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    private Date createTime;
     /**
      * updateTime
      */
     @ApiModelProperty(value = "updateTime")
-    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    // @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
     private Date updateTime;
 
     //判断是否为头条有效素材0否_1是

+ 10 - 1
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDateUnitKuaishou.java

@@ -72,7 +72,7 @@ public class RuleDateUnitKuaishou {
     /**
      * 深度转化目标出价
      */
-    private Long deepConversionBid;
+    private BigDecimal deepConversionBid;
     /**
      * 深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无
      */
@@ -82,9 +82,18 @@ public class RuleDateUnitKuaishou {
      */
     private Integer androidOsv;
     /**
+     * 优化目标
+     * 2:行为数;180:激活数;53:表单数;190: 付费;191:首日ROI;324:唤起应用;348:有效线索;383: 授信;384: 完件;394:订单提交;;396:注册
+     */
+    private Integer ocpxActionType;
+    /**
      * 付费单价
      */
     private BigDecimal payCost;
+    /**
+     * 出价
+     */
+    private BigDecimal cpaBid;
 
     private Integer status;
 

+ 86 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/WexinConfig.java

@@ -0,0 +1,86 @@
+package cn.com.ctop.common.module.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import me.chanjar.weixin.cp.api.WxCpService;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 企业微信配置信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-06-17
+ */
+@Data
+@TableName("ctop_wexin_config")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_wexin_config对象", description = "企业微信配置信息")
+public class WexinConfig {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "id")
+    private Integer id;
+    /**
+     * corpId
+     */
+    @Excel(name = "corpId", width = 15)
+    @ApiModelProperty(value = "corpId")
+    private String corpId;
+    /**
+     * agentId
+     */
+    @Excel(name = "agentId", width = 15)
+    @ApiModelProperty(value = "agentId")
+    private Integer agentId;
+    /**
+     * corpSecret
+     */
+    @Excel(name = "corpSecret", width = 15)
+    @ApiModelProperty(value = "corpSecret")
+    private String corpSecret;
+    /**
+     * aesKey
+     */
+    @Excel(name = "aesKey", width = 15)
+    @ApiModelProperty(value = "aesKey")
+    private String aesKey;
+    /**
+     * token
+     */
+    @Excel(name = "token", width = 15)
+    @ApiModelProperty(value = "token")
+    private String token;
+    /**
+     * remarks
+     */
+    @Excel(name = "remarks", width = 15)
+    @ApiModelProperty(value = "remarks")
+    private String remarks;
+    /**
+     * createTime
+     */
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+
+    @TableField(exist = false)
+    private WxCpService wxCpService;
+}

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

@@ -56,4 +56,7 @@ public interface CtopOauthTokenMapper extends BaseMapper<CtopOauthToken> {
      */
     List<CtopOauthToken> selectKuaiShouTokens(@Param("mediaId") String platformTypeByteDance);
 
+    List<CtopOauthToken> queryKsValidRuleAccountsToken();
+
+    List<CtopOauthToken> queryTtValidRuleAccountsToken();
 }

+ 4 - 3
module-common/src/main/java/cn/com/ctop/common/module/mapper/MailLogMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.MailLog;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -19,11 +20,11 @@ public interface MailLogMapper extends BaseMapper<MailLog> {
 
     List<String> selectMailList(@Param("projectId") Long projectId);
 
-    List<String> selectWeiXinIdList(@Param("projectId") Long projectId);
+    List<JSONObject> selectWeiXinIdList(@Param("projectId") Long projectId);
 
-    String getWChatIdByUserId(@Param("userId") String responsibleId);
+    JSONObject getWChatIdByUserId(@Param("userId") String responsibleId);
 
     String getUserNameByUserId(@Param("userId") String transferor);
 
-    String getWeChatByMail(@Param("mail") String mail);
+    JSONObject getWeChatByMail(@Param("mail") String mail);
 }

+ 15 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/WexinConfigMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.WexinConfig;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 企业微信配置信息
+ *
+ * @author jeecg-boot
+ * 2021-06-17
+ * @version V1.0
+ */
+public interface WexinConfigMapper extends BaseMapper<WexinConfig> {
+
+}

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

@@ -136,4 +136,26 @@
         group by account_id
     </select>
 
+    <select id="queryKsValidRuleAccountsToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
+        SELECT * FROM ctop_oauth_token
+        WHERE account_id IN
+              (SELECT t2.account_id FROM ctop_rule_template t1
+                                             INNER JOIN ctop_rule_account_template t2 ON t1.id = t2.template_id
+               WHERE t1.media_type = 2
+                 AND t2.template_status = 0
+               GROUP BY t2.account_id
+              )
+    </select>
+
+    <select id="queryTtValidRuleAccountsToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
+        SELECT * FROM ctop_oauth_token
+        WHERE account_id IN
+              (SELECT t2.account_id FROM ctop_rule_template t1
+                                             INNER JOIN ctop_rule_account_template t2 ON t1.id = t2.template_id
+               WHERE t1.media_type IN (1,3)
+                 AND t2.template_status = 0
+               GROUP BY t2.account_id
+              )
+    </select>
+
 </mapper>

+ 6 - 6
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MailLogMapper.xml

@@ -27,9 +27,9 @@
     </select>
 
 
-    <select id="selectWeiXinIdList" resultType="java.lang.String">
+    <select id="selectWeiXinIdList" resultType="com.alibaba.fastjson.JSONObject">
      select
-     t2.wexin_id
+     t2.wexin_id,t2.corp_id
      from
      ctop_project_member t1
      left join ctop_corp_wexin_user t2
@@ -41,8 +41,8 @@
      and t2.wexin_id != ''
     </select>
 
-    <select id="getWChatIdByUserId" resultType="java.lang.String">
-    select t1.wexin_id
+    <select id="getWChatIdByUserId" resultType="com.alibaba.fastjson.JSONObject">
+    select t1.wexin_id,corp_id
     from ctop_corp_wexin_user t1
     left join  sys_user t2
     on  t1.user_id = t2.id
@@ -58,9 +58,9 @@
     where id = #{userId}
     </select>
 
-    <select id="getWeChatByMail" resultType="java.lang.String">
+    <select id="getWeChatByMail" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
-            wexin_id
+            wexin_id,corp_id
         FROM
             ctop_corp_wexin_user
         WHERE

+ 2 - 3
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml

@@ -128,7 +128,6 @@
         <if test="projectId !=null and projectId != ''">
             and matInfo.project_id = #{projectId}
         </if>
-
         <if test="status!=null">
             and matInfo.status = #{status}
         </if>
@@ -147,10 +146,10 @@
                 #{item}
             </foreach>
         </if>
-        <if test="startDate!=null">
+        <if test="startDate!= null and startDate != '' ">
             and matInfo.create_time &gt;= #{startDate}
         </if>
-        <if test="endDate!=null">
+        <if test="endDate != null and endDate != '' ">
             and matInfo.create_time &lt;= #{endDate}
         </if>
         <if test="projectId!=null">

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/WexinConfigMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.common.module.mapper.WexinConfigMapper">
+
+</mapper>

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

@@ -39,4 +39,14 @@ public interface ICtopOauthTokenService extends IService<CtopOauthToken> {
     CtopOauthToken selectOneByMediaId(String platformTypeKuaishou);
 
     void getKuaiShouAgentRefreshToken(Long agentId, String accessToken, String refreshToken);
+
+    /**
+     *查询 快手 有效规则帐户token
+     */
+    List<CtopOauthToken> queryKsValidRuleAccountsToken();
+
+    /**
+     *查询 头条 有效规则帐户token
+     */
+    List<CtopOauthToken> queryTtValidRuleAccountsToken();
 }

+ 2 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/ISysUserService.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.common.module.service;
 
+import cn.com.ctop.common.module.entity.SysRole;
 import cn.com.ctop.common.module.entity.SysUser;
 import cn.com.ctop.common.module.model.SysUserSysDepartModel;
 import cn.com.ctop.common.module.vo.SysUserVo;
@@ -270,5 +271,5 @@ public interface ISysUserService extends IService<SysUser> {
 
     Map<String, String> getUserMapByMap(Map<String, String> userIdMap);
 
-    Integer updUserDesignLeaderById(String userId,String userName,String roleId);
+    String getRoleCodeByUserId(String userId);
 }

+ 16 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IWexinConfigService.java

@@ -0,0 +1,16 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.WexinConfig;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 企业微信配置信息
+ *
+ * @author jeecg-boot
+ * 2021-06-17
+ * @version V1.0
+ */
+public interface IWexinConfigService extends IService<WexinConfig> {
+
+    WexinConfig getInfoByCorpId(String corpId);
+}

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

@@ -300,6 +300,16 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
 
     }
 
+    @Override
+    public List<CtopOauthToken> queryKsValidRuleAccountsToken() {
+        return ctopOauthTokenMapper.queryKsValidRuleAccountsToken();
+    }
+
+    @Override
+    public List<CtopOauthToken> queryTtValidRuleAccountsToken() {
+        return ctopOauthTokenMapper.queryTtValidRuleAccountsToken();
+    }
+
     private Date addSecond(Date date, int seconds) {
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(date);

+ 7 - 4
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MailLogServiceImpl.java

@@ -9,6 +9,7 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CorpWexinUtils;
 import cn.com.feishu.provider.MessageProvider;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Primary;
@@ -25,11 +26,13 @@ import org.springframework.stereotype.Service;
 public class MailLogServiceImpl extends ServiceImpl<MailLogMapper, MailLog> implements IMailLogService {
     @Autowired
     private MailLogMapper mailLogMapper;
+    @Autowired
+    private CorpWexinUtils corpWexinUtils;
 
 
     @Override
     public void sendWeChat(String responsibleId, Long accountId, String projectName, String transferor, String assignee) {
-        String weChatId = mailLogMapper.getWChatIdByUserId(responsibleId);
+        JSONObject weChatId = mailLogMapper.getWChatIdByUserId(responsibleId);
         if (!Check.isNull(weChatId)) {
             String transferorName = mailLogMapper.getUserNameByUserId(transferor); // 转让人姓名
             String assigneeName = mailLogMapper.getUserNameByUserId(assignee); // 转让人姓名
@@ -39,7 +42,7 @@ public class MailLogServiceImpl extends ServiceImpl<MailLogMapper, MailLog> impl
                     .append("账号:" + accountId).append(",申请由:" + transferorName + "转户于:" + assigneeName).append("<br/>")
                     .append("等待您的审核,请您及时处理!");
 
-            CorpWexinUtils.sendMessageByWeChatId(weChatId, text.toString());
+            corpWexinUtils.sendMessageByWeChatId(weChatId, text.toString());
         }
 
         CorpFeishuUser user = corpFeishuUserService.getByUserId(responsibleId);
@@ -74,7 +77,7 @@ public class MailLogServiceImpl extends ServiceImpl<MailLogMapper, MailLog> impl
     @Override
     public void sendWeChatByStatus(String projectName, Integer status, String userId, Long accountId) {
 
-        String weChatId = mailLogMapper.getWChatIdByUserId(userId);
+        JSONObject weChatId = mailLogMapper.getWChatIdByUserId(userId);
         if (!Check.isNull(weChatId)) {
             String statusName = "";
 
@@ -91,7 +94,7 @@ public class MailLogServiceImpl extends ServiceImpl<MailLogMapper, MailLog> impl
                     .append("申请的转户操作已:" + statusName).append("<br/>")
                     .append("请您前往验证,谢谢!");
 
-            CorpWexinUtils.sendMessageByWeChatId(weChatId, text.toString());
+            corpWexinUtils.sendMessageByWeChatId(weChatId, text.toString());
         }
 
         CorpFeishuUser user = corpFeishuUserService.getByUserId(userId);

+ 10 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -780,7 +780,16 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
             ascription = "true";
         }
 
-        List<MaterialInfo> dailyList = materialInfoMapper.getListByParams(tagCode, type, status, productId, materialName, code, startDate, endDate, userId, projectId, ascription, clipId, shotId, planId, offlineFlag);
+        if (!Check.isNull(startDate)) {
+            startDate = startDate + " 00:00:01";
+        }
+
+        if (!Check.isNull(endDate)) {
+            endDate = endDate + " 23:59:59";
+        }
+
+
+        List<MaterialInfo> dailyList = materialInfoMapper.getListByParams(tagCode, type, status, productId, materialName, code, startDate, endDate, userId, projectId, ascription, clipId, shotId, planId,offlineFlag);
         List<MaterialInfo> setList = new ArrayList<>();
         PageInfo<MaterialInfo> pageInfo = new PageInfo<>(dailyList);
         if (null != dailyList && !dailyList.isEmpty()) {

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RefreshTokenServiceImpl.java

@@ -58,7 +58,7 @@ public class RefreshTokenServiceImpl implements IRefreshTokenService {
     @Override
     public void byteDanceRefresh(String accountId) {
         if (null == accountId || "".equals(accountId.trim()) || "null".equalsIgnoreCase(accountId)) {
-            List<CtopOauthToken> byteDanceOauthTokens = oauthTokenMapper.selectByteDanceTokens(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+            List<CtopOauthToken> byteDanceOauthTokens = oauthTokenMapper.selectToutiaoToken();
             if (!Check.isNull(byteDanceOauthTokens)) {
                 for (CtopOauthToken oauthToken : byteDanceOauthTokens) {
                     oauthTokenService.getByteDanceAccessToken(oauthToken);

+ 6 - 2
module-common/src/main/java/cn/com/ctop/common/module/service/impl/SendMessageServiceImpl.java

@@ -4,6 +4,7 @@ import cn.com.ctop.common.module.mapper.MailLogMapper;
 import cn.com.ctop.common.module.service.ISendMessageService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -13,11 +14,14 @@ import org.springframework.stereotype.Service;
 public class SendMessageServiceImpl implements ISendMessageService {
     @Autowired
     private MailLogMapper mailLogMapper;
+    @Autowired
+    private CorpWexinUtils corpWexinUtils;
+
     @Override
     public void sendMessage(String userId, String text) {
-        String weChatId = mailLogMapper.getWChatIdByUserId(userId);
+        JSONObject weChatId = mailLogMapper.getWChatIdByUserId(userId);
         if (!Check.isNull(weChatId)) {
-            CorpWexinUtils.sendMessageByWeChatId(weChatId, text);
+            corpWexinUtils.sendMessageByWeChatId(weChatId, text);
             log.info("消息发送成功,userId:{}", userId);
         }
     }

+ 22 - 6
module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysDepartServiceImpl.java

@@ -1,7 +1,16 @@
 package cn.com.ctop.common.module.service.impl;
 
-import cn.com.ctop.common.module.entity.*;
-import cn.com.ctop.common.module.mapper.*;
+import cn.com.ctop.common.module.entity.SysDepart;
+import cn.com.ctop.common.module.entity.SysDepartPermission;
+import cn.com.ctop.common.module.entity.SysDepartRole;
+import cn.com.ctop.common.module.entity.SysDepartRolePermission;
+import cn.com.ctop.common.module.entity.SysDepartRoleUser;
+import cn.com.ctop.common.module.entity.SysUserDepart;
+import cn.com.ctop.common.module.mapper.SysDepartMapper;
+import cn.com.ctop.common.module.mapper.SysDepartPermissionMapper;
+import cn.com.ctop.common.module.mapper.SysDepartRolePermissionMapper;
+import cn.com.ctop.common.module.mapper.SysDepartRoleUserMapper;
+import cn.com.ctop.common.module.mapper.SysUserDepartMapper;
 import cn.com.ctop.common.module.model.DepartIdModel;
 import cn.com.ctop.common.module.model.SysDepartTreeModel;
 import cn.com.ctop.common.module.service.ISysBaseApi;
@@ -13,16 +22,20 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import io.netty.util.internal.StringUtil;
-import org.jeecg.common.constant.CacheConstant;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.util.YouBianCodeUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
 /**
  * <p>
@@ -101,7 +114,7 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
         return listResult;
     }
 
-  //  @Cacheable(value = CacheConstant.SYS_DEPART_IDS_CACHE)
+    //  @Cacheable(value = CacheConstant.SYS_DEPART_IDS_CACHE)
     @Override
     public List<DepartIdModel> queryDepartIdTreeList() {
         LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
@@ -132,6 +145,9 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
             }
             String s = UUID.randomUUID().toString().replace("-", "");
             sysDepart.setId(s);
+            if (!Check.isNull(sysDepart.getLeaderName())) {
+                sysDepart.setLeaderName(sysDepart.getLeaderName().trim());
+            }
             // 先判断该对象有无父级ID,有则意味着不是最高级,否则意味着是最高级
             // 获取父级ID
             String parentId = sysDepart.getParentId();

+ 6 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysUserServiceImpl.java

@@ -308,6 +308,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     }
 
     @Override
+    public String getRoleCodeByUserId(String userId) {
+        return sysRoleMapper.getRoleCodeByUserId(userId);
+    }
+
+
+    @Override
     public Map<String, String> getDepNamesByUserIds(List<String> userIds) {
         List<SysUserDepVo> list = this.baseMapper.getDepNamesByUserIds(userIds);
         Map<String, String> res = new HashMap<String, String>();

+ 29 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/WexinConfigServiceImpl.java

@@ -0,0 +1,29 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.WexinConfig;
+import cn.com.ctop.common.module.mapper.WexinConfigMapper;
+import cn.com.ctop.common.module.service.IWexinConfigService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 企业微信配置信息
+ *
+ * @author jeecg-boot
+ * 2021-06-17
+ * @version V1.0
+ */
+@Service
+public class WexinConfigServiceImpl extends ServiceImpl<WexinConfigMapper, WexinConfig> implements IWexinConfigService {
+
+    @Override
+    public WexinConfig getInfoByCorpId(String corpId) {
+        QueryWrapper<WexinConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("corp_id", corpId);
+        queryWrapper.orderByDesc("create_time");
+        queryWrapper.last("limit 1");
+        WexinConfig config = this.getOne(queryWrapper);
+        return config;
+    }
+}

+ 45 - 31
module-common/src/main/java/cn/com/ctop/common/module/utils/CorpWexinUtils.java

@@ -1,5 +1,9 @@
 package cn.com.ctop.common.module.utils;
 
+import cn.com.ctop.common.module.entity.WexinConfig;
+import cn.com.ctop.common.module.service.IWexinConfigService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import lombok.val;
 import me.chanjar.weixin.common.error.WxErrorException;
@@ -7,69 +11,79 @@ import me.chanjar.weixin.cp.api.WxCpService;
 import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
 import me.chanjar.weixin.cp.bean.WxCpMessage;
 import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
+@Service
 @Slf4j
 public class CorpWexinUtils {
-    private static WxCpService wxCpService;
+    @Autowired
+    private IWexinConfigService wexinConfigService;
+    private static Map<String, WexinConfig> configMap = new HashMap<>();
 
-    {
-        initService();
-    }
-
-    public static void initService() {
-        val configStorage = new WxCpDefaultConfigImpl();
-        configStorage.setCorpId("ww24b8a47826f5875f");
-        configStorage.setAgentId(1000002);
-        configStorage.setCorpSecret("MJIlySADGPlgvADnkFQPUpfZD4yV-4WN6066OgNnb0s");
-        configStorage.setToken("hcst2019");
-        configStorage.setAesKey("hcst2019");
-        wxCpService = new WxCpServiceImpl();
-        wxCpService.setWxCpConfigStorage(configStorage);
+    private Map<String, WexinConfig> getConfigMap() {
+        QueryWrapper<WexinConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.orderByDesc("create_time");
+        List<WexinConfig> list = wexinConfigService.list(queryWrapper);
+        for (WexinConfig config : list) {
+            WxCpService wxCpService = new WxCpServiceImpl();
+            val configStorage = new WxCpDefaultConfigImpl();
+            configStorage.setCorpId(config.getCorpId());
+            configStorage.setAgentId(config.getAgentId());
+            configStorage.setCorpSecret(config.getCorpSecret());
+            configStorage.setToken(config.getToken());
+            configStorage.setAesKey(config.getAesKey());
+            wxCpService.setWxCpConfigStorage(configStorage);
+            config.setWxCpService(wxCpService);
+            configMap.put(config.getCorpId(), config);
+        }
+        return configMap;
     }
 
-    public static void sendMessage(List<String> wxUserList, String content) {
-        if (wxCpService == null) {
-            initService();
+    public void sendMessage(List<JSONObject> wxUserList, String content) {
+        if (Check.isNullMap(configMap)) {
+            getConfigMap();
         }
         if (wxUserList != null && wxUserList.size() > 0) {
-            for (String userId : wxUserList) {
+            for (JSONObject userInfo : wxUserList) {
                 WxCpMessage message = new WxCpMessage();
                 message.setMsgType("text");
                 message.setContent(content);
                 message.setAgentId(1000002);
-                message.setToUser(userId);
+                message.setToUser(userInfo.getString("wexin_id"));
                 try {
+                    WexinConfig config = configMap.get(userInfo.getString("corp_id"));
+                    WxCpService wxCpService = config.getWxCpService();
                     wxCpService.messageSend(message);
                 } catch (WxErrorException e) {
-                    log.error("发送信息失败,userId:{}", userId);
+                    log.error("发送信息失败,userId:{}", userInfo.getString("wexin_id"));
                     e.printStackTrace();
                 }
             }
         }
     }
-
-    public synchronized static void sendMessageByWeChatId(String weChatId, String content) {
-        if (wxCpService == null) {
-            initService();
+    public void sendMessageByWeChatId(JSONObject weChatInfo, String content) {
+        if (Check.isNullMap(configMap)) {
+            this.getConfigMap();
         }
-        if (!Check.isNull(weChatId)) {
+        if (!Check.isNull(weChatInfo)) {
             WxCpMessage message = new WxCpMessage();
             message.setMsgType("text");
             message.setContent(content);
             message.setAgentId(1000002);
-            message.setToUser(weChatId);
+            message.setToUser(weChatInfo.getString("wexin_id"));
             try {
+                WexinConfig config = configMap.get(weChatInfo.getString("corp_id"));
+                WxCpService wxCpService = config.getWxCpService();
                 wxCpService.messageSend(message);
             } catch (WxErrorException e) {
-                log.error("发送信息失败,userId:{}", weChatId);
+                log.error("发送信息失败,userId:{}", weChatInfo.getString("wexin_id"));
                 e.printStackTrace();
             }
-
         }
-
-
     }
-
 }

+ 146 - 146
module-common/src/main/java/cn/com/ctop/common/module/utils/JavacvUtil.java

@@ -1,146 +1,146 @@
-package cn.com.ctop.common.module.utils;
-
-import com.google.common.collect.Lists;
-import org.bytedeco.javacpp.opencv_core;
-import org.bytedeco.javacv.FFmpegFrameGrabber;
-import org.bytedeco.javacv.Frame;
-import org.bytedeco.javacv.Java2DFrameConverter;
-import org.opencv.core.CvType;
-import org.opencv.core.Mat;
-import org.opencv.core.MatOfByte;
-import org.opencv.imgcodecs.Imgcodecs;
-import org.opencv.imgproc.Imgproc;
-
-import javax.imageio.ImageIO;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.awt.image.DataBufferByte;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-public class JavacvUtil {
-    /**
-     * 视频文件指定时间段的帧截取
-     * @param file
-     * @param start
-     * @param end
-     */
-    public static List<File> videoIntercept(File file, Integer start, Integer end) {
-        Frame frame = null;
-        List<File> files = Lists.newArrayList();
-        FFmpegFrameGrabber fFmpegFrameGrabber = new FFmpegFrameGrabber(file);
-        String filePath = "D://video//images//";
-        String fileTargetName = "movie";
-        try {
-            fFmpegFrameGrabber.start();
-            int ftp = fFmpegFrameGrabber.getLengthInFrames();
-            for (int i=0 ; i < ftp ; i++){
-                if( i >= start && i <= end){
-                    frame = fFmpegFrameGrabber.grabImage();
-                    doExecuteFrame(frame, filePath, fileTargetName, i ,files);
-                }
-            }
-            fFmpegFrameGrabber.stop();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return files;
-    }
-
-    public static void doExecuteFrame(Frame frame, String targetFilePath, String targetFileName, int index ,List<File> files) {
-        if ( frame == null || frame.image == null) {
-            return;
-        }
-        Java2DFrameConverter converter = new Java2DFrameConverter();
-        String imageMat = "jpg";
-        String fileName = targetFilePath + targetFileName + "_" + index + "." + imageMat;
-        BufferedImage bi = converter.getBufferedImage(frame);
-
-//        Mat img = Imgcodecs.imread("");
-//        Mat imgHSV = new Mat(img.rows(), img.cols(), CvType.CV_8UC3);
-//        Mat img2 = new Mat(img.rows(), img.cols(), CvType.CV_8UC3);
-
-        //转成HSV空间
-//        Imgproc.cvtColor(img, imgHSV, Imgproc.COLOR_BGR2HSV);
-//        //转回BGR空间
-//        Imgproc.cvtColor(imgHSV, img2, Imgproc.COLOR_HSV2BGR);
-
-        File output = new File(fileName);
-        files.add(output);
-        try{
-            ImageIO.write(bi, imageMat, output);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static void main(String[] args) {
-        List<File> files = videoIntercept(new File("C:\\Users\\宋英豪\\Desktop\\nfpHmswW.mp4"), 10, 100);
-    }
-
-    /**
-     * Mat转换成BufferedImage
-     *
-     * @param matrix
-     *            要转换的Mat
-     * @param fileExtension
-     *            格式为 ".jpg", ".png", etc
-     * @return
-     */
-    public static BufferedImage Mat2BufImg (Mat matrix, String fileExtension) {
-        // convert the matrix into a matrix of bytes appropriate for
-        // this file extension
-        MatOfByte mob = new MatOfByte();
-        Imgcodecs.imencode(fileExtension, matrix, mob);
-        // convert the "matrix of bytes" into a byte array
-        byte[] byteArray = mob.toArray();
-        BufferedImage bufImage = null;
-        try {
-            InputStream in = new ByteArrayInputStream(byteArray);
-            bufImage = ImageIO.read(in);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return bufImage;
-    }
-
-    /**
-     * BufferedImage转换成Mat
-     *
-     * @param original
-     *            要转换的BufferedImage
-     * @param imgType
-     *            bufferedImage的类型 如 BufferedImage.TYPE_3BYTE_BGR
-     * @param matType
-     *            转换成mat的type 如 CvType.CV_8UC3
-     */
-    public static Mat BufImg2Mat (BufferedImage original, int imgType, int matType) {
-        if (original == null) {
-            throw new IllegalArgumentException("original == null");
-        }
-
-        // Don't convert if it already has correct type
-        if (original.getType() != imgType) {
-
-            // Create a buffered image
-            BufferedImage image = new BufferedImage(original.getWidth(), original.getHeight(), imgType);
-
-            // Draw the image onto the new buffer
-            Graphics2D g = image.createGraphics();
-            try {
-                g.setComposite(AlphaComposite.Src);
-                g.drawImage(original, 0, 0, null);
-            } finally {
-                g.dispose();
-            }
-        }
-
-        byte[] pixels = ((DataBufferByte) original.getRaster().getDataBuffer()).getData();
-        Mat mat = Mat.eye(original.getHeight(), original.getWidth(), matType);
-        mat.put(0, 0, pixels);
-        return mat;
-    }
-}
+//package cn.com.ctop.common.module.utils;
+//
+//import com.google.common.collect.Lists;
+//import org.bytedeco.javacpp.opencv_core;
+//import org.bytedeco.javacv.FFmpegFrameGrabber;
+//import org.bytedeco.javacv.Frame;
+//import org.bytedeco.javacv.Java2DFrameConverter;
+//import org.opencv.core.CvType;
+//import org.opencv.core.Mat;
+//import org.opencv.core.MatOfByte;
+//import org.opencv.imgcodecs.Imgcodecs;
+//import org.opencv.imgproc.Imgproc;
+//
+//import javax.imageio.ImageIO;
+//import java.awt.*;
+//import java.awt.image.BufferedImage;
+//import java.awt.image.DataBufferByte;
+//import java.io.ByteArrayInputStream;
+//import java.io.File;
+//import java.io.IOException;
+//import java.io.InputStream;
+//import java.util.List;
+//
+//public class JavacvUtil {
+//    /**
+//     * 视频文件指定时间段的帧截取
+//     * @param file
+//     * @param start
+//     * @param end
+//     */
+//    public static List<File> videoIntercept(File file, Integer start, Integer end) {
+//        Frame frame = null;
+//        List<File> files = Lists.newArrayList();
+//        FFmpegFrameGrabber fFmpegFrameGrabber = new FFmpegFrameGrabber(file);
+//        String filePath = "D://video//images//";
+//        String fileTargetName = "movie";
+//        try {
+//            fFmpegFrameGrabber.start();
+//            int ftp = fFmpegFrameGrabber.getLengthInFrames();
+//            for (int i=0 ; i < ftp ; i++){
+//                if( i >= start && i <= end){
+//                    frame = fFmpegFrameGrabber.grabImage();
+//                    doExecuteFrame(frame, filePath, fileTargetName, i ,files);
+//                }
+//            }
+//            fFmpegFrameGrabber.stop();
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        return files;
+//    }
+//
+//    public static void doExecuteFrame(Frame frame, String targetFilePath, String targetFileName, int index ,List<File> files) {
+//        if ( frame == null || frame.image == null) {
+//            return;
+//        }
+//        Java2DFrameConverter converter = new Java2DFrameConverter();
+//        String imageMat = "jpg";
+//        String fileName = targetFilePath + targetFileName + "_" + index + "." + imageMat;
+//        BufferedImage bi = converter.getBufferedImage(frame);
+//
+////        Mat img = Imgcodecs.imread("");
+////        Mat imgHSV = new Mat(img.rows(), img.cols(), CvType.CV_8UC3);
+////        Mat img2 = new Mat(img.rows(), img.cols(), CvType.CV_8UC3);
+//
+//        //转成HSV空间
+////        Imgproc.cvtColor(img, imgHSV, Imgproc.COLOR_BGR2HSV);
+////        //转回BGR空间
+////        Imgproc.cvtColor(imgHSV, img2, Imgproc.COLOR_HSV2BGR);
+//
+//        File output = new File(fileName);
+//        files.add(output);
+//        try{
+//            ImageIO.write(bi, imageMat, output);
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        }
+//    }
+//
+//    public static void main(String[] args) {
+//        List<File> files = videoIntercept(new File("C:\\Users\\宋英豪\\Desktop\\nfpHmswW.mp4"), 10, 100);
+//    }
+//
+//    /**
+//     * Mat转换成BufferedImage
+//     *
+//     * @param matrix
+//     *            要转换的Mat
+//     * @param fileExtension
+//     *            格式为 ".jpg", ".png", etc
+//     * @return
+//     */
+//    public static BufferedImage Mat2BufImg (Mat matrix, String fileExtension) {
+//        // convert the matrix into a matrix of bytes appropriate for
+//        // this file extension
+//        MatOfByte mob = new MatOfByte();
+//        Imgcodecs.imencode(fileExtension, matrix, mob);
+//        // convert the "matrix of bytes" into a byte array
+//        byte[] byteArray = mob.toArray();
+//        BufferedImage bufImage = null;
+//        try {
+//            InputStream in = new ByteArrayInputStream(byteArray);
+//            bufImage = ImageIO.read(in);
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        return bufImage;
+//    }
+//
+//    /**
+//     * BufferedImage转换成Mat
+//     *
+//     * @param original
+//     *            要转换的BufferedImage
+//     * @param imgType
+//     *            bufferedImage的类型 如 BufferedImage.TYPE_3BYTE_BGR
+//     * @param matType
+//     *            转换成mat的type 如 CvType.CV_8UC3
+//     */
+//    public static Mat BufImg2Mat (BufferedImage original, int imgType, int matType) {
+//        if (original == null) {
+//            throw new IllegalArgumentException("original == null");
+//        }
+//
+//        // Don't convert if it already has correct type
+//        if (original.getType() != imgType) {
+//
+//            // Create a buffered image
+//            BufferedImage image = new BufferedImage(original.getWidth(), original.getHeight(), imgType);
+//
+//            // Draw the image onto the new buffer
+//            Graphics2D g = image.createGraphics();
+//            try {
+//                g.setComposite(AlphaComposite.Src);
+//                g.drawImage(original, 0, 0, null);
+//            } finally {
+//                g.dispose();
+//            }
+//        }
+//
+//        byte[] pixels = ((DataBufferByte) original.getRaster().getDataBuffer()).getData();
+//        Mat mat = Mat.eye(original.getHeight(), original.getWidth(), matType);
+//        mat.put(0, 0, pixels);
+//        return mat;
+//    }
+//}

+ 1 - 1
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ByteDancePlanRuleDataJob.java

@@ -34,7 +34,7 @@ public class ByteDancePlanRuleDataJob {
     @XxlJob("bytedancePlanRuleLoadJob")
     public void execute() throws Exception {
         Date date = new Date();
-        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        List<CtopOauthToken> tokens = tokenService.queryTtValidRuleAccountsToken();
         tokens.forEach(token -> executorService.submit(()->{
             //1:删除历史数据
             Map<String,Object> params = new HashMap<>();

+ 21 - 1
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ByteDanceRefreshTokenJob.java

@@ -1,16 +1,22 @@
 package cn.com.ctop.job.bytedance.handler;
 
+import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.IRefreshTokenService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.HttpUtils;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.HashMap;
+import java.util.List;
+
 @Component
 public class ByteDanceRefreshTokenJob {
 
     @Autowired
     private IRefreshTokenService refreshTokenService;
-
+    private static final String REFRESH_AUTHNAME_URL = "http://api.tjyourong.com.cn/jeecg-boot/ctop/userAllocation/updateAuthName?";
     /**
      * 刷新token
      * @throws Exception
@@ -19,4 +25,18 @@ public class ByteDanceRefreshTokenJob {
     public void execute() throws Exception {
         refreshTokenService.byteDanceRefresh(null);
     }
+
+    @Autowired
+    private IUserAllocationService userAllocationService;
+
+    @XxlJob("refreshAuthName")
+    public void refreshAuthName() throws Exception {
+        List<UserAllocation> userAllocationList = userAllocationService.listByMediaId(null,0);
+        if(null!=userAllocationList&&!userAllocationList.isEmpty()){
+            userAllocationList.forEach(userAllocation -> {
+                String url = REFRESH_AUTHNAME_URL+"accountId="+userAllocation.getAccountId()+"&mediaId="+userAllocation.getMediaId();
+                HttpUtils.httpGet(url,new HashMap<>(),new HashMap<>());
+            });
+        }
+    }
 }

+ 68 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceCheckAccountReportJob.java

@@ -0,0 +1,68 @@
+package cn.com.ctop.job.bytedance.handler;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceCheckReportTaskInfoService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class BytedanceCheckAccountReportJob {
+    private ExecutorService executorService = Executors.newFixedThreadPool(10);
+    private CountDownLatch countDownLatch;
+    @Autowired
+    private IBytedanceCheckReportTaskInfoService checkReportTaskInfoService;
+    @XxlJob("initCheckReportJob")
+    public void initCheckReportJob() throws Exception {
+        String date = DateUtils.addDay(DateUtils.formatDate(),-1);
+        String param = XxlJobHelper.getJobParam();
+        if (param==null || param.trim().length()==0) {
+            param = date;
+        }
+        checkReportTaskInfoService.initTask(date);
+        //查询初始化的任务
+        List<BytedanceCheckReportTaskInfo>taskInfos = checkReportTaskInfoService.getListByParams(null,date,0);
+        if(null!=taskInfos&&!taskInfos.isEmpty()){
+            countDownLatch = new CountDownLatch(taskInfos.size());
+            taskInfos.forEach(taskInfo ->executorService.submit(()->{
+                try {
+                    checkReportTaskInfoService.checkCost(taskInfo);
+                }catch (Exception e){
+                }finally {
+                    countDownLatch.countDown();
+                }
+            }));
+            countDownLatch.await();
+            XxlJobHelper.log("{}数据初始化完成",date);
+        }
+    }
+
+    @XxlJob("refreshCheckReportJob")
+    public void refreshCheckReportJob() throws Exception {
+        //1:查询异常任务数据
+        List<BytedanceCheckReportTaskInfo>taskInfos = checkReportTaskInfoService.getListByParams(null,null,50001);
+        if(null!=taskInfos&&!taskInfos.isEmpty()){
+            countDownLatch = new CountDownLatch(taskInfos.size());
+            taskInfos.forEach(taskInfo -> {
+                try {
+                    checkReportTaskInfoService.reloadData(taskInfo);
+                    checkReportTaskInfoService.checkCost(taskInfo);
+                }catch (Exception e){
+                }finally {
+                    countDownLatch.countDown();
+                }
+            });
+            countDownLatch.await();
+            XxlJobHelper.log("数据更新完成");
+        }
+    }
+}

+ 19 - 1
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceEtlVideoJob.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.job.bytedance.handler;
 
+import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoEtlInfoService;
 import cn.com.ctop.toutiao.modules.report.service.IEtlBytedanceReportVideoDailyService;
 import com.xxl.job.core.handler.annotation.XxlJob;
@@ -42,7 +43,24 @@ public class BytedanceEtlVideoJob {
         etlBytedanceReportVideoDailyService.updBytedanceVideo();
     }
 
-    @XxlJob("etlBytedanceVideoJob")
+    @Autowired
+    private IETLReportBytedanceVideoService etlReportBytedanceVideoService;
+    @XxlJob("etlBytedanceVideoClipInfoJob")
+    public void etlBytedanceVideoClipInfoJob() throws Exception {
+        etlReportBytedanceVideoService.etlBytedanceVideoClipIdJob();
+    }
+
+    @XxlJob("etlBytedanceVideoPlanInfoJob")
+    public void etlBytedanceVideoPlanInfoJob() throws Exception {
+        etlReportBytedanceVideoService.etlBytedanceVideoPlanInfoJob();
+    }
+
+    @XxlJob("etlBytedanceVideoShotInfoJob")
+    public void etlBytedanceVideoShotInfoJob() throws Exception {
+        etlReportBytedanceVideoService.etlBytedanceVideoShotInfoJob();
+    }
+
+    @XxlJob("formatBytedance")
     public void etlBytedanceVideoJob() throws Exception {
         etlBytedanceReportVideoDailyService.etlBytedanceVideo();
     }

+ 1 - 1
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/RuleDataAccountCleanJob.java

@@ -28,7 +28,7 @@ public class RuleDataAccountCleanJob {
     @XxlJob("ruleDataAccountCleanJob")
     public void execute() throws Exception {
         XxlJobHelper.log("规则预警账户维度数据开始清洗");
-        List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
+        List<CtopOauthToken> tokens = oauthTokenService.queryTtValidRuleAccountsToken();
         tokens.forEach(token -> executorService.submit(()->{
             Map<String,Object> params = new HashMap<>();
             params.put("account_id",token.getAccountId());

+ 11 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEtlVideoJob.java

@@ -60,4 +60,15 @@ public class KuaishouEtlVideoJob {
             materialReportDailyService.etlKuaishouAccountMaterialReportInfo(DateUtils.formatDate(DateUtils.addDay(new Date(),-i)));
         }
     }
+
+    @XxlJob("etlKuaishouReportCompanyInfo")
+    public void etlKuaishouReportCompanyInfo(){
+        Date date = DateUtils.addDay(new Date(),-1);
+        materialReportDailyService.etlKuaishouReportCompanyInfo(DateUtils.formatDate(date));
+    }
+
+    @XxlJob("etlKuaishouVideoReportStateDate")
+    public void etlKuaishouVideoReportStateDate(){
+        materialReportDailyService.etlKuaishouVideoReportStateDate();
+    }
 }

+ 49 - 4
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouProjectVideoGetJob.java

@@ -1,10 +1,16 @@
 package cn.com.ctop.job.kuaishou.handler;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IProjectService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouProjectVideoGetService;
+import com.alibaba.fastjson.JSONObject;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -20,21 +26,60 @@ import java.util.concurrent.Executors;
  * @return
  * @throws
  */
+@Slf4j
 @Component
 public class KuaishouProjectVideoGetJob {
     @Autowired
     private IKuaishouProjectVideoGetService projectVideoGetService;
     @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+    @Autowired
     private IProjectService projectService;
-    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(10);
 
     @XxlJob("kuaishouProjectVideoGetJob")
-    public void kuaishouProjectVideoGetJob() {
+    public void execute() throws Exception {
+        log.info("同步素造素材供应商-------start");
+        kuaishouSupplierVideoGet();
+        Thread.sleep(60000);
+        log.info("清洗项目素材-------start");
+        kuaishouProjectVideoGet();
+    }
+
+
+    /**
+     * 获取供应商信息
+     */
+    private void kuaishouSupplierVideoGet() {
+        List<JSONObject> datas = videoGetService.getAccountIds();
+        for (JSONObject data : datas) {
+            CtopOauthToken token = tokenService.getTokenByAccountId(data.getLong("accountId"));
+            if (Check.isNull(token)) {
+                continue;
+            }
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    videoGetService.getSuZaoList(token.getAccessToken(), data.getLong("accountId"), 1, data.getString("startDate"));
+                }
+            });
+        }
+        XxlJobHelper.log("同步素造素材供应商完成");
+    }
+
+    /**
+     * 素材清洗
+     */
+    private void kuaishouProjectVideoGet() {
         //2快手,1开启的项目
-        List<Project> projects = projectService.listByMediaType(2, 1);
+        List<Project> projects = projectService.listByMediaType(2, 0);
         projects.forEach(project -> executorService.submit(() -> {
-            projectVideoGetService.clearProjectVideo(project.getId());
+            projectVideoGetService.clearProjectVideo(project.getId(), 1, null);
         }));
         XxlJobHelper.log("清洗项目素材完成");
     }
+
 }

+ 0 - 50
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouSupplierVideoGetJob.java

@@ -1,50 +0,0 @@
-package cn.com.ctop.job.kuaishou.handler;
-
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
-import com.alibaba.fastjson.JSONObject;
-import com.xxl.job.core.context.XxlJobHelper;
-import com.xxl.job.core.handler.annotation.XxlJob;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * 同步素造素材供应商
- *
- * @param
- * @author ZHAOXA
- * @return
- * @throws
- */
-@Component
-public class KuaishouSupplierVideoGetJob {
-    @Autowired
-    private IKuaiShouVideoGetService videoGetService;
-    @Autowired
-    private ICtopOauthTokenService tokenService;
-    static ExecutorService executorService = Executors.newFixedThreadPool(5);
-
-    @XxlJob("kuaishouSupplierVideoGetJob")
-    public void KuaishouSupplierVideoGetJob() {
-        List<JSONObject> datas = videoGetService.getAccountIds();
-        for (JSONObject data : datas) {
-            CtopOauthToken token = tokenService.getTokenByAccountId(data.getLong("accountId"));
-            if (Check.isNull(token)) {
-                continue;
-            }
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    videoGetService.getSuZaoList(token.getAccessToken(), data.getLong("accountId"), 1, data.getString("startDate"));
-                }
-            });
-        }
-        XxlJobHelper.log("同步素造素材供应商完成");
-    }
-}

+ 1 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataAccountCleanJob.java

@@ -27,7 +27,7 @@ public class RuleKuaiShouDataAccountCleanJob {
     @XxlJob("ruleKuaiShouDataAccountCleanJob")
     public void execute() throws Exception {
         XxlJobHelper.log("规则预警账户维度数据开始清洗");
-        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        List<CtopOauthToken> tokens = oauthTokenService.queryKsValidRuleAccountsToken();
         tokens.forEach(token -> executorService.submit(()->{
             Map<String,Object> params = new HashMap<>();
             params.put("account_id",token.getAccountId());

+ 1 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataPlanCleanJob.java

@@ -25,7 +25,7 @@ public class RuleKuaiShouDataPlanCleanJob {
     @XxlJob("ruleKuaiShouDataPlanCleanJob")
     public void execute() throws Exception {
         XxlJobHelper.log("规则预警计划维度数据开始清洗");
-        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        List<CtopOauthToken> tokens = oauthTokenService.queryKsValidRuleAccountsToken();
         tokens.forEach(token -> executorService.submit(()->{
             Map<String,Object> params = new HashMap<>();
             params.put("account_id",token.getAccountId());

+ 1 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataTargetCleanJob.java

@@ -28,7 +28,7 @@ public class RuleKuaiShouDataTargetCleanJob {
     @XxlJob("ruleKuaiShouDataTargetCleanJob")
     public void execute() throws Exception {
         XxlJobHelper.log("规则预警定向维度数据开始清洗");
-        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        List<CtopOauthToken> tokens = oauthTokenService.queryKsValidRuleAccountsToken();
         tokens.forEach(token -> executorService.submit(() ->{
             Map<String,Object>params = new HashMap<>();
             params.put("account_id",token.getAccountId());

+ 1 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataUnitCleanJob.java

@@ -30,7 +30,7 @@ public class RuleKuaiShouDataUnitCleanJob {
     @XxlJob("ruleKuaiShouDataUnitCleanJob")
     public void execute() throws Exception {
         XxlJobHelper.log("规则预警组维度数据开始清洗");
-        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        List<CtopOauthToken> tokens = oauthTokenService.queryKsValidRuleAccountsToken();
         tokens.forEach(token -> executorService.submit(() -> {
             Map<String,Object>params = new HashMap<>();
             params.put("account_id",token.getAccountId());

+ 93 - 44
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouVideoDirectionalPackageController.java

@@ -1,43 +1,47 @@
 package cn.com.ctop.kuaishou.modules.ai.controller;
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.QueryGenerator;
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouVideoDirectionalPackage;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouVideoDirectionalPackageService;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import org.jeecg.common.api.vo.Result;
-import cn.com.ctop.common.module.utils.QueryGenerator;
-import org.jeecg.common.util.oConvertUtils;
-
-import java.util.Date;
-
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.oConvertUtils;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
-
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
-import com.alibaba.fastjson.JSON;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 素材绑定的定向包模板
@@ -49,11 +53,12 @@ import io.swagger.annotations.ApiOperation;
 @Slf4j
 @Api(tags = "素材绑定的定向包模板")
 @RestController
-@RequestMapping("/kuais/kuaishouVideoDirectionalPackage")
+@RequestMapping("/kuaishouVideoDirectionalPackage")
 public class KuaishouVideoDirectionalPackageController {
     @Autowired
     private IKuaishouVideoDirectionalPackageService kuaishouVideoDirectionalPackageService;
-
+    @Autowired
+    private IUserAllocationService userAllocationService;
     /**
      * 分页列表查询
      *
@@ -77,27 +82,45 @@ public class KuaishouVideoDirectionalPackageController {
         result.setResult(pageList);
         return result;
     }
-	/**
-	 * 创建定向包
-	 *
-	 * @param
-	 * @return
-	 */
-	@PostMapping(value = "/createDirectionalPackage")
-	public Result<Object> createDirectionalPackage(@RequestBody JSONObject requestJson) {
-		Result<JSONObject> result = new Result<>();
-		try {
-			Long accountId = requestJson.getLong("projectId");
-			if (Check.isNull(accountId)) {
-				return Result.error("请选择账户id");
-			}
-//			return kuaishouVideoDirectionalPackageService.saveOrUpdate(null);
-		} catch (Exception e) {
-			log.error("创建定向包失败", e);
-			return Result.error("创建失败" + e.getMessage());
-		}
-		return null;
-	}
+
+    /**
+     * 创建定向包
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/saveOrUpdate")
+    public Result<Object> saveOrUpdate(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            String videoGetId = requestJson.getString("videoGetId");
+            if (Check.isNull(videoGetId)) {
+                return Result.error("请选择素材");
+            }
+            KuaishouVideoDirectionalPackage directionalPackage = JSONObject.toJavaObject(requestJson, KuaishouVideoDirectionalPackage.class);
+            if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
+                directionalPackage.setKeyword(JSONObject.toJSONString(requestJson.getJSONArray("keyword")));
+            }
+            kuaishouVideoDirectionalPackageService.saveOrUpdate(directionalPackage);
+            String id = "";
+            if (!Check.isNull(directionalPackage.getId())) {
+                id = directionalPackage.getId();
+            } else {
+                QueryWrapper<KuaishouVideoDirectionalPackage> queryWrapper = new QueryWrapper<>();
+                queryWrapper.eq("video_get_id", videoGetId);
+                queryWrapper.eq("signature", directionalPackage.getSignature());
+                KuaishouVideoDirectionalPackage one = kuaishouVideoDirectionalPackageService.getOne(queryWrapper);
+                if(!Check.isNull(one)){
+                    id = one.getId();
+                }
+            }
+            return Result.ok(id);
+        } catch (Exception e) {
+            log.error("创建定向包失败", e);
+            return Result.error("创建失败" + e.getMessage());
+        }
+    }
+
     /**
      * 编辑
      *
@@ -179,6 +202,32 @@ public class KuaishouVideoDirectionalPackageController {
     }
 
     /**
+     * 查询素材定向
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/queryDirctional")
+    public Result<Object> queryDirctional(String id) {
+        if (Check.isNull(id)) {
+            return Result.error("缺失参数");
+        }
+        Result<KuaishouVideoDirectionalPackage> result = new Result<>();
+        QueryWrapper<KuaishouVideoDirectionalPackage> advertiserQueryWrapper = new QueryWrapper<>();
+        advertiserQueryWrapper.eq("video_get_id", id);
+        KuaishouVideoDirectionalPackage kuaishouVideoDirectionalPackage = kuaishouVideoDirectionalPackageService.getOne(advertiserQueryWrapper);
+        if (kuaishouVideoDirectionalPackage == null) {
+            return Result.ok("该素材未配置定向");
+        } else {
+            JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(kuaishouVideoDirectionalPackage)).toJavaObject(JSONObject.class);
+            if (!Check.isNull(data.getString("keyword"))) {
+                data.put("keyword", data.getJSONArray("keyword"));
+            }
+            return Result.ok(data);
+        }
+    }
+
+    /**
      * 导出excel
      *
      * @param request

+ 8 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAdvertiserStrategy.java

@@ -47,10 +47,18 @@ public class AiKuaishouAdvertiserStrategy {
      */
     private Integer campaignType;
     /**
+     * 计划状态
+     */
+    private Integer campaignStatus;
+    /**
      * 客户要求的广告组名称规范
      */
     private String groupName;
     /**
+     * 组状态
+     */
+    private Integer groupStatus;
+    /**
      * 定向模板id
      */
     private Integer templateId;

+ 4 - 8
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouVideoDirectionalPackage.java

@@ -31,15 +31,11 @@ public class KuaishouVideoDirectionalPackage {
     /**
      * 账户ID
      */
-    @Excel(name = "账户ID", width = 15)
-    @ApiModelProperty(value = "账户ID")
+    @Excel(name = "素材get表主键ID", width = 15)
+    @ApiModelProperty(value = "素材get表主键ID")
     private String videoGetId;
-    /**
-     * 0无效,1有效
-     */
-    @Excel(name = "0无效,1有效", width = 15)
-    @ApiModelProperty(value = "0无效,1有效")
-    private Integer dataStatus;
+
+    private String signature;
     /**
      * 地域
      */

+ 13 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -802,9 +802,9 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             List<KuaiShouVideoGet> customVideos = new ArrayList<>();
 
             if (Check.isNull(strategy.getMaterialKeyword())) {
-                generalVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), "all", null);
+                customVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), "all", null);
                 //2:查询特定素材
-                customVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), appInfo.getAppVersion(), null);
+                generalVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), appInfo.getAppVersion(), null);
             } else { //  tt语音特殊素材查询
                 generalVideos = videoGetService.getNewVideoBetweenTime(strategy.getAccountId(), startTime, endTime, strategy.getChannelType(), strategy.getMaterialKeyword(), null);
 
@@ -870,6 +870,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     @Autowired
     private IKuaiShouCampaignService campaignService;
 
+
     private List<KuaiShouVideoGet> getVideosByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo, Integer createType, Long videoCnt) {
         if (createType == 1) {
             return getNewVideoListByParams(strategy, startTime, endTime, appInfo);
@@ -916,9 +917,15 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             aiKuaishouCampaignLevelOperationRecordService.saveOrUpdate(record);
             return null;
         }
+
         campaignId = (Long) campaignCreateResult.get("campaignId");
         record.setCampaignId(campaignId);
         aiKuaishouCampaignLevelOperationRecordService.saveOrUpdate(record);
+        Integer campaignStatus = strategy.getCampaignStatus();
+        if (!Check.isNull(campaignStatus) && campaignStatus == 2) {
+            updateService.updateCampaignStatus(token.getAccessToken(), token.getAccountId(), campaignId, campaignStatus, "yumeng");
+        }
+
         return campaignId;
     }
 
@@ -934,6 +941,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         unitParams.put("unit_name", unitName);
         //出价类型
         unitParams.put("bid_type", strategy.getBidType());
+        if (!Check.isNull(strategy.getGroupStatus()) && strategy.getGroupStatus() == 2) {
+            unitParams.put("put_status", strategy.getGroupStatus());
+
+        }
 
         //组单日预算
         if (null != strategy.getUnitDayBudget() && strategy.getUnitDayBudget() != 0) {

+ 4 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouLandpagePackageServiceImpl.java

@@ -26,6 +26,7 @@ import org.jeecg.common.system.vo.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -41,14 +42,14 @@ import java.util.Map;
 @Service
 public class KuaishouLandpagePackageServiceImpl extends ServiceImpl<KuaishouLandpagePackageMapper, KuaishouLandpagePackage> implements IKuaishouLandpagePackageService {
 
-    @Autowired
+    @Resource
     private KuaishouLandpagePackageMapper landpagePackageMapper;
-    @Autowired
+    @Resource
     private KuaishouLandpagePackageRelMapper landpagePackageRelMapper;
     @Autowired
     private KuaishouLandpagePackageRelServiceImpl landpagePackageRelService;
 
-    @Autowired
+    @Resource
     private UserAllocationMapper userAllocationMapper;
     @Autowired
     private ICtopOauthTokenService oauthTokenService;

+ 36 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouVideoGetController.java

@@ -27,7 +27,15 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
@@ -37,7 +45,12 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 快手-获取视频接口
@@ -80,6 +93,25 @@ public class KuaiShouVideoGetController {
         return result;
     }
 
+    /**
+     * 真人、制作标签素材统计报表
+     *
+     * @return
+     */
+    @GetMapping(value = "/labelMaterialList")
+    public Result<Object> labelMaterialList(String realname, String roleCode, String startTime, String endTime, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(startTime) || Check.isNull(endTime)) {
+                return Result.error("请选择查询日期");
+            }
+            return kuaiShouReportDailyMaterialService.labelMaterialList(realname, roleCode, startTime, endTime, pageNo, pageSize);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+
+    }
+
 
     @GetMapping(value = "/getVideoList")
     public Result<PageInfo<KuaiShouVideoGetVo>> getVideoList(Long accountId,
@@ -116,8 +148,8 @@ public class KuaiShouVideoGetController {
             requestMap.put("orderBy", orderBy);
             requestMap.put("materialType", materialType);
             requestMap.put("channelType", channelType);
-            if(!Check.isNull(signatures)){
-                String[] signatureArray =  signatures.split(",");
+            if (!Check.isNull(signatures)) {
+                String[] signatureArray = signatures.split(",");
                 requestMap.put("signatureList", signatureArray);
             }
             if ("time".equals(orderBy)) {

+ 89 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouProjectVideoGetController.java

@@ -4,8 +4,11 @@ import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.QueryGenerator;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProjectVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouProjectVideoGetService;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -53,6 +56,8 @@ import java.util.Map;
 public class KuaishouProjectVideoGetController {
     @Autowired
     private IKuaishouProjectVideoGetService kuaishouProjectVideoGetService;
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
 
     /**
      * 分页列表查询
@@ -75,6 +80,26 @@ public class KuaishouProjectVideoGetController {
     }
 
     /**
+     * 素材关联被拒创意
+     */
+    @GetMapping(value = "/queryCreativeByVideo")
+    public Result<Object> queryCreativeByVideo(String signature, Long projectId, Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(signature) || Check.isNull(projectId)) {
+                return Result.error("缺失参数");
+            }
+            List<String> photoIds = videoGetService.queryPhotoIdsByProjectAndMd5(projectId, signature, null);
+            if (!Check.isNull(photoIds)) {
+                return kuaishouProjectVideoGetService.queryCreativeBySignature(photoIds, accountId, pageNo, pageSize);
+            }
+            return Result.ok("没有查询到素材");
+        } catch (Exception e) {
+            e.printStackTrace();
+            return Result.error("查询失败");
+        }
+    }
+
+    /**
      * 素材数量统计
      *
      * @return
@@ -93,18 +118,77 @@ public class KuaishouProjectVideoGetController {
     }
 
     /**
+     * 下架素材
+     *
+     * @return
+     */
+    @PostMapping(value = "/offShelfVideo")
+    public Result<Object> offShelfVideo(@RequestBody JSONObject data) {
+        try {
+            if (Check.isNull(data.getString("id"))) {
+                return Result.error("缺失参数");
+            }
+            KuaishouProjectVideoGet videoGet = new KuaishouProjectVideoGet();
+            videoGet.setStatus(1);
+            videoGet.setId(data.getString("id"));
+            kuaishouProjectVideoGetService.updateById(videoGet);
+            return Result.ok("success");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("下架失败");
+    }
+
+    /**
+     * 下架素材
+     *
+     * @return
+     */
+    @PostMapping(value = "/offShelfVideos")
+    public Result<Object> offShelfVideos(@RequestBody JSONObject data) {
+        try {
+            Long projectId = data.getLong("projectId");
+            if (Check.isNull(projectId)) {
+                return Result.error("请选择项目");
+            }
+            JSONArray accountId = data.getJSONArray("accountId");
+            if (Check.isNull(accountId)) {
+                return Result.error("请选择账户");
+            }
+            String signature = data.getString("signature");
+            if (Check.isNull(signature)) {
+                return Result.error("请选择下架的视频");
+            }
+            KuaishouProjectVideoGet videoGet = new KuaishouProjectVideoGet();
+            QueryWrapper<KuaishouProjectVideoGet> queryWrapper = new QueryWrapper<>();
+            videoGet.setStatus(1);
+            queryWrapper.eq("project_id", projectId);
+            queryWrapper.eq("signature", signature);
+            kuaishouProjectVideoGetService.update(videoGet, queryWrapper);
+            List<String> photoIds = videoGetService.queryPhotoIdsByProjectAndMd5(projectId, signature, accountId);
+            for (Object photoId : photoIds) {
+                kuaishouProjectVideoGetService.deleteCreativesByPhotoId(photoId);
+            }
+            return Result.ok("success");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("下架失败");
+    }
+
+    /**
      * 素材详情数据
      * put_start_time
      *
      * @return
      */
     @GetMapping(value = "/getVideoDetails")
-    public Result<Object> getVideoDetails(String signature) {
+    public Result<Object> getVideoDetails(String signature, String id) {
         try {
-            if (Check.isNull(signature)) {
-                return Result.error("请选择素材");
+            if (Check.isNull(signature) || Check.isNull(id)) {
+                return Result.error("缺失参数");
             }
-            return kuaishouProjectVideoGetService.getVideoDetails(signature);
+            return kuaishouProjectVideoGetService.getVideoDetails(signature, id);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -157,7 +241,7 @@ public class KuaishouProjectVideoGetController {
     @GetMapping(value = "/clearProjectVideo")
     public Result<Object> clearProjectVideo(Long projectId) {
         try {
-            kuaishouProjectVideoGetService.clearProjectVideo(projectId);
+            kuaishouProjectVideoGetService.clearProjectVideo(projectId,1,null);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }

+ 6 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouProjectVideoGet.java

@@ -47,12 +47,6 @@ public class KuaishouProjectVideoGet {
     @ApiModelProperty(value = "0 可用 1 删除")
     private Integer status;
     /**
-     * 视频id
-     */
-    @Excel(name = "视频id", width = 15)
-    @ApiModelProperty(value = "视频id")
-    private String photoId;
-    /**
      * 宽
      */
     @Excel(name = "宽", width = 15)
@@ -82,6 +76,7 @@ public class KuaishouProjectVideoGet {
     @Excel(name = "1 竖版视频 2 横版视频", width = 15)
     @ApiModelProperty(value = "1 竖版视频 2 横版视频")
     private Integer materialType;
+
     /**
      * 0:自产 1:素造
      */
@@ -113,6 +108,11 @@ public class KuaishouProjectVideoGet {
      * 允许投放结束时间
      */
     private String putEndTime;
+    private String supplierAccountName;
+    private Long supplierAccountId;
+
+    private String materialTag;
+
     /**
      * 创建时间
      */

+ 6 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCreativeMapper.java

@@ -34,4 +34,10 @@ public interface KuaiShouCreativeMapper extends BaseMapper<KuaiShouCreative> {
     Integer getRejectedCountsforAccountId(Long accountId);
 
     String getClickTrackUrl(@Param("accountId") Long accountId, @Param("unitId") Long unitId);
+
+    Long queryCreativeByPhotoIdTotal(@Param("photoIds")  List<String> photoIds, @Param("accountId") Long accountId);
+
+    List<JSONObject> queryCreativeByPhotoId(@Param("photoId") String photoId);
+
+    List<JSONObject> queryCreativeByPhotoIds(@Param("photoIds") List<String> photoIds, @Param("accountId") Long accountId);
 }

+ 9 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouReportDailyMaterialMapper.java

@@ -31,11 +31,17 @@ public interface KuaiShouReportDailyMaterialMapper extends BaseMapper<KuaiShouRe
 
     void batchReplace(@Param("addList") List<KuaiShouReportDailyMaterial> addList);
 
-    KuaiShouReportDailyMaterial getEtlDataByParams(@Param("signature")String signature, @Param("date") String date,@Param("projectId")Long projectId);
+    KuaiShouReportDailyMaterial getEtlDataByParams(@Param("signature") String signature, @Param("date") String date, @Param("projectId") Long projectId);
 
-    List<KuaiShouReportDailyMaterial> getSignatureByDate(@Param("date")String date);
+    List<KuaiShouReportDailyMaterial> getSignatureByDate(@Param("date") String date);
 
-    List<KuaiShouReportDailyMaterial> getSignatureByDateGroupByProjectId(@Param("date")String date);
+    List<KuaiShouReportDailyMaterial> getSignatureByDateGroupByProjectId(@Param("date") String date);
 
     List<JSONObject> getVideoInfoByList(@Param("photoIdList") List<Long> photoIdList);
+
+    Long labelMaterialListTotal(@Param("realname") String realname, @Param("roleCode") String roleCode, @Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    List<JSONObject> labelMaterialList(@Param("realname") String realname, @Param("roleCode") String roleCode, @Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    JSONObject labelMaterialAll(@Param("realname") String realname, @Param("roleCode") String roleCode, @Param("startTime") String startTime, @Param("endTime") String endTime);
 }

+ 7 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouVideoGetMapper.java

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.batch.mapper;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProjectVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -42,13 +43,15 @@ public interface KuaiShouVideoGetMapper extends BaseMapper<KuaiShouVideoGet> {
 
     Integer getHotMoneyCountByAccountId(Long accountId);
 
-    List<KuaiShouVideoGet> getZeroVideoByParams(@Param("accountId")Long accountId, @Param("startTime")String startTime, @Param("endTime")String endTime, @Param("videoCnt")Long videoCnt,@Param("appVersion")String appVersion,@Param("channelType")Integer channelType,@Param("relativeCnt")Integer relativeCnt);
+    List<KuaiShouVideoGet> getZeroVideoByParams(@Param("accountId") Long accountId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("videoCnt") Long videoCnt, @Param("appVersion") String appVersion, @Param("channelType") Integer channelType, @Param("relativeCnt") Integer relativeCnt);
 
-    List<KuaiShouVideoGet> getHistoryTopVideoByParams(@Param("accountId")Long accountId, @Param("startTime")String startTime, @Param("endTime")String endTime, @Param("videoCnt")Long videoCnt,@Param("appVersion")String appVersion,@Param("channelType")Integer channelType);
+    List<KuaiShouVideoGet> getHistoryTopVideoByParams(@Param("accountId") Long accountId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("videoCnt") Long videoCnt, @Param("appVersion") String appVersion, @Param("channelType") Integer channelType);
 
-    List<KuaishouProjectVideoGet> selectProjectVideo(@Param("projectId") Long projectId,@Param("updateTime") String updateTime);
+    List<KuaishouProjectVideoGet> selectProjectVideo(@Param("projectId") Long projectId, @Param("updateTime") String updateTime);
 
-    void updateBatch(@Param(value = "videoGetList")  List<KuaiShouVideoGet> videoGetList);
+    void updateBatch(@Param(value = "videoGetList") List<KuaiShouVideoGet> videoGetList);
 
     List<JSONObject> getAccountIds();
+
+    List<String> queryPhotoIdsByProjectAndMd5(@Param("projectId") Long projectId, @Param("signature") String signature, @Param("accountId") JSONArray accountId);
 }

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouProjectVideoGetMapper.java

@@ -17,7 +17,7 @@ import java.util.Map;
  */
 public interface KuaishouProjectVideoGetMapper extends BaseMapper<KuaishouProjectVideoGet> {
 
-    void replaceBatch(@Param("list") List<KuaishouProjectVideoGet> list);
+    void replaceBatch(@Param("dataList") List<KuaishouProjectVideoGet> list);
 
     String queryLatestUpdateTime(@Param("projectId") Long projectId);
 
@@ -27,7 +27,7 @@ public interface KuaishouProjectVideoGetMapper extends BaseMapper<KuaishouProjec
 
     JSONObject getVideoTotalNumber(Map<String, Object> paramsMap);
 
-    JSONObject getVideoDetails(@Param("signature") String signature);
+    JSONObject getVideoDetails(@Param("signature") String signature,@Param("id") String id);
 
     Long getAccountVideosTotal(@Param("signature") String signature, @Param("projectId") Long projectId);
 

+ 51 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml

@@ -170,4 +170,55 @@
 
     </select>
 
+    <select id="queryCreativeByPhotoIdTotal" resultType="java.lang.Long">
+        SELECT
+            IFNULL(COUNT(1),0)
+        FROM ctop_kuaishou_creative t1
+        WHERE t1.photo_id in
+        <foreach collection="photoIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        <if test="accountId!=null">
+            and  t1.account_id = #{accountId}
+        </if>
+        and t1.status = 42
+    </select>
+
+
+    <select id="queryCreativeByPhotoId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            IFNULL(t2.auth_name,'') 'authName',
+            IFNULL(t1.account_id,'') 'accountId',
+            IFNULL(t1.creative_id,'') 'creativeId',
+            IFNULL(t1.creative_name,'') 'creativeName',
+            IFNULL(t1.cover_url,'') 'coverUrl',
+            IFNULL(t1.description,'') 'description',
+            IFNULL(t1.review_detail,'') 'reviewDetail'
+        FROM ctop_kuaishou_creative t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        WHERE t1.photo_id = #{photoId}
+    </select>
+
+    <select id="queryCreativeByPhotoIds" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            IFNULL(t2.auth_name,'') 'authName',
+            IFNULL(t1.account_id,'') 'accountId',
+            IFNULL(t1.creative_id,'') 'creativeId',
+            IFNULL(t1.creative_name,'') 'creativeName',
+            IFNULL(t1.cover_url,'') 'coverUrl',
+            IFNULL(t1.description,'') 'description',
+            IFNULL(t1.review_detail,'') 'reviewDetail'
+        FROM ctop_kuaishou_creative t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        WHERE t1.photo_id in
+        <foreach collection="photoIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        <if test="accountId!=null">
+            and  t1.account_id = #{accountId}
+        </if>
+        and t1.status = 42
+    </select>
 </mapper>

+ 451 - 79
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml

@@ -136,17 +136,37 @@
 
 
     <insert id="loadMaterialDailyReport">
-		LOAD DATA local INFILE  #{localPath}
-	    INTO TABLE ctop_kuaishou_report_daily_material
-		FIELDS TERMINATED BY ',' enclosed by '"' LINES TERMINATED BY '\n'
-		IGNORE 1 LINES
-		(photo_id,
-		image_token,
-		cover_url,
-		photo_url,
-		@photo_caption,
-		@creative_material_type_string,
-        @ad_scene,
+        LOAD
+        DATA local INFILE
+        #{localPath}
+        INTO
+        TABLE
+        ctop_kuaishou_report_daily_material
+        FIELDS
+        TERMINATED
+        BY
+        ','
+        enclosed
+        by
+        '"'
+        LINES
+        TERMINATED
+        BY
+        '\n'
+        IGNORE
+        1
+        LINES
+        (
+        photo_id,
+        image_token,
+        cover_url,
+        photo_url,
+        @
+        photo_caption,
+        @
+        creative_material_type_string,
+        @
+        ad_scene,
         charge,
         photo_show,
         aclick,
@@ -164,13 +184,15 @@
         activation,
         submit,
         stat_date,
-        @stat_hour,
+        @
+        stat_hour,
         photo_click,
         photo_click_ratio,
         action_ratio,
         impression_1k_cost,
         photo_click_cost,
-        @click_1k_cost,
+        @
+        click_1k_cost,
         action_cost,
         event_pay_first_day,
         event_pay_purchase_amount_first_day,
@@ -201,43 +223,81 @@
         event_next_day_stay_ratio,
         event_next_day_stay,
         play_3s_ratio,
-        @event_valid_clues,
-        @event_valid_clues_cost,
-        @ad_product_cnt,
-        @event_goods_view,
-        @merchant_reco_fans,
-        @event_order_amount_roi,
-        @event_goods_view_cost,
-        @merchant_reco_fans_cost,
-        @event_new_user_pay,
-        @event_new_user_pay_cost,
-        @event_new_user_pay_ratio,
-        @event_button_click,
-        @event_button_click_cost,
-        @event_button_click_ratio,
-        @play_5s_ratio,
-        @play_end_ratio,
-        @event_order_paid_roi,
-        @event_new_user_jinjian_app,
-        @event_new_user_jinjian_app_cost,
-        @event_new_user_jinjian_app_roi,
-        @event_new_user_credit_grant_app,
-        @event_new_user_credit_grant_app_cost,
-        @event_new_user_credit_grant_app_roi,
-        @event_new_user_jinjian_page,
-        @event_new_user_jinjian_page_cost,
-        @event_new_user_jinjian_page_roi,
-        @event_new_user_credit_grant_page,
-        @event_new_user_credit_grant_page_cost,
-        @event_new_user_credit_grant_page_roi,
-        @event_appoint_form,
-        @event_appoint_form_cost,
-        @event_appoint_form_ratio,
-        @event_appoint_jump_click,
-        @event_appoint_jump_click_cost,
-        @event_appoint_jump_click_ratio
+        @
+        event_valid_clues,
+        @
+        event_valid_clues_cost,
+        @
+        ad_product_cnt,
+        @
+        event_goods_view,
+        @
+        merchant_reco_fans,
+        @
+        event_order_amount_roi,
+        @
+        event_goods_view_cost,
+        @
+        merchant_reco_fans_cost,
+        @
+        event_new_user_pay,
+        @
+        event_new_user_pay_cost,
+        @
+        event_new_user_pay_ratio,
+        @
+        event_button_click,
+        @
+        event_button_click_cost,
+        @
+        event_button_click_ratio,
+        @
+        play_5s_ratio,
+        @
+        play_end_ratio,
+        @
+        event_order_paid_roi,
+        @
+        event_new_user_jinjian_app,
+        @
+        event_new_user_jinjian_app_cost,
+        @
+        event_new_user_jinjian_app_roi,
+        @
+        event_new_user_credit_grant_app,
+        @
+        event_new_user_credit_grant_app_cost,
+        @
+        event_new_user_credit_grant_app_roi,
+        @
+        event_new_user_jinjian_page,
+        @
+        event_new_user_jinjian_page_cost,
+        @
+        event_new_user_jinjian_page_roi,
+        @
+        event_new_user_credit_grant_page,
+        @
+        event_new_user_credit_grant_page_cost,
+        @
+        event_new_user_credit_grant_page_roi,
+        @
+        event_appoint_form,
+        @
+        event_appoint_form_cost,
+        @
+        event_appoint_form_ratio,
+        @
+        event_appoint_jump_click,
+        @
+        event_appoint_jump_click_cost,
+        @
+        event_appoint_jump_click_ratio
         )
-          set account_id = #{accountId}
+        set
+        account_id
+        =
+        #{accountId}
     </insert>
 
     <select id="getPhotoList" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterialVo">
@@ -256,24 +316,19 @@
 
     <select id="getPhotoListByDate"
             resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterialVo">
-        select
-        id as id,
-        photo_id as photoId
-        from
-        ctop_kuaishou_report_daily_material
+        select id       as id,
+               photo_id as photoId
+        from ctop_kuaishou_report_daily_material
         WHERE stat_date = #{statDate}
-        and signature is null
+          and signature is null
         group by photo_id
     </select>
 
     <select id="getVideoGetByPhotoId" resultType="cn.com.ctop.kuaishou.modules.report.entity.VideoGetvo">
-      select
-      signature as 'signature',
-      channel_type as 'channelType'
-      from ctop_kuaishou_video_get
-      where photo_id = #{photoId}
-      and signature is not null
-      limit 1
+        select signature as 'signature', channel_type as 'channelType'
+        from ctop_kuaishou_video_get
+        where photo_id = #{photoId}
+          and signature is not null limit 1
     </select>
 
 
@@ -348,28 +403,21 @@
     </select>
     <select id="getSignatureByDate"
             resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial">
-        select
-            distinct signature
-        from
-        ctop_kuaishou_report_daily_material
-        where
-            signature is not null
-        and
-            signature != ''
+        select distinct signature
+        from ctop_kuaishou_report_daily_material
+        where signature is not null
+          and signature != ''
         and
             stat_date = #{date}
     </select>
     <select id="getSignatureByDateGroupByProjectId"
             resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial">
-        select
-    distinct signature,project_id
-from
-    ctop_kuaishou_report_daily_material report
-    left join ctop_user_allocation allocation on report.account_id = allocation.account_id
-where
-    signature is not null
-    and
-    signature != ''
+        select distinct signature,
+                        project_id
+        from ctop_kuaishou_report_daily_material report
+                 left join ctop_user_allocation allocation on report.account_id = allocation.account_id
+        where signature is not null
+          and signature != ''
     and
     stat_date = #{date}
     </select>
@@ -387,5 +435,329 @@ where
         and signature is not null
         group by photo_id
     </select>
+
+    <select id="labelMaterialListTotal" resultType="java.lang.Long">
+        SELECT IFNULL(COUNT(1),0) FROM
+        (
+        SELECT
+        t1.user_id
+        FROM ctop_material_tag_info t1
+        LEFT JOIN ctop_tag_info t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_kuaishou_video_get t4 ON t4.signature= t1.code
+        INNER JOIN(
+        SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
+        LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
+        LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        WHERE 1=1
+        <if test="realname!=null">
+            and tt1.realname LIKE CONCAT('%',#{realname},'%')
+        </if>
+        <if test="roleCode!=null">
+            AND tt3.role_code = #{roleCode}
+        </if>
+        ) t3 ON t3.id = t1.user_id
+        WHERE t2.parent_id in(60155,60156)
+        AND t4.stat_date &gt;= #{startTime}
+        AND t4.stat_date &lt;= concat(#{endTime},' 23:59:59')
+        GROUP BY t1.user_id
+        ) t
+    </select>
+
+    <select id="labelMaterialList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        k.user_id,
+        k.realname,
+        k.role_name 'roleName',
+        IFNULL(k1.zhenren_charge,0)as 'zhenrenCharge',
+        IFNULL(k2.zhenren_number,0)as 'zhenrenNumber',
+        IFNULL(ROUND(k1.zhenren_charge/k2.zhenren_number,2),0) as 'zhenrenCost',
+        IFNULL(k3.zhizuo_charge,0)as 'zhizuoCharge',
+        IFNULL(k4.zhizuo_number,0)as 'zhizuoNumber',
+        IFNULL(ROUND(k3.zhizuo_charge/k4.zhizuo_number,2),0) as 'zhizuoCost'
+        FROM
+        (SELECT
+        t1.user_id,
+        t3.realname,
+        t3.role_name
+        FROM ctop_material_tag_info t1
+        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_kuaishou_video_get t4 ON t4.signature= t1.code
+        INNER JOIN(
+        SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
+        LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
+        LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        WHERE 1=1
+        <if test="realname!=null">
+            and tt1.realname LIKE CONCAT('%',#{realname},'%')
+        </if>
+        <if test="roleCode!=null">
+            AND tt3.role_code = #{roleCode}
+        </if>
+        ) t3 ON t3.id = t1.user_id
+        WHERE t2.parent_id in(60155,60156)
+        AND t4.stat_date &gt;=  #{startTime}
+        AND t4.stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        GROUP BY t1.user_id
+        ) k
+        LEFT JOIN
+        (
+            SELECT
+        t1.user_id, SUM(t5.charge) 'zhenren_charge'
+        FROM ctop_material_tag_info t1
+        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_kuaishou_video_get t4 ON t4.signature= t1.`code`
+        INNER JOIN(
+        SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
+        LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
+        LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        WHERE 1=1
+        <if test="realname!=null">
+            and tt1.realname LIKE CONCAT('%',#{realname},'%')
+        </if>
+        <if test="roleCode!=null">
+            AND tt3.role_code = #{roleCode}
+        </if>
+        ) t3 ON t3.id = t1.user_id
+        LEFT JOIN ctop_kuaishou_report_daily_material t5 ON  t1.`code` = t5.signature
+        WHERE 1=1
+        AND t4.stat_date &gt;=  #{startTime}
+        AND t4.stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        AND t2.parent_id = 60155
+        GROUP BY t1.user_id
+        ) k1 ON k1.user_id =k.user_id
+        LEFT JOIN
+        (SELECT user_id, COUNT(1) 'zhenren_number' FROM (
+        SELECT
+        t1.user_id,t4.signature
+        FROM ctop_material_tag_info t1
+        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_kuaishou_video_get t4 ON t4.signature= t1.`code`
+        INNER JOIN(
+        SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
+        LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
+        LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        WHERE 1=1
+        <if test="realname!=null">
+            and tt1.realname LIKE CONCAT('%',#{realname},'%')
+        </if>
+        <if test="roleCode!=null">
+            AND tt3.role_code = #{roleCode}
+        </if>
+        ) t3 ON t3.id = t1.user_id
+        WHERE 1=1
+        AND t4.stat_date &gt;=  #{startTime}
+        AND t4.stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        AND t2.parent_id = 60155
+        GROUP BY t1.user_id,t1.`code`
+        ) t
+        GROUP BY user_id
+        )k2 ON k.user_id = k2.user_id
+        LEFT JOIN
+        (
+        SELECT
+        t1.user_id, SUM(t5.charge) 'zhizuo_charge'
+        FROM ctop_material_tag_info t1
+        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_kuaishou_video_get t4 ON t4.signature= t1.`code`
+        INNER JOIN(
+        SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
+        LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
+        LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        WHERE 1=1
+        <if test="realname!=null">
+            and tt1.realname LIKE CONCAT('%',#{realname},'%')
+        </if>
+        <if test="roleCode!=null">
+            AND tt3.role_code = #{roleCode}
+        </if>
+        ) t3 ON t3.id = t1.user_id
+        LEFT JOIN ctop_kuaishou_report_daily_material t5 ON  t1.`code` = t5.signature
+        WHERE 1=1
+        AND t4.stat_date &gt;=  #{startTime}
+        AND t4.stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        AND t2.parent_id = 60156
+        GROUP BY t1.user_id
+        )k3 ON k3.user_id =k.user_id
+        LEFT JOIN
+        (SELECT user_id, COUNT(1) 'zhizuo_number' FROM (
+        SELECT
+        t1.user_id,t4.signature
+        FROM ctop_material_tag_info t1
+        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_kuaishou_video_get t4 ON t4.signature= t1.`code`
+        INNER JOIN(
+        SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
+        LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
+        LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        WHERE 1=1
+        <if test="realname!=null">
+            and tt1.realname LIKE CONCAT('%',#{realname},'%')
+        </if>
+        <if test="roleCode!=null">
+            AND tt3.role_code = #{roleCode}
+        </if>
+        ) t3 ON t3.id = t1.user_id
+        WHERE 1=1
+        AND t4.stat_date &gt;=  #{startTime}
+        AND t4.stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        AND t2.parent_id = 60156
+        GROUP BY t1.user_id,t1.`code`
+        ) t
+        GROUP BY user_id
+        )k4 ON k4.user_id = k.user_id
+        ORDER BY k1.zhenren_charge DESC,k3.zhizuo_charge DESC
+
+    </select>
+
+    <select id="labelMaterialAll" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        '总计' as 'realname',
+        '-' as 'roleName',
+        IFNULL(SUM(t.zhenren_charge),0) as 'zhenrenCharge',
+        IFNULL(SUM(t.zhenren_number),0) as 'zhenrenNumber',
+        IFNULL(ROUND(SUM(t.zhenren_charge)/SUM(t.zhenren_number),2),0) as 'zhenrenCost',
+        IFNULL(SUM(t.zhizuo_charge),0) as 'zhizuoCharge',
+        IFNULL(SUM(t.zhizuo_number),0) as 'zhizuoNumber',
+        IFNULL(ROUND(SUM(t.zhizuo_charge)/SUM(t.zhizuo_number),2),0) as 'zhizuoCost'
+        FROM
+        (SELECT
+        IFNULL(k1.zhenren_charge,0)as 'zhenren_charge',
+        IFNULL(k2.zhenren_number,0)as 'zhenren_number',
+        IFNULL(k3.zhizuo_charge,0)as 'zhizuo_charge',
+        IFNULL(k4.zhizuo_number,0)as 'zhizuo_number'
+        FROM
+        (SELECT
+        t1.user_id,
+        t3.realname,
+        t3.role_name
+        FROM ctop_material_tag_info t1
+        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_kuaishou_video_get t4 ON t4.signature= t1.code
+        INNER JOIN(
+        SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
+        LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
+        LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        WHERE 1=1
+        <if test="realname!=null">
+            and tt1.realname LIKE CONCAT('%',#{realname},'%')
+        </if>
+        <if test="roleCode!=null">
+            AND tt3.role_code = #{roleCode}
+        </if>
+        ) t3 ON t3.id = t1.user_id
+        WHERE t2.parent_id in(60155,60156)
+        AND t4.stat_date &gt;=  #{startTime}
+        AND t4.stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        GROUP BY t1.user_id
+        ) k
+        LEFT JOIN
+        (
+        SELECT
+        t1.user_id, SUM(t5.charge) 'zhenren_charge'
+        FROM ctop_material_tag_info t1
+        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_kuaishou_video_get t4 ON t4.signature= t1.`code`
+        INNER JOIN(
+        SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
+        LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
+        LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        WHERE 1=1
+        <if test="realname!=null">
+            and tt1.realname LIKE CONCAT('%',#{realname},'%')
+        </if>
+        <if test="roleCode!=null">
+            AND tt3.role_code = #{roleCode}
+        </if>
+        ) t3 ON t3.id = t1.user_id
+        LEFT JOIN ctop_kuaishou_report_daily_material t5 ON  t1.`code` = t5.signature
+        WHERE 1=1
+        AND t4.stat_date &gt;=  #{startTime}
+        AND t4.stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        AND t2.parent_id = 60155
+        GROUP BY t1.user_id
+        )k1 ON k1.user_id =k.user_id
+        LEFT JOIN
+        (SELECT user_id, COUNT(1) 'zhenren_number' FROM (
+        SELECT
+        t1.user_id,t4.signature
+        FROM ctop_material_tag_info t1
+        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_kuaishou_video_get t4 ON t4.signature= t1.`code`
+        INNER JOIN(
+        SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
+        LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
+        LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        WHERE 1=1
+        <if test="realname!=null">
+            and tt1.realname LIKE CONCAT('%',#{realname},'%')
+        </if>
+        <if test="roleCode!=null">
+            AND tt3.role_code = #{roleCode}
+        </if>
+        ) t3 ON t3.id = t1.user_id
+        WHERE 1=1
+        AND t4.stat_date &gt;=  #{startTime}
+        AND t4.stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        AND t2.parent_id = 60155
+        GROUP BY t1.user_id,t1.`code`
+        ) t
+        GROUP BY user_id
+        )k2 ON k.user_id = k2.user_id
+        LEFT JOIN
+        (
+        SELECT
+        t1.user_id, SUM(t5.charge) 'zhizuo_charge'
+        FROM ctop_material_tag_info t1
+        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_kuaishou_video_get t4 ON t4.signature= t1.`code`
+        INNER JOIN(
+        SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
+        LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
+        LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        WHERE 1=1
+        <if test="realname!=null">
+            and tt1.realname LIKE CONCAT('%',#{realname},'%')
+        </if>
+        <if test="roleCode!=null">
+            AND tt3.role_code = #{roleCode}
+        </if>
+        ) t3 ON t3.id = t1.user_id
+        LEFT JOIN ctop_kuaishou_report_daily_material t5 ON  t1.`code` = t5.signature
+        WHERE 1=1
+        AND t4.stat_date &gt;=  #{startTime}
+        AND t4.stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        AND t2.parent_id = 60156
+        GROUP BY t1.user_id
+        )k3 ON k3.user_id =k.user_id
+        LEFT JOIN
+        (SELECT user_id, COUNT(1) 'zhizuo_number' FROM (
+        SELECT
+        t1.user_id,t4.signature
+        FROM ctop_material_tag_info t1
+        LEFT JOIN ctop_tag_info  t2 ON t2.id = t1.tag_id
+        LEFT JOIN ctop_kuaishou_video_get t4 ON t4.signature= t1.`code`
+        INNER JOIN(
+        SELECT tt1.id,tt3.role_name,tt1.realname FROM sys_user tt1
+        LEFT JOIN sys_user_role tt2 ON tt1.id = tt2.user_id
+        LEFT JOIN sys_role tt3 ON tt2.role_id = tt3.id
+        WHERE 1=1
+        <if test="realname!=null">
+            and tt1.realname LIKE CONCAT('%',#{realname},'%')
+        </if>
+        <if test="roleCode!=null">
+            AND tt3.role_code = #{roleCode}
+        </if>
+        ) t3 ON t3.id = t1.user_id
+        WHERE 1=1
+        AND t4.stat_date &gt;=  #{startTime}
+        AND t4.stat_date &lt;=  concat(#{endTime},' 23:59:59')
+        AND t2.parent_id = 60156
+        GROUP BY t1.user_id,t1.`code`
+        ) t
+        GROUP BY user_id
+        )k4 ON k4.user_id = k.user_id
+        ORDER BY k1.zhenren_charge DESC,k3.zhizuo_charge DESC
+        )t
+    </select>
 </mapper>
 

+ 122 - 121
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml

@@ -60,10 +60,10 @@
         </if>
         <if test="signatureList != null and signatureList != '' ">
             and signature in
-              <foreach collection="signatureList" item="item" separator=","
-                             open="(" close=")">
-                    #{item}
-                </foreach>
+            <foreach collection="signatureList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
         </if>
         group by signature
         order by stat_date desc
@@ -72,31 +72,32 @@
 
     <select id="getHighQualityVideo" parameterType="java.util.Map"
             resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
-        select * from ctop_kuaishou_video_get
+        select *
+        from ctop_kuaishou_video_get
         where account_id = #{accountId}
-        and signature in
-        (
-        select
-            daily_material.signature
-        from
-        ctop_kuaishou_report_daily_material daily_material
-        inner join
-        ctop_user_allocation allocation
-        on daily_material.account_id = allocation.account_id
-        where  allocation.project_id in (select project_id from ctop_user_allocation where account_id = #{accountId})
-        and  to_days(now()) - to_days(daily_material.stat_date) &lt;= #{days}
-        and daily_material.signature is not null
-        GROUP BY daily_material.signature
-        order by sum(daily_material.charge) desc
-        limit #{num}
-        )
+          and signature in
+              (
+                  select daily_material.signature
+                  from ctop_kuaishou_report_daily_material daily_material
+                           inner join
+                       ctop_user_allocation allocation
+                       on daily_material.account_id = allocation.account_id
+                  where allocation.project_id in
+                        (select project_id from ctop_user_allocation where account_id = #{accountId})
+                    and to_days(now()) - to_days(daily_material.stat_date) &lt;= #{days}
+                    and daily_material.signature is not null
+                  GROUP BY daily_material.signature
+                  order by sum(daily_material.charge) desc
+            limit #{num}
+            )
     </select>
 
     <select id="selectPhotoIdsByAccountId" parameterType="java.lang.Long"
             resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
-        select * from ctop_kuaishou_video_get
+        select *
+        from ctop_kuaishou_video_get
         where account_id = #{accountId}
-        and status = 0
+          and status = 0
     </select>
 
     <select id="getVideoListByMap" resultType="com.alibaba.fastjson.JSONObject">
@@ -131,32 +132,32 @@
         order by stat_date desc
     </select>
     <select id="getPhotoIdsByParams" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
-        select distinct photo_id from ctop_kuaishou_video_get
+        select distinct photo_id
+        from ctop_kuaishou_video_get
         where account_id = #{accountId}
-        and signature = #{signature}
-        and status = 0
+          and signature = #{signature}
+          and status = 0
     </select>
 
     <insert id="etlVideoBaseInfoByStaDate">
-    replace INTO ctop_etl_kuaishou_video_base_info (
+        replace
+        INTO ctop_etl_kuaishou_video_base_info (
 	signature,
 	channel_type,
 	photo_id,
     photo_name,
     material_type
-    ) SELECT
-	signature,
-	channel_type,
-	photo_id,
-    photo_name,
-    material_type
-  FROM
-	ctop_kuaishou_video_get
-	where  stat_date &gt;= #{statDate}
-	and signature is not null
-   GROUP BY
-	photo_id
- </insert>
+    )
+        SELECT signature,
+               channel_type,
+               photo_id,
+               photo_name,
+               material_type
+        FROM ctop_kuaishou_video_get
+        where stat_date &gt;= #{statDate}
+          and signature is not null
+        GROUP BY photo_id
+    </insert>
 
     <select id="getVideoInfoByPhotoIds" resultType="com.alibaba.fastjson.JSONObject">
         select
@@ -175,49 +176,39 @@
         group by photo_id
     </select>
     <select id="getTotalCountByAccount" resultType="java.lang.Integer">
-        select
-        count(distinct signature)
+        select count(distinct signature)
         from ctop_kuaishou_video_get
-        where  account_id = #{accountId}
+        where account_id = #{accountId}
     </select>
     <select id="getTotalCountByAccountAndStatDate" resultType="java.lang.Integer">
-        SELECT
-    	count(DISTINCT signature)
-        FROM
-	    ctop_kuaishou_video_get
-        WHERE
-	    account_id = #{accountId}
-        AND DATE_FORMAT(stat_date, '%Y-%m-%d') = #{statDate}
+        SELECT count(DISTINCT signature)
+        FROM ctop_kuaishou_video_get
+        WHERE account_id = #{accountId}
+          AND DATE_FORMAT(stat_date, '%Y-%m-%d') = #{statDate}
     </select>
     <select id="getEffectiveCountByAccountId" resultType="java.lang.Integer">
-        SELECT
-        count(1)
-        FROM
-        (
-        SELECT
-        signature
-        FROM
-        ctop_kuaishou_video_get
-        WHERE
-        account_id = #{accountId}
-        GROUP BY
-        signature
-        ) t1
-        LEFT JOIN ctop_kuaishou_video_etl_info t2 ON t1.signature = t2.video_code
-        WHERE
-        t2.effect_date IS NOT NULL
-        AND t2.effect_day_num &lt;= 7
+        SELECT count(1)
+        FROM (
+                 SELECT signature
+                 FROM ctop_kuaishou_video_get
+                 WHERE account_id = #{accountId}
+                 GROUP BY signature
+             ) t1
+                 LEFT JOIN ctop_kuaishou_video_etl_info t2 ON t1.signature = t2.video_code
+        WHERE t2.effect_date IS NOT NULL
+          AND t2.effect_day_num &lt;= 7
 
     </select>
     <select id="getZeroVideoByParams" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
         select
         video.*
         from
-        ctop_kuaishou_video_get video left join ctop_kuaishou_video_relate_creatives creative on video.photo_id = creative.photo_id and video.account_id = creative.account_id
+        ctop_kuaishou_video_get video left join ctop_kuaishou_video_relate_creatives creative on video.photo_id =
+        creative.photo_id and video.account_id = creative.account_id
         where
-              1=1
+        1=1
         <if test="relativeCnt!=null">
-           and creative.creative_count &lt;= #{relativeCnt}
+            and creative.creative_count &lt;= #{relativeCnt}
         </if>
 
         <if test="accountId!=null">
@@ -244,36 +235,29 @@
     </select>
 
     <select id="getHotMoneyCountByAccountId" resultType="java.lang.Integer">
-        SELECT
-        count(1)
-        FROM
-        (
-        SELECT
-        signature
-        FROM
-        ctop_kuaishou_video_get
-        WHERE
-        account_id = #{accountId}
-        GROUP BY
-        signature
-        ) t1
-        LEFT JOIN ctop_kuaishou_video_etl_info t2 ON t1.signature = t2.video_code
-        WHERE
-        t2.faddish_date is not null
-        and faddish_day_num &lt;=14
+        SELECT count(1)
+        FROM (
+                 SELECT signature
+                 FROM ctop_kuaishou_video_get
+                 WHERE account_id = #{accountId}
+                 GROUP BY signature
+             ) t1
+                 LEFT JOIN ctop_kuaishou_video_etl_info t2 ON t1.signature = t2.video_code
+        WHERE t2.faddish_date is not null
+          and faddish_day_num &lt;= 14
     </select>
     <select id="getHistoryTopVideoByParams"
             resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
         select
-            video.*
+        video.*
         from
-            ctop_kuaishou_report_daily_material report
+        ctop_kuaishou_report_daily_material report
         left join (select * from ctop_kuaishou_video_get
-                where
-                    status = 0
-                and signature is not null
+        where
+        status = 0
+        and signature is not null
         <if test="accountId!=null">
-                 and account_id = #{accountId}
+            and account_id = #{accountId}
         </if>
         <if test="channelType!=null">
             and channel_type = #{channelType}
@@ -288,11 +272,11 @@
             and photo_name like concat(#{appVersion},'%')
         </if>
         group by signature) video
-                  on video.signature = report.signature
+        on video.signature = report.signature
         left join (SELECT id, photo_id from ctop_ai_creative_limit WHERE account_id = #{accountId}) t2
-            on video.photo_id = t2.photo_id
-            where video.id is not null
-            group by video.signature
+        on video.photo_id = t2.photo_id
+        where video.id is not null
+        group by video.signature
         order by sum(report.charge) desc
         <if test="videoCnt!=null">
             limit #{videoCnt}
@@ -301,39 +285,56 @@
 
     <select id="selectProjectVideo" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProjectVideoGet">
         SELECT
-            t1.id,
-            t2.project_id,
-            t1.status,
-            t1.photo_id,
-            t1.width,
-            t1.height,
-            t1.url,
-            t1.cover_url,
-            t1.material_type,
-            t1.channel_type,
-            t1.stat_date,
-            t1.signature,
-            t1.photo_name,
-            t1.update_time
+        t1.id,
+        t2.project_id,
+        t1.status,
+        t1.photo_id,
+        t1.width,
+        t1.height,
+        t1.url,
+        t1.cover_url,
+        t1.material_type,
+        t1.channel_type,
+        t1.stat_date,
+        t1.signature,
+        t1.photo_name,
+        t1.update_time,
+        material_tag,
+        supplier_account_id,
+        supplier_account_name
         FROM ctop_kuaishou_video_get t1
-                 INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        WHERE t1.`status` =0
-          AND t2.project_id=#{projectId}
-        <if test="updateTime!=null">
-          AND t1.update_time >=#{updateTime}
+        INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        WHERE t2.project_id=#{projectId}
+        <if test="updateTime!=null and updateTime!=''">
+            AND t1.update_time &gt; #{updateTime}
         </if>
-
+        group by t1.signature
     </select>
 
     <select id="getAccountIds" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            account_id 'accountId',DATE_FORMAT(MAX(create_time),'%Y-%m-%d %H:%i:%s') 'startDate'
+        SELECT account_id 'accountId',DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 65 MINUTE), '%Y-%m-%d %H:%i:%s') 'startDate'
         FROM ctop_kuaishou_video_get
         where channel_type = 1
-          and  status = 0
+          and status = 0
         GROUP BY account_id
     </select>
 
+    <select id="queryPhotoIdsByProjectAndMd5" resultType="java.lang.String">
+        SELECT t1.photo_id
+        FROM ctop_kuaishou_video_get t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where t1.status = 0
+        AND t2.project_id = #{projectId}
+        AND t1.signature =#{signature}
+        <if test="accountId !=null">
+            AND t1.account_id IN
+            <foreach collection="accountId" item="id" separator="," open="(" close=")">
+                #{id}
+            </foreach>
+        </if>
+        GROUP BY photo_id
+    </select>
+
     <update id="updateBatch">
         UPDATE ctop_kuaishou_video_get SET
         material_tag = CASE id
@@ -353,7 +354,7 @@
         END
         WHERE id IN
         <foreach item="videoGet" index="index" collection="videoGetList" open="(" separator="," close=")">
-             #{videoGet.id}
+            #{videoGet.id}
         </foreach>
     </update>
 </mapper>

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 96 - 90
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouProjectVideoGetMapper.xml


+ 3 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouReportDailyMaterialService.java

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
 
 import java.util.List;
 import java.util.Map;
@@ -26,4 +27,6 @@ public interface IKuaiShouReportDailyMaterialService extends IService<KuaiShouRe
     List<KuaiShouReportDailyMaterial> getSignatureByDateGroupByProjectId(String date);
 
     List<KuaiShouReportDailyMaterial> getVideoInfoByList(List<KuaiShouReportDailyMaterial> addList, List<Long> photoIdList);
+
+    Result<Object> labelMaterialList(String realname, String roleCode, String startTime, String endTime, Integer pageNo, Integer pageSize);
 }

+ 6 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -27,7 +28,7 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
 
     List<KuaiShouVideoGet> getNewVideoDescDate(Long accountId, Integer newVideoCnt);
 
-    List<KuaiShouVideoGet> getNewVideoBetweenTime(Long accountId, String startTime, String endTime,Integer channelType,String appVersion,Integer videoCnt);
+    List<KuaiShouVideoGet> getNewVideoBetweenTime(Long accountId, String startTime, String endTime, Integer channelType, String appVersion, Integer videoCnt);
 
     List<JSONObject> getVideoListByMap(Map<String, Object> requestMap);
 
@@ -49,11 +50,13 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
 
     Integer getHotMoneyCountByAccountId(Long accountId);
 
-    List<KuaiShouVideoGet> getZeroVideoByParams(Long accountId, String startTime, String endTime, Long videoCnt,String appVersion,Integer channelType,Integer relativeCnt);
+    List<KuaiShouVideoGet> getZeroVideoByParams(Long accountId, String startTime, String endTime, Long videoCnt, String appVersion, Integer channelType, Integer relativeCnt);
 
     List<KuaiShouVideoGet> getHistoryTopVideoByParams(Long accountId, String startTime, String endTime, Long videoCnt, String appVersion, Integer channelType);
 
-    void getSuZaoList(String token, Long accountId, int page,String startDate);
+    void getSuZaoList(String token, Long accountId, int page, String startDate);
 
     List<JSONObject> getAccountIds();
+
+    List<String> queryPhotoIdsByProjectAndMd5(Long projectId, String signature, JSONArray accountId);
 }

+ 9 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouProjectVideoGetService.java

@@ -4,6 +4,8 @@ import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProjectVideoGet;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
 
+import java.util.List;
+
 /**
  * @Description: 快手-项目下视频信息
  * @Author: jeecg-boot
@@ -15,14 +17,17 @@ public interface IKuaishouProjectVideoGetService extends IService<KuaishouProjec
     /**
      * 清洗项目数据
      */
-    void clearProjectVideo(Long projectId);
+    void clearProjectVideo(Long projectId, Integer pageStart,String updateTime);
 
-    Result<Object> queryPageList(KuaishouProjectVideoGet kuaishouProjectVideoGet,Integer pageNo,Integer pageSize);
+    Result<Object> queryPageList(KuaishouProjectVideoGet kuaishouProjectVideoGet, Integer pageNo, Integer pageSize);
 
     Result<Object> getVideoTotalNumber(Long projectId);
 
-    Result<Object> getVideoDetails(String signature);
+    Result<Object> getVideoDetails(String signature, String id);
+
+    Result<Object> getAccountVideos(String signature, Long projectId, Integer pageNo, Integer pageSize);
 
-    Result<Object> getAccountVideos(String signature,Long projectId,Integer pageNo,Integer pageSize);
+    Result<Object> queryCreativeBySignature(List<String> photoIds, Long accountId, Integer pageNo, Integer pageSize);
 
+    void deleteCreativesByPhotoId(Object photoId);
 }

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

@@ -12,6 +12,7 @@ import cn.com.ctop.common.module.utils.SendMailUtil;
 import cn.com.ctop.kuaishou.modules.batch.service.IAccountWarningService;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportHourlyAccountMapper;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +33,8 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
     private MailLogMapper mailLogMapper;
     @Autowired
     private IProjectService projectService;
+    @Autowired
+    private CorpWexinUtils corpWexinUtils;
 
 
     /**
@@ -127,8 +130,8 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
             } catch (Exception e) {
                 e.printStackTrace();
             }
-            List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
-            CorpWexinUtils.sendMessage(wexinIds, text.toString());
+            List<JSONObject> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+            corpWexinUtils.sendMessage(wexinIds, text.toString());
         }
     }
 
@@ -167,8 +170,8 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
                 e.printStackTrace();
             }
         }
-        List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
-        CorpWexinUtils.sendMessage(wexinIds, text.toString());
+        List<JSONObject> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+        corpWexinUtils.sendMessage(wexinIds, text.toString());
 
     }
 

+ 17 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java

@@ -10,7 +10,10 @@ import cn.com.ctop.kuaishou.modules.report.mapper.KuaiShouReportHourlyMaterialMa
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -124,6 +127,20 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
     }
 
     @Override
+    public Result<Object> labelMaterialList(String realname, String roleCode, String startTime, String endTime, Integer pageNo, Integer pageSize) {
+        Long total = dailyMaterialMapper.labelMaterialListTotal(realname, roleCode, startTime, endTime);
+        PageHelper.startPage(pageNo, pageSize, false);
+        PageInfo pageInfo = new PageInfo(dailyMaterialMapper.labelMaterialList(realname, roleCode, startTime, endTime));
+        pageInfo.setTotal(total);
+        JSONObject data = new JSONObject();
+        data.put("pageInfo", pageInfo);
+        if (total > 0) {
+            data.put("total", dailyMaterialMapper.labelMaterialAll(realname, roleCode, startTime, endTime));
+        }
+        return Result.ok(data);
+    }
+
+    @Override
     public List<KuaiShouReportDailyMaterial> getSignatureByDate(String date) {
         return dailyMaterialMapper.getSignatureByDate(date);
     }

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

@@ -307,7 +307,6 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
         param.put("end_date", DateUtils.formatDate(new Date(),DateUtils.NEW_FORMAT));
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
-        System.out.println(result);
         if (Check.isNull(resultJson)) {
             return;
         }
@@ -348,4 +347,9 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     public List<JSONObject> getAccountIds() {
         return videoGetMapper.getAccountIds();
     }
+
+    @Override
+    public List<String> queryPhotoIdsByProjectAndMd5(Long projectId, String signature,JSONArray accountId) {
+        return videoGetMapper.queryPhotoIdsByProjectAndMd5(projectId, signature,accountId);
+    }
 }

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

@@ -1,25 +1,37 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProjectVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouVideoGetMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouProjectVideoGetMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouProjectVideoGetService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.xxl.job.core.enums.NoEn;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 /**
  * 快手-项目下视频信息
@@ -28,9 +40,10 @@ import java.util.Map;
  * @version V1.0
  * @date 2021-05-21
  */
+@Slf4j
 @Service
 public class KuaishouProjectVideoGetServiceImpl extends ServiceImpl<KuaishouProjectVideoGetMapper, KuaishouProjectVideoGet> implements IKuaishouProjectVideoGetService {
-
+    static ExecutorService kuaiShouExecutorService = Executors.newFixedThreadPool(5);
     @Autowired
     private KuaishouProjectVideoGetMapper projectVideoGetMapper;
     @Autowired
@@ -39,14 +52,32 @@ public class KuaishouProjectVideoGetServiceImpl extends ServiceImpl<KuaishouProj
     private IKuaiShouImageGetService imageGetService;
     @Autowired
     private IKuaiShouMaterialUploadService uploadService;
+    @Resource
+    private KuaiShouCreativeMapper kuaiShouCreativeMapper;
+    @Autowired
+    private IKuaiShouUpdateService kuaiShouUpdateService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
 
     @Override
-    public void clearProjectVideo(Long projectId) {
-        String updateTime = projectVideoGetMapper.queryLatestUpdateTime(projectId);
-        System.out.println(updateTime);
-        List<KuaishouProjectVideoGet> list = videoGetMapper.selectProjectVideo(projectId, updateTime);
-        if (!Check.isNull(list)) {
+    public void clearProjectVideo(Long projectId, Integer pageNo, String updateTime) {
+        try {
+            if (Check.isNull(updateTime) && pageNo == 1) {
+                updateTime = projectVideoGetMapper.queryLatestUpdateTime(projectId);
+            }
+            PageHelper.startPage(pageNo, 1000, false);
+            List<KuaishouProjectVideoGet> list = videoGetMapper.selectProjectVideo(projectId, updateTime);
+            if (Check.isNull(list)) {
+                return;
+            }
+            log.info("清洗快手项目素材数据,projectId:{},pageNo:{},size:{}", projectId, pageNo, list.size());
             projectVideoGetMapper.replaceBatch(list);
+            Thread.sleep(500);
+            clearProjectVideo(projectId, pageNo + 1, updateTime);
+        } catch (Exception e) {
+            log.error("清洗项目数据异常", e);
         }
     }
 
@@ -79,8 +110,8 @@ public class KuaishouProjectVideoGetServiceImpl extends ServiceImpl<KuaishouProj
     }
 
     @Override
-    public Result<Object> getVideoDetails(String signature) {
-        return Result.ok(projectVideoGetMapper.getVideoDetails(signature));
+    public Result<Object> getVideoDetails(String signature, String id) {
+        return Result.ok(projectVideoGetMapper.getVideoDetails(signature, id));
     }
 
     @Override
@@ -92,4 +123,39 @@ public class KuaishouProjectVideoGetServiceImpl extends ServiceImpl<KuaishouProj
         return Result.ok(list);
     }
 
+    @Override
+    public Result<Object> queryCreativeBySignature(List<String> photoIds, Long accountId, Integer pageNo, Integer pageSize) {
+        Long total = kuaiShouCreativeMapper.queryCreativeByPhotoIdTotal(photoIds, accountId);
+        PageHelper.startPage(pageNo, pageSize, false);
+        PageInfo<JSONObject> list = new PageInfo<>(kuaiShouCreativeMapper.queryCreativeByPhotoIds(photoIds, accountId));
+        list.setTotal(total);
+        return Result.ok(list);
+
+    }
+
+    @Override
+    public void deleteCreativesByPhotoId(Object photoId) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = "";
+        if (!Check.isNull(user)) {
+            userId = user.getId();
+        }
+        List<JSONObject> list = kuaiShouCreativeMapper.queryCreativeByPhotoId(String.valueOf(photoId));
+        if (!Check.isNull(list)) {
+            for (JSONObject data : list) {
+                Long accountId = data.getLong("accountId");
+                Long creativeId = data.getLong("creativeId");
+                CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+                if (!Check.isNull(token)) {
+                    String finalUserId = userId;
+                    kuaiShouExecutorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            kuaiShouUpdateService.updateCreativeStatus(token.getAccessToken(), accountId, creativeId, NoEn.NO3.valueInt(), finalUserId);
+                        }
+                    });
+                }
+            }
+        }
+    }
 }

+ 10 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/EtlKuaishouVideoInfoServiceImpl.java

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.material.service.impl;
 
 import cn.com.ctop.common.module.entity.MaterialInfo;
 import cn.com.ctop.common.module.entity.SysUser;
+import cn.com.ctop.common.module.mapper.SysUserMapper;
 import cn.com.ctop.common.module.service.IMaterialAscriptionService;
 import cn.com.ctop.common.module.service.IMaterialInfoService;
 import cn.com.ctop.common.module.service.ISysUserService;
@@ -10,6 +11,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.material.entity.EtlKuaishouVideoInfo;
 import cn.com.ctop.kuaishou.modules.material.mapper.EtlKuaishouVideoInfoMapper;
 import cn.com.ctop.kuaishou.modules.material.service.IEtlKuaishouVideoInfoService;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -44,9 +46,7 @@ public class EtlKuaishouVideoInfoServiceImpl extends ServiceImpl<EtlKuaishouVide
     private ISysUserService sysUserService;
     @Autowired
     private IMaterialInfoService materialInfoService;
-
     ExecutorService executorService = Executors.newFixedThreadPool(200);
-
     @Override
     public void etlKuaishouVideoInfo(String date) {
         //1:查询当前日期内的所有存在md5码信息的视频数据
@@ -82,8 +82,14 @@ public class EtlKuaishouVideoInfoServiceImpl extends ServiceImpl<EtlKuaishouVide
                                 //根据id查询剪辑所属的设计负责人
                                 SysUser user = sysUserService.getById(clipId);
                                 if(null!=user){
-                                    etlKuaishouVideoInfo.setDesignTeamLeaderId(user.getLeaderId());
-                                    etlKuaishouVideoInfo.setDesignTeamLeaderName(user.getLeaderName());
+                                    String roleCode = sysUserService.getRoleCodeByUserId(user.getId());
+                                    if(null!=roleCode&&roleCode.trim().equals("designTeamLeader")){
+                                        etlKuaishouVideoInfo.setDesignTeamLeaderId(user.getId());
+                                        etlKuaishouVideoInfo.setDesignTeamLeaderName(user.getRealname());
+                                    }else{
+                                        etlKuaishouVideoInfo.setDesignTeamLeaderId(user.getLeaderId());
+                                        etlKuaishouVideoInfo.setDesignTeamLeaderName(user.getLeaderName());
+                                    }
                                 }
                             }
                             String clipName = ascription.getString("clipName");

+ 6 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/KuaishouBidWarningServiceImpl.java

@@ -12,6 +12,7 @@ import cn.com.ctop.common.module.utils.SendMailUtil;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
 import cn.com.ctop.kuaishou.modules.material.service.IKuaishouBidWarningService;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.xxl.job.core.context.XxlJobHelper;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,6 +31,8 @@ public class KuaishouBidWarningServiceImpl implements IKuaishouBidWarningService
     private KuaiShouGroupMapper groupMapper;
     @Autowired
     private MailLogMapper mailLogMapper;
+    @Autowired
+    private CorpWexinUtils corpWexinUtils;
 
 
     /**
@@ -51,7 +54,7 @@ public class KuaishouBidWarningServiceImpl implements IKuaishouBidWarningService
                 }
                 Long maxBid = project.getMaxBid();
                 Long projectId = project.getId();
-                List<UserAllocation> userAllocations = userAllocationService.getByParams(projectId,null,null);
+                List<UserAllocation> userAllocations = userAllocationService.getByParams(projectId, null, null);
                 if (!Check.isNull(userAllocations)) {
                     for (UserAllocation userAllocation : userAllocations) {
                         if (userAllocation.getAccountStatus() == 1) {
@@ -108,7 +111,7 @@ public class KuaishouBidWarningServiceImpl implements IKuaishouBidWarningService
             }
         }
 
-        List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
-        CorpWexinUtils.sendMessage(wexinIds, text.toString());
+        List<JSONObject> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+        corpWexinUtils.sendMessage(wexinIds, text.toString());
     }
 }

+ 6 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaishouAccountMaterialReportDailyMapper.java

@@ -19,4 +19,10 @@ public interface EtlKuaishouAccountMaterialReportDailyMapper extends BaseMapper<
     List<EtlKuaishouAccountMaterialReportDaily> etlKuaishouAccountMaterialReportDailyList(@Param(value = "date")String date,@Param(value = "accountId")Long accountId);
 
     void replaceBatch(@Param(value = "records")List<EtlKuaishouAccountMaterialReportDaily> getList);
+
+    void replace(@Param(value = "report")EtlKuaishouAccountMaterialReportDaily report);
+
+    void etlKuaishouReportCompanyInfo(@Param(value = "formatDate") String formatDate);
+
+    void etlKuaishouVideoReportStateDate();
 }

+ 85 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouAccountMaterialReportDailyMapper.xml

@@ -142,6 +142,88 @@
             )
         </foreach>
     </insert>
+    <insert id="replace">
+    replace into ctop_etl_kuaishou_account_material_report_daily(
+        company_id ,
+        company_name ,
+        project_id ,
+        project_name,
+        account_id,
+        signature,
+        charge,
+        photo_show ,
+        aclick ,
+        bclick ,
+        download_started ,
+        download_completed ,
+        activation ,
+        submit ,
+        stat_date ,
+        photo_click ,
+        event_pay_first_day ,
+        event_pay_purchase_amount_first_day ,
+        event_pay ,
+        event_pay_purchase_amount ,
+        event_register ,
+        event_jin_jian_app ,
+        event_credit_grant_app ,
+        event_order_paid ,
+        event_order_paid_purchase_amount ,
+        event_jin_jian_landing_page ,
+        event_credit_grant_landing_page ,
+        event_next_day_stay ,
+        form_count,
+        play_3s_count)
+        values
+        (
+            #{report.companyId},
+            #{report.companyName},
+            #{report.projectId},
+            #{report.projectName},
+            #{report.accountId},
+            #{report.signature},
+            #{report.charge},
+            #{report.photoShow},
+            #{report.aclick},
+            #{report.bclick},
+            #{report.downloadStarted} ,
+            #{report.downloadCompleted} ,
+            #{report.activation},
+            #{report.submit},
+            #{report.statDate},
+            #{report.photoClick},
+            #{report.eventPayFirstDay},
+            #{report.eventPayPurchaseAmountFirstDay},
+            #{report.eventPay},
+            #{report.eventPayPurchaseAmount},
+            #{report.eventRegister},
+            #{report.eventJinJianApp},
+            #{report.eventCreditGrantApp},
+            #{report.eventOrderPaid},
+            #{report.eventOrderPaidPurchaseAmount},
+            #{report.eventJinJianLandingPage},
+            #{report.eventCreditGrantLandingPage} ,
+            #{report.eventNextDayStay},
+            #{report.formCount},
+            #{report.play3sCount}
+        )
+    </insert>
+    <update id="etlKuaishouReportCompanyInfo">
+        update ctop_etl_kuaishou_account_material_report_daily a left join ctop_user_allocation cua on a.account_id = cua.account_id
+            left join user_company uc on cua.user_id = uc.user_id
+            set a.company_name = uc.company_name
+        where a.company_name is null
+          and uc.company_name is not null
+          and a.stat_date = #{formatDate}
+    </update>
+    <update id="etlKuaishouVideoReportStateDate">
+        UPDATE ctop_etl_kuaishou_video_info info
+            LEFT JOIN ( SELECT min( stat_date ) AS minDate, signature FROM ctop_kuaishou_report_daily_material GROUP BY signature ) a ON a.signature = info.video_code
+            SET info.state_date = a.minDate
+        WHERE
+            a.minDate IS NOT NULL
+          AND info.state_date IS NULL
+    </update>
     <select id="etlKuaishouAccountMaterialReportDailyList"
             resultType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouAccountMaterialReportDaily">
     select
@@ -150,7 +232,7 @@
     u.project_id ,
     p.project_name,
     m.account_id,
-    m.signature,
+    video.signature,
     sum(m.charge)as charge ,
     sum(m.photo_show)as photo_show ,
     sum(m.aclick)as aclick ,
@@ -176,9 +258,10 @@
     sum(m.form_count)as form_count,
      round(sum(m.play_3s_ratio*m.photo_show))as play_3s_count
     from ctop_kuaishou_report_daily_material m left join ctop_user_allocation u on u.account_id = m.account_id
+    left  join ctop_kuaishou_video_get video on video.account_id = m.account_id and m.photo_id = video.photo_id
 left join ctop_project p on p.id = u.project_id
 left join user_company c on c.user_id = u.account_id
-where m.signature is not null
+where 1=1
 and m.stat_date = #{date} and m.account_id = #{accountId}
 group by m.account_id,m.signature
     </select>

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportAccountDailyMapper.xml

@@ -285,13 +285,13 @@
                      AND media_id =2
                      GROUP BY user_id) t) as 'totle'
                  FROM (
-                     SELECT sum (charge) as 'charge', t2.user_id 'userId' FROM ctop_etl_kuaishou_report_account_daily t1
+                     SELECT sum(charge) as 'charge', t2.user_id 'userId' FROM ctop_etl_kuaishou_report_account_daily t1
                      LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
                      WHERE t1.stat_date &gt;= #{mStartDate}
                      AND t1.stat_date &lt;= #{today}
                      AND media_id =2
                      GROUP BY user_id
-                     ORDER BY SUM (charge) DESC
+                     ORDER BY SUM(charge) DESC
                      ) t, (select @rownum := 0) a
              ) tt
         WHERE tt.userId = #{userId}

+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IEtlKuaishouAccountMaterialReportDailyService.java

@@ -14,4 +14,8 @@ public interface IEtlKuaishouAccountMaterialReportDailyService extends IService<
     void etlKuaishouAccountMaterialReportDailyData(String date);
 
     void etlKuaishouAccountMaterialReportInfo(String formatDate);
+
+    void etlKuaishouReportCompanyInfo(String formatDate);
+
+    void etlKuaishouVideoReportStateDate();
 }

+ 13 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaishouAccountMaterialReportDailyServiceImpl.java

@@ -60,7 +60,9 @@ public class EtlKuaishouAccountMaterialReportDailyServiceImpl extends ServiceImp
         tokens.forEach(token -> etlExecutorService.submit(()->{
             try {
                 List<EtlKuaishouAccountMaterialReportDaily> getList = etlKuaishouAccountMaterialReportDailyMapper.etlKuaishouAccountMaterialReportDailyList(formatDate,token.getAccountId());
-                etlKuaishouAccountMaterialReportDailyMapper.replaceBatch(getList);
+                if(null!=getList&&!getList.isEmpty()){
+                    getList.forEach(report->etlKuaishouAccountMaterialReportDailyMapper.replace(report));
+                }
             }catch (Exception e){
                 e.printStackTrace();
             }finally {
@@ -74,4 +76,14 @@ public class EtlKuaishouAccountMaterialReportDailyServiceImpl extends ServiceImp
         }
         log.info("{}数据获取完成",formatDate);
     }
+
+    @Override
+    public void etlKuaishouReportCompanyInfo(String formatDate) {
+        etlKuaishouAccountMaterialReportDailyMapper.etlKuaishouReportCompanyInfo(formatDate);
+    }
+
+    @Override
+    public void etlKuaishouVideoReportStateDate() {
+        etlKuaishouAccountMaterialReportDailyMapper.etlKuaishouVideoReportStateDate();
+    }
 }

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

@@ -186,9 +186,10 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
                     unit.setUnitId(unitDetail.getLong("unit_id"));
                     unit.setUnitName(unitDetail.getString("unit_name"));
                     unit.setCharge(unitDetail.getBigDecimal("charge"));
-                    unit.setDeepConversionBid(group.getDeepConversionBid());
+                    unit.setDeepConversionBid(new BigDecimal(group.getDeepConversionBid()).divide(new BigDecimal("1000")));
                     unit.setDeepConversionType(group.getDeepConversionType());
-
+                    unit.setOcpxActionType(group.getOcpxActionType());
+                    unit.setCpaBid(new BigDecimal(group.getCpaBid()).divide(new BigDecimal("1000"), 2, RoundingMode.HALF_UP));
                     //未知优化目标数据存空
                     if (group.getOcpxActionType() != 0) {
                         unit.setConvertNum(handleConvertNum(group.getOcpxActionType(), unitDetail));

+ 8 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/ETLReportBytedanceVideoMapper.java

@@ -34,4 +34,12 @@ public interface ETLReportBytedanceVideoMapper extends BaseMapper<ETLReportByted
     List<ETLReportBytedanceVideo> getDuplicateVideoInfo(@Param("date")String date);
 
     void deleteDuplicateVideoInfo(@Param("video")ETLReportBytedanceVideo video);
+
+    List<ETLReportBytedanceVideo> getBytedanceVideoClipInfo();
+    List<ETLReportBytedanceVideo> getBytedanceVideoShotInfo();
+    List<ETLReportBytedanceVideo> getBytedanceVideoPlanInfo();
+
+    void updateClipInfo(@Param("clipId")String clipId, @Param("clipName")String clipName, @Param("md5")String md5);
+    void updateShotInfo(@Param("shotId")String shotId, @Param("shotName")String shotName, @Param("md5")String md5);
+    void updatePlanInfo(@Param("planId")String planId, @Param("planName")String planName, @Param("md5")String md5);
 }

+ 55 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/xml/ETLReportBytedanceVideoMapper.xml

@@ -201,6 +201,16 @@
             )
         </foreach>
     </insert>
+    <update id="updateClipInfo">
+        update etl_report_bytedance_video set clip_id=#{clipId},clip_name=#{clipName} where md5=#{md5}
+    </update>
+    <update id="updateShotInfo">
+        update etl_report_bytedance_video set shot_id=#{shotId},shot_name=#{shotName} where md5=#{md5}
+    </update>
+    <update id="updatePlanInfo">
+        update etl_report_bytedance_video set plan_id=#{planId},plan_name=#{planName} where md5=#{md5}
+    </update>
+
     <delete id="deleteDuplicateVideoInfo">
         delete from
                     etl_report_bytedance_video
@@ -319,4 +329,49 @@
         from etl_report_bytedance_video where stat_datetime =#{date} and cost>0 GROUP BY stat_datetime,material_id,account_id
         HAVING total >1 ORDER BY total DESC;
     </select>
+    <select id="getBytedanceVideoClipInfo"
+            resultType="cn.com.ctop.toutiao.modules.link.entity.ETLReportBytedanceVideo">
+        SELECT DISTINCT
+            video.md5 as 'md5',
+            cmi.clip_id as 'clip_id',
+            u.realname as 'clip_name'
+        FROM
+            etl_report_bytedance_video video
+                LEFT JOIN ctop_material_ascription cmi ON video.md5 = cmi.
+                CODE LEFT JOIN sys_user u ON u.id = cmi.clip_id
+        WHERE
+            cmi.clip_id IS NOT NULL
+          AND video.clip_id = ''
+          AND u.realname IS NOT NULL
+    </select>
+    <select id="getBytedanceVideoShotInfo"
+            resultType="cn.com.ctop.toutiao.modules.link.entity.ETLReportBytedanceVideo">
+        SELECT DISTINCT
+            video.md5 as 'md5',
+            cmi.shot_id as 'shot_id',
+            u.realname as 'shot_name'
+        FROM
+            etl_report_bytedance_video video
+                LEFT JOIN ctop_material_ascription cmi ON video.md5 = cmi.
+                CODE LEFT JOIN sys_user u ON u.id = cmi.shot_id
+        WHERE
+            cmi.shot_id IS NOT NULL
+          AND video.shot_id = ''
+          AND u.realname IS NOT NULL
+    </select>
+    <select id="getBytedanceVideoPlanInfo"
+            resultType="cn.com.ctop.toutiao.modules.link.entity.ETLReportBytedanceVideo">
+        SELECT DISTINCT
+            video.md5 as 'md5',
+            cmi.plan_id as 'plan_id',
+            u.realname as 'plan_name'
+        FROM
+            etl_report_bytedance_video video
+                LEFT JOIN ctop_material_ascription cmi ON video.md5 = cmi.
+                CODE LEFT JOIN sys_user u ON u.id = cmi.plan_id
+        WHERE
+            cmi.plan_id IS NOT NULL
+          AND video.plan_id = ''
+          AND u.realname IS NOT NULL
+    </select>
 </mapper>

+ 6 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/service/IETLReportBytedanceVideoService.java

@@ -16,4 +16,10 @@ public interface IETLReportBytedanceVideoService extends IService<ETLReportByted
     void cleanETL(String statDate);
 
     void cleanData(String data);
+
+    void etlBytedanceVideoClipIdJob();
+
+    void etlBytedanceVideoPlanInfoJob();
+
+    void etlBytedanceVideoShotInfoJob();
 }

+ 30 - 51
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/service/impl/ETLReportBytedanceVideoServiceImpl.java

@@ -35,57 +35,6 @@ public class ETLReportBytedanceVideoServiceImpl extends ServiceImpl<ETLReportByt
         return baseReportBytedanceVideoDailyService.list(queryWrapper);
     }
 
-/*    @Override
-    public void cleanETL(String statDate) {
-        List<BaseReportBytedanceVideoDaily> source = listByStatDate(statDate);
-        if(source.isEmpty()){
-            XxlJobHelper.log("头条数据报表清洗ETL异常,请检查数据源");
-        }
-        List<ETLReportBytedanceVideo> batch = new ArrayList<>();
-        source.forEach(it->{
-            JSONObject videoInfo= etlReportBytedanceVideoMapper.queryVideoInfoByMaterialId(it.getMaterialId());
-            if(null==videoInfo||videoInfo.isEmpty()){
-                XxlJobHelper.log("头条数据报表清洗ETL异常,未关联到video_info,materialId:{}",it.getMaterialId());
-            }else {
-                //TODO 暂时从老数据库查询,新素材库怕同步数据有偏差
-                //JSONObject materialVideo= etlReportBytedanceVideoMapper.queryMaterialVideoByMd5(videoInfo.getString("md5"));
-                JSONObject materialVideo= etlReportBytedanceVideoMapper.queryMaterialVideoByMd5Old(videoInfo.getString("md5"));
-                //JSONObject relatePerson=etlReportBytedanceVideoMapper.queryRelatePersonByMd5(videoInfo.getString("md5"));
-                JSONObject relatePerson=etlReportBytedanceVideoMapper.queryRelatePersonByMd5Old(videoInfo.getString("md5"));
-
-                JSONObject accountDetail=etlReportBytedanceVideoMapper.queryAccountDetailByAccountId(it.getAccountId());
-                ETLReportBytedanceVideo temp = JSONObject.toJavaObject(JSONObject.parseObject(JSON.toJSON(it).toString()),ETLReportBytedanceVideo.class);
-                temp.setMd5(videoInfo.getString("md5"));
-                temp.setToutiaoUrl(videoInfo.getString("url"));
-                if(null!=materialVideo&&!materialVideo.isEmpty()) {
-                    temp.setUrl(materialVideo.getString("url"));
-                    temp.setCoverUrl(materialVideo.getString("coverUrl"));
-                    temp.setMaterialName(materialVideo.getString("materialName"));
-                    temp.setMaterialCreateTime(materialVideo.getDate("createTime").toString());
-                }
-                if(null!=accountDetail&&!accountDetail.isEmpty()){
-                    temp.setAccountName(accountDetail.getString("accountName"));
-                    temp.setProjectId(accountDetail.getLong("projectId"));
-                    temp.setProjectName(accountDetail.getString("projectName"));
-                    temp.setProductId(accountDetail.getLong("productId"));
-                    temp.setProductName(accountDetail.getString("productName"));
-                    temp.setAdvertiserId(accountDetail.getString("advertiserId"));
-                    temp.setAdvertiserName(accountDetail.getString("advertiserName"));
-                }
-                if(null!=relatePerson&&!relatePerson.isEmpty()){
-                    temp.setClipId(relatePerson.getString("clipId"));
-                    temp.setClipName(relatePerson.getString("clipName"));
-                    temp.setShotId(relatePerson.getString("shotId"));
-                    temp.setShotName(relatePerson.getString("shotName"));
-                    temp.setPlanId(relatePerson.getString("planId"));
-                    temp.setPlanName(relatePerson.getString("planName"));
-                }
-                batch.add(temp);
-            }
-            this.saveBatch(batch);
-        });
-    }*/
-
     @Override
     public void cleanETL(String statDate) {
         List<ETLReportBytedanceVideo> etlReportBytedanceVideos = etlReportBytedanceVideoMapper.queryETLData(statDate);
@@ -112,4 +61,34 @@ public class ETLReportBytedanceVideoServiceImpl extends ServiceImpl<ETLReportByt
         }
     }
 
+    @Override
+    public void etlBytedanceVideoClipIdJob() {
+        List <ETLReportBytedanceVideo> clipInfos = etlReportBytedanceVideoMapper.getBytedanceVideoClipInfo();
+        if(null!=clipInfos&&!clipInfos.isEmpty()){
+            clipInfos.forEach(clipInfo->{
+                etlReportBytedanceVideoMapper.updateClipInfo(clipInfo.getClipId(),clipInfo.getClipName(),clipInfo.getMd5());
+            });
+        }
+    }
+
+    @Override
+    public void etlBytedanceVideoPlanInfoJob() {
+        List <ETLReportBytedanceVideo> planInfos = etlReportBytedanceVideoMapper.getBytedanceVideoPlanInfo();
+        if(null!=planInfos&&!planInfos.isEmpty()){
+            planInfos.forEach(planInfo->{
+                etlReportBytedanceVideoMapper.updatePlanInfo(planInfo.getPlanId(),planInfo.getPlanName(),planInfo.getMd5());
+            });
+        }
+    }
+
+    @Override
+    public void etlBytedanceVideoShotInfoJob() {
+        List <ETLReportBytedanceVideo> shotInfos = etlReportBytedanceVideoMapper.getBytedanceVideoShotInfo();
+        if(null!=shotInfos&&!shotInfos.isEmpty()){
+            shotInfos.forEach(shotInfo->{
+                etlReportBytedanceVideoMapper.updateShotInfo(shotInfo.getShotId(),shotInfo.getShotName(),shotInfo.getMd5());
+            });
+        }
+    }
+
 }

+ 6 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceBidWarningServiceImpl.java

@@ -13,6 +13,7 @@ import cn.com.ctop.common.module.utils.SendMailUtil;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceBidWarningService;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.xxl.job.core.context.XxlJobHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -34,6 +35,8 @@ public class BytedanceBidWarningServiceImpl implements IBytedanceBidWarningServi
     private MailLogMapper mailLogMapper;
     @Autowired
     private IByteDanceAdvertisePlanService byteDanceAdvertisePlanService;
+    @Autowired
+    private CorpWexinUtils corpWexinUtils;
 
     @Override
     public void bidWarning() {
@@ -48,7 +51,7 @@ public class BytedanceBidWarningServiceImpl implements IBytedanceBidWarningServi
                     }
                     Long maxBid = project.getMaxBid();
                     Long projectId = project.getId();
-                    List<UserAllocation> userAllocations = userAllocationService.getByParams(projectId,null,null);
+                    List<UserAllocation> userAllocations = userAllocationService.getByParams(projectId, null, null);
                     if (!Check.isNull(userAllocations)) {
                         for (UserAllocation userAllocation : userAllocations) {
                             if (userAllocation.getAccountStatus() == 1) {
@@ -108,7 +111,7 @@ public class BytedanceBidWarningServiceImpl implements IBytedanceBidWarningServi
             }
         }
 
-        List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
-        CorpWexinUtils.sendMessage(wexinIds, text.toString());
+        List<JSONObject> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+        corpWexinUtils.sendMessage(wexinIds, text.toString());
     }
 }

+ 166 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceCheckReportTaskInfoController.java

@@ -0,0 +1,166 @@
+package cn.com.ctop.toutiao.modules.report.controller;
+
+import cn.com.ctop.common.module.utils.QueryGenerator;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceCheckReportTaskInfoService;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 头条数据检查任务记录
+ * @author jeecg-boot
+ * @date   2021-06-07
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="头条数据检查任务记录")
+@RestController
+@RequestMapping("/ctop/bytedanceCheckReportTaskInfo")
+public class BytedanceCheckReportTaskInfoController {
+	@Autowired
+	private IBytedanceCheckReportTaskInfoService bytedanceCheckReportTaskInfoService;
+
+	/**
+	  * 分页列表查询
+	 * @param bytedanceCheckReportTaskInfo
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@ApiOperation(value="头条数据检查任务记录-分页列表查询", notes="头条数据检查任务记录-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<BytedanceCheckReportTaskInfo>> queryPageList(BytedanceCheckReportTaskInfo bytedanceCheckReportTaskInfo,
+																	 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+																	 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+																	 HttpServletRequest req) {
+		Result<IPage<BytedanceCheckReportTaskInfo>> result = new Result<>();
+		QueryWrapper<BytedanceCheckReportTaskInfo> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceCheckReportTaskInfo, req.getParameterMap());
+		Page<BytedanceCheckReportTaskInfo> page = new Page<>(pageNo, pageSize);
+		IPage<BytedanceCheckReportTaskInfo> pageList = bytedanceCheckReportTaskInfoService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param bytedanceCheckReportTaskInfo
+	 * @return
+	 */
+	@ApiOperation(value="头条数据检查任务记录-添加", notes="头条数据检查任务记录-添加")
+	@PostMapping(value = "/add")
+	public Result<BytedanceCheckReportTaskInfo> add(@RequestBody BytedanceCheckReportTaskInfo bytedanceCheckReportTaskInfo) {
+		Result<BytedanceCheckReportTaskInfo> result = new Result<>();
+		try {
+			bytedanceCheckReportTaskInfoService.save(bytedanceCheckReportTaskInfo);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param bytedanceCheckReportTaskInfo
+	 * @return
+	 */
+	@ApiOperation(value="头条数据检查任务记录-编辑", notes="头条数据检查任务记录-编辑")
+	@PutMapping(value = "/edit")
+	public Result<BytedanceCheckReportTaskInfo> edit(@RequestBody BytedanceCheckReportTaskInfo bytedanceCheckReportTaskInfo) {
+		Result<BytedanceCheckReportTaskInfo> result = new Result<BytedanceCheckReportTaskInfo>();
+		BytedanceCheckReportTaskInfo bytedanceCheckReportTaskInfoEntity = bytedanceCheckReportTaskInfoService.getById(bytedanceCheckReportTaskInfo.getId());
+		if(bytedanceCheckReportTaskInfoEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = bytedanceCheckReportTaskInfoService.updateById(bytedanceCheckReportTaskInfo);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@ApiOperation(value="头条数据检查任务记录-通过id删除", notes="头条数据检查任务记录-通过id删除")
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id") String id) {
+		try {
+			bytedanceCheckReportTaskInfoService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+
+	/**
+	 *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@ApiOperation(value="头条数据检查任务记录-批量删除", notes="头条数据检查任务记录-批量删除")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<BytedanceCheckReportTaskInfo> deleteBatch(@RequestParam(name="ids") String ids) {
+		Result<BytedanceCheckReportTaskInfo> result = new Result<>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.bytedanceCheckReportTaskInfoService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@ApiOperation(value="头条数据检查任务记录-通过id查询", notes="头条数据检查任务记录-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<BytedanceCheckReportTaskInfo> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<BytedanceCheckReportTaskInfo> result = new Result<>();
+		BytedanceCheckReportTaskInfo bytedanceCheckReportTaskInfo = bytedanceCheckReportTaskInfoService.getById(id);
+		if(bytedanceCheckReportTaskInfo==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(bytedanceCheckReportTaskInfo);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+}

+ 67 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/BytedanceCheckReportTaskInfo.java

@@ -0,0 +1,67 @@
+package cn.com.ctop.toutiao.modules.report.entity;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 头条数据检查任务记录
+ * @author jeecg-boot
+ * @date   2021-06-07
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_bytedance_check_report_task_info")
+public class BytedanceCheckReportTaskInfo {
+    
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**accountId*/
+	private Long accountId;
+	private BigDecimal accountCost;
+	private BigDecimal campaignCost;
+	private BigDecimal matCost;
+	private BigDecimal imageCost;
+	/**stateDate*/
+	private String stateDate;
+	/**status*/
+	private Integer status;
+	/**desc*/
+	private String description;
+	/**createTime*/
+	private Date createTime;
+	/**updateTime*/
+	private Date updateTime;
+	private Integer costStatus;
+
+	public BytedanceCheckReportTaskInfo(){
+
+	}
+	public BytedanceCheckReportTaskInfo(CtopOauthToken token, String date) {
+		this.accountId = token.getAccountId();
+		this.accountCost = BigDecimal.ZERO;
+		this.campaignCost = BigDecimal.ZERO;
+		this.matCost = BigDecimal.ZERO;
+		this.imageCost = BigDecimal.ZERO;
+		this.status = 0;
+		this.costStatus = 0;
+		this.stateDate = date;
+		this.createTime = new Date();
+		this.updateTime = new Date();
+	}
+}

+ 7 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceCampaignDailyReportMapper.java

@@ -1,14 +1,17 @@
 package cn.com.ctop.toutiao.modules.report.mapper;
 
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceCampaignDailyReport;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
- * @Description: 广告组日报表信息
- * @Author: jeecg-boot
- * @Date: 2019-09-11
- * @Version: V1.0
+ * 广告组日报表信息
+ * @author jeecg-boot
+ * 2019-09-11
+ * @version V1.0
  */
 public interface BytedanceCampaignDailyReportMapper extends BaseMapper<BytedanceCampaignDailyReport> {
 
+    BytedanceCheckReportTaskInfo checkCampaignCostByParams(@Param(value = "accountId") Long accountId, @Param(value = "stateDate")String stateDate);
 }

+ 14 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceCheckReportTaskInfoMapper.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.toutiao.modules.report.mapper;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 头条数据检查任务记录
+ * @author jeecg-boot
+ * 2021-06-07
+ * @version V1.0
+ */
+public interface BytedanceCheckReportTaskInfoMapper extends BaseMapper<BytedanceCheckReportTaskInfo> {
+
+}

+ 5 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceReportMaterialDailyMapper.java

@@ -3,10 +3,7 @@ package cn.com.ctop.toutiao.modules.report.mapper;
 import cn.com.ctop.common.module.vo.BytedanceImageCostVO;
 import cn.com.ctop.common.module.vo.BytedanceImageCostVOEntity;
 import cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo;
-import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
-import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
-import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportVideoMaterialDaily;
-import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import cn.com.ctop.toutiao.modules.report.entity.*;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -63,4 +60,8 @@ public interface BytedanceReportMaterialDailyMapper extends BaseMapper<Bytedance
     List<BytedanceVideoEtlInfo> getSignatureByDate(@Param(value = "date") String date);
 
     BytedanceVideoEtlInfo getEtlDataByParams(@Param("signature")String signature, @Param("date")String date);
+
+    BytedanceCheckReportTaskInfo checkMatCostByParams(@Param("accountId")Long accountId, @Param("stateDate")String stateDate);
+
+    BytedanceCheckReportTaskInfo checkImageCostByParams(@Param("accountId")Long accountId, @Param("stateDate")String stateDate);
 }

+ 12 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceCampaignDailyReportMapper.xml

@@ -2,4 +2,16 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.toutiao.modules.report.mapper.BytedanceCampaignDailyReportMapper">
 
+    <select id="checkCampaignCostByParams"
+            resultType="cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo">
+        select
+               sum(cost) as campaign_cost,
+               stat_datetime as state_date
+        from
+             ctop_bytedance_report_campaign_daily
+        where
+              advertiser_id = #{accountId}
+          and
+              stat_datetime = #{stateDate}
+    </select>
 </mapper>

+ 5 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceCheckReportTaskInfoMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.toutiao.modules.report.mapper.BytedanceCheckReportTaskInfoMapper">
+
+</mapper>

+ 24 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceReportMaterialDailyMapper.xml

@@ -450,6 +450,30 @@ where a.plane_id is not null and a.plane_name is null
             report.stat_datetime&lt;= #{date}
         group by video.signature;
     </select>
+    <select id="checkMatCostByParams"
+            resultType="cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo">
+        select
+               sum(cost) as mat_cost,
+               stat_datetime as state_date
+        from
+             ctop_bytedance_report_material_daily
+        where
+              account_id = #{accountId}
+          and
+              stat_datetime = #{stateDate}
+    </select>
+    <select id="checkImageCostByParams"
+            resultType="cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo">
+        select
+            sum(cost) as image_cost,
+            stat_datetime as state_date
+        from
+            ctop_bytedance_report_image_daily
+        where
+            account_id = #{accountId}
+          and
+            stat_datetime = #{stateDate}
+    </select>
 
     <insert id="replaceIntoVideoMaterialBatch">
         REPLACE INTO ctop_bytedance_report_video_material_daily

+ 2 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceAdvertiserDailyReportService.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.modules.report.service;
 
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceAdvertiserDailyReport;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 /**
@@ -11,4 +12,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IBytedanceAdvertiserDailyReportService extends IService<BytedanceAdvertiserDailyReport> {
 
+    BytedanceAdvertiserDailyReport getByParams(Long accountId, String stateDate);
 }

+ 2 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceCampaignDailyReportService.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.modules.report.service;
 
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceCampaignDailyReport;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 /**
@@ -11,4 +12,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IBytedanceCampaignDailyReportService extends IService<BytedanceCampaignDailyReport> {
 
+    BytedanceCheckReportTaskInfo checkCampaignCostByParams(Long accountId, String stateDate);
 }

+ 24 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceCheckReportTaskInfoService.java

@@ -0,0 +1,24 @@
+package cn.com.ctop.toutiao.modules.report.service;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * 头条数据检查任务记录
+ * @author jeecg-boot
+ * 2021-06-07
+ * @version V1.0
+ */
+public interface IBytedanceCheckReportTaskInfoService extends IService<BytedanceCheckReportTaskInfo> {
+    void initTask(String date);
+
+    BytedanceCheckReportTaskInfo getInfoByParams(Long accountId, String date);
+
+    List<BytedanceCheckReportTaskInfo> getListByParams(Long accountId, String date,Integer status);
+
+    void checkCost(BytedanceCheckReportTaskInfo taskInfo);
+
+    void reloadData(BytedanceCheckReportTaskInfo taskInfo);
+}

+ 5 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceReportMaterialDailyService.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.modules.report.service;
 
 import cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -19,4 +20,8 @@ public interface IBytedanceReportMaterialDailyService extends IService<Bytedance
     List<BytedanceVideoEtlInfo> getSignatureByDate(String date);
 
     BytedanceVideoEtlInfo getEtlDataByParams(String signature, String date);
+
+    BytedanceCheckReportTaskInfo checkMatCostByParams(Long accountId, String stateDate);
+
+    BytedanceCheckReportTaskInfo checkImageCostByParams(Long accountId, String stateDate);
 }

+ 7 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ByteDanceHourlyAccountWarningServiceImpl.java

@@ -12,6 +12,7 @@ import cn.com.ctop.common.module.utils.SendMailUtil;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceAdvertiserHourlyReportMapper;
 import cn.com.ctop.toutiao.modules.report.service.IByteDanceHourlyAccountWarningService;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -35,6 +36,8 @@ public class ByteDanceHourlyAccountWarningServiceImpl implements IByteDanceHourl
     private MailLogMapper mailLogMapper;
     @Autowired
     private IProjectService projectService;
+    @Autowired
+    private CorpWexinUtils corpWexinUtils;
 
     /**
      * 头条账户 出价预警
@@ -123,8 +126,8 @@ public class ByteDanceHourlyAccountWarningServiceImpl implements IByteDanceHourl
             } catch (Exception e) {
                 e.printStackTrace();
             }
-            List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
-            CorpWexinUtils.sendMessage(wexinIds, text.toString());
+            List<JSONObject> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+            corpWexinUtils.sendMessage(wexinIds, text.toString());
         }
     }
 
@@ -162,8 +165,8 @@ public class ByteDanceHourlyAccountWarningServiceImpl implements IByteDanceHourl
                 e.printStackTrace();
             }
         }
-        List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
-        CorpWexinUtils.sendMessage(wexinIds, text.toString());
+        List<JSONObject> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+        corpWexinUtils.sendMessage(wexinIds, text.toString());
     }
 
 

+ 11 - 39
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAdvertiserDailyReportServiceImpl.java

@@ -4,6 +4,7 @@ import cn.com.ctop.toutiao.modules.report.DTO.AccountReportDTO;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceAdvertiserDailyReport;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceAdvertiserDailyReportMapper;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceAdvertiserDailyReportService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
@@ -21,45 +22,16 @@ import java.util.List;
 @Primary
 
 public class BytedanceAdvertiserDailyReportServiceImpl extends ServiceImpl<BytedanceAdvertiserDailyReportMapper, BytedanceAdvertiserDailyReport> implements IBytedanceAdvertiserDailyReportService {
-
-    public void bytedanceAccountReportStatistics(AccountReportDTO accountReportDTO){
-        String startDate = accountReportDTO.getStartDate();
-        String endDate = accountReportDTO.getEndDate();
-        BigDecimal discount = accountReportDTO.getDiscount();  //仅头条内广可用 折扣
-        BigDecimal point = accountReportDTO.getPoint();  //仅头条可用 返点
-        List<Long> accountIds = accountReportDTO.getAccountIds();
-        Integer statHour = accountReportDTO.getStatHour();
-        Integer type = accountReportDTO.getType();  //1今天  2昨天和其他单天 3近一周、15天、1月、3月按钮 4六个月、一年 5输入框输入的除了单天的时间段
-
-        //type=1分时操作
-        if(type == 1){
-
-        }else if(type == 2){
-
-        }else if(type == 3 || type == 5){
-
+    @Override
+    public BytedanceAdvertiserDailyReport getByParams(Long accountId, String stateDate) {
+        QueryWrapper<BytedanceAdvertiserDailyReport> queryWrapper = new QueryWrapper<>();
+        if(null!=accountId&&accountId!=0){
+            queryWrapper.eq("advertiser_id",accountId);
         }
-
-
-
-
-
-
-
-    }
-
-
-
-
-    public void bytedanceAccountReportListAndCollect(AccountReportDTO accountReportDTO){
-
-
-
-
-
-
-
+        if(null!=stateDate&&!"".equals(stateDate.trim())){
+            queryWrapper.eq("stat_datetime",stateDate+" 00:00:00");
+        }
+        queryWrapper.orderByDesc("id").last("limit 1");
+        return this.getOne(queryWrapper);
     }
-
-
 }

+ 0 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceCampaignDailyReportServiceImpl.java


Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác