Explorar o código

Merge remote-tracking branch 'origin/master'

yumeng %!s(int64=3) %!d(string=hai) anos
pai
achega
82c2b71376
Modificáronse 67 ficheiros con 4505 adicións e 192 borrados
  1. 25 0
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 15 11
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java
  3. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  4. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MaterialReportOverViewMapper.xml
  5. 15 8
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MaterialReportOverViewServiceImpl.java
  6. 4 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  7. 10 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  8. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  9. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  10. 176 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAiProjectCreativeJob.java
  11. 2 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAutoSynchronousProjectMaterialJob.java
  12. 1 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAccountReportLoadJob.java
  13. 5 2
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouVideoRelateCreativesJob.java
  14. 239 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouProjectCreateCreativeController.java
  15. 92 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouAppPackageController.java
  16. 67 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouDirectionalPackageController.java
  17. 24 11
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouPopulationPackageController.java
  18. 351 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouProjectStrategyController.java
  19. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouVideoDirectionalPackageController.java
  20. 84 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountLevelOperationRecord.java
  21. 85 41
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouCampaignLevelOperationRecord.java
  22. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouCreativeLevelOperationRecord.java
  23. 107 52
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouProgramCreativeLevelOperationRecord.java
  24. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouUnitLevelOperationRecord.java
  25. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouAppPackageRel.java
  26. 77 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouMaterialPoolOperationRecord.java
  27. 377 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouProjectStrategy.java
  28. 101 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/enums/KuaishouProjectCreativeMatTypeEnum.java
  29. 20 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAccountLevelOperationRecordMapper.java
  30. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppPackageMapper.java
  31. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAppPackageRelMapper.java
  32. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouDirectionalPackageMapper.java
  33. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouDirectionalPckageRelMapper.java
  34. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouMaterialPoolOperationRecordMapper.java
  35. 32 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouProjectStrategyMapper.java
  36. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountLevelOperationRecordMapper.xml
  37. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppPackageMapper.xml
  38. 31 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAppPackageRelMapper.xml
  39. 20 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouDirectionalPackageMapper.xml
  40. 9 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouDirectionalPckageRelMapper.xml
  41. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouMaterialPoolOperationRecordMapper.xml
  42. 200 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouProjectStrategyMapper.xml
  43. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountLevelOperationRecordService.java
  44. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouProjectCreateCreativeService.java
  45. 7 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouAppPackageService.java
  46. 11 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouDirectionalPackageService.java
  47. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouMaterialPoolOperationRecordService.java
  48. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouPopulationPackageService.java
  49. 28 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouProjectStrategyService.java
  50. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountLevelOperationRecordServiceImpl.java
  51. 1616 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouProjectCreateCreativeServiceImpl.java
  52. 27 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouAppPackageServiceImpl.java
  53. 29 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouDirectionalPackageServiceImpl.java
  54. 68 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouMaterialPoolOperationRecordServiceImpl.java
  55. 6 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouPopulationPackageServiceImpl.java
  56. 92 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouProjectStrategyServiceImpl.java
  57. 15 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java
  58. 7 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouProjectVideoGetMapper.java
  59. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouTemplateTargetMapper.java
  60. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml
  61. 120 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouProjectVideoGetMapper.xml
  62. 11 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouTemplateTargetMapper.xml
  63. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouProjectVideoGetService.java
  64. 79 23
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  65. 16 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouProjectVideoGetServiceImpl.java
  66. 12 10
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouVideoRelateCreativesServiceImpl.java
  67. 0 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceVideoReportMapper.xml

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

@@ -1641,6 +1641,31 @@ public class DateUtils extends PropertyEditorSupport {
 
         return days;
     }
+
+    /**
+     * 判断time是否在from,to之内
+     *
+     * @param time 指定日期
+     * @param from 开始日期
+     * @param to   结束日期
+     * @throws
+     */
+    public static boolean checkTimeLimit(Date time, Date from, Date to) {
+        Calendar date = Calendar.getInstance();
+        date.setTime(time);
+
+        Calendar after = Calendar.getInstance();
+        after.setTime(from);
+
+        Calendar before = Calendar.getInstance();
+        before.setTime(to);
+
+        if (date.after(after) && date.before(before)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
 }
 
 

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

@@ -163,12 +163,12 @@ public class CallbackController {
                     BigDecimal warningAmount = json.getBigDecimal("WarningAmount");
                     String systemType = json.getString("systemType");
 
-                    /* TODO
+
                     Integer autoDelivery = json.getInteger("autoDelivery");
                     String materialTypeStr = json.getString("materialType");
                     //物料类型,0-不同步,1应用包,(2人群包,3定向包)
                     JSONArray materialTypeArr = json.getJSONArray("materialType");
-*/
+
                     CtopOauthToken topOauthToken = new CtopOauthToken();
                     topOauthToken.setId(String.valueOf(accountId));
                     topOauthToken.setAppId(json.getLong("appId"));
@@ -203,7 +203,7 @@ public class CallbackController {
                     userAllocation.setSystemType(systemType);
                     // 获取快手昵称
                     userAllocation.setAuthName((String) advertiseBaseInfoMap.get("userName"));
-                    if(null!=authBeginTime&&!authBeginTime.trim().equals("")){
+                    if (null != authBeginTime && !authBeginTime.trim().equals("")) {
                         userAllocation.setAuthBeginTime(authBeginTime);
                     }
                     userAllocation.setMediaId(mediaId);
@@ -214,9 +214,9 @@ public class CallbackController {
                     userAllocation.setCreateTime(new Date());
                     userAllocation.setUpdateTime(new Date());
                     //自动投放,0关闭,1开启
-                    /* TODO
+
                     userAllocation.setAutoDelivery(autoDelivery);
-                    userAllocation.setMaterialType(materialTypeStr);*/
+                    userAllocation.setMaterialType(materialTypeStr);
                     allocationMapper.deleteById(userAllocation.getId());
                     Map<String, Object> deleteUserMap = new HashMap<>();
                     deleteUserMap.put("advertiser_id", advertiserId);
@@ -227,7 +227,7 @@ public class CallbackController {
                     if (i > 0) {
                         log.info("同步分配用户表完成,task_id:{},accountId:{}", state, accountId);
                     }
-                   /* TODO Integer materialType = materialTypeArr.getInteger(0);*/
+                    Integer materialType = materialTypeArr.getInteger(0);
                     //账号绑定
                     bindAccountAuthService.addBindAccount(accountId, KuaishouInterfaceConstant.LOGIN_TYPE_KUAISHOU, advertiserId);
                     Thread t = new Thread() {
@@ -235,10 +235,10 @@ public class CallbackController {
                         public void run() {
                             try {
                                 kuaishouInterfaceService.loadKuaishouDataSingle(topOauthToken);
-                                /* TODO
+
                                 if (!Check.isNull(materialType) && materialType != 0) {
                                     synchronMaterials(materialType, accountId, projectId);
-                                }*/
+                                }
                             } catch (ParseException e) {
                                 e.printStackTrace();
                             }
@@ -260,10 +260,14 @@ public class CallbackController {
             accountIds.add(accountId);
             //1 有效项目模板
             List<Long> ids = kuaishouAppPackageService.queryByAppVersion(projectId, null, 1);
+            JSONObject data = new JSONObject();
+            data.put("accountIds", accountIds);
+            data.put("message", "授权同步应用");
             log.info("同步账户应用,应用模板={}", ids);
             if (!Check.isNull(ids)) {
                 for (Long id : ids) {
-                    kuaishouAppPackageService.pushAppPackage(id, accountIds);
+                    data.put("id", id);
+                    kuaishouAppPackageService.pushAppPackage(id, accountIds, data);
                 }
             }
         }
@@ -381,7 +385,7 @@ public class CallbackController {
                             userAllocation.setProjectId(projectId);
                             userAllocation.setSystemType(systemType);
                             userAllocation.setAuthName((String) advertiserDataMap.get("name"));
-                            if(null!=authBeginTime&&!authBeginTime.trim().equals("")){
+                            if (null != authBeginTime && !authBeginTime.trim().equals("")) {
                                 userAllocation.setAuthBeginTime(authBeginTime);
                             }
                             userAllocation.setAdvertiserId(advertiserId);
@@ -436,7 +440,7 @@ public class CallbackController {
                     userAllocation.setProjectId(projectId);
                     userAllocation.setSystemType(systemType);
                     userAllocation.setAuthName((String) advertiserDataMap.get("name"));
-                    if(null!=authBeginTime&&!authBeginTime.trim().equals("")){
+                    if (null != authBeginTime && !authBeginTime.trim().equals("")) {
                         userAllocation.setAuthBeginTime(authBeginTime);
                     }
                     userAllocation.setAdvertiserId(advertiserId);

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

@@ -269,6 +269,7 @@ public class UserAllocationController {
                  queryWrapper.eq("media_id", project.getMediaId());
             }*/
             queryWrapper.isNotNull("account_id");
+            queryWrapper.orderByDesc("create_time");
             List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
             result.setSuccess(true);
             result.setResult(userAllocations);

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MaterialReportOverViewMapper.xml

@@ -433,7 +433,7 @@
                 #{item}
             </foreach>
         </if>
-        AND stat_datetime &gt; #{startDate}
+        AND stat_datetime &gt;= #{startDate}
         AND stat_datetime &lt;= #{endDate}
         AND md5!=''
         GROUP BY md5

+ 15 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MaterialReportOverViewServiceImpl.java

@@ -29,6 +29,7 @@ import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -85,6 +86,10 @@ public class MaterialReportOverViewServiceImpl implements IMaterialReportOverVie
 
     @Override
     public Map<String, Object> getTotalModule(int mediaId, String startDate, String endDate, JSONArray projects) {
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        String nowData = sdf.format(new Date());
+
         Map<String, Object> result = new HashMap<>();
         if (projects.isEmpty()) {
             projects = getProjectsByCurrentUser(mediaId);
@@ -98,9 +103,9 @@ public class MaterialReportOverViewServiceImpl implements IMaterialReportOverVie
             //同比 (本阶段截止昨天消耗-上一个阶段截止和昨天对应日期的消耗)/上一个阶段截止和昨天对应日期的消耗 X 100%
             result.put("yearOnYearCompare", countLink(cost,lastCost));
             //昨日消耗
-            BigDecimal yesterdayCost = materialReportOverViewMapper.queryBytedanceCost(endDate, endDate, projects);
+            BigDecimal yesterdayCost = materialReportOverViewMapper.queryBytedanceCost(DateUtils.addDay(nowData, -1), DateUtils.addDay(nowData, -1), projects);
             //前天消耗
-            BigDecimal beforeYesterdayCost = materialReportOverViewMapper.queryBytedanceCost(DateUtils.addDay(endDate, -1), DateUtils.addDay(endDate, -1), projects);
+            BigDecimal beforeYesterdayCost = materialReportOverViewMapper.queryBytedanceCost(DateUtils.addDay(nowData, -2), DateUtils.addDay(nowData, -2), projects);
             result.put("yesterdayCost", yesterdayCost);
             //环比 (昨日消耗-前日消耗)/前日消耗 X 100%
             result.put("chainCompare", countLink(yesterdayCost,beforeYesterdayCost));
@@ -114,9 +119,9 @@ public class MaterialReportOverViewServiceImpl implements IMaterialReportOverVie
             //同比 (本阶段截止昨天消耗-上一个阶段截止和昨天对应日期的消耗)/上一个阶段截止和昨天对应日期的消耗 X 100%
             result.put("yearOnYearCompare", countLink(cost,lastCost));
             //昨日消耗
-            BigDecimal yesterdayCost = materialReportOverViewMapper.queryKuaishouCost(endDate, endDate, projects);
+            BigDecimal yesterdayCost = materialReportOverViewMapper.queryKuaishouCost(DateUtils.addDay(nowData, -1), DateUtils.addDay(nowData, -1), projects);
             //前天消耗
-            BigDecimal beforeYesterdayCost = materialReportOverViewMapper.queryKuaishouCost(DateUtils.addDay(endDate, -1), DateUtils.addDay(endDate, -1), projects);
+            BigDecimal beforeYesterdayCost = materialReportOverViewMapper.queryKuaishouCost(DateUtils.addDay(nowData, -2), DateUtils.addDay(nowData, -2), projects);
             result.put("yesterdayCost", yesterdayCost);
             //环比 (昨日消耗-前日消耗)/前日消耗 X 100%
             result.put("chainCompare", countLink(yesterdayCost,beforeYesterdayCost));
@@ -178,6 +183,8 @@ public class MaterialReportOverViewServiceImpl implements IMaterialReportOverVie
     //爆款视频
     @Override
     public Map<String, Object> sumDataVideoHot(int mediaId, String startDate, String endDate, JSONArray projects) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        String nowData = sdf.format(new Date());
         Map<String, Object> result = new HashMap<>();
         if (projects.isEmpty()) {
             projects = getProjectsByCurrentUser(mediaId);
@@ -195,9 +202,9 @@ public class MaterialReportOverViewServiceImpl implements IMaterialReportOverVie
             //同比 (本阶段截止昨天的爆款视频数量-上一个阶段截止和昨天对应日期的爆款视频数量)/上一个阶段截止和昨天对应日期的爆款视频数量X 100%
             result.put("hotYearOnYearCompare", countLink(new BigDecimal(hotTotal),new BigDecimal(lastHotTotal)));
             //昨日消耗
-            List<Map<String, String>> yesterdayHost = materialReportOverViewMapper.selectHotMaterialVideoBytedance(endDate,endDate, projects);
+            List<Map<String, String>> yesterdayHost = materialReportOverViewMapper.selectHotMaterialVideoBytedance(DateUtils.addDay(nowData, -1),DateUtils.addDay(nowData, -1), projects);
             //前天消耗
-            List<Map<String, String>> beforeYesterdayHost = materialReportOverViewMapper.selectHotMaterialVideoBytedance(DateUtils.addDay(endDate, -1), DateUtils.addDay(endDate, -1), projects);
+            List<Map<String, String>> beforeYesterdayHost = materialReportOverViewMapper.selectHotMaterialVideoBytedance(DateUtils.addDay(nowData, -2), DateUtils.addDay(nowData, -2), projects);
             long yesterday = yesterdayHost.stream().collect(Collectors.summarizingInt(s->Integer.valueOf(String.valueOf(s.get("count"))))).getSum();
             long before = beforeYesterdayHost.stream().collect(Collectors.summarizingInt(s->Integer.valueOf(String.valueOf(s.get("count"))))).getSum();
             //环比 (昨日-前日)/前日消耗 X 100%
@@ -216,9 +223,9 @@ public class MaterialReportOverViewServiceImpl implements IMaterialReportOverVie
             //同比 (本阶段截止昨天的爆款视频数量-上一个阶段截止和昨天对应日期的爆款视频数量)/上一个阶段截止和昨天对应日期的爆款视频数量X 100%
             result.put("hotYearOnYearCompare", countLink(new BigDecimal(hotTotal),new BigDecimal(lastHotTotal)));
             //昨日消耗
-            List<Map<String, String>> yesterdayHost = materialReportOverViewMapper.selectHotMaterialVideoKs(endDate,endDate, projects);
+            List<Map<String, String>> yesterdayHost = materialReportOverViewMapper.selectHotMaterialVideoKs(DateUtils.addDay(nowData, -1),DateUtils.addDay(nowData, -1), projects);
             //前天消耗
-            List<Map<String, String>> beforeYesterdayHost = materialReportOverViewMapper.selectHotMaterialVideoKs(DateUtils.addDay(endDate, -1), DateUtils.addDay(endDate, -1), projects);
+            List<Map<String, String>> beforeYesterdayHost = materialReportOverViewMapper.selectHotMaterialVideoKs(DateUtils.addDay(nowData, -2), DateUtils.addDay(nowData, -2), projects);
             long yesterday = yesterdayHost.stream().collect(Collectors.summarizingInt(s->Integer.valueOf(String.valueOf(s.get("count"))))).getSum();
             long before = beforeYesterdayHost.stream().collect(Collectors.summarizingInt(s->Integer.valueOf(String.valueOf(s.get("count"))))).getSum();
             //环比 (昨日-前日)/前日消耗 X 100%

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

@@ -50,4 +50,8 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     List<UserAllocation> getAccountListByUserIdAndProductId(@Param("userId")String userId,@Param("projectId")Long projectId,@Param("productId")Long productId);
 
     List<JSONObject> getUserIdListByProductId(@Param("productId") Long productId);
+
+    int updateProjectStrategyStatus(@Param("accountId") Long accountId,@Param("projectStrategy") Integer projectStrategy);
+
+    List<Long> queryAutomaticAccounts(@Param("projectId") Long projectId);
 }

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

@@ -194,5 +194,15 @@
         </if>
     </select>
 
+    <update id="updateProjectStrategyStatus">
+        update ctop_user_allocation set auto_delivery = #{projectStrategy}
+        where account_id = #{accountId}
+    </update>
+
+    <select id="queryAutomaticAccounts" resultType="java.lang.Long">
+        select account_id from ctop_user_allocation
+        where project_id = #{projectId}
+        AND auto_delivery = 1
+    </select>
 
 </mapper>

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

@@ -58,4 +58,7 @@ public interface IUserAllocationService extends IService<UserAllocation> {
      */
     List<Long> getValidProjectIds(Integer mediaId);
 
+    boolean updateProjectStrategyStatus(Long accountId, Integer projectStrategy);
+
+    List<Long> queryAutomaticAccounts(Long projectId);
 }

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

@@ -190,4 +190,15 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     public List<Long> getValidProjectIds(Integer mediaId) {
         return userAllocationMapper.getValidProjectIds(mediaId);
     }
+
+    @Override
+    public boolean updateProjectStrategyStatus(Long accountId, Integer projectStrategy) {
+        int num  = userAllocationMapper.updateProjectStrategyStatus(accountId, projectStrategy);
+        return num>0;
+    }
+
+    @Override
+    public List<Long> queryAutomaticAccounts(Long projectId) {
+        return userAllocationMapper.queryAutomaticAccounts(projectId);
+    }
 }

+ 176 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAiProjectCreativeJob.java

@@ -0,0 +1,176 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils2;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouProjectStrategy;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouProjectStrategyService;
+import com.alibaba.fastjson.JSONObject;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.text.ParseException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author syh
+ * 自动投放定时任务
+ */
+@Component
+@Slf4j
+public class KuaishouAiProjectCreativeJob {
+
+    @Value("${xxl-job.requestUrl}")
+    private String jobUrl;
+
+    @Autowired
+    private IKuaishouProjectStrategyService kuaishouProjectStrategyService;
+
+    /**
+     * 项目自定义上新
+     */
+    @XxlJob("projectCustomCreativeOnNew")
+    public void projectCustomCreativeOnNew() {
+        List<KuaishouProjectStrategy> strategies = kuaishouProjectStrategyService.getAllEffectStrategy(4, "1");
+        if (null == strategies || strategies.isEmpty()) {
+            return;
+        }
+        String url = jobUrl + "/jeecg-boot/ai/projectCreate/projectCreative";
+        JSONObject jsonObject = null;
+        try {
+            for (KuaishouProjectStrategy strategy : strategies) {
+                Map<String, Object> requestMap = new HashMap<>();
+                requestMap.put("id", strategy.getId());
+                String result = HttpUtils2.httpGet(url, requestMap, null);
+                jsonObject = JSONObject.parseObject(result);
+                if (!Check.isNull(jsonObject)) {
+                    Integer code = jsonObject.getInteger("code");
+                    if (!Check.isNull(code) && code == 0) {
+                        log.info("快手自动上新异步执行中,accountId:{}", strategy.getProjectId());
+                    } else {
+                        log.error("快手自动上新异步执行失败,accountId:{}", strategy.getProjectId());
+                    }
+                } else {
+                    log.info("快手自动上新返回结果为空,accountId:{}", strategy.getProjectId());
+                }
+            }
+        } catch (Exception e) {
+            log.error("自定义上新异常,返回结果:{}", jsonObject);
+        }
+    }
+
+    /**
+     * 项目自定义补充
+     */
+    @XxlJob("projectCustomCreativeSupplement")
+    public void projectCustomCreativeSupplement() {
+        List<KuaishouProjectStrategy> strategies = kuaishouProjectStrategyService.getAllEffectStrategy(4, null);
+        if (null == strategies || strategies.isEmpty()) {
+            return;
+        }
+        JSONObject jsonObject = null;
+        try {
+            String url = jobUrl + "/jeecg-boot/ai/projectCreate/projectCreativeSupplement";
+            int hour = DateUtils.getNowHour();
+            for (KuaishouProjectStrategy strategy : strategies) {
+                Map<String, Object> requestMap = new HashMap<>();
+                requestMap.put("id", strategy.getId());
+                requestMap.put("hour", hour);
+                String result = HttpUtils2.httpGet(url, requestMap, null);
+                jsonObject = JSONObject.parseObject(result);
+                if (!Check.isNull(jsonObject)) {
+                    Integer code = jsonObject.getInteger("code");
+                    if (!Check.isNull(code) && code == 0) {
+                        log.info("快手创意补充异步执行中,accountId:{}", strategy.getAccountId());
+                    } else {
+                        log.error("快手创意补充异步执行失败,accountId:{}", strategy.getAccountId());
+                    }
+                } else {
+                    log.error("快手创意补充返回结果为空,accountId:{}", strategy.getAccountId());
+                }
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+            log.error("自定义创意补充异常,返回结果:{}", jsonObject);
+        }
+    }
+
+    /**
+     * 项目程序化上新创意
+     */
+    @XxlJob("projectProgramCreativeAuto")
+    public void kuaishouProgramCreativeAuto() {
+        List<KuaishouProjectStrategy> strategies = kuaishouProjectStrategyService.getAllEffectStrategy(7, "1");
+        if (null == strategies || strategies.isEmpty()) {
+            return;
+        }
+        JSONObject jsonObject = null;
+        try {
+            String url = jobUrl + "/jeecg-boot/ai/projectCreate/projectProgramAutomaticCreates";
+            for (KuaishouProjectStrategy strategy : strategies) {
+                long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
+                Map<String, Object> requestMap = new HashMap<>();
+                requestMap.put("id", strategy.getId());
+                requestMap.put("videoCnt", videoCnt);
+                String result = HttpUtils2.httpGet(url, requestMap, null);
+                jsonObject = JSONObject.parseObject(result);
+                if (!Check.isNull(jsonObject)) {
+                    Integer code = jsonObject.getInteger("code");
+                    if (!Check.isNull(code) && code == 0) {
+                        log.info("程序化创意上新异步执行中,accountId:{}", strategy.getAccountId());
+                    } else {
+                        log.error("程序化创意上新异步执行失败,accountId:{}", strategy.getAccountId());
+                    }
+                } else {
+                    log.error("程序化创意上新返回结果为空,accountId:{}", strategy.getAccountId());
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("程序化创意上新异常,返回结果:{}", jsonObject);
+        }
+    }
+
+    /**
+     * 项目程序化高质量创意
+     */
+    @XxlJob("projectProgramCreativeTop")
+    public void kuaishouProgramCreativeTop() {
+        List<KuaishouProjectStrategy> strategies = kuaishouProjectStrategyService.getAllEffectStrategy(7, "2");
+        if (null == strategies || strategies.isEmpty()) {
+            return;
+        }
+        JSONObject jsonObject = null;
+
+        try {
+            String url = jobUrl + "/jeecg-boot/ai/projectCreate/projectProgramCreativeTop";
+            for (KuaishouProjectStrategy strategy : strategies) {
+                long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
+                Map<String, Object> requestMap = new HashMap<>();
+                requestMap.put("id", strategy.getId());
+                requestMap.put("videoCnt", videoCnt);
+                String result = HttpUtils2.httpGet(url, requestMap, null);
+                jsonObject = JSONObject.parseObject(result);
+                if (!Check.isNull(jsonObject)) {
+                    Integer code = jsonObject.getInteger("code");
+                    if (!Check.isNull(code) && code == 0) {
+                        log.info("程序化高质量创建异步执行中,accountId:{}", strategy.getAccountId());
+                    } else {
+                        log.error("程序化高质量创建异步执行失败,accountId:{}", strategy.getAccountId());
+                    }
+                } else {
+                    log.error("程序化高质量创建返回结果为空,accountId:{}", strategy.getAccountId());
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("程序化高质量创建异常,返回结果:{}", jsonObject);
+        }
+
+    }
+}

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

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
@@ -43,7 +44,7 @@ public class KuaishouAutoSynchronousProjectMaterialJob {
             log.info("同步账户应用,应用模板={}", ids);
             if (!Check.isNull(ids)) {
                 for (Long id : ids) {
-                    kuaishouAppPackageService.pushAppPackage(id, accountIds);
+                    kuaishouAppPackageService.pushAppPackage(id, accountIds,null);
                 }
             }
         }

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

@@ -34,7 +34,7 @@ public class KuaishouDailyAccountReportLoadJob {
      */
     @XxlJob("kuaishouDailyAccountReport")
     public void execute() throws Exception {
-        Date getDate = DateUtils.addDay(new Date(), -1);
+        Date getDate = new Date();
         Date getDate2 = DateUtils.addDay(new Date(), -2);
         //1:查询当日数据
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();

+ 5 - 2
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouVideoRelateCreativesJob.java

@@ -40,6 +40,7 @@ public class KuaishouVideoRelateCreativesJob {
 
     /**
      * 视频库-更新视频关联创意数
+     *
      * @throws Exception
      */
     @XxlJob("kuaishouVideoRelateCreativesJob")
@@ -90,7 +91,7 @@ public class KuaishouVideoRelateCreativesJob {
             int count = 0;
             for (KuaiShouVideoGet video : KuaiShouVideoGets) {
                 count++;
-                if (count < 20) {
+                if (count < 19) {
                     photoIds.add(video.getPhotoId());
                     statdateMap.put(video.getPhotoId(), video);
                 } else {
@@ -101,7 +102,9 @@ public class KuaishouVideoRelateCreativesJob {
                     count = 0;
                 }
             }
-            dateList.add(photoIds);
+            if (photoIds.size() > 0) {
+                dateList.add(photoIds);
+            }
             kuaishouVideoRelateCreativesService.videoRelateCreatives(accountId, dateList, statdateMap);
         }
     }

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

@@ -0,0 +1,239 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouProjectStrategy;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouProjectCreateCreativeService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouProjectStrategyService;
+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.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.text.ParseException;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+@Api(tags = "快手-自动投放")
+@RestController
+@RequestMapping("/ai/projectCreate")
+public class AiKuaishouProjectCreateCreativeController {
+    @Autowired
+    private IAiKuaishouProjectCreateCreativeService projectCreateCreativeService;
+    @Autowired
+    private IKuaishouProjectStrategyService kuaishouProjectStrategyService;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+    static ExecutorService kuaishouCustomCreativeSupplementExecutorService = Executors.newFixedThreadPool(3);
+
+    /**
+     * 检查匹配
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/projectAutomaticCreates")
+    public JSONObject projectAutomaticCreates(String id, Integer operationType) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(id) || Check.isNull(operationType)) {
+                throw new Exception("参数为空");
+            }
+            KuaishouProjectStrategy strategy = kuaishouProjectStrategyService.getById(id);
+            if (Check.isNull(strategy)) {
+                throw new Exception("根据id获取详细信息为空");
+            }
+            Long projectId = strategy.getProjectId();
+            List<Long> list = userAllocationService.queryAutomaticAccounts(projectId);
+            if (Check.isNull(list)) {
+                throw new Exception("项目:" + projectId + "中未配置自动投放账户!");
+            }
+            list.forEach(accountId -> executorService.submit(() -> {
+                Boolean unitOverrun = projectCreateCreativeService.getUnitOverrun(projectId.toString().concat(accountId.toString()));
+                if (!unitOverrun) {
+                    strategy.setAccountId(accountId);
+                    // operationType 1检查反馈,2创建时信息
+                    projectCreateCreativeService.projectAutomaticCreates(strategy, operationType);
+                }
+            }));
+            returnJson.put("code", 0);
+            returnJson.put("message", "自定义上新异步创建中");
+        } catch (Exception e) {
+            log.error("项目自动创建异常", e.fillInStackTrace());
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    /**
+     * 项目自定义上新
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/projectCreative")
+    public JSONObject projectCreative(String id) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(id)) {
+                throw new Exception("参数为空");
+            }
+            KuaishouProjectStrategy strategy = kuaishouProjectStrategyService.getById(id);
+            if (Check.isNull(strategy)) {
+                throw new Exception("根据id获取详细信息为空");
+            }
+            Long projectId = strategy.getProjectId();
+            List<Long> list = userAllocationService.queryAutomaticAccounts(projectId);
+            if (Check.isNull(list)) {
+                throw new Exception("项目:" + projectId + "中未配置自动投放账户!");
+            }
+            list.forEach(accountId -> executorService.submit(() -> {
+                Boolean unitOverrun = projectCreateCreativeService.getUnitOverrun(projectId.toString().concat(accountId.toString()));
+                if (!unitOverrun) {
+                    strategy.setAccountId(accountId);
+                    projectCreateCreativeService.projectAutomaticCreates(strategy);
+                }
+            }));
+            returnJson.put("code", 0);
+            returnJson.put("message", "自定义上新异步创建中");
+        } catch (Exception e) {
+            log.error("项目自动创建异常", e.fillInStackTrace());
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+    /**
+     * 项目维度自定义创意补充
+     *
+     * @param id
+     * @param hour
+     * @return
+     */
+    @GetMapping(value = "/projectCreativeSupplement")
+    public JSONObject projectCreativeSupplement(String id, Integer hour) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(id)) {
+                throw new Exception("主键id不能为空");
+            }
+            KuaishouProjectStrategy strategy = kuaishouProjectStrategyService.getById(id);
+            if (Check.isNull(strategy)) {
+                throw new Exception("根据id获取详细信息为空");
+            }
+            Long projectId = strategy.getProjectId();
+            List<Long> list = userAllocationService.queryAutomaticAccounts(projectId);
+            if (Check.isNull(list)) {
+                throw new Exception("项目:" + projectId + "中未配置自动投放账户!");
+            }
+            list.forEach(accountId -> executorService.submit(() -> {
+                Boolean unitOverrun = projectCreateCreativeService.getUnitOverrun(projectId.toString().concat(accountId.toString()));
+                if (!unitOverrun) {
+                    strategy.setAccountId(accountId);
+                    try {
+                        projectCreateCreativeService.customCreativeSupplement(strategy, hour);
+                    } catch (ParseException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }));
+            returnJson.put("code", 0);
+            returnJson.put("message", "自定义补充异步创建中...");
+        } catch (Exception e) {
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    /**
+     * 项目程序化上新
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/projectProgramAutomaticCreates")
+    public JSONObject projectProgramAutomaticCreates(String id) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(id)) {
+                throw new Exception("参数为空");
+            }
+            KuaishouProjectStrategy strategy = kuaishouProjectStrategyService.getById(id);
+            if (Check.isNull(strategy)) {
+                throw new Exception("根据id获取详细信息为空");
+            }
+            Long projectId = strategy.getProjectId();
+            List<Long> list = userAllocationService.queryAutomaticAccounts(projectId);
+            if (Check.isNull(list)) {
+                throw new Exception("项目:" + projectId + "中未配置自动投放账户!");
+            }
+            list.forEach(accountId -> executorService.submit(() -> {
+                Boolean unitOverrun = projectCreateCreativeService.getUnitOverrun(projectId.toString().concat(accountId.toString()));
+                if (!unitOverrun) {
+                    strategy.setAccountId(accountId);
+                    projectCreateCreativeService.projectProgramAutomaticCreates(strategy, 1);
+                }
+            }));
+            returnJson.put("code", 0);
+            returnJson.put("message", "程序化上新异步创建中");
+        } catch (Exception e) {
+            log.error("项目自动创建异常", e.fillInStackTrace());
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+    /**
+     * 项目程序化高质量创意
+     *
+     * @param id
+     * @param hour
+     * @return
+     */
+    @GetMapping(value = "/projectProgramCreativeTop")
+    public JSONObject projectProgramCreativeSupplement(String id, Integer hour) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(id)) {
+                throw new Exception("参数为空");
+            }
+            KuaishouProjectStrategy strategy = kuaishouProjectStrategyService.getById(id);
+            if (Check.isNull(strategy)) {
+                throw new Exception("根据id获取详细信息为空");
+            }
+            Long projectId = strategy.getProjectId();
+            List<Long> list = userAllocationService.queryAutomaticAccounts(projectId);
+            if (Check.isNull(list)) {
+                throw new Exception("项目:" + projectId + "中未配置自动投放账户!");
+            }
+            list.forEach(accountId -> executorService.submit(() -> {
+                Boolean unitOverrun = projectCreateCreativeService.getUnitOverrun(projectId.toString().concat(accountId.toString()));
+                if (!unitOverrun) {
+                    strategy.setAccountId(accountId);
+                    projectCreateCreativeService.projectProgramAutomaticCreates(strategy, 2);
+                }
+            }));
+            returnJson.put("code", 0);
+            returnJson.put("message", "程序化高质量异步创建中");
+        } catch (Exception e) {
+            log.error("项目自动创建异常", e.fillInStackTrace());
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+}

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

@@ -7,7 +7,10 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.common.module.utils.LoadFileUtil;
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackage;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackageRel;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageRelService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouMaterialPoolOperationRecordService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
@@ -50,7 +53,11 @@ public class KuaishouAppPackageController {
     @Autowired
     private IKuaishouAppPackageService kuaishouAppPackageService;
     @Autowired
+    private IKuaishouAppPackageRelService kuaishouAppPackageRelService;
+    @Autowired
     private IProjectService projectService;
+    @Autowired
+    private IKuaishouMaterialPoolOperationRecordService kuaishouMaterialPoolOperationRecordService;
 
     /**
      * 分页列表查询
@@ -71,6 +78,79 @@ public class KuaishouAppPackageController {
         return Result.error("查询应用列表失败");
     }
 
+    @GetMapping(value = "/getProjectAppList")
+    public Result<Object> getProjectAppList(Long projectId) {
+        try {
+            if (Check.isNull(projectId)) {
+                return Result.error("缺少参数");
+            }
+            return kuaishouAppPackageService.getProjectAppList(projectId);
+        } catch (Exception e) {
+            log.error("查询项目下应用异常", e);
+        }
+        return Result.error("查询项目下应用失败");
+    }
+
+    @PostMapping(value = "/getAppsDetail")
+    public Result<Object> getAppsDetail(@RequestBody JSONObject data) {
+        try {
+            String ids = data.getString("apptemIds");
+            if (Check.isNull(ids)) {
+                return Result.error("缺少参数");
+            }
+            List<Long> list = JSONObject.parseObject(ids, List.class);
+            if (list.size() == 0) {
+                return Result.error("缺少参数");
+            }
+            return kuaishouAppPackageService.getAppsDetail(list);
+        } catch (Exception e) {
+            log.error("查询项目下应用异常", e);
+        }
+        return Result.error("查询项目下应用失败");
+    }
+
+    @PostMapping(value = "/edit")
+    public Result<Object> edit(@RequestBody JSONObject data) {
+        String impressionUrl = data.getString("impressionUrl");
+        String trackUrl = data.getString("trackUrl");
+        String actionbarClickUrl = data.getString("actionbarClickUrl");
+        String adPhotoPlayedT3sUrl = data.getString("adPhotoPlayedT3sUrl");
+
+        if (Check.isNull(impressionUrl) && Check.isNull(actionbarClickUrl) && Check.isNull(adPhotoPlayedT3sUrl) && Check.isNull(trackUrl)) {
+            return Result.error("缺少参数");
+        }
+        Long id = data.getLong("id");
+        KuaishouAppPackageRel packageRel = kuaishouAppPackageRelService.getById(id);
+        if (packageRel == null) {
+            return Result.error("未找到对应实体");
+        } else {
+            boolean ok = false;
+            if (!Check.isNull(impressionUrl) || !Check.isNull(actionbarClickUrl) || !Check.isNull(adPhotoPlayedT3sUrl)) {
+                if (!Check.isNull(impressionUrl)) {
+                    packageRel.setImpressionUrl(impressionUrl);
+                }
+                if (!Check.isNull(actionbarClickUrl)) {
+                    packageRel.setActionbarClickUrl(actionbarClickUrl);
+                }
+                if (!Check.isNull(adPhotoPlayedT3sUrl)) {
+                    packageRel.setAdPhotoPlayedT3sUrl(adPhotoPlayedT3sUrl);
+                }
+                ok = kuaishouAppPackageRelService.updateById(packageRel);
+            }
+            if (!Check.isNull(trackUrl)) {
+                KuaishouAppPackage appTem = kuaishouAppPackageService.getById(packageRel.getApptemId());
+                if (!Check.isNull(appTem)) {
+                    appTem.setTrackUrl(trackUrl);
+                    ok = kuaishouAppPackageService.updateById(appTem);
+                }
+            }
+            if (ok) {
+                return Result.ok("修改成功!");
+            }
+        }
+        return Result.error("修改失败");
+    }
+
     /**
      * 查询相关账户
      *
@@ -162,7 +242,8 @@ public class KuaishouAppPackageController {
             if (Check.isNull(accountIds)) {
                 return Result.error("请选择推送账户");
             }
-            return kuaishouAppPackageService.pushAppPackage(id, accountIds);
+            Result<Object> result = kuaishouAppPackageService.pushAppPackage(id, accountIds, requestJson);
+            return result;
         } catch (Exception e) {
             log.error("推送应用异常", e);
         }
@@ -282,7 +363,12 @@ public class KuaishouAppPackageController {
             }
             kuaishouAppPackage.setImageMd5(LoadFileUtil.getMD5(newFileUrl));
             kuaishouAppPackage.setDataStatus(1);//有效
+            String type = "update";
+            if (Check.isNull(kuaishouAppPackage.getId())) {
+                type = "add";
+            }
             kuaishouAppPackageService.saveOrUpdate(kuaishouAppPackage);
+            kuaishouMaterialPoolOperationRecordService.addRecord(JSONObject.parseObject(JSONObject.toJSONString(kuaishouAppPackage)).toJavaObject(JSONObject.class), "/fillInLink", 3, type);
             return Result.ok("操作成功!");
         } catch (Exception e) {
             log.error(e.getMessage(), e);
@@ -302,7 +388,7 @@ public class KuaishouAppPackageController {
             if (Check.isNull(projectId) || Check.isNull(appVersion)) {
                 return Result.error("缺失参数");
             }
-            List<Long> list = kuaishouAppPackageService.queryByAppVersion(projectId, appVersion,null);
+            List<Long> list = kuaishouAppPackageService.queryByAppVersion(projectId, appVersion, null);
             if (Check.isNull(list)) {
                 return Result.ok("success");
             } else {
@@ -334,6 +420,10 @@ public class KuaishouAppPackageController {
             kuaishouAppPackage.setDataStatus(0);
             boolean ok = kuaishouAppPackageService.updateById(kuaishouAppPackage);
             if (ok) {
+                JSONObject data = new JSONObject();
+                data.put("id", kuaishouAppPackage.getId());
+                data.put("projectId", kuaishouAppPackageEntity.getProjectId());
+                kuaishouMaterialPoolOperationRecordService.addRecord(data, "/kuaishouAppPackage/delete", 3, "delete");
                 result.success("刪除成功!");
             }
         }

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

@@ -6,16 +6,16 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.QueryGenerator;
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouMaterialPoolOperationRecordService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageHelper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.checkerframework.checker.units.qual.C;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
@@ -62,6 +62,9 @@ public class KuaishouDirectionalPackageController {
     private IKuaishouDirectionalPackageService kuaishouDirectionalPackageService;
 
     @Autowired
+    private IKuaishouMaterialPoolOperationRecordService kuaishouMaterialPoolOperationRecordService;
+
+    @Autowired
     private ICtopOauthTokenService oauthTokenService;
 
     /**
@@ -85,6 +88,42 @@ public class KuaishouDirectionalPackageController {
 
     }
 
+    @GetMapping(value = "/getProjectTarget")
+    public Result<Object> getProjectTarget(Long projectId, String templateName,
+                                           @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                           @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(projectId)) {
+                return Result.error("缺少参数");
+            }
+            return kuaishouDirectionalPackageService.getProjectTarget(projectId, templateName, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e);
+            return Result.error("查询失败," + e.getMessage());
+        }
+    }
+
+    @PostMapping(value = "/getProjectTargetByIds")
+    public Result<Object> getProjectTargetByIds(@RequestBody JSONObject data) {
+        try {
+            JSONArray ids = data.getJSONArray("ids");
+            if (Check.isNull(ids)) {
+                return Result.error("缺少参数");
+            }
+            List<String> list = JSONObject.parseObject(JSONObject.toJSONString(ids), List.class);
+            if (Check.isNull(list)) {
+                return Result.error("缺少参数");
+            }
+
+
+            List<KuaishouDirectionalPackage> targets = kuaishouDirectionalPackageService.getProjectTargetByIds(list);
+            return Result.ok(targets);
+        } catch (Exception e) {
+            log.error("查询异常,", e);
+            return Result.error("查询失败," + e.getMessage());
+        }
+    }
+
     /**
      * 相关账户/组
      *
@@ -134,7 +173,11 @@ public class KuaishouDirectionalPackageController {
             if (Check.isNull(requestJson.getString("templateName"))) {
                 return Result.error("未获取到定向包名称");
             }
-            return kuaishouDirectionalPackageService.editPopulation(requestJson);
+            Result<Object> result = kuaishouDirectionalPackageService.editPopulation(requestJson);
+            if (result.getCode() == 200) {
+                kuaishouMaterialPoolOperationRecordService.addRecord(requestJson, "/editPopulation", 1, "update");
+            }
+            return result;
         } catch (Exception e) {
             log.error("查询异常,", e.getMessage());
             e.printStackTrace();
@@ -178,7 +221,6 @@ public class KuaishouDirectionalPackageController {
      */
     @PostMapping(value = "/createDirectionalPackage")
     public Result<Object> createDirectionalPackage(@RequestBody JSONObject requestJson) {
-        Result<JSONObject> result = new Result<>();
         try {
             if (Check.isNull(requestJson.getString("templateName"))) {
                 return Result.error("定向模板名称为必传项");
@@ -187,7 +229,11 @@ public class KuaishouDirectionalPackageController {
             if (Check.isNull(accountId)) {
                 return Result.error("请选择账户id");
             }
-            return kuaishouDirectionalPackageService.createDirectionalPackage(requestJson);
+            Result<Object> result = kuaishouDirectionalPackageService.createDirectionalPackage(requestJson);
+            if (result.getCode() == 200) {
+                kuaishouMaterialPoolOperationRecordService.addRecord(requestJson, "/createDirectionalPackage", 1, "add");
+            }
+            return result;
         } catch (Exception e) {
             log.error("创建定向包失败", e);
             return Result.error("创建失败" + e.getMessage());
@@ -210,7 +256,11 @@ public class KuaishouDirectionalPackageController {
             if (Check.isNull(requestJson.getString("projectId"))) {
                 return Result.error("请选择项目");
             }
-            return kuaishouDirectionalPackageService.updateDirectionalPackage(requestJson);
+            Result<Object> result1 = kuaishouDirectionalPackageService.updateDirectionalPackage(requestJson);
+            if (result1.getCode() == 200) {
+                kuaishouMaterialPoolOperationRecordService.addRecord(requestJson, "/updateDirectionalPackage", 1, "update");
+            }
+            return result1;
         } catch (Exception e) {
             result.setSuccess(false);
             result.setMessage(e.getMessage());
@@ -235,7 +285,8 @@ public class KuaishouDirectionalPackageController {
             if (Check.isNull(datas)) {
                 return Result.error("请选择推送账户");
             }
-            return kuaishouDirectionalPackageService.pushDirectionalPackage(id, datas);
+            Result<Object> result = kuaishouDirectionalPackageService.pushDirectionalPackage(id, datas, requestJson);
+            return result;
         } catch (Exception e) {
             log.error("推送定向包异常", e);
         }
@@ -283,8 +334,17 @@ public class KuaishouDirectionalPackageController {
     @GetMapping(value = "/delete")
     public Result<Object> delete(String id) {
         try {
+
+            KuaishouDirectionalPackage directionalPackage = kuaishouDirectionalPackageService.getById(id);
+            if (Check.isNull(directionalPackage)) {
+                return Result.error("未查到实体");
+            }
             boolean b = kuaishouDirectionalPackageService.removeById(id);
             if (b) {
+                JSONObject data = new JSONObject();
+                data.put("id", id);
+                data.put("projectId", directionalPackage.getProjectId());
+                kuaishouMaterialPoolOperationRecordService.addRecord(data, "/kuaishouDirectionalPackage/delete", 1, "delete");
                 return Result.ok("删除成功");
             }
         } catch (Exception e) {

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

@@ -3,13 +3,13 @@ package cn.com.ctop.kuaishou.modules.ai.controller;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.QueryGenerator;
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackage;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouMaterialPoolOperationRecordService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -56,6 +56,8 @@ import java.util.Map;
 public class KuaishouPopulationPackageController {
     @Autowired
     private IKuaishouPopulationPackageService kuaishouPopulationPackageService;
+    @Autowired
+    private IKuaishouMaterialPoolOperationRecordService kuaishouMaterialPoolOperationRecordService;
 
     /**
      * 分页列表查询
@@ -161,18 +163,19 @@ public class KuaishouPopulationPackageController {
      * @author ZHAOXA
      */
     @GetMapping(value = "/getRelatedGroups")
-    public Result<Object> getRelatedGroups(Long id,Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+    public Result<Object> getRelatedGroups(Long id, Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
         try {
             if (Check.isNull(id)) {
                 return Result.error("缺少参数");
             }
             PageHelper.startPage(pageNo, pageSize);
-            return kuaishouPopulationPackageService.getRelatedGroups(id,accountId);
+            return kuaishouPopulationPackageService.getRelatedGroups(id, accountId);
         } catch (Exception e) {
             log.error("查询异常", e);
         }
         return Result.error("查询失败");
     }
+
     /**
      * 查询项目下有效账户
      *
@@ -216,13 +219,14 @@ public class KuaishouPopulationPackageController {
     @RequestMapping(value = "/checkPopulationPackage")
     public Result<Object> checkPopulationPackage(String signature) {
         try {
-           return kuaishouPopulationPackageService.checkPopulationPackage(signature);
+            return kuaishouPopulationPackageService.checkPopulationPackage(signature);
         } catch (Exception e) {
             log.error("查询异常,", e.getMessage());
             e.printStackTrace();
         }
         return Result.error("查询失败");
     }
+
     /**
      * 添加
      *
@@ -232,7 +236,6 @@ public class KuaishouPopulationPackageController {
     @ApiOperation(value = "项目绑定的人群包模板-添加", notes = "项目绑定的人群包模板-添加")
     @PostMapping(value = "/add")
     public Result<Object> add(@RequestBody KuaishouPopulationPackage kuaishouPopulationPackage) {
-        Result<KuaishouPopulationPackage> result = new Result<>();
         try {
             if (Check.isNull(kuaishouPopulationPackage.getType())) {
                 return Result.error("请选择匹配类型");
@@ -246,12 +249,15 @@ public class KuaishouPopulationPackageController {
             if (Check.isNull(kuaishouPopulationPackage.getProjectId())) {
                 return Result.error("请选择项目");
             }
-            return kuaishouPopulationPackageService.createEntity(kuaishouPopulationPackage);
+            Result<Object> result = kuaishouPopulationPackageService.createEntity(kuaishouPopulationPackage);
+            if (result.getCode() == 200) {
+                kuaishouMaterialPoolOperationRecordService.addRecord(JSONObject.parseObject(JSONObject.toJSONString(kuaishouPopulationPackage)).toJavaObject(JSONObject.class), "/kuaishouPopulationPackage/add", 2, "add");
+            }
+            return result;
         } catch (Exception e) {
             log.error(e.getMessage(), e);
-            result.error500("上传异常");
+            return Result.error("上传异常");
         }
-        return Result.error("上传失败");
     }
 
     /**
@@ -269,7 +275,8 @@ public class KuaishouPopulationPackageController {
             if (Check.isNull(accountIds) || Check.isNull(id)) {
                 return Result.error("缺少参数");
             }
-            return kuaishouPopulationPackageService.push(accountIds, id);
+            Result<Object> result = kuaishouPopulationPackageService.push(accountIds, id, request);
+            return result;
         } catch (Exception e) {
             log.error("查询异常,", e.getMessage());
             e.printStackTrace();
@@ -290,11 +297,17 @@ public class KuaishouPopulationPackageController {
             if (Check.isNull(id)) {
                 return Result.error("参数为空");
             }
-            KuaishouPopulationPackage populationPackage = new KuaishouPopulationPackage();
-            populationPackage.setId(id);
+            KuaishouPopulationPackage populationPackage = kuaishouPopulationPackageService.getById(id);
+            if (Check.isNull(populationPackage)) {
+                return Result.error("未查到实体");
+            }
             populationPackage.setDataStatus(0);//逻辑删除
             boolean b = kuaishouPopulationPackageService.updateById(populationPackage);
             if (b) {
+                JSONObject data = new JSONObject();
+                data.put("id", id);
+                data.put("projectId", populationPackage.getProjectId());
+                kuaishouMaterialPoolOperationRecordService.addRecord(data, "/kuaishouPopulationPackage/delete", 2, "delete");
                 return Result.ok("删除成功!");
             }
         } catch (Exception e) {

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

@@ -0,0 +1,351 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.service.IProjectService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.QueryGenerator;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouProjectStrategy;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouProjectStrategyService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+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.vo.LoginUser;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 自动投放-项目策略表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-06-24
+ */
+@Slf4j
+@Api(tags = "自动投放-项目策略表")
+@RestController
+@RequestMapping("/kuaishouProjectStrategy")
+public class KuaishouProjectStrategyController {
+    @Autowired
+    private IKuaishouProjectStrategyService kuaishouProjectStrategyService;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private IProjectService projectService;
+
+
+    /**
+     * 项目配置列表
+     */
+    @PostMapping(value = "/queryProjectList")
+    public Result<Object> queryProjectList(@RequestBody JSONObject data) {
+        try {
+            if (Check.isNull(data.getString("startTime")) || Check.isNull(data.getString("endTime"))) {
+                return Result.error("请选择查询时间");
+            }
+            return kuaishouProjectStrategyService.queryProjectList(data);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 项目策略中账户列表
+     */
+    @PostMapping(value = "/queryAccountList")
+    public Result<Object> queryAccountList(@RequestBody JSONObject data) {
+        try {
+            if (Check.isNull(data.getString("startTime")) || Check.isNull(data.getString("endTime"))) {
+                return Result.error("请选择查询时间");
+            }
+            return kuaishouProjectStrategyService.queryAccountList(data);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 修改项目策略状态
+     */
+    @PostMapping(value = "/updateProjectStrategy")
+    public Result<Object> updateProjectStrategy(@RequestBody KuaishouProjectStrategy kuaishouProjectStrategy) {
+        KuaishouProjectStrategy kuaishouProjectStrategyEntity = kuaishouProjectStrategyService.getById(kuaishouProjectStrategy.getId());
+        if (kuaishouProjectStrategyEntity == null) {
+            return Result.error("未找到对应实体");
+        } else {
+            boolean ok = kuaishouProjectStrategyService.updateById(kuaishouProjectStrategy);
+            if (ok) {
+                return Result.ok("修改成功!");
+            }
+        }
+        return Result.ok("修改失败!");
+    }
+
+    /**
+     * 修改项目策略状态
+     */
+    @PostMapping(value = "/updateAccountStatus")
+    public Result<Object> updateAccountStatus(@RequestBody JSONObject data) {
+        try {
+            Long accountId = data.getLong("accountId");
+            Integer projectStrategy = data.getInteger("projectStrategy");
+            if (Check.isNull(accountId) || Check.isNull(projectStrategy)) {
+                return Result.error("缺失参数");
+            }
+            boolean ok = userAllocationService.updateProjectStrategyStatus(accountId, projectStrategy);
+            if (ok) {
+                return Result.ok("修改成功!");
+            }
+        } catch (Exception e) {
+            log.error("修改异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("修改失败");
+    }
+
+    /**
+     * 校验是否有开启的项目
+     */
+    @GetMapping(value = "/checkProjectisOpen")
+    public Result<Object> checkProjectisOpen(Long projectId) {
+        try {
+            if (Check.isNull(projectId)) {
+                return Result.error("缺失参数");
+            }
+            boolean ok = kuaishouProjectStrategyService.checkProjectisOpen(projectId);
+            if (ok) {
+                return Result.ok((Object) 1);
+            }
+        } catch (Exception e) {
+            log.error("修改异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.ok((Object) 0);
+    }
+
+    /**
+     * 出价反显展示
+     */
+    @GetMapping(value = "/queryBidInfo")
+    public Result<Object> queryBidInfo(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouProjectStrategy> result = new Result<>();
+        KuaishouProjectStrategy kuaishouProjectStrategy = kuaishouProjectStrategyService.getById(id);
+        if (kuaishouProjectStrategy == null) {
+            return Result.error("未找到对应实体");
+        } else {
+            return Result.ok(kuaishouProjectStrategy);
+        }
+    }
+
+    /**
+     * 查询项目策略匹配结果
+     */
+    @GetMapping(value = "/queryMatchResult")
+    public Result<Object> queryMatchResult(Long projectId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        Result<KuaishouProjectStrategy> result = new Result<>();
+        try {
+            return kuaishouProjectStrategyService.queryMatchResult(projectId, pageNo, pageSize);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+
+    /**
+     * 创建项目策略
+     */
+    @PostMapping(value = "/createProjectStrategy")
+    public Result<KuaishouProjectStrategy> createProjectStrategy(@RequestBody JSONObject data) {
+        Result<KuaishouProjectStrategy> result = new Result<>();
+        try {
+            KuaishouProjectStrategy kuaishouProjectStrategy = JSONObject.parseObject(data.toJSONString(), KuaishouProjectStrategy.class);
+            kuaishouProjectStrategy.setStatDate(DateUtils.getNowDate("yyyy-MM-dd"));
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            if (!Check.isNull(user)) {
+                kuaishouProjectStrategy.setUserId(user.getId());
+            }
+            if (Check.isNull(kuaishouProjectStrategy.getId()) && !Check.isNull(kuaishouProjectStrategy.getProjectId())) {
+                QueryWrapper<UserAllocation> wrapper = new QueryWrapper<>();
+                wrapper.eq("project_id", kuaishouProjectStrategy.getProjectId());
+                wrapper.eq("account_status", 0);
+                wrapper.eq("auto_delivery", 0);
+                UserAllocation userAllocation = new UserAllocation();
+                userAllocation.setAutoDelivery(1);
+                userAllocationService.update(userAllocation, wrapper);
+            }
+            boolean b = kuaishouProjectStrategyService.saveOrUpdate(kuaishouProjectStrategy);
+            result.success("操作成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "自动投放-项目策略表-通过id删除", notes = "自动投放-项目策略表-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id") String id) {
+        try {
+            kuaishouProjectStrategyService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @ApiOperation(value = "自动投放-项目策略表-批量删除", notes = "自动投放-项目策略表-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouProjectStrategy> deleteBatch(@RequestParam(name = "ids") String ids) {
+        Result<KuaishouProjectStrategy> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouProjectStrategyService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "自动投放-项目策略表-通过id查询", notes = "自动投放-项目策略表-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouProjectStrategy> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouProjectStrategy> result = new Result<>();
+        KuaishouProjectStrategy kuaishouProjectStrategy = kuaishouProjectStrategyService.getById(id);
+        if (kuaishouProjectStrategy == null) {
+            result.error500("未找到对应实体");
+        } else {
+            Project project = projectService.getById(kuaishouProjectStrategy.getProjectId());
+            if (!Check.isNull(project)) {
+                kuaishouProjectStrategy.setProjectName(project.getProjectName());
+            }
+            result.setResult(kuaishouProjectStrategy);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouProjectStrategy> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouProjectStrategy kuaishouProjectStrategy = JSON.parseObject(deString, KuaishouProjectStrategy.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouProjectStrategy, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouProjectStrategy> pageList = kuaishouProjectStrategyService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "自动投放-项目策略表列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouProjectStrategy.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("自动投放-项目策略表列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaishouProjectStrategy> listKuaishouProjectStrategys = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouProjectStrategy.class, params);
+                kuaishouProjectStrategyService.saveBatch(listKuaishouProjectStrategys);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouProjectStrategys.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

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

@@ -101,6 +101,13 @@ public class KuaishouVideoDirectionalPackageController {
             if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
                 directionalPackage.setKeyword(JSONObject.toJSONString(requestJson.getJSONArray("keyword")));
             }
+            if("0".equals(requestJson.getJSONObject("allForm").getString("behaviorInterest"))){
+                directionalPackage.setSceneType("[]");
+                directionalPackage.setTimeType(-1);
+                directionalPackage.setStrengthType(0);
+                directionalPackage.setLabel("[]");
+                directionalPackage.setInterestLabel("[]");
+            }
             kuaishouVideoDirectionalPackageService.saveOrUpdate(directionalPackage);
             String id = "";
             if (!Check.isNull(directionalPackage.getId())) {

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

@@ -0,0 +1,84 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 智能投放-账户层级操作记录表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-07-11
+ */
+@Data
+@TableName("ctop_ai_kuaishou_account_level_operation_record")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_ai_kuaishou_account_level_operation_record对象", description = "智能投放-账户层级操作记录表")
+public class AiKuaishouAccountLevelOperationRecord {
+
+    /**
+     * 账户操作表uuid
+     */
+    @TableId(type = IdType.ASSIGN_UUID)
+    @ApiModelProperty(value = "账户操作表uuid")
+    private String id;
+    /**
+     * AI策略ID
+     */
+    @Excel(name = "AI策略ID", width = 15)
+    @ApiModelProperty(value = "AI策略ID")
+    private String aiStrategyUuid;
+    /**
+     * 项目ID
+     */
+    @Excel(name = "项目ID", width = 15)
+    @ApiModelProperty(value = "项目ID")
+    private Long projectId;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 异常类型 1 检查错误,2创建时错误
+     */
+    @Excel(name = "错误类型", width = 15)
+    @ApiModelProperty(value = "状态")
+    private Integer errType;
+    /**
+     * 1:账户自动投放 2:项目自动投放
+     */
+    @Excel(name = "1:账户自动投放 2:项目自动投放", width = 15)
+    @ApiModelProperty(value = "1:账户自动投放 2:项目自动投放")
+    private Integer createType;
+    /**
+     * 状态详情
+     */
+    @Excel(name = "状态详情", width = 15)
+    @ApiModelProperty(value = "状态详情")
+    private String message;
+    private String statDate;
+    /**
+     * 状态
+     */
+    @Excel(name = "状态", width = 15)
+    @ApiModelProperty(value = "状态")
+    private Integer status;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    private Date updateTime;
+}

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

@@ -9,53 +9,97 @@ import java.util.Date;
 
 /**
  * 计划创建记录
+ *
  * @author jeecg-boot
- * @date   2021-04-12
  * @version V1.0
+ * @date 2021-04-12
  */
 @Data
 @TableName("ctop_ai_kuaishou_campaign_level_operation_record")
 public class AiKuaishouCampaignLevelOperationRecord {
 
-	/**计划操作表uuid*/
-	@TableId(type = IdType.ASSIGN_UUID)
-	private String campaignUuid;
-	/**AI策略ID*/
-	private String aiStrategyUuid;
-	/**账户ID*/
-	private Long accountId;
-	/**广告计划ID*/
-	private Long campaignId;
-	/**广告计划名称*/
-	private String campaignName;
-	/**计划类型 2-提升应用安装 3-获取电商下单 4-推广品牌活动 5-收集销售线索 7-提高应用活跃*/
-	private Integer campaignType;
-	/**单日预算*/
-	private Long dayBudget;
-	/**分日预算*/
-	private String dayBudgetSchedule;
-	/**操作类型 1-新增 2-修改*/
-	private Integer operationType;
-	/**计划创建时间*/
-	private Date campaignCreateTime;
-	/**计划更新时间*/
-	private Date campaignUpdateTime;
-	/**创建时间*/
-	private Date createTime;
-	/**状态*/
-	private Integer status;
-	/**状态详情*/
-	private String message;
+    /**
+     * 计划操作表uuid
+     */
+    @TableId(type = IdType.ASSIGN_UUID)
+    private String campaignUuid;
+    /**
+     * AI策略ID
+     */
+    private String aiStrategyUuid;
+    /**
+     * 账户ID
+     */
+    private Long accountId;
+    /**
+     * 广告计划ID
+     */
+    private Long campaignId;
+    /**
+     * 广告计划名称
+     */
+    private String campaignName;
+    /**
+     * 计划类型 2-提升应用安装 3-获取电商下单 4-推广品牌活动 5-收集销售线索 7-提高应用活跃
+     */
+    private Integer campaignType;
+    /**
+     * 单日预算
+     */
+    private Long dayBudget;
+    /**
+     * 分日预算
+     */
+    private String dayBudgetSchedule;
+    /**
+     * 操作类型 1-新增 2-修改
+     */
+    private Integer operationType;
+    /**
+     * 计划创建时间
+     */
+    private Date campaignCreateTime;
+    /**
+     * 计划更新时间
+     */
+    private Date campaignUpdateTime;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    /**
+     * 状态
+     */
+    private Integer status;
+    /**
+     * 状态详情
+     */
+    private String message;
+    /**
+     * 1:账户自动投放 2:项目自动投放
+     */
+    private Integer createType;
 
-	public AiKuaishouCampaignLevelOperationRecord(AiKuaishouAdvertiserStrategy strategy, Long campaignId, Integer code, String message) {
-		this.accountId = strategy.getAccountId();
-		this.dayBudget = strategy.getCampaignDayBudget();
-		this.dayBudgetSchedule = strategy.getCampaignDayBudgetSchedule();
-		this.campaignType = strategy.getCampaignType();
-		this.campaignId = campaignId;
-		this.status = code;
-		this.message = message;
-		this.operationType = 1;
-		this.createTime = new Date();
-	}
+    public AiKuaishouCampaignLevelOperationRecord(AiKuaishouAdvertiserStrategy strategy, Long campaignId, Integer code, String message) {
+        this.accountId = strategy.getAccountId();
+        this.dayBudget = strategy.getCampaignDayBudget();
+        this.dayBudgetSchedule = strategy.getCampaignDayBudgetSchedule();
+        this.campaignType = strategy.getCampaignType();
+        this.campaignId = campaignId;
+        this.status = code;
+        this.message = message;
+        this.operationType = 1;
+        this.createTime = new Date();
+    }
+
+    public AiKuaishouCampaignLevelOperationRecord(KuaishouProjectStrategy strategy, Long campaignId, Integer code, String message) {
+        this.accountId = strategy.getAccountId();
+        this.dayBudget = strategy.getCampaignDayBudget();
+        this.campaignType = strategy.getCampaignType();
+        this.campaignId = campaignId;
+        this.status = code;
+        this.message = message;
+        this.operationType = 1;
+        this.createTime = new Date();
+    }
 }

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

@@ -151,4 +151,8 @@ public class AiKuaishouCreativeLevelOperationRecord {
      * 状态详情
      */
     private String message;
+    /**
+     * 1:账户自动投放 2:项目自动投放
+     */
+    private Integer createType;
 }

+ 107 - 52
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouProgramCreativeLevelOperationRecord.java

@@ -9,63 +9,118 @@ import java.util.Date;
 
 /**
  * 程序换创意创建记录
+ *
  * @author jeecg-boot
- * @date   2021-04-12
  * @version V1.0
+ * @date 2021-04-12
  */
 @Data
 @TableName("ctop_ai_kuaishou_program_creative_level_operation_record")
 public class AiKuaishouProgramCreativeLevelOperationRecord {
 
-	/**程序化创意操作表uuid*/
-	@TableId(type = IdType.ASSIGN_UUID)
-	private String creativeUuid;
-	/**AI策略ID*/
-	private String aiStrategyUuid;
-	/**账户ID*/
-	private Integer accountId;
-	/**广告计划ID*/
-	private Integer campaignId;
-	/**广告组ID*/
-	private Integer unitId;
-	/**是否为便利贴,默认为0*/
-	private Integer isSticky;
-	/**程序化创意名称*/
-	private String packageName;
-	/**横版视频ID list*/
-	private String horizontalPhotoIds;
-	/**竖版视频ID list*/
-	private String verticalPhotoIds;
-	/**封面list image_token*/
-	private String coverImageTokens;
-	/**落地页ID*/
-	private Integer siteId;
-	/**封面贴纸*/
-	private String stickerStyles;
-	/**封面广告语*/
-	private String coverSlogans;
-	/**行动号召按钮*/
-	private String actionBar;
-	/**作品广告语*/
-	private String captions;
-	/**第三方点击检测链接*/
-	private String clickUrl;
-	/**第三方点击检测链接*/
-	private String actionbarClickUrl;
-	/**创意分类*/
-	private Integer creativeCategory;
-	/**创意标签*/
-	private String creativeTag;
-	/**状态值 1-已提交等待回调 0-创建成功 */
-	private Integer status;
-	/**状态详情*/
-	private String message;
-	/**操作类型 1-新增 2-修改*/
-	private Integer operationType;
-	/**创意创建时间*/
-	private Date creativeCreateTime;
-	/**创意更新时间*/
-	private Date creativeUpdateTime;
-	/**创建时间*/
-	private Date createTime;
+    /**
+     * 程序化创意操作表uuid
+     */
+    @TableId(type = IdType.ASSIGN_UUID)
+    private String creativeUuid;
+    /**
+     * AI策略ID
+     */
+    private String aiStrategyUuid;
+    /**
+     * 账户ID
+     */
+    private Long accountId;
+    /**
+     * 广告计划ID
+     */
+    private Long campaignId;
+    /**
+     * 广告组ID
+     */
+    private Long unitId;
+    /**
+     * 是否为便利贴,默认为0
+     */
+    private Integer isSticky;
+    /**
+     * 程序化创意名称
+     */
+    private String packageName;
+    /**
+     * 横版视频ID list
+     */
+    private String horizontalPhotoIds;
+    /**
+     * 竖版视频ID list
+     */
+    private String verticalPhotoIds;
+    /**
+     * 封面list image_token
+     */
+    private String coverImageTokens;
+    /**
+     * 落地页ID
+     */
+    private Integer siteId;
+    /**
+     * 封面贴纸
+     */
+    private String stickerStyles;
+    /**
+     * 封面广告语
+     */
+    private String coverSlogans;
+    /**
+     * 行动号召按钮
+     */
+    private String actionBar;
+    /**
+     * 作品广告语
+     */
+    private String captions;
+    /**
+     * 第三方点击检测链接
+     */
+    private String clickUrl;
+    /**
+     * 第三方点击检测链接
+     */
+    private String actionbarClickUrl;
+    /**
+     * 创意分类
+     */
+    private Integer creativeCategory;
+    /**
+     * 创意标签
+     */
+    private String creativeTag;
+    /**
+     * 状态值 1-已提交等待回调 0-创建成功
+     */
+    private Integer status;
+    /**
+     * 状态详情
+     */
+    private String message;
+    /**
+     * 操作类型 1-新增 2-修改
+     */
+    private Integer operationType;
+    /**
+     * 创意创建时间
+     */
+    private Date creativeCreateTime;
+    /**
+     * 创意更新时间
+     */
+    private Date creativeUpdateTime;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    /**
+     * 1:账户自动投放 2:项目自动投放
+     */
+    private Integer createType;
 }

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

@@ -192,6 +192,11 @@ public class AiKuaishouUnitLevelOperationRecord {
      */
     private Integer gender;
     /**
+     * 创建类型
+     * 1:账户自动投放 2:项目自动投放
+     */
+    private Integer createType;
+    /**
      * 操作系统
      */
     private Integer platformOs;

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

@@ -65,6 +65,19 @@ public class KuaishouAppPackageRel {
     @ApiModelProperty(value = "快手方-应用地址")
     private String returnUrl;
 
+    /**
+     * 第三方开始播放监测链接
+     */
+    private String impressionUrl;
+    /**
+     * 第三方有效播放监测链接
+     */
+    private String adPhotoPlayedT3sUrl;
+    /**
+     * 第三方点击按钮监测链接
+     */
+    private String actionbarClickUrl;
+
     private Integer dataStatus;
 
     private String appVersion;

+ 77 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouMaterialPoolOperationRecord.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.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 物料池操作记录表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-07-19
+ */
+@Data
+@TableName("ctop_kuaishou_material_pool_operation_record")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_material_pool_operation_record对象", description = "物料池操作记录表")
+public class KuaishouMaterialPoolOperationRecord {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 项目ID
+     */
+    @Excel(name = "项目ID", width = 15)
+    @ApiModelProperty(value = "项目ID")
+    private Long projectId;
+    /**
+     * 操作人
+     */
+    @Excel(name = "操作人", width = 15)
+    @ApiModelProperty(value = "操作人")
+    private String userId;
+    /**
+     * 物料类型,1-定向,2-人群,3-应用
+     */
+    @Excel(name = "物料类型,1-定向,2-人群,3-应用", width = 15)
+    @ApiModelProperty(value = "物料类型,1-定向,2-人群,3-应用")
+    private Integer materialType;
+    /**
+     * 操作类型,add,update,delete
+     */
+    @Excel(name = "操作类型,add,update,delete", width = 15)
+    @ApiModelProperty(value = "操作类型,add,update,delete")
+    private String type;
+    /**
+     * 操作数据JSON
+     */
+    @Excel(name = "操作数据JSON", width = 15)
+    @ApiModelProperty(value = "操作数据JSON")
+    private String data;
+    //方法名
+    private String method_name;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+}

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

@@ -0,0 +1,377 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 自动投放-项目策略表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-06-24
+ */
+@Data
+@TableName("ctop_ai_kuaishou_project_strategy")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_ai_kuaishou_project_strategy对象", description = "自动投放-项目策略表")
+public class KuaishouProjectStrategy {
+
+    /**
+     * 客户策略ID
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "客户策略ID")
+    private Long id;
+    /**
+     * 项目ID
+     */
+    @Excel(name = "项目ID", width = 15)
+    @ApiModelProperty(value = "项目ID")
+    private Long projectId;
+    /**
+     * userId
+     */
+    @Excel(name = "userId", width = 15)
+    @ApiModelProperty(value = "userId")
+    private String userId;
+    /**
+     * 策略状态 0-停用 1-使用
+     */
+    @Excel(name = "策略状态 0-停用 1-使用", width = 15)
+    @ApiModelProperty(value = "策略状态 0-停用 1-使用")
+    private Integer dataStatus;
+    /**
+     * 计划类型 2-提升应用安装 3-获取电商下单 4-推广品牌活动 5-收集销售线索 7-提高应用活跃
+     */
+    @Excel(name = "计划类型 2-提升应用安装 3-获取电商下单 4-推广品牌活动 5-收集销售线索 7-提高应用活跃", width = 15)
+    @ApiModelProperty(value = "计划类型 2-提升应用安装 3-获取电商下单 4-推广品牌活动 5-收集销售线索 7-提高应用活跃")
+    private Integer campaignType;
+    /**
+     * 计划命名规范
+     */
+    @Excel(name = "计划命名规范", width = 15)
+    @ApiModelProperty(value = "计划命名规范")
+    private String campaignName;
+
+    private Integer campaignStatus;
+
+    private String statDate;
+    /**
+     * 广告组命名规范
+     */
+    @Excel(name = "广告组命名规范", width = 15)
+    @ApiModelProperty(value = "广告组命名规范")
+    private String groupName;
+    /**
+     * -1:投放 2 暂停
+     */
+    private Integer groupStatus;
+    /**
+     * 是否开启素材挖掘
+     */
+    private Integer assetMining;
+    /**
+     * 计划单日预算
+     */
+    @Excel(name = "计划单日预算", width = 15)
+    @ApiModelProperty(value = "计划单日预算")
+    private Long campaignDayBudget;
+    /**
+     * 组单日预算
+     */
+    @Excel(name = "组单日预算", width = 15)
+    @ApiModelProperty(value = "组单日预算")
+    private Long unitDayBudget;
+    /**
+     * 单/多应用,1单应用,2多应用
+     */
+    @Excel(name = "单/多应用,1单应用,2多应用", width = 15)
+    @ApiModelProperty(value = "单/多应用,1单应用,2多应用")
+    private Integer singleAppid;
+    /**
+     * 应用ID
+     */
+    @Excel(name = "应用ID", width = 15)
+    @ApiModelProperty(value = "应用ID")
+    private Long appId;
+    /**
+     * 应用ID列表
+     */
+    @Excel(name = "应用ID列表", width = 15)
+    @ApiModelProperty(value = "应用ID列表")
+    private String appIdArray;
+    /**
+     * 定向模板id列表
+     */
+    @Excel(name = "定向模板id列表", width = 15)
+    @ApiModelProperty(value = "定向模板id列表")
+    private String templateIdArray;
+    /**
+     * 组-优先从系统应用商店下载
+     */
+    @Excel(name = "组-优先从系统应用商店下载", width = 15)
+    @ApiModelProperty(value = "组-优先从系统应用商店下载")
+    private Integer useAppMarket;
+    /**
+     * 组-应用商店列表
+     */
+    @Excel(name = "组-应用商店列表", width = 15)
+    @ApiModelProperty(value = "组-应用商店列表")
+    private String appStore;
+    /**
+     * 组-调起应用链接
+     */
+    @Excel(name = "组-调起应用链接", width = 15)
+    @ApiModelProperty(value = "组-调起应用链接")
+    private String schemaUri;
+    /**
+     * 组-优化目标 2:行为数,180:激活数;53:表单数;190: 付费;191:首日ROI;324:唤起应用...
+     */
+    @Excel(name = "组-优化目标 2:行为数,180:激活数;53:表单数;190: 付费;191:首日ROI;324:唤起应用...", width = 15)
+    @ApiModelProperty(value = "组-优化目标 2:行为数,180:激活数;53:表单数;190: 付费;191:首日ROI;324:唤起应用...")
+    private Integer ocpxActionType;
+    /**
+     * 组-转化目标ID
+     */
+    @Excel(name = "组-转化目标ID", width = 15)
+    @ApiModelProperty(value = "组-转化目标ID")
+    private Integer convertId;
+    /**
+     * 组-优化目标出价类型
+     */
+    @Excel(name = "组-优化目标出价类型", width = 15)
+    @ApiModelProperty(value = "组-优化目标出价类型")
+    private Integer bidType;
+    /**
+     * 出价
+     */
+    @Excel(name = "出价", width = 15)
+    @ApiModelProperty(value = "出价")
+    private String bid;
+    /**
+     * OCPC出价
+     */
+    @Excel(name = "OCPC出价", width = 15)
+    @ApiModelProperty(value = "OCPC出价")
+    private String cpaBid;
+    /**
+     * 组-深度转化出价
+     */
+    @Excel(name = "组-深度转化出价", width = 15)
+    @ApiModelProperty(value = "组-深度转化出价")
+    private String deepConversionBid;
+    /**
+     * 组-深度转化目标
+     */
+    @Excel(name = "组-深度转化目标", width = 15)
+    @ApiModelProperty(value = "组-深度转化目标")
+    private Long deepConversionType;
+    /**
+     * 组-优先低成本出价
+     */
+    @Excel(name = "组-优先低成本出价", width = 15)
+    @ApiModelProperty(value = "组-优先低成本出价")
+    private Long smartBid;
+    /**
+     * 组-付费ROI系数
+     */
+    @Excel(name = "组-付费ROI系数", width = 15)
+    @ApiModelProperty(value = "组-付费ROI系数")
+    private Float roiRatio;
+    /**
+     * 组-投放开始时间
+     */
+    @Excel(name = "组-投放开始时间", width = 15)
+    @ApiModelProperty(value = "组-投放开始时间")
+    private String beginTime;
+    /**
+     * 组-投放结束时间
+     */
+    @Excel(name = "组-投放结束时间", width = 15)
+    @ApiModelProperty(value = "组-投放结束时间")
+    private String endTime;
+    /**
+     * 组-投放时间段
+     */
+    @Excel(name = "组-投放时间段", width = 15)
+    @ApiModelProperty(value = "组-投放时间段")
+    private String scheduleTime;
+    /**
+     * url类型 当计划类型为:3(获取电商下单)时必填:1 - 淘宝商品短链;2 - 淘宝商品itemID;4 - 金牛电商
+     */
+    @Excel(name = "url类型 当计划类型为:3(获取电商下单)时必填:1 - 淘宝商品短链;2 - 淘宝商品itemID;4 - 金牛电商", width = 15)
+    @ApiModelProperty(value = "url类型 当计划类型为:3(获取电商下单)时必填:1 - 淘宝商品短链;2 - 淘宝商品itemID;4 - 金牛电商")
+    private Integer urlType;
+    /**
+     * 当计划类型为5(收集销售线索)&使用建站时必填:需使用魔力建站;不传默认1,2:落地页
+     */
+    @Excel(name = "当计划类型为5(收集销售线索)&使用建站时必填:需使用魔力建站;不传默认1,2:落地页", width = 15)
+    @ApiModelProperty(value = "当计划类型为5(收集销售线索)&使用建站时必填:需使用魔力建站;不传默认1,2:落地页")
+    private Integer webUriType;
+    /**
+     * 投放链接
+     */
+    @Excel(name = "投放链接", width = 15)
+    @ApiModelProperty(value = "投放链接")
+    private String url;
+    /**
+     * 组-创意展现方式 1-轮播  2-优选
+     */
+    @Excel(name = "组-创意展现方式 1-轮播  2-优选", width = 15)
+    @ApiModelProperty(value = "组-创意展现方式 1-轮播  2-优选")
+    private Integer showMode;
+    /**
+     * 组-投放方式 1-加速投放  2-平滑投放 3-优先低成本
+     */
+    @Excel(name = "组-投放方式 1-加速投放  2-平滑投放 3-优先低成本", width = 15)
+    @ApiModelProperty(value = "组-投放方式 1-加速投放  2-平滑投放 3-优先低成本")
+    private Integer speed;
+    /**
+     * 创意制作方式,0-不限,4-自定义,7-程序化创意2.0
+     */
+    @Excel(name = " 创意制作方式,0-不限,4-自定义,7-程序化创意2.0", width = 15)
+    @ApiModelProperty(value = " 创意制作方式,0-不限,4-自定义,7-程序化创意2.0")
+    private Integer unitType;
+    /**
+     * 广告位;1:优选,3:视频播放页,5:联盟,6:上下滑
+     */
+    @Excel(name = "广告位;1:优选,3:视频播放页,5:联盟,6:上下滑", width = 15)
+    @ApiModelProperty(value = "广告位;1:优选,3:视频播放页,5:联盟,6:上下滑")
+    private String sceneId;
+    /**
+     * 关联封面数
+     */
+    @Excel(name = "关联封面数", width = 15)
+    @ApiModelProperty(value = "关联封面数")
+    private Integer imageCnt;
+    /**
+     * 自定义组数,最多400
+     */
+    @Excel(name = "自定义组数,最多400", width = 15)
+    @ApiModelProperty(value = "自定义组数,最多400")
+    private Integer customUnitCnt;
+    /**
+     * 程序化组数,最多60
+     */
+    @Excel(name = "程序化组数,最多60", width = 15)
+    @ApiModelProperty(value = "程序化组数,最多60")
+    private Integer programUnitCnt;
+    /**
+     * 素材类型 2-不限,0-内部,1-素造
+     */
+    @Excel(name = "素材类型 2-不限,0-内部,1-素造", width = 15)
+    @ApiModelProperty(value = "素材类型 2-不限,0-内部,1-素造")
+    private Integer channelType;
+    /**
+     * 智能抽帧
+     */
+    @Excel(name = "智能抽帧", width = 15)
+    @ApiModelProperty(value = "智能抽帧")
+    private Integer smartCover;
+    /**
+     * 行动号召
+     */
+    @Excel(name = "行动号召", width = 15)
+    @ApiModelProperty(value = "行动号召")
+    private String actionBarText;
+    /**
+     * 广告语
+     */
+    @Excel(name = "广告语", width = 15)
+    @ApiModelProperty(value = "广告语")
+    private String description;
+
+    private String stickerTitle;
+
+    private String overlayType;
+
+    private String exposeTag;
+
+    private String newExposeTag;
+    /**
+     * 创意分类
+     */
+    @Excel(name = "创意分类", width = 15)
+    @ApiModelProperty(value = "创意分类")
+    private Integer creativeCategory;
+    //安卓下载中间页ID
+    private Integer siteId;
+    /**
+     * 创意标签
+     */
+    @Excel(name = "创意标签", width = 15)
+    @ApiModelProperty(value = "创意标签")
+    private String creativeTag;
+    /**
+     * 创意-第三方点击检测链接
+     */
+    @Excel(name = "创意-第三方点击检测链接", width = 15)
+    @ApiModelProperty(value = "创意-第三方点击检测链接")
+    private String clickTrackUrl;
+    /**
+     * 创意-第三方开始播放监测链接
+     */
+    @Excel(name = "创意-第三方开始播放监测链接", width = 15)
+    @ApiModelProperty(value = "创意-第三方开始播放监测链接")
+    private String impressionUrl;
+    /**
+     * 创意-第三方有效播放监测链接
+     */
+    @Excel(name = "创意-第三方有效播放监测链接", width = 15)
+    @ApiModelProperty(value = "创意-第三方有效播放监测链接")
+    private String adPhotoPlayedT3sUrl;
+    /**
+     * 创意-第三方点击按钮监测链接
+     */
+    @Excel(name = "创意-第三方点击按钮监测链接", width = 15)
+    @ApiModelProperty(value = "创意-第三方点击按钮监测链接")
+    private String actionbarClickUrl;
+    /**
+     * 素材来源 1-上限素材,2-高质量素材,3-遗漏素材,4-历史打捞
+     */
+    @Excel(name = "素材来源 1-上限素材,2-高质量素材,3-遗漏素材,4-历史打捞", width = 15)
+    @ApiModelProperty(value = "素材来源 1-上限素材,2-高质量素材,3-遗漏素材,4-历史打捞")
+    private String sourceMaterial;
+    /**
+     * 定时执行生效时间
+     */
+    @ApiModelProperty(value = "定时执行生效时间")
+    private Date effectiveTime;
+    /**
+     * 定时执行失效时间
+     */
+    @ApiModelProperty(value = "定时执行失效时间")
+    private Date expiryTime;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+
+    @TableField(exist = false)
+    private Long accountId;
+
+    @TableField(exist = false)
+    private String strategyUuid;
+    @TableField(exist = false)
+    private Long campaignId;
+    @TableField(exist = false)
+    private String projectName;
+
+}

+ 101 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/enums/KuaishouProjectCreativeMatTypeEnum.java

@@ -0,0 +1,101 @@
+package cn.com.ctop.kuaishou.modules.ai.enums;
+
+/**
+ * @author syh
+ */
+public enum KuaishouProjectCreativeMatTypeEnum {
+    /**
+     * 13 23 分别是历史遗漏素材,归类到上新素材中
+     * type字段 第一位创意创建方式,第二位素材获取方式
+     * 快手创意素材获取类型
+     */
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_NEW("41","自定义上新",-20L,-10L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_HIGH_quality("42","自定义高质量",-28*60*24L,-1*60*24L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_MISSING("43","自定义上新",-60*60*24L,-1*60*24L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_HISTORY("44","自定义历史",-60*60*24L,-1*60*24L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_NEW("71","程序化上新",-3*60*24L,-5L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_HIGH_quality("72","程序化高质量",-28*60*24L,-1*60*24L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_MISSING("73","程序化上新",-60*60*24L,-1*60*24L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_HISTORY("74","程序化历史",-60*60*24L,-1*60*24L),;
+
+    /**
+     * 类型
+     */
+    private String type;
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * 素材查询的时间区间
+     */
+    private Long videoGetStartTime;
+    private Long videoGetEndTime;
+
+    KuaishouProjectCreativeMatTypeEnum(String type, String name, Long videoGetStartTime, Long videoGetEndTime) {
+        this.type = type;
+        this.name = name;
+        this.videoGetStartTime = videoGetStartTime;
+        this.videoGetEndTime = videoGetEndTime;
+    }
+
+    public static String getNameByType(String type) {
+        for (KuaishouProjectCreativeMatTypeEnum createTypeEnum : KuaishouProjectCreativeMatTypeEnum.values()) {
+            if (createTypeEnum.getType().equals(type)) {
+                return createTypeEnum.getName();
+            }
+        }
+        return "";
+    }
+
+    public static Long getStartTimeByType(String type) {
+        for (KuaishouProjectCreativeMatTypeEnum createTypeEnum : KuaishouProjectCreativeMatTypeEnum.values()) {
+            if (createTypeEnum.getType().equals(type)) {
+                return createTypeEnum.getVideoGetStartTime();
+            }
+        }
+        return -10L;
+    }
+
+    public static Long getEndTimeByType(String type) {
+        for (KuaishouProjectCreativeMatTypeEnum createTypeEnum : KuaishouProjectCreativeMatTypeEnum.values()) {
+            if (createTypeEnum.getType().equals(type)) {
+                return createTypeEnum.getVideoGetEndTime();
+            }
+        }
+        return -5L;
+    }
+
+
+    public String getType() {
+        return this.type;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public void setName(String value) {
+        this.name = value;
+    }
+
+    public Long getVideoGetStartTime() {
+        return videoGetStartTime;
+    }
+
+    public void setVideoGetStartTime(Long videoGetStartTime) {
+        this.videoGetStartTime = videoGetStartTime;
+    }
+
+    public Long getVideoGetEndTime() {
+        return videoGetEndTime;
+    }
+
+    public void setVideoGetEndTime(Long videoGetEndTime) {
+        this.videoGetEndTime = videoGetEndTime;
+    }
+}

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

@@ -0,0 +1,20 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountLevelOperationRecord;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 智能投放-账户层级操作记录表
+ *
+ * @author jeecg-boot
+ * 2021-07-11
+ * @version V1.0
+ */
+public interface AiKuaishouAccountLevelOperationRecordMapper extends BaseMapper<AiKuaishouAccountLevelOperationRecord> {
+
+    List<JSONObject> queryMatchResult(@Param("projectId") Long projectId);
+}

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

@@ -29,4 +29,6 @@ public interface KuaishouAppPackageMapper extends BaseMapper<KuaishouAppPackage>
     List<JSONObject> getRelatedGroups(@Param("id") Long id, @Param("accountId") Long accountId);
 
     String getUrlByMd5(@Param("md5") String md5);
+
+    List<KuaishouAppPackage> getProjectAppList(@Param("projectId") Long projectId);
 }

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

@@ -26,4 +26,8 @@ public interface KuaishouAppPackageRelMapper extends BaseMapper<KuaishouAppPacka
     List<JSONObject> getRelatedAccounts(@Param("id") Long id);
 
     List<JSONObject> getAccountByProjectId(@Param("projectId") Long projectId, @Param("id") String id);
+
+    List<JSONObject> getAppsDetail(@Param("ids") List<Long> ids);
+
+    JSONObject queryAppId(@Param("appTemId") Long appTemId, @Param("accountId") Long accountId);
 }

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

@@ -25,4 +25,8 @@ public interface KuaishouDirectionalPackageMapper extends BaseMapper<KuaishouDir
     List<JSONObject> getRelatedAccount(@Param("id") String id);
 
     List getRelatedGroup(@Param("id") String id, @Param("accountId") Long accountId);
+
+    List<KuaishouDirectionalPackage> queryListByProjectId(@Param("projectId") Long projectId, @Param("templateName") String templateName);
+
+    List<KuaishouDirectionalPackage> getProjectTargetByIds(@Param("ids") List<String> ids);
 }

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

@@ -28,4 +28,6 @@ public interface KuaishouDirectionalPckageRelMapper extends BaseMapper<KuaishouD
     List<JSONObject> queryUnitIdByAccountId(@Param("id") String id, @Param("accountId") Long accountId);
 
     void updateTemName(@Param("id") String id, @Param("templateName") String templateName);
+
+    Long selectTemplateId(@Param("dirId") String id,@Param("accountId")Long accountId);
 }

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import java.util.List;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouMaterialPoolOperationRecord;
+import org.apache.ibatis.annotations.Param;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 物料池操作记录表
+ * @author jeecg-boot
+ * 2021-07-19
+ * @version V1.0
+ */
+public interface KuaishouMaterialPoolOperationRecordMapper extends BaseMapper<KuaishouMaterialPoolOperationRecord> {
+
+}

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

@@ -0,0 +1,32 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouProjectStrategy;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 自动投放-项目策略表
+ *
+ * @author jeecg-boot
+ * 2021-06-24
+ * @version V1.0
+ */
+public interface KuaishouProjectStrategyMapper extends BaseMapper<KuaishouProjectStrategy> {
+
+    List<JSONObject> queryProjectList(JSONObject data);
+
+    List<JSONObject> queryAccountList(JSONObject data);
+
+    JSONObject queryProjectAll(JSONObject data);
+
+    JSONObject queryAccountAll(JSONObject data);
+
+    Integer checkProjectisOpen(Long projectId);
+
+    List<KuaishouProjectStrategy> getAllEffectStrategy(@Param("unitType")int unitType, @Param("sourceMaterial")String sourceMaterial);
+
+    List<Long> queryProjectId();
+}

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

@@ -0,0 +1,17 @@
+<?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.AiKuaishouAccountLevelOperationRecordMapper">
+
+    <select id="queryMatchResult" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            t1.account_id as 'accountId',
+            t1.message as 'resultText',
+            t1.`status` as 'authStatus',
+            t2.auth_name as 'authName'
+        FROM
+            ctop_ai_kuaishou_account_level_operation_record t1
+                LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where t1.project_id = #{projectId}
+        and stat_date = DATE_FORMAT(now(), '%Y-%m-%d')
+    </select>
+</mapper>

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

@@ -133,4 +133,18 @@
         WHERE image_md5 = #{md5} limit 1
     </select>
 
+    <select id="getProjectAppList" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAppPackage">
+        SELECT
+            t1.id,
+            t1.project_id,
+            CONCAT(app_name,'(',CASE  WHEN platform=1 OR platform=2 then 'Android' else 'iOS' END ,')') as 'appName',
+            t1.platform
+        FROM ctop_kuaishou_app_package t1
+                 LEFT JOIN ctop_kuaishou_app_package_rel t2 ON t1.id = t2.apptem_id
+        WHERE t1.data_status = 1
+          AND t1.project_id = #{projectId}
+          and t2.data_status = 1
+        GROUP BY t1.id
+    </select>
+
 </mapper>

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

@@ -92,4 +92,35 @@
           AND t1.project_id = #{projectId}
     </select>
 
+    <select id="queryAppId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT app_id,impression_url,actionbar_click_url,ad_photo_played_t3s_url,t2.track_url FROM  ctop_kuaishou_app_package_rel t1
+        LEFT JOIN ctop_kuaishou_app_package t2 ON t2.id = t1.apptem_id
+        where t1.data_status = 1
+        AND t1.account_id = #{accountId}
+        AND t1.apptem_id = #{appTemId}
+    </select>
+
+    <select id="getAppsDetail" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            apptem_id as 'apptemId',
+            t2.id,
+            t1.project_id as 'projectId',
+            t1.app_name as 'appName',
+            IFNULL(t1.track_url, '') as 'tracUrl',
+            t1.platform ,
+            t2.app_version as 'appVersion',
+            IFNULL(t2.impression_url, '') as 'impressionUrl',
+            IFNULL(t2.actionbar_click_url, '') as 'actionbarClickUrl',
+            IFNULL(t2.ad_photo_played_t3s_url, '') as 'adPhotoPlayedT3sUrl',
+            t2.app_id as 'appId',
+            (SELECT COUNT(1) FROM ctop_kuaishou_app_package_rel WHERE apptem_id = t2.apptem_id AND data_status = 1) as 'count'
+        FROM ctop_kuaishou_app_package t1
+                LEFT JOIN ctop_kuaishou_app_package_rel t2 ON t1.id = t2.apptem_id
+        WHERE t2.data_status = 1
+          AND apptem_id in
+        <foreach collection="ids" item="ids" separator="," open="(" close=")">
+            #{ids}
+        </foreach>
+    </select>
+
 </mapper>

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

@@ -109,4 +109,24 @@
         LEFT JOIN ctop_user_allocation t3 ON t1.account_id = t3.account_id
         WHERE t2.rel_type = 'unit' AND t2.dir_id =#{id}
     </select>
+
+    <select id="queryListByProjectId" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage">
+        SELECT *
+        FROM ctop_kuaishou_directional_package
+        WHERE data_status = 1
+        and project_id = #{projectId}
+        <if test="templateName !=null">
+            and template_name like concat('%',#{templateName},'%')
+        </if>
+    </select>
+
+    <select id="getProjectTargetByIds" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage">
+        SELECT *
+        FROM ctop_kuaishou_directional_package
+        WHERE data_status = 1
+        and id in
+        <foreach collection="ids" item="ids" separator="," open="(" close=")">
+            #{ids}
+        </foreach>
+    </select>
 </mapper>

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

@@ -93,6 +93,15 @@
           AND t2.dir_id = #{id}
     </select>
 
+    <select id="selectTemplateId" resultType="java.lang.Long">
+        SELECT template_id
+        FROM ctop_kuaishou_directional_package_rel
+        WHERE rel_type = 'account'
+        AND dir_id = #{dirId}
+        AND rel_id =#{accountId}
+        and data_status = 1
+    </select>
+
     <update id="updateTemName">
         update
             ctop_kuaishou_directional_package_rel

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouMaterialPoolOperationRecordMapper.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.KuaishouMaterialPoolOperationRecordMapper">
+
+</mapper>

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

@@ -0,0 +1,200 @@
+<?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.KuaishouProjectStrategyMapper">
+
+    <select id="queryProjectList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t1.*,
+               (SELECT COUNT(1) FROM ctop_user_allocation WHERE account_status = 0 and t1.projectId = project_id) as 'allAccountCount',
+               (SELECT COUNT(1) FROM ctop_user_allocation WHERE account_status = 0 and t1.projectId = project_id and auto_delivery = 1) as 'successCount',
+               IFNULL(SUM(t2.charge),0) as 'charge',
+               IFNULL(SUM(t2.photo_show),0) as 'photoShow',
+               IFNULL(SUM(t2.photo_click),0) as 'photoClick',
+               IFNULL(SUM(t2.aclick),0) as 'aclick',
+               IFNULL(SUM(t2.bclick),0) as 'bclick',
+               CONCAT(CAST(IFNULL(ROUND(SUM(t2.photo_click)/SUM(t2.photo_show)*100,2),0)as CHAR),'%') as 'photoClickRatio',
+               CONCAT(CAST(IFNULL(ROUND(SUM(t2.bclick)/SUM(t2.aclick)*100,2),0)as CHAR),'%') as 'actionRatio',
+               IFNULL(ROUND(SUM(t2.charge)/SUM(t2.aclick)*1000,2),0) as 'impression1kCost',
+               IFNULL(ROUND(SUM(t2.charge)/SUM(t2.photo_click),2),0) as 'photoClickCost',
+               IFNULL(ROUND(SUM(t2.charge)/SUM(t2.bclick),2),0) as 'actionCost'
+        FROM
+            (
+                SELECT
+                    k1.id,
+                    k1.data_status as 'dataStatus',
+                    k1.project_id as 'projectId',
+                    k3.project_name as 'projectName',
+                    k3.responsible_name as 'responsibleName',
+                    k1.stat_date as 'statDate',
+                    k2.account_id as 'accountId',
+                    k1.create_time as 'createTime'
+                FROM ctop_ai_kuaishou_project_strategy k1
+                         LEFT JOIN ctop_user_allocation k2 ON k1.project_id = k2.project_id
+                         LEFT JOIN ctop_project k3 ON k1.project_id = k3.id
+                where k3.media_id=2 and k2.auto_delivery != 3
+                    <if test="projectId != null ">
+                    and  k1.project_id = #{projectId}
+                    </if>
+                  <if test="dataStatus != null ">
+                    and  k1.data_status = #{dataStatus}
+                    </if>
+                    <if test="userId != null ">
+                     and k3.responsible_id = #{userId}
+                    </if>
+            ) t1
+                LEFT JOIN ctop_etl_kuaishou_report_account_daily t2 ON t2.account_id = t1.accountId
+        and t2.stat_date &gt;=#{startTime}
+        and t2.stat_date &lt;=#{endTime}
+        GROUP BY t1.id
+        <if test="sortCode != '' and sortCode != null ">
+            ORDER BY ${sortCode} ${sortType}
+        </if>
+    </select>
+
+    <select id="queryAccountList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            IFNULL(t1.auth_name,'') as 'authName',
+            IFNULL(t1.account_id,'') as 'accountId',
+            IFNULL(t1.auto_delivery,0) as 'projectStrategy',
+            IFNULL(t3.project_name,'') as 'projectName',
+            IFNULL(SUM(t2.charge),0) as 'charge',
+            IFNULL(SUM(t2.photo_show),0) as 'photoShow',
+            IFNULL(SUM(t2.photo_click),0) as 'photoClick',
+            IFNULL(SUM(t2.aclick),0) as 'aclick',
+            IFNULL(SUM(t2.bclick),0) as 'bclick',
+            CONCAT(CAST(IFNULL(ROUND(SUM(t2.photo_click)/SUM(t2.photo_show)*100,2),0)as CHAR),'%') as 'photoClickRatio',
+            CONCAT(CAST(IFNULL(ROUND(SUM(t2.bclick)/SUM(t2.aclick)*100,2),0)as CHAR),'%') as 'actionRatio',
+            IFNULL(ROUND(SUM(t2.charge)/SUM(t2.aclick)*1000,2),0) as 'impression1kCost',
+            IFNULL(ROUND(SUM(t2.charge)/SUM(t2.photo_click),2),0) as 'photoClickCost',
+            IFNULL(ROUND(SUM(t2.charge)/SUM(t2.bclick),2),0) as 'actionCost',
+            (SELECT IFNULL(MIN(stat_date),'') FROM ctop_kuaishou_report_daily_account where account_id = t1.account_id AND charge >0) as 'statDate'
+        FROM ctop_user_allocation t1
+                 LEFT JOIN ctop_etl_kuaishou_report_account_daily t2 ON t2.account_id = t1.account_id
+                and t2.stat_date &gt;=#{startTime}
+                and t2.stat_date &lt;=#{endTime}
+                 LEFT JOIN ctop_project t3 ON t1.project_id = t3.id
+        where t1.auto_delivery != 3 AND account_status = 0
+        <if test="projectIds != null and projectIds.size()>0 ">
+            AND t1.project_id in
+            <foreach collection="projectIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+          <if test="authName != null ">
+              and  t1.auth_name LIKE CONCAT('%',#{authName},'%')
+        </if>
+        GROUP BY t1.account_id
+        <if test="sortCode != '' and sortCode != null ">
+            ORDER BY ${sortCode} ${sortType}
+        </if>
+    </select>
+
+    <select id="queryAccountAll" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            '-' as 'authName',
+            IFNULL(t1.account_id,'') as 'accountId',
+            IFNULL(t1.project_strategy,0) as 'projectStrategy',
+            '-' as 'projectName',
+            IFNULL(SUM(t2.charge),0) as 'charge',
+            IFNULL(SUM(t2.photo_show),0) as 'photoShow',
+            IFNULL(SUM(t2.photo_click),0) as 'photoClick',
+            IFNULL(SUM(t2.aclick),0) as 'aclick',
+            IFNULL(SUM(t2.bclick),0) as 'bclick',
+            CONCAT(CAST(IFNULL(ROUND(SUM(t2.photo_click)/SUM(t2.photo_show)*100,2),0)as CHAR),'%') as 'photoClickRatio',
+            CONCAT(CAST(IFNULL(ROUND(SUM(t2.bclick)/SUM(t2.aclick)*100,2),0)as CHAR),'%') as 'actionRatio',
+            IFNULL(ROUND(SUM(t2.charge)/SUM(t2.aclick)*1000,2),0) as 'impression1kCost',
+            IFNULL(ROUND(SUM(t2.charge)/SUM(t2.photo_click),2),0) as 'photoClickCost',
+            IFNULL(ROUND(SUM(t2.charge)/SUM(t2.bclick),2),0) as 'actionCost'
+        FROM ctop_user_allocation t1
+                 LEFT JOIN ctop_etl_kuaishou_report_account_daily t2 ON t2.account_id = t1.account_id
+                 LEFT JOIN ctop_project t3 ON t1.project_id = t3.id
+        where t1.auto_delivery != 3
+          and t2.stat_date &gt;=#{startTime}
+          and t2.stat_date &lt;=#{endTime}
+        <if test="projectIds != null and projectIds.size()>0 ">
+            AND t1.project_id in
+            <foreach collection="projectIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+          <if test="authName != null ">
+              and  t1.auth_name LIKE CONCAT('%',#{authName},'%')
+        </if>
+    </select>
+
+    <select id="queryProjectAll" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            '-' as 'authName',
+            IFNULL(t1.account_id,'') as 'accountId',
+            IFNULL(t1.project_strategy,0) as 'projectStrategy',
+            '-' as 'projectName',
+            IFNULL(SUM(t2.charge),0) as 'charge',
+            IFNULL(SUM(t2.photo_show),0) as 'photoShow',
+            IFNULL(SUM(t2.photo_click),0) as 'photoClick',
+            IFNULL(SUM(t2.aclick),0) as 'aclick',
+            IFNULL(SUM(t2.bclick),0) as 'bclick',
+            CONCAT(CAST(IFNULL(ROUND(SUM(t2.photo_click)/SUM(t2.photo_show)*100,2),0)as CHAR),'%') as 'photoClickRatio',
+            CONCAT(CAST(IFNULL(ROUND(SUM(t2.bclick)/SUM(t2.aclick)*100,2),0)as CHAR),'%') as 'actionRatio',
+            IFNULL(ROUND(SUM(t2.charge)/SUM(t2.aclick)*1000,2),0) as 'impression1kCost',
+            IFNULL(ROUND(SUM(t2.charge)/SUM(t2.photo_click),2),0) as 'photoClickCost',
+            IFNULL(ROUND(SUM(t2.charge)/SUM(t2.bclick),2),0) as 'actionCost',
+            (SELECT COUNT(1) FROM ctop_user_allocation where auto_delivery = 1 AND account_status = 0
+            <if test="projectIds != null and projectIds.size()>0 ">
+                 AND project_id in
+                <foreach collection="projectIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            ) as 'successCount',
+            (SELECT COUNT(1) FROM ctop_user_allocation where account_status = 0
+            <if test="projectIds != null and projectIds.size()>0 ">
+            AND project_id in
+            <foreach collection="projectIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+            </if>
+            ) as 'allAccountCount'
+        FROM ctop_user_allocation t1
+                 LEFT JOIN ctop_etl_kuaishou_report_account_daily t2 ON t2.account_id = t1.account_id and t2.stat_date &gt;=#{startTime}
+                 and t2.stat_date &lt;=#{endTime}
+                 LEFT JOIN ctop_project t3 ON t1.project_id = t3.id
+        where t1.auto_delivery != 3
+        <if test="projectIds != null and projectIds.size()>0 ">
+            and t1.project_id in
+            <foreach collection="projectIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+          <if test="userId != null ">
+              and  t3.responsible_id =#{userId}
+        </if>
+    </select>
+
+
+    <select id="checkProjectisOpen" resultType="java.lang.Integer">
+        SELECT COUNT(1) FROM ctop_ai_kuaishou_project_strategy WHERE data_status = 1
+        AND project_id = #{projectId}
+        LIMIT 1
+    </select>
+
+    <select id="getAllEffectStrategy" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouProjectStrategy">
+        SELECT id, project_id from ctop_ai_kuaishou_project_strategy
+        WHERE data_status = 1
+        <if test="unitType != null ">
+          AND (unit_type = #{unitType} OR unit_type = 0)
+        </if>
+        <if test="sourceMaterial != null ">
+          AND LOCATE(#{sourceMaterial},source_material)
+        </if>
+    </select>
+
+    <select id="queryProjectId" resultType="java.lang.Long">
+        SELECT project_id from ctop_ai_kuaishou_project_strategy
+        group by project_id
+    </select>
+
+</mapper>

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountLevelOperationRecord;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 智能投放-账户层级操作记录表
+ *
+ * @author jeecg-boot
+ * 2021-07-11
+ * @version V1.0
+ */
+public interface IAiKuaishouAccountLevelOperationRecordService extends IService<AiKuaishouAccountLevelOperationRecord> {
+
+}

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

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouProjectStrategy;
+
+import java.text.ParseException;
+
+public interface IAiKuaishouProjectCreateCreativeService {
+
+    void customCreativeSupplement(KuaishouProjectStrategy strategy, Integer hour) throws ParseException;
+
+    void projectAutomaticCreates(KuaishouProjectStrategy strategy);
+
+    void projectAutomaticCreates(KuaishouProjectStrategy strategy,Integer operationType);
+    // 组创建是否超限
+    Boolean getUnitOverrun(String keyx);
+
+    void projectProgramAutomaticCreates(KuaishouProjectStrategy strategy,Integer type);
+}

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

@@ -19,7 +19,7 @@ public interface IKuaishouAppPackageService extends IService<KuaishouAppPackage>
 
     Result<Object> importExcel(MultipartFile file, Long projectId, Integer platform, String imageUrl) throws Exception;
 
-    Result<Object> pushAppPackage(Long id, JSONArray accountIds);
+    Result<Object> pushAppPackage(Long id, JSONArray accountIds,JSONObject requestJson);
 
     Result<Object> queryPushResults(String id, JSONArray accountIds, String status);
 
@@ -36,4 +36,10 @@ public interface IKuaishouAppPackageService extends IService<KuaishouAppPackage>
     Result<Object> getAccountByProjectId(Long projectId, String id);
 
     String getDownloadPath(String url);
+
+    Result<Object> getProjectAppList(Long projectId);
+
+    Result<Object> getAppsDetail(List<Long> list);
+
+    JSONObject queryAppId(Long appTemId, Long accountId);
 }

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

@@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
 
+import java.util.List;
+
 /**
  * @Description: 自动投放-定向包详情
  * @Author: jeecg-boot
@@ -22,7 +24,9 @@ public interface IKuaishouDirectionalPackageService extends IService<KuaishouDir
 
     Result<Object> getRelatedAccountGroup(String id, Integer type,Long accountId, Integer pageNo, Integer pageSize);
 
-    Result<Object> pushDirectionalPackage(String id, JSONArray datas);
+    Result<Object> pushDirectionalPackage(String id, JSONArray datas,JSONObject requestJson);
+
+    void createDirectionalPackage2(JSONObject data, JSONObject request);
 
     Result<Object> queryPushResults(String id, JSONArray accountIds,String status);
 
@@ -45,4 +49,10 @@ public interface IKuaishouDirectionalPackageService extends IService<KuaishouDir
     void createUnitAndTemplate(JSONObject request) throws Exception;
 
     Result<Object> queryPopulationById(Long templateId, Long accountId);
+
+    Result<Object> getProjectTarget(Long projectId, String templateName,Integer pageNo, Integer pageSize);
+
+    List<KuaishouDirectionalPackage> getProjectTargetByIds(List<String> list);
+
+    Long selectTemplateId(String id, Long accountId);
 }

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

@@ -0,0 +1,18 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouMaterialPoolOperationRecord;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 物料池操作记录表
+ *
+ * @author jeecg-boot
+ * 2021-07-19
+ * @version V1.0
+ */
+public interface IKuaishouMaterialPoolOperationRecordService extends IService<KuaishouMaterialPoolOperationRecord> {
+
+    void addRecord(JSONObject data, String methodName, Integer materialType, String type);
+
+}

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

@@ -17,7 +17,7 @@ public interface IKuaishouPopulationPackageService extends IService<KuaishouPopu
 
     Result<Object> createEntity(KuaishouPopulationPackage kuaishouPopulationPackage);
 
-    Result<Object> push(JSONArray accountIds, Long id);
+    Result<Object> push(JSONArray accountIds, Long id,JSONObject request);
 
     Result<Object> queryPageList(KuaishouPopulationPackage kuaishouPopulationPackage, Integer pageNo, Integer pageSize);
 

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

@@ -0,0 +1,28 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouProjectStrategy;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+import java.util.List;
+
+/**
+ * 自动投放-项目策略表
+ *
+ * @author jeecg-boot
+ * 2021-06-24
+ * @version V1.0
+ */
+public interface IKuaishouProjectStrategyService extends IService<KuaishouProjectStrategy> {
+
+    Result<Object> queryProjectList(JSONObject data);
+
+    Result<Object> queryAccountList(JSONObject data);
+
+    Result<Object> queryMatchResult(Long projectId,Integer pageNo, Integer pageSize);
+
+    boolean checkProjectisOpen(Long projectId);
+
+    List<KuaishouProjectStrategy> getAllEffectStrategy(int unitType,String sourceMaterial);
+}

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

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaishouAccountLevelOperationRecordMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountLevelOperationRecordService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 智能投放-账户层级操作记录表
+ *
+ * @author jeecg-boot
+ * 2021-07-11
+ * @version V1.0
+ */
+@Service
+public class AiKuaishouAccountLevelOperationRecordServiceImpl extends ServiceImpl<AiKuaishouAccountLevelOperationRecordMapper, AiKuaishouAccountLevelOperationRecord> implements IAiKuaishouAccountLevelOperationRecordService {
+
+}

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1616 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouProjectCreateCreativeServiceImpl.java


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

@@ -13,6 +13,7 @@ import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppGroupMapper;
 import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppPackageMapper;
 import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAppPackageRelMapper;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouMaterialPoolOperationRecordService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
@@ -66,7 +67,8 @@ public class KuaishouAppPackageServiceImpl extends ServiceImpl<KuaishouAppPackag
     private ISysRoleExtService sysRoleService;
     @Autowired
     private KuaishouAppPackageRelMapper relMapper;
-
+    @Autowired
+    private IKuaishouMaterialPoolOperationRecordService kuaishouMaterialPoolOperationRecordService;
     @Autowired
     private KuaishouAppGroupMapper appGroupMapper;
 
@@ -168,6 +170,7 @@ public class KuaishouAppPackageServiceImpl extends ServiceImpl<KuaishouAppPackag
             return Result.error("数据异常,重复的应用标记:" + errVersion.substring(0, errVersion.length() - 1));
         }
         appPackageMapper.replaceBatch(appList);
+        kuaishouMaterialPoolOperationRecordService.addRecord(JSONObject.parseObject(JSONObject.toJSONString(appList)).toJavaObject(JSONObject.class), "/importAppExcel", 3, "add");
         return Result.ok("文件导入成功");
     }
 
@@ -180,6 +183,23 @@ public class KuaishouAppPackageServiceImpl extends ServiceImpl<KuaishouAppPackag
         return LoadFileUtil.downLoadFromUrl(url, path.toString());
     }
 
+    @Override
+    public Result<Object> getProjectAppList(Long projectId) {
+        List<KuaishouAppPackage> list = appPackageMapper.getProjectAppList(projectId);
+        return Result.ok(list);
+    }
+
+    @Override
+    public Result<Object> getAppsDetail(List<Long> ids) {
+        List<JSONObject> list = relMapper.getAppsDetail(ids);
+        return Result.ok(list);
+    }
+
+    @Override
+    public JSONObject queryAppId(Long appTemId, Long accountId) {
+        return relMapper.queryAppId(appTemId, accountId);
+    }
+
     private String getCellValue(Cell cell) {
         String value = "";
         if (cell != null) {
@@ -222,7 +242,7 @@ public class KuaishouAppPackageServiceImpl extends ServiceImpl<KuaishouAppPackag
     }
 
     @Override
-    public Result<Object> pushAppPackage(Long id, JSONArray accountIds) {
+    public Result<Object> pushAppPackage(Long id, JSONArray accountIds, JSONObject object) {
         KuaishouAppPackage appPackage = appPackageMapper.selectById(id);
         if (Check.isNull(appPackage)) {
             return Result.error("未获取到应用信息");
@@ -292,6 +312,10 @@ public class KuaishouAppPackageServiceImpl extends ServiceImpl<KuaishouAppPackag
         if (!list.isEmpty()) {
             relMapper.replaceBatch(list);
         }
+        if (!Check.isNull(object)) {
+            object.put("projectId", appPackage.getProjectId());
+            kuaishouMaterialPoolOperationRecordService.addRecord(object, "/pushAppPackage", 3, "push");
+        }
         return Result.ok("推送完成");
     }
 
@@ -355,6 +379,7 @@ public class KuaishouAppPackageServiceImpl extends ServiceImpl<KuaishouAppPackag
             }
         }
         PageHelper.startPage(pageNo, pageSize);
+
         List<JSONObject> list = appPackageMapper.queryPageList(userId, kuaishouAppPackage.getAppName(), kuaishouAppPackage.getAppVersion(), kuaishouAppPackage.getProjectId(), kuaishouAppPackage.getPlatform());
         for (JSONObject object : list) {
             object.put("unitCount", appPackageMapper.queryUnitCount(object.getLong("id")));

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

@@ -13,6 +13,7 @@ import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouDirectionalPackageMapper;
 import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouDirectionalPckageRelMapper;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPckageRelService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouMaterialPoolOperationRecordService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
@@ -74,6 +75,8 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
     @Autowired
     private IKuaiShouGroupTemplateService groupTemplateService;
     static ExecutorService executorService = null;
+    @Autowired
+    private IKuaishouMaterialPoolOperationRecordService kuaishouMaterialPoolOperationRecordService;
 
     @Override
     public Result<Object> createDirectionalPackage(JSONObject requestJson) {
@@ -374,20 +377,26 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
     }
 
     @Override
-    public Result<Object> pushDirectionalPackage(String id, JSONArray datas) {
+    public Result<Object> pushDirectionalPackage(String id, JSONArray datas, JSONObject requestJson) {
         KuaishouDirectionalPackage directionalPackage = packageMapper.selectById(id);
+        if (Check.isNull(directionalPackage)) {
+            return Result.error("未获取到定向信息");
+        }
+        requestJson.put("projectId", directionalPackage.getProjectId());
         JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(directionalPackage)).toJavaObject(JSONObject.class);
         if (Check.isNull(data)) {
             return Result.error("未找到定向包");
         }
         for (int i = 0; i < datas.size(); i++) {
             JSONObject request = datas.getJSONObject(i);
-            createDirectionalPackage(data, request);
+            createDirectionalPackage2(data, request);
         }
+        kuaishouMaterialPoolOperationRecordService.addRecord(requestJson, "/pushDirectionalPackage", 1, "push");
         return Result.ok("推送完成");
     }
 
-    private void createDirectionalPackage(JSONObject data, JSONObject request) {
+    @Override
+    public void createDirectionalPackage2(JSONObject data, JSONObject request) {
         Long accountId = request.getLong("accountId");
         CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
         String message = "";
@@ -675,4 +684,21 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
         return Result.ok(data);
     }
 
+    @Override
+    public Result<Object> getProjectTarget(Long projectId, String templateName, Integer pageNo, Integer pageSize) {
+        PageHelper.startPage(pageNo, pageSize);
+        List<KuaishouDirectionalPackage> list = packageMapper.queryListByProjectId(projectId, templateName);
+        return Result.ok(new PageInfo(list));
+    }
+
+    @Override
+    public List<KuaishouDirectionalPackage> getProjectTargetByIds(List<String> ids) {
+        return packageMapper.getProjectTargetByIds(ids);
+    }
+
+    @Override
+    public Long selectTemplateId(String id, Long accountId) {
+        return relMapper.selectTemplateId(id, accountId);
+    }
+
 }

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

@@ -0,0 +1,68 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouMaterialPoolOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouMaterialPoolOperationRecordMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouMaterialPoolOperationRecordService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 物料池操作记录表
+ *
+ * @author jeecg-boot
+ * 2021-07-19
+ * @version V1.0
+ */
+@Slf4j
+@Service
+public class KuaishouMaterialPoolOperationRecordServiceImpl extends ServiceImpl<KuaishouMaterialPoolOperationRecordMapper, KuaishouMaterialPoolOperationRecord> implements IKuaishouMaterialPoolOperationRecordService {
+
+    @Autowired
+    private KuaishouMaterialPoolOperationRecordMapper operationRecordMapper;
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(3);
+
+    @Override
+    public void addRecord(JSONObject data, String methodName, Integer materialType, String type) {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            insertInfo(data, methodName, materialType, type);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+                log.info("添加物料池操作记录完成");
+            }
+        };
+        thread.start();
+    }
+
+    private void insertInfo(JSONObject data, String methodName, Integer materialType, String type) {
+        KuaishouMaterialPoolOperationRecord record = new KuaishouMaterialPoolOperationRecord();
+        record.setData(JSONObject.toJSONString(data));
+        record.setMethod_name(methodName);
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        if (!Check.isNull(user)) {
+            record.setUserId(user.getId());
+        }
+        record.setProjectId(data.getLong("projectId"));
+        record.setMaterialType(materialType);
+        record.setType(type);
+        operationRecordMapper.insert(record);
+    }
+}

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

@@ -10,6 +10,7 @@ import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackage;
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel;
 import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageMapper;
 import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouMaterialPoolOperationRecordService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationGroupService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageRelService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageService;
@@ -61,6 +62,8 @@ public class KuaishouPopulationPackageServiceImpl extends ServiceImpl<KuaishouPo
     private IKuaishouPopulationGroupService populationGroupService;
     @Autowired
     private ISysRoleExtService sysRoleService;
+    @Autowired
+    private IKuaishouMaterialPoolOperationRecordService kuaishouMaterialPoolOperationRecordService;
 
     @Value("${zip.local.download-path}")
     private String downloadPath;
@@ -119,7 +122,7 @@ public class KuaishouPopulationPackageServiceImpl extends ServiceImpl<KuaishouPo
     }
 
     @Override
-    public Result<Object> push(JSONArray accountIds, Long id) {
+    public Result<Object> push(JSONArray accountIds, Long id, JSONObject request) {
         KuaishouPopulationPackage pPackage = kuaishouPopulationPackageMapper.selectById(id);
         if (Check.isNull(pPackage)) {
             return Result.error("没有获取到人群包");
@@ -128,6 +131,7 @@ public class KuaishouPopulationPackageServiceImpl extends ServiceImpl<KuaishouPo
         if (Check.isNull(newFileUrl)) {
             return Result.error("本地下载文件失败,路径:" + pPackage.getUrl());
         }
+        request.put("projectId",pPackage.getProjectId());
         for (Object account : accountIds) {
             Long accountId = Long.valueOf(String.valueOf(account));
             KuaishouPopulationPackageRel relEntity = relMapper.queryEntity(accountId, pPackage.getId());
@@ -144,6 +148,7 @@ public class KuaishouPopulationPackageServiceImpl extends ServiceImpl<KuaishouPo
                 }
             }
         }
+        kuaishouMaterialPoolOperationRecordService.addRecord(request, "/kuaishouPopulationPackage/push", 2, "push");
         LoadFileUtil.delFile(newFileUrl);
         return Result.ok("推送结束");
     }

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

@@ -0,0 +1,92 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouProjectStrategy;
+import cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaishouAccountLevelOperationRecordMapper;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouProjectStrategyMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouProjectStrategyService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 自动投放-项目策略表
+ *
+ * @author jeecg-boot
+ * 2021-06-24
+ * @version V1.0
+ */
+@Service
+public class KuaishouProjectStrategyServiceImpl extends ServiceImpl<KuaishouProjectStrategyMapper, KuaishouProjectStrategy> implements IKuaishouProjectStrategyService {
+
+    @Autowired
+    private KuaishouProjectStrategyMapper kuaishouProjectStrategyMapper;
+
+    @Autowired
+    private AiKuaishouAccountLevelOperationRecordMapper kuaishouAccountLevelOperationRecordMapper;
+
+    @Override
+    public Result<Object> queryProjectList(JSONObject data) {
+        List<Long> projectIds = new ArrayList<>();
+        if (Check.isNull(data.getLong("projectId"))) {
+            projectIds = kuaishouProjectStrategyMapper.queryProjectId();
+        } else {
+            projectIds.add(data.getLong("projectId"));
+        }
+        data.put("projectIds", projectIds);
+        JSONObject result = new JSONObject();
+        JSONObject allInfo = kuaishouProjectStrategyMapper.queryProjectAll(data);
+        Integer pageNo = Check.isNull(data.getInteger("pageNo")) ? 1 : data.getInteger("pageNo");
+        Integer pageSize = Check.isNull(data.getInteger("pageSize")) ? 10 : data.getInteger("pageSize");
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> list = kuaishouProjectStrategyMapper.queryProjectList(data);
+        result.put("total", allInfo);
+        result.put("pageInfo", new PageInfo<>(list));
+        return Result.ok(result);
+    }
+
+    @Override
+    public Result<Object> queryAccountList(JSONObject data) {
+        List<Long> projectIds = new ArrayList<>();
+        if (Check.isNull(data.getLong("projectId"))) {
+            projectIds = kuaishouProjectStrategyMapper.queryProjectId();
+        } else {
+            projectIds.add(data.getLong("projectId"));
+        }
+        data.put("projectIds", projectIds);
+        JSONObject result = new JSONObject();
+        JSONObject allInfo = kuaishouProjectStrategyMapper.queryAccountAll(data);
+        Integer pageNo = Check.isNull(data.getInteger("pageNo")) ? 1 : data.getInteger("pageNo");
+        Integer pageSize = Check.isNull(data.getInteger("pageSize")) ? 10 : data.getInteger("pageSize");
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> list = kuaishouProjectStrategyMapper.queryAccountList(data);
+        result.put("total", allInfo);
+        result.put("pageInfo", new PageInfo<>(list));
+        return Result.ok(result);
+    }
+
+    @Override
+    public Result<Object> queryMatchResult(Long projectId, Integer pageNo, Integer pageSize) {
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> list = kuaishouAccountLevelOperationRecordMapper.queryMatchResult(projectId);
+        return Result.ok(new PageInfo<>(list));
+    }
+
+    @Override
+    public boolean checkProjectisOpen(Long projectId) {
+        Integer num = kuaishouProjectStrategyMapper.checkProjectisOpen(projectId);
+        return num <= 0;
+    }
+
+    @Override
+    public List<KuaishouProjectStrategy> getAllEffectStrategy(int unitType, String sourceMaterial) {
+        return kuaishouProjectStrategyMapper.getAllEffectStrategy(unitType, sourceMaterial);
+    }
+}

+ 15 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -44,13 +45,24 @@ public class KuaiShouVideoGet {
     private Integer materialType;
     private Integer channelType;
     private Integer status;
-    /**素造素材标签*/
+    /**
+     * 素造素材标签
+     */
     private String materialTag;
-    /**素造供应商id*/
+    /**
+     * 素造供应商id
+     */
     private Long supplierAccountId;
-    /**供应商名称*/
+    /**
+     * 供应商名称
+     */
     private String supplierAccountName;
 
+    @TableField(exist = false)
+    private String putStartTime;
+    @TableField(exist = false)
+    private String putEndTime;
+
     /**
      * 创建时间
      */

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProjectVideoGet;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -27,10 +28,15 @@ public interface KuaishouProjectVideoGetMapper extends BaseMapper<KuaishouProjec
 
     JSONObject getVideoTotalNumber(Map<String, Object> paramsMap);
 
-    JSONObject getVideoDetails(@Param("signature") String signature,@Param("id") String id);
+    JSONObject getVideoDetails(@Param("signature") String signature, @Param("id") String id);
 
     Long getAccountVideosTotal(@Param("signature") String signature, @Param("projectId") Long projectId);
 
     List<JSONObject> getAccountVideos(@Param("signature") String signature, @Param("projectId") Long projectId);
 
+    List<KuaiShouVideoGet> getNewVideoBetweenTime(@Param("accountId") Long accountId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("channelType") Integer channelType);
+
+    List<KuaiShouVideoGet> getZeroVideoByParams(@Param("accountId") Long accountId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("videoCnt") Long videoCnt, @Param("appVersion") String appVersion, @Param("channelType") Integer channelType, @Param("relativeCnt") Integer relativeCnt);
+
+    List<KuaiShouVideoGet> getHistoryTopVideoByParams(@Param("accountId") Long accountId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("videoCnt") Long videoCnt, @Param("appVersion") String appVersion, @Param("channelType") Integer channelType);
 }

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

@@ -18,4 +18,6 @@ public interface KuaishouTemplateTargetMapper extends BaseMapper<KuaishouTemplat
     void templateTargetList(@Param("templateTargetList") List<KuaishouTemplateTarget> templateTargetList);
 
     KuaishouTemplateTarget queryTemplateTarget(@Param("templateId") Long templateId, @Param("accountId")Long accountId);
+
+    List<KuaishouTemplateTarget> queryTemplateTargetByIds(@Param("templateIds") List<Long> templateIds);
 }

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

@@ -94,7 +94,7 @@
 
     <select id="selectPhotoIdsByAccountId" parameterType="java.lang.Long"
             resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
-        select *
+        select photo_id,stat_date,channel_type
         from ctop_kuaishou_video_get
         where account_id = #{accountId}
           and status = 0

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

@@ -202,12 +202,14 @@
                IFNULL(ROUND(SUM(t1.charge) / SUM(t1.aclick) * 1000, 2), 0) 'impression1kCost',
                IFNULL(ROUND(SUM(t1.charge) / SUM(t1.photo_click), 2), 0) 'photoClickCost',
                IFNULL(ROUND(SUM(t1.charge) / SUM(t1.bclick), 2), 0) 'actionCost'
-        FROM  ctop_kuaishou_video_get t0
-                  LEFT JOIN ctop_kuaishou_report_daily_material t1 ON t0.account_id = t1.account_id
-                  LEFT JOIN ctop_user_allocation t2 ON t0.account_id = t2.account_id
-                  LEFT JOIN (
-            SELECT IFNULL(COUNT(1),0) 'rejectCount',account_id FROM ctop_kuaishou_creative WHERE `status` = 42
-            and account_id IN (SELECT account_id FROM ctop_user_allocation where project_id = #{projectId})
+        FROM ctop_kuaishou_video_get t0
+                 LEFT JOIN ctop_kuaishou_report_daily_material t1 ON t0.account_id = t1.account_id
+                 LEFT JOIN ctop_user_allocation t2 ON t0.account_id = t2.account_id
+                 LEFT JOIN (
+            SELECT IFNULL(COUNT(1), 0) 'rejectCount',account_id
+            FROM ctop_kuaishou_creative
+            WHERE `status` = 42
+              and account_id IN (SELECT account_id FROM ctop_user_allocation where project_id = #{projectId})
             GROUP BY account_id
         ) t3 ON t0.account_id = t3.account_id
         WHERE t2.project_id = #{projectId}
@@ -215,4 +217,116 @@
         GROUP BY t0.account_id
     </select>
 
+    <select id="getNewVideoBetweenTime" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
+        select t2.*,t1.put_end_time,t1.put_start_time
+        from ctop_kuaishou_project_video_get t1
+                 INNER JOIN
+             (
+                 SELECT tt1.*, tt2.project_id
+                 FROM ctop_user_allocation tt2
+                 LEFT JOIN ctop_kuaishou_video_get tt1 ON tt2.account_id = tt1.account_id
+                 WHERE tt2.account_id = #{accountId}
+                 and tt1.signature is not null
+                 group by tt1.signature
+             ) t2 ON t1.project_id = t2.project_id AND t1.signature = t2.signature
+        WHERE t1.status = 0
+        <if test="startTime!=null">
+            AND t1.stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime!=null">
+            and t1.stat_date &lt;= #{endTime}
+        </if>
+        <if test="channelType!=null">
+            AND t1.channel_type = #{channelType}
+        </if>
+    </select>
+
+    <select id="getZeroVideoByParams" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
+        select t1.* from (
+        select t2.*,t1.put_end_time,t1.put_start_time
+        from ctop_kuaishou_project_video_get t1
+        INNER JOIN
+        (
+        SELECT tt1.*, tt2.project_id
+        FROM ctop_user_allocation tt2
+        LEFT JOIN ctop_kuaishou_video_get tt1 ON tt2.account_id = tt1.account_id
+        WHERE tt2.account_id = #{accountId}
+        and tt1.signature is not null
+        <if test="appVersion != null and appVersion != '' ">
+            and tt1.photo_name like concat(#{appVersion},'%')
+        </if>
+        group by tt1.signature
+        ) t2 ON t1.project_id = t2.project_id AND t1.signature = t2.signature
+        WHERE t1.status = 0
+        <if test="startTime!=null">
+            AND t1.stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime!=null">
+            and t1.stat_date &lt;= #{endTime}
+        </if>
+        <if test="channelType!=null">
+            AND t1.channel_type = #{channelType}
+        </if>
+        ) t1
+        left join ctop_kuaishou_video_relate_creatives t2 on t1.photo_id =
+        t2.photo_id and t1.account_id = t2.account_id
+        where
+        1=1
+        <if test="relativeCnt!=null">
+            and t2.creative_count &lt;= #{relativeCnt}
+        </if>
+        order by t1.stat_date desc
+        <if test="videoCnt!=null">
+            limit #{videoCnt}
+        </if>
+    </select>
+
+    <select id="getHistoryTopVideoByParams"
+            resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
+        select
+        t2.*
+        from
+        ctop_kuaishou_report_daily_material t1
+        left join (
+        select t2.*,t1.put_end_time,t1.put_start_time
+        from ctop_kuaishou_project_video_get t1
+        INNER JOIN
+        (
+        SELECT tt1.*, tt2.project_id
+        FROM ctop_user_allocation tt2
+        LEFT JOIN ctop_kuaishou_video_get tt1 ON tt2.account_id = tt1.account_id
+        WHERE tt2.account_id = #{accountId}
+        and tt1.signature is not null
+        <if test="appVersion != null and appVersion != '' ">
+            and tt1.photo_name like concat(#{appVersion},'%')
+        </if>
+        group by tt1.signature
+        ) t2 ON t1.project_id = t2.project_id AND t1.signature = t2.signature
+        WHERE t1.status = 0
+        <if test="startTime!=null">
+            AND t1.stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime!=null">
+            and t1.stat_date &lt;= #{endTime}
+        </if>
+        <if test="channelType!=null">
+            AND t1.channel_type = #{channelType}
+        </if>
+        ) t2
+        on t1.signature = t2.signature
+        where t2.id is not null
+        and t2.photo_id NOT IN (
+        SELECT
+        photo_id
+        FROM
+        ctop_ai_creative_limit
+        WHERE
+        account_id = #{accountId}
+        )
+        group by t2.signature
+        order by sum(t1.charge) desc
+        <if test="videoCnt!=null">
+            limit #{videoCnt}
+        </if>
+    </select>
 </mapper>

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

@@ -96,5 +96,16 @@
           AND t2.account_id = #{accountId}
     </select>
 
+    <select id="queryTemplateTargetByIds" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget">
+        SELECT *
+        FROM ctop_kuaishou_template_target t1
+        WHERE t1.template_id in
+        <foreach collection="templateIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+
+    </select>
+
 
 </mapper>

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProjectVideoGet;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
@@ -30,4 +31,10 @@ public interface IKuaishouProjectVideoGetService extends IService<KuaishouProjec
     Result<Object> queryCreativeBySignature(List<String> photoIds, Long accountId, Integer pageNo, Integer pageSize);
 
     void deleteCreativesByPhotoId(Object photoId);
+
+    List<KuaiShouVideoGet> getNewVideoBetweenTime(Long accountId, String startTime, String endTime, Integer channelType);
+
+    List<KuaiShouVideoGet> getZeroVideoByParams(Long accountId, String startTime, String endTime, Long videoCnt, String appVersion, Integer channelType, Integer relativeCnt);
+
+    List<KuaiShouVideoGet> getHistoryTopVideoByParams(Long accountId, String startTime, String endTime, Long videoCnt, String appVersion, Integer channelType);
 }

+ 79 - 23
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -8,18 +8,67 @@ import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
 import cn.com.ctop.common.module.service.IOauthConfigService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
-import cn.com.ctop.common.module.utils.*;
-import cn.com.ctop.kuaishou.modules.ai.service.*;
-import cn.com.ctop.kuaishou.modules.batch.entity.*;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.JsonUtil;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiCreativeLimitService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountCreativeOverrunInfoService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationGroupService;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAdvertiserBaseInfo;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouDailyFlows;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListChildren;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListParent;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouTargetingTags;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouPopulation;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
-import cn.com.ctop.kuaishou.modules.batch.mapper.*;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAdvertiserBaseInfoMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAppListMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListChildrenMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListParentMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouTargetingTagsMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyFlowsService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouOverRunSendMessageService;
+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.IKuaishouPopulationService;
+import cn.com.ctop.kuaishou.modules.batch.service.IWarningOperationService;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
-import cn.com.ctop.kuaishou.modules.report.entity.*;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCampaign;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreative;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreativeStatistic;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyAccount;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCampaign;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreative;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreativeStatistic;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyGroup;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
-import cn.com.ctop.kuaishou.modules.report.service.*;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCampaignService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCreativeService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyAccountService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCampaignService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCreativeService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyGroupService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -54,7 +103,11 @@ import java.io.IOException;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -130,6 +183,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     private IKuaishouAppPackageService appPackageService;
     @Autowired
     private UserAllocationMapper allocationMapper;
+
     @Override
     public void getAdvertiserReportHourly(CtopOauthToken token, Date startDate, Date endDate) {
         try {
@@ -268,8 +322,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             if (!Check.isNull(videoGetList)) {
                 videoGetService.replaceBatch(videoGetList);
             }
-
-            getVideoListByPage(token, startDate, endDate, page + 1);
+            Integer total_count = resultJson.getJSONObject("data").getInteger("total_count");
+            if (!Check.isNull(total_count) && total_count == 500) {
+                getVideoListByPage(token, startDate, endDate, page + 1);
+            }
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -781,26 +837,26 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     @Override
     public void loadKuaishouDataSingle(CtopOauthToken token) throws java.text.ParseException {
         String beginDateStr = allocationMapper.getUserAllocation(token.getAccountId()).getAuthBeginTime();
-        beginDateStr = Check.isNull(beginDateStr) ? DateUtils.formatDate(DateUtils.addDay(new Date(),-180),"yyyy-MM-dd") : beginDateStr;
-        Date beginDate = DateUtils.parseDate(beginDateStr,DateUtils.WEB_FORMAT);
-        Date endDate = DateUtils.addDay(new Date(),-1);
-        while (!beginDate.after(endDate)){
-            beginDate = DateUtils.addDay(beginDate,1);
+        beginDateStr = Check.isNull(beginDateStr) ? DateUtils.formatDate(DateUtils.addDay(new Date(), -180), "yyyy-MM-dd") : beginDateStr;
+        Date beginDate = DateUtils.parseDate(beginDateStr, DateUtils.WEB_FORMAT);
+        Date endDate = DateUtils.addDay(new Date(), -1);
+        while (!beginDate.after(endDate)) {
+            beginDate = DateUtils.addDay(beginDate, 1);
             getAdvertiserReportHourly(token, beginDate, beginDate);
             getAdvertiserReportDaily(token, beginDate, beginDate, null);
         }
 //        Date endDate = new Date();
 //        for (int i = 0; i < 7; i++) {
 //            Date getStartDate = DateUtils.addDay(endDate, -i);
-            //1: 获取广告主信息数据
+        //1: 获取广告主信息数据
 //            getAdvertiserReportHourly(token, beginDate, endDate);
 //            getAdvertiserReportDaily(token, beginDate, endDate, null);
-            //2:获取广告计划信息数据
-            //getAdvertiserCampaignReportHourly(token, getStartDate, getStartDate);
-            //3:获取广告组信息数据
-            // getAdvertiserGroupReportHourly(token, getStartDate, getStartDate);
-            //4: 获取广告创意信息数据
-            // getAdvertiserCreativeReportHourly(token, getStartDate, getStartDate);
+        //2:获取广告计划信息数据
+        //getAdvertiserCampaignReportHourly(token, getStartDate, getStartDate);
+        //3:获取广告组信息数据
+        // getAdvertiserGroupReportHourly(token, getStartDate, getStartDate);
+        //4: 获取广告创意信息数据
+        // getAdvertiserCreativeReportHourly(token, getStartDate, getStartDate);
 //        }
         //获取全量广告计划数据
         getCampaignList(token, null, null);
@@ -810,7 +866,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         getCreativeList(token, null, null);
         getAppList(token.getAccountId(), token.getAccessToken());
         log.info("----------------开始历史数据获取,accountId:{}", token.getAccountId());
-        String endDateStr = DateUtils.formatDate(endDate,"yyyy-MM-dd");
+        String endDateStr = DateUtils.formatDate(endDate, "yyyy-MM-dd");
 //        String startDate = DateUtils.addMonth(endDateStr, -1);
         historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), beginDateStr, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
         getVideoList(token, null, null);

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

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.batch.service.impl;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProjectVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouVideoGetMapper;
@@ -158,4 +159,19 @@ public class KuaishouProjectVideoGetServiceImpl extends ServiceImpl<KuaishouProj
             }
         }
     }
+
+    @Override
+    public List<KuaiShouVideoGet> getNewVideoBetweenTime(Long accountId, String startTime, String endTime, Integer channelType) {
+        return projectVideoGetMapper.getNewVideoBetweenTime(accountId, startTime, endTime, channelType);
+    }
+
+    @Override
+    public List<KuaiShouVideoGet> getZeroVideoByParams(Long accountId, String startTime, String endTime, Long videoCnt, String appVersion, Integer channelType, Integer relativeCnt) {
+        return projectVideoGetMapper.getZeroVideoByParams(accountId, startTime, endTime, videoCnt, appVersion, channelType, relativeCnt);
+    }
+
+    @Override
+    public List<KuaiShouVideoGet> getHistoryTopVideoByParams(Long accountId, String startTime, String endTime, Long videoCnt, String appVersion, Integer channelType) {
+        return projectVideoGetMapper.getHistoryTopVideoByParams(accountId, startTime, endTime, videoCnt, appVersion, channelType);
+    }
 }

+ 12 - 10
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouVideoRelateCreativesServiceImpl.java

@@ -136,7 +136,7 @@ public class KuaishouVideoRelateCreativesServiceImpl extends ServiceImpl<Kuaisho
                             kuaishouVideoRelateCreativesMapper.insertBatch(videolist);
                         }
                     } else {
-                        log.info("频库-视频关联创意数查询失败,accountId:{},返回信息:{}", accountId, resultJson);
+                        log.info("频库-视频关联创意数查询失败,入参:{},返回结果:{}", params, resultJson);
                     }
                 }
             }
@@ -151,17 +151,17 @@ public class KuaishouVideoRelateCreativesServiceImpl extends ServiceImpl<Kuaisho
     }
 
     @Override
-    public List<KuaishouVideoRelateCreatives> listByParams(Long accountId,Integer matNum) {
+    public List<KuaishouVideoRelateCreatives> listByParams(Long accountId, Integer matNum) {
         QueryWrapper<KuaishouVideoRelateCreatives> queryWrapper = new QueryWrapper<>();
-        if(null!=accountId&&accountId!=0){
-            queryWrapper.eq("account_id",accountId);
+        if (null != accountId && accountId != 0) {
+            queryWrapper.eq("account_id", accountId);
         }
-        if(null == matNum||matNum == 0){
+        if (null == matNum || matNum == 0) {
             matNum = 10;
         }
-        queryWrapper.le("creative_count",30);
+        queryWrapper.le("creative_count", 30);
         queryWrapper.orderByDesc("stat_date");
-        queryWrapper.last("limit "+matNum);
+        queryWrapper.last("limit " + matNum);
         return this.list(queryWrapper);
     }
 
@@ -188,18 +188,20 @@ public class KuaishouVideoRelateCreativesServiceImpl extends ServiceImpl<Kuaisho
             int count = 0;
             for (KuaiShouVideoGet video : KuaiShouVideoGets) {
                 count++;
-                if (count < 20) {
+                if (count < 19) {
                     photoIds.add(video.getPhotoId());
                     statdateMap.put(video.getPhotoId(), video);
                 } else {
                     photoIds.add(video.getPhotoId());
-                    statdateMap.put(video.getPhotoId(),video);
+                    statdateMap.put(video.getPhotoId(), video);
                     dateList.add(photoIds);
                     photoIds = new JSONArray();
                     count = 0;
                 }
             }
-            dateList.add(photoIds);
+            if (photoIds.size() > 0) {
+                dateList.add(photoIds);
+            }
             this.videoRelateCreatives(accountId, dateList, statdateMap);
         }
     }

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

@@ -16,8 +16,6 @@
         t1.material_name AS materialName,
         t1.project_name AS projectName,
         t1.material_create_time AS createTime,
-        sum (t1.material_show) as showMaterial,
-        sum (t1.click) as clickMaterial,
         ${filed}
         FROM
         etl_report_bytedance_video t1