Explorar el Código

Merge branch 'master' into jiaoyang

# Conflicts:
#	jeecg-boot-module-system/src/main/resources/application-dev.yml
#	jeecg-boot-module-system/src/main/resources/application-test.yml
#	jeecg-boot-module-system/src/main/resources/application-wps.yml
#	jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
#	module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java
#	module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewPlanReportCtrl.java
yumeng hace 4 años
padre
commit
2270eaa0ba
Se han modificado 100 ficheros con 3818 adiciones y 110 borrados
  1. 19 19
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 23 0
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/JsonResourceUtil.java
  3. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  4. 71 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/AiKuaiShouReportAnalyzeCtrl.java
  5. 55 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/AiKuaiShouStrategyListPageCtrl.java
  6. 24 14
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouStrategyController.java
  7. 22 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/StrategyController.java
  8. 270 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BytedanceVideoEtlInfoController.java
  9. 231 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/KuaishouVideoEtlInfoController.java
  10. 143 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialImageVideoInfoController.java
  11. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  12. 16 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  13. 55 19
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  14. 17 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  15. 257 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/BytedanceVideoEtlInfoEntity.java
  16. 292 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/KuaishouVideoEtlInfoEntity.java
  17. 12 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
  18. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserService.java
  19. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
  20. 24 0
      jeecg-boot-module-system/src/main/resources/ads/timing-task.json
  21. 2 2
      jeecg-boot-module-system/src/main/resources/jeecg/jeecg_database.properties
  22. 13 3
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/constant/MatchLogic.java
  23. 3 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/RuleIndicator.java
  24. 4 3
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleAccountThresholdServiceImpl.java
  25. 27 19
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java
  26. 2 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleTemplateServiceImpl.java
  27. 41 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialImageVideoInfo.java
  28. 19 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTargetKuaishou.java
  29. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/SysUser.java
  30. 4 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/CustomDataByAccountMapper.java
  31. 14 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialImageVideoInfoMapper.java
  32. 1 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/SysUserMapper.java
  33. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  34. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialImageVideoInfoMapper.xml
  35. 6 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysUserMapper.xml
  36. 26 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  37. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialCutFrameService.java
  38. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialImageInfoService.java
  39. 14 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialImageVideoInfoService.java
  40. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMessageTemplate.java
  41. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  42. 10 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialCutFrameServiceImpl.java
  43. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialImageInfoServiceImpl.java
  44. 18 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialImageVideoInfoServiceImpl.java
  45. 16 3
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java
  46. 14 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  47. 9 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  48. 0 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/LoadFileUtil.java
  49. 0 5
      module-job-bytedance/pom.xml
  50. 4 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ByteDancePlanRuleDataJob.java
  51. 24 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceEtlVideoJob.java
  52. 0 6
      module-job-kuaishou/pom.xml
  53. 36 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAiAdsNewMaterialCreativityJob.java
  54. 3 3
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAudienceReportJob.java
  55. 1 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEffectVideoJob.java
  56. 24 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEtlVideoJob.java
  57. 104 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouVideoRelateCreativesJob.java
  58. 135 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouCreateController.java
  59. 245 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouMaterialControer.java
  60. 77 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountTargetTemplate.java
  61. 42 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouStrategyMapCreative.java
  62. 41 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouStrategyMiddle.java
  63. 37 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouStrategyTargetBase.java
  64. 30 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouStrategyTargetDetails.java
  65. 40 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouStrategyTargetUnion.java
  66. 46 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouStrategyTemplate.java
  67. 56 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaiShouVideoLastTime.java
  68. 23 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaiShouStrategyListPageMapper.java
  69. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAccountTargetTemplateMapper.java
  70. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouStrategyMapCreativeMapper.java
  71. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouStrategyMiddleMapper.java
  72. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouStrategyTargetBaseMapper.java
  73. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouStrategyTargetDetailsMapper.java
  74. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouStrategyTargetUnionMapper.java
  75. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouStrategyTemplateMapper.java
  76. 33 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/IAiKuaiShouReportAnalyzeMapper.java
  77. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaiShouVideoLastTimeMapper.java
  78. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountTargetTemplateMapper.xml
  79. 465 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouReportAnalyzeMapper.xml
  80. 192 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouStrategyListPageMapper.xml
  81. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouStrategyMapCreativeMapper.xml
  82. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouStrategyMiddleMapper.xml
  83. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouStrategyTargetBaseMapper.xml
  84. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouStrategyTargetDetailsMapper.xml
  85. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouStrategyTargetUnionMapper.xml
  86. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouStrategyTemplateMapper.xml
  87. 12 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaiShouVideoLastTimeMapper.xml
  88. 23 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaiShouReportAnalyzeService.java
  89. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaiShouStrategyListPageService.java
  90. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountTargetTemplateService.java
  91. 9 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouNewCreateCampaign.java
  92. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouStrategyMapCreativeService.java
  93. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouStrategyMiddleService.java
  94. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouStrategyService.java
  95. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouStrategyTargetBaseService.java
  96. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouStrategyTargetDetailsService.java
  97. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouStrategyTargetUnionService.java
  98. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouStrategyTemplateService.java
  99. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiStrategyService.java
  100. 0 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaiShouCreateService.java

+ 19 - 19
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -10,14 +10,7 @@ import java.sql.Timestamp;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * 类描述:时间操作定义类
@@ -831,21 +824,28 @@ public class DateUtils extends PropertyEditorSupport {
     }
 
 
-    public static void main(String[] args) throws ParseException {
-        /*Date date = stampToTime(1599458521L);
-        String s = formatDate(date);
-        System.err.println(s);*/
-        Long s1 = timeToStamp("2020-09-23 21:30:00");
-        System.err.println(s1);
+    public static int getdaysOfTwoDate(String minDate, String date) {
+        Date bigDate = parseDate(date, "yyyy-MM-dd");
+        Date smallDate = parseDate(minDate, "yyyy-MM-dd");
+        int days = (int) ((bigDate.getTime() - smallDate.getTime()) / (1000 * 3600 * 24));
+        return days + 1;
     }
 
-    public static int getdaysOfTwoDate(String minDate, String date) {
-        Date bigDate = parseDate(date,"yyyy-MM-dd");
-        Date smallDate = parseDate(minDate,"yyyy-MM-dd");
-        int days = (int) ((bigDate.getTime() - smallDate.getTime()) / (1000*3600*24));
-        return days+1;
+
+    /**
+     * 当前时间前推
+     *
+     * @param endDate
+     * @param i
+     * @return
+     */
+    public static Date addTime(Date endDate, int i) {
+        Long time = Long.valueOf(i * 1000 * 60);
+        Long time1 = endDate.getTime() - time;
+        return new Date(time1);
     }
 
+
     /**
      * String类型 转换为Date, 如果参数长度为10 转换格式”yyyy-MM-dd“ 如果参数长度为19 转换格式”yyyy-MM-dd
      * HH:mm:ss“ * @param text String类型的时间值

+ 23 - 0
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/JsonResourceUtil.java

@@ -49,6 +49,29 @@ public class JsonResourceUtil {
         return json;
     }
 
+    //json文件转化为JSONArray
+    public static JSONArray getJsonArrFromResource(String filename) {
+        JSONArray json = null;
+        if (!filename.contains(".json")) {
+            filename += ".json";
+        }
+        try {
+            ClassPathResource classPathResource = new ClassPathResource(filename);
+            if (classPathResource.exists()) {
+                InputStream inputStream = classPathResource.getInputStream();
+                String content = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+                json = JSON.parseArray(content);
+            } else {
+                logger.info("file not exist!");
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.info("readFileToString" + e.getMessage());
+        }
+        return json;
+    }
+
     public static Map<String, Map<String, Object>> jsonToMap(Object jsonObj) {
         JSONObject jsonObject = JSONObject.parseObject(jsonObj.toString());
         Map<String, Map<String, Object>> mapMap = new HashMap<>();

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

@@ -181,6 +181,8 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/shiwan/shiwanFileUpload/*", "anon");
         filterChainDefinitionMap.put("/oa/wechatNoList/*", "anon");
         filterChainDefinitionMap.put("/ruleGroup/*", "anon");
+        filterChainDefinitionMap.put("/kuaishou/material/*", "anon");
+        filterChainDefinitionMap.put("/kuaishou/create/*", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 71 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/AiKuaiShouReportAnalyzeCtrl.java

@@ -0,0 +1,71 @@
+package org.jeecg.modules.ads.controller;
+
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouReportAnalyzeService;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+@RequestMapping("/ai/analyze")
+@RestController
+public class AiKuaiShouReportAnalyzeCtrl {
+
+    @Autowired
+    IAiKuaiShouReportAnalyzeService aiKuaiShouReportAnalyzeService;
+
+    @GetMapping("/getStrategyAndTarget")
+    public Result<List<JSONObject>> getStrategyAndTarget(@RequestParam("accountId") Long accountId){
+        Result<List<JSONObject>> result=new Result<>();
+        result.setResult(aiKuaiShouReportAnalyzeService.getStrategyAndTarget(accountId));
+        result.setSuccess(true);
+        return result;
+    }
+
+    @GetMapping("/getStrategyAndMaterial")
+    public Result<List<JSONObject>> getStrategyAndMaterial(@RequestParam("accountId") Long accountId){
+        Result<List<JSONObject>> result=new Result<>();
+        result.setResult(aiKuaiShouReportAnalyzeService.getStrategyAndMaterial(accountId));
+        result.setSuccess(true);
+        return result;
+    }
+
+    @PostMapping("/report/targetOrMaterial")
+    public Result<PageInfo<JSONObject>> targetOrMaterialReport(@RequestBody JSONObject params){
+        Result<PageInfo<JSONObject>> result=new Result<>();
+        if(params.isEmpty()){
+            result.error500("参数为空");
+        }else {
+            if(params.getString("type").equals("target")){
+                result.setResult(aiKuaiShouReportAnalyzeService.getTargetReportBy(params));
+            }
+            else if(params.getString("type").equals("material")){
+                result.setResult(aiKuaiShouReportAnalyzeService.getMaterialReportBy(params));
+            }
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    //TODO 先不加时间维度,现在是t-2
+    @PostMapping("/chart/targetOrMaterial")
+    public Result<Map<String,Object>> targetOrMaterialChart(@RequestBody JSONObject params){
+        Result<Map<String,Object>> result=new Result<>();
+        if(params.isEmpty()){
+            result.error500("参数为空");
+        }else {
+            if(params.getString("type").equals("target")){
+                result.setResult(aiKuaiShouReportAnalyzeService.getTargetChartBy(params));
+            }
+            else if(params.getString("type").equals("material")){
+                result.setResult(aiKuaiShouReportAnalyzeService.getMaterialChartBy(params));
+            }
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+}

+ 55 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/AiKuaiShouStrategyListPageCtrl.java

@@ -0,0 +1,55 @@
+package org.jeecg.modules.ads.controller;
+
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouStrategyListPageService;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+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.RestController;
+
+@RequestMapping("/ai/list")
+@RestController
+public class AiKuaiShouStrategyListPageCtrl {
+
+    @Autowired
+    IAiKuaiShouStrategyListPageService aiKuaiShouStrategyListPageService;
+
+    @PostMapping("/pageStrategy")
+    public Result<PageInfo<JSONObject>> pageStrategy(@RequestBody JSONObject params){
+        Result<PageInfo<JSONObject>> result=new Result<>();
+        if(params.isEmpty()){
+            result.error500("参数为空");
+        }else {
+            result.setSuccess(true);
+            result.setResult(aiKuaiShouStrategyListPageService.pageStrategy(params));
+        }
+        return result;
+    }
+
+    @PostMapping("/pageCampaign")
+    public Result<PageInfo<JSONObject>> pageCampaign(@RequestBody JSONObject params){
+        Result<PageInfo<JSONObject>> result=new Result<>();
+        if(params.isEmpty()){
+            result.error500("参数为空");
+        }else {
+            result.setSuccess(true);
+            result.setResult(aiKuaiShouStrategyListPageService.pageCampaign(params));
+        }
+        return result;
+    }
+
+    @PostMapping("/pageUnit")
+    public Result<PageInfo<JSONObject>> pageUnit(@RequestBody JSONObject params){
+        Result<PageInfo<JSONObject>> result=new Result<>();
+        if(params.isEmpty()){
+            result.error500("参数为空");
+        }else {
+            result.setSuccess(true);
+            result.setResult(aiKuaiShouStrategyListPageService.pageUnit(params));
+        }
+        return result;
+    }
+}

+ 24 - 14
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouStrategyController.java

@@ -1,7 +1,8 @@
-package cn.com.ctop.kuaishou.modules.batch.controller;
+package org.jeecg.modules.ads.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiStrategyService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouStrategyService;
 import com.alibaba.fastjson.JSON;
@@ -13,8 +14,10 @@ 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.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -22,14 +25,7 @@ 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.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
@@ -57,6 +53,8 @@ import java.util.Map;
 public class KuaishouStrategyController {
     @Autowired
     private IKuaishouStrategyService kuaishouStrategyService;
+    @Autowired
+    private IAiStrategyService strategyService;
 
     /**
      * 分页列表查询
@@ -82,15 +80,12 @@ public class KuaishouStrategyController {
         result.setResult(pageList);
         return result;
     }
-
     /**
      * 添加
      *
-     * @param kuaishouStrategy
+     * @param data
      * @return
      */
-    @AutoLog(value = "kuaishou.modules.batch-优化评估策略表-添加")
-    @ApiOperation(value = "kuaishou.modules.batch-优化评估策略表-添加", notes = "kuaishou.modules.batch-优化评估策略表-添加")
     @PostMapping(value = "/add")
     public Result<Object> add(@RequestBody JSONObject data) {
         Result<Object> result = new Result<>();
@@ -98,8 +93,23 @@ public class KuaishouStrategyController {
             if (Check.isNull(data.getLong("accountId"))) {
                 return Result.error(-1, "请选择账户");
             }
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
             KuaishouStrategy strategy = JSONObject.toJavaObject(data, KuaishouStrategy.class);
+            JSONArray appStore = data.getJSONArray("appStore");
+            if(null!=appStore&&!appStore.isEmpty()){
+                strategy.setAppStore(appStore.toJSONString());
+            }
+            JSONArray siteId = data.getJSONArray("siteId");
+            if(null!=siteId&&!siteId.isEmpty()){
+                strategy.setSiteId(siteId.toJSONString());
+            }
+            JSONArray creativeTag = data.getJSONArray("creativeTag");
+            if(null!=creativeTag&&!creativeTag.isEmpty()){
+                strategy.setCreativeTag(creativeTag.toJSONString());
+            }
+            strategy.setCreateBy(user.getId());
             kuaishouStrategyService.save(strategy);
+            strategyService.createCreativeByStrategy(strategy);
             result.success("添加成功!");
         } catch (Exception e) {
             log.error(e.getMessage(), e);
@@ -111,7 +121,7 @@ public class KuaishouStrategyController {
     /**
      * 编辑
      *
-     * @param kuaishouStrategy
+     * @param
      * @return
      */
     @AutoLog(value = "kuaishou.modules.batch-优化评估策略表-编辑")

+ 22 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/StrategyController.java

@@ -0,0 +1,22 @@
+package org.jeecg.modules.ads.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+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.RestController;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@Slf4j
+@RequestMapping("/ctop/strategy")
+public class StrategyController {
+    @PostMapping("previewCreative")
+    public Map<String,Object> previewCreative(@RequestBody JSONObject data){
+        Map<String,Object>result = new HashMap<>();
+        return result;
+    }
+}

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

@@ -0,0 +1,270 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.vo.SheetInfoVo;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoEtlInfoService;
+import com.alibaba.excel.EasyExcelFactory;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.metadata.Sheet;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.excelutil.entity.BytedanceVideoEtlInfoEntity;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+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 javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 头条视频信息清洗
+ * @author jeecg-boot
+ * @date   2020-12-25
+ * @version V1.0
+ */
+@Slf4j
+@RestController
+@RequestMapping("/ctop/bytedanceVideoEtlInfo")
+public class BytedanceVideoEtlInfoController {
+	@Autowired
+	private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
+
+	/**
+	  * 分页列表查询
+	 * @param bytedanceVideoEtlInfo
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@GetMapping(value = "/list")
+	public Result<IPage<BytedanceVideoEtlInfo>> queryPageList(BytedanceVideoEtlInfo bytedanceVideoEtlInfo,
+															  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+															  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+															  HttpServletRequest req) {
+		Result<IPage<BytedanceVideoEtlInfo>> result = new Result<>();
+		String type = bytedanceVideoEtlInfo.getType();
+		bytedanceVideoEtlInfo.setType(null);
+		String startDate = bytedanceVideoEtlInfo.getStartDate();
+		bytedanceVideoEtlInfo.setStartDate(null);
+		String endDate = bytedanceVideoEtlInfo.getEndDate();
+		bytedanceVideoEtlInfo.setEndDate(null);
+		QueryWrapper<BytedanceVideoEtlInfo> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceVideoEtlInfo, req.getParameterMap());
+		if(null!=type&&!type.equals("")){
+			if(type.trim().equals("valid")){
+				//有效
+				if(null!=startDate&&!"".equals(startDate.trim())){
+					queryWrapper.ge("effect_date",startDate);
+				}
+				if(null!=endDate&&!"".equals(endDate.trim())){
+					queryWrapper.le("effect_date",endDate);
+				}
+				queryWrapper.le("effect_day_num",7);
+			}else if(type.trim().equals("hot")){
+				//爆款
+				if(null!=startDate&&!"".equals(startDate.trim())){
+					queryWrapper.ge("faddish_date",startDate);
+				}
+				if(null!=endDate&&!"".equals(endDate.trim())){
+					queryWrapper.le("faddish_date",endDate);
+				}
+				queryWrapper.le("faddish_day_num",30);
+			}else {
+				//上线
+				if(null!=startDate&&!"".equals(startDate.trim())){
+					queryWrapper.ge("state_date",startDate);
+				}
+				if(null!=endDate&&!"".equals(endDate.trim())){
+					queryWrapper.le("state_date",endDate);
+				}
+			}
+		}
+		queryWrapper.orderByDesc("total_cost");
+		Page<BytedanceVideoEtlInfo> page = new Page<BytedanceVideoEtlInfo>(pageNo, pageSize);
+		IPage<BytedanceVideoEtlInfo> pageList = bytedanceVideoEtlInfoService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param bytedanceVideoEtlInfo
+	 * @return
+	 */
+	@PostMapping(value = "/add")
+	public Result<BytedanceVideoEtlInfo> add(@RequestBody BytedanceVideoEtlInfo bytedanceVideoEtlInfo) {
+		Result<BytedanceVideoEtlInfo> result = new Result<>();
+		try {
+			bytedanceVideoEtlInfoService.save(bytedanceVideoEtlInfo);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param bytedanceVideoEtlInfo
+	 * @return
+	 */
+	@PutMapping(value = "/edit")
+	public Result<BytedanceVideoEtlInfo> edit(@RequestBody BytedanceVideoEtlInfo bytedanceVideoEtlInfo) {
+		Result<BytedanceVideoEtlInfo> result = new Result<BytedanceVideoEtlInfo>();
+		BytedanceVideoEtlInfo bytedanceVideoEtlInfoEntity = bytedanceVideoEtlInfoService.getById(bytedanceVideoEtlInfo.getId());
+		if(bytedanceVideoEtlInfoEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = bytedanceVideoEtlInfoService.updateById(bytedanceVideoEtlInfo);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@GetMapping(value = "/queryById")
+	public Result<BytedanceVideoEtlInfo> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<BytedanceVideoEtlInfo> result = new Result<>();
+		BytedanceVideoEtlInfo bytedanceVideoEtlInfo = bytedanceVideoEtlInfoService.getById(id);
+		if(bytedanceVideoEtlInfo==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(bytedanceVideoEtlInfo);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+
+  /**
+      * 导出excel
+   *
+   * @param request
+   * @param response
+   */
+  @PostMapping(value = "/exportXls")
+  public void exportXls(BytedanceVideoEtlInfo bytedanceVideoEtlInfo,
+								HttpServletRequest request, HttpServletResponse response)throws Exception {
+      // Step.1 组装查询条件
+	  String type = bytedanceVideoEtlInfo.getType();
+	  bytedanceVideoEtlInfo.setType(null);
+	  String startDate = bytedanceVideoEtlInfo.getStartDate();
+	  bytedanceVideoEtlInfo.setStartDate(null);
+	  String endDate = bytedanceVideoEtlInfo.getEndDate();
+	  bytedanceVideoEtlInfo.setEndDate(null);
+	  QueryWrapper<BytedanceVideoEtlInfo> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceVideoEtlInfo, request.getParameterMap());
+	  if(null!=type&&!type.equals("")){
+		  if(type.trim().equals("valid")){
+			  //有效
+			  if(null!=startDate&&!"".equals(startDate.trim())){
+				  queryWrapper.ge("effect_date",startDate);
+			  }
+			  if(null!=endDate&&!"".equals(endDate.trim())){
+				  queryWrapper.le("effect_date",endDate);
+			  }
+			  queryWrapper.le("effect_day_num",7);
+		  }else if(type.trim().equals("hot")){
+			  //爆款
+			  if(null!=startDate&&!"".equals(startDate.trim())){
+				  queryWrapper.ge("faddish_date",startDate);
+			  }
+			  if(null!=endDate&&!"".equals(endDate.trim())){
+				  queryWrapper.le("faddish_date",endDate);
+			  }
+			  queryWrapper.le("faddish_day_num",30);
+		  }else {
+			  //上线
+			  if(null!=startDate&&!"".equals(startDate.trim())){
+				  queryWrapper.ge("state_date",startDate);
+			  }
+			  if(null!=endDate&&!"".equals(endDate.trim())){
+				  queryWrapper.le("state_date",endDate);
+			  }
+		  }
+	  }
+	  queryWrapper.orderByDesc("total_cost");
+	  List<BytedanceVideoEtlInfo> pageList = bytedanceVideoEtlInfoService.list(queryWrapper);
+
+	  //查询总的消耗信息
+	  SheetInfoVo totalSheetVo = new SheetInfoVo<BytedanceVideoEtlInfoEntity>();
+	  List<BytedanceVideoEtlInfoEntity> details = new ArrayList<>();
+	  if(null!=pageList&&!pageList.isEmpty()){
+		pageList.forEach(etlInfo->{
+			details.add(new BytedanceVideoEtlInfoEntity(etlInfo));
+		});
+		totalSheetVo.setDetails(details);
+	  }
+	  totalSheetVo.setSheetName("头条视频数据统计列表");
+	  OutputStream outputStream = response.getOutputStream();
+	  String date = DateUtils.formatDate(new Date());
+	  HttpUtils.setResponseHeader(response, "头条视频数据统计列表" + date + ".xlsx");
+	  ExcelWriter excelWriter = EasyExcelFactory.getWriter(outputStream);
+
+	  Sheet sheet = new Sheet(1, 0, BytedanceVideoEtlInfoEntity.class);
+	  sheet.setSheetName(totalSheetVo.getSheetName());
+	  excelWriter.write(totalSheetVo.getDetails(), sheet);
+	  excelWriter.finish();
+	  outputStream.flush();
+	  outputStream.close();
+  }
+
+  /**
+      * 通过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<BytedanceVideoEtlInfo> listBytedanceVideoEtlInfos = ExcelImportUtil.importExcel(file.getInputStream(), BytedanceVideoEtlInfo.class, params);
+              bytedanceVideoEtlInfoService.saveBatch(listBytedanceVideoEtlInfos);
+              return Result.ok("文件导入成功!数据行数:" + listBytedanceVideoEtlInfos.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("文件导入失败!");
+  }
+
+}

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

@@ -0,0 +1,231 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.vo.SheetInfoVo;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouVideoEtlInfo;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
+import com.alibaba.excel.EasyExcelFactory;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.metadata.Sheet;
+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 lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.excelutil.entity.BytedanceVideoEtlInfoEntity;
+import org.jeecg.modules.excelutil.entity.KuaishouVideoEtlInfoEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+ /**
+ * 快手视频信息清洗
+ * @author jeecg-boot
+ * @date   2020-12-25
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="快手视频信息清洗")
+@RestController
+@RequestMapping("/ctop/kuaishouVideoEtlInfo")
+public class KuaishouVideoEtlInfoController {
+	@Autowired
+	private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
+
+	/**
+	  * 分页列表查询
+	 * @param kuaishouVideoEtlInfo
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@GetMapping(value = "/list")
+	public Result<IPage<KuaishouVideoEtlInfo>> queryPageList(KuaishouVideoEtlInfo kuaishouVideoEtlInfo,
+															 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+															 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+															 HttpServletRequest req) {
+		Result<IPage<KuaishouVideoEtlInfo>> result = new Result<>();
+		String type = kuaishouVideoEtlInfo.getType();
+		kuaishouVideoEtlInfo.setType(null);
+		String startDate = kuaishouVideoEtlInfo.getStartDate();
+		kuaishouVideoEtlInfo.setStartDate(null);
+		String endDate = kuaishouVideoEtlInfo.getEndDate();
+		kuaishouVideoEtlInfo.setEndDate(null);
+		QueryWrapper<KuaishouVideoEtlInfo> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouVideoEtlInfo, req.getParameterMap());
+		if(null!=type&&!type.equals("")){
+			if(type.trim().equals("valid")){
+				//有效
+				if(null!=startDate&&!"".equals(startDate.trim())){
+					queryWrapper.ge("effect_date",startDate);
+				}
+				if(null!=endDate&&!"".equals(endDate.trim())){
+					queryWrapper.le("effect_date",endDate);
+				}
+				queryWrapper.lt("effect_day_num",7);
+			}else if(type.trim().equals("hot")){
+				//爆款
+				if(null!=startDate&&!"".equals(startDate.trim())){
+					queryWrapper.ge("faddish_date",startDate);
+				}
+				if(null!=endDate&&!"".equals(endDate.trim())){
+					queryWrapper.le("faddish_date",endDate);
+				}
+				queryWrapper.le("faddish_day_num",30);
+			}else {
+				//上线
+				if(null!=startDate&&!"".equals(startDate.trim())){
+					queryWrapper.ge("state_date",startDate);
+				}
+				if(null!=endDate&&!"".equals(endDate.trim())){
+					queryWrapper.le("state_date",endDate);
+				}
+			}
+		}
+		queryWrapper.orderByDesc("total_cost");
+		Page<KuaishouVideoEtlInfo> page = new Page<KuaishouVideoEtlInfo>(pageNo, pageSize);
+		IPage<KuaishouVideoEtlInfo> pageList = kuaishouVideoEtlInfoService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param kuaishouVideoEtlInfo
+	 * @return
+	 */
+	@PostMapping(value = "/add")
+	public Result<KuaishouVideoEtlInfo> add(@RequestBody KuaishouVideoEtlInfo kuaishouVideoEtlInfo) {
+		Result<KuaishouVideoEtlInfo> result = new Result<>();
+		try {
+			kuaishouVideoEtlInfoService.save(kuaishouVideoEtlInfo);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param kuaishouVideoEtlInfo
+	 * @return
+	 */
+	@PutMapping(value = "/edit")
+	public Result<KuaishouVideoEtlInfo> edit(@RequestBody KuaishouVideoEtlInfo kuaishouVideoEtlInfo) {
+		Result<KuaishouVideoEtlInfo> result = new Result<KuaishouVideoEtlInfo>();
+		KuaishouVideoEtlInfo kuaishouVideoEtlInfoEntity = kuaishouVideoEtlInfoService.getById(kuaishouVideoEtlInfo.getId());
+		if(kuaishouVideoEtlInfoEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = kuaishouVideoEtlInfoService.updateById(kuaishouVideoEtlInfo);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@GetMapping(value = "/queryById")
+	public Result<KuaishouVideoEtlInfo> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<KuaishouVideoEtlInfo> result = new Result<>();
+		KuaishouVideoEtlInfo kuaishouVideoEtlInfo = kuaishouVideoEtlInfoService.getById(id);
+		if(kuaishouVideoEtlInfo==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(kuaishouVideoEtlInfo);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+
+  /**
+      * 导出excel
+   *
+   * @param request
+   * @param response
+   */
+  @PostMapping(value = "/exportXls")
+  public void exportXls(KuaishouVideoEtlInfo kuaishouVideoEtlInfo,
+								HttpServletRequest request, HttpServletResponse response) throws Exception{
+	  // Step.1 组装查询条件
+	  // Step.1 组装查询条件
+	  String type = kuaishouVideoEtlInfo.getType();
+	  kuaishouVideoEtlInfo.setType(null);
+	  String startDate = kuaishouVideoEtlInfo.getStartDate();
+	  kuaishouVideoEtlInfo.setStartDate(null);
+	  String endDate = kuaishouVideoEtlInfo.getEndDate();
+	  kuaishouVideoEtlInfo.setEndDate(null);
+	  QueryWrapper<KuaishouVideoEtlInfo> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouVideoEtlInfo, request.getParameterMap());
+	  if(null!=type&&!type.equals("")){
+		  if(type.trim().equals("valid")){
+			  //有效
+			  if(null!=startDate&&!"".equals(startDate.trim())){
+				  queryWrapper.ge("effect_date",startDate);
+			  }
+			  if(null!=endDate&&!"".equals(endDate.trim())){
+				  queryWrapper.le("effect_date",endDate);
+			  }
+			  queryWrapper.lt("effect_day_num",7);
+		  }else if(type.trim().equals("hot")){
+			  //爆款
+			  if(null!=startDate&&!"".equals(startDate.trim())){
+				  queryWrapper.ge("faddish_date",startDate);
+			  }
+			  if(null!=endDate&&!"".equals(endDate.trim())){
+				  queryWrapper.le("faddish_date",endDate);
+			  }
+			  queryWrapper.lt("faddish_day_num",30);
+		  }else {
+			  //上线
+			  if(null!=startDate&&!"".equals(startDate.trim())){
+				  queryWrapper.ge("state_date",startDate);
+			  }
+			  if(null!=endDate&&!"".equals(endDate.trim())){
+				  queryWrapper.le("state_date",endDate);
+			  }
+		  }
+	  }
+	  queryWrapper.orderByDesc("total_cost");
+	  List<KuaishouVideoEtlInfo> pageList = kuaishouVideoEtlInfoService.list(queryWrapper);
+
+	  //查询总的消耗信息
+	  SheetInfoVo totalSheetVo = new SheetInfoVo<KuaishouVideoEtlInfoEntity>();
+	  List<KuaishouVideoEtlInfoEntity> details = new ArrayList<>();
+	  if(null!=pageList&&!pageList.isEmpty()){
+		  pageList.forEach(etlInfo->{
+			  details.add(new KuaishouVideoEtlInfoEntity(etlInfo));
+		  });
+		  totalSheetVo.setDetails(details);
+	  }
+	  totalSheetVo.setSheetName("头条视频数据统计列表");
+	  OutputStream outputStream = response.getOutputStream();
+	  String date = DateUtils.formatDate(new Date());
+	  HttpUtils.setResponseHeader(response, "头条视频数据统计列表" + date + ".xlsx");
+	  ExcelWriter excelWriter = EasyExcelFactory.getWriter(outputStream);
+
+	  Sheet sheet = new Sheet(1, 0, KuaishouVideoEtlInfoEntity.class);
+	  sheet.setSheetName(totalSheetVo.getSheetName());
+	  excelWriter.write(totalSheetVo.getDetails(), sheet);
+	  excelWriter.finish();
+	  outputStream.flush();
+	  outputStream.close();
+  }
+}

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

@@ -0,0 +1,143 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.common.module.entity.MaterialImageVideoInfo;
+import cn.com.ctop.common.module.service.IMaterialImageVideoInfoService;
+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 lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+
+/**
+ * 视频封面关联表信息
+ * @author jeecg-boot
+ * @date   2020-12-17
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="视频封面关联表信息")
+@RestController
+@RequestMapping("/com.cn/materialImageVideoInfo")
+public class MaterialImageVideoInfoController {
+	@Autowired
+	private IMaterialImageVideoInfoService materialImageVideoInfoService;
+
+	/**
+	  * 分页列表查询
+	 * @param materialImageVideoInfo
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@GetMapping(value = "/list")
+	public Result<IPage<MaterialImageVideoInfo>> queryPageList(MaterialImageVideoInfo materialImageVideoInfo,
+															   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+															   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+															   HttpServletRequest req) {
+		Result<IPage<MaterialImageVideoInfo>> result = new Result<>();
+		QueryWrapper<MaterialImageVideoInfo> queryWrapper = QueryGenerator.initQueryWrapper(materialImageVideoInfo, req.getParameterMap());
+		Page<MaterialImageVideoInfo> page = new Page<MaterialImageVideoInfo>(pageNo, pageSize);
+		IPage<MaterialImageVideoInfo> pageList = materialImageVideoInfoService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param materialImageVideoInfo
+	 * @return
+	 */
+	@PostMapping(value = "/add")
+	public Result<MaterialImageVideoInfo> add(@RequestBody MaterialImageVideoInfo materialImageVideoInfo) {
+		Result<MaterialImageVideoInfo> result = new Result<>();
+		try {
+			materialImageVideoInfoService.save(materialImageVideoInfo);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param materialImageVideoInfo
+	 * @return
+	 */
+	@PutMapping(value = "/edit")
+	public Result<MaterialImageVideoInfo> edit(@RequestBody MaterialImageVideoInfo materialImageVideoInfo) {
+		Result<MaterialImageVideoInfo> result = new Result<MaterialImageVideoInfo>();
+		MaterialImageVideoInfo materialImageVideoInfoEntity = materialImageVideoInfoService.getById(materialImageVideoInfo.getId());
+		if(materialImageVideoInfoEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = materialImageVideoInfoService.updateById(materialImageVideoInfo);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		try {
+			materialImageVideoInfoService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+
+	/**
+	  *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<MaterialImageVideoInfo> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<MaterialImageVideoInfo> result = new Result<>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.materialImageVideoInfoService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@GetMapping(value = "/queryById")
+	public Result<MaterialImageVideoInfo> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<MaterialImageVideoInfo> result = new Result<>();
+		MaterialImageVideoInfo materialImageVideoInfo = materialImageVideoInfoService.getById(id);
+		if(materialImageVideoInfo==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(materialImageVideoInfo);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+}

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

@@ -499,6 +499,7 @@ public class MaterialInfoController {
                 url = KuaishouInterfaceConstant.HTTPS_PREFIX + url;
             }
             materialInfo.setUrl(url);
+            materialInfo.setCreateTime(new Date());
             MaterialCutFrame cutFrame = materialCutFrameService.getCutFrameByCode(materialInfo.getCode());
             if (Check.isNull(cutFrame)) {
                 String videoUrl = URLDecoder.decode(url).replace("https://media-1301855440.cos.ap-chongqing.myqcloud.com/", "");

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

@@ -28,10 +28,21 @@ import org.jeecg.modules.ctop.service.IAdvertiserService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecg.modules.system.service.ISysUserService;
 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.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 项目成员
@@ -178,18 +189,19 @@ public class ProjectMemberController {
                 userId = null;
             }
             List<JSONObject> projectList = projectMemberService.getProjectByUserIdAndMediaIds(userId, mediaIds);
+            List<JSONObject> haveList = new ArrayList<>();
             if (!Check.isNull(projectList)) {
                 for (int i = 0; i < projectList.size(); i++) {
                     JSONObject project = projectList.get(i);
                     List<JSONObject> accountList = userAllocationService.getAccountListByProject(project.getLong("projectId"));
                     if (!Check.isNull(accountList)) {
                         project.put("accountList", accountList);
+                        haveList.add(project);
                     }
                 }
             }
             result.setSuccess(true);
-            result.setResult(projectList);
-
+            result.setResult(haveList);
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);

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

@@ -10,9 +10,11 @@ import cn.com.ctop.crawler.modules.core.service.CrawlerDouyinMusicTaskService;
 import cn.com.ctop.crawler.modules.douyin.service.DouyinMusicService;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
 import cn.com.ctop.toutiao.modules.report.service.*;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -88,7 +90,59 @@ public class TestController {
 
     static ExecutorService executorService = Executors.newFixedThreadPool(10);
     static ExecutorService videoService = Executors.newFixedThreadPool(5);
-    static ExecutorService suzhaoService = Executors.newFixedThreadPool(10);
+    static ExecutorService suzhaoService = Executors.newFixedThreadPool(5);
+    @Autowired
+    private IKuaiShouDailyAgentService dailyAgentService;
+
+
+    @GetMapping(value = "/getCreativeByProjectId")
+    public void gerCreative(Long projectId, String startDate, String endDate) {
+
+        Result<String> result = new Result<>();
+        try {
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Date start = simpleDateFormat.parse(startDate);
+            Date end = simpleDateFormat.parse(endDate);
+            QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+            userAllocationQueryWrapper.eq("project_id", projectId);
+            List<UserAllocation> list = userAllocationService.list(userAllocationQueryWrapper);
+            if (!Check.isNull(list)) {
+                for (UserAllocation allocation : list) {
+                    Long accountId = allocation.getAccountId();
+                    QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+                    tokenQueryWrapper.eq("media_id", 2);
+                    tokenQueryWrapper.eq("account_id", accountId);
+                    CtopOauthToken token = oauthTokenMapper.selectOne(tokenQueryWrapper);
+                    if (!Check.isNull(token)) {
+                        suzhaoService.submit(new Runnable() {
+                            @Override
+                            public void run() {
+                                JSONArray arr = new JSONArray();
+                                kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, start, end, arr, arr);
+
+                            }
+                        });
+
+
+                    }
+                }
+
+            }
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+
+    }
+
+
+    @GetMapping(value = "/agentReport")
+    public void agentReport(String startDate, String endDate) {
+        dailyAgentService.getAgentReportByPage(startDate, endDate);
+    }
 
 
     @GetMapping(value = "/getData")
@@ -905,24 +959,6 @@ public class TestController {
     }
 
 
-    @GetMapping(value = "/getCreativeByAccount")
-    public void gerCreative(Long accountId) {
-        QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
-        oauthTokenQueryWrapper.eq("media_id", 2);
-        oauthTokenQueryWrapper.eq("account_id", accountId);
-        oauthTokenQueryWrapper.last("limit 1");
-        CtopOauthToken token = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
-
-        try {
-            kuaishouInterfaceService.getCreativeList(token, null, null);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-
-    }
-
-
     @Autowired
     private IBytedancePlanDailyReportService planDailyReportService;
     @Autowired

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

@@ -137,13 +137,11 @@ public class UserAllocationController {
         try {
 
             QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("user_id", userId);
             queryWrapper.eq("project_id", projectId);
-           /*  Project project = projectService.getById(projectId);
-                if (!Check.isNull(project)) {
-                queryWrapper.eq("media_id", project.getMediaId());
-            }*/
-
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)) {
+                queryWrapper.eq("user_id", userId);
+            }
             List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
             result.setSuccess(true);
             result.setResult(userAllocations);
@@ -305,6 +303,19 @@ public class UserAllocationController {
         return result;
     }
 
+    @GetMapping(value = "/getAccountIdsByUserId")
+    public Result<List<JSONObject>> getAccountIdsByUserId(String userId) {
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+            List<JSONObject> accountIds = userAllocationService.getAccountIdsByUserId(userId);
+            result.setSuccess(true);
+            result.setResult(accountIds);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.success(e.getMessage());
+        }
+        return result;
+    }
 
     /**
      * 分页列表查询

+ 257 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/BytedanceVideoEtlInfoEntity.java

@@ -0,0 +1,257 @@
+package org.jeecg.modules.excelutil.entity;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.metadata.BaseRowModel;
+
+import java.math.BigDecimal;
+
+public class BytedanceVideoEtlInfoEntity extends BaseRowModel {
+    /**视频唯一标识*/
+    @ExcelProperty(value = "视频唯一标识", index = 1)
+    private String videoCode;
+    /**初次产生消耗时间*/
+    @ExcelProperty(value = "视频上线时间", index = 2)
+    private String stateDate;
+    /**url*/
+    @ExcelProperty(value = "视频链接", index = 3)
+    private String url;
+    /**coverUrl*/
+    @ExcelProperty(value = "封面链接", index = 4)
+    private String coverUrl;
+    /**companyName*/
+    @ExcelProperty(value = "所属公司", index = 5)
+    private String companyName;
+    /**planName*/
+    @ExcelProperty(value = "编导名称", index = 6)
+    private String planName;
+    /**clipName*/
+    @ExcelProperty(value = "剪辑名称", index = 7)
+    private String clipName;
+    /**shotName*/
+    @ExcelProperty(value = "拍摄名称", index = 8)
+    private String shotName;
+    /**singleWeekCost*/
+    @ExcelProperty(value = "上线一周消耗", index = 9)
+    private BigDecimal singleWeekCost;
+    /**twoWeekCost*/
+    @ExcelProperty(value = "上线两周消耗", index = 10)
+    private BigDecimal twoWeekCost;
+    /**fourWeekCost*/
+    @ExcelProperty(value = "上线四周消耗", index = 11)
+    private BigDecimal fourWeekCost;
+    /**总消耗*/
+    @ExcelProperty(value = "总消耗", index = 12)
+    private BigDecimal totalCost;
+    /**clickNum*/
+    @ExcelProperty(value = "封面点击数", index = 13)
+    private Long clickNum;
+    /**showNum*/
+    @ExcelProperty(value = "素材曝光数", index = 14)
+    private Long showNum;
+    /**activeNum*/
+    @ExcelProperty(value = "有效数", index = 15)
+    private Long activeNum;
+    /**convertNum*/
+    @ExcelProperty(value = "转化数", index = 16)
+    private Long convertNum;
+    /**effectDate*/
+    @ExcelProperty(value = "达成有效日期", index = 17)
+    private String effectDate;
+    /**faddishDate*/
+    @ExcelProperty(value = "达成爆款日期", index = 18)
+    private String faddishDate;
+    /**effectDayNum*/
+    @ExcelProperty(value = "达成有效天数", index = 19)
+    private Integer effectDayNum;
+    /**faddishDayNum*/
+    @ExcelProperty(value = "达成爆款天数", index = 20)
+    private Integer faddishDayNum;
+
+    public BytedanceVideoEtlInfoEntity(BytedanceVideoEtlInfo etlInfo) {
+        this.videoCode = etlInfo.getVideoCode();
+        this.stateDate = etlInfo.getStateDate();
+        this.url = etlInfo.getUrl();
+        this.coverUrl = etlInfo.getCoverUrl();
+        this.companyName = etlInfo.getCompanyName();
+        this.planName = etlInfo.getPlanName();
+        this.clipName = etlInfo.getClipName();
+        this.shotName = etlInfo.getShotName();
+        this.singleWeekCost = etlInfo.getSingleWeekCost();
+        this.twoWeekCost = etlInfo.getTwoWeekCost();
+        this.fourWeekCost = etlInfo.getFourWeekCost();
+        this.totalCost = etlInfo.getTotalCost();
+        this.clickNum = etlInfo.getClickNum();
+        this.showNum = etlInfo.getShowNum();
+        this.activeNum = etlInfo.getActiveNum();
+        this.convertNum = etlInfo.getConvertNum();
+        this.effectDate = etlInfo.getEffectDate();
+        this.faddishDate = etlInfo.getFaddishDate();
+        this.effectDayNum = etlInfo.getEffectDayNum();
+        this.faddishDayNum = etlInfo.getFaddishDayNum();
+    }
+
+    public BytedanceVideoEtlInfoEntity() {
+
+    }
+
+    public String getVideoCode() {
+        return videoCode;
+    }
+
+    public void setVideoCode(String videoCode) {
+        this.videoCode = videoCode;
+    }
+
+    public String getStateDate() {
+        return stateDate;
+    }
+
+    public void setStateDate(String stateDate) {
+        this.stateDate = stateDate;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getCoverUrl() {
+        return coverUrl;
+    }
+
+    public void setCoverUrl(String coverUrl) {
+        this.coverUrl = coverUrl;
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public String getPlanName() {
+        return planName;
+    }
+
+    public void setPlanName(String planName) {
+        this.planName = planName;
+    }
+
+    public String getClipName() {
+        return clipName;
+    }
+
+    public void setClipName(String clipName) {
+        this.clipName = clipName;
+    }
+
+    public String getShotName() {
+        return shotName;
+    }
+
+    public void setShotName(String shotName) {
+        this.shotName = shotName;
+    }
+
+    public BigDecimal getSingleWeekCost() {
+        return singleWeekCost;
+    }
+
+    public void setSingleWeekCost(BigDecimal singleWeekCost) {
+        this.singleWeekCost = singleWeekCost;
+    }
+
+    public BigDecimal getTwoWeekCost() {
+        return twoWeekCost;
+    }
+
+    public void setTwoWeekCost(BigDecimal twoWeekCost) {
+        this.twoWeekCost = twoWeekCost;
+    }
+
+    public BigDecimal getFourWeekCost() {
+        return fourWeekCost;
+    }
+
+    public void setFourWeekCost(BigDecimal fourWeekCost) {
+        this.fourWeekCost = fourWeekCost;
+    }
+
+    public BigDecimal getTotalCost() {
+        return totalCost;
+    }
+
+    public void setTotalCost(BigDecimal totalCost) {
+        this.totalCost = totalCost;
+    }
+
+    public Long getClickNum() {
+        return clickNum;
+    }
+
+    public void setClickNum(Long clickNum) {
+        this.clickNum = clickNum;
+    }
+
+    public Long getShowNum() {
+        return showNum;
+    }
+
+    public void setShowNum(Long showNum) {
+        this.showNum = showNum;
+    }
+
+    public Long getActiveNum() {
+        return activeNum;
+    }
+
+    public void setActiveNum(Long activeNum) {
+        this.activeNum = activeNum;
+    }
+
+    public Long getConvertNum() {
+        return convertNum;
+    }
+
+    public void setConvertNum(Long convertNum) {
+        this.convertNum = convertNum;
+    }
+
+    public String getEffectDate() {
+        return effectDate;
+    }
+
+    public void setEffectDate(String effectDate) {
+        this.effectDate = effectDate;
+    }
+
+    public String getFaddishDate() {
+        return faddishDate;
+    }
+
+    public void setFaddishDate(String faddishDate) {
+        this.faddishDate = faddishDate;
+    }
+
+    public Integer getEffectDayNum() {
+        return effectDayNum;
+    }
+
+    public void setEffectDayNum(Integer effectDayNum) {
+        this.effectDayNum = effectDayNum;
+    }
+
+    public Integer getFaddishDayNum() {
+        return faddishDayNum;
+    }
+
+    public void setFaddishDayNum(Integer faddishDayNum) {
+        this.faddishDayNum = faddishDayNum;
+    }
+}

+ 292 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/KuaishouVideoEtlInfoEntity.java

@@ -0,0 +1,292 @@
+package org.jeecg.modules.excelutil.entity;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouVideoEtlInfo;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.metadata.BaseRowModel;
+
+import java.math.BigDecimal;
+
+public class KuaishouVideoEtlInfoEntity extends BaseRowModel {
+    /**
+     * 视频唯一标识
+     */
+    @ExcelProperty(value = "视频唯一标识", index = 1)
+    private String videoCode;
+    /**
+     * 初次产生消耗时间
+     */
+    @ExcelProperty(value = "视频上线时间", index = 2)
+    private String stateDate;
+    /**
+     * url
+     */
+    @ExcelProperty(value = "视频链接", index = 3)
+    private String url;
+    /**
+     * coverUrl
+     */
+    @ExcelProperty(value = "封面链接", index = 4)
+    private String coverUrl;
+    /**
+     * companyName
+     */
+    @ExcelProperty(value = "所属公司", index = 5)
+    private String companyName;
+    /**
+     * planName
+     */
+    @ExcelProperty(value = "编导名称", index = 5)
+    private String planName;
+    /**
+     * clipName
+     */
+    @ExcelProperty(value = "剪辑名称", index = 7)
+    private String clipName;
+    /**
+     * shotName
+     */
+    @ExcelProperty(value = "拍摄名称", index = 8)
+    private String shotName;
+    /**
+     * singleWeekCost
+     */
+    @ExcelProperty(value = "上线一周消耗", index = 9)
+    private BigDecimal singleWeekCost;
+    /**
+     * twoWeekCost
+     */
+    @ExcelProperty(value = "上线两周消耗", index = 10)
+    private BigDecimal twoWeekCost;
+    /**
+     * fourWeekCost
+     */
+    @ExcelProperty(value = "上线四周消耗", index = 11)
+    private BigDecimal fourWeekCost;
+    /**
+     * 总消耗
+     */
+    @ExcelProperty(value = "总消耗", index = 12)
+    private BigDecimal totalCost;
+    /**
+     * clickNum
+     */
+    @ExcelProperty(value = "封面曝光数", index = 13)
+    private Long photoShow;
+    @ExcelProperty(value = "封面点击数", index = 14)
+    private Long photoClick;
+    @ExcelProperty(value = "素材曝光数", index = 15)
+    private Long aclick;
+    /**
+     * convertNum
+     */
+    @ExcelProperty(value = "行为数", index = 16)
+    private Long bclick;
+    /**
+     * effectDate
+     */
+    @ExcelProperty(value = "达成有效日期", index = 17)
+    private String effectDate;
+    /**
+     * faddishDate
+     */
+    @ExcelProperty(value = "达成爆款日期", index = 18)
+    private String faddishDate;
+    /**
+     * effectDayNum
+     */
+    @ExcelProperty(value = "达成有效天数", index = 19)
+    private Integer effectDayNum;
+    /**
+     * faddishDayNum
+     */
+    @ExcelProperty(value = "达成爆款天数", index = 20)
+    private Integer faddishDayNum;
+
+    public KuaishouVideoEtlInfoEntity(KuaishouVideoEtlInfo etlInfo) {
+        this.videoCode = etlInfo.getVideoCode();
+        this.stateDate = etlInfo.getStateDate();
+        this.url = etlInfo.getUrl();
+        this.coverUrl = etlInfo.getCoverUrl();
+        this.companyName = etlInfo.getCompanyName();
+        this.planName = etlInfo.getPlanName();
+        this.clipName = etlInfo.getClipName();
+        this.shotName = etlInfo.getShotName();
+        this.singleWeekCost = etlInfo.getSingleWeekCost();
+        this.twoWeekCost = etlInfo.getTwoWeekCost();
+        this.fourWeekCost = etlInfo.getFourWeekCost();
+        this.totalCost = etlInfo.getTotalCost();
+        this.photoClick = etlInfo.getPhotoClick();
+        this.photoShow = etlInfo.getPhotoShow();
+        this.aclick = etlInfo.getAclick();
+        this.bclick = etlInfo.getBclick();
+        this.effectDate = etlInfo.getEffectDate();
+        this.faddishDate = etlInfo.getFaddishDate();
+        this.effectDayNum = etlInfo.getEffectDayNum();
+        this.faddishDayNum = etlInfo.getFaddishDayNum();
+    }
+
+    public KuaishouVideoEtlInfoEntity() {
+
+    }
+
+    public String getVideoCode() {
+        return videoCode;
+    }
+
+    public void setVideoCode(String videoCode) {
+        this.videoCode = videoCode;
+    }
+
+    public String getStateDate() {
+        return stateDate;
+    }
+
+    public void setStateDate(String stateDate) {
+        this.stateDate = stateDate;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getCoverUrl() {
+        return coverUrl;
+    }
+
+    public void setCoverUrl(String coverUrl) {
+        this.coverUrl = coverUrl;
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public String getPlanName() {
+        return planName;
+    }
+
+    public void setPlanName(String planName) {
+        this.planName = planName;
+    }
+
+    public String getClipName() {
+        return clipName;
+    }
+
+    public void setClipName(String clipName) {
+        this.clipName = clipName;
+    }
+
+    public String getShotName() {
+        return shotName;
+    }
+
+    public void setShotName(String shotName) {
+        this.shotName = shotName;
+    }
+
+    public BigDecimal getSingleWeekCost() {
+        return singleWeekCost;
+    }
+
+    public void setSingleWeekCost(BigDecimal singleWeekCost) {
+        this.singleWeekCost = singleWeekCost;
+    }
+
+    public BigDecimal getTwoWeekCost() {
+        return twoWeekCost;
+    }
+
+    public void setTwoWeekCost(BigDecimal twoWeekCost) {
+        this.twoWeekCost = twoWeekCost;
+    }
+
+    public BigDecimal getFourWeekCost() {
+        return fourWeekCost;
+    }
+
+    public void setFourWeekCost(BigDecimal fourWeekCost) {
+        this.fourWeekCost = fourWeekCost;
+    }
+
+    public BigDecimal getTotalCost() {
+        return totalCost;
+    }
+
+    public void setTotalCost(BigDecimal totalCost) {
+        this.totalCost = totalCost;
+    }
+
+    public Long getPhotoShow() {
+        return photoShow;
+    }
+
+    public void setPhotoShow(Long photoShow) {
+        this.photoShow = photoShow;
+    }
+
+    public Long getPhotoClick() {
+        return photoClick;
+    }
+
+    public void setPhotoClick(Long photoClick) {
+        this.photoClick = photoClick;
+    }
+
+    public Long getAclick() {
+        return aclick;
+    }
+
+    public void setAclick(Long aclick) {
+        this.aclick = aclick;
+    }
+
+    public Long getBclick() {
+        return bclick;
+    }
+
+    public void setBclick(Long bclick) {
+        this.bclick = bclick;
+    }
+
+    public String getEffectDate() {
+        return effectDate;
+    }
+
+    public void setEffectDate(String effectDate) {
+        this.effectDate = effectDate;
+    }
+
+    public String getFaddishDate() {
+        return faddishDate;
+    }
+
+    public void setFaddishDate(String faddishDate) {
+        this.faddishDate = faddishDate;
+    }
+
+    public Integer getEffectDayNum() {
+        return effectDayNum;
+    }
+
+    public void setEffectDayNum(Integer effectDayNum) {
+        this.effectDayNum = effectDayNum;
+    }
+
+    public Integer getFaddishDayNum() {
+        return faddishDayNum;
+    }
+
+    public void setFaddishDayNum(Integer faddishDayNum) {
+        this.faddishDayNum = faddishDayNum;
+    }
+}

+ 12 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

@@ -6,6 +6,8 @@ import cn.com.ctop.common.module.entity.SysRole;
 import cn.com.ctop.common.module.entity.SysUser;
 import cn.com.ctop.common.module.model.SysUserSysDepartModel;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.common.module.vo.SysDepartUsersVO;
 import cn.com.ctop.common.module.vo.SysUserRoleVO;
 import cn.com.ctop.common.module.vo.SysUserVo;
@@ -111,6 +113,16 @@ public class SysUserController {
         return map;
     }
 
+    @RequestMapping(value = "/getAllDesigner", method = RequestMethod.GET)
+    public Map<String, Object> getAllDesigner() {
+        Map<String, Object> map = new HashMap<>();
+        List<SysUser> userList = sysUserService.getAllDesigner();
+        map.put("data",userList);
+        ResultMapUtils.setResultMap(map, StatusCode.COMMON_SUCCESS);
+        return map;
+    }
+
+
     @Autowired
     private UserCompanyMapper userCompanyMapper;
 

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserService.java

@@ -260,4 +260,7 @@ public interface ISysUserService extends IService<SysUser> {
     List<SysUser> queryByDepIds(List<String> departIds, String username);
 
     List<SysUserVo> getAllUser(String userName);
+
+    List<SysUser> getAllDesigner();
+
 }

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java

@@ -275,6 +275,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     }
 
     @Override
+    public List<SysUser> getAllDesigner() {
+        return userMapper.selectAllDesigner();
+    }
+
+    @Override
     public Map<String, String> getDepNamesByUserIds(List<String> userIds) {
         List<SysUserDepVo> list = this.baseMapper.getDepNamesByUserIds(userIds);
         Map<String, String> res = new HashMap<String, String>();

+ 24 - 0
jeecg-boot-module-system/src/main/resources/ads/timing-task.json

@@ -0,0 +1,24 @@
+[
+  {
+    "accountId": "9556344",
+    "marketing_goal": "2",
+    "app_store": "[\"huawei\",\"oppo\",\"vivo\",\"xiaomi\",\"meizu\",\"smartisan\"]",
+    "use_app_market":"1",
+    "app_ids": "[2817201]",
+    "region": "[]",
+    "ages_range": "[18, 24, 31, 41, 50]",
+    "gender": 0,
+    "platform_os": 0,
+    "custom_crowd":"2",
+    "population": "[]",
+    "exclude_population": "[11950861, 11814320]",
+    "bid_type": 10,
+    "ocpx_action_type":180,
+    "cpa_bid": 26500,
+    "scene_id": "[6, 7]",
+    "site_id": "[{\"appId\":2817201,\"siteId\":\"\"}]",
+    "impression_url": "https://adtracker.surge.alibaba.com/monitor.htm?channel=3&taskId=4&app=7&action=1&adid=__DID__&adName=__DNAME__&cid=__CID__&imeiMd5=__IMEI2__&idfaMd5=__IDFA2__&oaid=__OAID__&callbackUrl=__CALLBACK__&groupId=__AID__&csite=__CSITE__&androidIdMd5=__ANDROIDID2__&timestamp=__TS__&mac1Md5=__MAC2__&macMd5=__MAC3__&ip=__IP__&translationTag=1&serviceProviderName=Huichuang.wz",
+    "click_track_url": "https://adtracker.surge.alibaba.com/monitor.htm?channel=3&taskId=4&app=7&action=1&adid=__DID__&adName=__DNAME__&cid=__CID__&imeiMd5=__IMEI2__&idfaMd5=__IDFA2__&oaid=__OAID__&callbackUrl=__CALLBACK__&groupId=__AID__&csite=__CSITE__&androidIdMd5=__ANDROIDID2__&timestamp=__TS__&mac1Md5=__MAC2__&macMd5=__MAC3__&ip=__IP__&translationTag=1&serviceProviderName=Huichuang.wz",
+    "actionbar_click_url": "https://adtracker.surge.alibaba.com/monitor.htm?channel=3&taskId=4&app=7&action=2&adid=__DID__&adName=__DNAME__&cid=__CID__&imeiMd5=__IMEI2__&idfaMd5=__IDFA2__&oaid=__OAID__&callbackUrl=__CALLBACK__&groupId=__AID__&csite=__CSITE__&androidIdMd5=__ANDROIDID2__&timestamp=__TS__&mac1Md5=__MAC2__&macMd5=__MAC3__&ip=__IP__&translationTag=1&serviceProviderName=NewHuichuang.wz"
+  }
+]

+ 2 - 2
jeecg-boot-module-system/src/main/resources/jeecg/jeecg_database.properties

@@ -1,8 +1,8 @@
 #mysql
 diver_name=com.mysql.jdbc.Driver
 url=jdbc:mysql://139.186.27.96:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
-username=hcst
-password=hcst@2020
+username=data
+password=hcst@2021
 database_name=jeecg-boot
 #oracle
 #diver_name=oracle.jdbc.driver.OracleDriver

+ 13 - 3
module-alarm/src/main/java/cn/com/ctop/alarm/modules/constant/MatchLogic.java

@@ -96,6 +96,13 @@ public class MatchLogic {
                     }
                 }
             } else {
+                /**
+                 不包含逻辑根据指标分两种:
+                 1、大部分数组型指标阈值逻辑:所设的阈值中,存在任一目标则不报警,都不存在时则报警,出现阈值之外的亦报警
+                 2、排除人群包、排除流量包逻辑:所选必须都存在,否则报警
+
+                 包含逻辑通用: 任一存在则报警
+                 */
                 if (value.contains("[") && threshold.contains("[")) {
                     List<String> values = strToList(value);
                     List<String> thresholds = strToList(threshold);
@@ -120,13 +127,16 @@ public class MatchLogic {
                                 }
                             }
                         } else {
-                            //不包含,任一存在不报警,都不存在则报警
+                            boolean flag = true;
+                            //不包含,阈值中,存在任一目标则不报警,都不存在时则报警,出现阈值之外的亦报警
                             for (String v : values) {
                                 if (threshold.contains(v)) {
-                                    return false;
+                                    flag = false;
+                                } else {
+                                    return true;
                                 }
                             }
-                            return true;
+                            return flag;
                         }
                     }
                 } else {

+ 3 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/RuleIndicator.java

@@ -75,6 +75,9 @@ public class RuleIndicator {
     @Excel(name = "对应数据字典id", width = 15)
     @ApiModelProperty(value = "对应数据字典id")
     private String dictId;
+
+    private String requestUrl;
+
     /**
      * 对应数据表名称
      */

+ 4 - 3
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleAccountThresholdServiceImpl.java

@@ -102,11 +102,12 @@ public class RuleAccountThresholdServiceImpl extends ServiceImpl<RuleAccountThre
                         continue;
                     }
                     String threshold = ruleJson.getString("threshold");
+                    RuleAccountThreshold updateThreshold = new RuleAccountThreshold();
                     if (Check.isNull(threshold)) {
-                        continue;
+                        updateThreshold.setThreshold("");
+                    } else {
+                        updateThreshold.setThreshold(threshold);
                     }
-                    RuleAccountThreshold updateThreshold = new RuleAccountThreshold();
-                    updateThreshold.setThreshold(threshold);
                     QueryWrapper<RuleAccountThreshold> updateQueryWrapper = new QueryWrapper();
                     updateQueryWrapper.eq("account_id", accountId);
                     updateQueryWrapper.eq("rule_id", ruleId);

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

@@ -592,8 +592,6 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                 }
                 if (ACCOUNT.equals(type)) {
                     msg += "请您及时查看并调整!";
-                } else {
-                    msg += "现已被关停,请您及时查看并调整!";
                 }
             } else {
                 msg += "请您及时查看并调整!";
@@ -664,26 +662,34 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
     private String kuaiShoushutDown(Long accountId, String ids, String type, String userId, String msg) {
         CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
         Map<String, Object> updateMap = new HashMap<>();
-        if (!Check.isNull(token) && !Check.isNull(ids)) {
-            String[] idSplit = ids.split(",");
-            for (String id : idSplit) {
-                if (CREATIVE.equals(type)) {
-                    updateMap = kuaiShouUpdateService.updateCreativeStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
-                    if (!(boolean) updateMap.get("success")) {
-                        msg = msg.replace(id, id + "(F)");
-                    }
-                } else if (UNIT.equals(type)) {
-                    updateMap = kuaiShouUpdateService.updateUnitStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
-                    if (!(boolean) updateMap.get("success")) {
-                        msg = msg.replace(id, id + "(F)");
-                    }
-                } else if (PLAN.equals(type)) {
-                    updateMap = kuaiShouUpdateService.updateCampaignStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
-                    if (!(boolean) updateMap.get("success")) {
-                        msg = msg.replace(id, id + "(F)");
+        try {
+            if (!Check.isNull(token) && !Check.isNull(ids)) {
+                String[] idSplit = ids.split(",");
+                for (String id : idSplit) {
+                    if (CREATIVE.equals(type)) {
+                        updateMap = kuaiShouUpdateService.updateCreativeStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
+                        if (!(boolean) updateMap.get("success")) {
+                            msg = msg.replace(id, id + "(F)");
+                        }
+                    } else if (UNIT.equals(type)) {
+                        updateMap = kuaiShouUpdateService.updateUnitStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
+                        if (!(boolean) updateMap.get("success")) {
+                            msg = msg.replace(id, id + "(F)");
+                        }
+                    } else if (PLAN.equals(type)) {
+                        updateMap = kuaiShouUpdateService.updateCampaignStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
+                        if (!(boolean) updateMap.get("success")) {
+                            msg = msg.replace(id, id + "(F)");
+                        }
                     }
                 }
+                msg += "现已被关停,请您及时查看并调整!";
+            } else {
+                msg = msg + "(F)获取签证失败!请联系管理员!";
             }
+        } catch (NumberFormatException e) {
+            log.error("快手关停操作异常", e);
+            msg = msg + "(F)操作关停失败!请联系管理员!";
         }
         return msg;
     }
@@ -721,9 +727,11 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                             }
                         }
                     }
+                    msg += "现已被关停,请您及时查看并调整!";
                 }
             }
         } catch (Exception e) {
+            msg = msg + "(F)操作关停失败!请联系管理员!";
             log.error("头条账户:{},关停{}失败", accountId, type, e);
         }
         return msg;

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

@@ -344,6 +344,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                         ruleJson.put("dataUnit", ruleIndicator.getDataUnit());
                         ruleJson.put("name", ruleIndicator.getName());
                         ruleJson.put("modelType", ruleIndicator.getModelType());
+                        ruleJson.put("requestUrl", ruleIndicator.getRequestUrl());
                     }
 
                     ruleDetail.add(ruleJson);
@@ -490,6 +491,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                         ruleJson.put("dataUnit", ruleIndicator.getDataUnit());
                         ruleJson.put("name", ruleIndicator.getName());
                         ruleJson.put("modelType", ruleIndicator.getModelType());
+                        ruleJson.put("requestUrl", ruleIndicator.getRequestUrl());
                     }
 
                     ruleDetail.add(ruleJson);

+ 41 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialImageVideoInfo.java

@@ -0,0 +1,41 @@
+package cn.com.ctop.common.module.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   2020-12-17
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_material_image_video_info")
+public class MaterialImageVideoInfo {
+    
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private java.lang.Long id;
+	/**视频md5码*/
+	@Excel(name = "视频md5码", width = 15)
+	private java.lang.String videoCode;
+	/**封面md5码*/
+	@Excel(name = "封面md5码", width = 15)
+	private java.lang.String coverCode;
+	/**createTime*/
+	private java.util.Date createTime;
+	/**updateTime*/
+	private java.util.Date updateTime;
+}

+ 19 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTargetKuaishou.java

@@ -39,4 +39,23 @@ public class RuleDataTargetKuaishou {
 	private String scheduleTime;
 
 	private Integer status;
+
+	/**应用商店*/
+	private String appStore;
+
+	/**定向人群包*/
+	private String population;
+
+	/**排除人群包*/
+	private String excludePopulation;
+
+	/**年龄范围*/
+	private String agesRange;
+
+	/**商业兴趣*/
+	private String businessInterest;
+
+	/**网络环境*/
+	private Integer network;
+
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/SysUser.java

@@ -198,4 +198,9 @@ public class SysUser implements Serializable {
     @TableField(exist = false)
     private String depart;
 
+    /**
+     * 部门
+     */
+    @TableField(exist = false)
+    private String roleName;
 }

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/CustomDataByAccountMapper.java

@@ -14,6 +14,10 @@ public interface CustomDataByAccountMapper {
     //快手查询账户日报数据
     JSONObject queryKsAccountData(@Param("accountId") Long accountId,@Param("date") String date);
 
+
+    //快手查询物料日报数据
+    JSONObject queryKsMaterialData(@Param("accountId") Long accountId,@Param("days") Integer days);
+
     //头条查询广告组日报数据
     JSONObject queryByCampaignData(@Param("accountId") Long accountId,@Param("date") String date);
 

+ 14 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialImageVideoInfoMapper.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.MaterialImageVideoInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 视频封面关联表信息
+ * @author: jeecg-boot
+ * @date:   2020-12-17
+ * @cersion: V1.0
+ */
+public interface MaterialImageVideoInfoMapper extends BaseMapper<MaterialImageVideoInfo> {
+
+}

+ 1 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/SysUserMapper.java

@@ -25,6 +25,7 @@ import java.util.Map;
  */
 public interface SysUserMapper extends BaseMapper<SysUser> {
     List<SysUser> selectAllUser();
+    List<SysUser> selectAllDesigner();
 
     /**
      * 通过用户账号查询用户信息

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

@@ -1,6 +1,7 @@
 package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.UserAllocation;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -26,6 +27,10 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
 
     List<JSONObject> getAccountIdListByUserId(@Param("userId") Long userId);
 
+    List<JSONObject> getAccountIdsByUserId(@Param("userId") String userId);
+
+    List<JSONObject> getAllAccountIdsByMediaId(@Param("mediaId") String mediaId);
+
     Long getProjectIdByAccountId(@Param("accountId") Long accountId);
 
     UserAllocation getUserAllocation(@Param("accountId") Long accountId);

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

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

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

@@ -254,4 +254,10 @@ SELECT
         INNER JOIN  ctop_user_allocation t2 ON t1.id = t2.user_id
         WHERE t2.account_id = #{accountId}
     </select>
+    <select id="selectAllDesigner" resultType="cn.com.ctop.common.module.entity.SysUser">
+        select user.realname,user.id,role.role_name from sys_user_role userRole left join sys_user user on userRole.user_id = user.id
+        left join sys_role role on userRole.role_id = role.id
+            where role.role_code in ('plane','plan','shot','clip','designTeamLeader')
+            and user.status = 1
+    </select>
 </mapper>

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

@@ -63,6 +63,32 @@
     AND t1.account_status = 0
     </select>
 
+    <select id="getAccountIdsByUserId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            allocation.account_id,
+            allocation.auth_name,
+            project.project_name as project_name
+        FROM
+            ctop_user_allocation allocation
+            left join ctop_project project on allocation.project_id = project.id
+        WHERE
+            allocation.user_id = #{userId}
+          and allocation.account_status=0
+    </select>
+
+
+    <select id="getAllAccountIdsByMediaId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            account_id,
+            auth_name,
+            project_name
+        FROM
+            ctop_user_allocation
+        WHERE
+            media_id=#{mediaId}
+          and account_status=0
+    </select>
+
     <select id="getProjectIdByAccountId" resultType="java.lang.Long">
     select  project_id  from  ctop_user_allocation
     where account_id = #{accountId}

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

@@ -33,4 +33,6 @@ public interface IMaterialCutFrameService extends IService<MaterialCutFrame> {
     MaterialCutFrame getCutFrameByCode(String code);
 
     List<JSONObject> getProgramCreativeCover(String signature);
+
+    MaterialCutFrame selectByMd5(String md5);
 }

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialImageInfoService.java

@@ -29,4 +29,7 @@ public interface IMaterialImageInfoService extends IService<MaterialImageInfo> {
     void initImageCode(MaterialImageInfo image);
 
     MaterialImageInfo getByCode(String signature);
+
+
+    List<MaterialImageInfo> getListByVideoSignature(String signature);
 }

+ 14 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialImageVideoInfoService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.MaterialImageVideoInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 视频封面关联表信息
+ * @Author: jeecg-boot
+ * @Date:   2020-12-17
+ * @Version: V1.0
+ */
+public interface IMaterialImageVideoInfoService extends IService<MaterialImageVideoInfo> {
+
+}

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

@@ -81,4 +81,6 @@ public interface IMessageTemplate {
      * @return
      */
     String getKuaiShouBidMessage(String projectName, Long advertiserId, Long unitId, String unit_name);
+
+    String getCopyCampaignMessage(String oldName, String state);
 }

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

@@ -1,6 +1,7 @@
 package cn.com.ctop.common.module.service;
 
 import cn.com.ctop.common.module.entity.UserAllocation;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -33,6 +34,8 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
     List<JSONObject> getAccountIdListByUserId(Long userId);
 
+    List<JSONObject> getAccountIdsByUserId(String userId);
+
     List<UserAllocation> getUserAllocations(String mediaId ,int switchType);
 
     JSONObject getSwitchStatusByAccount(Long accountId);

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

@@ -424,9 +424,18 @@ public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMap
     }
 
     @Override
-    public  List<JSONObject>  getProgramCreativeCover(String signature) {
+    public List<JSONObject> getProgramCreativeCover(String signature) {
         return materialCutFrameMapper.getProgramCreativeCover(signature);
     }
 
+    @Override
+    public MaterialCutFrame selectByMd5(String md5) {
+        QueryWrapper<MaterialCutFrame> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("signature", md5);
+        queryWrapper.last("limit 1");
+        return this.getOne(queryWrapper);
+
+    }
+
 
 }

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

@@ -151,4 +151,15 @@ public class MaterialImageInfoServiceImpl extends ServiceImpl<MaterialImageInfoM
         return this.getOne(queryWrapper);
     }
 
+
+    @Override
+    public List<MaterialImageInfo> getListByVideoSignature(String signature) {
+        QueryWrapper<MaterialImageInfo>queryWrapper =new QueryWrapper<>();
+        if(null!=signature&&!signature.trim().equals("")){
+            queryWrapper.eq("video_id",signature);
+        }
+        return this.list(queryWrapper);
+    }
+
+
 }

+ 18 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialImageVideoInfoServiceImpl.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.MaterialImageVideoInfo;
+import cn.com.ctop.common.module.mapper.MaterialImageVideoInfoMapper;
+import cn.com.ctop.common.module.service.IMaterialImageVideoInfoService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 视频封面关联表信息
+ * @author jeecg-boot
+ * @date   2020-12-17
+ * @version V1.0
+ */
+@Service
+public class MaterialImageVideoInfoServiceImpl extends ServiceImpl<MaterialImageVideoInfoMapper, MaterialImageVideoInfo> implements IMaterialImageVideoInfoService {
+
+}

+ 16 - 3
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java

@@ -5,9 +5,6 @@ import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSONObject;
 import org.springframework.stereotype.Service;
 
-import java.util.Arrays;
-import java.util.List;
-
 @Service
 public class MessageTemplateImpl implements IMessageTemplate {
 
@@ -195,4 +192,20 @@ public class MessageTemplateImpl implements IMessageTemplate {
         return text.toString();
     }
 
+    @Override
+    public String getCopyCampaignMessage(String oldName, String state) {
+        StringBuilder text = new StringBuilder();
+        if ("2".equals(state)) {
+            text.append("广告计划复制成功通知").append("<br/>")
+                    .append("您复制的广告计划:").append(oldName).append("<br/>")
+                    .append("现已复制完成,请知悉");
+        } else {
+            text.append("广告计划复制失败预警").append("<br/>")
+                    .append("您复制的广告计划:").append(oldName).append("<br/>")
+                    .append("复制失败,请您联系管理员或重新执行复制操作!").append("<br/>");
+        }
+        return text.toString();
+    }
+
+
 }

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

@@ -6,12 +6,14 @@ import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
+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.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -121,6 +123,18 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     }
 
     @Override
+    public List<JSONObject> getAccountIdsByUserId(String userId) {
+        List<JSONObject> result= new ArrayList<>();
+        if(userId.equals("e9ca23d68d884d4ebb19d07889727dae")){
+            result=userAllocationMapper.getAllAccountIdsByMediaId("2");
+        }else {
+            result=userAllocationMapper.getAccountIdsByUserId(userId);
+
+        }
+        return result;
+    }
+
+    @Override
     public List<UserAllocation> getUserAllocations(String mediaId, int switchType) {
         QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("media_id", mediaId);

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

@@ -309,9 +309,17 @@ public class KuaishouInterfaceConstant {
      * 屏蔽评论接口
      */
     public static final String COMMENT_SHIELD = "/rest/openapi/v1/comment/shield";
-  /**
+    /**
      * 人群分析报表
      */
     public static final String AUDIENCE_REPORT = "/rest/openapi/v1/report/audience_report";
+    /**
+     * 视频库-推送视频
+     */
+    public static final String VIDEO_SHARE = "/rest/openapi/v1/file/ad/video/share";
+    /**
+     * 频库-视频关联创意数查询
+     */
+    public static final String VIDEO_RELATE_CREATIVES = "/rest/openapi/v1/file/ad/video/relate/creatives";
 
 }

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

@@ -19,7 +19,6 @@ public class LoadFileUtil {
      */
     public static String downLoadFromUrl(String urlStr, String savePath) {
         try {
-
             String fileName = AesEncryptUtil.getUrlDecoderString(urlStr.substring(urlStr.lastIndexOf("/") + 1));
             URL url = new URL(urlStr);
 

+ 0 - 5
module-job-bytedance/pom.xml

@@ -56,11 +56,6 @@
             <groupId>org.slf4j</groupId>
             <artifactId>jcl-over-slf4j</artifactId>
         </dependency>
-        <dependency>
-            <groupId>cn.com.ctop</groupId>
-            <artifactId>module-media</artifactId>
-            <version>2.0.2</version>
-        </dependency>
 
         <dependency>
             <groupId>cn.com.ctop</groupId>

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

@@ -2,6 +2,7 @@ package cn.com.ctop.job.bytedance.handler;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IRuleDataCreativeService;
 import cn.com.ctop.common.module.service.IRuleDataPlanService;
 import cn.com.ctop.common.module.service.IRuleDataTargetService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
@@ -26,6 +27,8 @@ public class ByteDancePlanRuleDataJob {
     @Autowired
     private IRuleDataPlanService ruleDataPlanService;
     @Autowired
+    private IRuleDataCreativeService ruleDataCreativeService;
+    @Autowired
     private IRuleDataTargetService ruleDataTargetService;
     private ExecutorService executorService = Executors.newFixedThreadPool(10);
     @XxlJob("bytedancePlanRuleLoadJob")
@@ -38,6 +41,7 @@ public class ByteDancePlanRuleDataJob {
             params.put("account_id",token.getAccountId());
             ruleDataPlanService.removeByMap(params);
             ruleDataTargetService.removeByMap(params);
+            ruleDataCreativeService.removeByMap(params);
             reportService.getAdvertiserPlanRuleData(token,date,date, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
         }));
     }

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

@@ -0,0 +1,24 @@
+package cn.com.ctop.job.bytedance.handler;
+
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoEtlInfoService;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+@Component
+public class BytedanceEtlVideoJob {
+
+    @Autowired
+    private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
+    @XxlJob("bytedanceEtlVideoJob")
+    public void execute() throws Exception {
+        Date startDate = DateUtils.addDay(new Date(),-2);
+        for(int i=0;i<=2;i++){
+            Date getDate = DateUtils.addDay(startDate,i);
+            bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
+        }
+    }
+}

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

@@ -58,12 +58,6 @@
         </dependency>
         <dependency>
             <groupId>cn.com.ctop</groupId>
-            <artifactId>module-media</artifactId>
-            <version>2.0.2</version>
-        </dependency>
-
-        <dependency>
-            <groupId>cn.com.ctop</groupId>
             <artifactId>module-alarm</artifactId>
             <version>2.0.2</version>
         </dependency>

+ 36 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAiAdsNewMaterialCreativityJob.java

@@ -0,0 +1,36 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountTargetTemplateService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouNewCreateCampaign;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+public class KuaishouAiAdsNewMaterialCreativityJob {
+
+    @Autowired
+    IAiKuaishouNewCreateCampaign aiKuaishouNewCreateCampaign;
+    @Autowired
+    private IAiKuaishouAccountTargetTemplateService aiKuaishouAccountTargetTemplateService;
+    @XxlJob("kuaishouAiAdsNewMaterialCreativityJob")
+    public void kuaishouAiAdsNewMaterialCreativityJob() {
+        List<AiKuaishouAccountTargetTemplate> accountTargetTemplates = aiKuaishouAccountTargetTemplateService.getAllEffectTemplate();
+        if(null==accountTargetTemplates||accountTargetTemplates.isEmpty()){
+            return;
+        }
+        accountTargetTemplates.forEach(targetTemplate -> aiKuaishouNewCreateCampaign.kuaishouAiAdsNewMaterialCreativity(targetTemplate));
+    }
+
+    @XxlJob("kuaishouAiAdsHotMaterialCreativityJob")
+    public void kuaishouAiAdsHotMaterialCreativityJob() {
+        List<AiKuaishouAccountTargetTemplate> accountTargetTemplates = aiKuaishouAccountTargetTemplateService.getAllEffectTemplate();
+        if(null==accountTargetTemplates||accountTargetTemplates.isEmpty()){
+            return;
+        }
+        accountTargetTemplates.forEach(targetTemplate -> aiKuaishouNewCreateCampaign.kuaishouAiAdsHotMaterialCreativity(targetTemplate));
+    }
+}

+ 3 - 3
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAudienceReportJob.java

@@ -38,8 +38,6 @@ public class KuaishouDailyAudienceReportJob {
 
     @XxlJob("kuaishouDailyAudienceReportJob")
     public void execute() throws Exception {
-        //查询两天前数据  策略
-        String date = DateUtils.getLastDay(DateUtils.date2Str(), 2);
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
         if (null == tokens || tokens.isEmpty()) {
             XxlJobHelper.log("定时获取人群分析报表数据异常:未获取到可用的token");
@@ -49,7 +47,7 @@ public class KuaishouDailyAudienceReportJob {
         //查询有效策略的账户ID
         List<Long> accountIds = kuaishouStrategyService.queryActiveAccount();
         if (Check.isNull(accountIds) || accountIds.size() == 0) {
-            XxlJobHelper.log("定时获取人群分析报表数据异常:获取到有效策略账户信息");
+            XxlJobHelper.log("定时获取人群分析报表数据异常:获取到有效策略账户信息");
             XxlJobHelper.handleFail();
             return;
         }
@@ -65,6 +63,8 @@ public class KuaishouDailyAudienceReportJob {
         if (!Check.isNull(activeTokens) && activeTokens.size() > 0) {
             int page = 1;
             int pageSize = 2000;
+            //查询两天前日期
+            String date = DateUtils.getLastDay(DateUtils.date2Str(), 2);
             activeTokens.forEach(token -> executorService.submit(() -> {
                 getAudienceReportData(token, date, "province", page, pageSize);
                 getAudienceReportData(token, date, "city", page, pageSize);

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

@@ -14,7 +14,7 @@ public class KuaishouEffectVideoJob {
     @Autowired
     private IKuaishouVideoEtlInfoService etlInfoService;
 
-    @XxlJob("kuaishouGroupDailyReportJob")
+    @XxlJob("kuaishouEffectVideoJob")
     public void execute() throws ParseException {
         Date getDate = DateUtils.addDay(new Date(),-1);
         etlInfoService.etlKuaishouVideoInfo(getDate);

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

@@ -0,0 +1,24 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoEtlInfoService;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+@Component
+public class KuaishouEtlVideoJob {
+    @Autowired
+    private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
+    @XxlJob("kuaishouEtlVideoJob")
+    public void execute() throws Exception {
+        Date startDate = DateUtils.addDay(new Date(),-2);
+        for(int i=0;i<=2;i++){
+            Date getDate = DateUtils.addDay(startDate,i);
+            kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
+        }
+    }
+}

+ 104 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouVideoRelateCreativesJob.java

@@ -0,0 +1,104 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouStrategyService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
+import com.alibaba.fastjson.JSONArray;
+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.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 频库-视频关联创意数查询
+ *
+ * @author ZXA
+ */
+@Component
+public class KuaishouVideoRelateCreativesJob {
+    @Autowired
+    private IKuaishouVideoRelateCreativesService kuaishouVideoRelateCreativesService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+    @Autowired
+    private IKuaishouStrategyService kuaishouStrategyService;
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+
+    @XxlJob("kuaishouVideoRelateCreativesJob")
+    public void execute() throws Exception {
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        if (null == tokens || tokens.isEmpty()) {
+            XxlJobHelper.log("定时获取人群分析报表数据异常:未获取到可用的token");
+            XxlJobHelper.handleFail();
+            return;
+        }
+        //查询有效策略的账户ID
+        List<Long> accountIds = kuaishouStrategyService.queryActiveAccount();
+        if (Check.isNull(accountIds) || accountIds.size() == 0) {
+            XxlJobHelper.log("定时获取人群分析报表数据异常:未获取到有效策略账户信息");
+            XxlJobHelper.handleFail();
+            return;
+        }
+        //筛选出有效账户,获取该账户的组级人群报表数据
+        List<CtopOauthToken> activeTokens = new ArrayList<>();
+        for (Long accountId : accountIds) {
+            for (CtopOauthToken token : tokens) {
+                if (token.getAccountId() - accountId == 0) {
+                    activeTokens.add(token);
+                }
+            }
+        }
+        if (!Check.isNull(activeTokens) && activeTokens.size() > 0) {
+            activeTokens.forEach(token -> executorService.submit(() -> {
+                videoRelateCreatives(token.getAccountId());
+            }));
+        }
+    }
+
+    /**
+     * 逐个账户数据处理
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void videoRelateCreatives(Long accountId) {
+        List<KuaiShouVideoGet> KuaiShouVideoGets = videoGetService.selectPhotoIdsByAccountId(accountId);
+        if (!Check.isNull(KuaiShouVideoGets)) {
+            JSONArray dateList = new JSONArray();
+            JSONArray photoIds = new JSONArray();
+            Map<String, Object> statdateMap = new HashMap<>();
+            int count = 0;
+            for (KuaiShouVideoGet video : KuaiShouVideoGets) {
+                count++;
+                if (count < 10) {
+                    photoIds.add(video.getPhotoId());
+                    statdateMap.put(video.getPhotoId(), video.getStatDate());
+                } else {
+                    photoIds.add(video.getPhotoId());
+                    statdateMap.put(video.getPhotoId(), video.getStatDate());
+                    dateList.add(photoIds);
+                    photoIds = new JSONArray();
+                    count = 0;
+                }
+            }
+            dateList.add(photoIds);
+            kuaishouVideoRelateCreativesService.videoRelateCreatives(accountId, dateList, statdateMap);
+        }
+    }
+}

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

@@ -0,0 +1,135 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouCreateService;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+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.RestController;
+
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+@Api(tags = "快手-批量工具")
+@RestController
+@RequestMapping("/kuaishou/create")
+public class KuaiShouCreateController {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService iKuaishouInterfaceService;
+    @Autowired
+    private IKuaiShouCampaignService campaignService;
+    @Autowired
+    private IKuaiShouCreateService kuaiShouCreateService;
+    static ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+    /**
+     * 创建计划
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/campaignCreate")
+    public JSONObject campaignCreate(@RequestBody JSONObject requestJson) {
+        JSONObject result = new JSONObject();
+        try {
+            Long accountId = requestJson.getLong("account_id");
+            CtopOauthToken oauthToken = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            JSONObject campaignJson = new JSONObject();
+            campaignJson.put("campaign_name", requestJson.getString("campaign_name"));
+            campaignJson.put("type", requestJson.getInteger("type"));
+            if (!Check.isNull(requestJson.getLong("day_budget"))) {
+                campaignJson.put("day_budget", requestJson.getLong("day_budget"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("day_budget_schedule"))) {
+                campaignJson.put("day_budget_schedule", requestJson.getJSONArray("day_budget_schedule"));
+            }
+            Map<String, Object> campaignMap = iKuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), accountId, campaignJson);
+            Integer code = (Integer) campaignMap.get("code");
+            if (code != 0) {
+                throw new Exception((String) campaignMap.get("message"));
+            }
+            Long campaignId = (Long) campaignMap.get("campaignId");
+            result.put("code", 0);
+            result.put("message", "SUCCESS");
+            JSONObject data = new JSONObject();
+            data.put("campaign_id", campaignId);
+            data.put("account_id", accountId);
+            KuaiShouCampaign campaign = campaignService.getCampaignByAccountAndCampaign(accountId, campaignId);
+            if (!Check.isNull(campaign)) {
+                data.put("campaign_create_time", campaign.getPutCreateTime());
+            }
+            result.put("data", data);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.put("code", -1);
+            result.put("message", e.getMessage());
+            JSONObject data = new JSONObject();
+            data.put("account_id", requestJson.getLong("account_id"));
+            result.put("data", data);
+
+        }
+        return result;
+    }
+
+
+    /**
+     * 创建组 创意
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/createUnitAndCreative")
+    public JSONObject createUnitAndCreative(@RequestBody JSONObject requestJson) {
+        JSONObject result = new JSONObject();
+        try {
+            Long accountId = requestJson.getLong("account_id");
+            if (Check.isNull(accountId)) {
+                throw new Exception("请填写账户id进行创建");
+            }
+            CtopOauthToken oauthToken = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            Long campaign_id = requestJson.getLong("campaign_id");
+            if (Check.isNull(campaign_id)) {
+                throw new Exception("请填写需要创建的计划id");
+            }
+            JSONArray group_list = requestJson.getJSONArray("group_list");
+            if (Check.isNull(group_list)) {
+                throw new Exception("请填写需要创建的组信息");
+            }
+            executorService.submit(() -> kuaiShouCreateService.createUnitAndCreative(oauthToken, campaign_id, group_list));
+            result.put("code", 0);
+            result.put("message", "异步执行中,等待回调...");
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.put("code", -1);
+            result.put("message", e.getMessage());
+            JSONObject data = new JSONObject();
+            data.put("account_id", requestJson.getLong("account_id"));
+            result.put("data", data);
+
+        }
+        return result;
+
+    }
+
+
+}

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

@@ -0,0 +1,245 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouVideoLastTime;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouVideoLastTimeService;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+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.RestController;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Api(tags = "快手-批量工具")
+@RestController
+@RequestMapping("/kuaishou/material")
+public class KuaiShouMaterialControer {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService iKuaishouInterfaceService;
+    @Autowired
+    private IKuaiShouVideoLastTimeService lastTimeService;
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+    @Autowired
+    private IKuaishouVideoRelateCreativesService relateCreativesService;
+
+    /**
+     * 查询上新素材
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/getNewVideoList")
+    public JSONObject getNewVideo(@RequestBody JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参不能为空");
+            }
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户id不能为空");
+            }
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("未获取账号授权信息");
+            }
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            iKuaishouInterfaceService.getVideoList(token, nowDate, nowDate);
+            iKuaishouInterfaceService.getSuZaoList(token.getAccessToken(), accountId, 1, nowDate, nowDate);
+            KuaiShouVideoLastTime videoLastTime = lastTimeService.getById(accountId);
+            Date startTime;
+            Date endDate = new Date();
+            if (!Check.isNull(videoLastTime)) {
+                startTime = videoLastTime.getLastTime();
+            } else {
+                startTime = DateUtils.addTime(endDate, 5);
+            }
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("startTime", DateUtils.formatDate(startTime, "yyyy-MM-dd HH:mm:ss"));
+            requestMap.put("endTime", DateUtils.formatDate(endDate, "yyyy-MM-dd HH:mm:ss"));
+            requestMap.put("accountId", accountId);
+            List<JSONObject> materialList = videoGetService.getVideoListByMap(requestMap);
+            if (!Check.isNull(materialList)) {
+                for (int i = 0; i < materialList.size(); i++) {
+                    JSONObject materialJson = materialList.get(i);
+                    String signature = materialJson.getString("signature");
+                    List<String> imageList = lastTimeService.getImageListByMd5(signature);
+                    materialJson.put("imageList", imageList);
+                }
+                KuaiShouVideoLastTime lastTime = new KuaiShouVideoLastTime();
+                lastTime.setId(accountId);
+                lastTime.setLastTime(endDate);
+                lastTimeService.saveOrUpdate(lastTime);
+                returnJson.put("code", 0);
+                returnJson.put("message", "SUCCESS");
+                returnJson.put("data", materialList);
+            } else {
+                returnJson.put("code", -1);
+                returnJson.put("message", "暂未新上素材");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    @PostMapping(value = "/getHistoryVideoList")
+    public JSONObject getHistoryVideoList(@RequestBody JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参不能为空");
+            }
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户id不能为空");
+            }
+
+
+            String startDate = requestJson.getString("startDate");
+            if (Check.isNull(startDate)) {
+                throw new Exception("请输入开始查询时间");
+            }
+
+            String endDate = requestJson.getString("endDate");
+            if (Check.isNull(endDate)) {
+                throw new Exception("请输入结束查询时间");
+            }
+
+            Integer createCount = requestJson.getInteger("createCount");
+            if (Check.isNull(createCount) || createCount == 0) {
+                throw new Exception("请输入最小关联数");
+            }
+
+            Integer num = requestJson.getInteger("num");
+            if (Check.isNull(num) || num == 0) {
+                throw new Exception("请输入查询条数");
+            }
+
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("startTime", startDate);
+            requestMap.put("endTime", endDate);
+            requestMap.put("accountId", accountId);
+            requestMap.put("num", num);
+            requestMap.put("createCount", createCount);
+            List<JSONObject> materialList = relateCreativesService.getVideoListByMap(requestMap);
+            if (!Check.isNull(materialList)) {
+                for (int i = 0; i < materialList.size(); i++) {
+                    JSONObject materialJson = materialList.get(i);
+                    KuaiShouVideoGet videoGet = videoGetService.getVideoByPhotoId(materialJson.getLong("photo_id"));
+                    if (!Check.isNull(videoGet)) {
+                        String signature = videoGet.getSignature();
+                        materialJson.put("signature", signature);
+                        materialJson.put("video_url", videoGet.getUrl());
+                        materialJson.put("channel_type", videoGet.getChannelType());
+                        List<String> imageList = lastTimeService.getImageListByMd5(signature);
+                        materialJson.put("imageList", imageList);
+                    }
+                }
+                returnJson.put("code", 0);
+                returnJson.put("message", "SUCCESS");
+                returnJson.put("data", materialList);
+            } else {
+                returnJson.put("code", -1);
+                returnJson.put("message", "暂未新上素材");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    @PostMapping(value = "/getHistoryTopVideoList")
+    public JSONObject getHistoryTopVideoList(@RequestBody JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参不能为空");
+            }
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户id不能为空");
+            }
+
+
+            String startDate = requestJson.getString("startDate");
+            if (Check.isNull(startDate)) {
+                throw new Exception("请输入开始查询时间");
+            }
+
+            String endDate = requestJson.getString("endDate");
+            if (Check.isNull(endDate)) {
+                throw new Exception("请输入结束查询时间");
+            }
+
+            Integer createCount = requestJson.getInteger("createCount");
+            if (Check.isNull(createCount) || createCount == 0) {
+                throw new Exception("请输入最小关联数");
+            }
+
+            Integer num = requestJson.getInteger("num");
+            if (Check.isNull(num) || num == 0) {
+                throw new Exception("请输入查询条数");
+            }
+
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("startTime", startDate);
+            requestMap.put("endTime", endDate);
+            requestMap.put("accountId", accountId);
+            requestMap.put("num", num);
+            requestMap.put("createCount", createCount);
+            List<JSONObject> materialList = relateCreativesService.getVideoListByMap(requestMap);
+            if (!Check.isNull(materialList)) {
+                for (int i = 0; i < materialList.size(); i++) {
+                    JSONObject materialJson = materialList.get(i);
+                    KuaiShouVideoGet videoGet = videoGetService.getVideoByPhotoId(materialJson.getLong("photo_id"));
+                    if (!Check.isNull(videoGet)) {
+                        String signature = videoGet.getSignature();
+                        materialJson.put("signature", signature);
+                        materialJson.put("video_url", videoGet.getUrl());
+                        materialJson.put("channel_type", videoGet.getChannelType());
+                        List<String> imageList = lastTimeService.getImageListByMd5(signature);
+                        materialJson.put("imageList", imageList);
+                    }
+                }
+                returnJson.put("code", 0);
+                returnJson.put("message", "SUCCESS");
+                returnJson.put("data", materialList);
+            } else {
+                returnJson.put("code", -1);
+                returnJson.put("message", "暂未新上素材");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+}

+ 77 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountTargetTemplate.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 io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 账户自动投放定向模板
+ * @author jeecg-boot
+ * @date   2021-01-07
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_ai_kuaishou_auto_creative_account_info")
+public class AiKuaishouAccountTargetTemplate {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**账户ID*/
+	private Long accountId;
+	/**营销目标{1应用安装},{2电商下单},{3推广品牌},{4营销线上},{5应用活跃}*/
+	private String marketingGoal;
+	/**请勾选投放应用已上架的应用商店*/
+	private String appStore;
+	/**是否优先从应用商店下载 true false*/
+	private String useAppMarket;
+	/**应用id集*/
+	private String appIds;
+	/**地域*/
+	private String region;
+	/**年龄段:{[]:不限}{18:18-23岁}{24:24-30岁}{31:31-40岁}{41:41-49岁}{50:50岁+*/
+	private String agesRange;
+	/**性别 1:女性, 2:男性, 0:不限*/
+	private Integer gender;
+	/**操作系统 1: Android, 2: iOS, 0:不限*/
+	private Integer platformOs;
+	/**自定义人群 0不限,1:定向,:2:排除,:3同时定向排除*/
+	private String customCrowd;
+	/**定向人群包*/
+	private String population;
+	/**排除人群包*/
+	private String excludePopulation;
+	/**出价类型(优化目标) 2点击数(CPC),10转化数(OCPM)*/
+	private Integer bidType;
+	/**封面点击出价*/
+	private Integer bid;
+	/**转化目标,2:行为数,180:激活数,53:表单数,190: 付费,191:首日ROI 。。。*/
+	private Integer ocpxActionType;
+	/**转化目标出价*/
+	private Integer cpaBid;
+	/**广告位 1:优选广告位;*/
+	private String sceneId;
+	/**下载详情页ID,建站id*/
+	private String siteId;
+	/**第三方开始播放监测链接*/
+	private String impressionUrl;
+	/**第三方点击检测链接*/
+	private String clickTrackUrl;
+	/**第三方点击按钮监测链接*/
+	private String actionbarClickUrl;
+	/**状态*/
+	private Integer status;
+	/**单个视频搭配图片个数*/
+	private Integer imageNumber;
+	/**创建时间*/
+	private Date createTime;
+	/**updateTime*/
+	private Date updateTime;
+	private String titlePrefix;
+	private String titleMiddle;
+}

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

@@ -0,0 +1,42 @@
+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 lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 策略创意表
+ */
+@Data
+@TableName("ctop_ai_kuaishou_strategy_map_creative")
+public class AiKuaishouStrategyMapCreative {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**账户id*/
+	private Long accountId;
+	/**计划id*/
+	private Long campaignId;
+	/**组id*/
+	private Long unitId;
+	/**创意id*/
+	private Long creativeId;
+	/**策略_定向关联id*/
+	private Long strategyTargetUnionId;
+	/**素材签名*/
+	private String videoSignature;
+	/**策略id*/
+	private Long strategyId;
+	/**是否创建成功*/
+	private Integer createSuccess;
+	/**失败原因*/
+	private String detail;
+	/**createTime*/
+	private Date createTime;
+	/**updateTime*/
+	private Date updateTime;
+}

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

@@ -0,0 +1,41 @@
+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.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 策略_策略模板中间表
+ */
+@Data
+@TableName("ctop_ai_kuaishou_strategy_middle")
+public class AiKuaishouStrategyMiddle {
+
+	/**middle_id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**策略id*/
+	private Long strategyId;
+	/**策略模板id*/
+	private Long strategyTemplateId;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+
+	public AiKuaishouStrategyMiddle(Long templateId, Long strategyId) {
+		this.strategyTemplateId = templateId;
+		this.strategyId = strategyId;
+		this.createTime = new Date();
+		this.updateTime = new Date();
+	}
+
+	public AiKuaishouStrategyMiddle() {
+	}
+}

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

@@ -0,0 +1,37 @@
+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.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 定向基础表
+ */
+@Data
+@TableName("ctop_ai_kuaishou_strategy_target_base")
+public class AiKuaishouStrategyTargetBase {
+
+	/**target_base_id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**定向类型:age|devices|用户行为|行业偏好等*/
+	private String targetType;
+	/**定向内容: 24-30|31-40|41-49 等*/
+	private String targetContent;
+	/**状态1可用 0不可用*/
+	private Integer status;
+	/**
+	 * 数据类型
+	 */
+	private String type;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+}

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

@@ -0,0 +1,30 @@
+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 lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 智能投放快手定向策略详细信息
+ */
+@Data
+@TableName("ctop_ai_kuaishou_strategy_target_details")
+public class AiKuaishouStrategyTargetDetails {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**策略id*/
+	private Long strategyId;
+	/**定向id*/
+	private Long targetId;
+	/**测试方向: age 、 devices、  用户行为 、 行业偏好 、付费人群包 等*/
+	private String type;
+	/**status*/
+	private Integer status;
+	private Date createTime;
+	private Date updateTime;
+}

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

@@ -0,0 +1,40 @@
+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.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 策略_定向中间表
+ */
+@Data
+@TableName("ctop_ai_kuaishou_strategy_target_union")
+public class AiKuaishouStrategyTargetUnion {
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**middle_id*/
+	private Long strategyMiddleId;
+	/**定向id*/
+	private Long strategyTargetId;
+	/**实际使用定向内用*/
+	private String actualTargetContent;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+
+	public AiKuaishouStrategyTargetUnion() {
+	}
+
+	public AiKuaishouStrategyTargetUnion(Long strategyMiddleId, Long strategyTargetId, String targetContent) {
+		this.strategyMiddleId = strategyMiddleId;
+		this.strategyTargetId = strategyTargetId;
+		this.actualTargetContent = targetContent;
+	}
+}

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

@@ -0,0 +1,46 @@
+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.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 策略模板表
+ */
+@Data
+@TableName("ctop_ai_kuaishou_strategy_template")
+public class AiKuaishouStrategyTemplate {
+
+	/**策略模板id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**账户id*/
+	private Long accountId;
+	/**策略模板名称*/
+	private String templateName;
+	/**策略类型 1:素材+出价 2:素材+定向  3:时间+出价 */
+	private Integer templateType;
+	/**测试方向*/
+	private String testDirection;
+	/**素材选择方式*/
+	private String materialSelectMethod;
+
+	/**
+	 * 组内素材组合模式
+	 * single 单视频+不同封面
+	 * mixed  多视频+各自封面
+	 */
+	private String materialFixType;
+	/**状态1可用 0不可用*/
+	private Integer status;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+}

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

@@ -0,0 +1,56 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+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;
+
+/**
+ * ai获取素材上次截止日期
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-01-11
+ */
+@Data
+@TableName("ctop_kuaishou_video_last_time")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_video_last_time对象", description = "ai获取素材上次截止日期")
+public class KuaiShouVideoLastTime {
+
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long Id;
+    /**
+     * 素材最后上新时间
+     */
+    @ApiModelProperty(value = "素材最后上新时间")
+    private Date lastTime;
+    /**
+     * 创建时间
+     */
+    @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;
+}

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

@@ -0,0 +1,23 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+
+/**
+ *  Created by JQ.bi on 2020.12.16
+ */
+@Mapper
+public interface AiKuaiShouStrategyListPageMapper {
+
+    List<JSONObject> queryStrategyBy(@Param("accountIds") JSONArray accountIds, @Param("strategyName") String strategyName, @Param("strategyState") Integer strategyState, @Param("id") Long id);
+
+    List<JSONObject> queryCampaignByStrategyId(@Param("strategyId") Long strategyId, @Param("campaignName") String campaignName, @Param("campaignId") Long campaignId, @Param("status") Integer status);
+
+    List<JSONObject> queryUnitByCampaignId(@Param("campaignId") Long campaignId, @Param("unitName") String unitName, @Param("unitId") Long unitId, @Param("status") Integer status);
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 账户自动投放定向模板
+ * @author: jeecg-boot
+ * @date:   2021-01-07
+ * @cersion: V1.0
+ */
+public interface AiKuaishouAccountTargetTemplateMapper extends BaseMapper<AiKuaishouAccountTargetTemplate> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyMapCreative;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 策略创意表
+ * @author: jeecg-boot
+ * @date:   2020-12-15
+ * @cersion: V1.0
+ */
+public interface AiKuaishouStrategyMapCreativeMapper extends BaseMapper<AiKuaishouStrategyMapCreative> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyMiddle;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 策略_策略模板中间表
+ * @author: jeecg-boot
+ * @date:   2020-12-15
+ * @cersion: V1.0
+ */
+public interface AiKuaishouStrategyMiddleMapper extends BaseMapper<AiKuaishouStrategyMiddle> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyTargetBase;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 定向基础表
+ * @author: jeecg-boot
+ * @date:   2020-12-15
+ * @cersion: V1.0
+ */
+public interface AiKuaishouStrategyTargetBaseMapper extends BaseMapper<AiKuaishouStrategyTargetBase> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyTargetDetails;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 智能投放快手定向策略详细信息
+ * @author: jeecg-boot
+ * @date:   2020-12-10
+ * @cersion: V1.0
+ */
+public interface AiKuaishouStrategyTargetDetailsMapper extends BaseMapper<AiKuaishouStrategyTargetDetails> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyTargetUnion;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 策略_定向中间表
+ * @author: jeecg-boot
+ * @date:   2020-12-15
+ * @cersion: V1.0
+ */
+public interface AiKuaishouStrategyTargetUnionMapper extends BaseMapper<AiKuaishouStrategyTargetUnion> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyTemplate;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 策略模板表
+ * @author: jeecg-boot
+ * @date:   2020-12-15
+ * @cersion: V1.0
+ */
+public interface AiKuaishouStrategyTemplateMapper extends BaseMapper<AiKuaishouStrategyTemplate> {
+
+}

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

@@ -0,0 +1,33 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface IAiKuaiShouReportAnalyzeMapper {
+
+    List<JSONObject> queryStrategyByAccountId(@Param("accountId") Long accountId);
+
+    List<JSONObject> queryTargetByStrategyId(@Param("strategyId") Long StrategyId);
+
+    List<JSONObject> queryMaterialByStrategyId(@Param("strategyId") Long strategyId);
+
+    List<JSONObject> queryTargetReportBy(@Param("accountId") Long accountId, @Param("strategyId") Long strategyId, @Param("codes") JSONArray codes, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryMaterialReportBy(@Param("accountId") Long accountId, @Param("strategyId") Long strategyId, @Param("targetIds") JSONArray targetIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryAgeChartByTarget(@Param("strategyId") Long strategyId, @Param("targetIds") JSONArray targetIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryAgeChartByMaterial(@Param("strategyId") Long strategyId, @Param("codes") JSONArray codes, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryGenderChartByTarget(@Param("strategyId") Long strategyId, @Param("targetIds") JSONArray targetIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryGenderChartByMaterial(@Param("strategyId") Long strategyId, @Param("codes") JSONArray codes, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryRegionChartByTarget(@Param("strategyId") Long strategyId, @Param("targetIds") JSONArray targetIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> queryRegionChartByMaterial(@Param("strategyId") Long strategyId, @Param("codes") JSONArray codes, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+}

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

@@ -0,0 +1,18 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouVideoLastTime;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import java.util.List;
+
+/**
+ * ai获取素材上次截止日期
+ *
+ * @author: jeecg-boot
+ * @date: 2021-01-11
+ * @cersion: V1.0
+ */
+public interface KuaiShouVideoLastTimeMapper extends BaseMapper<KuaiShouVideoLastTime> {
+
+    List<String> getImageListByMd5(String signature);
+}

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

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

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

@@ -0,0 +1,465 @@
+<?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.IAiKuaiShouReportAnalyzeMapper">
+
+    <select id="queryStrategyByAccountId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT id,
+               strategy_name
+        FROM ctop_kuaishou_strategy
+        WHERE account_id = #{accountId}
+    </select>
+
+    <select id="queryTargetByStrategyId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t4.id,
+               t4.target_type,
+               t4.target_content
+        FROM ctop_kuaishou_strategy t1
+                 LEFT JOIN ctop_ai_kuaishou_strategy_middle t2 on t1.id = t2.strategy_id
+                 LEFT JOIN ctop_ai_kuaishou_strategy_target_union t3 on t2.id = t3.strategy_middle_id
+                 LEFT JOIN ctop_ai_kuaishou_strategy_target_base t4 on t3.strategy_target_id = t4.id
+        where t1.id = #{strategyId}
+    </select>
+
+    <select id="queryMaterialByStrategyId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT DISTINCT t2.code,
+                        t2.material_name,
+                        t2.cover_url
+        FROM ctop_ai_kuaishou_strategy_map_creative t1
+                 LEFT JOIN ctop_material_info t2 ON t1.video_signature = t2.CODE
+        WHERE t1.strategy_id = #{strategyId}
+            and t2.code is not null
+        GROUP BY t2.code
+    </select>
+
+    <select id="queryTargetReportBy" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        r.target_type as targetType,
+        r.target_content as targetContent,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_report_daily_group t LEFT JOIN (SELECT
+        unit_id,
+        t3.target_type,
+        t3.target_content
+        FROM
+        ctop_ai_kuaishou_strategy_map_creative t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_union t2 on t1.strategy_target_union_id=t2.id
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_base t3 on t2.strategy_target_id=t3.id
+        WHERE
+        t1.strategy_id= #{strategyId}
+        and t1.video_signature in
+        <foreach item="item" index="index" collection="codes"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY t1.unit_id,t3.id) r on t.unit_id=r.unit_id
+        where account_id=#{accountId}
+        <if test="startDate != null">
+            AND t.stat_date >=#{startDate}
+        </if>
+        <if test="endDate != null">
+            AND t.stat_date &lt;=#{endDate}
+        </if>
+        GROUP BY t.unit_id
+    </select>
+
+    <select id="queryMaterialReportBy" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT r.creativeCount,
+        r.scenes,
+        t.signature as code,
+        t.cover_url as coverUrl,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_report_daily_material t LEFT JOIN (SELECT
+        t1.video_signature as code,
+        COUNT(t1.video_signature) as creativeCount,
+        t4.scenes
+        FROM
+        ctop_ai_kuaishou_strategy_map_creative t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_union t2 on t1.strategy_target_union_id=t2.id
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_base t3 on t2.strategy_target_id=t3.id
+        LEFT JOIN ctop_kuaishou_strategy t4 on t1.strategy_id=t4.id
+        WHERE
+        t1.strategy_id= #{strategyId}
+        and t3.id in
+        <foreach item="item" index="index" collection="targetIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY t1.video_signature) r on t.signature=r.`code`
+        where account_id=#{accountId}
+        <if test="startDate != null">
+            AND t.stat_date >=#{startDate}
+        </if>
+        <if test="endDate != null">
+            AND t.stat_date &lt;=#{endDate}
+        </if>
+        GROUP BY t.signature
+    </select>
+
+    <select id="queryAgeChartByTarget" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            t.age_segment as ageSegment,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+            ctop_kuaishou_audience_report_daily_age t
+        WHERE
+                unit_id IN (
+                SELECT
+                    t1.unit_id
+                FROM
+                    ctop_ai_kuaishou_strategy_map_creative t1
+                        LEFT JOIN ctop_ai_kuaishou_strategy_target_union t2 ON t1.strategy_target_union_id = t2.id
+                        LEFT JOIN ctop_ai_kuaishou_strategy_target_base t3 ON t2.strategy_target_id = t3.id
+                        LEFT JOIN ctop_kuaishou_strategy t4 ON t1.strategy_id = t4.id
+                WHERE
+                    t1.strategy_id = #{strategyId}
+                  AND t3.id in
+        <foreach item="item" index="index" collection="targetIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+                GROUP BY
+                    t1.unit_id
+            )
+        GROUP BY
+            t.age_segment
+    </select>
+
+    <select id="queryAgeChartByMaterial" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            t.age_segment as ageSegment,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+            ctop_kuaishou_audience_report_daily_age t
+        WHERE
+                unit_id IN (
+                SELECT
+                    unit_id
+                FROM
+                    ctop_ai_kuaishou_strategy_map_creative
+                WHERE
+                    strategy_id = #{strategyId}
+                  AND video_signature in
+        <foreach item="item" index="index" collection="codes"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+                GROUP BY
+                    unit_id
+            )
+        GROUP BY
+            t.age_segment
+    </select>
+
+    <select id="queryGenderChartByTarget" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t.gender,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_audience_report_daily_gender t
+        WHERE
+        unit_id IN (
+        SELECT
+        t1.unit_id
+        FROM
+        ctop_ai_kuaishou_strategy_map_creative t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_union t2 ON t1.strategy_target_union_id = t2.id
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_base t3 ON t2.strategy_target_id = t3.id
+        LEFT JOIN ctop_kuaishou_strategy t4 ON t1.strategy_id = t4.id
+        WHERE
+        t1.strategy_id = #{strategyId}
+        AND t3.id in
+        <foreach item="item" index="index" collection="targetIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY
+        t1.unit_id
+        )
+        GROUP BY
+        t.gender
+    </select>
+
+    <select id="queryGenderChartByMaterial" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t.gender,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_audience_report_daily_gender t
+        WHERE
+        unit_id IN (
+        SELECT
+        unit_id
+        FROM
+        ctop_ai_kuaishou_strategy_map_creative
+        WHERE
+        strategy_id = #{strategyId}
+        AND video_signature in
+        <foreach item="item" index="index" collection="codes"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY
+        unit_id
+        )
+        GROUP BY
+        t.gender
+    </select>
+
+    <select id="queryRegionChartByTarget" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t.province,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_audience_report_daily_province t
+        WHERE
+        unit_id IN (
+        SELECT
+        t1.unit_id
+        FROM
+        ctop_ai_kuaishou_strategy_map_creative t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_union t2 ON t1.strategy_target_union_id = t2.id
+        LEFT JOIN ctop_ai_kuaishou_strategy_target_base t3 ON t2.strategy_target_id = t3.id
+        LEFT JOIN ctop_kuaishou_strategy t4 ON t1.strategy_id = t4.id
+        WHERE
+        t1.strategy_id = #{strategyId}
+        AND t3.id in
+        <foreach item="item" index="index" collection="targetIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY
+        t1.unit_id
+        )
+        GROUP BY
+        t.province
+    </select>
+
+    <select id="queryRegionChartByMaterial" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t.province,
+        IFNULL(sum(t.charge),0) as cost,
+        IFNULL(sum(t.photo_show),0) as photoShow,
+        IFNULL(sum(t.photo_click),0) as photoClick,
+        CASE WHEN sum(t.photo_click) / sum(t.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.photo_click) /
+        sum(t.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t.aclick),0) as aclick,
+        IFNULL(sum(t.bclick),0) as bclick,
+        CASE WHEN sum(t.bclick) / sum(t.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t.bclick) / sum(t.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t.charge) / sum(t.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t.charge) / sum(t.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t.charge) / sum(t.photo_click)), 2)
+        END AS cpc ,
+        IFNULL(sum(t.activation),0) as active,
+        CASE WHEN sum(t.charge) / sum(t.activation) IS NULL THEN 0 ELSE sum(t.charge) / sum(t.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t.activation) / sum(t.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t.activation) /
+        sum(t.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t.event_register),0) as register,
+        CASE WHEN sum(t.charge) / sum(t.event_register) IS NULL THEN 0 ELSE round(sum(t.charge)/sum(t.event_register),3)
+        end as activeRegisterCost ,
+        CASE WHEN sum(t.event_register) / sum(t.activation) IS NULL THEN 0 ELSE concat(round(sum(t.event_register) /
+        sum(t.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t.event_next_day_stay) / sum(t.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t.event_next_day_stay) / sum(t.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_audience_report_daily_province t
+        WHERE
+        unit_id IN (
+        SELECT
+        unit_id
+        FROM
+        ctop_ai_kuaishou_strategy_map_creative
+        WHERE
+        strategy_id = #{strategyId}
+        AND video_signature in
+        <foreach item="item" index="index" collection="codes"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY
+        unit_id
+        )
+        GROUP BY
+        t.province
+    </select>
+
+</mapper>

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

@@ -0,0 +1,192 @@
+<?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.AiKuaiShouStrategyListPageMapper">
+
+    <select id="queryStrategyBy" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.id,
+        t1.strategy_state as strategyState,
+        t1.strategy_name as strategyName,
+        t1.create_time as createTime,
+        t1.account_id as accountId,
+        (select auth_name from ctop_user_allocation where account_id=t1.account_id limit 1) as authName,
+        '' as status,
+        t1.scenes,
+        t1.budget,
+        IFNULL(sum(t3.charge),0) as cost,
+        IFNULL(sum(t3.photo_show),0) as photoShow,
+        IFNULL(sum(t3.photo_click),0) as photoClick,
+        CASE WHEN sum(t3.photo_click) / sum(t3.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t3.photo_click) / sum(t3.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t3.aclick),0) as aclick,
+        IFNULL(sum(t3.bclick),0) as bclick,
+        CASE WHEN sum(t3.bclick) / sum(t3.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t3.bclick) / sum(t3.aclick)) * 100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t3.charge) / sum(t3.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t3.charge) / sum(t3.photo_show)) * 1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t3.charge) / sum(t3.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t3.charge) / sum(t3.photo_click)), 2) END AS cpc ,
+        IFNULL(sum(t3.activation),0) as active,
+        CASE WHEN sum(t3.charge) / sum(t3.activation) IS NULL THEN 0 ELSE sum(t3.charge) / sum(t3.activation) end AS activeCost ,
+        CASE WHEN sum(t3.activation) / sum(t3.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t3.activation) / sum(t3.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t3.event_register),0) as register,
+        CASE WHEN sum(t3.charge) / sum(t3.event_register) IS NULL THEN 0 ELSE round(sum(t3.charge)/sum(t3.event_register),3) end as activeRegisterCost ,
+        CASE WHEN sum(t3.event_register) / sum(t3.activation) IS NULL THEN 0 ELSE concat(round(sum(t3.event_register) / sum(t3.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t3.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t3.event_next_day_stay) / sum(t3.activation) IS NULL THEN 0 ELSE concat(round(sum(t3.event_next_day_stay) / sum(t3.activation)*100,2),'%') end as nextDayOpenRate
+        FROM (
+        SELECT
+        DISTINCT t2.campaign_id,
+        t1.id,
+        t1.strategy_state,
+        t1.strategy_name,
+        t1.create_time,
+        t1.account_id,
+        '' as status,
+        t1.scenes,
+        t1.budget
+        from ctop_kuaishou_strategy t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_map_creative t2 on t1.id=t2.strategy_id
+        where t1.account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        AND t1.strategy_name like '%${strategyName}%'
+        <if test="strategyState != null">
+            AND t1.strategy_state= #{strategyState}
+        </if>
+        <if test="id != null">
+            AND t1.id=#{id}
+        </if>
+        ) t1 left join ctop_kuaishou_report_daily_campaign t3 on t1.campaign_id=t3.campaign_id
+        group by t1.campaign_id
+        order by t1.create_time desc
+    </select>
+
+    <select id="queryCampaignByStrategyId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.campaign_id as campaignId,
+        t1.campaign_name as campaignName,
+        t1.status,
+        t3.id as strategyId,
+        t3.strategy_name as strategyName,
+        IFNULL(sum(t1.charge),0) as cost,
+        IFNULL(sum(t1.photo_show),0) as photoShow,
+        IFNULL(sum(t1.photo_click),0) as photoClick,
+        CASE WHEN sum(t1.photo_click) / sum(t1.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.photo_click) /
+        sum(t1.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t1.aclick),0) as aclick,
+        IFNULL(sum(t1.bclick),0) as bclick,
+        CASE WHEN sum(t1.bclick) / sum(t1.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.bclick) / sum(t1.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t1.charge) / sum(t1.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t1.charge) / sum(t1.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_click)),
+        2) END AS cpc ,
+        IFNULL(sum(t1.activation),0) as active,
+        CASE WHEN sum(t1.charge) / sum(t1.activation) IS NULL THEN 0 ELSE sum(t1.charge) / sum(t1.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t1.activation) / sum(t1.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t1.activation) /
+        sum(t1.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t1.event_register),0) as register,
+        CASE WHEN sum(t1.charge) / sum(t1.event_register) IS NULL THEN 0 ELSE
+        round(sum(t1.charge)/sum(t1.event_register),3) end as activeRegisterCost ,
+        CASE WHEN sum(t1.event_register) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_register) /
+        sum(t1.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t1.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t1.event_next_day_stay) / sum(t1.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t1.event_next_day_stay) / sum(t1.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        (
+        SELECT
+        DISTINCT t2.campaign_id,
+        t1.id,
+        t1.strategy_state,
+        t1.strategy_name,
+        t1.create_time,
+        t1.account_id,
+        '' as status,
+        t1.scenes,
+        t1.budget from ctop_kuaishou_strategy t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_map_creative t2 on t1.id=t2.strategy_id
+        where t1.id=#{strategyId}
+        ) t3 left join ctop_kuaishou_report_daily_campaign t1 on t3.campaign_id=t1.campaign_id
+        WHERE
+        1=1
+        <if test="campaignName != null">
+            and t1.campaign_name like '%${campaignName}}%'
+        </if>
+        <if test="campaignId != null">
+            and t1.campaign_id=#{campaignId}
+        </if>
+        <if test="status != null">
+            AND t1.status=#{status}
+        </if>
+        GROUP BY t1.campaign_id
+        order by t1.create_time desc
+    </select>
+
+    <select id="queryUnitByCampaignId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.campaign_id as campaignId,
+        t1.campaign_name as campaignName,
+        t1.unit_id as unitId,
+        t1.unit_name as unitName,
+        t1.status,
+        t3.id as strategyId,
+        t3.strategy_name as strategyName,
+        IFNULL(sum(t1.charge),0) as cost,
+        IFNULL(sum(t1.photo_show),0) as photoShow,
+        IFNULL(sum(t1.photo_click),0) as photoClick,
+        CASE WHEN sum(t1.photo_click) / sum(t1.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.photo_click) /
+        sum(t1.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t1.aclick),0) as aclick,
+        IFNULL(sum(t1.bclick),0) as bclick,
+        CASE WHEN sum(t1.bclick) / sum(t1.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.bclick) / sum(t1.aclick)) *
+        100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t1.charge) / sum(t1.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_show)) *
+        1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t1.charge) / sum(t1.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_click)),
+        2) END AS cpc ,
+        IFNULL(sum(t1.activation),0) as active,
+        CASE WHEN sum(t1.charge) / sum(t1.activation) IS NULL THEN 0 ELSE sum(t1.charge) / sum(t1.activation) end AS
+        activeCost ,
+        CASE WHEN sum(t1.activation) / sum(t1.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t1.activation) /
+        sum(t1.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t1.event_register),0) as register,
+        CASE WHEN sum(t1.charge) / sum(t1.event_register) IS NULL THEN 0 ELSE
+        round(sum(t1.charge)/sum(t1.event_register),3) end as activeRegisterCost ,
+        CASE WHEN sum(t1.event_register) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_register) /
+        sum(t1.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t1.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t1.event_next_day_stay) / sum(t1.activation) IS NULL THEN 0 ELSE
+        concat(round(sum(t1.event_next_day_stay) / sum(t1.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        (
+        SELECT
+        DISTINCT
+        t2.unit_id,
+        t2.campaign_id,
+        t1.id,
+        t1.strategy_state ,
+        t1.strategy_name ,
+        t1.create_time ,
+        t1.account_id,
+        '' as status,
+        t1.scenes,
+        t1.budget from ctop_kuaishou_strategy t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_map_creative t2 on t1.id=t2.strategy_id
+        where t2.campaign_id=#{campaignId}
+        ) t3 left join ctop_kuaishou_report_daily_group t1 on t3.unit_id=t1.unit_id
+        where
+        1=1
+        <if test="unitName != null">
+            and t1.unit_name like '%${unitName}}%'
+        </if>
+        <if test="unitId != null">
+            and t1.unit_id=#{unitId}
+        </if>
+        <if test="status != null">
+            AND t1.status=#{status}
+        </if>
+        GROUP BY t1.unit_id
+        order by t1.create_time desc
+    </select>
+</mapper>

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

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

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

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

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

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

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

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

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

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

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

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

+ 12 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaiShouVideoLastTimeMapper.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.KuaiShouVideoLastTimeMapper">
+    <select id="getImageListByMd5" resultType="java.lang.String">
+      select
+      signature
+      from ctop_material_cut_frame
+      where video_signature = #{md5}
+      limit 15
+    </select>
+
+</mapper>

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

@@ -0,0 +1,23 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+
+import java.util.List;
+import java.util.Map;
+
+public interface IAiKuaiShouReportAnalyzeService {
+
+    List<JSONObject> getStrategyAndTarget(Long accountId);
+
+    List<JSONObject> getStrategyAndMaterial(Long accountId);
+
+    PageInfo<JSONObject> getTargetReportBy(JSONObject params);
+
+    PageInfo<JSONObject> getMaterialReportBy(JSONObject params);
+
+    Map<String,Object> getTargetChartBy(JSONObject params);
+
+    Map<String,Object> getMaterialChartBy(JSONObject params);
+
+}

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+
+/**
+ *  Created by JQ.bi on 2020.12.16
+ */
+public interface IAiKuaiShouStrategyListPageService {
+
+    PageInfo<JSONObject> pageStrategy(JSONObject params);
+
+    PageInfo<JSONObject> pageCampaign(JSONObject params);
+
+    PageInfo<JSONObject> pageUnit(JSONObject params);
+
+}

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

@@ -0,0 +1,18 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * @Description: 账户自动投放定向模板
+ * @Author: jeecg-boot
+ * @Date:   2021-01-07
+ * @Version: V1.0
+ */
+public interface IAiKuaishouAccountTargetTemplateService extends IService<AiKuaishouAccountTargetTemplate> {
+
+    List<AiKuaishouAccountTargetTemplate> getAllEffectTemplate();
+
+}

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

@@ -0,0 +1,9 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
+
+public interface IAiKuaishouNewCreateCampaign {
+    void kuaishouAiAdsNewMaterialCreativity(AiKuaishouAccountTargetTemplate targetTemplate);
+
+    void kuaishouAiAdsHotMaterialCreativity(AiKuaishouAccountTargetTemplate targetTemplate);
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyMapCreative;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 策略创意表
+ * @Author: jeecg-boot
+ * @Date:   2020-12-15
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyMapCreativeService extends IService<AiKuaishouStrategyMapCreative> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyMiddle;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 策略_策略模板中间表
+ * @Author: jeecg-boot
+ * @Date:   2020-12-15
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyMiddleService extends IService<AiKuaishouStrategyMiddle> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyTemplate;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 智能投放策略信息
+ * @Author: jeecg-boot
+ * @Date:   2020-12-10
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyService extends IService<AiKuaishouStrategyTemplate> {
+
+}

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyTargetBase;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * @Description: 定向基础表
+ * @Author: jeecg-boot
+ * @Date:   2020-12-15
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyTargetBaseService extends IService<AiKuaishouStrategyTargetBase> {
+
+    List<AiKuaishouStrategyTargetBase> listByType(String testDirection);
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyTargetDetails;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 智能投放快手定向策略详细信息
+ * @Author: jeecg-boot
+ * @Date:   2020-12-10
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyTargetDetailsService extends IService<AiKuaishouStrategyTargetDetails> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyTargetUnion;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 策略_定向中间表
+ * @Author: jeecg-boot
+ * @Date:   2020-12-15
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyTargetUnionService extends IService<AiKuaishouStrategyTargetUnion> {
+
+}

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyTemplate;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 策略模板表
+ * @Author: jeecg-boot
+ * @Date:   2020-12-15
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyTemplateService extends IService<AiKuaishouStrategyTemplate> {
+
+    AiKuaishouStrategyTemplate getOneByParams(String testDirection, Integer status);
+}

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

@@ -0,0 +1,7 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
+
+public interface IAiStrategyService {
+    void createCreativeByStrategy(KuaishouStrategy strategy);
+}

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


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio