瀏覽代碼

Merge branch 'master' into jiaoyang

# Conflicts:
#	module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java
#	module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateServiceImpl.java
yumeng 4 年之前
父節點
當前提交
88dcae3c1d
共有 100 個文件被更改,包括 7926 次插入1531 次删除
  1. 6 0
      jeecg-boot-module-system/pom.xml
  2. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AiKuaishouAdvertiserStrategyController.java
  3. 2 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  4. 4 27
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  5. 265 0
      jeecg-boot-module-system/src/main/resources/application-preprod.yml
  6. 50 12
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  7. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  8. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  9. 9 3
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  10. 17 25
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java
  11. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  12. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/ConverterUtils.java
  13. 16 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  14. 10 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/StringUtils.java
  15. 1 1
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceAiCreateJob.java
  16. 5 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceEtlVideoJob.java
  17. 7 0
      module-job-kuaishou/pom.xml
  18. 57 32
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/CrowdListQueryJob.java
  19. 10 2
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEtlVideoJob.java
  20. 29 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouLandpagesJob.java
  21. 239 0
      module-job-kuaishou/src/main/resources/application-preprod.yml
  22. 11 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouCreateCreativeController.java
  23. 257 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouAppMultipleBidsController.java
  24. 436 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouAppPackageController.java
  25. 0 403
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouCrowdPackController.java
  26. 493 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouDirectionalPackageController.java
  27. 337 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouLandpagePackageController.java
  28. 412 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouPopulationPackageController.java
  29. 7 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAdvertiserStrategy.java
  30. 295 148
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouUnitLevelOperationRecord.java
  31. 77 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaiShouAppMultipleBids.java
  32. 71 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouAppGroup.java
  33. 126 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouAppPackage.java
  34. 79 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouAppPackageRel.java
  35. 232 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouDirectionalPackage.java
  36. 109 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouDirectionalaPckageRel.java
  37. 119 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouLandpagePackage.java
  38. 63 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouLandpagePackageRel.java
  39. 59 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouPopulationGroup.java
  40. 93 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouPopulationPackage.java
  41. 102 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouPopulationPackageRel.java
  42. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaiShouAppMultipleBidsMapper.java
  43. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppGroupMapper.java
  44. 30 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppPackageMapper.java
  45. 29 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppPackageRelMapper.java
  46. 0 41
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouCrowdPackMapper.java
  47. 28 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouDirectionalPackageMapper.java
  48. 29 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouDirectionalPckageRelMapper.java
  49. 29 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouLandpagePackageMapper.java
  50. 20 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouLandpagePackageRelMapper.java
  51. 22 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationGroupMapper.java
  52. 30 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationPackageMapper.java
  53. 40 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationPackageRelMapper.java
  54. 36 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaiShouAppMultipleBidsMapper.xml
  55. 22 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppGroupMapper.xml
  56. 117 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppPackageMapper.xml
  57. 95 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppPackageRelMapper.xml
  58. 0 344
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouCrowdPackMapper.xml
  59. 97 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouDirectionalPackageMapper.xml
  60. 94 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouDirectionalPckageRelMapper.xml
  61. 94 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouLandpagePackageMapper.xml
  62. 12 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouLandpagePackageRelMapper.xml
  63. 29 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationGroupMapper.xml
  64. 96 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationPackageMapper.xml
  65. 194 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationPackageRelMapper.xml
  66. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaiShouAppMultipleBidsService.java
  67. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouAppGroupService.java
  68. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouAppPackageRelService.java
  69. 37 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouAppPackageService.java
  70. 0 31
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouCrowdPackService.java
  71. 48 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouDirectionalPackageService.java
  72. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouDirectionalPckageRelService.java
  73. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouLandpagePackageRelService.java
  74. 38 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouLandpagePackageService.java
  75. 28 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouPopulationGroupService.java
  76. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouPopulationPackageRelService.java
  77. 37 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouPopulationPackageService.java
  78. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/KuaishouAppPackageRelMapper.java
  79. 410 166
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java
  80. 48 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouAppMultipleBidsServiceImpl.java
  81. 57 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java
  82. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouAppGroupServiceImpl.java
  83. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouAppPackageRelServiceImpl.java
  84. 310 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouAppPackageServiceImpl.java
  85. 0 277
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouCrowdPackServiceImpl.java
  86. 660 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouDirectionalPackageServiceImpl.java
  87. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouDirectionalTemplateRelServiceImpl.java
  88. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouLandpagePackageRelServiceImpl.java
  89. 172 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouLandpagePackageServiceImpl.java
  90. 74 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouPopulationGroupServiceImpl.java
  91. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouPopulationPackageRelServiceImpl.java
  92. 356 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouPopulationPackageServiceImpl.java
  93. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/DingPanController.java
  94. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouVideoGetController.java
  95. 44 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateController.java
  96. 36 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTarget.java
  97. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTemplate.java
  98. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouTemplate.java
  99. 36 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouTemplateTarget.java
  100. 0 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouPopulationMapper.java

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

@@ -259,6 +259,12 @@
             </properties>
             </properties>
         </profile>
         </profile>
         <profile>
         <profile>
+            <id>preprod</id>
+            <properties>
+                <activatedProperties>preprod</activatedProperties>
+            </properties>
+        </profile>
+        <profile>
             <id>wps</id>
             <id>wps</id>
             <properties>
             <properties>
                 <activatedProperties>wps</activatedProperties>
                 <activatedProperties>wps</activatedProperties>

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

@@ -3,13 +3,16 @@ package org.jeecg.modules.ctop.controller;
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 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.common.module.utils.QueryGenerator;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -43,6 +46,8 @@ public class AiKuaishouAdvertiserStrategyController {
     private IUserAllocationService allocationService;
     private IUserAllocationService allocationService;
     @Autowired
     @Autowired
     private ISysRoleService sysRoleService;
     private ISysRoleService sysRoleService;
+    @Autowired
+    private IKuaiShouAppMultipleBidsService kuaiShouAppMultipleBidsService;
 
 
     /**
     /**
      * 分页列表查询
      * 分页列表查询
@@ -254,6 +259,8 @@ public class AiKuaishouAdvertiserStrategyController {
      * @param id
      * @param id
      * @return
      * @return
      */
      */
+
+
     @GetMapping(value = "/queryById")
     @GetMapping(value = "/queryById")
     public Result<AiKuaishouAdvertiserStrategy> queryById(@RequestParam(name = "id", required = true) String id) {
     public Result<AiKuaishouAdvertiserStrategy> queryById(@RequestParam(name = "id", required = true) String id) {
         Result<AiKuaishouAdvertiserStrategy> result = new Result<>();
         Result<AiKuaishouAdvertiserStrategy> result = new Result<>();
@@ -261,6 +268,14 @@ public class AiKuaishouAdvertiserStrategyController {
         if (aiKuaishouAdvertiserStrategy == null) {
         if (aiKuaishouAdvertiserStrategy == null) {
             result.error500("未找到对应实体");
             result.error500("未找到对应实体");
         } else {
         } else {
+            if (aiKuaishouAdvertiserStrategy.getMultipleBids() == 1) {
+                List<JSONObject> appInfoList = kuaiShouAppMultipleBidsService.getAppInfiList(aiKuaishouAdvertiserStrategy.getAccountId(), aiKuaishouAdvertiserStrategy.getAppIdArray());
+                if (!Check.isNull(appInfoList)) {
+                    aiKuaishouAdvertiserStrategy.setAppInfoList(appInfoList);
+
+                }
+            }
+
             result.setResult(aiKuaishouAdvertiserStrategy);
             result.setResult(aiKuaishouAdvertiserStrategy);
             result.setSuccess(true);
             result.setSuccess(true);
         }
         }

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

@@ -149,7 +149,8 @@ public class MaterialInfoController {
     public Result<Object> watermarkVideo(@RequestParam(name = "id") String id, @RequestParam(name = "watermarkTemplateId") Long watermarkTemplateId) {
     public Result<Object> watermarkVideo(@RequestParam(name = "id") String id, @RequestParam(name = "watermarkTemplateId") Long watermarkTemplateId) {
         Result<Object> result = new Result<>();
         Result<Object> result = new Result<>();
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        materialInfoService.watermarkVideo(id, watermarkTemplateId, sysUser.getId());
+        Thread thread = new Thread(()-> materialInfoService.watermarkVideo(id, watermarkTemplateId, sysUser.getId()));
+        thread.start();
         result.setCode(200);
         result.setCode(200);
         result.setSuccess(true);
         result.setSuccess(true);
         result.setMessage("水印合成任务执行成功,请稍后查看");
         result.setMessage("水印合成任务执行成功,请稍后查看");

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

@@ -1021,39 +1021,17 @@ public class TestController {
     }
     }
 
 
 
 
-    @GetMapping(value = "/createTask")
-    public String createTask(Long accountId) {
-        Result<String> result = new Result<String>();
-        try {
-            QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
-            oauthTokenQueryWrapper.eq("media_id", 2);
-            oauthTokenQueryWrapper.eq("account_id", accountId);
-            oauthTokenQueryWrapper.last("limit 1");
-            CtopOauthToken token = tokenMapper.selectOne(oauthTokenQueryWrapper);
-            String endDateStr = DateUtils.getDate("yyyy-MM-dd");
-            String startDate = DateUtils.addMonth(endDateStr, -6);
-            historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            result.setSuccess(false);
-        }
-        return "success";
-    }
-
-
     @GetMapping(value = "/getHistoryData")
     @GetMapping(value = "/getHistoryData")
-    public String getHistoryData() {
+    public String getHistoryData(String startDate, String endDate) {
         Result<String> result = new Result<>();
         Result<String> result = new Result<>();
         try {
         try {
-            String endDateStr = DateUtils.getDate("yyyy-MM-dd");
-            String startDate = DateUtils.addMonth(endDateStr, -6);
+
             QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
             QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
             tokenQueryWrapper.eq("media_id", 2);
             tokenQueryWrapper.eq("media_id", 2);
             List<CtopOauthToken> ctopOauthTokens = tokenMapper.selectList(tokenQueryWrapper);
             List<CtopOauthToken> ctopOauthTokens = tokenMapper.selectList(tokenQueryWrapper);
             if (!Check.isNull(ctopOauthTokens)) {
             if (!Check.isNull(ctopOauthTokens)) {
                 for (CtopOauthToken token : ctopOauthTokens) {
                 for (CtopOauthToken token : ctopOauthTokens) {
-                    historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), "2020-09-01", "2020-10-01", CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
+                    historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDate, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
                 }
                 }
 
 
             }
             }
@@ -1480,7 +1458,7 @@ public class TestController {
     private IKuaiShouGroupService kuaiShouGroupService;
     private IKuaiShouGroupService kuaiShouGroupService;
     @Autowired
     @Autowired
     private IKuaishouStrategyService kuaishouStrategyService;
     private IKuaishouStrategyService kuaishouStrategyService;
-
+    static ExecutorService executorServic1e = Executors.newFixedThreadPool(5);
     /**
     /**
      * 勿动勿删,煜一人群报表数据拉取接口。
      * 勿动勿删,煜一人群报表数据拉取接口。
      *
      *
@@ -1507,7 +1485,6 @@ public class TestController {
         } else {
         } else {
             dayList = DateUtils.getDays(startTime, endTime);
             dayList = DateUtils.getDays(startTime, endTime);
         }
         }
-        ExecutorService executorServic1e = Executors.newFixedThreadPool(8);
         int page = 1;
         int page = 1;
         int pageSize = 2000;
         int pageSize = 2000;
         dayList.forEach(date -> executorServic1e.submit(() -> {
         dayList.forEach(date -> executorServic1e.submit(() -> {

+ 265 - 0
jeecg-boot-module-system/src/main/resources/application-preprod.yml

@@ -0,0 +1,265 @@
+server:
+  port: 8807
+  ip: 39.97.120.42
+  servlet:
+    context-path: /jeecg-boot
+    compression:
+      enabled: true
+      mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
+management:
+  endpoints:
+    web:
+      exposure:
+        include: metrics,httptrace
+spring:
+  servlet:
+    multipart:
+      max-file-size: -1
+      max-request-size: -1
+  mail:
+    host: smtp.exmail.qq.com
+    username: notice@c-top.com.cn
+    password: Hcst@2019
+    properties:
+      mail:
+        smtp:
+          ssl.enable: enable
+          auth: true
+          starttls:
+            enable: true
+            required: true
+    ## quartz定时任务,采用数据库方式
+    #quartz:
+    #job-store-type: jdbc
+  #json 时间戳统一转换
+  jackson:
+    date-format:   yyyy-MM-dd HH:mm:ss
+    time-zone:   GMT+8
+  jpa:
+    open-in-view: false
+  activiti:
+    check-process-definitions: false
+    #启用作业执行器
+    async-executor-activate: false
+    #启用异步执行器
+    job-executor-activate: false
+  aop:
+    proxy-target-class: true
+  #配置freemarker
+  freemarker:
+    # 设置模板后缀名
+    suffix: .ftl
+    # 设置文档类型
+    content-type: text/html
+    # 设置页面编码格式
+    charset: UTF-8
+    # 设置页面缓存
+    cache: false
+    prefer-file-system-access: false
+    # 设置ftl文件路径
+    template-loader-path:
+      - classpath:/templates
+  # 设置静态文件路径,js,css等
+  mvc:
+    static-path-pattern: /**
+  resource:
+    static-locations: classpath:/static/,classpath:/public/
+  autoconfigure:
+    exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
+  datasource:
+    url: jdbc:mysql://172.30.0.4:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    username: hcst
+    password: hcst@2020
+    driver-class-name: com.mysql.jdbc.Driver
+    druid:
+      stat-view-servlet:
+        loginUsername: admin
+        loginPassword: hcst20161
+        enabled: true
+      web-stat-filter:
+        enabled: true
+    #      remove-abandoned: false
+    dynamic:
+      druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
+        # 连接池的配置信息
+        # 初始化大小,最小,最大
+        connection-init-sql: set names utf8mb4
+        initial-size: 5
+        min-idle: 5
+        maxActive: 20
+        # 配置获取连接等待超时的时间
+        maxWait: 60000
+        # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+        timeBetweenEvictionRunsMillis: 60000
+        # 配置一个连接在池中最小生存的时间,单位是毫秒
+        minEvictableIdleTimeMillis: 300000
+        validationQuery: SELECT 1 FROM DUAL
+        testWhileIdle: true
+        testOnBorrow: false
+        testOnReturn: false
+        # 打开PSCache,并且指定每个连接上PSCache的大小
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 20
+        # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+        filters: stat,wall,slf4j
+        # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
+        connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
+      datasource:
+        master:
+          url: jdbc:mysql://172.30.0.4:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          username: hcst
+          password: hcst@2020
+          driver-class-name: com.mysql.jdbc.Driver
+          # 多数据源配置
+          #multi-datasource1:
+          #url: jdbc:mysql://localhost:3306/jeecg-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
+          #username: root
+          #password: root
+          #driver-class-name: com.mysql.jdbc.Driver
+  #redis 配置
+  redis:
+    database: 0
+    host: 172.30.0.17
+    lettuce:
+      pool:
+        max-active: 8   #最大连接数据库连接数,设 0 为没有限制
+        max-idle: 8     #最大等待连接中的数量,设 0 为没有限制
+        max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
+        min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
+      shutdown-timeout: 100ms
+    password: foobared
+    port: 6379
+#mybatis plus 设置
+mybatis-plus:
+  mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml,classpath*:cn/com/ctop/**/xml/*Mapper.xml
+  global-config:
+    # 关闭MP3.0自带的banner
+    banner: false
+    db-config:
+      #主键类型  0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
+      id-type: 4
+      # 默认数据库表下划线命名
+      table-underline: true
+#  configuration:
+#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+#jeecg专用配置
+jeecg:
+  #积木报表设置
+  jmreport:
+    mode: dev
+    #是否需要校验token
+    is_verify_token: false
+    #必须校验方法
+    verify_methods: remove,delete,save,add,update
+  elasticsearch:
+    cluster-nodes:
+    check-enabled: false
+  uploadType:
+  oss:
+    endpoint:
+    accessKey:
+    secretKey:
+    bucketName:
+    staticDomain:
+  sms:
+    accessKeyId:
+    accessKeySecret:
+  minio:
+    minio_url:
+    minio_name:
+    minio_pass:
+    bucketName:
+  ffmpeg:
+    bin: ffmpeg
+  path:
+    #文件上传根目录 设置
+    upload: /data/upload
+    #webapp文件路径
+    webapp: /data/webapp
+    video-upload: /data/upload/video/
+    image-upload: /data/upload/image/
+    kuaishou-agent-image: /data/upload/image/temp.png
+    kuaishou-account-captcha-image: /data/upload/image/captcha.png
+    chrome-driver: /usr/bin/chromedriver
+    csv-upload: /data/upload/csv/
+    bak-database-file: /data/data/bak/
+    report-history: /data/upload/report/history/
+    report-daily: /data/upload/report/daily/
+kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
+  group-control:
+    path: http://39.106.184.70
+    port: 4723
+logging:
+  level:
+    root: info
+  config: classpath:logback-prod.xml
+chrome:
+  script:
+    clean: sh /data/webapp/cleanProcess.sh
+cas:
+  prefixUrl:
+oss:
+  replace:
+    replace-value: oss-cn-beijing
+    replace-old-value: oss-cn-beijing
+    download: /data/file/video/
+
+zip:
+  local:
+    download-path: /data/unzip/
+bytedance:
+  appId: 1635316529903624
+  secret: 0c51523e90d6166418fc8421a4896808e90e26f4
+  url:
+    auth-prefix: https://ad.oceanengine.com/openapi
+    api-prefix: https://ad.oceanengine.com/open_api
+    callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/bytedance
+    refresh-token: /oauth2/refresh_token
+    advertiser-info: /2/advertiser/public_info/
+    ad-get: /2/ad/get/
+    ad-create: /2/ad/create/
+    ad-update: /2/ad/update/
+    ad-update-status: /2/ad/update/status/
+    ad-update-bid: /2/ad/update/bid/
+    ad-update-budget: /2/ad/update/budget/
+    ad-update-reject-reason: 2/ad/reject_reason/
+    campaign-get: /2/campaign/get/
+    campaign-create: /2/campaign/create/
+    campaign-update-status: /2/campaign/update/status/
+    campaign-update: /2/campaign/update/
+    dmp-custom-audience-select: /2/dmp/custom_audience/select/
+    file-video-ad: /2/file/video/ad/
+    file-image-ad: /2/file/image/ad/
+    creative-update-status: /2/creative/update/status/
+    creative-material-get: /2/creative/material/read/
+    creative-create-v2: /2/creative/create_v2/
+    creative-get: /2/creative/get/
+    creative-read: /2/creative/read_v2/
+    creative-update: /2/creative/update_v2/
+    creative-reject-reason: /2/creative/reject_reason/
+    advertiser-report-get: /2/report/advertiser/get/
+    campaign-report-get: /2/report/campaign/get/
+    ad-report-get: /2/report/ad/get/
+    ad-creative-get: /2/report/creative/get/
+    advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/
+ai:
+  callback:
+    callback-unit-url: http://139.186.27.96:31012/ai_callback_add_group
+    callback-creative-url: http://139.186.27.96:31012/ai_callback_add_creative
+xxl-job:
+  requestUrl: http://api.tjyourong.com.cn

+ 50 - 12
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -11,11 +11,13 @@ import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouAccountMaterialRepo
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyImageService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyImageService;
 import cn.com.ctop.oa.modules.service.IWechatNoListService;
 import cn.com.ctop.oa.modules.service.IWechatNoListService;
 import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
 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.material.service.IByteDanceCampaignService;
 import cn.com.ctop.toutiao.modules.report.service.*;
 import cn.com.ctop.toutiao.modules.report.service.*;
 import com.csvreader.CsvReader;
 import com.csvreader.CsvReader;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.common.util.RedisUtil;
 import org.junit.Test;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -48,12 +50,18 @@ public class SampleTest {
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
     @Autowired
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
     private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private RedisUtil redisUtil;
 
 
     @Test
     @Test
     public void loadKuaishouCookie() throws ParseException {
     public void loadKuaishouCookie() throws ParseException {
 
 
+        redisUtil.set("11sdfhgjksdhfjksdhfjksdhfkjsjkfhkjsddhfjksdhfkjhsjkfhjkshfjksdhfjksdhfjkshdjkfhsjkdfhkjsd1","hahahaha",5);
+        Object o = redisUtil.get("11sdfhgjksdhfjksdhfjksdhfkjsjkfhkjsddhfjksdhfkjhsjkfhjkshfjksdhfjksdhfjkshdjkfhsjkdfhkjsd1");
+        System.err.println(o);
+
 
 
-        try {
+        /*try {
             // 用来保存数据
             // 用来保存数据
             ArrayList<String[]> csvFileList = new ArrayList<String[]>();
             ArrayList<String[]> csvFileList = new ArrayList<String[]>();
             // 定义一个CSV路径
             // 定义一个CSV路径
@@ -77,7 +85,7 @@ public class SampleTest {
             }
             }
         } catch (IOException e) {
         } catch (IOException e) {
             e.printStackTrace();
             e.printStackTrace();
-        }
+        }*/
 
 
 
 
 
 
@@ -122,18 +130,13 @@ public class SampleTest {
     @Autowired
     @Autowired
     private IBytedanceReportService bytedanceReportService;
     private IBytedanceReportService bytedanceReportService;
 
 
+    @Autowired
+    private IByteDanceAdvertiserDataService advertiserDataService;
+
     @Test
     @Test
     public void loadBytedanceVideoReportData() {
     public void loadBytedanceVideoReportData() {
-        String startDate = "2021-04-01";
-        String endDate = "2021-04-26";
-        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
-        Long start = System.currentTimeMillis();
-
-        tokens.forEach(token -> {
-            bytedanceReportService.bytedanceVideoMaterialReport(token, startDate, endDate);
-        });
-        Long end = System.currentTimeMillis();
-        log.info("查询素材消耗用时:{}毫秒", end - start);
+        CtopOauthToken token = tokenService.getTokenByAccountId(1696831659659278L);
+        advertiserDataService.getMaterialList(token);
     }
     }
 
 
     @Autowired
     @Autowired
@@ -215,4 +218,39 @@ public class SampleTest {
         }
         }
     }
     }
 
 
+    @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 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);
+    }
 }
 }

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

@@ -44,4 +44,6 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     List<UserAllocation> listByMediaId(@Param("mediaId")String mediaId, @Param("accountStatus")Integer accountStatus);
     List<UserAllocation> listByMediaId(@Param("mediaId")String mediaId, @Param("accountStatus")Integer accountStatus);
 
 
     List<JSONObject> getAccountListByProjectList(@Param("list") List list);
     List<JSONObject> getAccountListByProjectList(@Param("list") List list);
+
+    List<Long> getValidProjectIds(@Param("mediaId")  Integer mediaId);
 }
 }

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -12,6 +12,7 @@
         ctop_user_allocation a
         ctop_user_allocation a
         left join ctop_project b on a.project_id = b.id
         left join ctop_project b on a.project_id = b.id
         where b.id = #{projectId}
         where b.id = #{projectId}
+        and account_status = 0
     </select>
     </select>
 
 
     <select id="queryAdvertiserId" resultType="String">
     <select id="queryAdvertiserId" resultType="String">
@@ -71,6 +72,16 @@
     </select>
     </select>
 
 
 
 
+    <select id="getValidProjectIds" resultType="java.lang.Long">
+        SELECT project_id FROM ctop_user_allocation t1
+        where account_status = 0
+        <if test="mediaId != null">
+              AND media_id = #{mediaId}
+        </if>
+        GROUP BY project_id
+    </select>
+
+
     <select id="getAccountIdListByUserId" resultType="com.alibaba.fastjson.JSONObject">
     <select id="getAccountIdListByUserId" resultType="com.alibaba.fastjson.JSONObject">
     SELECT
     SELECT
     t1.account_id as 'accountId',
     t1.account_id as 'accountId',

+ 9 - 3
module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.common.module.service;
 package cn.com.ctop.common.module.service;
 
 
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.entity.UserAllocation;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 
@@ -18,7 +17,7 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
 
     UserAllocation getByAccountId(Long accountId);
     UserAllocation getByAccountId(Long accountId);
 
 
-    List<UserAllocation> getByParams(Long projectId, String systemType,Integer accountStatus);
+    List<UserAllocation> getByParams(Long projectId, String systemType, Integer accountStatus);
 
 
     Map<String, Object> getPangolinAccountListByParams(String userId, JSONObject data);
     Map<String, Object> getPangolinAccountListByParams(String userId, JSONObject data);
 
 
@@ -38,7 +37,7 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
 
     List<JSONObject> getAccountIdsByUserId(String userId);
     List<JSONObject> getAccountIdsByUserId(String userId);
 
 
-    List<UserAllocation> getUserAllocations(String mediaId ,int switchType);
+    List<UserAllocation> getUserAllocations(String mediaId, int switchType);
 
 
     JSONObject getSwitchStatusByAccount(Long accountId);
     JSONObject getSwitchStatusByAccount(Long accountId);
 
 
@@ -46,5 +45,12 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
 
     Map<Long, List<JSONObject>> getAccountListByProjectList(List<JSONObject> projectList);
     Map<Long, List<JSONObject>> getAccountListByProjectList(List<JSONObject> projectList);
 
 
+    /**
+     * 获取有效的项目ID集合
+     *
+     * @param mediaId 平台类型 1 头条 2快手
+     * @throws
+     */
+    List<Long> getValidProjectIds(Integer mediaId);
 
 
 }
 }

+ 17 - 25
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -3,10 +3,7 @@ package cn.com.ctop.common.module.service.impl;
 import cn.com.ctop.common.module.constant.CosConstant;
 import cn.com.ctop.common.module.constant.CosConstant;
 import cn.com.ctop.common.module.entity.*;
 import cn.com.ctop.common.module.entity.*;
 import cn.com.ctop.common.module.enums.MaterialSupplierEnum;
 import cn.com.ctop.common.module.enums.MaterialSupplierEnum;
-import cn.com.ctop.common.module.mapper.MaterialAscriptionMapper;
-import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
-import cn.com.ctop.common.module.mapper.MaterialParameterMapper;
-import cn.com.ctop.common.module.mapper.MaterialTagMapper;
+import cn.com.ctop.common.module.mapper.*;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.common.module.utils.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
@@ -52,19 +49,19 @@ import static cn.com.ctop.common.module.utils.CloudVideoProcessUtil.videoWaterma
 @Service
 @Service
 public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, MaterialInfo> implements IMaterialInfoService {
 public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, MaterialInfo> implements IMaterialInfoService {
 
 
-    @Autowired
-    private MaterialInfoMapper materialInfoMapper;
     private static ExecutorService uploadExecutorService = Executors.newFixedThreadPool(5);
     private static ExecutorService uploadExecutorService = Executors.newFixedThreadPool(5);
 
 
     @Resource
     @Resource
     private ITencentWatermarkTemplateService tencentWatermarkTemplateService;
     private ITencentWatermarkTemplateService tencentWatermarkTemplateService;
     @Resource
     @Resource
     private IVideoWatermarkTaskService videoWatermarkTaskService;
     private IVideoWatermarkTaskService videoWatermarkTaskService;
-    @Autowired
+    @Resource
+    private MaterialInfoMapper materialInfoMapper;
+    @Resource
     private MaterialParameterMapper materialParameterMapper;
     private MaterialParameterMapper materialParameterMapper;
-    @Autowired
+    @Resource
     private MaterialAscriptionMapper materialAscriptionMapper;
     private MaterialAscriptionMapper materialAscriptionMapper;
-    @Autowired
+    @Resource
     private MaterialTagMapper materialTagMapper;
     private MaterialTagMapper materialTagMapper;
     @Resource
     @Resource
     private IMaterialCutFrameService materialCutFrameService;
     private IMaterialCutFrameService materialCutFrameService;
@@ -475,6 +472,8 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     }
     }
 
 
 
 
+
+
     @Autowired
     @Autowired
     private IMaterialImageInfoService materialImageInfoService;
     private IMaterialImageInfoService materialImageInfoService;
     @Autowired
     @Autowired
@@ -509,7 +508,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
             info.setProjectId(projectId);
             info.setProjectId(projectId);
             info.setWatermarkCode(json.getString("watermarkCode"));
             info.setWatermarkCode(json.getString("watermarkCode"));
             info.setStatus(0);
             info.setStatus(0);
-            info.setMaterialName(json.getString("materialName"));
+            info.setMaterialName(StringUtils.getFileNameNoEx(json.getString("materialName")));
             info.setWatermarkMaterialName(json.getString("watermarkMaterialName"));
             info.setWatermarkMaterialName(json.getString("watermarkMaterialName"));
             info.setMaterialDescribe(json.getString("materialDescribe"));
             info.setMaterialDescribe(json.getString("materialDescribe"));
             info.setCreateTime(new Date());
             info.setCreateTime(new Date());
@@ -559,7 +558,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                 MaterialAscription materialAscription = new MaterialAscription();
                 MaterialAscription materialAscription = new MaterialAscription();
                 materialAscription.setMaterialId(info.getCode());
                 materialAscription.setMaterialId(info.getCode());
                 String clipId = ascription.getString("clipId");
                 String clipId = ascription.getString("clipId");
-                if (null != clipId && !"".equals(clipId.trim())) {
+                if(null!=clipId&&!"".equals(clipId.trim())){
                     materialAscription.setClipId(clipId);
                     materialAscription.setClipId(clipId);
                 }
                 }
                 materialAscription.setShotId(ascription.getString("shotId"));
                 materialAscription.setShotId(ascription.getString("shotId"));
@@ -686,22 +685,15 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
 
 
 
 
     private void insertTagList(String code, String userId, JSONArray tagList) {
     private void insertTagList(String code, String userId, JSONArray tagList) {
-        try {
-            if (null != tagList && !tagList.isEmpty()) {
-                for (int m = 0; m < tagList.size(); m++) {
-                    Long tagId = tagList.getLong(m);
-                    TagInfo tagInfo = tagInfoService.getById(tagId);
-                    MaterialTagInfo setTag = new MaterialTagInfo(code, tagInfo, userId);
-                    setTag.setCategoryId(tagInfo.getTagCategoryId());
-                    materialTagInfoService.save(setTag);
-                }
+        if (null != tagList && !tagList.isEmpty()) {
+            for (int m = 0; m < tagList.size(); m++) {
+                Long tagId = tagList.getLong(m);
+                TagInfo tagInfo = tagInfoService.getById(tagId);
+                MaterialTagInfo setTag = new MaterialTagInfo(code, tagInfo, userId);
+                setTag.setCategoryId(tagInfo.getTagCategoryId());
+                materialTagInfoService.save(setTag);
             }
             }
-        } catch (Exception e) {
-            e.printStackTrace();
-
         }
         }
-
-
     }
     }
 
 
     @Autowired
     @Autowired

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -175,4 +175,9 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
         }
         }
         return map;
         return map;
     }
     }
+
+    @Override
+    public List<Long> getValidProjectIds(Integer mediaId) {
+        return userAllocationMapper.getValidProjectIds(mediaId);
+    }
 }
 }

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/utils/ConverterUtils.java

@@ -343,7 +343,7 @@ public class ConverterUtils {
      */
      */
     public static Integer getAsInteger(final Object obj) {
     public static Integer getAsInteger(final Object obj) {
         final Number answer = getAsNumber(obj);
         final Number answer = getAsNumber(obj);
-        if (answer == null) {
+        if (Check.isNull(answer)) {
             return null;
             return null;
         } else if (answer instanceof Integer) {
         } else if (answer instanceof Integer) {
             return (Integer) answer;
             return (Integer) answer;

+ 16 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -83,7 +83,23 @@ public class KuaishouInterfaceConstant {
      * 创建定向模板
      * 创建定向模板
      */
      */
     public static final String TEMPLATE_CREATE = "/rest/openapi/v1/target/template/create";
     public static final String TEMPLATE_CREATE = "/rest/openapi/v1/target/template/create";
+
     public static final String TEMPLATE_UPDATE = "/rest/openapi/v1/target/template/update";
     public static final String TEMPLATE_UPDATE = "/rest/openapi/v1/target/template/update";
+
+    /**
+     * 删除定向模板
+     */
+    public static final String TEMPLATE_DELETE = "/rest/openapi/v1/target/template/delete";
+    /**
+     * 获取行为与兴趣"类目"
+     */
+    public static final String BEHAVIOR_INTEREST = "/rest/openapi/v1/tool/label/behavior_interest";
+
+    /**
+     * 获取行为兴趣"关键词"
+     */
+    public static final String KEYWORD_QUERY = "/rest/openapi/v1/tool/keyword/query";
+
     /**
     /**
      * 获取地域信息
      * 获取地域信息
      */
      */

+ 10 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/StringUtils.java

@@ -21,6 +21,16 @@ public class StringUtils {
         return list;
         return list;
     }
     }
 
 
+    public static String getFileNameNoEx(String filename) {
+        if ((filename != null) && (filename.length() > 0)) {
+            int dot = filename.lastIndexOf('.');
+            if ((dot >-1) && (dot < (filename.length()))) {
+                return filename.substring(0, dot);
+            }
+        }
+        return filename;
+    }
+
     /**
     /**
      * 将下划线风格转换为驼峰风格
      * 将下划线风格转换为驼峰风格
      * @param inputString
      * @param inputString

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

@@ -9,7 +9,7 @@ import java.util.Date;
 
 
 @Component
 @Component
 public class BytedanceAiCreateJob {
 public class BytedanceAiCreateJob {
-    private static final String URLPREFIX = "http://118.24.244.213:8080/bytedance-api//advertiser/aiBytedanceAdvertiserStrategy/autoCreateCreative?hour=";
+    private static final String URLPREFIX = "http://118.24.244.213:8080/bytedance-api/advertiser/aiBytedanceAdvertiserStrategy/autoCreateCreative?hour=";
     @XxlJob("bytedanceAutoCreateJob")
     @XxlJob("bytedanceAutoCreateJob")
     public void execute() throws Exception {
     public void execute() throws Exception {
         String hour = DateUtils.getNowHour(new Date());
         String hour = DateUtils.getNowHour(new Date());

+ 5 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceEtlVideoJob.java

@@ -41,4 +41,9 @@ public class BytedanceEtlVideoJob {
     public void updBytedanceVideoJob() throws Exception {
     public void updBytedanceVideoJob() throws Exception {
         etlBytedanceReportVideoDailyService.updBytedanceVideo();
         etlBytedanceReportVideoDailyService.updBytedanceVideo();
     }
     }
+
+    @XxlJob("etlBytedanceVideoJob")
+    public void etlBytedanceVideoJob() throws Exception {
+        etlBytedanceReportVideoDailyService.etlBytedanceVideo();
+    }
 }
 }

+ 7 - 0
module-job-kuaishou/pom.xml

@@ -210,6 +210,13 @@
             </properties>
             </properties>
         </profile>
         </profile>
         <profile>
         <profile>
+            <id>preprod</id>
+            <properties>
+                <activatedProperties>preprod</activatedProperties>
+            </properties>
+        </profile>
+
+        <profile>
             <id>jiaoyang</id>
             <id>jiaoyang</id>
             <properties>
             <properties>
                 <activatedProperties>jiaoyang</activatedProperties>
                 <activatedProperties>jiaoyang</activatedProperties>

+ 57 - 32
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/CrowdListQueryJob.java

@@ -3,18 +3,22 @@ package cn.com.ctop.job.kuaishou.handler;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
-import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouCrowdPackMapper;
-import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouCrowdPackService;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageMapper;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageRelService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Date;
+import java.util.Hashtable;
 import java.util.List;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Executors;
@@ -24,13 +28,14 @@ public class CrowdListQueryJob {
     @Autowired
     @Autowired
     private ICtopOauthTokenService tokenService;
     private ICtopOauthTokenService tokenService;
     @Autowired
     @Autowired
-    private KuaishouCrowdPackMapper crowdPackMapper;
-    @Autowired
     private IKuaishouPopulationService iKuaishouPopulationService;
     private IKuaishouPopulationService iKuaishouPopulationService;
     @Autowired
     @Autowired
-    private IKuaishouCrowdPackService crowdPackService;
-
-    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+    private KuaishouPopulationPackageMapper kuaishouPopulationPackageMapper;
+    @Autowired
+    private KuaishouPopulationPackageRelMapper relMapper;
+    @Autowired
+    private IKuaishouPopulationPackageRelService relService;
+    static ExecutorService executorService = Executors.newFixedThreadPool(3);
 
 
     @XxlJob("crowdListQueryJob")
     @XxlJob("crowdListQueryJob")
     public void execute() {
     public void execute() {
@@ -40,36 +45,56 @@ public class CrowdListQueryJob {
                 list.add(i);
                 list.add(i);
             }
             }
         }
         }
-        list.forEach(status -> executorService.submit(() -> {
-            List<KuaishouCrowdPack> crowdList = crowdPackMapper.queryListByStatus();
-            for (KuaishouCrowdPack crowdPack : crowdList) {
-                CtopOauthToken token = tokenService.getTokenByAccountId(crowdPack.getAccountId());
-                JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(crowdPack.getAccountId(), token.getAccessToken(), status);
-                if (jsonObject.getInteger("code") == 0) {
-                    JSONObject data = jsonObject.getJSONObject("data");
-                    if (!Check.isNull(data)) {
-                        JSONArray details = data.getJSONArray("details");
-                        if (details.size() > 0) {
-                            for (int j = 0; j < details.size(); j++) {
-                                JSONObject obj = details.getJSONObject(j);
-                                if (Check.isNull(crowdPackMapper.queryByAccountId(obj.getLong("account_id"), obj.getLong("orientation_id")))) {
-                                    KuaishouCrowdPack oldPack = crowdPackMapper.queryByAccountId(null, obj.getLong("orientation_id"));
-                                    KuaishouCrowdPack crowdPackEntity = JSONObject.toJavaObject(obj, KuaishouCrowdPack.class);
-                                    if (!Check.isNull(oldPack)) {
-                                        crowdPackEntity.setStatDate(oldPack.getStatDate());
-                                        crowdPackEntity.setUrl(oldPack.getUrl());
-                                        crowdPackEntity.setSignature(oldPack.getSignature());
+        List<JSONObject> objs = kuaishouPopulationPackageMapper.queryListByStatus();
+        objs.forEach(o -> executorService.submit(() -> {
+            Long accountId = o.getLong("account_id");
+            Long projectId = o.getLong("project_id");
+            Hashtable newIds = new Hashtable();
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (!Check.isNull(token)) {
+                for (Integer status : list) {
+                    JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(accountId, token.getAccessToken(), status);
+                    if (jsonObject.getInteger("code") == 0) {
+                        JSONObject data = jsonObject.getJSONObject("data");
+                        if (!Check.isNull(data)) {
+                            JSONArray details = data.getJSONArray("details");
+                            if (details.size() > 0) {
+                                List<KuaishouPopulationPackageRel> rellist = new ArrayList<>();
+                                for (int j = 0; j < details.size(); j++) {
+                                    JSONObject obj = details.getJSONObject(j);
+                                    KuaishouPopulationPackageRel rel = JSONObject.parseObject(obj.toJSONString(), KuaishouPopulationPackageRel.class);
+                                    newIds.put(rel.getOrientationId(), rel.getOrientationId());
+                                    if (Check.isNull(relMapper.queryByOrientationId(rel.getOrientationId(), rel.getAccountId()))) {
+                                        rel.setProjectId(projectId);
+                                        rel.setDataStatus(1);
+                                        rel.setStatDate(DateUtils.formatDate(new Date()));
+                                        rellist.add(rel);
+                                    } else {
+                                        rel.setDataStatus(1);
+                                        relMapper.updateStatus(rel);
                                     }
                                     }
-                                    crowdPackEntity.setMessage("PUSH OK");
-                                    crowdPackEntity.setDataStatus(1);
-                                    crowdPackService.save(crowdPackEntity);
-                                } else {
-                                    crowdPackMapper.update(obj);
+                                }
+                                if (!Check.isNull(rellist)) {
+                                    relMapper.replaceBatch(rellist);
                                 }
                                 }
                             }
                             }
                         }
                         }
                     }
                     }
                 }
                 }
+                //查询现有的人群包ID集
+                List<Long> oldOrientationIds = relMapper.queryByOrientationId(null, accountId);
+                if (oldOrientationIds.size() != newIds.size()) {
+                    for (Long id : oldOrientationIds) {
+                        if (!newIds.contains(id)) {
+                            KuaishouPopulationPackageRel rel = new KuaishouPopulationPackageRel();
+                            rel.setDataStatus(0);
+                            rel.setOrientationId(id);
+                            rel.setAccountId(accountId);
+                            rel.setMessage("人群包已从媒体后台删除");
+                            relMapper.updateStatus(rel);
+                        }
+                    }
+                }
             }
             }
         }));
         }));
         XxlJobHelper.log("快手人群报表更新成功");
         XxlJobHelper.log("快手人群报表更新成功");

+ 10 - 2
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEtlVideoJob.java

@@ -2,6 +2,7 @@ package cn.com.ctop.job.kuaishou.handler;
 
 
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.material.service.IEtlKuaishouVideoInfoService;
 import cn.com.ctop.kuaishou.modules.material.service.IEtlKuaishouVideoInfoService;
+import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouAccountMaterialReportDailyService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
@@ -17,9 +18,10 @@ public class KuaishouEtlVideoJob {
     @Autowired
     @Autowired
     private IKuaiShouVideoGetService videoGetService;
     private IKuaiShouVideoGetService videoGetService;
     @Autowired
     @Autowired
+    private IEtlKuaishouAccountMaterialReportDailyService materialReportDailyService;
+    @Autowired
     private IEtlKuaishouVideoInfoService videoEtlInfoService;
     private IEtlKuaishouVideoInfoService videoEtlInfoService;
 
 
-
     @XxlJob("kuaishouEtlVideoJob")
     @XxlJob("kuaishouEtlVideoJob")
     public void execute() throws Exception {
     public void execute() throws Exception {
         Date startDate = DateUtils.addDay(new Date(), -2);
         Date startDate = DateUtils.addDay(new Date(), -2);
@@ -51,5 +53,11 @@ public class KuaishouEtlVideoJob {
             videoEtlInfoService.etlKuaishouVideoInfo(DateUtils.formatDate(DateUtils.addDay(startDate,i)));
             videoEtlInfoService.etlKuaishouVideoInfo(DateUtils.formatDate(DateUtils.addDay(startDate,i)));
         }
         }
     }
     }
-
+    @XxlJob("etlKuaishouAccountMaterialReportInfo")
+    public void etlKuaishouAccountMaterialReportInfo(){
+        Date startDate = new Date();
+        for(int i=1;i<=2;i++){
+            materialReportDailyService.etlKuaishouAccountMaterialReportInfo(DateUtils.formatDate(DateUtils.addDay(new Date(),-i)));
+        }
+    }
 }
 }

+ 29 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouLandpagesJob.java

@@ -0,0 +1,29 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
+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;
+
+@Component
+public class KuaishouLandpagesJob {
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    static ExecutorService executorService = Executors.newFixedThreadPool(3);
+
+    @XxlJob("kuaishouLandpagesJob")
+    public void execute() {
+        //获取快手有效的账户
+        List<Long> list = userAllocationService.getValidProjectIds(2);
+        list.forEach(projectId -> executorService.submit(() -> landpagePackageService.synchronousData(projectId)));
+        XxlJobHelper.log("快手落地页数据更新");
+    }
+}

+ 239 - 0
module-job-kuaishou/src/main/resources/application-preprod.yml

@@ -0,0 +1,239 @@
+management:
+  endpoints:
+    web:
+      exposure:
+        include: metrics,httptrace
+spring:
+  servlet:
+    multipart:
+      max-file-size: -1
+      max-request-size: -1
+  mail:
+    host: smtp.163.com
+    username: jeecgos@163.com
+    password: ??
+    properties:
+      mail:
+        smtp:
+          auth: true
+          starttls:
+            enable: true
+            required: true
+  #json 时间戳统一转换
+  jackson:
+    date-format:   yyyy-MM-dd HH:mm:ss
+    time-zone:   GMT+8
+  aop:
+    proxy-target-class: true
+  #配置freemarker
+  freemarker:
+    # 设置模板后缀名
+    suffix: .ftl
+    # 设置文档类型
+    content-type: text/html
+    # 设置页面编码格式
+    charset: UTF-8
+    # 设置页面缓存
+    cache: false
+    prefer-file-system-access: false
+    # 设置ftl文件路径
+    template-loader-path:
+      - classpath:/templates
+  # 设置静态文件路径,js,css等
+  mvc:
+    static-path-pattern: /**
+  resource:
+    static-locations: classpath:/static/,classpath:/public/
+  autoconfigure:
+    exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
+  datasource:
+    url: jdbc:mysql://172.30.0.4:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    username: hcst
+    password: hcst@2020
+    driver-class-name: com.mysql.jdbc.Driver
+    druid:
+      stat-view-servlet:
+        loginUsername: admin
+        loginPassword: hcst2016
+        enabled: true
+      web-stat-filter:
+        enabled: true
+    #      remove-abandoned: false
+    dynamic:
+      druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
+        # 连接池的配置信息
+        # 初始化大小,最小,最大
+        connection-init-sql: set names utf8mb4
+        initial-size: 5
+        min-idle: 5
+        maxActive: 20
+        # 配置获取连接等待超时的时间
+        maxWait: 60000
+        # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+        timeBetweenEvictionRunsMillis: 60000
+        # 配置一个连接在池中最小生存的时间,单位是毫秒
+        minEvictableIdleTimeMillis: 300000
+        validationQuery: SELECT 1 FROM DUAL
+        testWhileIdle: true
+        testOnBorrow: false
+        testOnReturn: false
+        # 打开PSCache,并且指定每个连接上PSCache的大小
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 20
+        # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+        filters: stat,slf4j
+        # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
+        connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
+      datasource:
+        master:
+          url: jdbc:mysql://172.30.0.4:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          username: hcst
+          password: hcst@2020
+          driver-class-name: com.mysql.jdbc.Driver
+  #redis 配置
+  redis:
+    database: 0
+    host: 172.30.0.17
+#    host: 127.0.0.1
+    lettuce:
+      pool:
+        max-active: 8   #最大连接数据库连接数,设 0 为没有限制
+        max-idle: 8     #最大等待连接中的数量,设 0 为没有限制
+        max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
+        min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
+      shutdown-timeout: 100ms
+    password: foobared
+    port: 6379
+#mybatis plus 设置
+mybatis-plus:
+  mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml,classpath*:cn/com/ctop/**/xml/*Mapper.xml
+  global-config:
+    # 关闭MP3.0自带的banner
+    banner: false
+    db-config:
+      #主键类型  0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
+      id-type: 4
+      # 默认数据库表下划线命名
+      table-underline: true
+#jeecg专用配置
+jeecg:
+  elasticsearch:
+    cluster-nodes:
+    check-enabled: false
+  uploadType:
+  oss:
+    endpoint:
+    accessKey:
+    secretKey:
+    bucketName:
+    staticDomain:
+  sms:
+    accessKeyId:
+    accessKeySecret:
+  minio:
+    minio_url:
+    minio_name:
+    minio_pass:
+    bucketName:
+  ffmpeg:
+    bin: ffmpeg
+  path:
+    #文件上传根目录 设置
+    upload: /data/upload
+    #webapp文件路径
+    webapp: /data/webapp
+    video-upload: /data/upload/video/
+    image-upload: /data/upload/image/
+    chrome-driver: /usr/bin/chromedriver
+    csv-upload: /data/upload/csv/
+    bak-database-file: /data/data/bak/
+    report-history: /data/upload/report/history/
+    report-daily: /data/upload/report/daily/
+    kuaishou-agent-image: /data/upload/image/temp.png
+    kuaishou-account-captcha-image: /data/upload/image/captcha.png
+kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
+  group-control:
+    path: http://39.106.184.70
+    port: 4723
+logging:
+  level:
+    root: info
+  config: classpath:logback-prod.xml
+chrome:
+  script:
+    clean: sh /data/webapp/cleanProcess.sh
+oss:
+  replace:
+    replace-value: oss-cn-beijing-internal
+    replace-old-value: oss-cn-beijing
+    download: /data/file/video/
+bytedance:
+  appId: 1635316529903624
+  secret: 0c51523e90d6166418fc8421a4896808e90e26f4
+  url:
+    auth-prefix: https://ad.oceanengine.com/openapi
+    api-prefix: https://ad.oceanengine.com/open_api
+    callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/bytedance
+    refresh-token: /oauth2/refresh_token
+    advertiser-info: /2/advertiser/public_info/
+    ad-get: /2/ad/get/
+    ad-create: /2/ad/create/
+    ad-update: /2/ad/update/
+    ad-update-status: /2/ad/update/status/
+    ad-update-bid: /2/ad/update/bid/
+    ad-update-budget: /2/ad/update/budget/
+    ad-update-reject-reason: 2/ad/reject_reason/
+    campaign-get: /2/campaign/get/
+    campaign-create: /2/campaign/create/
+    campaign-update-status: /2/campaign/update/status/
+    campaign-update: /2/campaign/update/
+    dmp-custom-audience-select: /2/dmp/custom_audience/select/
+    file-video-ad: /2/file/video/ad/
+    file-image-ad: /2/file/image/ad/
+    creative-update-status: /2/creative/update/status/
+    creative-material-get: /2/creative/material/read/
+    creative-create-v2: /2/creative/create_v2/
+    creative-get: /2/creative/get/
+    creative-read: /2/creative/read_v2/
+    creative-update: /2/creative/update_v2/
+    creative-reject-reason: /2/creative/reject_reason/
+    advertiser-report-get: /2/report/advertiser/get/
+    campaign-report-get: /2/report/campaign/get/
+    ad-report-get: /2/report/ad/get/
+    ad-creative-get: /2/report/creative/get/
+    advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/
+xxl:
+  job:
+    accessToken:
+    executor:
+      appname: module-job-kuaishou
+      port: 9998
+      ip:
+      logpath: /data/applogs/xxl-job/jobhandler
+      logretentiondays: 30
+    admin:
+      addresses: http://139.186.29.76:8090/xxl-job-admin
+ai:
+  callback:
+    callback-unit-url: http://192.168.1.193:31012/ai_callback_add_group
+    callback-creative-url: http://192.168.1.193:31012/ai_callback_add_creative
+zip:
+  local:
+    download-path: /data/unzip/
+xxl-job:
+  requestUrl: http://api.tjyourong.com.cn

+ 11 - 7
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouCreateCreativeController.java

@@ -82,13 +82,17 @@ public class AiKuaishouCreateCreativeController {
             if (Check.isNull(hour)) {
             if (Check.isNull(hour)) {
                 throw new Exception("小时数据为空");
                 throw new Exception("小时数据为空");
             }
             }
-            kuaishouCustomCreativeSupplementExecutorService.submit(() -> {
-                try {
-                    createCreativeService.customCreativeSupplement(strategy, hour);
-                } catch (ParseException e) {
-                    e.printStackTrace();
-                }
-            });
+            if (strategy.getHistoryTop() == 0) {
+                kuaishouCustomCreativeSupplementExecutorService.submit(() -> {
+                    try {
+                        createCreativeService.customCreativeSupplement(strategy, hour);
+                    } catch (ParseException e) {
+                        e.printStackTrace();
+                    }
+                });
+            } else {
+                log.info("高质量暂停搭建,accountId:{}", strategy.getAccountId());
+            }
             returnJson.put("code", 0);
             returnJson.put("code", 0);
             returnJson.put("message", "异步创建中");
             returnJson.put("message", "异步创建中");
         } catch (Exception e) {
         } catch (Exception e) {

+ 257 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouAppMultipleBidsController.java

@@ -0,0 +1,257 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.QueryGenerator;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouAppMultipleBids;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
+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
+ * @version V1.0
+ * @date 2021-05-18
+ */
+@Slf4j
+@Api(tags = "多应用分别出价")
+@RestController
+@RequestMapping("/adsp/kuaiShouAppMultipleBids")
+public class KuaiShouAppMultipleBidsController {
+    @Autowired
+    private IKuaiShouAppMultipleBidsService kuaiShouAppMultipleBidsService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaiShouAppMultipleBids
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @ApiOperation(value = "多应用分别出价-分页列表查询", notes = "多应用分别出价-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaiShouAppMultipleBids>> queryPageList(KuaiShouAppMultipleBids kuaiShouAppMultipleBids,
+                                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                HttpServletRequest req) {
+        Result<IPage<KuaiShouAppMultipleBids>> result = new Result<>();
+        QueryWrapper<KuaiShouAppMultipleBids> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouAppMultipleBids, req.getParameterMap());
+        Page<KuaiShouAppMultipleBids> page = new Page<KuaiShouAppMultipleBids>(pageNo, pageSize);
+        IPage<KuaiShouAppMultipleBids> pageList = kuaiShouAppMultipleBidsService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaiShouAppMultipleBids
+     * @return
+     */
+    @ApiOperation(value = "多应用分别出价-添加", notes = "多应用分别出价-添加")
+    @PostMapping(value = "/saveOrUpdate")
+    public Result<KuaiShouAppMultipleBids> add(@RequestBody KuaiShouAppMultipleBids kuaiShouAppMultipleBids) {
+        Result<KuaiShouAppMultipleBids> result = new Result<>();
+        try {
+            Long accountId = kuaiShouAppMultipleBids.getAccountId();
+            Long appId = kuaiShouAppMultipleBids.getAppId();
+            QueryWrapper<KuaiShouAppMultipleBids> appMultipleBidsQueryWrapper = new QueryWrapper<>();
+            appMultipleBidsQueryWrapper.eq("account_id", accountId);
+            appMultipleBidsQueryWrapper.eq("app_id", appId);
+            appMultipleBidsQueryWrapper.orderByDesc("create_time");
+            appMultipleBidsQueryWrapper.last("limit 1");
+            KuaiShouAppMultipleBids one = kuaiShouAppMultipleBidsService.getOne(appMultipleBidsQueryWrapper);
+            if (Check.isNull(one)) {
+                kuaiShouAppMultipleBidsService.save(kuaiShouAppMultipleBids);
+            } else {
+                kuaiShouAppMultipleBids.setId(one.getId());
+                kuaiShouAppMultipleBidsService.updateById(kuaiShouAppMultipleBids);
+            }
+
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaiShouAppMultipleBids
+     * @return
+     */
+    @ApiOperation(value = "多应用分别出价-编辑", notes = "多应用分别出价-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaiShouAppMultipleBids> edit(@RequestBody KuaiShouAppMultipleBids kuaiShouAppMultipleBids) {
+        Result<KuaiShouAppMultipleBids> result = new Result<KuaiShouAppMultipleBids>();
+        KuaiShouAppMultipleBids kuaiShouAppMultipleBidsEntity = kuaiShouAppMultipleBidsService.getById(kuaiShouAppMultipleBids.getId());
+        if (kuaiShouAppMultipleBidsEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaiShouAppMultipleBidsService.updateById(kuaiShouAppMultipleBids);
+            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 {
+            kuaiShouAppMultipleBidsService.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<KuaiShouAppMultipleBids> deleteBatch(@RequestParam(name = "ids") String ids) {
+        Result<KuaiShouAppMultipleBids> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaiShouAppMultipleBidsService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "多应用分别出价-通过id查询", notes = "多应用分别出价-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaiShouAppMultipleBids> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaiShouAppMultipleBids> result = new Result<>();
+        KuaiShouAppMultipleBids kuaiShouAppMultipleBids = kuaiShouAppMultipleBidsService.getById(id);
+        if (kuaiShouAppMultipleBids == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaiShouAppMultipleBids);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaiShouAppMultipleBids> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaiShouAppMultipleBids kuaiShouAppMultipleBids = JSON.parseObject(deString, KuaiShouAppMultipleBids.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouAppMultipleBids, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaiShouAppMultipleBids> pageList = kuaiShouAppMultipleBidsService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "多应用分别出价列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaiShouAppMultipleBids.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("多应用分别出价列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaiShouAppMultipleBids> listKuaiShouAppMultipleBidss = ExcelImportUtil.importExcel(file.getInputStream(), KuaiShouAppMultipleBids.class, params);
+                kuaiShouAppMultipleBidsService.saveBatch(listKuaiShouAppMultipleBidss);
+                return Result.ok("文件导入成功!数据行数:" + listKuaiShouAppMultipleBidss.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 436 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouAppPackageController.java

@@ -0,0 +1,436 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackage;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+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.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 项目绑定的应用
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-12
+ */
+@Slf4j
+@Api(tags = "项目绑定的应用")
+@RestController
+@RequestMapping("/kuaishouAppPackage")
+public class KuaishouAppPackageController {
+    @Autowired
+    private IKuaishouAppPackageService kuaishouAppPackageService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouAppPackage
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @GetMapping(value = "/list")
+    public Result<Object> queryPageList(KuaishouAppPackage kuaishouAppPackage, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            return kuaishouAppPackageService.queryPageList(kuaishouAppPackage, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询应用列表异常", e);
+        }
+        return Result.error("查询应用列表失败");
+    }
+
+    /**
+     * 查询相关账户
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedAccounts")
+    public Result<Object> getRelatedAccounts(Long id, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouAppPackageService.getRelatedAccounts(id);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+
+    }
+
+    /**
+     * 查询相关组
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedGroups")
+    public Result<Object> getRelatedGroups(Long id, Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouAppPackageService.getRelatedGroups(id, accountId);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+
+    }
+    /**
+     * 查询项目下有效账户
+     *
+     * @param projectId 账户ID
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getAccountByProjectId")
+    public Result<Object> getAccountByProjectId(Long projectId, String id,
+                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(projectId)) {
+                return Result.error("请选择项目");
+            }
+            if (Check.isNull(id)) {
+                return Result.error("请选择应用");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouAppPackageService.getAccountByProjectId(projectId, id);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+    /**
+     * 推送应用
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/pushAppPackage")
+    public Result<Object> pushAppPackage(@RequestBody JSONObject requestJson) {
+        try {
+            Long id = requestJson.getLong("id");
+            JSONArray accountIds = requestJson.getJSONArray("accountIds");
+            if (Check.isNull(id)) {
+                return Result.error("请选择应用");
+            }
+            if (Check.isNull(accountIds)) {
+                return Result.error("请选择推送账户");
+            }
+            return kuaishouAppPackageService.pushAppPackage(id, accountIds);
+        } catch (Exception e) {
+            log.error("推送应用异常", e);
+        }
+        return Result.error("推送失败");
+    }
+
+    /**
+     * 查询推送结果
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/queryPushResults")
+    public Result<Object> queryPushResults(@RequestBody JSONObject requestJson) {
+        try {
+            String id = requestJson.getString("id");
+            JSONArray accountIds = requestJson.getJSONArray("accountIds");
+            if (Check.isNull(id)) {
+                return Result.error("请选择应用");
+            }
+            Integer pageNo = requestJson.getInteger("pageNo");
+            Integer pageSize = requestJson.getInteger("pageSize");
+            if (Check.isNull(pageNo)) {
+                pageNo = 1;
+            }
+            if (Check.isNull(pageSize)) {
+                pageSize = 10;
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouAppPackageService.queryPushResults(id, accountIds, null);
+        } catch (Exception e) {
+            log.error("查询推送结果异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 查询推送历史
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/queryPushHistory")
+    public Result<Object> queryPushHistory(@RequestBody JSONObject requestJson) {
+        try {
+            String id = requestJson.getString("id");
+            JSONArray accountIds = requestJson.getJSONArray("accountIds");
+            if (Check.isNull(id)) {
+                return Result.error("请选择应用");
+            }
+            Integer pageNo = requestJson.getInteger("pageNo");
+            Integer pageSize = requestJson.getInteger("pageSize");
+            if (Check.isNull(pageNo)) {
+                pageNo = 1;
+            }
+            if (Check.isNull(pageSize)) {
+                pageSize = 10;
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouAppPackageService.queryPushResults(id, accountIds, requestJson.getString("status"));
+        } catch (Exception e) {
+            log.error("查询推送历史异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 添加——填写链接
+     *
+     * @param kuaishouAppPackage
+     * @return
+     */
+    @PostMapping(value = "/fillInLink")
+    public Result<Object> fillInLink(@RequestBody KuaishouAppPackage kuaishouAppPackage) {
+        try {
+            if (Check.isNull(kuaishouAppPackage.getProjectId())) {
+                return Result.error("请选择项目");
+            } else if (Check.isNull(kuaishouAppPackage.getAppVersion())) {
+                return Result.error("请填写应用标记");
+            } else if (Check.isNull(kuaishouAppPackage.getAppName())) {
+                return Result.error("请填写应用名称");
+            } else if (Check.isNull(kuaishouAppPackage.getPlatform())) {
+                return Result.error("请选择应用类型");
+            } else {
+                Integer platform = kuaishouAppPackage.getPlatform();
+                if ((platform == 1 || platform == 3) && Check.isNull(kuaishouAppPackage.getImageToken())) {
+                    return Result.error("请上传图标");
+                }
+                if ((platform == 1 || platform == 2) && Check.isNull(kuaishouAppPackage.getAppPrivacyUrl())) {
+                    return Result.error("安卓类应用隐私政策url不为空");
+                }
+                if (platform == 1 && Check.isNull(kuaishouAppPackage.getPackageName())) {
+                    return Result.error("请填写应用包名");
+                }
+            }
+            kuaishouAppPackage.setDataStatus(1);//有效
+            kuaishouAppPackageService.saveOrUpdate(kuaishouAppPackage);
+            return Result.ok("操作成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return Result.error("操作失败");
+    }
+
+    /**
+     * 校验应用标记
+     *
+     * @param kuaishouAppPackage
+     * @return
+     */
+    @GetMapping(value = "/checkAppVersion")
+    public Result<Object> checkAppVersion(Long projectId, String appVersion, Long id) {
+        try {
+            if (Check.isNull(projectId) || Check.isNull(appVersion)) {
+                return Result.error("缺失参数");
+            }
+            List<Long> list = kuaishouAppPackageService.queryByAppVersion(projectId, appVersion);
+            if (Check.isNull(list)) {
+                return Result.ok("success");
+            } else {
+                //修改校验
+                if (!Check.isNull(id) && (list.size() == 1 && list.get(0) - id == 0)) {
+                    return Result.ok("success");
+                }
+                return Result.error("重复的应用标记");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return Result.error("操作失败");
+    }
+
+    /**
+     * 逻辑删除,修改模板状态
+     *
+     * @param kuaishouAppPackage
+     * @return
+     */
+    @PostMapping(value = "/delete")
+    public Result<KuaishouAppPackage> delete(@RequestBody KuaishouAppPackage kuaishouAppPackage) {
+        Result<KuaishouAppPackage> result = new Result<KuaishouAppPackage>();
+        KuaishouAppPackage kuaishouAppPackageEntity = kuaishouAppPackageService.getById(kuaishouAppPackage.getId());
+        if (kuaishouAppPackageEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            kuaishouAppPackage.setDataStatus(0);
+            boolean ok = kuaishouAppPackageService.updateById(kuaishouAppPackage);
+            if (ok) {
+                result.success("刪除成功!");
+            }
+        }
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "项目绑定的应用-通过id删除")
+    @ApiOperation(value = "项目绑定的应用-通过id删除", notes = "项目绑定的应用-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaishouAppPackageService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "项目绑定的应用-批量删除")
+    @ApiOperation(value = "项目绑定的应用-批量删除", notes = "项目绑定的应用-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouAppPackage> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouAppPackage> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouAppPackageService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "项目绑定的应用-通过id查询")
+    @ApiOperation(value = "项目绑定的应用-通过id查询", notes = "项目绑定的应用-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouAppPackage> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouAppPackage> result = new Result<>();
+        KuaishouAppPackage kuaishouAppPackage = kuaishouAppPackageService.getById(id);
+        if (kuaishouAppPackage == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouAppPackage);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出应用模板
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportAppTemplate")
+    public void exportXls(HttpServletRequest request, HttpServletResponse response) {
+        Map<String, Object> paramsMap = new HashMap<>();
+        try {
+            List<List<Object>> excelList = new ArrayList<>();
+            OutputStream os = response.getOutputStream();
+            ExportExcelUtils eeu = new ExportExcelUtils();
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            String[] titles = {"应用名称", "应用包名", "应用标记", "隐私政策链接", "下载链接", "监测链接", "广告监测SDK"};
+            eeu.exportExcelForAttendance(workbook, 0, "Sheet1", titles, excelList);
+            HttpUtils.setResponseHeader(response, "AppTemplate.xlsx");
+            workbook.write(os);
+            os.flush();
+            os.close();
+        } catch (IOException e) {
+            log.error(e.getMessage());
+        }
+    }
+
+    /**
+     * 导入应用程序excel
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @PostMapping(value = "/importAppExcel")
+    @ResponseBody
+    public Result<Object> importExcel(HttpServletResponse response,
+                                      @RequestParam("file") MultipartFile file,
+                                      @RequestParam("projectId") Long projectId,
+                                      @RequestParam("platform") Integer platform,
+                                      @RequestParam("imageToken") String imageToken,
+                                      @RequestParam("imageUrl") String imageUrl) {
+        response.setHeader("Access-Control-Allow-Origin", "*");
+        try {
+            if (Check.isNull(file)) {
+                return Result.error("执行失败,请上传应用Excel文件");
+            } else if (Check.isNull(projectId)) {
+                return Result.error("请选择项目");
+            } else if (Check.isNull(imageToken) || Check.isNull(imageUrl)) {
+                return Result.error("请上传图标");
+            } else if (Check.isNull(platform)) {
+                return Result.error("请选择应用类型");
+            }
+            return kuaishouAppPackageService.importExcel(file, projectId, platform, imageToken, imageUrl);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("解析应用Excel文档异常", e);
+            return Result.error("解析应用Excel文档失败," + e.getMessage());
+        }
+    }
+
+}

+ 0 - 403
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouCrowdPackController.java

@@ -1,403 +0,0 @@
-package cn.com.ctop.kuaishou.modules.ai.controller;
-
-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.ai.entity.KuaishouCrowdPack;
-import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouCrowdPackService;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-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.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-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 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
- * @version V1.0
- * @date 2021-03-26
- */
-@Slf4j
-@Api(tags = "人群报表")
-@RestController
-@RequestMapping("/kuaishouCrowdPack")
-public class KuaishouCrowdPackController {
-    @Autowired
-    private IKuaishouCrowdPackService kuaishouCrowdPackService;
-
-    /**
-     * 分页列表查询
-     *
-     * @param kuaishouCrowdPack
-     * @param pageNo
-     * @param pageSize
-     * @param req
-     * @return
-     */
-    @AutoLog(value = "人群报表-分页列表查询")
-    @ApiOperation(value = "人群报表-分页列表查询", notes = "人群报表-分页列表查询")
-    @GetMapping(value = "/list")
-    public Result<IPage<KuaishouCrowdPack>> list(KuaishouCrowdPack kuaishouCrowdPack,
-                                                 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                 HttpServletRequest req) {
-        Result<IPage<KuaishouCrowdPack>> result = new Result<>();
-        QueryWrapper<KuaishouCrowdPack> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouCrowdPack, req.getParameterMap());
-        Page<KuaishouCrowdPack> page = new Page<KuaishouCrowdPack>(pageNo, pageSize);
-        IPage<KuaishouCrowdPack> pageList = kuaishouCrowdPackService.page(page, queryWrapper);
-        result.setSuccess(true);
-        result.setResult(pageList);
-        return result;
-    }
-
-    /**
-     * 人群包列表
-     *
-     * @param
-     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
-     * @throws
-     * @author ZHAOXA
-     */
-    @GetMapping(value = "/queryPageList")
-    public Result<Object> queryPageList(KuaishouCrowdPack kuaishouCrowdPack,
-                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
-        try {
-            return kuaishouCrowdPackService.queryPageList(kuaishouCrowdPack, pageNo, pageSize);
-        } catch (Exception e) {
-            log.error("查询异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("查询失败");
-    }
-
-    /**
-     * 相关账户查询
-     *
-     * @param
-     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
-     * @throws
-     * @author ZHAOXA
-     */
-    @GetMapping(value = "/queryRel")
-    public Result<Object> queryRel(String type, String signature,
-                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
-        try {
-            if (Check.isNull(type) || Check.isNull(signature)) {
-                return Result.error("缺失参数");
-            }
-            return kuaishouCrowdPackService.queryRel(type, signature, pageNo, pageSize);
-        } catch (Exception e) {
-            log.error("查询异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("查询失败");
-    }
-
-    /**
-     * 查询原因
-     *
-     * @param
-     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
-     * @throws
-     * @author ZHAOXA
-     */
-    @GetMapping(value = "/queryFailReason")
-    public Result<Object> queryFailReason(String signature,
-                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
-        try {
-            return kuaishouCrowdPackService.queryFailReason(signature, pageNo, pageSize);
-        } catch (Exception e) {
-            log.error("查询异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("查询失败");
-    }
-
-    /**
-     * 上传前的人群包校验
-     *
-     * @param
-     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
-     * @throws
-     * @author ZHAOXA
-     */
-    @GetMapping(value = "/checkCrowdPackage")
-    public Result<Object> checkCrowdPackage(String signature) {
-        try {
-            return kuaishouCrowdPackService.checkCrowdPackage(signature);
-        } catch (Exception e) {
-            log.error("查询异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("查询失败");
-    }
-
-    /**
-     * 上传人群包
-     *
-     * @param kuaishouCrowdPack
-     * @return
-     */
-
-    @PostMapping(value = "/uploadCrowdPack")
-    public Result<Object> uploadCrowdPack(@RequestBody JSONObject request) {
-        Integer type = request.getInteger("type");
-        String orientationName = request.getString("orientationName");
-        Long accountId = request.getLong("accountId");
-        String url = request.getString("url");
-        try {
-            if (Check.isNull(type) || Check.isNull(orientationName) || Check.isNull(url) || Check.isNull(accountId)) {
-                return Result.error("缺少参数");
-            }
-            return kuaishouCrowdPackService.uploadCrowdPack(type, orientationName, accountId, url);
-        } catch (Exception e) {
-            log.error("上传异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("上传失败");
-    }
-
-    /**
-     * 账户推送
-     *
-     * @param kuaishouCrowdPack
-     * @return
-     */
-    @AutoLog(value = "账户推送")
-    @ApiOperation(value = "账户推送", notes = "账户推送")
-    @PostMapping(value = "/accountPush")
-    public Result<Object> accountPush(@RequestBody JSONObject request) {
-        try {
-            JSONArray accountIds = request.getJSONArray("accountIds");
-            String signature = request.getString("signature");
-            if (Check.isNull(accountIds) || Check.isNull(signature)) {
-                return Result.error("缺少参数");
-            }
-            return kuaishouCrowdPackService.accountPush(request);
-        } catch (Exception e) {
-            log.error("查询异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("查询失败");
-    }
-
-    @RequestMapping(value = "/crowdListQuery")
-    public Result<Object> crowdListQuery() {
-        try {
-            kuaishouCrowdPackService.crowdListQuery();
-            return Result.ok("success");
-        } catch (Exception e) {
-            log.error("查询异常,", e.getMessage());
-            e.printStackTrace();
-        }
-        return Result.error("查询失败");
-    }
-
-    /**
-     * 添加
-     *
-     * @param kuaishouCrowdPack
-     * @return
-     */
-    @AutoLog(value = "人群报表-添加")
-    @ApiOperation(value = "人群报表-添加", notes = "人群报表-添加")
-    @PostMapping(value = "/add")
-    public Result<KuaishouCrowdPack> add(@RequestBody KuaishouCrowdPack kuaishouCrowdPack) {
-        Result<KuaishouCrowdPack> result = new Result<>();
-        try {
-            kuaishouCrowdPackService.save(kuaishouCrowdPack);
-            result.success("添加成功!");
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-            result.error500("操作失败");
-        }
-        return result;
-    }
-
-    /**
-     * 编辑
-     *
-     * @param kuaishouCrowdPack
-     * @return
-     */
-    @AutoLog(value = "人群报表-编辑")
-    @ApiOperation(value = "人群报表-编辑", notes = "人群报表-编辑")
-    @PostMapping(value = "/edit")
-    public Result<KuaishouCrowdPack> edit(@RequestBody KuaishouCrowdPack kuaishouCrowdPack) {
-        Result<KuaishouCrowdPack> result = new Result<KuaishouCrowdPack>();
-        KuaishouCrowdPack kuaishouCrowdPackEntity = kuaishouCrowdPackService.getById(kuaishouCrowdPack.getId());
-        if (kuaishouCrowdPackEntity == null) {
-            result.error500("未找到对应实体");
-        } else {
-            boolean ok = kuaishouCrowdPackService.updateById(kuaishouCrowdPack);
-            if (ok) {
-                result.success("修改成功!");
-            }
-        }
-        return result;
-    }
-
-    /**
-     * 通过id删除
-     *
-     * @param id
-     * @return
-     */
-    @AutoLog(value = "人群报表-通过id删除")
-    @ApiOperation(value = "人群报表-通过id删除", notes = "人群报表-通过id删除")
-    @GetMapping(value = "/delete")
-    public Result<Object> delete(KuaishouCrowdPack kuaishouCrowdPack) {
-        KuaishouCrowdPack kuaishouCrowdPackEntity = kuaishouCrowdPackService.getById(kuaishouCrowdPack.getId());
-        if (kuaishouCrowdPackEntity == null) {
-            return Result.error("未找到对应实体");
-        } else {
-            kuaishouCrowdPackEntity.setDataStatus(0);
-            return kuaishouCrowdPackService.updateDataStatus(kuaishouCrowdPackEntity);
-        }
-    }
-
-    /**
-     * 批量删除
-     *
-     * @param ids
-     * @return
-     */
-    @AutoLog(value = "人群报表-批量删除")
-    @ApiOperation(value = "人群报表-批量删除", notes = "人群报表-批量删除")
-    @DeleteMapping(value = "/deleteBatch")
-    public Result<KuaishouCrowdPack> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
-        Result<KuaishouCrowdPack> result = new Result<>();
-        if (ids == null || "".equals(ids.trim())) {
-            result.error500("参数不识别!");
-        } else {
-            this.kuaishouCrowdPackService.removeByIds(Arrays.asList(ids.split(",")));
-            result.success("删除成功!");
-        }
-        return result;
-    }
-
-    /**
-     * 通过id查询
-     *
-     * @param id
-     * @return
-     */
-    @AutoLog(value = "人群报表-通过id查询")
-    @ApiOperation(value = "人群报表-通过id查询", notes = "人群报表-通过id查询")
-    @GetMapping(value = "/queryById")
-    public Result<KuaishouCrowdPack> queryById(@RequestParam(name = "id", required = true) String id) {
-        Result<KuaishouCrowdPack> result = new Result<>();
-        KuaishouCrowdPack kuaishouCrowdPack = kuaishouCrowdPackService.getById(id);
-        if (kuaishouCrowdPack == null) {
-            result.error500("未找到对应实体");
-        } else {
-            result.setResult(kuaishouCrowdPack);
-            result.setSuccess(true);
-        }
-        return result;
-    }
-
-    /**
-     * 导出excel
-     *
-     * @param request
-     * @param response
-     */
-    @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
-        // Step.1 组装查询条件
-        QueryWrapper<KuaishouCrowdPack> queryWrapper = null;
-        try {
-            String paramsStr = request.getParameter("paramsStr");
-            if (oConvertUtils.isNotEmpty(paramsStr)) {
-                String deString = URLDecoder.decode(paramsStr, "UTF-8");
-                KuaishouCrowdPack kuaishouCrowdPack = JSON.parseObject(deString, KuaishouCrowdPack.class);
-                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouCrowdPack, request.getParameterMap());
-            }
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        }
-
-        //Step.2 AutoPoi 导出Excel
-        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
-        List<KuaishouCrowdPack> pageList = kuaishouCrowdPackService.list(queryWrapper);
-        //导出文件名称
-        mv.addObject(NormalExcelConstants.FILE_NAME, "人群报表列表");
-        mv.addObject(NormalExcelConstants.CLASS, KuaishouCrowdPack.class);
-        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("人群报表列表数据", "导出人:Jeecg", "导出信息"));
-        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
-        return mv;
-    }
-
-    /**
-     * 通过excel导入数据
-     *
-     * @param request
-     * @param response
-     * @return
-     */
-    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
-    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
-        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
-        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
-            MultipartFile file = entity.getValue();
-            ImportParams params = new ImportParams();
-            params.setTitleRows(2);
-            params.setHeadRows(1);
-            params.setNeedSave(true);
-            try {
-                List<KuaishouCrowdPack> listKuaishouCrowdPacks = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouCrowdPack.class, params);
-                kuaishouCrowdPackService.saveBatch(listKuaishouCrowdPacks);
-                return Result.ok("文件导入成功!数据行数:" + listKuaishouCrowdPacks.size());
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-                return Result.error("文件导入失败:" + e.getMessage());
-            } finally {
-                try {
-                    file.getInputStream().close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return Result.ok("文件导入失败!");
-    }
-
-}

+ 493 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouDirectionalPackageController.java

@@ -0,0 +1,493 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.QueryGenerator;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.pagehelper.PageHelper;
+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.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 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
+ * @version V1.0
+ * @date 2021-04-20
+ */
+@Slf4j
+@Api(tags = "自动投放-定向包详情")
+@RestController
+@RequestMapping("/kuaishouDirectionalPackage")
+public class KuaishouDirectionalPackageController {
+    @Autowired
+    private IKuaishouDirectionalPackageService kuaishouDirectionalPackageService;
+
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouDirectionalPackage
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-分页列表查询")
+    @ApiOperation(value = "自动投放-定向包详情-分页列表查询", notes = "自动投放-定向包详情-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouDirectionalPackage>> queryPageList(KuaishouDirectionalPackage kuaishouDirectionalPackage,
+                                                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                   HttpServletRequest req) {
+        Result<IPage<KuaishouDirectionalPackage>> result = new Result<>();
+        QueryWrapper<KuaishouDirectionalPackage> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouDirectionalPackage, req.getParameterMap());
+        Page<KuaishouDirectionalPackage> page = new Page<KuaishouDirectionalPackage>(pageNo, pageSize);
+        IPage<KuaishouDirectionalPackage> pageList = kuaishouDirectionalPackageService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 查询定向包列表
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/queryList")
+    public Result<Object> queryList(KuaishouDirectionalPackage directionalPackage,
+                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            return kuaishouDirectionalPackageService.queryList(directionalPackage, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e);
+            return Result.error("查询失败," + e.getMessage());
+        }
+
+    }
+
+    /**
+     * 相关账户/组
+     *
+     * @param projectId 账户ID
+     * @param type      1是账户,2是组维度
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedAccountGroup")
+    public Result<Object> getRelatedAccountGroup(String id, Integer type, Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("请选择定向包");
+            }
+            if (Check.isNull(type)) {
+                return Result.error("请选择查询类型");
+            }
+            return kuaishouDirectionalPackageService.getRelatedAccountGroup(id, type, accountId, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e);
+            return Result.error("查询失败");
+        }
+
+    }
+
+    /**
+     * 编辑定向包
+     *
+     * @param projectId 账户ID
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @PostMapping(value = "/editPopulation")
+    public Result<Object> editPopulation(@RequestBody JSONObject requestJson) {
+        try {
+            if (Check.isNull(requestJson.getString("id"))) {
+                return Result.error("请选择定向包");
+            }
+            if (Check.isNull(requestJson.getLong("accountId"))) {
+                return Result.error("请选择账户");
+            }
+            if (Check.isNull(requestJson.getLong("templateId"))) {
+                return Result.error("未获取到定向包ID");
+            }
+            if (Check.isNull(requestJson.getString("templateName"))) {
+                return Result.error("未获取到定向包名称");
+            }
+            return kuaishouDirectionalPackageService.editPopulation(requestJson);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 查询项目下有效账户
+     *
+     * @param projectId 账户ID
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getAccountByProjectId")
+    public Result<Object> getAccountByProjectId(Long projectId, String id,
+                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(projectId)) {
+                return Result.error("请选择项目");
+            }
+            if (Check.isNull(id)) {
+                return Result.error("请选择定向包");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouDirectionalPackageService.getAccountByProjectId(projectId, id);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 创建定向包
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/createDirectionalPackage")
+    public Result<Object> createDirectionalPackage(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson.getString("templateName"))) {
+                return Result.error("定向模板名称为必传项");
+            }
+            Long accountId = requestJson.getLong("projectId");
+            if (Check.isNull(accountId)) {
+                return Result.error("请选择账户id");
+            }
+            return kuaishouDirectionalPackageService.createDirectionalPackage(requestJson);
+        } catch (Exception e) {
+            log.error("创建定向包失败", e);
+            return Result.error("创建失败" + e.getMessage());
+        }
+    }
+
+    /**
+     * 修改定向包
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/updateDirectionalPackage")
+    public Result<Object> updateDirectionalPackage(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson.getString("id"))) {
+                return Result.error("请选择定向包");
+            }
+            if (Check.isNull(requestJson.getString("projectId"))) {
+                return Result.error("请选择项目");
+            }
+            return kuaishouDirectionalPackageService.updateDirectionalPackage(requestJson);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return Result.error("上传失败");
+    }
+
+    /**
+     * 推送定向包
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/pushDirectionalPackage")
+    public Result<Object> pushDirectionalPackage(@RequestBody JSONObject requestJson) {
+        try {
+            String id = requestJson.getString("id");
+            JSONArray datas = requestJson.getJSONArray("datas");
+            if (Check.isNull(id)) {
+                return Result.error("请选择定向包");
+            }
+            if (Check.isNull(datas)) {
+                return Result.error("请选择推送账户");
+            }
+            return kuaishouDirectionalPackageService.pushDirectionalPackage(id, datas);
+        } catch (Exception e) {
+            log.error("推送定向包异常", e);
+        }
+        return Result.error("推送失败");
+    }
+
+    /**
+     * 查询推送结果
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/queryPushResults")
+    public Result<Object> queryPushResults(@RequestBody JSONObject requestJson) {
+        try {
+            String id = requestJson.getString("id");
+            JSONArray accountIds = requestJson.getJSONArray("accountIds");
+            if (Check.isNull(id)) {
+                return Result.error("请选择定向包");
+            }
+            Integer pageNo = requestJson.getInteger("pageNo");
+            Integer pageSize = requestJson.getInteger("pageSize");
+            if (Check.isNull(pageNo)) {
+                pageNo = 1;
+            }
+            if (Check.isNull(pageSize)) {
+                pageSize = 10;
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouDirectionalPackageService.queryPushResults(id, accountIds, requestJson.getString("status"));
+        } catch (Exception e) {
+            log.error("查询推送结果异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 删除定向模板
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<?>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/delete")
+    public Result<Object> delete(String id) {
+        try {
+            boolean b = kuaishouDirectionalPackageService.removeById(id);
+            if (b) {
+                return Result.ok("删除成功");
+            }
+        } catch (Exception e) {
+            log.error("删除异常", e);
+        }
+        return Result.error("删除失败!");
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouDirectionalPackage
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-添加")
+    @ApiOperation(value = "自动投放-定向包详情-添加", notes = "自动投放-定向包详情-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouDirectionalPackage> add(@RequestBody KuaishouDirectionalPackage kuaishouDirectionalPackage) {
+        Result<KuaishouDirectionalPackage> result = new Result<>();
+        try {
+            kuaishouDirectionalPackageService.save(kuaishouDirectionalPackage);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouDirectionalPackage
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-编辑")
+    @ApiOperation(value = "自动投放-定向包详情-编辑", notes = "自动投放-定向包详情-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouDirectionalPackage> edit(@RequestBody KuaishouDirectionalPackage kuaishouDirectionalPackage) {
+        Result<KuaishouDirectionalPackage> result = new Result<KuaishouDirectionalPackage>();
+        KuaishouDirectionalPackage kuaishouDirectionalPackageEntity = kuaishouDirectionalPackageService.getById(kuaishouDirectionalPackage.getId());
+        if (kuaishouDirectionalPackageEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouDirectionalPackageService.updateById(kuaishouDirectionalPackage);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-批量删除")
+    @ApiOperation(value = "自动投放-定向包详情-批量删除", notes = "自动投放-定向包详情-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouDirectionalPackage> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouDirectionalPackage> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouDirectionalPackageService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 查询待修改的定向包
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/queryById")
+    public Result<Object> queryById(@RequestParam(name = "id", required = true) String id) {
+        KuaishouDirectionalPackage kuaishouDirectionalPackage = kuaishouDirectionalPackageService.getById(id);
+        if (kuaishouDirectionalPackage == null) {
+            return Result.error("未找到对应实体");
+        } else {
+            JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(kuaishouDirectionalPackage)).toJavaObject(JSONObject.class);
+            if (!Check.isNull(data.getString("keyword"))) {
+                data.put("keyword", data.getJSONArray("keyword"));
+            }
+            return Result.ok(data);
+        }
+    }
+
+    /**
+     * 查询待修改的定向包
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/queryPopulationById")
+    public Result<Object> queryPopulationById(Long templateId, Long accountId) {
+        try {
+            if (Check.isNull(templateId) || Check.isNull(accountId)) {
+                return Result.error("缺少参数");
+            }
+            return kuaishouDirectionalPackageService.queryPopulationById(templateId, accountId);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouDirectionalPackage> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouDirectionalPackage kuaishouDirectionalPackage = JSON.parseObject(deString, KuaishouDirectionalPackage.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouDirectionalPackage, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouDirectionalPackage> pageList = kuaishouDirectionalPackageService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "自动投放-定向包详情列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouDirectionalPackage.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("自动投放-定向包详情列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaishouDirectionalPackage> listKuaishouDirectionalPackages = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouDirectionalPackage.class, params);
+                kuaishouDirectionalPackageService.saveBatch(listKuaishouDirectionalPackages);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouDirectionalPackages.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 337 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouLandpagePackageController.java

@@ -0,0 +1,337 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+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.ai.entity.KuaishouLandpagePackage;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.pagehelper.PageHelper;
+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.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 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
+ * @version V1.0
+ * @date 2021-05-11
+ */
+@Slf4j
+@Api(tags = "落地页账户项目关联表")
+@RestController
+@RequestMapping("/kuaishouLandpagePackage")
+public class KuaishouLandpagePackageController {
+    @Autowired
+    private IKuaishouLandpagePackageService kuaishouLandpagePackageService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouLandpagePackage
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "落地页账户项目关联表-分页列表查询")
+    @ApiOperation(value = "落地页账户项目关联表-分页列表查询", notes = "落地页账户项目关联表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<Object> queryPageList(KuaishouLandpagePackage kuaishouLandpagePackage, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            return kuaishouLandpagePackageService.queryPageList(kuaishouLandpagePackage, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询落地页列表异常", e);
+        }
+        return Result.error("查询落地页列表失败");
+    }
+
+    /**
+     * 同步项目下落地页和账户关联数据
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/synchronousData")
+    public Result<Object> synchronousData(KuaishouLandpagePackage kuaishouLandpagePackage) {
+        try {
+            if (Check.isNull(kuaishouLandpagePackage.getProjectId())) {
+                return Result.error("请选择项目");
+            }
+            return kuaishouLandpagePackageService.synchronousData(kuaishouLandpagePackage.getProjectId());
+        } catch (Exception e) {
+            log.error("同步落地页数据异常", e);
+        }
+        return Result.error("同步落地页数据失败");
+    }
+
+    /**
+     * 查询相关账户
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedAccounts")
+    public Result<Object> getRelatedAccounts(Long siteId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(siteId)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouLandpagePackageService.getRelatedAccounts(siteId);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+
+    }
+
+    /**
+     * 查询相关组
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedGroups")
+    public Result<Object> getRelatedGroups(Long siteId, Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(siteId)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouLandpagePackageService.getRelatedGroups(siteId, accountId);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+
+    }
+
+    /**
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/createLandPageAndUnit")
+    public Result<Object> createLandPageAndUnit(Long siteId, Long creativeId, Long unitId, Long accountId) {
+        try {
+            kuaishouLandpagePackageService.createLandPageAndUnit(siteId, creativeId, unitId, accountId);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.ok("ok");
+
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouLandpagePackage
+     * @return
+     */
+    @AutoLog(value = "落地页账户项目关联表-添加")
+    @ApiOperation(value = "落地页账户项目关联表-添加", notes = "落地页账户项目关联表-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouLandpagePackage> add(@RequestBody KuaishouLandpagePackage kuaishouLandpagePackage) {
+        Result<KuaishouLandpagePackage> result = new Result<>();
+        try {
+            kuaishouLandpagePackageService.save(kuaishouLandpagePackage);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouLandpagePackage
+     * @return
+     */
+    @AutoLog(value = "落地页账户项目关联表-编辑")
+    @ApiOperation(value = "落地页账户项目关联表-编辑", notes = "落地页账户项目关联表-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouLandpagePackage> edit(@RequestBody KuaishouLandpagePackage kuaishouLandpagePackage) {
+        Result<KuaishouLandpagePackage> result = new Result<KuaishouLandpagePackage>();
+        KuaishouLandpagePackage kuaishouLandpagePackageEntity = kuaishouLandpagePackageService.getById(kuaishouLandpagePackage.getId());
+        if (kuaishouLandpagePackageEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouLandpagePackageService.updateById(kuaishouLandpagePackage);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "落地页账户项目关联表-通过id删除")
+    @ApiOperation(value = "落地页账户项目关联表-通过id删除", notes = "落地页账户项目关联表-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaishouLandpagePackageService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "落地页账户项目关联表-批量删除")
+    @ApiOperation(value = "落地页账户项目关联表-批量删除", notes = "落地页账户项目关联表-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouLandpagePackage> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouLandpagePackage> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouLandpagePackageService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "落地页账户项目关联表-通过id查询")
+    @ApiOperation(value = "落地页账户项目关联表-通过id查询", notes = "落地页账户项目关联表-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouLandpagePackage> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouLandpagePackage> result = new Result<>();
+        KuaishouLandpagePackage kuaishouLandpagePackage = kuaishouLandpagePackageService.getById(id);
+        if (kuaishouLandpagePackage == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouLandpagePackage);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouLandpagePackage> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouLandpagePackage kuaishouLandpagePackage = JSON.parseObject(deString, KuaishouLandpagePackage.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouLandpagePackage, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouLandpagePackage> pageList = kuaishouLandpagePackageService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "落地页账户项目关联表列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouLandpagePackage.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("落地页账户项目关联表列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaishouLandpagePackage> listKuaishouLandpagePackages = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouLandpagePackage.class, params);
+                kuaishouLandpagePackageService.saveBatch(listKuaishouLandpagePackages);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouLandpagePackages.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 412 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouPopulationPackageController.java

@@ -0,0 +1,412 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.QueryGenerator;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackage;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+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.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+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 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
+ * @version V1.0
+ * @date 2021-05-06
+ */
+@Slf4j
+@Api(tags = "项目绑定的人群包模板")
+@RestController
+@RequestMapping("/kuaishouPopulationPackage")
+public class KuaishouPopulationPackageController {
+    @Autowired
+    private IKuaishouPopulationPackageService kuaishouPopulationPackageService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouPopulationPackage
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @ApiOperation(value = "项目绑定的人群包模板-分页列表查询", notes = "项目绑定的人群包模板-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<Object> queryPageList(KuaishouPopulationPackage kuaishouPopulationPackage,
+                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            return kuaishouPopulationPackageService.queryPageList(kuaishouPopulationPackage, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询人群包列表异常", e);
+        }
+        return Result.error("查询人群包列表失败");
+    }
+
+    /**
+     * 查询推送结果
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/queryPushResults")
+    public Result<Object> queryPushResults(@RequestBody JSONObject requestJson) {
+        try {
+            Long id = requestJson.getLong("id");
+            JSONArray accountIds = requestJson.getJSONArray("accountIds");
+            if (Check.isNull(accountIds) || Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            Integer pageNo = requestJson.getInteger("pageNo");
+            Integer pageSize = requestJson.getInteger("pageSize");
+            if (Check.isNull(pageNo)) {
+                pageNo = 1;
+            }
+            if (Check.isNull(pageSize)) {
+                pageSize = 10;
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouPopulationPackageService.queryPushResults(id, accountIds);
+        } catch (Exception e) {
+            log.error("查询推送结果异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 查询推送历史
+     *
+     * @param
+     * @return
+     */
+    @GetMapping(value = "/queryPushHistory")
+    public Result<Object> queryPushHistory(Long id, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouPopulationPackageService.queryPushHistory(id);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 查询相关账户
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedAccounts")
+    public Result<Object> getRelatedAccounts(Long id, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouPopulationPackageService.getRelatedAccounts(id);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+
+    }
+
+    /**
+     * 查询相关组
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedGroups")
+    public Result<Object> getRelatedGroups(Long id,Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouPopulationPackageService.getRelatedGroups(id,accountId);
+        } catch (Exception e) {
+            log.error("查询异常", e);
+        }
+        return Result.error("查询失败");
+    }
+    /**
+     * 查询项目下有效账户
+     *
+     * @param projectId 账户ID
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getAccountByProjectId")
+    public Result<Object> getAccountByProjectId(Long projectId, String id,
+                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(projectId)) {
+                return Result.error("请选择项目");
+            }
+            if (Check.isNull(id)) {
+                return Result.error("请选择应用");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            return kuaishouPopulationPackageService.getAccountByProjectId(projectId, id);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    @RequestMapping(value = "/crowdListQuery")
+    public Result<Object> crowdListQuery() {
+        try {
+            kuaishouPopulationPackageService.crowdListQuery();
+            return Result.ok("success");
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    @RequestMapping(value = "/checkPopulationPackage")
+    public Result<Object> checkPopulationPackage(String signature) {
+        try {
+           return kuaishouPopulationPackageService.checkPopulationPackage(signature);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+    /**
+     * 添加
+     *
+     * @param kuaishouPopulationPackage
+     * @return
+     */
+    @ApiOperation(value = "项目绑定的人群包模板-添加", notes = "项目绑定的人群包模板-添加")
+    @PostMapping(value = "/add")
+    public Result<Object> add(@RequestBody KuaishouPopulationPackage kuaishouPopulationPackage) {
+        Result<KuaishouPopulationPackage> result = new Result<>();
+        try {
+            if (Check.isNull(kuaishouPopulationPackage.getType())) {
+                return Result.error("请选择匹配类型");
+            }
+            if (Check.isNull(kuaishouPopulationPackage.getOrientationName())) {
+                return Result.error("请填写人群包名称");
+            }
+            if (Check.isNull(kuaishouPopulationPackage.getUrl())) {
+                return Result.error("请填写文件路径");
+            }
+            if (Check.isNull(kuaishouPopulationPackage.getProjectId())) {
+                return Result.error("请选择项目");
+            }
+            return kuaishouPopulationPackageService.createEntity(kuaishouPopulationPackage);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("上传异常");
+        }
+        return Result.error("上传失败");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouPopulationPackage
+     * @return
+     */
+    @ApiOperation(value = "项目绑定的人群包模板-编辑", notes = "项目绑定的人群包模板-编辑")
+    @PostMapping(value = "/push")
+    public Result<Object> push(@RequestBody JSONObject request) {
+        try {
+            JSONArray accountIds = request.getJSONArray("accountIds");
+            Long id = request.getLong("id");
+            if (Check.isNull(accountIds) || Check.isNull(id)) {
+                return Result.error("缺少参数");
+            }
+            return kuaishouPopulationPackageService.push(accountIds, id);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("推送失败");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "项目绑定的人群包模板-通过id删除", notes = "项目绑定的人群包模板-通过id删除")
+    @GetMapping(value = "/delete")
+    public Result<Object> delete(Long id) {
+        try {
+            if (Check.isNull(id)) {
+                return Result.error("参数为空");
+            }
+            KuaishouPopulationPackage populationPackage = new KuaishouPopulationPackage();
+            populationPackage.setId(id);
+            populationPackage.setDataStatus(0);//逻辑删除
+            boolean b = kuaishouPopulationPackageService.updateById(populationPackage);
+            if (b) {
+                return Result.ok("删除成功!");
+            }
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+        }
+        return Result.error("删除失败!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @ApiOperation(value = "项目绑定的人群包模板-批量删除", notes = "项目绑定的人群包模板-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouPopulationPackage> deleteBatch(@RequestParam(name = "ids") String ids) {
+        Result<KuaishouPopulationPackage> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouPopulationPackageService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "项目绑定的人群包模板-通过id查询", notes = "项目绑定的人群包模板-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouPopulationPackage> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouPopulationPackage> result = new Result<>();
+        KuaishouPopulationPackage kuaishouPopulationPackage = kuaishouPopulationPackageService.getById(id);
+        if (kuaishouPopulationPackage == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouPopulationPackage);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouPopulationPackage> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouPopulationPackage kuaishouPopulationPackage = JSON.parseObject(deString, KuaishouPopulationPackage.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouPopulationPackage, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouPopulationPackage> pageList = kuaishouPopulationPackageService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "项目绑定的人群包模板列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouPopulationPackage.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("项目绑定的人群包模板列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaishouPopulationPackage> listKuaishouPopulationPackages = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouPopulationPackage.class, params);
+                kuaishouPopulationPackageService.saveBatch(listKuaishouPopulationPackages);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouPopulationPackages.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.ai.entity;
 package cn.com.ctop.kuaishou.modules.ai.entity;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -8,6 +9,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.EqualsAndHashCode;
 
 
 import java.util.Date;
 import java.util.Date;
+import java.util.List;
 
 
 /**
 /**
  * 快手账户策略设置信息表
  * 快手账户策略设置信息表
@@ -71,7 +73,7 @@ public class AiKuaishouAdvertiserStrategy {
     /**
     /**
      * 深度出价
      * 深度出价
      */
      */
-    private Long cpaBid;
+    private String cpaBid;
     private Long deepConversionBid;
     private Long deepConversionBid;
     /**
     /**
      * 优先低成本出价
      * 优先低成本出价
@@ -376,7 +378,11 @@ public class AiKuaishouAdvertiserStrategy {
     private Long programUnitCnt;
     private Long programUnitCnt;
     private String materialKeyword;
     private String materialKeyword;
     private Integer historyTop;
     private Integer historyTop;
+    private Integer multipleBids;
 
 
     @TableField(exist = false)
     @TableField(exist = false)
     private String authName;
     private String authName;
+
+    @TableField(exist = false)
+    private List<JSONObject> appInfoList;
 }
 }

+ 295 - 148
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouUnitLevelOperationRecord.java

@@ -9,159 +9,306 @@ import java.util.Date;
 
 
 /**
 /**
  * 组创建记录
  * 组创建记录
+ *
  * @author jeecg-boot
  * @author jeecg-boot
- * @date   2021-04-12
  * @version V1.0
  * @version V1.0
+ * @date 2021-04-12
  */
  */
 @Data
 @Data
 @TableName("ctop_ai_kuaishou_unit_level_operation_record")
 @TableName("ctop_ai_kuaishou_unit_level_operation_record")
 public class AiKuaishouUnitLevelOperationRecord {
 public class AiKuaishouUnitLevelOperationRecord {
 
 
-	/**组操作表uuid*/
-	@TableId(type = IdType.ASSIGN_UUID)
-	private String groupUuid;
-	/**AI策略ID*/
-	private String aiStrategyUuid;
-	/**账户ID*/
-	private Long accountId;
-	/**广告计划ID*/
-	private Long campaignId;
-	/**广告组ID*/
-	private Long unitId;
-	/**广告组名称*/
-	private String groupName;
-	/**定向模板id*/
-	private Integer templateId;
-	/**优化目标出价类型*/
-	private Integer bidType;
-	/**优先从系统应用商店下载*/
-	private Integer useAppMarket;
-	/**应用商店列表*/
-	private String appStore;
-	/**出价*/
-	private Integer bid;
-	/**出价*/
-	private Integer cpaBid;
-	/**优先低成本出价*/
-	private Integer smartBid;
-	/**优化目标*/
-	private Integer ocpxActionType;
-	/**深度转化目标*/
-	private Integer deepConversionType;
-	/**付费ROI系数*/
-	private Float roiRatio;
-	/**资源位置*/
-	private String sceneId;
-	/** 创意制作方式*/
-	private Integer unitType;
-	/**投放开始时间*/
-	private String beginTime;
-	/**投放结束时间*/
-	private String endTime;
-	/**投放时间段*/
-	private String scheduleTime;
-	/**单日预算*/
-	private Integer dayBudget;
-	/**分日预算*/
-	private String dayBudgetSchedule;
-	/**转化目标ID*/
-	private Integer convertId;
-	/**url类型*/
-	private Integer urlType;
-	/**url类型*/
-	private Integer webUriType;
-	/**投放链接*/
-	private String url;
-	/**调起链接*/
-	private String schemaUri;
-	/**应用ID*/
-	private Integer appId;
-	/**创意展现方式*/
-	private Integer showMode;
-	/**投放方式*/
-	private Integer speed;
-	/**预约广告*/
-	private Integer siteType;
-	/**游戏礼包码*/
-	private String giftData;
-	/**是否使用落地页前置功能*/
-	private Integer videoLandingPage;
-	/**智能定向*/
-	private Integer autoTarget;
-	/**是否开启自动生成视频*/
-	private Integer autoCreatePhoto;
-	/**地域*/
-	private String region;
-	/**商圈定向*/
-	private String districtIds;
-	/**用户类型*/
-	private Integer userType;
-	/**最大年龄*/
-	private Integer ageMin;
-	/**最小年龄*/
-	private Integer ageMax;
-	/**固定年龄段*/
-	private String agesRange;
-	/**性别*/
-	private Integer gender;
-	/**操作系统*/
-	private Integer platformOs;
-	/**Android版本*/
-	private Integer androidOsv;
-	/**iOS版本*/
-	private Integer iosOsv;
-	/**网络环境*/
-	private Integer network;
-	/**设备品牌*/
-	private String deviceBrand;
-	/**设备价格*/
-	private String devicePrice;
-	/**商业兴趣类型*/
-	private Integer businessInterestType;
-	/**商业兴趣*/
-	private String businessInterest;
-	/**网红粉丝*/
-	private String fansStar;
-	/**兴趣视频用户*/
-	private String interestVideo;
-	/**APP行为-按分类*/
-	private String appInterest;
-	/**APP行为-按APP名称*/
-	private String appIds;
-	/**过滤已转化人群纬度*/
-	private Integer filterConvertedLevel;
-	/**人群包定向*/
-	private String population;
-	/**人群包排除*/
-	private String excludePopulation;
-	/**付费人群包id*/
-	private String paidAudience;
-	/**开启智能扩量*/
-	private Integer isOpen;
-	/**不可突破年龄*/
-	private Integer noAgeBreak;
-	/**不可突破性别*/
-	private Integer noGenderBreak;
-	/**不可突破地域*/
-	private Integer noAreaBreak;
-	/**行为兴趣定向*/
-	private String behaviorInterest;
-	/**操作类型 1-新增 2-修改*/
-	private Integer operationType;
-	/**组创建时间*/
-	private Date groupCreateTime;
-	/**组更新时间*/
-	private Date groupUpdateTime;
-	/**创建时间*/
-	private Date createTime;
-	/**状态*/
-	private Integer status;
-	/**状态详情*/
-	private String message;
-	/**程序化创意2.0-是否开启智能抽帧*/
-	private Integer smartCover;
-	/**程序化创意2.0-是否开启素材挖掘*/
-	private Integer assetMining;
-	/**深度转化目标出价*/
-	private Integer deepConversionBid;
+    /**
+     * 组操作表uuid
+     */
+    @TableId(type = IdType.ASSIGN_UUID)
+    private String groupUuid;
+    /**
+     * AI策略ID
+     */
+    private String aiStrategyUuid;
+    /**
+     * 账户ID
+     */
+    private Long accountId;
+    /**
+     * 广告计划ID
+     */
+    private Long campaignId;
+    /**
+     * 广告组ID
+     */
+    private Long unitId;
+    /**
+     * 广告组名称
+     */
+    private String groupName;
+    /**
+     * 定向模板id
+     */
+    private Integer templateId;
+    /**
+     * 优化目标出价类型
+     */
+    private Integer bidType;
+    /**
+     * 优先从系统应用商店下载
+     */
+    private Integer useAppMarket;
+    /**
+     * 应用商店列表
+     */
+    private String appStore;
+    /**
+     * 出价
+     */
+    private Integer bid;
+    /**
+     * 出价
+     */
+    private Integer cpaBid;
+    /**
+     * 优先低成本出价
+     */
+    private Integer smartBid;
+    /**
+     * 优化目标
+     */
+    private Integer ocpxActionType;
+    /**
+     * 深度转化目标
+     */
+    private Integer deepConversionType;
+    /**
+     * 付费ROI系数
+     */
+    private Float roiRatio;
+    /**
+     * 资源位置
+     */
+    private String sceneId;
+    /**
+     * 创意制作方式
+     */
+    private Integer unitType;
+    /**
+     * 投放开始时间
+     */
+    private String beginTime;
+    /**
+     * 投放结束时间
+     */
+    private String endTime;
+    /**
+     * 投放时间段
+     */
+    private String scheduleTime;
+    /**
+     * 单日预算
+     */
+    private Integer dayBudget;
+    /**
+     * 分日预算
+     */
+    private String dayBudgetSchedule;
+    /**
+     * 转化目标ID
+     */
+    private Integer convertId;
+    /**
+     * url类型
+     */
+    private Integer urlType;
+    /**
+     * url类型
+     */
+    private Integer webUriType;
+    /**
+     * 投放链接
+     */
+    private String url;
+    /**
+     * 调起链接
+     */
+    private String schemaUri;
+    /**
+     * 应用ID
+     */
+    private Integer appId;
+    /**
+     * 创意展现方式
+     */
+    private Integer showMode;
+    /**
+     * 投放方式
+     */
+    private Integer speed;
+    /**
+     * 预约广告
+     */
+    private Integer siteType;
+    /**
+     * 游戏礼包码
+     */
+    private String giftData;
+    /**
+     * 是否使用落地页前置功能
+     */
+    private Integer videoLandingPage;
+    /**
+     * 智能定向
+     */
+    private Integer autoTarget;
+    /**
+     * 是否开启自动生成视频
+     */
+    private Integer autoCreatePhoto;
+    /**
+     * 地域
+     */
+    private String region;
+    /**
+     * 商圈定向
+     */
+    private String districtIds;
+    /**
+     * 用户类型
+     */
+    private Integer userType;
+    /**
+     * 最大年龄
+     */
+    private Integer ageMin;
+    /**
+     * 最小年龄
+     */
+    private Integer ageMax;
+    /**
+     * 固定年龄段
+     */
+    private String agesRange;
+    /**
+     * 性别
+     */
+    private Integer gender;
+    /**
+     * 操作系统
+     */
+    private Integer platformOs;
+    /**
+     * Android版本
+     */
+    private Integer androidOsv;
+    /**
+     * iOS版本
+     */
+    private Integer iosOsv;
+    /**
+     * 网络环境
+     */
+    private Integer network;
+    /**
+     * 设备品牌
+     */
+    private String deviceBrand;
+    /**
+     * 设备价格
+     */
+    private String devicePrice;
+    /**
+     * 商业兴趣类型
+     */
+    private Integer businessInterestType;
+    /**
+     * 商业兴趣
+     */
+    private String businessInterest;
+    /**
+     * 网红粉丝
+     */
+    private String fansStar;
+    /**
+     * 兴趣视频用户
+     */
+    private String interestVideo;
+    /**
+     * APP行为-按分类
+     */
+    private String appInterest;
+    /**
+     * APP行为-按APP名称
+     */
+    private String appIds;
+    /**
+     * 过滤已转化人群纬度
+     */
+    private Integer filterConvertedLevel;
+    /**
+     * 人群包定向
+     */
+    private String population;
+    /**
+     * 人群包排除
+     */
+    private String excludePopulation;
+    /**
+     * 付费人群包id
+     */
+    private String paidAudience;
+    /**
+     * 开启智能扩量
+     */
+    private Integer isOpen;
+    /**
+     * 不可突破年龄
+     */
+    private Integer noAgeBreak;
+    /**
+     * 不可突破性别
+     */
+    private Integer noGenderBreak;
+    /**
+     * 不可突破地域
+     */
+    private Integer noAreaBreak;
+    /**
+     * 行为兴趣定向
+     */
+    private String behaviorInterest;
+    /**
+     * 操作类型 1-新增 2-修改
+     */
+    private Integer operationType;
+    /**
+     * 组创建时间
+     */
+    private Date groupCreateTime;
+    /**
+     * 组更新时间
+     */
+    private Date groupUpdateTime;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    /**
+     * 状态
+     */
+    private Integer status;
+    /**
+     * 状态详情
+     */
+    private String message;
+    /**
+     * 程序化创意2.0-是否开启智能抽帧
+     */
+    private Integer smartCover;
+    /**
+     * 程序化创意2.0-是否开启素材挖掘
+     */
+    private Integer assetMining;
+    /**
+     * 深度转化目标出价
+     */
+    private Integer deepConversionBid;
 }
 }

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

@@ -0,0 +1,77 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+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;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 多应用分别出价
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-18
+ */
+@Data
+@TableName("ctop_ai_kuaishou_app_multiple_bids")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_ai_kuaishou_app_multiple_bids对象", description = "多应用分别出价")
+public class KuaiShouAppMultipleBids {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户id
+     */
+    @Excel(name = "账户id", width = 15)
+    @ApiModelProperty(value = "账户id")
+    private Long accountId;
+    /**
+     * app_id
+     */
+    @Excel(name = "app_id", width = 15)
+    @ApiModelProperty(value = "app_id")
+    private Long appId;
+    /**
+     * 出价
+     */
+    @Excel(name = "出价", width = 15)
+    @ApiModelProperty(value = "出价")
+    private Long cpaBid;
+    /**
+     * 监测链接
+     */
+    @Excel(name = "监测链接", width = 15)
+    @ApiModelProperty(value = "监测链接")
+    private String trackUrl;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

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

@@ -0,0 +1,71 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+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;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 应用-广告组关联表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-14
+ */
+@Data
+@TableName("ctop_kuaishou_app_group")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_app_group对象", description = "应用-广告组关联表")
+public class KuaishouAppGroup {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 广告组ID
+     */
+    @Excel(name = "广告组ID", width = 15)
+    @ApiModelProperty(value = "广告组ID")
+    private Long unitId;
+    /**
+     * 应用id
+     */
+    @Excel(name = "应用id", width = 15)
+    @ApiModelProperty(value = "应用id")
+    private Long appId;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

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

@@ -0,0 +1,126 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+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;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 项目绑定的应用
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-12
+ */
+@Data
+@TableName("ctop_kuaishou_app_package")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_app_package对象", description = "项目绑定的应用")
+public class KuaishouAppPackage {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 项目ID
+     */
+    @Excel(name = "项目ID", width = 15)
+    @ApiModelProperty(value = "项目ID")
+    private Long projectId;
+    /**
+     * 应用唯一标识
+     */
+    @Excel(name = "应用唯一标识", width = 15)
+    @ApiModelProperty(value = "应用唯一标识")
+    private String appMd5;
+    /**
+     * 应用地址
+     */
+    @Excel(name = "应用地址", width = 15)
+    @ApiModelProperty(value = "应用地址")
+    private String url;
+    /**
+     * 应用标记
+     */
+    @Excel(name = "应用标记", width = 15)
+    @ApiModelProperty(value = "应用标记")
+    private String appVersion;
+    /**
+     * 应用名称
+     */
+    @Excel(name = "应用名称", width = 15)
+    @ApiModelProperty(value = "应用名称")
+    private String appName;
+    /**
+     * 应用图标链接地址
+     */
+    @Excel(name = "应用图标链接地址", width = 15)
+    @ApiModelProperty(value = "应用图标链接地址")
+    private String appIconUrl;
+    /**
+     * 安卓类应用必填 隐私政策链接
+     */
+    private String appPrivacyUrl;
+    /**
+     * 图片token
+     */
+    @Excel(name = "图片token", width = 15)
+    @ApiModelProperty(value = "图片token")
+    private String imageToken;
+    /**
+     * 应用包名
+     */
+    @Excel(name = "应用包名", width = 15)
+    @ApiModelProperty(value = "应用包名")
+    private String packageName;
+
+    /**
+     * 监测链接
+     */
+    private String trackUrl;
+    /**
+     * 应用类型 1: Android 应用下载,2: Android 网页游戏,3: iOS 应用下载, 4:iOS 网页游戏
+     */
+    @Excel(name = "应用类型 1: Android 应用下载,2: Android 网页游戏,3: iOS 应用下载, 4:iOS 网页游戏", width = 15)
+    @ApiModelProperty(value = "应用类型 1: Android 应用下载,2: Android 网页游戏,3: iOS 应用下载, 4:iOS 网页游戏")
+    private Integer platform;
+    /**
+     * 是否接入快手广告监测SDK	0:未接入,1:已接入
+     */
+    @Excel(name = "是否接入快手广告监测SDK	0:未接入,1:已接入", width = 15)
+    @ApiModelProperty(value = "是否接入快手广告监测SDK	0:未接入,1:已接入")
+    private Integer useSdk;
+    /**
+     * 0无效,1有效
+     */
+    private Integer dataStatus;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

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

@@ -0,0 +1,79 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+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-05-13
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_kuaishou_app_package_rel")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_kuaishou_app_package_rel对象", description="应用和账户关联表")
+public class KuaishouAppPackageRel {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	@ApiModelProperty(value = "id")
+	private Long id;
+	/**应用模板ID*/
+	@Excel(name = "应用模板ID", width = 15)
+	@ApiModelProperty(value = "应用模板ID")
+	private Long apptemId;
+	/**项目ID*/
+	@Excel(name = "项目ID", width = 15)
+	@ApiModelProperty(value = "项目ID")
+	private Long projectId;
+	/**账户ID*/
+	@Excel(name = "账户ID", width = 15)
+	@ApiModelProperty(value = "账户ID")
+	private Long accountId;
+	/**账户ID*/
+	@Excel(name = "账户ID", width = 15)
+	@ApiModelProperty(value = "账户ID")
+	private Long appId;
+	/**快手方-应用地址*/
+	@Excel(name = "快手方-应用地址", width = 15)
+	@ApiModelProperty(value = "快手方-应用地址")
+	private String returnUrl;
+
+	private Integer dataStatus;
+
+	private String appVersion;
+	/**返回信息*/
+	@Excel(name = "返回信息", width = 15)
+	@ApiModelProperty(value = "返回信息")
+	private String message;
+	/**更新时间*/
+	@Excel(name = "更新时间", width = 15)
+	@ApiModelProperty(value = "更新时间")
+	private String returnUpdateTime;
+	/**创建时间*/
+	@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	@ApiModelProperty(value = "创建时间")
+	private Date createTime;
+	/**修改时间*/
+	@Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	@ApiModelProperty(value = "修改时间")
+	private Date updateTime;
+}

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

@@ -0,0 +1,232 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+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 org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 自动投放-定向包详情
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-20
+ */
+@Data
+@TableName("ctop_kuaishou_directional_package")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_directional_package对象", description = "自动投放-定向包详情")
+public class KuaishouDirectionalPackage {
+
+    /**
+     * id
+     */
+    private String id;
+    /**
+     * 定向模板id
+     */
+    private Long projectId;
+    /**
+     * 0无效,1有效
+     */
+    private Integer dataStatus;
+
+    private String templateName;
+    /**
+     * 地域
+     */
+    @Excel(name = "地域", width = 15)
+    @ApiModelProperty(value = "地域")
+    private String region;
+    /**
+     * 商圈定向
+     */
+    @Excel(name = "商圈定向", width = 15)
+    @ApiModelProperty(value = "商圈定向")
+    private String districtIds;
+    /**
+     * 用户类型 0:实时1:常驻 2:不限
+     */
+    @Excel(name = "用户类型 0:实时1:常驻 2:不限 ", width = 15)
+    @ApiModelProperty(value = "用户类型 0:实时1:常驻 2:不限 ")
+    private Integer userType;
+    /**
+     * 可选年龄段 18:18-23岁 24:24-30岁 31:31-40岁 41:41-49岁 50:50-100岁
+     */
+    @Excel(name = "可选年龄段 18:18-23岁 24:24-30岁 31:31-40岁 41:41-49岁 50:50-100岁 ", width = 15)
+    @ApiModelProperty(value = "可选年龄段 18:18-23岁 24:24-30岁 31:31-40岁 41:41-49岁 50:50-100岁 ")
+    private String agesRange;
+    /**
+     * 年龄最小值
+     */
+    @Excel(name = "年龄最小值", width = 15)
+    @ApiModelProperty(value = "年龄最小值")
+    private Integer min;
+    /**
+     * 年龄最大值
+     */
+    @Excel(name = "年龄最大值", width = 15)
+    @ApiModelProperty(value = "年龄最大值")
+    private Integer max;
+    /**
+     * 性别 1:女性, 2:男性,0 表示不限
+     */
+    @Excel(name = "性别 1:女性, 2:男性,0 表示不限", width = 15)
+    @ApiModelProperty(value = "性别 1:女性, 2:男性,0 表示不限")
+    private Integer gender;
+    /**
+     * 定向的 os 版本 应用安装类计划以app_id中的platform_os为准 1:Android,2:iOS,0 表示不限
+     */
+    @Excel(name = "定向的 os 版本 应用安装类计划以app_id中的platform_os为准 1:Android,2:iOS,0 表示不限", width = 15)
+    @ApiModelProperty(value = "定向的 os 版本 应用安装类计划以app_id中的platform_os为准 1:Android,2:iOS,0 表示不限")
+    private Integer platformOs;
+    /**
+     * Android 版本 3:不限,4:4.x+,5:5.x+,6:6.x+,7:7.x+
+     */
+    @Excel(name = "Android 版本 3:不限,4:4.x+,5:5.x+,6:6.x+,7:7.x+", width = 15)
+    @ApiModelProperty(value = "Android 版本 3:不限,4:4.x+,5:5.x+,6:6.x+,7:7.x+")
+    private Integer androidOsv;
+    /**
+     * iOS 版本 6:不限, 7:7.x+, 8:8.x+, 9:9.x+, 10:10.x+
+     */
+    @Excel(name = "iOS 版本 6:不限, 7:7.x+, 8:8.x+, 9:9.x+, 10:10.x+", width = 15)
+    @ApiModelProperty(value = "iOS 版本 6:不限, 7:7.x+, 8:8.x+, 9:9.x+, 10:10.x+")
+    private Integer iosOsv;
+    /**
+     * 网络环境 1:WI-FI,2:移动网络,0:表示不限
+     */
+    @Excel(name = "网络环境 1:WI-FI,2:移动网络,0:表示不限", width = 15)
+    @ApiModelProperty(value = "网络环境 1:WI-FI,2:移动网络,0:表示不限")
+    private Integer network;
+    /**
+     * 过滤已转化人群纬度 0:不限 1:广告组 2:广告计划 3:本账户 4:公司主体 5:APP
+     */
+    @Excel(name = "过滤已转化人群纬度 0:不限 1:广告组 2:广告计划 3:本账户 4:公司主体 5:APP", width = 15)
+    @ApiModelProperty(value = "过滤已转化人群纬度 0:不限 1:广告组 2:广告计划 3:本账户 4:公司主体 5:APP")
+    private Integer filterConvertedLevel;
+    /**
+     * 设备品牌  1:OPPO,2:VIVO, 3:华为,4:小米,5:荣耀,6:三星,7:金立,8:魅族,9:乐视,10:其他,11:苹果(只有 platform_os 为不限时支持此选项);传值为 [] 表示不限;当 platform_os 表示 iOS 的时候,没有设备品牌定向
+     */
+    @Excel(name = "设备品牌  1:OPPO,2:VIVO, 3:华为,4:小米,5:荣耀,6:三星,7:金立,8:魅族,9:乐视,10:其他,11:苹果(只有 platform_os 为不限时支持此选项);传值为 [] 表示不限;当 platform_os 表示 iOS 的时候,没有设备品牌定向", width = 15)
+    @ApiModelProperty(value = "设备品牌  1:OPPO,2:VIVO, 3:华为,4:小米,5:荣耀,6:三星,7:金立,8:魅族,9:乐视,10:其他,11:苹果(只有 platform_os 为不限时支持此选项);传值为 [] 表示不限;当 platform_os 表示 iOS 的时候,没有设备品牌定向")
+    private String deviceBrand;
+    /**
+     * 设备价格 1:1,500元以下,2:1,501~2,000,3:2,001~2,500,4:2,501~3,000,5、3,001~3,500,6:3,501~4,000,7:4,001~4,500,8:4,501~5,000,9:5,001~5,500,10:5,500元以上,传值为 [] 表示不限
+     */
+    @Excel(name = "设备价格 1:1,500元以下,2:1,501~2,000,3:2,001~2,500,4:2,501~3,000,5、3,001~3,500,6:3,501~4,000,7:4,001~4,500,8:4,501~5,000,9:5,001~5,500,10:5,500元以上,传值为 [] 表示不限", width = 15)
+    @ApiModelProperty(value = "设备价格 1:1,500元以下,2:1,501~2,000,3:2,001~2,500,4:2,501~3,000,5、3,001~3,500,6:3,501~4,000,7:4,001~4,500,8:4,501~5,000,9:5,001~5,500,10:5,500元以上,传值为 [] 表示不限")
+    private String devicePrice;
+    /**
+     * 商业兴趣类型 0:默认值 1:智能投放 2:兴趣标签
+     */
+    @Excel(name = "商业兴趣类型 0:默认值 1:智能投放 2:兴趣标签", width = 15)
+    @ApiModelProperty(value = "商业兴趣类型 0:默认值 1:智能投放 2:兴趣标签")
+    private Integer businessInterestType;
+    /**
+     * 商业兴趣
+     */
+    @Excel(name = "商业兴趣", width = 15)
+    @ApiModelProperty(value = "商业兴趣")
+    private String businessInterest;
+    /**
+     * 网红类别
+     */
+    @Excel(name = "网红类别", width = 15)
+    @ApiModelProperty(value = "网红类别")
+    private String fansStar;
+    /**
+     * 兴趣视频
+     */
+    @Excel(name = "兴趣视频", width = 15)
+    @ApiModelProperty(value = "兴趣视频")
+    private String interestVideo;
+    /**
+     * APP行为-按分类
+     */
+    @Excel(name = "APP行为-按分类", width = 15)
+    @ApiModelProperty(value = "APP行为-按分类")
+    private String appInterest;
+    /**
+     * APP行为-按APP名称
+     */
+    @Excel(name = "APP行为-按APP名称", width = 15)
+    @ApiModelProperty(value = "APP行为-按APP名称")
+    private String appIds;
+    /**
+     * 开启智能扩量 默认为0,为1时打开智能扩量,其他数值报错;关闭智能扩量时,以下三个字段必须为0
+     */
+    @Excel(name = "开启智能扩量 默认为0,为1时打开智能扩量,其他数值报错;关闭智能扩量时,以下三个字段必须为0", width = 15)
+    @ApiModelProperty(value = "开启智能扩量 默认为0,为1时打开智能扩量,其他数值报错;关闭智能扩量时,以下三个字段必须为0")
+    private Integer isOpen;
+    /**
+     * 不可突破年龄 默认为0(可突破/无需控制),定向age数据不为空时,可设为1(不可突破)
+     */
+    @Excel(name = "不可突破年龄 默认为0(可突破/无需控制),定向age数据不为空时,可设为1(不可突破)", width = 15)
+    @ApiModelProperty(value = "不可突破年龄 默认为0(可突破/无需控制),定向age数据不为空时,可设为1(不可突破)")
+    private Integer noAgeBreak;
+    /**
+     * 不可突破性别 默认为0(可突破/无需控制),定向gender数据不为空时,可设为1(不可突破
+     */
+    @Excel(name = "不可突破性别 默认为0(可突破/无需控制),定向gender数据不为空时,可设为1(不可突破", width = 15)
+    @ApiModelProperty(value = "不可突破性别 默认为0(可突破/无需控制),定向gender数据不为空时,可设为1(不可突破")
+    private Integer noGenderBreak;
+    /**
+     * 不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)
+     */
+    @Excel(name = "不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)", width = 15)
+    @ApiModelProperty(value = "不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)")
+    private Integer noAreaBreak;
+    /**
+     * 行为定向关键词
+     */
+    @Excel(name = "行为定向关键词", width = 15)
+    @ApiModelProperty(value = "行为定向关键词")
+    private String keyword;
+    /**
+     * 行为定向 类目词
+     */
+    @Excel(name = "行为定向 类目词", width = 15)
+    @ApiModelProperty(value = "行为定向 类目词")
+    private String label;
+    /**
+     * 兴趣定向类目词
+     */
+    @Excel(name = "兴趣定向类目词", width = 15)
+    @ApiModelProperty(value = "兴趣定向类目词")
+    private String interestLabel;
+    /**
+     * 在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天
+     */
+    @Excel(name = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天", width = 15)
+    @ApiModelProperty(value = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天")
+    private Integer timeType;
+    /**
+     * 行为强度	0:不限 1:高强度
+     */
+    @Excel(name = "行为强度	0:不限 1:高强度", width = 15)
+    @ApiModelProperty(value = "行为强度	0:不限 1:高强度")
+    private Integer strengthType;
+    /**
+     * 行为场景	1:社区 2:APP 4:推广
+     */
+    @Excel(name = "行为场景	1:社区 2:APP 4:推广", width = 15)
+    @ApiModelProperty(value = "行为场景	1:社区 2:APP 4:推广")
+    private String sceneType;
+    /**
+     * 定向模板创建时间
+     */
+    @ApiModelProperty(value = "定向模板创建时间")
+    private Date createTime;
+    /**
+     * 定向模板修改时间
+     */
+    @ApiModelProperty(value = "定向模板修改时间")
+    private Date updateTime;
+}

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

@@ -0,0 +1,109 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+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 org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 自动投放-定向包详情关系表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-25
+ */
+@Data
+@TableName("ctop_kuaishou_directional_package_rel")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_directional_template_rel对象", description = "自动投放-定向包详情关系表")
+public class KuaishouDirectionalaPckageRel {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 本地定向模板ID
+     */
+    @Excel(name = "本地定向模板ID", width = 15)
+    @ApiModelProperty(value = "本地定向模板ID")
+    private String dirId;
+    /**
+     * 项目ID
+     */
+    @Excel(name = "项目ID", width = 15)
+    @ApiModelProperty(value = "项目ID")
+    private Long projectId;
+    /**
+     * 0无效,1有效
+     */
+    private Integer dataStatus;
+    /**
+     * 定向模板id
+     */
+    @Excel(name = "定向模板id", width = 15)
+    @ApiModelProperty(value = "定向模板id")
+    private Long templateId;
+    /**
+     * 人群包名
+     */
+    @Excel(name = "人群包名", width = 15)
+    @ApiModelProperty(value = "人群包名")
+    private String templateName;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long relId;
+    /**
+     * 绑定类型,account 账户,unit 组
+     */
+    @Excel(name = "绑定类型,account 账户,unit 组", width = 15)
+    @ApiModelProperty(value = "绑定类型,account 账户,unit 组")
+    private String relType;
+    /**
+     * 排除人群包
+     */
+    @Excel(name = "排除人群包", width = 15)
+    @ApiModelProperty(value = "排除人群包")
+    private String excludePopulation;
+    /**
+     * 付费人群包
+     */
+    @Excel(name = "付费人群包", width = 15)
+    @ApiModelProperty(value = "付费人群包")
+    private String paidAudience;
+    /**
+     * 定向人群包
+     */
+    @Excel(name = "定向人群包", width = 15)
+    @ApiModelProperty(value = "定向人群包")
+    private String population;
+    /**
+     * 结果说明
+     */
+    @Excel(name = "结果说明", width = 15)
+    @ApiModelProperty(value = "结果说明")
+    private String message;
+    /**
+     * 定向模板创建时间
+     */
+    @ApiModelProperty(value = "定向模板创建时间")
+    private Date createTime;
+    /**
+     * 定向模板修改时间
+     */
+    @ApiModelProperty(value = "定向模板修改时间")
+    private Date updateTime;
+}

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

@@ -0,0 +1,119 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+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
+ * @version V1.0
+ * @date 2021-05-11
+ */
+@Data
+@TableName("ctop_kuaishou_landpage_package")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_landpage_package对象", description = "落地页账户项目关联表")
+public class KuaishouLandpagePackage {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 项目ID
+     */
+    @Excel(name = "项目ID", width = 15)
+    @ApiModelProperty(value = "项目ID")
+    private Long projectId;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 落地页名称
+     */
+    @Excel(name = "落地页名称", width = 15)
+    @ApiModelProperty(value = "落地页名称")
+    private String landpageName;
+    /**
+     * 落地页ID
+     */
+    @Excel(name = "落地页ID", width = 15)
+    @ApiModelProperty(value = "落地页ID")
+    private Long siteId;
+    /**
+     * 落地页URL
+     */
+    @Excel(name = "落地页URL", width = 15)
+    @ApiModelProperty(value = "落地页URL")
+    private String url;
+    /**
+     * 落地页类型	0:站内;1:联盟
+     */
+    @Excel(name = "落地页类型	0:站内;1:联盟", width = 15)
+    @ApiModelProperty(value = "落地页类型	0:站内;1:联盟")
+    private Integer bizType;
+    /**
+     * 应用ID
+     */
+    @Excel(name = "应用ID", width = 15)
+    @ApiModelProperty(value = "应用ID")
+    private Long appId;
+    /**
+     * 组件数据
+     */
+    @Excel(name = "组件数据", width = 15)
+    @ApiModelProperty(value = "组件数据")
+    private String comps;
+    /**
+     * 落地页创建时间
+     */
+    @Excel(name = "落地页创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "落地页创建时间")
+    private Date landpageCreateTime;
+    /**
+     * 落地页修改时间
+     */
+    @Excel(name = "落地页修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "落地页修改时间")
+    private Date landpageUpdateTime;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

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

@@ -0,0 +1,63 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+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-05-11
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_kuaishou_landpage_package_rel")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_kuaishou_landpage_package_rel对象", description="落地页-广告组关联表")
+public class KuaishouLandpagePackageRel {
+    
+	/**id*/
+	@TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+	private Long id;
+	/**账户ID*/
+	@Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+	private Long accountId;
+	/**广告组ID*/
+	@Excel(name = "广告组ID", width = 15)
+    @ApiModelProperty(value = "广告组ID")
+	private Long unitId;
+	/**落地页id*/
+	@Excel(name = "落地页id", width = 15)
+    @ApiModelProperty(value = "落地页id")
+	private Long siteId;
+	/**创意ID集*/
+	@Excel(name = "创意ID集", width = 15)
+    @ApiModelProperty(value = "创意ID集")
+	private String creativeArr;
+	/**创建时间*/
+	@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+	private Date createTime;
+	/**修改时间*/
+	@Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+	private Date updateTime;
+}

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

@@ -0,0 +1,59 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+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-05-08
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_kuaishou_population_group")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_kuaishou_population_group对象", description="人群包-广告组关联表")
+public class KuaishouPopulationGroup {
+    
+	/**id*/
+	@TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+	private Long id;
+	/**账户ID*/
+	@Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+	private Long accountId;
+	/**广告组ID*/
+	@Excel(name = "广告组ID", width = 15)
+    @ApiModelProperty(value = "广告组ID")
+	private Long unitId;
+	/**人群包id*/
+	@Excel(name = "人群包id", width = 15)
+    @ApiModelProperty(value = "人群包id")
+	private Long orientationId;
+	/**创建时间*/
+	@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+	private Date createTime;
+	/**修改时间*/
+	@Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+	private Date updateTime;
+}

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

@@ -0,0 +1,93 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+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
+ * @version V1.0
+ * @date 2021-05-06
+ */
+@Data
+@TableName("ctop_kuaishou_population_package")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_population_package对象", description = "项目绑定的人群包模板")
+public class KuaishouPopulationPackage {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 项目ID
+     */
+    @Excel(name = "项目ID", width = 15)
+    @ApiModelProperty(value = "项目ID")
+    private Long projectId;
+    /**
+     * 人群包名称
+     */
+    @Excel(name = "人群包名称", width = 15)
+    @ApiModelProperty(value = "人群包名称")
+    private String orientationName;
+    /**
+     * 链接
+     */
+    @Excel(name = "链接", width = 15)
+    @ApiModelProperty(value = "链接")
+    private String url;
+
+    private String statDate;
+    /**
+     * 0 删除,1 有效
+     */
+    @Excel(name = "0 删除,1 有效", width = 15)
+    @ApiModelProperty(value = "0 删除,1 有效")
+    private Integer dataStatus;
+    /**
+     * 匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5
+     */
+    @Excel(name = "匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5", width = 15)
+    @ApiModelProperty(value = "匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5")
+    private Integer type;
+    /**
+     * signature
+     */
+    @Excel(name = "signature", width = 15)
+    @ApiModelProperty(value = "signature")
+    private String signature;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

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

@@ -0,0 +1,102 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+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-05-07
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_kuaishou_population_package_rel")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_kuaishou_population_package_rel对象", description="人群包模板和账户绑定关系表")
+public class KuaishouPopulationPackageRel {
+    
+	/**id*/
+	@TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+	private Long id;
+	/**本地人群模板ID*/
+	@Excel(name = "本地人群模板ID", width = 15)
+    @ApiModelProperty(value = "本地人群模板ID")
+	private Long popId;
+	/**项目ID*/
+	@Excel(name = "项目ID", width = 15)
+    @ApiModelProperty(value = "项目ID")
+	private Long projectId;
+	/**账户ID*/
+	@Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+	private Long accountId;
+	/**上传日期*/
+	@Excel(name = "上传日期", width = 15)
+    @ApiModelProperty(value = "上传日期")
+	private String statDate;
+	/**人群包ID*/
+	@Excel(name = "人群包ID", width = 15)
+    @ApiModelProperty(value = "人群包ID")
+	private Long orientationId;
+	/**人群包名称*/
+	@Excel(name = "人群包名称", width = 15)
+    @ApiModelProperty(value = "人群包名称")
+	private String orientationName;
+	/**人群包类型 1上传人群,2广告人群,3主题专区,4逻辑规则,5人群扩展,6平台定制,7定制付费...*/
+	@Excel(name = "人群包类型 1上传人群,2广告人群,3主题专区,4逻辑规则,5人群扩展,6平台定制,7定制付费...", width = 15)
+    @ApiModelProperty(value = "人群包类型 1上传人群,2广告人群,3主题专区,4逻辑规则,5人群扩展,6平台定制,7定制付费...")
+	private String populationType;
+	/**匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5*/
+	@Excel(name = "匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5", width = 15)
+    @ApiModelProperty(value = "匹配类型 1:IMEI;2:IDFA;3:IMEI_MD5;4:IDFA_MD5;5:手机号-MD5;7:OAID;8:OAID_MD5")
+	private Integer type;
+	/**状态 0计算中,1已生效,2已删除,3推送中,4已推送,5计算失败,6推送失败,7已失效*/
+	@Excel(name = "状态 0计算中,1已生效,2已删除,3推送中,4已推送,5计算失败,6推送失败,7已失效", width = 15)
+    @ApiModelProperty(value = "状态 0计算中,1已生效,2已删除,3推送中,4已推送,5计算失败,6推送失败,7已失效")
+	private Integer status;
+	/**0成功,1失败*/
+	private Integer dataStatus;
+	/**覆盖人群*/
+	@Excel(name = "覆盖人群", width = 15)
+    @ApiModelProperty(value = "覆盖人群")
+	private Long coverNum;
+	/**上传数量*/
+	@Excel(name = "上传数量", width = 15)
+    @ApiModelProperty(value = "上传数量")
+	private Long recordSize;
+	/**匹配数量*/
+	@Excel(name = "匹配数量", width = 15)
+    @ApiModelProperty(value = "匹配数量")
+	private Long matchSize;
+	/**创建时间*/
+	@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+	private Date createTime;
+	/**修改时间*/
+	@Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+	private Date updateTime;
+	/**执行结果反馈*/
+	@Excel(name = "执行结果反馈", width = 15)
+    @ApiModelProperty(value = "执行结果反馈")
+	private String message;
+	private String signature;
+}

+ 21 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaiShouAppMultipleBidsMapper.java

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouAppMultipleBids;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 多应用分别出价
+ *
+ * @author jeecg-boot
+ * 2021-05-18
+ * @version V1.0
+ */
+public interface KuaiShouAppMultipleBidsMapper extends BaseMapper<KuaiShouAppMultipleBids> {
+
+    List<JSONObject> getAppInfoList(@Param("accountId") Long accountId, @Param("appIds") JSONArray jsonArray);
+}

+ 19 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppGroupMapper.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import java.util.List;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppGroup;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 应用-广告组关联表
+ * @author: jeecg-boot
+ * @date:   2021-05-14
+ * @cersion: V1.0
+ */
+public interface KuaishouAppGroupMapper extends BaseMapper<KuaishouAppGroup> {
+
+    void replaceBatch(@Param("request") JSONObject request);
+}

+ 30 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppPackageMapper.java

@@ -0,0 +1,30 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackage;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 项目绑定的应用
+ *
+ * @author: jeecg-boot
+ * @date: 2021-05-12
+ * @cersion: V1.0
+ */
+public interface KuaishouAppPackageMapper extends BaseMapper<KuaishouAppPackage> {
+
+    void replaceBatch(@Param("appList") List<KuaishouAppPackage> appList);
+
+    List<String> queryAppVersions(@Param("projectId") Long projectId);
+
+    List<Long> queryByAppVersion(@Param("projectId") Long projectId,@Param("appVersion") String appVersion);
+
+    List<JSONObject> queryPageList(@Param("appVersion") String appVersion, @Param("projectId") Long projectId, @Param("platform") Integer platform);
+
+    Long queryUnitCount(@Param("id") Long id);
+
+    List<JSONObject> getRelatedGroups(@Param("id") Long id, @Param("accountId") Long accountId);
+}

+ 29 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppPackageRelMapper.java

@@ -0,0 +1,29 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackageRel;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 应用和账户关联表
+ *
+ * @author: jeecg-boot
+ * @date: 2021-05-13
+ * @cersion: V1.0
+ */
+public interface KuaishouAppPackageRelMapper extends BaseMapper<KuaishouAppPackageRel> {
+
+    void replaceBatch(@Param("relList") List<KuaishouAppPackageRel> relList);
+
+    KuaishouAppPackageRel queryEntityByAccountId(@Param("accountId") Long accountId, @Param("appVersion") String appVersion);
+
+    List<JSONObject> queryPushResults(@Param("id") String id, @Param("accountIds") JSONArray accountIds, @Param("status") String status);
+
+    List<JSONObject> getRelatedAccounts(@Param("id") Long id);
+
+    List<JSONObject> getAccountByProjectId(@Param("projectId") Long projectId, @Param("id") String id);
+}

+ 0 - 41
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouCrowdPackMapper.java

@@ -1,41 +0,0 @@
-package cn.com.ctop.kuaishou.modules.ai.mapper;
-
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * 人群报表
- *
- * @author: jeecg-boot
- * @date: 2021-03-26
- * @cersion: V1.0
- */
-public interface KuaishouCrowdPackMapper extends BaseMapper<KuaishouCrowdPack> {
-
-    Long getTotal(@Param(value = "status") Integer status, @Param(value = "accountId") Long accountId, @Param(value = "orientationName") String orientationName);
-
-    List<JSONObject> queryPageList(@Param(value = "status") Integer status, @Param(value = "accountId") Long accountId, @Param(value = "orientationName") String orientationName);
-
-    List<KuaishouCrowdPack> queryListByStatus();
-
-    List<JSONObject> queryFailReason(@Param(value = "signature") String signature);
-
-    List<JSONObject> queryRelAccounts(@Param(value = "signature") String signature);
-
-    List<JSONObject> queryRelProject(@Param(value = "signature") String signature);
-
-    void replaceBatch(@Param(value = "list") List<KuaishouCrowdPack> list);
-
-    Integer queryProjectCount(@Param(value = "signature") String signature);
-
-    KuaishouCrowdPack queryByAccountId(@Param(value = "accountId") Long accountId, @Param(value = "orientationId") Long orientationId);
-
-    Integer queryAccountCount(@Param(value = "signature") String signature);
-
-    void update(JSONObject obj);
-}

+ 28 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouDirectionalPackageMapper.java

@@ -0,0 +1,28 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 自动投放-定向包详情
+ *
+ * @author: jeecg-boot
+ * @date: 2021-04-20
+ * @cersion: V1.0
+ */
+public interface KuaishouDirectionalPackageMapper extends BaseMapper<KuaishouDirectionalPackage> {
+
+    KuaishouDirectionalPackage queryEntity(JSONObject requestJson);
+
+    List<JSONObject> queryList(KuaishouDirectionalPackage directionalPackage);
+
+    Long queryListTotal(KuaishouDirectionalPackage directionalPackage);
+
+    List<JSONObject> getRelatedAccount(@Param("id") String id);
+
+    List getRelatedGroup(@Param("id") String id, @Param("accountId") Long accountId);
+}

+ 29 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouDirectionalPckageRelMapper.java

@@ -0,0 +1,29 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalaPckageRel;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 自动投放-定向包详情关系表
+ *
+ * @author: jeecg-boot
+ * @date: 2021-04-25
+ * @cersion: V1.0
+ */
+public interface KuaishouDirectionalPckageRelMapper extends BaseMapper<KuaishouDirectionalaPckageRel> {
+
+    void replace(KuaishouDirectionalaPckageRel rel);
+
+    List<JSONObject> queryPushResults(@Param("id") String id, @Param("accountIds") JSONArray accountIds,@Param("status") String status);
+
+    List<JSONObject> getAccountByProjectId(@Param("projectId") Long projectId, @Param("id") String id);
+
+    List<JSONObject> queryRelId(@Param("projectId") Long projectId, @Param("id") String id, @Param("type") String type);
+
+    List<JSONObject> queryUnitIdByAccountId(@Param("id") String id,@Param("accountId")  Long accountId);
+}

+ 29 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouLandpagePackageMapper.java

@@ -0,0 +1,29 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackage;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 落地页账户项目关联表
+ *
+ * @author: jeecg-boot
+ * @date: 2021-05-11
+ * @cersion: V1.0
+ */
+public interface KuaishouLandpagePackageMapper extends BaseMapper<KuaishouLandpagePackage> {
+
+    void replaceBatch(@Param("landpagePackageList") List<KuaishouLandpagePackage> landpagePackageList);
+
+    void deleteByAccountId(@Param("accountId") Long accountId);
+
+    List<JSONObject> queryPageList(@Param("accountId") Long accountId,@Param("projectId") Long projectId);
+
+    List<JSONObject> getRelatedAccounts(@Param("siteId") Long siteId);
+
+    List<JSONObject> getRelatedGroups(@Param("siteId") Long siteId, @Param("accountId") Long accountId);
+
+}

+ 20 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouLandpagePackageRelMapper.java

@@ -0,0 +1,20 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import java.util.List;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackageRel;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 落地页-广告组关联表
+ * @author: jeecg-boot
+ * @date:   2021-05-11
+ * @cersion: V1.0
+ */
+public interface KuaishouLandpagePackageRelMapper extends BaseMapper<KuaishouLandpagePackageRel> {
+
+    JSONObject queryByUnitId(@Param("siteId") Long siteId,@Param("unitId") Long unitId,@Param("accountId") Long accountId);
+
+}

+ 22 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationGroupMapper.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationGroup;
+import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 人群包-广告组关联表
+ *
+ * @author jeecg-boot
+ * 2021-05-08
+ * @version V1.0
+ */
+public interface KuaishouPopulationGroupMapper extends BaseMapper<KuaishouPopulationGroup> {
+
+    void deleteByUnitId(@Param("unitId") Long unitId);
+
+    void replaceBatch(@Param(value = "list") List<KuaishouPopulationGroup> list);
+}

+ 30 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationPackageMapper.java

@@ -0,0 +1,30 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackage;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 项目绑定的人群包模板
+ *
+ * @author jeecg-boot
+ * 2021-05-06
+ * @version V1.0
+ */
+public interface KuaishouPopulationPackageMapper extends BaseMapper<KuaishouPopulationPackage> {
+
+    Long queryPageListTotal(@Param("projectId") Long projectId, @Param("orientationName") String orientationName);
+
+    List<JSONObject> queryPageList(@Param("projectId") Long projectId, @Param("orientationName") String orientationName);
+
+    Long queryUnitCount(@Param("id") Long id);
+
+    List<JSONObject> getRelatedGroups(@Param("id") Long id, @Param("accountId") Long accountId);
+
+    List<JSONObject> queryListByStatus();
+
+    KuaishouPopulationPackage checkPopulationPackage(@Param("signature") String signature);
+}

+ 40 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouPopulationPackageRelMapper.java

@@ -0,0 +1,40 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 人群包模板和账户绑定关系表
+ *
+ * @author jeecg-boot
+ * 2021-05-07
+ * @version V1.0
+ */
+public interface KuaishouPopulationPackageRelMapper extends BaseMapper<KuaishouPopulationPackageRel> {
+
+    /**
+     * 查询账户同一主题下可推送的该人群包ID
+     */
+    KuaishouPopulationPackageRel queryPushableCrowdPackage(@Param("accountId") Long accountId, @Param("id") Long id);
+
+    KuaishouPopulationPackageRel queryByAccountId(@Param("accountId") Long accountId, @Param("orientationId") Long orientationId);
+
+    void replaceBatch(@Param("packageRels") List<KuaishouPopulationPackageRel> packageRels);
+
+    List<JSONObject> queryPushResults(@Param("id") Long id, @Param("accountIds") JSONArray accountIds);
+
+    List<JSONObject> getRelatedAccounts(@Param("id") Long id);
+
+    KuaishouPopulationPackageRel queryEntity(@Param("accountId") Long accountId, @Param("id") Long id);
+
+    List<JSONObject> getAccountByProjectId(@Param("projectId") Long projectId, @Param("id") String id);
+
+    void updateStatus(@Param("rel") KuaishouPopulationPackageRel rel);
+
+    List<Long> queryByOrientationId(@Param("orientationId") Long orientationId, @Param("accountId") Long accountId);
+}

+ 36 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaiShouAppMultipleBidsMapper.xml

@@ -0,0 +1,36 @@
+<?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.kuaishou.modules.ai.mapper.KuaiShouAppMultipleBidsMapper">
+
+    <select id="getAppInfoList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.*, t2.app_name,t2.app_version,t2.platform
+        FROM
+        (
+        SELECT
+        *
+        FROM
+        ctop_ai_kuaishou_app_multiple_bids
+        WHERE
+        account_id = #{accountId}
+        <if test="appIds != null and appIds != '' ">
+            and app_id in
+            <foreach collection="appIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        ) t1
+        LEFT JOIN (
+        SELECT
+        app_id,
+        app_name,
+        app_version,
+        platform
+        FROM
+        ctop_kuaishou_app_list
+        WHERE
+        account_id =#{accountId}
+        ) t2 ON t1.app_id = t2.app_id
+    </select>
+</mapper>

+ 22 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppGroupMapper.xml

@@ -0,0 +1,22 @@
+<?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.kuaishou.modules.ai.mapper.KuaishouAppGroupMapper">
+
+    <insert id="replaceBatch">
+        replace
+        into ctop_kuaishou_app_group(
+        id,
+        account_id,
+        unit_id,
+        app_id
+        )
+        values
+            (
+        #{request.id},
+        #{request.accountId},
+        #{request.unitId},
+        #{request.appId}
+        )
+    </insert>
+
+</mapper>

+ 117 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppPackageMapper.xml

@@ -0,0 +1,117 @@
+<?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.kuaishou.modules.ai.mapper.KuaishouAppPackageMapper">
+
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_app_package(
+        id,
+        project_id,
+        app_md5,
+        url,
+        app_version,
+        app_name,
+        app_icon_url,
+        image_token,
+        package_name,
+        platform,
+        app_privacy_url,
+        use_sdk,
+        track_url,
+        data_status
+        )
+        values
+        <foreach collection="appList" item="app" separator=",">
+            (
+            #{app.id},
+            #{app.projectId},
+            #{app.appMd5},
+            #{app.url},
+            #{app.appVersion},
+            #{app.appName},
+            #{app.appIconUrl},
+            #{app.imageToken},
+            #{app.packageName},
+            #{app.platform},
+            #{app.appPrivacyUrl},
+            #{app.useSdk},
+            #{app.trackUrl},
+            #{app.dataStatus}
+            )
+        </foreach>
+    </insert>
+    <select id="queryAppVersions" resultType="java.lang.String">
+        SELECT app_version
+        FROM ctop_kuaishou_app_package
+        where project_id = #{projectId}
+    </select>
+
+    <select id="queryByAppVersion" resultType="java.lang.Long">
+        SELECT id
+        FROM ctop_kuaishou_app_package
+        where project_id = #{projectId}
+          and app_version = #{appVersion}
+    </select>
+
+    <select id="queryPageList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.id,
+        t1.project_id 'projectId',
+        t1.app_name 'appName',
+        t1.app_version 'appVersion',
+        t1.platform,
+        CASE t1.platform
+        WHEN 1 THEN 'Android应用下载'
+        WHEN 2 THEN 'Android网页游戏'
+        WHEN 3 THEN 'iOS应用下载'
+        WHEN 4 THEN 'iOS网页游戏'
+        END 'platformStr',
+        t1.package_name 'packageName',
+        DATE_FORMAT(t1.create_time,'%Y-%m-%d') 'createTime',
+        t2.project_name 'projectName',
+        (SELECT COUNT(1) FROM ctop_kuaishou_app_package_rel WHERE apptem_id = t1.id AND data_status = 1)'accountCount'
+        FROM ctop_kuaishou_app_package t1
+        LEFT JOIN ctop_project = t2 on t1.project_id =t2.id
+        WHERE t1.data_status =1
+        <if test="appVersion!=null">
+            AND t1.app_version Like concat('%',#{appVersion},'%')
+        </if>
+        <if test="projectId!=null">
+            AND t1.project_id=#{projectId}
+        </if>
+        <if test="platform!=null">
+            AND t1.platform=#{platform}
+        </if>
+        order by t1.create_time desc
+    </select>
+
+    <select id="queryUnitCount" resultType="java.lang.Long">
+        SELECT IFNULL(COUNT(1), 0)
+        FROM ctop_kuaishou_app_group
+        where app_id IN
+              (SELECT app_id
+               FROM ctop_kuaishou_app_package_rel
+               WHERE data_status = 1
+                 AND apptem_id = #{id}
+              )
+    </select>
+
+    <select id="getRelatedGroups" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t2.account_id as 'accountId',
+        t2.auth_name as 'authName',
+        t3.unit_name as 'unitName'
+        FROM ctop_kuaishou_app_group t1
+        INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        INNER JOIN ctop_kuaishou_group t3 ON t1.unit_id = t3.unit_id
+        where t1.app_id IN
+        (SELECT DISTINCT app_id
+        FROM ctop_kuaishou_app_package_rel
+        WHERE data_status = 1
+        AND apptem_id =#{id}
+        <if test="accountId !=null">
+            AND account_id = #{accountId}
+        </if>
+        )
+        order by t1.create_time desc
+    </select>
+
+</mapper>

+ 95 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppPackageRelMapper.xml

@@ -0,0 +1,95 @@
+<?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.kuaishou.modules.ai.mapper.KuaishouAppPackageRelMapper">
+
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_app_package_rel(
+        id,
+        apptem_id,
+        project_id,
+        account_id,
+        app_id,
+        app_version,
+        data_status,
+        return_url,
+        message,
+        return_update_time
+        )
+        values
+        <foreach collection="relList" item="rel" separator=",">
+            (
+            #{rel.id},
+            #{rel.apptemId},
+            #{rel.projectId},
+            #{rel.accountId},
+            #{rel.appId},
+            #{rel.appVersion},
+            #{rel.dataStatus},
+            #{rel.returnUrl},
+            #{rel.message},
+            #{rel.returnUpdateTime}
+            )
+        </foreach>
+    </insert>
+
+    <select id="queryEntityByAccountId" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackageRel">
+        SELECT apptem_id, app_id, project_id
+        FROM ctop_kuaishou_app_package_rel
+        where account_id = #{accountId}
+          and app_version = #{appVersion}
+          and data_status = 1
+    </select>
+
+    <select id="queryPushResults" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        apptem_id 'id',
+        IFNULL(t2.auth_name,'') as 'authName',
+        IFNULL(t2.account_id,'') as 'accountId',
+        IFNULL(t1.message,'-') as 'message',
+        CASE WHEN t1.data_status =1 THEN '推送成功' ELSE '推送失败' end as 'result'
+        FROM ctop_kuaishou_app_package_rel t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where apptem_id = #{id}
+        <if test=" status!=null">
+            AND  t1.data_status = #{status}
+        </if>
+        <if test="accountIds!=null">
+            AND t1.account_id IN
+            <foreach item="item" index="index" collection="accountIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        order by t1.create_time desc
+    </select>
+
+    <select id="getRelatedAccounts" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT apptem_id as 'id',
+               IFNULL(t2.auth_name, '') as 'authName',
+               IFNULL(t2.account_id, '') as 'accountId',
+               (SELECT COUNT(1)
+                FROM ctop_kuaishou_app_list
+                where account_id = t1.account_id) as 'appCount'
+        FROM ctop_kuaishou_app_package_rel t1
+                 LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where t1.apptem_id =#{id}
+          AND t1.data_status = 1
+        order by t1.create_time desc
+    </select>
+
+    <select id="getAccountByProjectId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            t1.account_id as 'accountId',
+            CONCAT(t1.auth_name,'(',t1.account_id,')') as 'authName',
+            IFNULL(t2.data_status,0) as 'state'
+        FROM ctop_user_allocation t1
+                 LEFT JOIN (
+            SELECT account_id,data_status FROM ctop_kuaishou_app_package_rel
+            WHERE  project_id = #{projectId}
+              AND apptem_id = #{id}
+        ) t2 ON t1.account_id = t2.account_id
+        where t1.account_status = 0
+          AND t1.project_id = #{projectId}
+    </select>
+
+</mapper>

+ 0 - 344
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouCrowdPackMapper.xml

@@ -1,344 +0,0 @@
-<?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.kuaishou.modules.ai.mapper.KuaishouCrowdPackMapper">
-
-    <select id="getTotal" resultType="java.lang.Long">
-        SELECT  IFNULL(COUNT(1),0) FROM(
-        SELECT 1
-        FROM ctop_kuaishou_crowd_package t1
-        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        WHERE t1.`status` is not null
-        AND t1.`status`!=2
-        and t1.data_status = 1
-        AND t1.signature is not null
-        <if test="orientationName !=null">
-            AND orientation_name LIKE CONCAT('%',#{orientationName},'%')
-        </if>
-        <if test="accountId !=null">
-            AND t2.account_id = #{accountId}
-        </if>
-        <if test="status !=null">
-            AND t1.`status` =#{status}
-        </if>
-        GROUP BY t1.signature
-        ) t
-    </select>
-
-    <select id="queryPageList" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT t1.id,
-        t1.account_id as 'accountId',
-        t2.auth_name as 'accountName',
-        IFNULL(stat_date,'') as 'statDate',
-        IFNULL(t1.orientation_id,'') as 'orientationId',
-        IFNULL(orientation_name,'') as 'orientationName',
-        IFNULL(url,'') as 'url',
-        IFNULL(population_type,'') as 'populationType',
-        IFNULL(t1.type,'') as 'type',
-        CASE t1.type
-        WHEN 1 THEN 'IMEI'
-        WHEN 2 THEN 'IDFA'
-        WHEN 3 THEN 'IMEI_MD5'
-        WHEN 4 THEN 'IDFA_MD5'
-        WHEN 5 THEN '手机号-MD5'
-        WHEN 7 THEN 'OAID'
-        WHEN 8 THEN 'OAID_MD5'
-        ELSE ''
-        END as 'typeStr',
-        <if test="status ==null">
-            t4.statusStr,
-            t4.`status`,
-        </if>
-        <if test="status !=null">
-            t1.`status`,
-            CASE t1.`status`
-            WHEN 0 THEN '计算中'
-            WHEN 1 THEN '已生效'
-            WHEN 3 THEN '推送中'
-            WHEN 4 THEN '已推送'
-            WHEN 5 THEN '计算失败'
-            WHEN 6 THEN '推送失败'
-            WHEN 7 THEN '已失效'
-            ELSE ''
-            END as 'statusStr',
-        </if>
-        IFNULL(t1.signature,'') as 'signature',
-        IFNULL(cover_num,0) as 'coverNum'
-        FROM ctop_kuaishou_crowd_package t1
-        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        LEFT JOIN (
-        SELECT t.signature ,COUNT(1) as 'num' FROM (SELECT DISTINCT signature, t2.project_id FROM
-        ctop_kuaishou_crowd_package t1
-        INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        where orientation_id is not null
-        GROUP BY project_id) t
-        ) t3 ON t1.signature = t3.signature
-        left join
-        (
-        SELECT signature,
-        CASE maxlevel
-        WHEN 66 THEN '计算中'
-        WHEN 77 THEN '已生效'
-        WHEN 88 THEN '推送中'
-        WHEN 99 THEN '已推送'
-        WHEN 33 THEN '计算失败'
-        WHEN 44 THEN '推送失败'
-        WHEN 55 THEN '已失效'
-        ELSE ''
-        END as 'statusStr',
-        CASE maxlevel
-        WHEN 66 THEN 0
-        WHEN 77 THEN 1
-        WHEN 88 THEN 3
-        WHEN 99 THEN 4
-        WHEN 33 THEN 5
-        WHEN 44 THEN 6
-        WHEN 55 THEN 7
-        ELSE -1
-        END as 'status'
-        FROM (
-        SELECT signature,max(level) as 'maxlevel' FROM (
-        SELECT signature,
-        CASE t1.`status`
-        WHEN 0 THEN 66
-        WHEN 1 THEN 77
-        WHEN 3 THEN 88
-        WHEN 4 THEN 99
-        WHEN 5 THEN 33
-        WHEN 6 THEN 44
-        WHEN 7 THEN 55
-        ELSE ''
-        END as 'level'
-        FROM ctop_kuaishou_crowd_package t1
-        where signature IN(
-        SELECT signature
-        FROM ctop_kuaishou_crowd_package t1
-        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        WHERE t1.`status` is not null
-        AND t1.`status`!=2
-        and t1.data_status = 1
-        AND t1.signature is not null
-        <if test="orientationName !=null">
-            AND orientation_name LIKE CONCAT('%',#{orientationName},'%')
-        </if>
-        <if test="accountId !=null">
-            AND t2.account_id =#{accountId}
-        </if>
-        GROUP BY t1.signature
-        )
-        GROUP BY t1.signature,`status`
-        )t1
-        GROUP BY signature
-        ) t2
-        ) t4 ON t1.signature = t4.signature
-        WHERE t1.`status` is not null
-        AND t1.`status`!=2
-        and t1.data_status = 1
-        AND t1.signature is not null
-        <if test="orientationName !=null">
-            AND orientation_name LIKE CONCAT('%',#{orientationName},'%')
-        </if>
-        <if test="accountId !=null">
-            AND t2.account_id =#{accountId}
-        </if>
-        <if test="status !=null">
-            AND t1.`status` =#{status}
-        </if>
-        GROUP BY t1.signature
-        order by t1.update_time desc
-    </select>
-
-    <select id="queryListByStatus" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack">
-        SELECT account_id
-        FROM ctop_kuaishou_crowd_package
-        WHERE `status` !=2
-        GROUP BY account_id
-    </select>
-
-    <select id="queryFailReason" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT DISTINCT IFNULL(t3.project_name, null) as 'projectName', IFNULL(t2.auth_name, null)as 'accountName', IFNULL(t1.message, null) as 'message'
-        FROM ctop_kuaishou_crowd_package t1
-                 INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-                 INNER JOIN ctop_project t3 ON t2.project_id = t3.id
-        WHERE t1.signature = #{signature}
-          AND t1.data_status = 0
-    </select>
-
-    <select id="queryRelAccounts" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT IFNULL(t1.project_name, '') AS 'projectName' ,
-               IFNULL(t1.auth_name, '') AS 'accountName',
-               t2.count,
-               t1.`status`,
-               CASE t1.`status`
-                   WHEN 0 THEN '计算中'
-                   WHEN 1 THEN '已生效'
-                   WHEN 2 THEN '已删除'
-                   WHEN 3 THEN '推送中'
-                   WHEN 4 THEN '已推送'
-                   WHEN 5 THEN '计算失败'
-                   WHEN 6 THEN '推送失败'
-                   WHEN 7 THEN '已失效'
-                   ELSE ''
-                   END as 'statusStr'
-        FROM (
-                 SELECT t2.auth_name, t2.account_id, t3.project_name, t1.status
-                 FROM ctop_kuaishou_crowd_package t1
-                          INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-                          INNER JOIN ctop_project t3 ON t3.id = t2.project_id
-                 where signature = #{signature}
-                   and data_status = 1
-                   AND `status` !=2
-                 GROUP BY t1.account_id
-             ) t1
-                 LEFT JOIN(
-            SELECT t.account_id, COUNT(1) as 'count'
-            FROM (
-                     SELECT t1.account_id, signature
-                     FROM ctop_kuaishou_crowd_package t1
-                              INNER JOIN (
-                         SELECT t1.account_id
-                         FROM ctop_kuaishou_crowd_package t1
-                                  INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-                         where signature = #{signature}
-                           and data_status = 1
-                           AND `status` !=2
-                         GROUP BY account_id
-                     ) t2 ON t1.account_id = t2.account_id
-                     where signature is not NULL
-                       AND data_status = 1
-                       AND `status` != 2
-                     GROUP BY signature, t1.account_id
-                 ) t
-            GROUP BY t.account_id
-        ) t2 ON t1.account_id = t2.account_id
-    </select>
-
-    <select id="queryRelProject" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT IFNULL(CONCAT(tt3.project_name, '(', tt.project_id, ')'), '') as 'projectName' ,
-               tt.accountCount,
-               tt2.count
-        FROM (
-                 SELECT t.project_id, COUNT(1) as  'accountCount'
-                 FROM (
-                          SELECT t1.project_id, t1.account_id
-                          FROM ctop_user_allocation t1
-                                   INNER JOIN(
-                              SELECT t1.account_id
-                              FROM ctop_kuaishou_crowd_package t1
-                                       INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-                              where signature = #{signature}
-                                AND data_status = 1
-                                AND `status` !=2
-                              GROUP BY t1.account_id
-                          ) t2 ON t2.account_id = t1.account_id
-                      ) t
-                 GROUP BY t.project_id
-             ) tt
-                 LEFT JOIN
-             (
-                 SELECT t.project_id, t.account_id, COUNT(1) as 'count'
-                 FROM (
-                          SELECT t3.project_id, t1.account_id, signature
-                          FROM ctop_kuaishou_crowd_package t1
-                                   INNER JOIN (
-                              SELECT t1.account_id
-                              FROM ctop_kuaishou_crowd_package t1
-                                       INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-                              where signature = #{signature}
-                                AND data_status = 1
-                                AND `status` !=2
-                              GROUP BY t1.account_id
-                          ) t2 ON t1.account_id = t2.account_id
-                                   INNER JOIN ctop_user_allocation t3 ON t3.account_id = t2.account_id
-                          where signature is not NULL
-                            AND data_status = 1
-                            AND `status` != 2
-                          GROUP BY signature, t1.account_id, t3.project_id
-                      ) t
-                 GROUP BY t.account_id, t.project_id
-             ) tt2 ON tt2.project_id = tt.project_id
-                 LEFT JOIN ctop_project tt3 ON tt2.project_id = tt3.id
-        GROUP BY tt.project_id
-    </select>
-
-    <select id="queryProjectCount" resultType="java.lang.Integer">
-        SELECT IFNULL(COUNT(1),0)
-        FROM (SELECT t2.project_id
-              FROM ctop_kuaishou_crowd_package t1
-                       INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-              where orientation_id is not null
-                AND signature = #{signature}
-                AND data_status = 1
-                AND `status` !=2
-              GROUP BY project_id) t
-    </select>
-    <select id="queryAccountCount" resultType="java.lang.Integer">
-        SELECT IFNULL(COUNT(1),0)
-        FROM (
-                 SELECT account_id
-                 FROM ctop_kuaishou_crowd_package
-                 WHERE signature = #{signature}
-                   AND `status` !=2
-                 AND data_status = 1
-                 GROUP BY account_id) t
-    </select>
-
-    <select id="queryByAccountId" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack">
-        SELECT *
-        FROM ctop_kuaishou_crowd_package
-        where data_status = 1
-        AND `status` !=2
-        <if test="accountId!=null">
-            AND account_id = #{accountId}
-        </if>
-        <if test="orientationId!=null">
-            AND orientation_id = #{orientationId}
-        </if>
-        limit 1
-    </select>
-
-    <update id="update">
-        update ctop_kuaishou_crowd_package
-        set status = #{status}
-        where account_id = #{account_id}
-        and orientation_id = #{orientation_id}
-    </update>
-
-    <insert id="replaceBatch">
-        replace into ctop_kuaishou_crowd_package(
-        account_id,
-        stat_date,
-        orientation_id,
-        orientation_name,
-        url,
-        population_type,
-        data_status,
-        type,
-        status,
-        signature,
-        cover_num,
-        record_size,
-        match_size,
-        message
-        )
-        values
-        <foreach collection="list" item="li" separator=",">
-            (
-            #{li.accountId},
-            #{li.statDate},
-            #{li.orientationId},
-            #{li.orientationName},
-            #{li.url},
-            #{li.populationType},
-            #{li.dataStatus},
-            #{li.type},
-            #{li.status},
-            #{li.signature},
-            #{li.coverNum},
-            #{li.recordSize},
-            #{li.matchSize},
-            #{li.message}
-            )
-        </foreach>
-    </insert>
-
-</mapper>

+ 97 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouDirectionalPackageMapper.xml

@@ -0,0 +1,97 @@
+<?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.kuaishou.modules.ai.mapper.KuaishouDirectionalPackageMapper">
+
+    <select id="queryEntity" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage">
+        SELECT project_id,template_name from ctop_kuaishou_directional_package
+        WHERE data_status = 1
+        <if test="projectId != null">
+            and project_id = #{projectId}
+        </if>
+        <if test="templateName != null">
+            and template_name = #{templateName}
+        </if>
+        limit 1
+    </select>
+    <select id="queryList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.id,
+        t1.template_name 'templateName',
+        t2.project_name 'projectName',
+        t1.project_id 'projectId',
+        CASE WHEN t1.platform_os =1 THEN 'Android' WHEN t1.platform_os =2 THEN 'IOS' ELSE '不限' END 'platformOs',
+        t1.update_time 'updateTime',
+        IFNULL(t4.count,0) as 'accountCount',
+        IFNULL(t5.count,0) as 'unitCount'
+        FROM ctop_kuaishou_directional_package t1
+        LEFT JOIN ctop_project t2 ON t2.id = t1.project_id
+        LEFT JOIN (
+        SELECT dir_id,COUNT(1) 'count' FROM
+        ctop_kuaishou_directional_package_rel
+        WHERE rel_type = 'account'
+        AND data_status=1
+        GROUP BY dir_id
+        ) t4 ON t4.dir_id = t1.id
+        LEFT JOIN (
+        SELECT dir_id,COUNT(1) 'count' FROM
+        ctop_kuaishou_directional_package_rel t
+        INNER JOIN ctop_kuaishou_group tt ON t.rel_id = tt.unit_id
+        WHERE t.rel_type = 'unit'
+        AND t.data_status=1
+        GROUP BY dir_id
+        ) t5 ON t5.dir_id = t1.id
+        where t1.data_status = 1
+        <if test="templateName !=null">
+            AND t1.template_name like concat('%',#{templateName},'%')
+        </if>
+        <if test="platformOs !=null">
+            AND t1.platform_os = #{platformOs}
+        </if>
+        <if test="projectId !=null">
+            AND t1.project_id = #{projectId}
+        </if>
+        order by t1.update_time desc
+    </select>
+    <select id="queryListTotal" resultType="java.lang.Long">
+        SELECT
+        IFNULL(count(1),0)
+        FROM ctop_kuaishou_directional_package t1
+        where t1.data_status = 1
+        <if test="templateName !=null">
+            AND t1.template_name like concat('%',#{templateName},'%')
+        </if>
+        <if test="platformOs !=null">
+            AND t1.platform_os = #{platformOs}
+        </if>
+        <if test="projectId !=null">
+            AND t1.project_id = #{projectId}
+        </if>
+    </select>
+
+
+    <select id="getRelatedAccount" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t1.dir_id as 'id', IFNULL(t2.auth_name, '') as 'authName', IFNULL(t2.account_id, '') as 'accountId', IFNULL(t1.template_id, '') as 'templateId', IFNULL(t1.template_name, '') as 'templateName'
+        FROM ctop_kuaishou_directional_package_rel t1
+                 INNER JOIN ctop_user_allocation t2 ON t1.rel_id = t2.account_id
+        WHERE t1.data_status = 1
+          AND t1.dir_id = #{id}
+    </select>
+
+    <select id="getRelatedGroup" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t2.dir_id as 'id',
+        IFNULL(t3.auth_name,'') as 'authName',
+        IFNULL(t1.account_id,'') as 'accountId',
+        IFNULL(t2.template_id,'') as 'templateId',
+        t1.unit_name as 'unitName'
+        FROM ctop_kuaishou_directional_package_rel t2
+        INNER JOIN ( SELECT account_id,unit_id,unit_name FROM ctop_kuaishou_group
+        where 1=1
+        <if test="accountId!=null">
+           and account_id = #{accountId}
+        </if>
+        ) t1 ON t1.unit_id = t2.rel_id
+        LEFT JOIN ctop_user_allocation t3 ON t1.account_id = t3.account_id
+        WHERE t2.rel_type = 'unit' AND t2.dir_id =#{id}
+    </select>
+</mapper>

+ 94 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouDirectionalPckageRelMapper.xml

@@ -0,0 +1,94 @@
+<?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.kuaishou.modules.ai.mapper.KuaishouDirectionalPckageRelMapper">
+
+    <insert id="replace">
+        replace
+        into ctop_kuaishou_directional_package_rel(
+        id ,
+        dir_id ,
+        project_id ,
+        template_id ,
+        template_name ,
+        data_status,
+        rel_id ,
+        rel_type ,
+        exclude_population ,
+        paid_audience ,
+        population ,
+        message
+        )
+        values
+            (
+        #{id} ,
+        #{dirId} ,
+        #{projectId} ,
+        #{templateId} ,
+        #{templateName} ,
+        #{dataStatus} ,
+        #{relId} ,
+        #{relType} ,
+        #{excludePopulation} ,
+        #{paidAudience} ,
+        #{population} ,
+        #{message}
+        )
+
+    </insert>
+
+    <select id="queryPushResults" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        dir_id 'id',
+        IFNULL(t2.auth_name,'') as 'authName',
+        IFNULL(t2.account_id,'') as 'accountId',
+        IFNULL(t1.template_id,'') as 'templateId',
+        IFNULL(t1.message,'-') as 'message',
+        CASE WHEN t1.data_status =1 THEN '推送成功' ELSE '推送失败' end as 'result'
+        FROM ctop_kuaishou_directional_package_rel t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.rel_id = t2.account_id
+        where dir_id = #{id}
+        AND rel_type = 'account'
+        <if test=" status!=null">
+        AND  t1.data_status = #{status}
+        </if>
+        <if test="accountIds!=null">
+            AND rel_id IN
+            <foreach item="item" index="index" collection="accountIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getAccountByProjectId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            t1.account_id as 'accountId',
+            CONCAT(t1.auth_name,'(',t1.account_id,')') as 'authName',
+            IFNULL(t2.data_status,0) as 'state'
+            FROM ctop_user_allocation t1
+                LEFT JOIN (
+                SELECT rel_id,data_status FROM ctop_kuaishou_directional_package_rel
+                WHERE  project_id = #{projectId}
+                  AND rel_type = 'account'
+                  AND dir_id = #{id}
+            ) t2 ON t1.account_id = t2.rel_id
+        where t1.account_status = 0
+          AND t1.project_id = #{projectId}
+    </select>
+
+    <select id="queryRelId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT rel_id,template_id FROM ctop_kuaishou_directional_package_rel
+        WHERE  project_id = #{projectId}
+          AND rel_type = #{type}
+          AND dir_id = #{id}
+    </select>
+
+    <select id="queryUnitIdByAccountId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT rel_id,template_id FROM(
+       SELECT DISTINCT unit_id FROM ctop_kuaishou_group
+       where account_id = #{accountId} ) t1
+       INNER JOIN ctop_kuaishou_directional_package_rel t2 ON t1.unit_id = t2.rel_id
+        WHERE t2.rel_type = 'unit' AND t2.dir_id = #{id}
+    </select>
+
+</mapper>

+ 94 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouLandpagePackageMapper.xml

@@ -0,0 +1,94 @@
+<?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.kuaishou.modules.ai.mapper.KuaishouLandpagePackageMapper">
+
+
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_landpage_package(
+        id,
+        project_id,
+        account_id,
+        landpage_name,
+        site_id,
+        url,
+        biz_type,
+        app_id,
+        comps,
+        landpage_create_time,
+        landpage_update_time
+        )
+        values
+        <foreach collection="landpagePackageList" item="landpage" separator=",">
+            (
+            #{landpage.id},
+            #{landpage.projectId},
+            #{landpage.accountId},
+            #{landpage.landpageName},
+            #{landpage.siteId},
+            #{landpage.url},
+            #{landpage.bizType},
+            #{landpage.appId},
+            #{landpage.comps},
+            #{landpage.landpageCreateTime},
+            #{landpage.landpageUpdateTime}
+            )
+        </foreach>
+    </insert>
+
+    <delete id="deleteByAccountId">
+        delete
+        from ctop_kuaishou_landpage_package
+        where account_id = #{accountId}
+    </delete>
+
+    <select id="queryPageList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.project_id 'projectId',
+        t1.account_id 'accountId',
+        CONCAT(t1.site_id,'') 'siteId',
+        t1.landpage_name 'landpageName',
+        t2.project_name 'projectName',
+        t3.auth_name 'authName',
+        t1.landpage_update_time 'landpageUpdateTime',
+        (SELECT COUNT(1) FROM ctop_kuaishou_landpage_package WHERE site_id = t1.site_id) as 'accountCount',
+        (SELECT COUNT(1) FROM ctop_kuaishou_landpage_package_rel WHERE site_id = t1.site_id) as 'unitCount'
+        FROM ctop_kuaishou_landpage_package t1
+        LEFT JOIN ctop_project t2 ON t1.project_id = t2.id
+        LEFT JOIN ctop_user_allocation t3 ON t1.account_id = t3.account_id
+        WHERE 1=1
+        <if test="projectId!=null">
+            AND t1.project_id =#{projectId}
+        </if>
+        <if test="accountId!=null">
+            AND t1.account_id =#{accountId}
+        </if>
+        ORDER BY t1.landpage_update_time desc
+    </select>
+
+    <select id="getRelatedAccounts" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t2.auth_name 'authName', (SELECT COUNT(1)
+                                         FROM ctop_kuaishou_landpage_package
+                                         WHERE account_id = t1.account_id) 'count'
+        FROM ctop_kuaishou_landpage_package t1
+                 LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where t1.account_id IN (
+            SELECT DISTINCT account_id
+            FROM ctop_kuaishou_landpage_package
+            WHERE site_id = #{siteId}
+        )
+        GROUP BY t1.account_id
+        order by t1.create_time desc
+    </select>
+
+    <select id="getRelatedGroups" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t2.auth_name 'authName', t3.unit_name 'unitName'
+        FROM ctop_kuaishou_landpage_package_rel t1
+        INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        INNER JOIN ctop_kuaishou_group t3 ON t1.unit_id = t3.unit_id
+        where t1.site_id = #{siteId}
+        <if test="accountId!=null">
+            AND t1.account_id = #{accountId}
+        </if>
+        order by t1.create_time desc
+    </select>
+</mapper>

+ 12 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouLandpagePackageRelMapper.xml

@@ -0,0 +1,12 @@
+<?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.kuaishou.modules.ai.mapper.KuaishouLandpagePackageRelMapper">
+
+    <select id="queryByUnitId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT id,creative_arr
+        FROM ctop_kuaishou_landpage_package_rel
+        WHERE unit_id = #{unitId}
+          AND site_id = #{siteId}
+          AND account_id = #{accountId}
+    </select>
+</mapper>

+ 29 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationGroupMapper.xml

@@ -0,0 +1,29 @@
+<?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.kuaishou.modules.ai.mapper.KuaishouPopulationGroupMapper">
+
+    <delete id="deleteByUnitId">
+        DELETE
+        FROM ctop_kuaishou_population_group
+        WHERE unit_id = #{unitId}
+    </delete>
+
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_population_group(
+        id,
+        account_id,
+        unit_id,
+        orientation_id
+        )
+        values
+        <foreach collection="list" item="pop" separator=",">
+            (
+            #{pop.id},
+            #{pop.accountId},
+            #{pop.unitId},
+            #{pop.orientationId}
+            )
+        </foreach>
+    </insert>
+
+</mapper>

+ 96 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationPackageMapper.xml

@@ -0,0 +1,96 @@
+<?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.kuaishou.modules.ai.mapper.KuaishouPopulationPackageMapper">
+
+    <select id="queryPageListTotal" resultType="java.lang.Long">
+        SELECT IFNULL(COUNT(1), 0)
+        FROM ctop_kuaishou_population_package t1
+        WHERE data_status = 1
+        <if test="orientationName !=null">
+            AND orientation_name LIKE CONCAT('%', #{orientationName}, '%')
+        </if>
+        <if test="projectId !=null">
+            AND t1.project_id =#{projectId}
+        </if>
+    </select>
+
+    <select id="queryPageList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.orientation_name 'orientationName',
+        IFNULL(t1.type,'') as 'type',
+        CASE t1.type
+        WHEN 1 THEN 'IMEI'
+        WHEN 2 THEN 'IDFA'
+        WHEN 3 THEN 'IMEI_MD5'
+        WHEN 4 THEN 'IDFA_MD5'
+        WHEN 5 THEN '手机号-MD5'
+        WHEN 7 THEN 'OAID'
+        WHEN 8 THEN 'OAID_MD5'
+        ELSE ''
+        END as 'typeStr',
+        t1.id,
+        t1.stat_date 'statDate',
+        t2.project_name 'projectName',
+        t1.project_id 'projectId',
+        (SELECT COUNT(1) FROM ctop_kuaishou_population_package_rel
+        WHERE pop_id = t1.id
+        AND data_status = 1)as 'accountCount'
+        FROM
+        ctop_kuaishou_population_package t1
+        LEFT JOIN ctop_project t2 ON t1.project_id = t2.id
+        WHERE data_status = 1
+        <if test="orientationName !=null">
+            AND orientation_name LIKE CONCAT(CONCAT('%', #{orientationName}), '%')
+        </if>
+        <if test="projectId !=null">
+            AND t1.project_id =#{projectId}
+        </if>
+        order by t1.create_time desc
+    </select>
+
+    <select id="queryUnitCount" resultType="java.lang.Long">
+        SELECT IFNULL(COUNT(1), 0)
+        FROM ctop_kuaishou_population_group t1
+        INNER JOIN ctop_kuaishou_group t3 ON t1.unit_id = t3.unit_id
+        where orientation_id IN
+              (SELECT orientation_id
+               FROM ctop_kuaishou_population_package_rel
+               WHERE data_status = 1
+                 AND pop_id = #{id}
+              )
+    </select>
+
+    <select id="queryListByStatus" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT account_id,project_id
+        FROM ctop_kuaishou_population_package_rel
+        WHERE data_status =1
+        GROUP BY account_id
+    </select>
+
+    <select id="getRelatedGroups" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t2.account_id as 'accountId',
+        t2.auth_name as 'authName',
+        t3.unit_name as 'unitName'
+        FROM ctop_kuaishou_population_group t1
+        INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        INNER JOIN ctop_kuaishou_group t3 ON t1.unit_id = t3.unit_id
+        where orientation_id IN
+        (SELECT DISTINCT orientation_id
+        FROM ctop_kuaishou_population_package_rel
+        WHERE data_status = 1
+        AND pop_id = #{id}
+        <if test="accountId !=null">
+            AND account_id = #{accountId}
+        </if>
+        )
+        order by t1.create_time desc
+    </select>
+
+    <select id="checkPopulationPackage" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackage">
+        select orientation_name
+        from ctop_kuaishou_population_package
+        where signature = #{signature}
+        AND data_status = 1
+</select>
+
+</mapper>

+ 194 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouPopulationPackageRelMapper.xml

@@ -0,0 +1,194 @@
+<?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.kuaishou.modules.ai.mapper.KuaishouPopulationPackageRelMapper">
+
+    <select id="queryPushableCrowdPackage"
+            resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel">
+        SELECT t1.*
+        FROM ctop_kuaishou_population_package_rel t1
+        WHERE `status` = 4
+          AND pop_id = #{id}
+          AND orientation_id is not null
+          AND data_status = 1
+          AND account_id IN (
+            SELECT account_id
+            FROM ctop_kuaishou_advertiser_base_info
+            WHERE user_id = (SELECT user_id FROM ctop_kuaishou_advertiser_base_info WHERE account_id = #{accountId})
+        )
+            limit 1
+    </select>
+
+    <select id="queryByAccountId" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack">
+        SELECT *
+        FROM ctop_kuaishou_population_package_rel
+        where data_status = 1
+        <if test="accountId!=null">
+            AND account_id = #{accountId}
+        </if>
+        <if test="orientationId!=null">
+            AND orientation_id = #{orientationId}
+        </if>
+        limit 1
+    </select>
+
+    <select id="queryPushResults" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        pop_id as 'id',
+        IFNULL(t2.auth_name,'') as 'authName',
+        IFNULL(t2.account_id,'') as 'accountId',
+        IFNULL(t1.message,'-') as 'message',
+        CASE WHEN t1.data_status =1 THEN '推送成功' ELSE '推送失败' end as 'result'
+        FROM ctop_kuaishou_population_package_rel t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where t1.pop_id = #{id}
+        <if test="accountIds!=null">
+            AND t1.account_id IN
+            <foreach item="item" index="index" collection="accountIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getRelatedAccounts" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT pop_id as 'id',
+               IFNULL(t2.auth_name, '') as 'authName',
+               IFNULL(t2.account_id, '') as 'accountId',
+               t1.`status`,
+               CASE t1.`status`
+                   WHEN 0 THEN '计算中'
+                   WHEN 1 THEN '已生效'
+                   WHEN 3 THEN '推送中'
+                   WHEN 4 THEN '已推送'
+                   WHEN 5 THEN '计算失败'
+                   WHEN 6 THEN '推送失败'
+                   WHEN 7 THEN '已失效'
+                   ELSE ''
+                   END as 'statusStr',
+               cover_num 'coverNum',
+               (SELECT COUNT(1)
+                FROM ctop_kuaishou_population_package_rel t
+                where t.account_id = t1.account_id
+                  AND t.data_status = 1
+                  AND (t.`status` = 0 OR t.`status` = 1 or t.`status` = 3 or t.`status` = 4)) as 'populationCount'
+        FROM ctop_kuaishou_population_package_rel t1
+                 LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where t1.pop_id = #{id}
+          AND t1.data_status = 1
+    </select>
+
+    <select id="queryEntity" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel">
+        SELECT pop_id,
+               account_id,
+               orientation_id
+        FROM ctop_kuaishou_population_package_rel
+        WHERE pop_id = #{id}
+          AND data_status = 1
+          AND account_id = #{accountId}
+    </select>
+
+    <select id="queryByOrientationId" resultType="java.lang.Long">
+        SELECT orientation_id
+        FROM ctop_kuaishou_population_package_rel
+        WHERE data_status = 1
+        AND account_id = #{accountId}
+        <if test="orientationId!=null">
+            AND orientation_id = #{orientationId}
+        </if>
+    </select>
+
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_population_package_rel(
+        id,
+        pop_id,
+        project_id,
+        account_id,
+        stat_date,
+        orientation_id,
+        signature,
+        orientation_name,
+        population_type,
+        `type`,
+        status,
+        cover_num,
+        record_size,
+        match_size,
+        message,
+        data_status
+        )
+        values
+        <foreach collection="packageRels" item="package" separator=",">
+            (
+            #{package.id},
+            #{package.popId},
+            #{package.projectId},
+            #{package.accountId},
+            #{package.statDate},
+            #{package.orientationId},
+            #{package.signature},
+            #{package.orientationName},
+            #{package.populationType},
+            #{package.type},
+            #{package.status},
+            #{package.coverNum},
+            #{package.recordSize},
+            #{package.matchSize},
+            #{package.message},
+            #{package.dataStatus}
+            )
+        </foreach>
+    </insert>
+
+    <select id="getAccountByProjectId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t1.account_id as 'accountId', CONCAT(t1.auth_name, '(', t1.account_id, ')') as 'authName', CASE
+                                                                                                              WHEN
+                                                                                                                      t2.status = 0
+                                                                                                                      OR
+                                                                                                                      t2.status = 1
+                                                                                                                      OR
+                                                                                                                      t2.status = 3
+                                                                                                                      OR
+                                                                                                                      t2.status = 4
+                                                                                                                  THEN 1
+                                                                                                              ELSE 0 END
+            as 'state'
+        FROM ctop_user_allocation t1
+                 LEFT JOIN (
+            SELECT account_id, status
+            FROM ctop_kuaishou_population_package_rel
+            WHERE project_id = #{projectId}
+              AND pop_id = #{id}
+              AND data_status = 1
+        ) t2 ON t1.account_id = t2.account_id
+        where t1.account_status = 0
+          AND t1.project_id = #{projectId}
+    </select>
+
+    <update id="updateStatus">
+        update
+        ctop_kuaishou_population_package_rel
+        <set>
+            <if test="rel.status != null">
+                status = #{rel.status},
+            </if>
+            <if test="rel.coverNum != null">
+                cover_num = #{rel.coverNum},
+            </if>
+            <if test="rel.recordSize != null">
+                record_size = #{rel.recordSize},
+            </if>
+            <if test="rel.dataStatus != null">
+                data_status = #{rel.dataStatus},
+            </if>
+            <if test="rel.matchSize != null">
+                match_size = #{rel.matchSize},
+            </if>
+            <if test="rel.message != null">
+                message = #{rel.message},
+            </if>
+        </set>
+        where orientation_id = #{rel.orientationId}
+        and account_id = #{rel.accountId}
+    </update>
+
+</mapper>

+ 21 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaiShouAppMultipleBidsService.java

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouAppMultipleBids;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * 多应用分别出价
+ *
+ * @author jeecg-boot
+ * 2021-05-18
+ * @version V1.0
+ */
+public interface IKuaiShouAppMultipleBidsService extends IService<KuaiShouAppMultipleBids> {
+
+    List<JSONObject> getAppInfiList(Long accountId, String appIdArray);
+
+    KuaiShouAppMultipleBids getInfoByAccountAndAppId(Long accountId, Long appId);
+}

+ 14 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouAppGroupService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppGroup;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 应用-广告组关联表
+ * @Author: jeecg-boot
+ * @Date: 2021-05-14
+ * @Version: V1.0
+ */
+public interface IKuaishouAppGroupService extends IService<KuaishouAppGroup> {
+
+}

+ 14 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouAppPackageRelService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackageRel;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 应用和账户关联表
+ * @Author: jeecg-boot
+ * @Date:   2021-05-13
+ * @Version: V1.0
+ */
+public interface IKuaishouAppPackageRelService extends IService<KuaishouAppPackageRel> {
+
+}

+ 37 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouAppPackageService.java

@@ -0,0 +1,37 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackage;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+/**
+ * @Description: 项目绑定的应用
+ * @Author: jeecg-boot
+ * @Date: 2021-05-12
+ * @Version: V1.0
+ */
+public interface IKuaishouAppPackageService extends IService<KuaishouAppPackage> {
+
+    Result<Object> importExcel(MultipartFile file, Long projectId, Integer platform, String imageToken, String imageUrl) throws Exception;
+
+    Result<Object> pushAppPackage(Long id, JSONArray accountIds);
+
+    Result<Object> queryPushResults(String id, JSONArray accountIds, String status);
+
+    List<Long> queryByAppVersion(Long projectId,String appVersion);
+
+    void createAppAndGroupRel(JSONObject request);
+
+    Result<Object> queryPageList(KuaishouAppPackage kuaishouAppPackage, Integer pageNo, Integer pageSize);
+
+    Result<Object> getRelatedAccounts(Long id);
+
+    Result<Object> getRelatedGroups(Long id, Long accountId);
+
+    Result<Object> getAccountByProjectId(Long projectId, String id);
+}

+ 0 - 31
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouCrowdPackService.java

@@ -1,31 +0,0 @@
-package cn.com.ctop.kuaishou.modules.ai.service;
-
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.extension.service.IService;
-import org.jeecg.common.api.vo.Result;
-
-/**
- * @Description: 人群报表
- * @Author: jeecg-boot
- * @Date: 2021-03-26
- * @Version: V1.0
- */
-public interface IKuaishouCrowdPackService extends IService<KuaishouCrowdPack> {
-
-    Result<Object> queryPageList(KuaishouCrowdPack kuaishouCrowdPack, Integer pageNo, Integer pageSize);
-
-    Result<Object> uploadCrowdPack(Integer type, String orientationName, Long accountId, String url);
-
-    Result<Object> accountPush(JSONObject request);
-
-    void crowdListQuery();
-
-    Result<Object> queryRel(String type, String signature, Integer pageNo, Integer pageSize);
-
-    Result<Object> queryFailReason(String signature, Integer pageNo, Integer pageSize);
-
-    Result<Object> updateDataStatus(KuaishouCrowdPack kuaishouCrowdPack);
-
-    Result<Object> checkCrowdPackage(String signature);
-}

+ 48 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouDirectionalPackageService.java

@@ -0,0 +1,48 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 自动投放-定向包详情
+ * @Author: jeecg-boot
+ * @Date: 2021-04-20
+ * @Version: V1.0
+ */
+public interface IKuaishouDirectionalPackageService extends IService<KuaishouDirectionalPackage> {
+
+    Result<Object> createDirectionalPackage(JSONObject requestJson);
+
+    Result<Object> updateDirectionalPackage(JSONObject requestJson) throws InterruptedException;
+
+    Result<Object> queryList(KuaishouDirectionalPackage directionalPackage, Integer pageNo, Integer pageSize);
+
+    Result<Object> getRelatedAccountGroup(String id, Integer type,Long accountId, Integer pageNo, Integer pageSize);
+
+    Result<Object> pushDirectionalPackage(String id, JSONArray datas);
+
+    Result<Object> queryPushResults(String id, JSONArray accountIds,String status);
+
+    Result<Object> editPopulation(JSONObject requestJson);
+
+    Result<Object> getAccountByProjectId(Long projectId, String id);
+
+    /**
+     * 添加广告组和定向模板绑定关系
+     *
+     * @param unitId            广告组Id
+     * @param templateId        模板Id
+     * @param population        定向人群包
+     * @param paidAudience      付费人群包
+     * @param excludePopulation 排除人群包
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    void createUnitAndTemplate(JSONObject request) throws Exception;
+
+    Result<Object> queryPopulationById(Long templateId, Long accountId);
+}

+ 14 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouDirectionalPckageRelService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalaPckageRel;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 自动投放-定向包详情关系表
+ * @Author: jeecg-boot
+ * @Date:   2021-04-25
+ * @Version: V1.0
+ */
+public interface IKuaishouDirectionalPckageRelService extends IService<KuaishouDirectionalaPckageRel> {
+
+}

+ 14 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouLandpagePackageRelService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackageRel;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 落地页-广告组关联表
+ * @Author: jeecg-boot
+ * @Date:   2021-05-11
+ * @Version: V1.0
+ */
+public interface IKuaishouLandpagePackageRelService extends IService<KuaishouLandpagePackageRel> {
+
+}

+ 38 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouLandpagePackageService.java

@@ -0,0 +1,38 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+import java.util.List;
+
+/**
+ * @Description: 落地页账户项目关联表
+ * @Author: jeecg-boot
+ * @Date: 2021-05-11
+ * @Version: V1.0
+ */
+public interface IKuaishouLandpagePackageService extends IService<KuaishouLandpagePackage> {
+
+    Result<Object> queryPageList(KuaishouLandpagePackage kuaishouLandpagePackage, Integer pageNo, Integer pageSize);
+
+    Result<Object> synchronousData(Long projectId);
+
+    Result<Object> getRelatedAccounts(Long siteId);
+
+    Result<Object> getRelatedGroups(Long siteId, Long accountId);
+
+    /**
+     * 绑定落地页与广告组的关系
+     *
+     * @param siteId     落地页Id
+     * @param creativeId 创意ID
+     * @param unitId     广告组ID
+     * @param accountId  账户ID
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    void createLandPageAndUnit(Long siteId, Long creativeId, Long unitId, Long accountId);
+
+}

+ 28 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouPopulationGroupService.java

@@ -0,0 +1,28 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationGroup;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 人群包-广告组关联表
+ *
+ * @author jeecg-boot
+ * 2021-05-08
+ * @version V1.0
+ */
+public interface IKuaishouPopulationGroupService extends IService<KuaishouPopulationGroup> {
+
+    /* 添加广告组和人群包绑定关系
+     *
+     * @param unitId            广告组Id
+     * @param accountId         账户Id
+     * @param population        定向人群包
+     * @param paidAudience      付费人群包
+     * @param excludePopulation 排除人群包
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    void createPopulationAndGroupRel(JSONObject request) throws Exception;
+}

+ 15 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouPopulationPackageRelService.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 人群包模板和账户绑定关系表
+ *
+ * @author jeecg-boot
+ * 2021-05-07
+ * @version V1.0
+ */
+public interface IKuaishouPopulationPackageRelService extends IService<KuaishouPopulationPackageRel> {
+
+}

+ 37 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouPopulationPackageService.java

@@ -0,0 +1,37 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackage;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * 项目绑定的人群包模板
+ *
+ * @author jeecg-boot
+ * 2021-05-06
+ * @version V1.0
+ */
+public interface IKuaishouPopulationPackageService extends IService<KuaishouPopulationPackage> {
+
+    Result<Object> createEntity(KuaishouPopulationPackage kuaishouPopulationPackage);
+
+    Result<Object> push(JSONArray accountIds, Long id);
+
+    Result<Object> queryPageList(KuaishouPopulationPackage kuaishouPopulationPackage, Integer pageNo, Integer pageSize);
+
+    Result<Object> queryPushResults(Long id, JSONArray accountIds);
+
+    Result<Object> queryPushHistory(Long  id);
+
+    Result<Object> getRelatedAccounts(Long id);
+
+    Result<Object> getRelatedGroups(Long id,Long accountId);
+
+    void crowdListQuery();
+
+    Result<Object> getAccountByProjectId(Long projectId, String id);
+
+    Result<Object> checkPopulationPackage(String signature);
+}

+ 17 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/KuaishouAppPackageRelMapper.java

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import java.util.List;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackageRel;
+import org.apache.ibatis.annotations.Param;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 应用和账户关联表
+ * @author: jeecg-boot
+ * @date:   2021-05-13
+ * @cersion: V1.0
+ */
+public interface KuaishouAppPackageRelMapper extends BaseMapper<KuaishouAppPackageRel> {
+
+}

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

@@ -12,6 +12,7 @@ import cn.com.ctop.kuaishou.modules.ai.entity.*;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeAdsenceTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeAdsenceTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeMatTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeMatTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.service.*;
 import cn.com.ctop.kuaishou.modules.ai.service.*;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
@@ -21,10 +22,12 @@ import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.common.util.RedisUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.ParseException;
 import java.util.*;
 import java.util.*;
 
 
@@ -57,6 +60,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     private IAiKuaishouUnitLevelOperationRecordService unitLevelOperationRecordService;
     private IAiKuaishouUnitLevelOperationRecordService unitLevelOperationRecordService;
     @Autowired
     @Autowired
     private IAiKuaishouCreativeLevelOperationRecordService creativeLevelOperationRecordService;
     private IAiKuaishouCreativeLevelOperationRecordService creativeLevelOperationRecordService;
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
+    @Autowired
+    private IKuaiShouAppMultipleBidsService kuaiShouAppMultipleBidsService;
 
 
 
 
     /**
     /**
@@ -88,30 +95,92 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         Integer singleAppid = strategy.getSingleAppid();
         Integer singleAppid = strategy.getSingleAppid();
         if (null != singleAppid && singleAppid == 0) {
         if (null != singleAppid && singleAppid == 0) {
             //多应用
             //多应用
-            String appidString = strategy.getAppIdArray();
-            JSONArray appIdArray = JSONArray.parseArray(appidString);
-            if (null != appIdArray && !appIdArray.isEmpty()) {
+            JSONArray appIdArray = JSONArray.parseArray(strategy.getAppIdArray());
+            String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
+            if (strategy.getMultipleBids() == 0) { // 非多应用多出价
+                if (null != appIdArray && !appIdArray.isEmpty()) {
+                    for (int i = 0; i < appIdArray.size(); i++) {
+                        AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
+                        if (null == appInfo) {
+                            log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
+                            continue;
+                        }
+                        if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
+                            strategy.setClickTrackUrl(appInfo.getTrackUrl());
+                            strategy.setImpressionUrl(appInfo.getTrackUrl());
+                        }
+                        replaceString = appInfo.getAppVersion() + "-" + replaceString;
+                        //1:查询素材
+                        List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType, videoCnt);
+                        if (null == allVideos || allVideos.isEmpty()) {
+                            log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
+                            continue;
+                        }
+                        Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo.getAppId(), strategyUuid);
+                        for (KuaiShouVideoGet videoItem : allVideos) {
+                            KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
+                            if (null != overrunInfo) {
+                                log.info("该账户创意创建已超限=>accountId:{}", accountId);
+                                return 0L;
+                            }
+                            // 获取视频封面数据
+                            List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
+                            if ((null == cutFrameList || cutFrameList.isEmpty())) {
+                                log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
+                                continue;
+                            }
+                            //开始创建组+创意
+                            String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appInfo.getAppId());
+                            JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
+                            Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
+                            Integer unitCode = (Integer) unitCreateResult.get("code");
+                            String unitMessage = (String) unitCreateResult.get("message");
+                            AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
+                            BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
+                            unitLevelOperationRecord.setGroupName(unitName);
+                            unitLevelOperationRecord.setCreateTime(new Date());
+                            unitLevelOperationRecord.setStatus(unitCode);
+                            unitLevelOperationRecord.setCampaignId(newCampaignId);
+                            unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
+                            unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
+                            unitLevelOperationRecord.setMessage(unitMessage);
+                            unitLevelOperationRecord.setCampaignId(newCampaignId);
+                            unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
+                            if (unitCode != 0) {
+                                log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
+                                unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                                continue;
+                            }
+                            Long unitId = (Long) unitCreateResult.get("unitId");
+                            unitLevelOperationRecord.setUnitId(unitId);
+                            unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                            videoCnt--;
+                            JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
+                            createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, appInfo.getAppVersion());
+                            if (videoCnt <= 0) {
+                                return videoCnt;
+                            }
+                        }
+                    }
+                }
+            } else if (strategy.getMultipleBids() == 1) { //  多应用多出价
+                List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
+                if (Check.isNull(allVideos)) {
+                    return videoCnt;
+                }
                 for (int i = 0; i < appIdArray.size(); i++) {
                 for (int i = 0; i < appIdArray.size(); i++) {
-                    String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
-                    AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
-                    if (null == appInfo) {
-                        log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
+                    Long appId = appIdArray.getLong(i);
+                    if (Check.isNull(appId)) {
                         continue;
                         continue;
                     }
                     }
-
-                    if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
-                        strategy.setClickTrackUrl(appInfo.getTrackUrl());
-                        strategy.setImpressionUrl(appInfo.getTrackUrl());
-                    }
-                    replaceString = appInfo.getAppVersion() + "-" + replaceString;
-                    //1:查询素材
-                    List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType, videoCnt);
-                    if (null == allVideos || allVideos.isEmpty()) {
-                        log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
+                    KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
+                    if (Check.isNull(multipleBids)) {
                         continue;
                         continue;
                     }
                     }
-                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo, strategyUuid);
-                    int unitCnt = 0;
+                    if (!Check.isNull(multipleBids.getTrackUrl())) {
+                        strategy.setClickTrackUrl(multipleBids.getTrackUrl());
+                    }
+                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
                     for (KuaiShouVideoGet videoItem : allVideos) {
                     for (KuaiShouVideoGet videoItem : allVideos) {
                         KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
                         KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
                         if (null != overrunInfo) {
                         if (null != overrunInfo) {
@@ -124,16 +193,20 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
                             log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
                             continue;
                             continue;
                         }
                         }
-                        unitCnt++;
                         //开始创建组+创意
                         //开始创建组+创意
-                        String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-                        String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, timestamp, unitCnt, videoItem.getPhotoName());
-                        JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
+                        String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId);
+                        JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
+                        unitParams.remove("cpa_bid");
+                        unitParams.put("cpa_bid", multipleBids.getCpaBid());
+                        strategy.setCpaBid(multipleBids.getCpaBid() + "");
                         Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                         Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                         Integer unitCode = (Integer) unitCreateResult.get("code");
                         Integer unitCode = (Integer) unitCreateResult.get("code");
                         String unitMessage = (String) unitCreateResult.get("message");
                         String unitMessage = (String) unitCreateResult.get("message");
                         AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
                         AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
                         BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
                         BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
+                        unitLevelOperationRecord.setCampaignId(newCampaignId);
+                        unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
+                        unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
                         unitLevelOperationRecord.setGroupName(unitName);
                         unitLevelOperationRecord.setGroupName(unitName);
                         unitLevelOperationRecord.setCreateTime(new Date());
                         unitLevelOperationRecord.setCreateTime(new Date());
                         unitLevelOperationRecord.setStatus(unitCode);
                         unitLevelOperationRecord.setStatus(unitCode);
@@ -150,13 +223,15 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                         videoCnt--;
                         videoCnt--;
                         JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
                         JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
-                        createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, appInfo.getAppVersion());
+                        createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
                         if (videoCnt <= 0) {
                         if (videoCnt <= 0) {
                             return videoCnt;
                             return videoCnt;
                         }
                         }
                     }
                     }
                 }
                 }
+
             }
             }
+
         } else {
         } else {
             //单一应用
             //单一应用
             String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
             String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
@@ -165,13 +240,18 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
                 log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
                 return videoCnt;
                 return videoCnt;
             }
             }
-            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, null, strategyUuid);
+            Long appId = null;
+            if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
+                appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
+                if (Check.isNull(appId)) {
+                    return videoCnt;
+                }
+            }
+            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
             if (null == newCampaignId) {
             if (null == newCampaignId) {
                 return videoCnt;
                 return videoCnt;
             }
             }
-
             //3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
             //3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
-            int unitCnt = 0;
             for (KuaiShouVideoGet videoItem : newVideos) {
             for (KuaiShouVideoGet videoItem : newVideos) {
                 KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
                 KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
                 if (null != overrunInfo) {
                 if (null != overrunInfo) {
@@ -183,15 +263,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
                     log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
                     continue;
                     continue;
                 }
                 }
-                unitCnt++;
-                String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-                String unitName = getName(strategy.getGroupName(), strategy, createType, null, timestamp, unitCnt, videoItem.getPhotoName());
-
-                Long appId = null;
-                if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
-                    appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
-                }
-
+                String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId);
                 JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
                 JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
                 Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                 Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                 Integer unitCode = (Integer) unitCreateResult.get("code");
                 Integer unitCode = (Integer) unitCreateResult.get("code");
@@ -199,12 +271,9 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
                 AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
                 BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
                 BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
                 unitLevelOperationRecord.setGroupName(unitName);
                 unitLevelOperationRecord.setGroupName(unitName);
-                if (!Check.isNull(strategy.getCpaBid())) {
-                    unitLevelOperationRecord.setCpaBid(Integer.valueOf(strategy.getCpaBid() + ""));
-                }
-                if (!Check.isNull(strategy.getBid())) {
-                    unitLevelOperationRecord.setBid(Integer.valueOf(strategy.getBid() + ""));
-                }
+                unitLevelOperationRecord.setCampaignId(newCampaignId);
+                unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
+                unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
                 unitLevelOperationRecord.setCreateTime(new Date());
                 unitLevelOperationRecord.setCreateTime(new Date());
                 unitLevelOperationRecord.setStatus(unitCode);
                 unitLevelOperationRecord.setStatus(unitCode);
                 unitLevelOperationRecord.setMessage(unitMessage);
                 unitLevelOperationRecord.setMessage(unitMessage);
@@ -250,59 +319,130 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         //2:判定账户是否单一应用
         //2:判定账户是否单一应用
         Long timeStart = null;
         Long timeStart = null;
         Long timeEnd = null;
         Long timeEnd = null;
-
         Integer singleAppid = strategy.getSingleAppid();
         Integer singleAppid = strategy.getSingleAppid();
         if (null != singleAppid && singleAppid == 0) {
         if (null != singleAppid && singleAppid == 0) {
             timeStart = -7 * 60 * 24L;
             timeStart = -7 * 60 * 24L;
             timeEnd = -5L;
             timeEnd = -5L;
         } else {
         } else {
-            timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
-            timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
+            if (strategy.getMultipleBids() == 0) {
+                timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
+                timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
+            } else if (strategy.getMultipleBids() == 1) {
+                if (createType == 1) {
+                    timeStart = -1 * 60 * 24L;
+                    timeEnd = -5L;
+                } else {
+                    timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
+                    timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
+                }
+            }
         }
         }
-
         Long now = System.currentTimeMillis();
         Long now = System.currentTimeMillis();
         String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
         String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
         String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
         String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
-
-
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String key = token.getAccountId() + "_ProgramCreative" + "_" + nowDate;
+        JSONArray appIdArray = JSON.parseArray(strategy.getAppIdArray());
         if (null != singleAppid && singleAppid == 0) {
         if (null != singleAppid && singleAppid == 0) {
-            //多应用
-            String appidString = strategy.getAppIdArray();
-            JSONArray appIdArray = JSON.parseArray(appidString);
-            if (null != appIdArray && !appIdArray.isEmpty()) {
+            String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
+            if (strategy.getMultipleBids() == 0) { //  非多应用多出价
+                //多应用
+                if (null != appIdArray && !appIdArray.isEmpty()) {
+                    for (int i = 0; i < appIdArray.size(); i++) {
+                        AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
+                        if (null == appInfo) {
+                            log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
+                            continue;
+                        }
+                        //判定是否通用监测链接
+                        if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
+                            strategy.setClickTrackUrl(appInfo.getTrackUrl());
+                            strategy.setImpressionUrl(appInfo.getTrackUrl());
+                        }
+                        replaceString = appInfo.getAppVersion() + "-" + replaceString;
+                        //1:查询可用素材
+                        List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType, videoCnt);
+                        if (null == allVideos || allVideos.isEmpty()) {
+                            return;
+                        }
+                        //判定创意创建是否超限
+                        KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
+                        if (null != overrunInfo) {
+                            log.info("该账户创意创建已超限=>accountId:{}", accountId);
+                            return;
+                        }
+                        Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo.getAppId(), strategyUuid);
+
+                        //创建组+创意
+                        List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
+                        for (int j = 1; j < splitVideos.size() + 1; j++) {
+                            Object redisObj = redisUtil.get(key);
+                            if (!Check.isNull(redisObj)) {
+                                Integer value = (Integer) redisObj;
+                                if (value == 1) {
+                                    log.error("程序化创意创建超限,accountId:{}", strategy.getAccountId());
+                                    return;
+                                }
+                            }
+                            //创建组
+                            String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appInfo.getAppId());
+                            JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
+                            Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
+                            Integer unitCode = (Integer) unitCreateResult.get("code");
+                            String unitMessage = (String) unitCreateResult.get("message");
+                            AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
+                            BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
+                            unitLevelOperationRecord.setGroupName(unitName);
+                            unitLevelOperationRecord.setCreateTime(new Date());
+                            unitLevelOperationRecord.setStatus(unitCode);
+                            unitLevelOperationRecord.setMessage(unitMessage);
+                            unitLevelOperationRecord.setCampaignId(newCampaignId);
+                            unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
+                            if (unitCode != 0) {
+                                log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
+                                unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                                continue;
+                            }
+                            Long unitId = (Long) unitCreateResult.get("unitId");
+                            unitLevelOperationRecord.setUnitId(unitId);
+                            unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                            JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, appInfo.getAppVersion());
+                            createProgramCreative(token, creativeParams, strategy);
+                        }
+                    }
+                }
+            } else if (strategy.getMultipleBids() == 1) { // 多应用多出价
+                List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
+                if (Check.isNull(allVideos)) {
+                    return;
+                }
                 for (int i = 0; i < appIdArray.size(); i++) {
                 for (int i = 0; i < appIdArray.size(); i++) {
-                    AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
-                    if (null == appInfo) {
-                        log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
+                    Long appId = appIdArray.getLong(i);
+                    if (Check.isNull(appId)) {
                         continue;
                         continue;
                     }
                     }
-                    //判定是否通用监测链接
-                    if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
-                        strategy.setClickTrackUrl(appInfo.getTrackUrl());
-                        strategy.setImpressionUrl(appInfo.getTrackUrl());
+                    KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
+                    if (Check.isNull(multipleBids)) {
+                        continue;
                     }
                     }
-                    String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
-                    replaceString = appInfo.getAppVersion() + "-" + replaceString;
-                    //1:查询可用素材
-                    List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType, videoCnt);
-                    if (null == allVideos || allVideos.isEmpty()) {
-                        return;
+                    if (!Check.isNull(multipleBids.getTrackUrl())) {
+                        strategy.setClickTrackUrl(multipleBids.getTrackUrl());
                     }
                     }
-                    //判定创意创建是否超限
-                    KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
-                    if (null != overrunInfo) {
-                        log.info("该账户创意创建已超限=>accountId:{}", accountId);
-                        return;
-                    }
-                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo, strategyUuid);
-
-                    //创建组+创意
+                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
                     List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
                     List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
                     for (int j = 1; j < splitVideos.size() + 1; j++) {
                     for (int j = 1; j < splitVideos.size() + 1; j++) {
+                        Object redisObj = redisUtil.get(key);
+                        if (!Check.isNull(redisObj)) {
+                            Integer value = (Integer) redisObj;
+                            if (value == 1) {
+                                log.error("程序化创意创建超限,accountId:{}", strategy.getAccountId());
+                                return;
+                            }
+                        }
                         //创建组
                         //创建组
-                        String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-                        String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, timestamp, null, null);
-                        JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
+                        String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId);
+                        JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
+                        unitParams.put("cpa_bid", multipleBids.getCpaBid());
                         Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                         Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                         Integer unitCode = (Integer) unitCreateResult.get("code");
                         Integer unitCode = (Integer) unitCreateResult.get("code");
                         String unitMessage = (String) unitCreateResult.get("message");
                         String unitMessage = (String) unitCreateResult.get("message");
@@ -322,7 +462,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         Long unitId = (Long) unitCreateResult.get("unitId");
                         Long unitId = (Long) unitCreateResult.get("unitId");
                         unitLevelOperationRecord.setUnitId(unitId);
                         unitLevelOperationRecord.setUnitId(unitId);
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                        JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, appInfo.getAppVersion());
+                        JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null);
                         createProgramCreative(token, creativeParams, strategy);
                         createProgramCreative(token, creativeParams, strategy);
                     }
                     }
                 }
                 }
@@ -335,23 +475,33 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 return;
                 return;
             }
             }
 
 
-            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, null, strategyUuid);
+            Long appId = null;
+            String appIdString = strategy.getAppIdArray();
+            if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
+                if (!Check.isNull(appIdString) && !Check.isNull(JSON.parseArray(appIdString))) {
+                    appId = JSON.parseArray(appIdString).getLong(0);
+                    if (Check.isNull(appId)) {
+                        return;
+                    }
+                }
+            }
+            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
             if (null == newCampaignId) {
             if (null == newCampaignId) {
                 return;
                 return;
             }
             }
             //创意
             //创意
             List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
             List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
             for (int j = 1; j < splitVideos.size() + 1; j++) {
             for (int j = 1; j < splitVideos.size() + 1; j++) {
-                //创建组
-                String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-                String unitName = getName(strategy.getGroupName(), strategy, createType, null, timestamp, null, null);
-                String appIdString = strategy.getAppIdArray();
-                Long appId = null;
-                if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
-                    if (!Check.isNull(appIdString) && !Check.isNull(JSON.parseArray(appIdString))) {
-                        appId = JSON.parseArray(appIdString).getLong(0);
+                Object redisObj = redisUtil.get(key);
+                if (!Check.isNull(redisObj)) {
+                    Integer value = (Integer) redisObj;
+                    if (value == 1) {
+                        log.error("程序化创意创建超限,accountId:{}", strategy.getAccountId());
+                        return;
                     }
                     }
                 }
                 }
+                //创建组
+                String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId);
                 JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
                 JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
                 Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                 Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                 Integer unitCode = (Integer) unitCreateResult.get("code");
                 Integer unitCode = (Integer) unitCreateResult.get("code");
@@ -402,11 +552,9 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             remindCnt = this.autoCreateCreative(strategy, 3, remindCnt);
             remindCnt = this.autoCreateCreative(strategy, 3, remindCnt);
         }
         }
         if (remindCnt >= 1) {
         if (remindCnt >= 1) {
-            if (strategy.getHistoryTop() == 0) {
-                log.info("{}组创建不足,剩余需要创建个数{},使用高质量素材创建", strategy.getAccountId(), remindCnt);
-                //高质量素材
-                remindCnt = this.autoCreateCreative(strategy, 2, remindCnt);
-            }
+            log.info("{}组创建不足,剩余需要创建个数{},使用高质量素材创建", strategy.getAccountId(), remindCnt);
+            //高质量素材
+            remindCnt = this.autoCreateCreative(strategy, 2, remindCnt);
         }
         }
         if (remindCnt >= 1) {
         if (remindCnt >= 1) {
             //历史打捞素材
             //历史打捞素材
@@ -437,6 +585,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         }
     }
     }
 
 
+    @Autowired
+    private IKuaiShouUpdateService updateService;
 
 
     private void createProgramCreative(CtopOauthToken token, JSONObject creativeParams, AiKuaishouAdvertiserStrategy strategy) {
     private void createProgramCreative(CtopOauthToken token, JSONObject creativeParams, AiKuaishouAdvertiserStrategy strategy) {
         Map<String, String> headers = new HashMap<>();
         Map<String, String> headers = new HashMap<>();
@@ -451,12 +601,41 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             return;
             return;
         }
         }
         Integer code = resultJson.getInteger("code");
         Integer code = resultJson.getInteger("code");
+
+
         String message = resultJson.getString("message");
         String message = resultJson.getString("message");
-        if (null == code || code != 0) {
-            log.error("创建程序化创意失败,accountId:{},返回结果:{},入参:{}", token.getAccountId(), message, creativeParams);
-            return;
+
+        Long unitId = creativeParams.getLong("unit_id");
+        if (code == 0) {
+            createLandPageAndUnit(creativeParams, resultJson.getJSONObject("data"));
+
+            log.info("创建程序化创意成功,accountId:{},unit:{}", token.getAccountId(), unitId);
+
+        } else {
+            log.error("快手创建程序化创意失败,accountId:{},unitId:{},返回信息:{}", token.getAccountId(), unitId, message);
+            if (code == 400001 && "/rest/openapi/v2/creative/advanced/program/create调用已超日限,次日可恢复调用".equals(message)) {
+                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                String key = token.getAccountId() + "_ProgramCreative" + "_" + nowDate;
+                redisUtil.set(key, 1, 100000L);
+                updateService.updateUnitStatus(token.getAccessToken(), token.getAccountId(), unitId, 3, "e9ca23d68d884d4ebb19d07889727dae");
+            }
+
+
+        }
+
+    }
+
+    //绑定落地页与广告组、创意的关系
+    private void createLandPageAndUnit(JSONObject programJson, JSONObject data) {
+        if (!Check.isNull(data) && !Check.isNull(programJson.getLong("site_id"))) {
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    landpagePackageService.createLandPageAndUnit(programJson.getLong("site_id"), data.getLong("creative_id"), programJson.getLong("unit_id"), programJson.getLong("advertiser_id"));
+                }
+            };
+            thread.start();
         }
         }
-        log.info("创建程序化创意成功");
     }
     }
 
 
     private JSONObject programCreativeParams(CtopOauthToken token, Long unitId, List<KuaiShouVideoGet> list, AiKuaishouAdvertiserStrategy strategy, Integer creativeCnt, String appVersion) {
     private JSONObject programCreativeParams(CtopOauthToken token, Long unitId, List<KuaiShouVideoGet> list, AiKuaishouAdvertiserStrategy strategy, Integer creativeCnt, String appVersion) {
@@ -516,8 +695,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         if (!Check.isNull(strategy.getActionbarClickUrl())) {
         if (!Check.isNull(strategy.getActionbarClickUrl())) {
             programJson.put("actionbar_click_url", strategy.getActionbarClickUrl());
             programJson.put("actionbar_click_url", strategy.getActionbarClickUrl());
         }
         }
-        JSONArray captions = new JSONArray();
-        captions.add(strategy.getDescription());
+
+        JSONArray captions = getCaptions(strategy.getDescription());
         programJson.put("captions", captions);
         programJson.put("captions", captions);
         if (!Check.isNull(strategy.getCreativeCategory())) {
         if (!Check.isNull(strategy.getCreativeCategory())) {
             programJson.put("creative_category", strategy.getCreativeCategory());
             programJson.put("creative_category", strategy.getCreativeCategory());
@@ -526,6 +705,22 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         return programJson;
         return programJson;
     }
     }
 
 
+    private JSONArray getCaptions(String description) {
+        JSONArray jsonArray = JSONArray.parseArray(description);
+        if (jsonArray.size() <= 3) {
+            return jsonArray;
+        }
+        Collections.shuffle(jsonArray);
+        JSONArray captions = new JSONArray();
+        for (int i = 0; i < jsonArray.size(); i++) {
+            captions.add(jsonArray.getString(i));
+            if (captions.size() == 3) {
+                break;
+            }
+        }
+        return captions;
+    }
+
     private List<KuaiShouVideoGet> getNewVideoListByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo) {
     private List<KuaiShouVideoGet> getNewVideoListByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo) {
         if (null == appInfo) {
         if (null == appInfo) {
             if (Check.isNull(strategy.getMaterialKeyword())) { // 素材名称为空 不需要标注特殊素材
             if (Check.isNull(strategy.getMaterialKeyword())) { // 素材名称为空 不需要标注特殊素材
@@ -620,24 +815,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     }
     }
 
 
 
 
-    private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType, Integer createType, AiKuaiShouAppInfo appInfo, String uuid) {
-        //  JSONArray campaignList;
-        String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-        /*if ("ALL_CAMPAIGN".equals(checkType)) {
-            campaignList = kuaishouInterfaceService.getCampaignList(token, null, null, 1);
-        } else {
-            timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-            campaignList = kuaishouInterfaceService.getCampaignList(token, new Date(), new Date(), 1);
-        }*/
-
-       /* if (!Check.isNull(campaignList)){
-            for (int i = 0; i < campaignList.size(); i++) {
-                JSONObject jsonObject = campaignList.getJSONObject(i);
-                if (jsonObject.getString("campaign_name").contains(replaceString)) {
-                    return jsonObject.getLong("campaign_id");
-                }
-            }
-        }*/
+    private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType, Integer createType, Long appId, String uuid) {
         Long campaignId = null;
         Long campaignId = null;
         if ("ALL_CAMPAIGN".equals(checkType)) {
         if ("ALL_CAMPAIGN".equals(checkType)) {
             campaignId = campaignService.getCampaignIdByAccountAndName(strategy.getAccountId(), replaceString);
             campaignId = campaignService.getCampaignIdByAccountAndName(strategy.getAccountId(), replaceString);
@@ -652,7 +830,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         // 不存在“上新”计划,则创建一个计划
         // 不存在“上新”计划,则创建一个计划
         JSONObject campaignParams = new JSONObject();
         JSONObject campaignParams = new JSONObject();
         campaignParams.put("advertiser_id", token.getAccountId());
         campaignParams.put("advertiser_id", token.getAccountId());
-        String campaignName = getName(strategy.getCampaignName(), strategy, createType, appInfo, timestamp, null, null);
+        String campaignName = getName(strategy.getCampaignName(), strategy, createType, null, "plan", null, appId);
         campaignParams.put("campaign_name", campaignName);
         campaignParams.put("campaign_name", campaignName);
         campaignParams.put("type", strategy.getCampaignType());
         campaignParams.put("type", strategy.getCampaignType());
         if (null != strategy.getCampaignDayBudget() && strategy.getCampaignDayBudget() != 0) {
         if (null != strategy.getCampaignDayBudget() && strategy.getCampaignDayBudget() != 0) {
@@ -696,15 +874,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             unitParams.put("day_budget", 0);
             unitParams.put("day_budget", 0);
         }
         }
         //应用商店列表
         //应用商店列表
-
         unitParams.put("ocpx_action_type", strategy.getOcpxActionType());
         unitParams.put("ocpx_action_type", strategy.getOcpxActionType());
-
         //出价
         //出价
         if (null != strategy.getBid() && strategy.getBid() != 0) {
         if (null != strategy.getBid() && strategy.getBid() != 0) {
             unitParams.put("bid", strategy.getBid());
             unitParams.put("bid", strategy.getBid());
         }
         }
-        if (null != strategy.getCpaBid() && strategy.getCpaBid() != 0) {
-            unitParams.put("cpa_bid", strategy.getCpaBid());
+        if (!Check.isNull(strategy.getCpaBid()) && !"0".equals((strategy.getCpaBid()))) {
+            Long cpdBid = getBidByString(strategy.getCpaBid());
+            unitParams.put("cpa_bid", cpdBid);
         }
         }
         //优先低成本
         //优先低成本
         if (null != strategy.getSmartBid() && strategy.getSmartBid() != 0) {
         if (null != strategy.getSmartBid() && strategy.getSmartBid() != 0) {
@@ -726,7 +903,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         if (!Check.isNull(strategy.getDeepConversionBid())) {
         if (!Check.isNull(strategy.getDeepConversionBid())) {
             unitParams.put("deep_conversion_bid", strategy.getDeepConversionBid());
             unitParams.put("deep_conversion_bid", strategy.getDeepConversionBid());
         }
         }
-
         Integer sceneId = null;
         Integer sceneId = null;
         String scenceIdString = strategy.getSceneId();
         String scenceIdString = strategy.getSceneId();
 
 
@@ -735,7 +911,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             sceneId = scenceArray.getInteger(0);
             sceneId = scenceArray.getInteger(0);
             unitParams.put("scene_id", scenceArray);
             unitParams.put("scene_id", scenceArray);
         }
         }
-
         Integer campaignType = strategy.getCampaignType();
         Integer campaignType = strategy.getCampaignType();
         if (campaignType == 2) { // 提升应用安装
         if (campaignType == 2) { // 提升应用安装
             //应用ID
             //应用ID
@@ -758,11 +933,9 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             if (!Check.isNull(strategy.getUrlType())) {
             if (!Check.isNull(strategy.getUrlType())) {
                 unitParams.put("url_type", strategy.getUrlType());
                 unitParams.put("url_type", strategy.getUrlType());
             }
             }
-
             if (!Check.isNull(strategy.getUrl())) {
             if (!Check.isNull(strategy.getUrl())) {
                 unitParams.put("url", strategy.getUrl());
                 unitParams.put("url", strategy.getUrl());
             }
             }
-
         } else if (campaignType == 5) { //收集销售线索
         } else if (campaignType == 5) { //收集销售线索
             //url类型
             //url类型
             if (!Check.isNull(strategy.getWebUriType())) {
             if (!Check.isNull(strategy.getWebUriType())) {
@@ -772,7 +945,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             if (!Check.isNull(strategy.getUrl())) {
             if (!Check.isNull(strategy.getUrl())) {
                 unitParams.put("url", strategy.getUrl());
                 unitParams.put("url", strategy.getUrl());
             }
             }
-
         } else if (campaignType == 7) { //  提高应用活跃
         } else if (campaignType == 7) { //  提高应用活跃
             //  appId
             //  appId
             if (!Check.isNull(appId)) {
             if (!Check.isNull(appId)) {
@@ -788,7 +960,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 unitParams.put("schema_uri", strategy.getSchemaUri());
                 unitParams.put("schema_uri", strategy.getSchemaUri());
             }
             }
         }
         }
-
         //投放开始时间
         //投放开始时间
         if (!Check.isNull(strategy.getBeginTime())) {
         if (!Check.isNull(strategy.getBeginTime())) {
             unitParams.put("begin_time", strategy.getBeginTime());
             unitParams.put("begin_time", strategy.getBeginTime());
@@ -807,8 +978,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         if (!Check.isNull(strategy.getConvertId())) {
         if (!Check.isNull(strategy.getConvertId())) {
             unitParams.put("convert_id", strategy.getConvertId());
             unitParams.put("convert_id", strategy.getConvertId());
         }
         }
-
-
         //创意展现方式
         //创意展现方式
         if (!Check.isNull(strategy.getShowMode())) {
         if (!Check.isNull(strategy.getShowMode())) {
             unitParams.put("show_mode", strategy.getShowMode());
             unitParams.put("show_mode", strategy.getShowMode());
@@ -829,7 +998,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         if (!Check.isNull(strategy.getAutoCreatePhoto())) {
         if (!Check.isNull(strategy.getAutoCreatePhoto())) {
             unitParams.put("auto_create_photo", strategy.getAutoCreatePhoto());
             unitParams.put("auto_create_photo", strategy.getAutoCreatePhoto());
         }
         }
-
         if (unitType == 7) {
         if (unitType == 7) {
             //是否开启智能抽帧
             //是否开启智能抽帧
             if (!Check.isNull(strategy.getSmartCover())) {
             if (!Check.isNull(strategy.getSmartCover())) {
@@ -859,8 +1027,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             // 定向数据
             // 定向数据
             unitParams.put("target", target);
             unitParams.put("target", target);
         }
         }
-
-
         // 设置定向内容
         // 设置定向内容
         JSONObject targetJsonObject = new JSONObject();
         JSONObject targetJsonObject = new JSONObject();
         if (null != strategy.getRegion() && !"".equals(strategy.getRegion())) {
         if (null != strategy.getRegion() && !"".equals(strategy.getRegion())) {
@@ -890,11 +1056,11 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         if (null != strategy.getDevicePrice() && !"".equals(strategy.getDevicePrice()) && !"[]".equals(strategy.getDevicePrice())) {
         if (null != strategy.getDevicePrice() && !"".equals(strategy.getDevicePrice()) && !"[]".equals(strategy.getDevicePrice())) {
             targetJsonObject.put("device_price", JSON.parseArray(strategy.getDevicePrice()));
             targetJsonObject.put("device_price", JSON.parseArray(strategy.getDevicePrice()));
         }
         }
-
-        if (null != strategy.getFilterConvertedLevel() && strategy.getFilterConvertedLevel() != 0) {
-            targetJsonObject.put("filter_converted_level", strategy.getFilterConvertedLevel());
+        if (sceneId != 5) {
+            if (null != strategy.getFilterConvertedLevel() && strategy.getFilterConvertedLevel() != 0) {
+                targetJsonObject.put("filter_converted_level", strategy.getFilterConvertedLevel());
+            }
         }
         }
-
         JSONArray appInterest = JSONArray.parseArray(strategy.getAppInterest());
         JSONArray appInterest = JSONArray.parseArray(strategy.getAppInterest());
         if (!Check.isNull(appInterest)) {
         if (!Check.isNull(appInterest)) {
             targetJsonObject.put("app_interest", appInterest);
             targetJsonObject.put("app_interest", appInterest);
@@ -921,25 +1087,51 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         }
 
 
         //是否开启智能扩量
         //是否开启智能扩量
-        if (null != strategy.getIsOpen() && strategy.getIsOpen().equals(1)) {
-            JSONObject intelliExtend = new JSONObject();
-            intelliExtend.put("is_open", 1);
-            if (null != strategy.getNoAgeBreak() && strategy.getNoAgeBreak().equals(1)) {
-                intelliExtend.put("no_age_break", 1);
-            }
-            if (null != strategy.getNoGenderBreak() && strategy.getNoGenderBreak().equals(1)) {
-                intelliExtend.put("no_gender_break", 1);
-            }
-            if (null != strategy.getNoAreaBreak() && strategy.getNoAreaBreak().equals(1)) {
-                intelliExtend.put("no_area_break", 1);
+        if (sceneId != 5) {
+            if (null != strategy.getIsOpen() && strategy.getIsOpen().equals(1)) {
+                JSONObject intelliExtend = new JSONObject();
+                intelliExtend.put("is_open", 1);
+                if (null != strategy.getNoAgeBreak() && strategy.getNoAgeBreak().equals(1)) {
+                    intelliExtend.put("no_age_break", 1);
+                }
+                if (null != strategy.getNoGenderBreak() && strategy.getNoGenderBreak().equals(1)) {
+                    intelliExtend.put("no_gender_break", 1);
+                }
+                if (null != strategy.getNoAreaBreak() && strategy.getNoAreaBreak().equals(1)) {
+                    intelliExtend.put("no_area_break", 1);
+                }
+                targetJsonObject.put("intelli_extend", intelliExtend);
             }
             }
-            targetJsonObject.put("intelli_extend", intelliExtend);
         }
         }
         unitParams.put("target", targetJsonObject);
         unitParams.put("target", targetJsonObject);
         log.info("广告组创建参数:{}", unitParams.toJSONString());
         log.info("广告组创建参数:{}", unitParams.toJSONString());
         return unitParams;
         return unitParams;
     }
     }
 
 
+    private Long getBidByString(String cpaBid) {
+        if (Check.isNull(cpaBid)) {
+            return null;
+        }
+        String bidString = null;
+        if (cpaBid.contains("/")) { // 阶梯出价
+            String[] split = cpaBid.split("/");
+            int random = new Random().nextInt(split.length);
+            bidString = split[random];
+
+        } else if (cpaBid.contains("-")) { // 随机出价
+            String[] split = cpaBid.split("-");
+            Double min = Double.valueOf(split[0]) / 1000;
+            Double max = Double.valueOf(split[1]) / 1000;
+            Double randomNumber = new BigDecimal(min + Math.random() * (max - min)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
+            bidString = String.valueOf(new Double(randomNumber * 1000).longValue());
+
+        } else {
+            bidString = cpaBid;
+        }
+
+        return Long.valueOf(bidString);
+    }
+
     private JSONArray cleanPramgramErrorScence(JSONArray scenceArray) {
     private JSONArray cleanPramgramErrorScence(JSONArray scenceArray) {
         JSONArray result = new JSONArray();
         JSONArray result = new JSONArray();
         if (null == scenceArray || scenceArray.isEmpty()) {
         if (null == scenceArray || scenceArray.isEmpty()) {
@@ -1136,7 +1328,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         creativeParams.put("photo_id", videoItem.getPhotoId());
         creativeParams.put("photo_id", videoItem.getPhotoId());
         creativeParams.put("creative_material_type", videoItem.getMaterialType());
         creativeParams.put("creative_material_type", videoItem.getMaterialType());
         creativeParams.put("action_bar_text", strategy.getActionBarText());
         creativeParams.put("action_bar_text", strategy.getActionBarText());
-        creativeParams.put("description", strategy.getDescription());
+        JSONArray descArr = JSONArray.parseArray(strategy.getDescription());
+        int index = new Random().nextInt(descArr.size());
+        String description = descArr.getString(index);
+        creativeParams.put("description", description);
         // 封面广告语标题
         // 封面广告语标题
         if (!Check.isNull(strategy.getStickerTitle())) {
         if (!Check.isNull(strategy.getStickerTitle())) {
             creativeParams.put("sticker_title", strategy.getStickerTitle());
             creativeParams.put("sticker_title", strategy.getStickerTitle());
@@ -1192,11 +1387,19 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate(token.getAccessToken(), token.getAccountId(), creativeParams, 1);
         Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate(token.getAccessToken(), token.getAccountId(), creativeParams, 1);
         Integer creativeCode = (Integer) creativeCreateResult.get("code");
         Integer creativeCode = (Integer) creativeCreateResult.get("code");
         String creativeMessage = (String) creativeCreateResult.get("message");
         String creativeMessage = (String) creativeCreateResult.get("message");
+
+        if (creativeCode == -1 && "/rest/openapi/v2/creative/create调用已超日限,次日可恢复调用".equals(creativeMessage)) {
+            updateService.updateUnitStatus(token.getAccessToken(), token.getAccountId(), unitId, 3, "e9ca23d68d884d4ebb19d07889727dae");
+        } else if (creativeCode == -1 && creativeMessage.contains("超过可关联的有效创意的上限")) {
+            updateService.updateUnitStatus(token.getAccessToken(), token.getAccountId(), unitId, 3, "e9ca23d68d884d4ebb19d07889727dae");
+        }
+
         AiKuaishouCreativeLevelOperationRecord record = new AiKuaishouCreativeLevelOperationRecord();
         AiKuaishouCreativeLevelOperationRecord record = new AiKuaishouCreativeLevelOperationRecord();
         BeanUtils.copyProperties(strategy, record);
         BeanUtils.copyProperties(strategy, record);
         record.setCreativeName(creativeName);
         record.setCreativeName(creativeName);
         record.setStatus(creativeCode);
         record.setStatus(creativeCode);
         record.setMessage(creativeMessage);
         record.setMessage(creativeMessage);
+        record.setUnitId(unitId);
         record.setAiStrategyUuid(uuid);
         record.setAiStrategyUuid(uuid);
         record.setCreateTime(new Date());
         record.setCreateTime(new Date());
         if (creativeCode != 0) {
         if (creativeCode != 0) {
@@ -1214,17 +1417,27 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
      * @param strategy 账户id
      * @param strategy 账户id
      * @return
      * @return
      */
      */
-    private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy, Integer createType, AiKuaiShouAppInfo appInfo, String timestamp, Integer cnt, String materialName) {
-        if (wildcard.contains("{{应用包名}}")) {
-            String appName = "";
-            if (null != appInfo) {
-                appName = appInfo.getAppName();
+    @Autowired
+    private RedisUtil redisUtil;
+    @Autowired
+    private IKuaiShouAppListService appListService;
+
+    private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy, Integer createType, String materialName, String type, Long campaignId, Long appId) {
+
+
+        if (wildcard.contains("{{应用名称}}") || wildcard.contains("{{应用标记}}")) {
+            KuaiShouAppList getAppInfo = appListService.getAppInfo(strategy.getAccountId(), appId);
+            if (!Check.isNull(getAppInfo)) {
+                wildcard = wildcard.replace("{{应用名称}}", getAppInfo.getAppName());
+                wildcard = wildcard.replace("{{应用标记}}", getAppInfo.getAppVersion());
+            } else {
+                wildcard = wildcard.replace("{{应用名称}}", "");
+                wildcard = wildcard.replace("{{应用标记}}", "");
             }
             }
-            wildcard = wildcard.replace("{{应用包名}}", appName);
         }
         }
+
+
         if (wildcard.contains("{{创意制作方式}}")) {
         if (wildcard.contains("{{创意制作方式}}")) {
-//            String creatype = KuaishouCreativeCreateTypeEnum.getNameByType(strategy.getOpenProgramCreate());
-//            wildcard = wildcard.replace("{{创意制作方式}}",creatype);
             if (strategy.getUnitType() == 4) {
             if (strategy.getUnitType() == 4) {
                 wildcard = wildcard.replace("{{创意制作方式}}", "自定义");
                 wildcard = wildcard.replace("{{创意制作方式}}", "自定义");
             } else if (strategy.getUnitType() == 7) {
             } else if (strategy.getUnitType() == 7) {
@@ -1242,22 +1455,51 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             } else {
             } else {
                 wildcard = wildcard.replace("{{素材名称}}", materialName);
                 wildcard = wildcard.replace("{{素材名称}}", materialName);
             }
             }
-
         }
         }
         if (!wildcard.contains("{{自定义}}")) {
         if (!wildcard.contains("{{自定义}}")) {
             wildcard = wildcard + "{{自定义}}";
             wildcard = wildcard + "{{自定义}}";
         }
         }
-        String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
-        if (null != appInfo) {
-            targetName = appInfo.getAppVersion() + "-" + targetName;
+        Date date = new Date();
+        String nowDate = DateUtils.formatDate(date, "yy-MMdd");
+        if (type.equals("plan")) {
+            if (wildcard.contains("{{日期}}")) {
+                wildcard = wildcard.replace("{{日期}}", nowDate);
+            } else {
+                wildcard = wildcard + "-" + nowDate;
+            }
+        } else if ("unit".equals(type)) {
+            wildcard = wildcard.replace("{{日期}}", nowDate);
         }
         }
+
+
+        String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
         wildcard = wildcard.replace("{{自定义}}", targetName);
         wildcard = wildcard.replace("{{自定义}}", targetName);
 
 
-        if (null != timestamp && !"".equals(timestamp.trim())) {
-            wildcard = wildcard + "-" + timestamp;
-        }
-        if (null != cnt) {
-            wildcard = wildcard + "-" + cnt.toString();
+
+        if (!Check.isNull(campaignId)) {
+            Integer count = null;
+            if (null != strategy.getSingleAppid() && strategy.getSingleAppid() == 0 && strategy.getMultipleBids() == 0) {
+                String redisKey = strategy.getAccountId() + "_" + campaignId;
+                Object redisValue = redisUtil.get(redisKey);
+                if (Check.isNull(redisValue)) {
+                    count = 1;
+                    redisUtil.set(redisKey, count);
+                } else {
+                    count = (Integer) redisValue + 1;
+                    redisUtil.set(redisKey, count);
+                }
+            } else {
+                String redisKey = strategy.getAccountId() + "_" + campaignId + nowDate;
+                Object redisValue = redisUtil.get(redisKey);
+                if (Check.isNull(redisValue)) {
+                    count = 1;
+                    redisUtil.set(redisKey, count, 100000L);
+                } else {
+                    count = (Integer) redisValue + 1;
+                    redisUtil.set(redisKey, count, 100000L);
+                }
+            }
+            wildcard = wildcard + "-" + count;
         }
         }
         wildcard = wildcard.replace("--", "-");
         wildcard = wildcard.replace("--", "-");
         if (wildcard.startsWith("-")) {
         if (wildcard.startsWith("-")) {
@@ -1283,4 +1525,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         }
         return adsence.substring(0, adsence.length() - 1);
         return adsence.substring(0, adsence.length() - 1);
     }
     }
+
+
 }
 }

+ 48 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouAppMultipleBidsServiceImpl.java

@@ -0,0 +1,48 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouAppMultipleBids;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaiShouAppMultipleBidsMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 多应用分别出价
+ *
+ * @author jeecg-boot
+ * 2021-05-18
+ * @version V1.0
+ */
+@Service
+public class KuaiShouAppMultipleBidsServiceImpl extends ServiceImpl<KuaiShouAppMultipleBidsMapper, KuaiShouAppMultipleBids> implements IKuaiShouAppMultipleBidsService {
+    @Autowired
+    private KuaiShouAppMultipleBidsMapper appMultipleBidsMapper;
+
+    @Override
+    public List<JSONObject> getAppInfiList(Long accountId, String appIdArray) {
+        if (!Check.isNull(appIdArray)) {
+            JSONArray jsonArray = JSONArray.parseArray(appIdArray);
+            List<JSONObject> appInfoList = appMultipleBidsMapper.getAppInfoList(accountId, jsonArray);
+            return appInfoList;
+
+        }
+        return null;
+    }
+
+    @Override
+    public KuaiShouAppMultipleBids getInfoByAccountAndAppId(Long accountId, Long appId) {
+        QueryWrapper<KuaiShouAppMultipleBids> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("app_id", appId);
+        queryWrapper.orderByDesc("create_time");
+        queryWrapper.last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+}

+ 57 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java

@@ -3,12 +3,22 @@ package cn.com.ctop.kuaishou.modules.ai.service.impl;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
-import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.HttpUtils2;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouCreateService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouCreateService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
+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.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -37,6 +47,8 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
     private IKuaiShouVideoGetService videoGetService;
     private IKuaiShouVideoGetService videoGetService;
     @Autowired
     @Autowired
     private IKuaiShouGroupTemplateService groupTemplateService;
     private IKuaiShouGroupTemplateService groupTemplateService;
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
 
 
     @Value("${ai.callback.callback-unit-url}")
     @Value("${ai.callback.callback-unit-url}")
     private String unitUrl;
     private String unitUrl;
@@ -446,6 +458,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 if (resultJson.getInteger("code") == 0) {
                 if (resultJson.getInteger("code") == 0) {
                     returnJson.put("code", 0);
                     returnJson.put("code", 0);
                     returnJson.put("message", "程序化创意创建成功");
                     returnJson.put("message", "程序化创意创建成功");
+                    createLandPageAndUnit(programJson, resultJson.getJSONObject("data"));
                 } else {
                 } else {
                     log.error("创建程序化创意失败,accountId:{},返回结果:{},入参:{}", oauthToken.getAccountId(), resultJson.getString("message"), programCreativeJson);
                     log.error("创建程序化创意失败,accountId:{},返回结果:{},入参:{}", oauthToken.getAccountId(), resultJson.getString("message"), programCreativeJson);
                     returnJson.put("code", -1);
                     returnJson.put("code", -1);
@@ -466,6 +479,18 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
         callback(creativeUrl, returnArray, "program_create");
         callback(creativeUrl, returnArray, "program_create");
     }
     }
 
 
+    //绑定落地页与广告组、创意的关系
+    private void createLandPageAndUnit(JSONObject programJson, JSONObject data) {
+        if (!Check.isNull(data) && !Check.isNull(programJson.getLong("site_id"))) {
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    landpagePackageService.createLandPageAndUnit(programJson.getLong("site_id"), data.getLong("creative_id"), programJson.getLong("unit_id"), programJson.getLong("advertiser_id"));
+                }
+            };
+            thread.start();
+        }
+    }
 
 
     /**
     /**
      * 回调
      * 回调
@@ -614,9 +639,36 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 target.put("intelli_extend", intelli_extend); // 智能扩量
                 target.put("intelli_extend", intelli_extend); // 智能扩量
             }
             }
         }
         }
-        if (Check.isNull(unitJson.getJSONObject("behavior_interest"))) {
-            // TODO 只是单独结构体 后续需要优化
-            target.put("behavior_interest", unitJson.getJSONObject("behavior_interest")); // 智能扩量
+        //-------------兴趣行为定向
+        JSONObject behaviorInterest = new JSONObject();
+        JSONObject behavior = new JSONObject();
+        JSONObject interest = new JSONObject();
+        if (!Check.isNull(unitJson.getJSONArray("keyword"))) {
+            behavior.put("keyword", unitJson.getJSONArray("keyword"));
+        }
+        if (!Check.isNull(unitJson.getJSONArray("label"))) {
+            behavior.put("label", unitJson.getJSONArray("label"));
+        }
+        if (!Check.isNull(unitJson.getInteger("strengthType"))) {
+            behavior.put("strength_type", unitJson.getInteger("strengthType"));
+        }
+        if (!Check.isNull(unitJson.getInteger("timeType"))) {
+            behavior.put("time_type", unitJson.getInteger("timeType"));
+        }
+        if (!Check.isNull(unitJson.getJSONArray("sceneType"))) {
+            behavior.put("scene_type", unitJson.getJSONArray("sceneType"));
+        }
+        if (!Check.isNull(unitJson.getJSONArray("interestLabel"))) {
+            interest.put("label", unitJson.getJSONArray("interestLabel"));
+        }
+        if (!Check.isNull(behavior)) {
+            behaviorInterest.put("behavior", behavior);
+        }
+        if (!Check.isNull(interest)) {
+            behaviorInterest.put("interest", interest);
+        }
+        if (!Check.isNull(behaviorInterest)) {
+            target.put("behavior_interest", behaviorInterest);
         }
         }
         return target;
         return target;
     }
     }

+ 19 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouAppGroupServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppGroup;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppGroupMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppGroupService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 应用-广告组关联表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-14
+ */
+@Service
+public class KuaishouAppGroupServiceImpl extends ServiceImpl<KuaishouAppGroupMapper, KuaishouAppGroup> implements IKuaishouAppGroupService {
+
+}

+ 19 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouAppPackageRelServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppPackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageRelService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 应用和账户关联表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-13
+ */
+@Service
+public class KuaishouAppPackageRelServiceImpl extends ServiceImpl<KuaishouAppPackageRelMapper, KuaishouAppPackageRel> implements IKuaishouAppPackageRelService {
+
+}

+ 310 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouAppPackageServiceImpl.java

@@ -0,0 +1,310 @@
+package cn.com.ctop.kuaishou.modules.ai.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.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackage;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppGroupMapper;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppPackageMapper;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppPackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+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 org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.MD5Util;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 项目绑定的应用
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-12
+ */
+@Service
+public class KuaishouAppPackageServiceImpl extends ServiceImpl<KuaishouAppPackageMapper, KuaishouAppPackage> implements IKuaishouAppPackageService {
+
+    @Autowired
+    private KuaishouAppPackageMapper appPackageMapper;
+
+    @Autowired
+    private KuaishouAppPackageRelMapper relMapper;
+
+    @Autowired
+    private KuaishouAppGroupMapper appGroupMapper;
+
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaiShouMaterialUploadService materialUploadService;
+
+    @Override
+    public Result<Object> importExcel(MultipartFile file, Long projectId, Integer platform, String imageToken, String imageUrl) throws Exception {
+        JSONObject returnJson = new JSONObject();
+        Workbook workbook = null;
+        String fileName = file.getOriginalFilename();
+        String substring = fileName.substring(fileName.lastIndexOf(".") + 1).toUpperCase();
+        if (substring.equals("XLS")) {
+            workbook = new HSSFWorkbook(file.getInputStream());
+        } else if (substring.equals("XLSX")) {
+            workbook = new XSSFWorkbook(file.getInputStream());
+        } else {
+            throw new Exception("文件不是Excel文件");
+        }
+        Sheet sheet = workbook.getSheet("Sheet1");
+        if (Check.isNull(sheet)) {
+            throw new Exception("Sheet标题不是默认的Sheet1");
+        }
+        int rows = sheet.getLastRowNum();// 指的行数,一共有多少行+
+        if (rows == 0) {
+            throw new Exception("请填写数据");
+        }
+        //查询项目下的应用标记(同一账户下应用标记不能重复),在此视为同一项目不可重复
+        List<String> appVersions = appPackageMapper.queryAppVersions(projectId);
+        StringBuffer errAppVersions = new StringBuffer();
+        List<KuaishouAppPackage> appList = new ArrayList<>();
+        for (int i = 1; i <= rows + 1; i++) {
+            Row row = sheet.getRow(i);
+            if (row != null) {
+                KuaishouAppPackage appPackage = new KuaishouAppPackage();
+                String appName = getCellValue(row.getCell(0));
+                String packageName = getCellValue(row.getCell(1));
+                String appVersion = getCellValue(row.getCell(2));
+                String appPrivacyUrl = getCellValue(row.getCell(3));
+                String url = getCellValue(row.getCell(4));
+                String trackUrl = getCellValue(row.getCell(5));
+                String useSdk = getCellValue(row.getCell(6));
+                if ((platform == 1 || platform == 2) && Check.isNull(appPrivacyUrl)) {
+                    return Result.error("执行失败,您选择的是安卓类应用,请填写隐私政策链接");
+                } else if (Check.isNull(appVersion)) {
+                    return Result.error("解析失败,文档中应用标记列缺失数据");
+                } else if (platform == 1 && Check.isNull(packageName)) {
+                    return Result.error("解析失败,选择Android应用下载时,文档中应用包名列缺失数据");
+                } else if (Check.isNull(appName)) {
+                    return Result.error("解析失败,文档中应用名称列缺失数据");
+                } else if (Check.isNull(url)) {
+                    return Result.error("解析失败,文档中下载链接列缺失数据");
+                } else if (Check.isNull(trackUrl)) {
+                    return Result.error("解析失败,文档中监测链接列缺失数据");
+                }
+                if (appVersions.contains(appVersion)) {
+                    errAppVersions.append(appVersion).append("、");
+                }
+                appPackage.setProjectId(projectId);
+                appPackage.setAppName(appName);
+                appPackage.setAppVersion(appVersion);
+                appPackage.setAppIconUrl(imageUrl);
+                appPackage.setPackageName(packageName);
+                appPackage.setPlatform(platform);
+                appPackage.setImageToken(imageToken);
+                appPackage.setTrackUrl(trackUrl);
+                appPackage.setAppPrivacyUrl(appPrivacyUrl);
+                appPackage.setDataStatus(1);//有效
+                appPackage.setUrl(url);
+                String md5 = MD5Util.getMd5(url);
+                if (!Check.isNull(md5)) {
+                    appPackage.setAppMd5(md5);
+                }
+                if (!Check.isNull(useSdk)) {
+                    appPackage.setUseSdk(Integer.valueOf(useSdk));
+                }
+                appList.add(appPackage);
+            }
+        }
+        String errVersion = errAppVersions.toString();
+        if (!Check.isNull(errVersion)) {
+            return Result.error("数据异常,重复的应用标记:" + errVersion.substring(0, errVersion.length() - 1));
+        }
+        appPackageMapper.replaceBatch(appList);
+        return Result.ok("文件导入成功");
+    }
+
+    private String getCellValue(Cell cell) {
+        String value = "";
+        if (cell != null) {
+            // 以下是判断数据的类型
+            switch (cell.getCellType()) {
+                case HSSFCell.CELL_TYPE_NUMERIC: // 数字
+                    value = cell.getNumericCellValue() + "";
+                    if (HSSFDateUtil.isCellDateFormatted(cell)) {
+                        Date date = cell.getDateCellValue();
+                        if (date != null) {
+                            value = new SimpleDateFormat("yyyy-MM-dd").format(date);
+                        } else {
+                            value = "";
+                        }
+                    } else {
+                        value = new DecimalFormat("0").format(cell.getNumericCellValue());
+                    }
+                    break;
+                case HSSFCell.CELL_TYPE_STRING: // 字符串
+                    value = cell.getStringCellValue();
+                    break;
+                case HSSFCell.CELL_TYPE_BOOLEAN: // Boolean
+                    value = cell.getBooleanCellValue() + "";
+                    break;
+                case HSSFCell.CELL_TYPE_FORMULA: // 公式
+                    value = cell.getCellFormula() + "";
+                    break;
+                case HSSFCell.CELL_TYPE_BLANK: // 空值
+                    value = "";
+                    break;
+                case HSSFCell.CELL_TYPE_ERROR: // 故障
+                    value = "非法字符";
+                    break;
+                default:
+                    value = "未知类型";
+                    break;
+            }
+        }
+        return value.trim();
+    }
+
+    @Override
+    public Result<Object> pushAppPackage(Long id, JSONArray accountIds) {
+        KuaishouAppPackage appPackage = appPackageMapper.selectById(id);
+        if (Check.isNull(appPackage)) {
+            return Result.error("为获取到应用信息");
+        }
+        KuaishouAppPackageRel rel = new KuaishouAppPackageRel();
+        rel.setApptemId(appPackage.getId());
+        rel.setProjectId(appPackage.getProjectId());
+        rel.setAppVersion(appPackage.getAppVersion());
+        List<KuaishouAppPackageRel> list = new ArrayList<>();
+        for (Object account : accountIds) {
+            try {
+                Long accountId = Long.valueOf(String.valueOf(account));
+                KuaishouAppPackageRel entity = relMapper.queryEntityByAccountId(accountId, appPackage.getAppVersion());
+                if (!Check.isNull(entity)) {
+                    continue;
+                }
+                CtopOauthToken oauthToken = tokenService.getTokenByAccountId(accountId);
+                JSONObject requestJson = new JSONObject();
+                requestJson.put("advertiser_id", accountId);
+                requestJson.put("app_version", appPackage.getAppVersion());
+                requestJson.put("app_name", appPackage.getAppName());
+                requestJson.put("image_token", appPackage.getImageToken());
+                requestJson.put("package_name", appPackage.getPackageName());
+                requestJson.put("platform", appPackage.getPlatform());
+                requestJson.put("url", appPackage.getUrl());
+                requestJson.put("use_sdk", appPackage.getUseSdk());
+                requestJson.put("app_privacy_url", appPackage.getAppPrivacyUrl());
+                String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.APP_CREATE;
+                Map<String, String> headerMap = new HashMap<>();
+                headerMap.put("Content-Type", "multipart/form-data");
+                headerMap.put("Access-Token", oauthToken.getAccessToken());
+                String result = materialUploadService.exceptInfoForRestTemplate(url, requestJson, headerMap);
+                JSONObject resultJson = JSONObject.parseObject(result);
+                rel.setAccountId(accountId);
+                if (!Check.isNull(resultJson)) {
+                    Integer code = resultJson.getInteger("code");
+                    if (code == 0) {
+                        JSONObject data = resultJson.getJSONObject("data");
+                        rel.setAppId(data.getLong("app_id"));
+                        rel.setReturnUrl(data.getString("url"));
+                        rel.setMessage(resultJson.getString("message"));
+                        rel.setDataStatus(1);
+                    } else {
+                        rel.setDataStatus(0);
+                        rel.setMessage(resultJson.getString("message"));
+                    }
+                } else {
+                    rel.setDataStatus(0);
+                    rel.setMessage("上传应用返回结果为空");
+                }
+            } catch (Exception e) {
+                rel.setDataStatus(0);
+                rel.setMessage("上传应用异常");
+                log.error("上传应用异常,accountId=" + account, e);
+            }
+            list.add(rel);
+        }
+        if (!list.isEmpty()) {
+            relMapper.replaceBatch(list);
+        }
+        return Result.ok("推送完成");
+    }
+    @Override
+    public Result<Object> queryPushResults(String id, JSONArray accountIds, String status) {
+        List<JSONObject> lsit = relMapper.queryPushResults(id, accountIds, status);
+        return Result.ok(new PageInfo<JSONObject>(lsit));
+    }
+
+    @Override
+    public List<Long> queryByAppVersion(Long projectId,String appVersion) {
+        return appPackageMapper.queryByAppVersion(projectId,appVersion);
+    }
+
+    @Override
+    public void createAppAndGroupRel(JSONObject request) {
+        try {
+            appGroupMapper.replaceBatch(request);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("添加广告组和应用绑定关系异常");
+        }
+    }
+
+    @Override
+    public Result<Object> queryPageList(KuaishouAppPackage kuaishouAppPackage, Integer pageNo, Integer pageSize) {
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> list = appPackageMapper.queryPageList(kuaishouAppPackage.getAppVersion(), kuaishouAppPackage.getProjectId(), kuaishouAppPackage.getPlatform());
+        for (JSONObject object : list) {
+            object.put("unitCount", appPackageMapper.queryUnitCount(object.getLong("id")));
+        }
+        return Result.ok(new PageInfo<JSONObject>(list));
+    }
+
+    @Override
+    public Result<Object> getRelatedAccounts(Long id) {
+        JSONObject result = new JSONObject();
+        KuaishouAppPackage appPackage = appPackageMapper.selectById(id);
+        List<JSONObject> list = relMapper.getRelatedAccounts(id);
+        result.put("app", appPackage);
+        result.put("page", new PageInfo<>(list));
+        return Result.ok(result);
+    }
+
+    @Override
+    public Result<Object> getRelatedGroups(Long id, Long accountId) {
+        JSONObject result = new JSONObject();
+        KuaishouAppPackage appPackage = appPackageMapper.selectById(id);
+        List<JSONObject> list = appPackageMapper.getRelatedGroups(id, accountId);
+        result.put("app", appPackage);
+        result.put("page", new PageInfo<>(list));
+        return Result.ok(result);
+    }
+
+    @Override
+    public Result<Object> getAccountByProjectId(Long projectId, String id) {
+        List<JSONObject> list = relMapper.getAccountByProjectId(projectId, id);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+
+}

+ 0 - 277
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouCrowdPackServiceImpl.java

@@ -1,277 +0,0 @@
-package cn.com.ctop.kuaishou.modules.ai.service.impl;
-
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.mapper.UserAllocationMapper;
-import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.LoadFileUtil;
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
-import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouCrowdPackMapper;
-import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouCrowdPackService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-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.jeecg.common.util.DateUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
-
-/**
- * 人群报表
- *
- * @author jeecg-boot
- * @version V1.0
- * @date 2021-03-26
- */
-@Slf4j
-@Service
-public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackMapper, KuaishouCrowdPack> implements IKuaishouCrowdPackService {
-
-    @Autowired
-    private KuaishouCrowdPackMapper crowdPackMapper;
-
-    @Autowired
-    private ICtopOauthTokenService tokenService;
-
-    @Autowired
-    private IKuaishouPopulationService iKuaishouPopulationService;
-
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-
-    @Autowired
-    UserAllocationMapper userAllocationMapper;
-
-    @Value("${zip.local.download-path}")
-    private String downloadPath;
-
-
-    @Override
-    public Result<Object> queryPageList(KuaishouCrowdPack kuaishouCrowdPack, Integer pageNo, Integer pageSize) {
-        Long total = crowdPackMapper.getTotal(kuaishouCrowdPack.getStatus(), kuaishouCrowdPack.getAccountId(), kuaishouCrowdPack.getOrientationName());
-        PageHelper.startPage(pageNo, pageSize, false);
-        List<JSONObject> list = crowdPackMapper.queryPageList(kuaishouCrowdPack.getStatus(), kuaishouCrowdPack.getAccountId(), kuaishouCrowdPack.getOrientationName());
-        for (JSONObject object : list) {
-            int count = crowdPackMapper.queryProjectCount(object.getString("signature"));
-            object.put("projectCount", count);
-            int accountCount = crowdPackMapper.queryAccountCount(object.getString("signature"));
-            object.put("accountCount", accountCount);
-        }
-        PageInfo pageInfo = new PageInfo(list);
-        pageInfo.setTotal(total);
-        return Result.ok(pageInfo);
-    }
-
-    @Override
-    public Result<Object> uploadCrowdPack(Integer type, String orientationName, Long accountId, String url) {
-        StringBuffer path = new StringBuffer();
-        path.append(downloadPath).append(DateUtils.getNowDate(DateUtils.WEB_FORMAT)).append("/").append(UUID.randomUUID().toString()).append("/");
-        if (!url.contains("http")) {
-            url = "https:".concat(url);
-        }
-        String newFileUrl = LoadFileUtil.downLoadFromUrl(url, path.toString());
-        if (Check.isNull(newFileUrl)) {
-            return Result.error("文件下载失败,路径:" + url);
-        }
-        String md5 = null;
-        try {
-            md5 = LoadFileUtil.getMD5(newFileUrl);
-        } catch (IOException e) {
-            log.error("获取MD5签名失败", e);
-        }
-        QueryWrapper<KuaishouCrowdPack> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("account_id", accountId);
-        queryWrapper.eq("signature", md5);
-        queryWrapper.eq("data_status", 1);
-        queryWrapper.last("limit 1");
-        KuaishouCrowdPack one = crowdPackMapper.selectOne(queryWrapper);
-        if (!Check.isNull(one)) {
-            return Result.error("本账户已上传过该人群包,人群包名为:" + one.getOrientationName());
-        }
-        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
-        JSONObject jsonObject = iKuaishouPopulationService.updatePopulation(token, type, orientationName, newFileUrl);
-        LoadFileUtil.delFile(newFileUrl);
-        if (!Check.isNull(jsonObject)) {
-            if (jsonObject.getInteger("code") == 0) {
-                KuaishouCrowdPack crowdPack = JSONObject.toJavaObject(jsonObject.getJSONObject("data"), KuaishouCrowdPack.class);
-                crowdPack.setSignature(md5);
-                crowdPack.setUrl(url);
-                crowdPack.setMessage(jsonObject.getString("message"));
-                crowdPack.setStatDate(DateUtils.formatDate(new Date()));
-                crowdPack.setDataStatus(1);
-                this.save(crowdPack);
-            } else {
-                KuaishouCrowdPack crowdPack = new KuaishouCrowdPack();
-                crowdPack.setAccountId(accountId);
-                crowdPack.setOrientationName(orientationName);
-                crowdPack.setSignature(md5);
-                crowdPack.setUrl(url);
-                crowdPack.setMessage(jsonObject.getString("message"));
-                crowdPack.setStatDate(DateUtils.formatDate(new Date()));
-                crowdPack.setDataStatus(0);
-                this.save(crowdPack);
-                return Result.error(jsonObject.getString("message"));
-            }
-        }
-        return Result.ok("success");
-    }
-
-    @Override
-    public Result<Object> accountPush(JSONObject request) {
-        JSONArray accountIds = request.getJSONArray("accountIds");
-        String signature = request.getString("signature");
-        Long accountId = request.getLong("accountId");
-        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
-        QueryWrapper<KuaishouCrowdPack> wrapper = new QueryWrapper<>();
-        wrapper.eq("account_id", accountId);
-        wrapper.eq("signature", signature);
-        wrapper.eq("status", 4);
-        wrapper.last("limit 1");
-        KuaishouCrowdPack kuaishouCrowdPack = crowdPackMapper.selectOne(wrapper);
-        if (Check.isNull(kuaishouCrowdPack)) {
-            return Result.error("该账户下没有可推送人群包");
-        }
-        JSONObject jsonObject = iKuaishouPopulationService.pushAccountsPopulation(token, kuaishouCrowdPack.getOrientationId(), accountIds);
-        if (jsonObject.getInteger("code") == 0) {
-            List<KuaishouCrowdPack> list = new ArrayList<>();
-            JSONObject data = jsonObject.getJSONObject("data");
-            if (!Check.isNull(data)) {
-                JSONArray success = data.getJSONArray("success");
-                for (Object account : success) {
-                    kuaishouCrowdPack.setAccountId(Long.valueOf(String.valueOf(account)));
-                    kuaishouCrowdPack.setMessage("PUSH OK");
-                    kuaishouCrowdPack.setStatDate(DateUtils.formatDate(new Date()));
-                    list.add(kuaishouCrowdPack);
-                }
-                JSONArray fail = data.getJSONArray("fail");
-                for (Object account : fail) {
-                    Long aaccount = Long.valueOf(String.valueOf(account));
-                    KuaishouCrowdPack crowdPack = crowdPackMapper.queryByAccountId(aaccount, kuaishouCrowdPack.getOrientationId());
-                    if (Check.isNull(crowdPack)) {
-                        kuaishouCrowdPack.setDataStatus(0);
-                        kuaishouCrowdPack.setAccountId(aaccount);
-                        kuaishouCrowdPack.setMessage("推送失败");
-                        kuaishouCrowdPack.setStatDate(DateUtils.formatDate(new Date()));
-                        kuaishouCrowdPack.setStatus(null);
-                        kuaishouCrowdPack.setType(null);
-                        kuaishouCrowdPack.setCoverNum(null);
-                        kuaishouCrowdPack.setRecordSize(null);
-                        kuaishouCrowdPack.setMatchSize(null);
-                        list.add(kuaishouCrowdPack);
-                    }
-                }
-                if (list.size() > 0) {
-                    crowdPackMapper.replaceBatch(list);
-                }
-            }
-        } else {
-            return Result.error(jsonObject.getString("message"));
-        }
-        return Result.ok("success");
-    }
-
-    @Override
-    public void crowdListQuery() {
-        List<KuaishouCrowdPack> crowdList = crowdPackMapper.queryListByStatus();
-        for (int i = 0; i <= 7; i++) {
-            if (i != 2) {
-                for (KuaishouCrowdPack crowdPack : crowdList) {
-                    CtopOauthToken token = tokenService.getTokenByAccountId(crowdPack.getAccountId());
-                    JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(crowdPack.getAccountId(), token.getAccessToken(), i);
-                    if (jsonObject.getInteger("code") == 0) {
-                        JSONObject data = jsonObject.getJSONObject("data");
-                        if (!Check.isNull(data)) {
-                            JSONArray details = data.getJSONArray("details");
-                            if (details.size() > 0) {
-                                for (int j = 0; j < details.size(); j++) {
-                                    JSONObject obj = details.getJSONObject(j);
-                                    if (Check.isNull(crowdPackMapper.queryByAccountId(obj.getLong("account_id"), obj.getLong("orientation_id")))) {
-                                        KuaishouCrowdPack oldPack = crowdPackMapper.queryByAccountId(null, obj.getLong("orientation_id"));
-                                        KuaishouCrowdPack crowdPackEntity = JSONObject.toJavaObject(obj, KuaishouCrowdPack.class);
-                                        if (!Check.isNull(oldPack)) {
-                                            crowdPackEntity.setStatDate(oldPack.getStatDate());
-                                            crowdPackEntity.setUrl(oldPack.getUrl());
-                                            crowdPackEntity.setSignature(oldPack.getSignature());
-                                        }
-                                        crowdPackEntity.setMessage("PUSH OK");
-                                        crowdPackEntity.setDataStatus(1);
-                                        this.save(crowdPackEntity);
-                                    } else {
-                                        crowdPackMapper.update(obj);
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    @Override
-    public Result<Object> queryRel(String type, String signature, Integer pageNo, Integer pageSize) {
-        PageHelper.startPage(pageNo, pageSize);
-        List<JSONObject> list = null;
-        if ("1".equals(type)) {
-            list = crowdPackMapper.queryRelProject(signature);
-        } else {
-            list = crowdPackMapper.queryRelAccounts(signature);
-        }
-        PageInfo pageInfo = new PageInfo(list);
-        return Result.ok(pageInfo);
-    }
-
-    @Override
-    public Result<Object> queryFailReason(String signature, Integer pageNo, Integer pageSize) {
-        PageHelper.startPage(pageNo, pageSize);
-        List<JSONObject> list = crowdPackMapper.queryFailReason(signature);
-        PageInfo pageInfo = new PageInfo(list);
-        return Result.ok(pageInfo);
-    }
-
-    @Override
-    public Result<Object> updateDataStatus(KuaishouCrowdPack kuaishouCrowdPack) {
-        CtopOauthToken token = tokenService.getTokenByAccountId(kuaishouCrowdPack.getAccountId());
-        JSONObject object = iKuaishouPopulationService.deletePopulation(kuaishouCrowdPack.getAccountId(), kuaishouCrowdPack.getOrientationId(), token.getAccessToken());
-        if (!Check.isNull(object)) {
-            if (object.getInteger("code") == 0) {
-                if (this.removeById(kuaishouCrowdPack.getId())) {
-                    return Result.ok("删除成功");
-                }
-            }
-            return Result.error("删除失败,".concat(object.getString("message")));
-        }
-        return Result.error("删除失败");
-    }
-
-    @Override
-    public Result<Object> checkCrowdPackage(String signature) {
-        QueryWrapper<KuaishouCrowdPack> wrapper = new QueryWrapper<>();
-        wrapper.eq("signature", signature);
-        wrapper.eq("data_status", 1);
-        wrapper.last("limit 1");
-        KuaishouCrowdPack kuaishouCrowdPack = crowdPackMapper.selectOne(wrapper);
-        Result result = new Result();
-        if (Check.isNull(kuaishouCrowdPack)) {
-            return Result.ok("success");
-        }
-        result.setSuccess(true);
-        result.setCode(201);
-        result.setMessage("后台保存过该人群包,名称为:" + kuaishouCrowdPack.getOrientationName());
-        result.setResult(kuaishouCrowdPack);
-        return result;
-    }
-}

+ 660 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouDirectionalPackageServiceImpl.java

@@ -0,0 +1,660 @@
+package cn.com.ctop.kuaishou.modules.ai.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.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalaPckageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouDirectionalPackageMapper;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouDirectionalPckageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPckageRelService;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateTargetMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+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;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 自动投放-定向包详情
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-20
+ */
+@Slf4j
+@Service
+public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouDirectionalPackageMapper, KuaishouDirectionalPackage> implements IKuaishouDirectionalPackageService {
+
+    @Autowired
+    private IKuaishouTemplateService kuaishouTemplateService;
+    @Autowired
+    private KuaishouDirectionalPackageMapper packageMapper;
+    @Autowired
+    private KuaishouDirectionalPckageRelMapper relMapper;
+    @Autowired
+    private IKuaishouDirectionalPckageRelService relService;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    private KuaishouTemplateMapper templateMapper;
+    @Autowired
+    private IKuaiShouUpdateService updateService;
+    @Autowired
+    private KuaiShouGroupMapper groupMapper;
+    @Autowired
+    private KuaishouTemplateTargetMapper templateTargetMapper;
+
+    @Autowired
+    private IKuaiShouGroupTemplateService groupTemplateService;
+    static ExecutorService executorService = null;
+
+    @Override
+    public Result<Object> createDirectionalPackage(JSONObject requestJson) {
+        KuaishouDirectionalPackage entity = packageMapper.queryEntity(requestJson);
+        if (!Check.isNull(entity)) {
+            return Result.error("该账户下定向包名已存在");
+        }
+        KuaishouDirectionalPackage kuaishouDirectionalPackage = JSONObject.toJavaObject(requestJson, KuaishouDirectionalPackage.class);
+        if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
+            kuaishouDirectionalPackage.setKeyword(JSONObject.toJSONString(requestJson.getJSONArray("keyword")));
+        }
+        kuaishouDirectionalPackage.setDataStatus(1);
+        boolean save = this.save(kuaishouDirectionalPackage);
+        if (save) {
+            return Result.ok("创建成功");
+        }
+        return Result.error("创建失败,定向包存储失败");
+    }
+
+
+    @Override
+    public Result<Object> updateDirectionalPackage(JSONObject requestJson) throws InterruptedException {
+        KuaishouDirectionalPackage entity = packageMapper.selectById(requestJson.getString("id"));
+        if (Check.isNull(entity)) {
+            return Result.error("未获取到定向包");
+        }
+        KuaishouDirectionalPackage kuaishouDirectionalPackage = JSONObject.toJavaObject(requestJson, KuaishouDirectionalPackage.class);
+        if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
+            kuaishouDirectionalPackage.setKeyword(JSONObject.toJSONString(requestJson.getJSONArray("keyword")));
+        }
+        this.saveOrUpdate(kuaishouDirectionalPackage);
+        //获取本项目绑定该定向的账户
+        List<JSONObject> accounts = relMapper.queryRelId(requestJson.getLong("projectId"), requestJson.getString("id"), "account");
+        if (!Check.isNull(accounts)) {
+            for (JSONObject account : accounts) {
+                updateAccountsDirectionalPackage(requestJson, account);
+            }
+        }
+        Thread.sleep(300);
+        //获取本项目绑定该定向的广告组
+        List<JSONObject> units = relMapper.queryRelId(requestJson.getLong("projectId"), requestJson.getString("id"), "unit");
+        if (!Check.isNull(units)) {
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    executorService = Executors.newFixedThreadPool(3);
+                    units.forEach(unit -> {
+                        executorService.submit(new Runnable() {
+                            @Override
+                            public void run() {
+                                try {
+                                    updateUnitsDirectionalPackage(requestJson, unit);
+                                } catch (Exception e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        });
+                    });
+                    log.info("修改广告组定向完成");
+                }
+            };
+            thread.start();
+        }
+        return Result.ok("该项目下定向包已做同步修改");
+    }
+
+    private void updateUnitsDirectionalPackage(JSONObject requestJson, JSONObject unit) {
+        try {
+            Long unitId = unit.getLong("rel_id");
+            QueryWrapper<KuaiShouGroup> queryWrapper = new QueryWrapper();
+            queryWrapper.eq("unit_id", unitId);
+            queryWrapper.last("limit 1");
+            KuaiShouGroup kuaiShouGroup = groupMapper.selectOne(queryWrapper);
+            if (Check.isNull(kuaiShouGroup)) {
+                throw new Exception("未获取到组信息");
+            }
+            CtopOauthToken token = oauthTokenService.getTokenByAccountId(kuaiShouGroup.getAccountId());
+            String sceneIdStr = kuaiShouGroup.getSceneId();
+            if (Check.isNull(sceneIdStr)) {
+                throw new Exception("未获取资源位置");
+            }
+            Integer sceneId = (Integer) JSONArray.parseArray(sceneIdStr).get(0);
+            JSONObject unitJson = new JSONObject();
+            unitJson.put("advertiser_id", kuaiShouGroup.getAccountId());
+            unitJson.put("unit_id", unitId);
+            if (sceneId != 5) {
+                unitJson.put("template_id", unit.getLong("template_id"));
+            } else {
+                JSONObject unionJson = groupTemplateService.getUnionJson(unit.getLong("template_id"));
+                if (Check.isNullMap(unionJson)) {
+                    throw new Exception("根据定向模板未获取到相关信息");
+                }
+                unitJson.put("target", unionJson.getJSONObject("target"));
+            }
+            updateService.updateUnit(token.getAccessToken(), unitJson);
+        } catch (Exception e) {
+            log.error("修改广告组定向异常", e);
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 更新帐户定向包
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void updateAccountsDirectionalPackage(JSONObject requestJson, JSONObject accounEntity) {
+        Long accountId = accounEntity.getLong("rel_id");
+        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+        try {
+            JSONObject param = new JSONObject();
+            param.put("template_id", accounEntity.getLong("template_id"));
+            param.put("advertiser_id", accountId);
+            if (!Check.isNull(requestJson.getString("templateName"))) {
+                param.put("template_name", requestJson.getString("templateName"));
+            }
+            JSONObject targetJson = new JSONObject();
+            if (requestJson.getJSONArray("region") != null) {
+                targetJson.put("region", requestJson.getJSONArray("region"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("districtIds"))) {
+                targetJson.put("district_ids", requestJson.getJSONArray("districtIds"));
+            }
+            if (!Check.isNull(requestJson.getInteger("userType"))) {
+                targetJson.put("user_type", requestJson.getInteger("userType"));
+            }
+            JSONArray agesRange = requestJson.getJSONArray("agesRange");
+            if (!Check.isNull(agesRange)) {
+                targetJson.put("ages_range", agesRange);
+            }
+            Integer min = requestJson.getInteger("min");
+            Integer max = requestJson.getInteger("max");
+            if (!Check.isNull(min) && !Check.isNull(max) && max != -1 && min != -1) {
+                JSONObject ageJson = new JSONObject();
+                ageJson.put("min", requestJson.getInteger("min"));
+                ageJson.put("max", requestJson.getInteger("max"));
+                targetJson.put("age", ageJson);
+            }
+
+            if (!Check.isNull(requestJson.getInteger("gender"))) {
+                targetJson.put("gender", requestJson.getInteger("gender"));
+            }
+            if (!Check.isNull(requestJson.getInteger("platformOs"))) {
+                targetJson.put("platform_os", requestJson.getInteger("platformOs"));
+            }
+            if (!Check.isNull(requestJson.getInteger("androidOsv"))) {
+                targetJson.put("android_osv", requestJson.getInteger("androidOsv"));
+            }
+            if (!Check.isNull(requestJson.getInteger("iosOsv"))) {
+                targetJson.put("ios_osv", requestJson.getInteger("iosOsv"));
+            }
+            if (!Check.isNull(requestJson.getInteger("network"))) {
+                targetJson.put("network", requestJson.getInteger("network"));
+            }
+            if (!Check.isNull(requestJson.getInteger("filterConvertedLevel"))) {
+                targetJson.put("filter_converted_level", requestJson.getInteger("filterConvertedLevel"));
+            }
+            if (requestJson.getJSONArray("deviceBrand") != null) {
+                targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
+            }
+            if (requestJson.getJSONArray("devicePrice") != null) {
+                targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
+            }
+            if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
+                targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
+                targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
+                targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
+                targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
+                targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("appIds"))) {
+                targetJson.put("app_ids", requestJson.getJSONArray("appIds"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("population"))) {
+                targetJson.put("population", requestJson.getJSONArray("population"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("paidAudience"))) {
+                targetJson.put("paid_audience", requestJson.getJSONArray("paidAudience"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
+                targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
+            }
+            if (!Check.isNull(requestJson.getInteger("isOpen"))) {
+                JSONObject intelliExtendJson = new JSONObject();
+                intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
+
+                if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
+                    intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
+                }
+                if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
+                    intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
+                }
+                if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
+                    intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
+                }
+                if (!Check.isNull(intelliExtendJson)) {
+                    targetJson.put("intelli_extend", intelliExtendJson);
+                }
+            }
+            JSONObject behaviorInterest = new JSONObject();
+            JSONObject behavior = new JSONObject();
+            JSONObject interest = new JSONObject();
+            if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
+                behavior.put("keyword", requestJson.getJSONArray("keyword"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("label"))) {
+                behavior.put("label", requestJson.getJSONArray("label"));
+            }
+            if (!Check.isNull(requestJson.getInteger("strengthType"))) {
+                behavior.put("strength_type", requestJson.getInteger("strengthType"));
+            }
+            if (!Check.isNull(requestJson.getInteger("timeType"))) {
+                behavior.put("time_type", requestJson.getInteger("timeType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("sceneType"))) {
+                behavior.put("scene_type", requestJson.getJSONArray("sceneType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("interestLabel"))) {
+                interest.put("label", requestJson.getJSONArray("interestLabel"));
+            }
+            if (!behavior.isEmpty()) {
+                behaviorInterest.put("behavior", behavior);
+            }
+            if (!interest.isEmpty()) {
+                behaviorInterest.put("interest", interest);
+            }
+            if (!behaviorInterest.isEmpty()) {
+                targetJson.put("behavior_interest", behaviorInterest);
+            }
+            if (!Check.isNull(targetJson)) {
+                param.put("target", targetJson);
+            }
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Access-Token", oauthToken.getAccessToken());
+            headers.put("Content-Type", " application/json");
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_UPDATE;
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    kuaishouTemplateService.getTemplateByAccountId(accountId, oauthToken.getAccessToken(), 1);
+                } else {
+                    log.error("修改账户定向失败," + resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            log.error("修改账户定向包异常,账户Id:{}", accountId, e);
+        }
+    }
+
+    @Override
+    public Result<Object> queryList(KuaishouDirectionalPackage directionalPackage, Integer pageNo, Integer pageSize) {
+        Long total = packageMapper.queryListTotal(directionalPackage);
+        PageHelper.startPage(pageNo, pageSize, false);
+        List<JSONObject> list = packageMapper.queryList(directionalPackage);
+        PageInfo pageInfo = new PageInfo(list);
+        pageInfo.setTotal(total);
+        return Result.ok(pageInfo);
+    }
+
+    @Override
+    public Result<Object> getRelatedAccountGroup(String id, Integer type, Long accountId, Integer pageNo, Integer pageSize) {
+        PageInfo pageInfo = null;
+        if (1 == type) {
+            PageHelper.startPage(pageNo, pageSize);
+            pageInfo = new PageInfo(packageMapper.getRelatedAccount(id));
+        } else {
+            PageHelper.startPage(pageNo, pageSize);
+            pageInfo = new PageInfo(packageMapper.getRelatedGroup(id, accountId));
+        }
+        return Result.ok(pageInfo);
+    }
+
+    @Override
+    public Result<Object> pushDirectionalPackage(String id, JSONArray datas) {
+        KuaishouDirectionalPackage directionalPackage = packageMapper.selectById(id);
+        JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(directionalPackage)).toJavaObject(JSONObject.class);
+        if (Check.isNull(data)) {
+            return Result.error("未找到定向包");
+        }
+        for (int i = 0; i < datas.size(); i++) {
+            JSONObject request = datas.getJSONObject(i);
+            createDirectionalPackage(data, request);
+        }
+        return Result.ok("推送完成");
+    }
+
+    private void createDirectionalPackage(JSONObject data, JSONObject request) {
+        Long accountId = request.getLong("accountId");
+        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+        String message = "";
+        KuaishouDirectionalaPckageRel rel = new KuaishouDirectionalaPckageRel();
+        rel.setDirId(data.getString("id"));
+        rel.setRelId(accountId);
+        rel.setRelType("account");
+        rel.setProjectId(data.getLong("projectId"));
+        rel.setTemplateName(data.getString("templateName"));
+        rel.setDataStatus(0);
+        try {
+            JSONObject param = new JSONObject();
+            param.put("advertiser_id", accountId);
+            param.put("template_name", data.getString("templateName"));
+            JSONObject targetJson = new JSONObject();
+            if (data.getJSONArray("region") != null) {
+                targetJson.put("region", data.getJSONArray("region"));
+            }
+            if (!Check.isNull(data.getJSONArray("districtIds"))) {
+                targetJson.put("district_ids", data.getJSONArray("districtIds"));
+            }
+            if (!Check.isNull(data.getInteger("userType"))) {
+                targetJson.put("user_type", data.getInteger("userType"));
+            }
+            if (!Check.isNull(data.getJSONArray("agesRange"))) {
+                targetJson.put("ages_range", data.getJSONArray("agesRange"));
+            }
+
+            Integer min = data.getInteger("min");
+            Integer max = data.getInteger("max");
+            if (!Check.isNull(min) && !Check.isNull(max) && max != -1 && min != -1) {
+                JSONObject ageJson = new JSONObject();
+                ageJson.put("min", data.getInteger("min"));
+                ageJson.put("max", data.getInteger("max"));
+                targetJson.put("age", ageJson);
+            }
+
+            if (!Check.isNull(data.getInteger("gender"))) {
+                targetJson.put("gender", data.getInteger("gender"));
+            }
+            if (!Check.isNull(data.getInteger("platformOs"))) {
+                targetJson.put("platform_os", data.getInteger("platformOs"));
+            }
+            if (!Check.isNull(data.getInteger("androidOsv"))) {
+                targetJson.put("android_osv", data.getInteger("androidOsv"));
+            }
+            if (!Check.isNull(data.getInteger("iosOsv"))) {
+                targetJson.put("ios_osv", data.getInteger("iosOsv"));
+            }
+            if (!Check.isNull(data.getInteger("network"))) {
+                targetJson.put("network", data.getInteger("network"));
+            }
+            if (!Check.isNull(data.getInteger("filterConvertedLevel"))) {
+                targetJson.put("filter_converted_level", data.getInteger("filterConvertedLevel"));
+            }
+            if (data.getJSONArray("deviceBrand") != null) {
+                targetJson.put("device_brand", data.getJSONArray("deviceBrand"));
+            }
+            if (data.getJSONArray("devicePrice") != null) {
+                targetJson.put("device_price", data.getJSONArray("devicePrice"));
+            }
+            if (!Check.isNull(data.getInteger("businessInterestType"))) {
+                targetJson.put("business_interest_type", data.getInteger("businessInterestType"));
+            }
+            if (!Check.isNull(data.getJSONArray("businessInterest"))) {
+                targetJson.put("business_interest", data.getJSONArray("businessInterest"));
+            }
+            if (!Check.isNull(data.getJSONArray("fansStar"))) {
+                targetJson.put("fans_star", data.getJSONArray("fansStar"));
+            }
+            if (!Check.isNull(data.getJSONArray("interestVideo"))) {
+                targetJson.put("interest_video", data.getJSONArray("interestVideo"));
+            }
+            if (!Check.isNull(data.getJSONArray("appInterest"))) {
+                targetJson.put("app_interest", data.getJSONArray("appInterest"));
+            }
+            if (!Check.isNull(data.getJSONArray("appIds"))) {
+                targetJson.put("app_ids", data.getJSONArray("appIds"));
+            }
+            if (!Check.isNull(request.getJSONArray("population"))) {
+                targetJson.put("population", request.getJSONArray("population"));
+                rel.setPopulation(request.getString("population"));
+            }
+            if (!Check.isNull(request.getJSONArray("paidAudience"))) {
+                targetJson.put("paid_audience", request.getJSONArray("paidAudience"));
+                rel.setPaidAudience(request.getString("paidAudience"));
+            }
+            if (!Check.isNull(request.getJSONArray("excludePopulation"))) {
+                targetJson.put("exclude_population", request.getJSONArray("excludePopulation"));
+                rel.setExcludePopulation(request.getString("excludePopulation"));
+            }
+            if (!Check.isNull(data.getInteger("isOpen"))) {
+                JSONObject intelliExtendJson = new JSONObject();
+                intelliExtendJson.put("is_open", data.getInteger("isOpen"));
+
+                if (!Check.isNull(data.getInteger("noAgeBreak"))) {
+                    intelliExtendJson.put("no_age_break", data.getInteger("noAgeBreak"));
+                }
+                if (!Check.isNull(data.getInteger("noGenderBreak"))) {
+                    intelliExtendJson.put("no_gender_break", data.getInteger("noGenderBreak"));
+                }
+                if (!Check.isNull(data.getInteger("noAreaBreak"))) {
+                    intelliExtendJson.put("no_area_break", data.getInteger("noAreaBreak"));
+                }
+                if (!Check.isNull(intelliExtendJson)) {
+                    targetJson.put("intelli_extend", intelliExtendJson);
+                }
+            }
+            //-------------兴趣行为定向
+            JSONObject behaviorInterest = new JSONObject();
+            JSONObject behavior = new JSONObject();
+            JSONObject interest = new JSONObject();
+            if (!Check.isNull(data.getJSONArray("keyword"))) {
+                behavior.put("keyword", data.getJSONArray("keyword"));
+            }
+            if (!Check.isNull(data.getJSONArray("label"))) {
+                behavior.put("label", data.getJSONArray("label"));
+            }
+            if (!Check.isNull(data.getInteger("strengthType"))) {
+                behavior.put("strength_type", data.getInteger("strengthType"));
+            }
+            if (!Check.isNull(data.getInteger("timeType"))) {
+                behavior.put("time_type", data.getInteger("timeType"));
+            }
+            if (!Check.isNull(data.getJSONArray("sceneType"))) {
+                behavior.put("scene_type", data.getJSONArray("sceneType"));
+            }
+            if (!Check.isNull(data.getJSONArray("interestLabel"))) {
+                interest.put("label", data.getJSONArray("interestLabel"));
+            }
+            if (!behavior.isEmpty()) {
+                behaviorInterest.put("behavior", behavior);
+            }
+            if (!interest.isEmpty()) {
+                behaviorInterest.put("interest", interest);
+            }
+            if (!behaviorInterest.isEmpty()) {
+                targetJson.put("behavior_interest", behaviorInterest);
+            }
+            if (!Check.isNull(targetJson)) {
+                param.put("target", targetJson);
+            }
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Access-Token", oauthToken.getAccessToken());
+            headers.put("Content-Type", " application/json");
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_CREATE;
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                message = resultJson.getString("message");
+                if (code == 0) {
+                    kuaishouTemplateService.getTemplateByAccountId(accountId, oauthToken.getAccessToken(), 1);
+                    JSONObject results = resultJson.getJSONObject("data");
+                    rel.setTemplateId(results.getLong("template_id"));
+                    rel.setDataStatus(1);
+                } else {
+                    message = "推送定向包失败," + message;
+                    log.error(message);
+                }
+            } else {
+                message = "推送定向包失败,返回结果为空";
+            }
+        } catch (Exception e) {
+            message = "推送定向包出现异常";
+            log.error(message, e);
+        }
+        rel.setMessage(message);
+        relMapper.replace(rel);
+    }
+
+    @Override
+    public Result<Object> queryPushResults(String id, JSONArray accountIds, String status) {
+        List<JSONObject> list = relMapper.queryPushResults(id, accountIds, status);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+
+    @Override
+    public Result<Object> editPopulation(JSONObject requestJson) {
+        Long accountId = requestJson.getLong("accountId");
+        String message = "";
+        KuaishouDirectionalaPckageRel rel = new KuaishouDirectionalaPckageRel();
+        try {
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            QueryWrapper<KuaishouDirectionalaPckageRel> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("dir_id", requestJson.getString("id"));
+            queryWrapper.eq("rel_id", accountId);
+            queryWrapper.eq("rel_type", "account");
+            queryWrapper.eq("template_id", requestJson.getLong("templateId"));
+            JSONObject param = new JSONObject();
+            param.put("template_id", requestJson.getLong("templateId"));
+            param.put("advertiser_id", accountId);
+            param.put("template_name", requestJson.getString("templateName"));
+            JSONObject targetJson = new JSONObject();
+            targetJson.put("population", requestJson.getJSONArray("population"));
+            rel.setPopulation(requestJson.getString("population"));
+            targetJson.put("paid_audience", requestJson.getJSONArray("paidAudience"));
+            rel.setPaidAudience(requestJson.getString("paidAudience"));
+            targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
+            rel.setExcludePopulation(requestJson.getString("excludePopulation"));
+            if (!Check.isNull(targetJson)) {
+                param.put("target", targetJson);
+            }
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Access-Token", oauthToken.getAccessToken());
+            headers.put("Content-Type", " application/json");
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_UPDATE;
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                message = resultJson.getString("message");
+                if (code == 0) {
+                    kuaishouTemplateService.getTemplateByAccountId(requestJson.getLong("accountId"), oauthToken.getAccessToken(), 1);
+                    JSONObject data = resultJson.getJSONObject("data");
+                    relService.update(rel, queryWrapper);
+                    List<JSONObject> units = relMapper.queryUnitIdByAccountId(requestJson.getString("id"), requestJson.getLong("accountId"));
+                    for (JSONObject unit : units) {
+                        updateUnitsDirectionalPackage(requestJson, unit);
+                    }
+                    return Result.ok("修改成功");
+                } else {
+                    return Result.error("修改失败," + message);
+                }
+            } else {
+                return Result.error("修改失败,返回结果为空");
+            }
+        } catch (Exception e) {
+            log.error("修改定向模板人群包信息异常,账户:{}", accountId, e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("修改失败");
+    }
+
+    @Override
+    public Result<Object> getAccountByProjectId(Long projectId, String id) {
+        List<JSONObject> list = relMapper.getAccountByProjectId(projectId, id);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+    @Override
+    public void createUnitAndTemplate(JSONObject request) throws Exception {
+        try {
+            JSONObject target = templateMapper.queryByTemplateId(request.getLong("templateId"));
+            if (Check.isNull(target)) {
+                throw new Exception("添加广告组和定向模板绑定关系失败");
+            }
+            KuaishouDirectionalaPckageRel relEntity = new KuaishouDirectionalaPckageRel();
+            relEntity.setDirId(target.getString("dir_id"));
+            relEntity.setProjectId(target.getLong("project_id"));
+            relEntity.setTemplateId(request.getLong("templateId"));
+            relEntity.setTemplateName(target.getString("template_name"));
+            relEntity.setDataStatus(1);
+            relEntity.setRelId(request.getLong("unitId"));
+            relEntity.setRelType("unit");
+            relEntity.setExcludePopulation(request.getString("excludePopulation"));
+            relEntity.setPopulation(request.getString("population"));
+            relEntity.setPaidAudience(request.getString("paidAudience"));
+            relMapper.replace(relEntity);
+        } catch (Exception e) {
+            log.error("添加广告组和定向模板绑定关系异常", e);
+        }
+    }
+
+    @Override
+    public Result<Object> queryPopulationById(Long templateId, Long accountId) {
+        KuaishouTemplateTarget target = templateTargetMapper.queryTemplateTarget(templateId, accountId);
+        if (Check.isNull(target)) {
+            return Result.error("为查询到人群包");
+        }
+        JSONObject data = new JSONObject();
+        String excludePopulation = target.getExcludePopulation();
+        if (!Check.isNull(excludePopulation)) {
+            data.put("excludePopulation", JSONArray.parseArray(excludePopulation));
+        }
+        String population = target.getPopulation();
+        if (!Check.isNull(population)) {
+            data.put("population", JSONArray.parseArray(population));
+        }
+        String paidAudience = target.getPaidAudience();
+        if (!Check.isNull(paidAudience)) {
+            data.put("paidAudience", JSONArray.parseArray(paidAudience));
+        }
+        return Result.ok(data);
+    }
+
+}

+ 19 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouDirectionalTemplateRelServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalaPckageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouDirectionalPckageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPckageRelService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 自动投放-定向包详情关系表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-25
+ */
+@Service
+public class KuaishouDirectionalTemplateRelServiceImpl extends ServiceImpl<KuaishouDirectionalPckageRelMapper, KuaishouDirectionalaPckageRel> implements IKuaishouDirectionalPckageRelService {
+
+}

+ 19 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouLandpagePackageRelServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouLandpagePackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageRelService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * 落地页-广告组关联表
+ * @author jeecg-boot
+ * @date   2021-05-11
+ * @version V1.0
+ */
+@Service
+public class KuaishouLandpagePackageRelServiceImpl extends ServiceImpl<KuaishouLandpagePackageRelMapper, KuaishouLandpagePackageRel> implements IKuaishouLandpagePackageRelService {
+
+}

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

@@ -0,0 +1,172 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackage;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouLandpagePackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouLandpagePackageMapper;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouLandpagePackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
+import com.alibaba.fastjson.JSON;
+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 org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 落地页账户项目关联表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-11
+ */
+@Service
+public class KuaishouLandpagePackageServiceImpl extends ServiceImpl<KuaishouLandpagePackageMapper, KuaishouLandpagePackage> implements IKuaishouLandpagePackageService {
+
+    @Autowired
+    private KuaishouLandpagePackageMapper landpagePackageMapper;
+    @Autowired
+    private KuaishouLandpagePackageRelMapper landpagePackageRelMapper;
+    @Autowired
+    private KuaishouLandpagePackageRelServiceImpl landpagePackageRelService;
+
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    @Override
+    public Result<Object> queryPageList(KuaishouLandpagePackage kuaishouLandpagePackage, Integer pageNo, Integer pageSize) {
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> list = landpagePackageMapper.queryPageList(kuaishouLandpagePackage.getAccountId(), kuaishouLandpagePackage.getProjectId());
+        return Result.ok(new PageInfo<JSONObject>(list));
+    }
+
+    @Override
+    public Result<Object> synchronousData(Long projectId) {
+        try {
+            List<UserAllocation> userAllocations = userAllocationMapper.selectAccountListByProjectId(projectId);
+            for (UserAllocation userAllocation : userAllocations) {
+                Long accountId = userAllocation.getAccountId();
+                CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+                String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PAGE_LIST;
+                Map<String, String> headers = new HashMap<>();
+                headers.put("Content-Type", "application/json");
+                headers.put("Access-Token", oauthToken.getAccessToken());
+                Map<String, Object> param = new HashMap<>();
+                param.put("advertiser_id", accountId);
+                param.put("page_size", 500);
+                String result = HttpUtils.httpPostRequest(url, param, headers);
+                JSONObject resultJson = JSON.parseObject(result);
+                if (!Check.isNull(resultJson)) {
+                    if (resultJson.getInteger("code") == 0) {
+                        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+                        if (!Check.isNull(details)) {
+                            List<KuaishouLandpagePackage> landpagePackageList = new ArrayList<>();
+                            for (int i = 0; i < details.size(); i++) {
+                                JSONObject jsonObject = details.getJSONObject(i);
+                                KuaishouLandpagePackage landpagePackage = getEntity(jsonObject);
+                                landpagePackage.setAccountId(accountId);
+                                landpagePackage.setProjectId(projectId);
+                                landpagePackageList.add(landpagePackage);
+                            }
+                            if (!Check.isNull(landpagePackageList)) {
+                                landpagePackageMapper.deleteByAccountId(accountId);
+                                landpagePackageMapper.replaceBatch(landpagePackageList);
+                            }
+
+                        }
+                    } else {
+                        log.error(resultJson.getString("message")+",accountId:"+accountId);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error("同步项目下落地页和账户关联数据异常", e);
+            return Result.error("同步项目下落地页和账户关联数据异常");
+        }
+        return Result.ok("同步成功");
+    }
+
+    /**
+     * 处理对象参数
+     */
+    private KuaishouLandpagePackage getEntity(JSONObject jsonObject) {
+        KuaishouLandpagePackage landpagePackage = new KuaishouLandpagePackage();
+        landpagePackage.setLandpageName(jsonObject.getString("name"));
+        landpagePackage.setSiteId(jsonObject.getLong("id"));
+        landpagePackage.setUrl(jsonObject.getString("url"));
+        landpagePackage.setBizType(jsonObject.getInteger("biz_type"));
+        landpagePackage.setLandpageCreateTime(jsonObject.getSqlDate("create_time"));
+        landpagePackage.setLandpageUpdateTime(jsonObject.getSqlDate("update_time"));
+        JSONArray compsArr = jsonObject.getJSONArray("comps");
+        if (!Check.isNull(compsArr)) {
+            landpagePackage.setComps(JSONObject.toJSONString(compsArr));
+            for (int j = 0; j < compsArr.size(); j++) {
+                JSONObject compJson = compsArr.getJSONObject(j);
+                JSONObject props = compJson.getJSONObject("props");
+                if (!Check.isNull(props)) {
+                    landpagePackage.setAppId(props.getLong("appId"));
+                }
+            }
+        }
+        return landpagePackage;
+    }
+
+    @Override
+    public Result<Object> getRelatedAccounts(Long siteId) {
+        List<JSONObject> list = landpagePackageMapper.getRelatedAccounts(siteId);
+        return Result.ok(new PageInfo<JSONObject>(list));
+    }
+
+    @Override
+    public Result<Object> getRelatedGroups(Long siteId, Long accountId) {
+        List<JSONObject> list = landpagePackageMapper.getRelatedGroups(siteId,accountId);
+        return Result.ok(new PageInfo<JSONObject>(list));
+    }
+
+    @Override
+    public void createLandPageAndUnit(Long siteId, Long creativeId, Long unitId, Long accountId) {
+        try {
+            JSONObject entity = landpagePackageRelMapper.queryByUnitId(siteId, unitId, accountId);
+            if (Check.isNull(entity)) {
+                KuaishouLandpagePackageRel rel = new KuaishouLandpagePackageRel();
+                rel.setUnitId(unitId);
+                rel.setAccountId(accountId);
+                rel.setSiteId(siteId);
+                JSONArray creativeArr = new JSONArray();
+                creativeArr.add(creativeId);
+                rel.setCreativeArr(JSONObject.toJSONString(creativeArr));
+                landpagePackageRelService.save(rel);
+            } else {
+                //不为空,落地页已经绑定过广告组,判断是否是新的创意
+                JSONArray creative_arr = entity.getJSONArray("creative_arr");
+                if (!creative_arr.contains(creativeId)) {
+                    //不包含创意,则添加并更新进数据表中
+                    KuaishouLandpagePackageRel rel = new KuaishouLandpagePackageRel();
+                    creative_arr.add(creativeId);
+                    rel.setCreativeArr(JSONObject.toJSONString(creative_arr));
+                    rel.setId(entity.getLong("id"));
+                    landpagePackageRelMapper.updateById(rel);
+                }
+            }
+        } catch (Exception e) {
+            log.error("绑定落地页与广告组异常", e);
+        }
+    }
+}

+ 74 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouPopulationGroupServiceImpl.java

@@ -0,0 +1,74 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationGroup;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationGroupMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationGroupService;
+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.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 人群包-广告组关联表
+ *
+ * @author jeecg-boot
+ * 2021-05-08
+ * @version V1.0
+ */
+@Service
+public class KuaishouPopulationGroupServiceImpl extends ServiceImpl<KuaishouPopulationGroupMapper, KuaishouPopulationGroup> implements IKuaishouPopulationGroupService {
+
+    @Autowired
+    private KuaishouPopulationGroupMapper populationGroupMapper;
+
+    @Override
+    public void createPopulationAndGroupRel(JSONObject request) throws Exception {
+        try {
+            List<KuaishouPopulationGroup> list = new ArrayList<>();
+            Long accountId = request.getLong("accountId");
+            Long unitId = request.getLong("unitId");
+            KuaishouPopulationGroup populationGroup = null;
+            JSONArray population = request.getJSONArray("population");
+            if (!Check.isNull(population)) {
+                for (Object id : population) {
+                    populationGroup = new KuaishouPopulationGroup();
+                    populationGroup.setAccountId(accountId);
+                    populationGroup.setUnitId(unitId);
+                    populationGroup.setOrientationId(Long.valueOf(String.valueOf(id)));
+                    list.add(populationGroup);
+                }
+            }
+            JSONArray excludePopulation = request.getJSONArray("excludePopulation");
+            if (!Check.isNull(excludePopulation)) {
+                for (Object id : excludePopulation) {
+                    populationGroup = new KuaishouPopulationGroup();
+                    populationGroup.setAccountId(accountId);
+                    populationGroup.setUnitId(unitId);
+                    populationGroup.setOrientationId(Long.valueOf(String.valueOf(id)));
+                    list.add(populationGroup);
+                }
+            }
+            JSONArray paidAudience = request.getJSONArray("paidAudience");
+            if (!Check.isNull(paidAudience)) {
+                for (Object id : paidAudience) {
+                    populationGroup = new KuaishouPopulationGroup();
+                    populationGroup.setAccountId(accountId);
+                    populationGroup.setUnitId(unitId);
+                    populationGroup.setOrientationId(Long.valueOf(String.valueOf(id)));
+                    list.add(populationGroup);
+                }
+            }
+            if (list.size() > 0) {
+                populationGroupMapper.deleteByUnitId(request.getLong("unitId"));
+                populationGroupMapper.replaceBatch(list);
+            }
+        } catch (NumberFormatException e) {
+            log.error("添加广告组和人群包绑定关系异常", e);
+        }
+    }
+}

+ 19 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouPopulationPackageRelServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageRelService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群包模板和账户绑定关系表
+ *
+ * @author jeecg-boot
+ * 2021-05-07
+ * @version V1.0
+ */
+@Service
+public class KuaishouPopulationPackageRelServiceImpl extends ServiceImpl<KuaishouPopulationPackageRelMapper, KuaishouPopulationPackageRel> implements IKuaishouPopulationPackageRelService {
+
+}

+ 356 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouPopulationPackageServiceImpl.java

@@ -0,0 +1,356 @@
+package cn.com.ctop.kuaishou.modules.ai.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.common.module.utils.LoadFileUtil;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackage;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageMapper;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationGroupService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageRelService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * 项目绑定的人群包模板
+ *
+ * @author jeecg-boot
+ * 2021-05-06
+ * @version V1.0
+ */
+@Service
+public class KuaishouPopulationPackageServiceImpl extends ServiceImpl<KuaishouPopulationPackageMapper, KuaishouPopulationPackage> implements IKuaishouPopulationPackageService {
+
+    @Autowired
+    private KuaishouPopulationPackageMapper kuaishouPopulationPackageMapper;
+    @Autowired
+    private KuaishouPopulationPackageRelMapper relMapper;
+    @Autowired
+    private IKuaishouPopulationPackageRelService relService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouPopulationService kuaishouPopulationService;
+    @Autowired
+    private IKuaishouPopulationService iKuaishouPopulationService;
+    @Autowired
+    private IKuaishouPopulationGroupService populationGroupService;
+    @Value("${zip.local.download-path}")
+    private String downloadPath;
+
+    @Override
+    public Result<Object> createEntity(KuaishouPopulationPackage kuaishouPopulationPackage) {
+        QueryWrapper<KuaishouPopulationPackage> wrapper = new QueryWrapper<>();
+        wrapper.eq("project_id", kuaishouPopulationPackage.getProjectId());
+        wrapper.eq("orientation_name", kuaishouPopulationPackage.getOrientationName());
+        wrapper.eq("data_status", 1);
+        wrapper.last("limit 1");
+        KuaishouPopulationPackage checkName = kuaishouPopulationPackageMapper.selectOne(wrapper);
+        if (!Check.isNull(checkName)) {
+            return Result.error("该项目下已存在人群包名,请重新输入!");
+        }
+
+        String url = kuaishouPopulationPackage.getUrl();
+        String newFileUrl = getDownloadPath(url);
+        if (Check.isNull(newFileUrl)) {
+            return Result.error("本地下载文件失败,路径:" + url);
+        }
+        String md5 = null;
+        try {
+            md5 = LoadFileUtil.getMD5(newFileUrl);
+        } catch (IOException e) {
+            log.error("获取MD5签名失败", e);
+        }
+
+        QueryWrapper<KuaishouPopulationPackage> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("project_id", kuaishouPopulationPackage.getProjectId());
+        queryWrapper.eq("signature", md5);
+        queryWrapper.eq("data_status", 1);
+        queryWrapper.last("limit 1");
+        KuaishouPopulationPackage one = kuaishouPopulationPackageMapper.selectOne(queryWrapper);
+        if (!Check.isNull(one)) {
+            return Result.error("该项目已上传过此人群包,人群包名为:" + one.getOrientationName());
+        }
+        kuaishouPopulationPackage.setSignature(md5);
+        kuaishouPopulationPackage.setDataStatus(1);
+        kuaishouPopulationPackage.setStatDate(DateUtils.formatDate(new Date()));
+        this.save(kuaishouPopulationPackage);
+        LoadFileUtil.delFile(newFileUrl);
+        return Result.ok("上传成功");
+    }
+
+    /**
+     * 文件下载到本地的路径
+     */
+    private String getDownloadPath(String url) {
+        StringBuffer path = new StringBuffer();
+        path.append(downloadPath).append(DateUtils.getNowDate(DateUtils.WEB_FORMAT)).append("/").append(UUID.randomUUID().toString()).append("/");
+        if (!url.contains("http")) {
+            url = "https:".concat(url);
+        }
+        return LoadFileUtil.downLoadFromUrl(url, path.toString());
+    }
+
+    @Override
+    public Result<Object> push(JSONArray accountIds, Long id) {
+        KuaishouPopulationPackage pPackage = kuaishouPopulationPackageMapper.selectById(id);
+        if (Check.isNull(pPackage)) {
+            return Result.error("没有获取到人群包");
+        }
+        String newFileUrl = getDownloadPath(pPackage.getUrl());
+        if (Check.isNull(newFileUrl)) {
+            return Result.error("本地下载文件失败,路径:" + pPackage.getUrl());
+        }
+        for (Object account : accountIds) {
+            Long accountId = Long.valueOf(String.valueOf(account));
+            KuaishouPopulationPackageRel relEntity = relMapper.queryEntity(accountId, pPackage.getId());
+            //查询该定向模板下是否存在有效的账户数据,不存在执行推送或者上传。
+            if (Check.isNull(relEntity)) {
+                //查询账户同一主题下可推送的该人群包ID
+                KuaishouPopulationPackageRel populationPackageRel = relMapper.queryPushableCrowdPackage(accountId, pPackage.getId());
+                if (Check.isNull(populationPackageRel)) {
+                    //执行上传操作
+                    uploadAccount(pPackage, accountId, newFileUrl);
+                } else {
+                    //执行跨账户推送操作
+                    pushAccount(populationPackageRel, pPackage, accountId);
+                }
+            }
+        }
+        LoadFileUtil.delFile(newFileUrl);
+        return Result.ok("推送结束");
+    }
+
+
+    /**
+     * 执行推送操作
+     */
+    private void pushAccount(KuaishouPopulationPackageRel populationPackageRel, KuaishouPopulationPackage pPackage, Long accountId) {
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        JSONArray array = new JSONArray();
+        array.add(accountId);
+        JSONObject jsonObject = kuaishouPopulationService.pushAccountsPopulation(token, populationPackageRel.getOrientationId(), array);
+        if (jsonObject.getInteger("code") == 0) {
+            List<KuaishouCrowdPack> list = new ArrayList<>();
+            JSONObject data = jsonObject.getJSONObject("data");
+            if (!Check.isNull(data)) {
+                JSONArray success = data.getJSONArray("success");
+                if (!Check.isNull(success)) {
+                    populationPackageRel.setProjectId(pPackage.getProjectId());
+                    populationPackageRel.setPopId(pPackage.getId());
+                    populationPackageRel.setAccountId(Long.valueOf(String.valueOf(accountId)));
+                    populationPackageRel.setMessage("OK");
+                    populationPackageRel.setStatDate(DateUtils.formatDate(new Date()));
+                }
+                JSONArray fail = data.getJSONArray("fail");
+                if (!Check.isNull(fail)) {
+                    KuaishouPopulationPackageRel fRel = relMapper.queryByAccountId(accountId, populationPackageRel.getOrientationId());
+                    if (Check.isNull(fRel)) {
+                        populationPackageRel = new KuaishouPopulationPackageRel();
+                        populationPackageRel.setProjectId(pPackage.getProjectId());
+                        populationPackageRel.setPopId(pPackage.getId());
+                        populationPackageRel.setSignature(pPackage.getSignature());
+                        populationPackageRel.setDataStatus(0);
+                        populationPackageRel.setOrientationName(pPackage.getOrientationName());
+                        populationPackageRel.setAccountId(accountId);
+                        populationPackageRel.setMessage("推送失败");
+                        populationPackageRel.setStatDate(DateUtils.formatDate(new Date()));
+                    }
+                }
+            }
+        } else {
+            populationPackageRel = new KuaishouPopulationPackageRel();
+            populationPackageRel.setProjectId(pPackage.getProjectId());
+            populationPackageRel.setPopId(pPackage.getId());
+            populationPackageRel.setDataStatus(0);
+            populationPackageRel.setSignature(pPackage.getSignature());
+            populationPackageRel.setAccountId(accountId);
+            populationPackageRel.setOrientationName(pPackage.getOrientationName());
+            populationPackageRel.setMessage(jsonObject.getString("message"));
+            populationPackageRel.setStatDate(DateUtils.formatDate(new Date()));
+        }
+        List<KuaishouPopulationPackageRel> packageRels = new ArrayList(1);
+        packageRels.add(populationPackageRel);
+        relMapper.replaceBatch(packageRels);
+    }
+
+    //**执行上传操作*/
+    private void uploadAccount(KuaishouPopulationPackage pPackage, Long accountId, String newFileUrl) {
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        KuaishouPopulationPackageRel packageRel = null;
+        JSONObject jsonObject = kuaishouPopulationService.updatePopulation(token, pPackage.getType(), pPackage.getOrientationName(), newFileUrl);
+        if (!Check.isNull(jsonObject)) {
+            if (jsonObject.getInteger("code") == 0) {
+                packageRel = JSONObject.toJavaObject(jsonObject.getJSONObject("data"), KuaishouPopulationPackageRel.class);
+                packageRel.setSignature(pPackage.getSignature());
+                packageRel.setMessage(jsonObject.getString("message"));
+                packageRel.setStatDate(DateUtils.formatDate(new Date()));
+                packageRel.setProjectId(pPackage.getProjectId());
+                packageRel.setPopId(pPackage.getId());
+                packageRel.setDataStatus(1);//成功
+            } else {
+                packageRel = new KuaishouPopulationPackageRel();
+                packageRel.setAccountId(accountId);
+                packageRel.setOrientationName(pPackage.getOrientationName());
+                packageRel.setSignature(pPackage.getSignature());
+                packageRel.setMessage(jsonObject.getString("message"));
+                packageRel.setStatDate(DateUtils.formatDate(new Date()));
+                packageRel.setProjectId(pPackage.getProjectId());
+                packageRel.setPopId(pPackage.getId());
+                packageRel.setDataStatus(0);
+            }
+        } else {
+            packageRel = new KuaishouPopulationPackageRel();
+            packageRel.setAccountId(accountId);
+            packageRel.setOrientationName(pPackage.getOrientationName());
+            packageRel.setSignature(pPackage.getSignature());
+            packageRel.setMessage("上传失败,返回结果为空");
+            packageRel.setStatDate(DateUtils.formatDate(new Date()));
+            packageRel.setProjectId(pPackage.getProjectId());
+            packageRel.setPopId(pPackage.getId());
+            packageRel.setDataStatus(0);
+        }
+        List<KuaishouPopulationPackageRel> packageRels = new ArrayList(1);
+        packageRels.add(packageRel);
+        relMapper.replaceBatch(packageRels);
+    }
+
+    @Override
+    public Result<Object> queryPageList(KuaishouPopulationPackage kuaishouPopulationPackage, Integer pageNo, Integer pageSize) {
+        Long total = kuaishouPopulationPackageMapper.queryPageListTotal(kuaishouPopulationPackage.getProjectId(), kuaishouPopulationPackage.getOrientationName());
+        PageHelper.startPage(pageNo, pageSize, false);
+        List<JSONObject> list = kuaishouPopulationPackageMapper.queryPageList(kuaishouPopulationPackage.getProjectId(), kuaishouPopulationPackage.getOrientationName());
+        if (!Check.isNull(list)) {
+            for (JSONObject object : list) {
+                object.put("unitCount", kuaishouPopulationPackageMapper.queryUnitCount(object.getLong("id")));
+            }
+        }
+        PageInfo pageInfo = new PageInfo(list);
+        pageInfo.setTotal(total);
+        return Result.ok(pageInfo);
+    }
+
+    @Override
+    public Result<Object> queryPushResults(Long id, JSONArray accountIds) {
+        List<JSONObject> list = relMapper.queryPushResults(id, accountIds);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+    @Override
+    public Result<Object> queryPushHistory(Long id) {
+        List<JSONObject> list = relMapper.queryPushResults(id, null);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+    @Override
+    public Result<Object> getRelatedAccounts(Long id) {
+        List<JSONObject> list = relMapper.getRelatedAccounts(id);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+    @Override
+    public Result<Object> getRelatedGroups(Long id, Long accountId) {
+        List<JSONObject> list = kuaishouPopulationPackageMapper.getRelatedGroups(id, accountId);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+    @Override
+    public void crowdListQuery() {
+        List<JSONObject> objs = kuaishouPopulationPackageMapper.queryListByStatus();
+        for (JSONObject o : objs) {
+            Long accountId = o.getLong("account_id");
+            Long projectId = o.getLong("project_id");
+            Hashtable newIds = new Hashtable();
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (!Check.isNull(token)) {
+                for (int i = 0; i <= 7; i++) {
+                    if (i != 2) {
+                        JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(accountId, token.getAccessToken(), i);
+                        if (jsonObject.getInteger("code") == 0) {
+                            JSONObject data = jsonObject.getJSONObject("data");
+                            if (!Check.isNull(data)) {
+                                JSONArray details = data.getJSONArray("details");
+                                if (details.size() > 0) {
+                                    List<KuaishouPopulationPackageRel> list = new ArrayList<>();
+                                    for (int j = 0; j < details.size(); j++) {
+                                        JSONObject obj = details.getJSONObject(j);
+                                        KuaishouPopulationPackageRel rel = JSONObject.parseObject(obj.toJSONString(), KuaishouPopulationPackageRel.class);
+                                        newIds.put(rel.getOrientationId(), rel.getOrientationId());
+                                        if (Check.isNull(relMapper.queryByOrientationId(rel.getOrientationId(), rel.getAccountId()))) {
+                                            rel.setProjectId(projectId);
+                                            rel.setDataStatus(1);
+                                            rel.setStatDate(DateUtils.formatDate(new Date()));
+                                            list.add(rel);
+                                        } else {
+                                            rel.setDataStatus(1);
+                                            relMapper.updateStatus(rel);
+                                        }
+                                    }
+                                    if (!Check.isNull(list)) {
+                                        relMapper.replaceBatch(list);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+                //查询现有的人群包ID集
+                List<Long> oldOrientationIds = relMapper.queryByOrientationId(null, accountId);
+                if (oldOrientationIds.size() != newIds.size()) {
+                    for (Long id : oldOrientationIds) {
+                        if (!newIds.contains(id)) {
+                            KuaishouPopulationPackageRel rel = new KuaishouPopulationPackageRel();
+                            rel.setDataStatus(0);
+                            rel.setOrientationId(id);
+                            rel.setAccountId(accountId);
+                            rel.setMessage("人群包已从媒体后台删除");
+                            relMapper.updateStatus(rel);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public Result<Object> getAccountByProjectId(Long projectId, String id) {
+        List<JSONObject> list = relMapper.getAccountByProjectId(projectId, id);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+    @Override
+    public Result<Object> checkPopulationPackage(String signature) {
+        KuaishouPopulationPackage ksPackage = kuaishouPopulationPackageMapper.checkPopulationPackage(signature);
+        if (Check.isNull(ksPackage)) {
+            return Result.ok("success");
+        } else {
+            Result<Object> r = new Result<>();
+            r.setCode(201);
+            r.setMessage("项目已保存过该人群包,名称为:" + ksPackage.getOrientationName());
+            r.setSuccess(true);
+            return r;
+        }
+    }
+
+}

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/DingPanController.java

@@ -157,7 +157,7 @@ public class DingPanController {
                 if (Check.isNullMap(unionJson)) {
                 if (Check.isNullMap(unionJson)) {
                     throw new Exception("根据定向模板未获取到相关信息");
                     throw new Exception("根据定向模板未获取到相关信息");
                 }
                 }
-                unitJson.put("target", unionJson);
+                unitJson.put("target", unionJson.getJSONObject("target"));
             }
             }
             JSONObject jsonObject = updateService.updateUnit(token.getAccessToken(), unitJson);
             JSONObject jsonObject = updateService.updateUnit(token.getAccessToken(), unitJson);
             Integer code = jsonObject.getInteger("code");
             Integer code = jsonObject.getInteger("code");

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

@@ -87,6 +87,7 @@ public class KuaiShouVideoGetController {
                                                              String endDate,
                                                              String endDate,
                                                              String materialType,
                                                              String materialType,
                                                              String channelType,
                                                              String channelType,
+                                                             String signatures,
                                                              String orderBy,
                                                              String orderBy,
                                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@@ -107,6 +108,7 @@ public class KuaiShouVideoGetController {
             if (Check.isNull(orderBy)) {
             if (Check.isNull(orderBy)) {
                 throw new Exception("请传入排序方式");
                 throw new Exception("请传入排序方式");
             }
             }
+
             List<KuaiShouVideoGetVo> list = new ArrayList<>();
             List<KuaiShouVideoGetVo> list = new ArrayList<>();
             PageHelper.startPage(pageNo, pageSize);
             PageHelper.startPage(pageNo, pageSize);
             Map<String, Object> requestMap = new HashMap<>();
             Map<String, Object> requestMap = new HashMap<>();
@@ -114,6 +116,10 @@ public class KuaiShouVideoGetController {
             requestMap.put("orderBy", orderBy);
             requestMap.put("orderBy", orderBy);
             requestMap.put("materialType", materialType);
             requestMap.put("materialType", materialType);
             requestMap.put("channelType", channelType);
             requestMap.put("channelType", channelType);
+            if(!Check.isNull(signatures)){
+                String[] signatureArray =  signatures.split(",");
+                requestMap.put("signatureList", signatureArray);
+            }
             if ("time".equals(orderBy)) {
             if ("time".equals(orderBy)) {
                 if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
                 if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
                     requestMap.put("startDate", startDate);
                     requestMap.put("startDate", startDate);

+ 44 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateController.java

@@ -21,7 +21,15 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.beans.factory.annotation.Autowired;
 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.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.ModelAndView;
@@ -57,9 +65,9 @@ public class KuaishouTemplateController {
     @AutoLog(value = "快手-定向模板-分页列表查询")
     @AutoLog(value = "快手-定向模板-分页列表查询")
     @ApiOperation(value = "快手-定向模板-分页列表查询", notes = "快手-定向模板-分页列表查询")
     @ApiOperation(value = "快手-定向模板-分页列表查询", notes = "快手-定向模板-分页列表查询")
     @GetMapping(value = "/list")
     @GetMapping(value = "/list")
-    public Result<List<JSONObject>> list(Long accountId, Integer platformOs) {
+    public Result<List<JSONObject>> list(Long accountId, Integer platformOs, Boolean autoTarget) {
         Result<List<JSONObject>> result = new Result<>();
         Result<List<JSONObject>> result = new Result<>();
-        List<JSONObject> list = kuaishouTemplateService.getJsonArrByAccountId(accountId, platformOs);
+        List<JSONObject> list = kuaishouTemplateService.getJsonArrByAccountId(accountId, platformOs, autoTarget);
         result.setSuccess(true);
         result.setSuccess(true);
         result.setResult(list);
         result.setResult(list);
         return result;
         return result;
@@ -67,6 +75,39 @@ public class KuaishouTemplateController {
 
 
 
 
     /**
     /**
+     * 获取行为与兴趣"类目词"
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getbehaviorInterest")
+    public Result<Object> getbehaviorInterest(Long accountId) {
+        Result<List<JSONObject>> result = new Result<>();
+        if (Check.isNull(accountId)) {
+            //各账户类目词一致
+            accountId = 23212L;
+        }
+        return kuaishouTemplateService.getBehaviorInterest(accountId);
+    }
+
+    /**
+     * 获取行为兴趣"关键词"
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @PostMapping(value = "/getKeywordQuery")
+    public Result<Object> getKeywordQuery(@RequestBody JSONObject data) {
+        Result<List<JSONObject>> result = new Result<>();
+        return kuaishouTemplateService.getKeywordQuery(data);
+    }
+
+
+    /**
      * 分页列表查询
      * 分页列表查询
      *
      *
      * @param kuaishouTemplate
      * @param kuaishouTemplate

+ 36 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTarget.java

@@ -188,6 +188,42 @@ public class KuaiShouGroupTarget {
     @ApiModelProperty(value = "不可突破地域 0:可突破/无需控制,1:不可突破")
     @ApiModelProperty(value = "不可突破地域 0:可突破/无需控制,1:不可突破")
     private Integer noAreaBreak;
     private Integer noAreaBreak;
     /**
     /**
+     * 行为定向关键词
+     */
+    @Excel(name = "行为定向关键词", width = 15)
+    @ApiModelProperty(value = "行为定向关键词")
+    private String keyword;
+    /**
+     * 行为定向 类目词
+     */
+    @Excel(name = "行为定向 类目词", width = 15)
+    @ApiModelProperty(value = "行为定向 类目词")
+    private String label;
+    /**
+     * 兴趣定向类目词
+     */
+    @Excel(name = "兴趣定向类目词", width = 15)
+    @ApiModelProperty(value = "兴趣定向类目词")
+    private String interestLabel;
+    /**
+     * 在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天
+     */
+    @Excel(name = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天", width = 15)
+    @ApiModelProperty(value = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天")
+    private Integer timeType;
+    /**
+     * 行为强度	0:不限 1:高强度
+     */
+    @Excel(name = "行为强度	0:不限 1:高强度", width = 15)
+    @ApiModelProperty(value = "行为强度	0:不限 1:高强度")
+    private Integer strengthType;
+    /**
+     * 行为场景	1:社区 2:APP 4:推广
+     */
+    @Excel(name = "行为场景	1:社区 2:APP 4:推广", width = 15)
+    @ApiModelProperty(value = "行为场景	1:社区 2:APP 4:推广")
+    private String sceneType;
+    /**
      * 创建时间
      * 创建时间
      */
      */
     @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
     @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTemplate.java

@@ -216,6 +216,7 @@ public class KuaiShouGroupTemplate {
     private String creativeReviewDetail;
     private String creativeReviewDetail;
     private Integer createType;
     private Integer createType;
     private String photoIds;
     private String photoIds;
+    private String schemaUri;
 
 
     /**
     /**
      * 创建时间
      * 创建时间

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouTemplate.java

@@ -53,6 +53,7 @@ public class KuaishouTemplate {
     @Excel(name = "绑定组个数", width = 15)
     @Excel(name = "绑定组个数", width = 15)
     @ApiModelProperty(value = "绑定组个数")
     @ApiModelProperty(value = "绑定组个数")
     private Integer unitCount;
     private Integer unitCount;
+    private Boolean autoTarget;
     /**
     /**
      * 定向模板创建时间
      * 定向模板创建时间
      */
      */

+ 36 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouTemplateTarget.java

@@ -198,6 +198,42 @@ public class KuaishouTemplateTarget {
     @ApiModelProperty(value = "不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)")
     @ApiModelProperty(value = "不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)")
     private Integer noAreaBreak;
     private Integer noAreaBreak;
     /**
     /**
+     * 行为定向关键词
+     */
+    @Excel(name = "行为定向关键词", width = 15)
+    @ApiModelProperty(value = "行为定向关键词")
+    private String keyword;
+    /**
+     * 行为定向 类目词
+     */
+    @Excel(name = "行为定向 类目词", width = 15)
+    @ApiModelProperty(value = "行为定向 类目词")
+    private String label;
+    /**
+     * 兴趣定向类目词
+     */
+    @Excel(name = "兴趣定向类目词", width = 15)
+    @ApiModelProperty(value = "兴趣定向类目词")
+    private String interestLabel;
+    /**
+     * 在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天
+     */
+    @Excel(name = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天", width = 15)
+    @ApiModelProperty(value = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天")
+    private Integer timeType;
+    /**
+     * 行为强度	0:不限 1:高强度
+     */
+    @Excel(name = "行为强度	0:不限 1:高强度", width = 15)
+    @ApiModelProperty(value = "行为强度	0:不限 1:高强度")
+    private Integer strengthType;
+    /**
+     * 行为场景	1:社区 2:APP 4:推广
+     */
+    @Excel(name = "行为场景	1:社区 2:APP 4:推广", width = 15)
+    @ApiModelProperty(value = "行为场景	1:社区 2:APP 4:推广")
+    private String sceneType;
+    /**
      * 定向模板创建时间
      * 定向模板创建时间
      */
      */
     @Excel(name = "定向模板创建时间", width = 15)
     @Excel(name = "定向模板创建时间", width = 15)

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


部分文件因文件數量過多而無法顯示