Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/test' into test

jiequan.bi 4 gadi atpakaļ
vecāks
revīzija
cb6a92877d
67 mainītis faili ar 2678 papildinājumiem un 231 dzēšanām
  1. 19 19
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  3. 18 18
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BytedanceVideoEtlInfoController.java
  4. 15 15
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/KuaishouVideoEtlInfoController.java
  5. 46 19
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  6. 4 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  7. 42 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/AlarmEventSendController.java
  8. 1 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/AlarmEventSend.java
  9. 1 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java
  10. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialCutFrameService.java
  11. 10 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialCutFrameServiceImpl.java
  12. 9 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  13. 24 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceEtlVideoJob.java
  14. 12 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAiAdsNewMaterialCreativityJob.java
  15. 0 25
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCampaignCopyDateJob.java
  16. 3 3
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAudienceReportJob.java
  17. 24 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEtlVideoJob.java
  18. 104 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouVideoRelateCreativesJob.java
  19. 135 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouCreateController.java
  20. 245 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouMaterialControer.java
  21. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountTargetTemplate.java
  22. 56 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaiShouVideoLastTime.java
  23. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaiShouVideoLastTimeMapper.java
  24. 12 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaiShouVideoLastTimeMapper.xml
  25. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouNewCreateCampaign.java
  26. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaiShouCreateService.java
  27. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaiShouVideoLastTimeService.java
  28. 93 12
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouNewCreateCampaignServiceImpl.java
  29. 6 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiStrategyServiceImpl.java
  30. 421 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java
  31. 28 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouVideoLastTimeServiceImpl.java
  32. 262 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouVideoRelateCreativesController.java
  33. 72 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouVideoRelateCreatives.java
  34. 2 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouReportDailyMaterialMapper.java
  35. 3 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouVideoGetMapper.java
  36. 23 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouVideoRelateCreativesMapper.java
  37. 38 20
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml
  38. 28 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml
  39. 52 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouVideoRelateCreativesMapper.xml
  40. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCampaignService.java
  41. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupService.java
  42. 3 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouReportDailyMaterialService.java
  43. 4 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java
  44. 25 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouVideoRelateCreativesService.java
  45. 11 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCampaignServiceImpl.java
  46. 11 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  47. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTemplateServiceImpl.java
  48. 7 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java
  49. 38 20
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java
  50. 13 39
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  51. 148 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouVideoRelateCreativesServiceImpl.java
  52. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaiShouReportDailyMaterial.java
  53. 83 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouProjectVideoEtlInfo.java
  54. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouProjectVideoEtlInfoMapper.java
  55. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouProjectVideoEtlInfoMapper.xml
  56. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouProjectVideoEtlInfoService.java
  57. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouVideoEtlInfoService.java
  58. 31 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouProjectVideoEtlInfoServiceImpl.java
  59. 115 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouVideoEtlInfoServiceImpl.java
  60. 16 12
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouPlanServiceImpl.java
  61. 76 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/BytedanceProjectVideoEtlInfo.java
  62. 14 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceProjectVideoEtlInfoMapper.java
  63. 5 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceProjectVideoEtlInfoMapper.xml
  64. 14 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceProjectVideoEtlInfoService.java
  65. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceVideoEtlInfoService.java
  66. 18 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceProjectVideoEtlInfoServiceImpl.java
  67. 132 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceVideoEtlInfoServiceImpl.java

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

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

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

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

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

@@ -69,28 +69,28 @@ public class BytedanceVideoEtlInfoController {
 			if(type.trim().equals("valid")){
 				//有效
 				if(null!=startDate&&!"".equals(startDate.trim())){
-					queryWrapper.gt("effect_date",startDate);
+					queryWrapper.ge("effect_date",startDate);
 				}
 				if(null!=endDate&&!"".equals(endDate.trim())){
-					queryWrapper.lt("effect_date",endDate);
+					queryWrapper.le("effect_date",endDate);
 				}
-				queryWrapper.lt("effect_day_num",7);
+				queryWrapper.le("effect_day_num",7);
 			}else if(type.trim().equals("hot")){
 				//爆款
-				if(null!=startDate&&!"faddish_date".equals(startDate.trim())){
-					queryWrapper.gt("",startDate);
+				if(null!=startDate&&!"".equals(startDate.trim())){
+					queryWrapper.ge("faddish_date",startDate);
 				}
 				if(null!=endDate&&!"".equals(endDate.trim())){
-					queryWrapper.lt("faddish_date",endDate);
+					queryWrapper.le("faddish_date",endDate);
 				}
-				queryWrapper.lt("faddish_day_num",30);
+				queryWrapper.le("faddish_day_num",30);
 			}else {
 				//上线
 				if(null!=startDate&&!"".equals(startDate.trim())){
-					queryWrapper.gt("state_date",startDate);
+					queryWrapper.ge("state_date",startDate);
 				}
 				if(null!=endDate&&!"".equals(endDate.trim())){
-					queryWrapper.lt("state_date",endDate);
+					queryWrapper.le("state_date",endDate);
 				}
 			}
 		}
@@ -181,28 +181,28 @@ public class BytedanceVideoEtlInfoController {
 		  if(type.trim().equals("valid")){
 			  //有效
 			  if(null!=startDate&&!"".equals(startDate.trim())){
-				  queryWrapper.gt("effect_date",startDate);
+				  queryWrapper.ge("effect_date",startDate);
 			  }
 			  if(null!=endDate&&!"".equals(endDate.trim())){
-				  queryWrapper.lt("effect_date",endDate);
+				  queryWrapper.le("effect_date",endDate);
 			  }
-			  queryWrapper.lt("effect_day_num",7);
+			  queryWrapper.le("effect_day_num",7);
 		  }else if(type.trim().equals("hot")){
 			  //爆款
-			  if(null!=startDate&&!"faddish_date".equals(startDate.trim())){
-				  queryWrapper.gt("",startDate);
+			  if(null!=startDate&&!"".equals(startDate.trim())){
+				  queryWrapper.ge("faddish_date",startDate);
 			  }
 			  if(null!=endDate&&!"".equals(endDate.trim())){
-				  queryWrapper.lt("faddish_date",endDate);
+				  queryWrapper.le("faddish_date",endDate);
 			  }
-			  queryWrapper.lt("faddish_day_num",30);
+			  queryWrapper.le("faddish_day_num",30);
 		  }else {
 			  //上线
 			  if(null!=startDate&&!"".equals(startDate.trim())){
-				  queryWrapper.gt("state_date",startDate);
+				  queryWrapper.ge("state_date",startDate);
 			  }
 			  if(null!=endDate&&!"".equals(endDate.trim())){
-				  queryWrapper.lt("state_date",endDate);
+				  queryWrapper.le("state_date",endDate);
 			  }
 		  }
 	  }

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

@@ -66,28 +66,28 @@ public class KuaishouVideoEtlInfoController {
 			if(type.trim().equals("valid")){
 				//有效
 				if(null!=startDate&&!"".equals(startDate.trim())){
-					queryWrapper.gt("effect_date",startDate);
+					queryWrapper.ge("effect_date",startDate);
 				}
 				if(null!=endDate&&!"".equals(endDate.trim())){
-					queryWrapper.lt("effect_date",endDate);
+					queryWrapper.le("effect_date",endDate);
 				}
 				queryWrapper.lt("effect_day_num",7);
 			}else if(type.trim().equals("hot")){
 				//爆款
-				if(null!=startDate&&!"faddish_date".equals(startDate.trim())){
-					queryWrapper.gt("",startDate);
+				if(null!=startDate&&!"".equals(startDate.trim())){
+					queryWrapper.ge("faddish_date",startDate);
 				}
 				if(null!=endDate&&!"".equals(endDate.trim())){
-					queryWrapper.lt("faddish_date",endDate);
+					queryWrapper.le("faddish_date",endDate);
 				}
-				queryWrapper.lt("faddish_day_num",30);
+				queryWrapper.le("faddish_day_num",30);
 			}else {
 				//上线
 				if(null!=startDate&&!"".equals(startDate.trim())){
-					queryWrapper.gt("state_date",startDate);
+					queryWrapper.ge("state_date",startDate);
 				}
 				if(null!=endDate&&!"".equals(endDate.trim())){
-					queryWrapper.lt("state_date",endDate);
+					queryWrapper.le("state_date",endDate);
 				}
 			}
 		}
@@ -178,28 +178,28 @@ public class KuaishouVideoEtlInfoController {
 		  if(type.trim().equals("valid")){
 			  //有效
 			  if(null!=startDate&&!"".equals(startDate.trim())){
-				  queryWrapper.gt("effect_date",startDate);
+				  queryWrapper.ge("effect_date",startDate);
 			  }
 			  if(null!=endDate&&!"".equals(endDate.trim())){
-				  queryWrapper.lt("effect_date",endDate);
+				  queryWrapper.le("effect_date",endDate);
 			  }
 			  queryWrapper.lt("effect_day_num",7);
 		  }else if(type.trim().equals("hot")){
 			  //爆款
-			  if(null!=startDate&&!"faddish_date".equals(startDate.trim())){
-				  queryWrapper.gt("",startDate);
+			  if(null!=startDate&&!"".equals(startDate.trim())){
+				  queryWrapper.ge("faddish_date",startDate);
 			  }
 			  if(null!=endDate&&!"".equals(endDate.trim())){
-				  queryWrapper.lt("faddish_date",endDate);
+				  queryWrapper.le("faddish_date",endDate);
 			  }
 			  queryWrapper.lt("faddish_day_num",30);
 		  }else {
 			  //上线
 			  if(null!=startDate&&!"".equals(startDate.trim())){
-				  queryWrapper.gt("state_date",startDate);
+				  queryWrapper.ge("state_date",startDate);
 			  }
 			  if(null!=endDate&&!"".equals(endDate.trim())){
-				  queryWrapper.lt("state_date",endDate);
+				  queryWrapper.le("state_date",endDate);
 			  }
 		  }
 	  }

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

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

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

@@ -137,13 +137,11 @@ public class UserAllocationController {
         try {
 
             QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("user_id", userId);
             queryWrapper.eq("project_id", projectId);
-           /*  Project project = projectService.getById(projectId);
-                if (!Check.isNull(project)) {
-                queryWrapper.eq("media_id", project.getMediaId());
-            }*/
-
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)) {
+                queryWrapper.eq("user_id", userId);
+            }
             List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
             result.setSuccess(true);
             result.setResult(userAllocations);

+ 42 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/AlarmEventSendController.java

@@ -3,10 +3,13 @@ package cn.com.ctop.alarm.modules.controller;
 import cn.com.ctop.alarm.modules.entity.AlarmEventSend;
 import cn.com.ctop.alarm.modules.service.IAlarmEventSendService;
 import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -81,6 +84,44 @@ public class AlarmEventSendController {
         return result;
     }
 
+    @AutoLog(value = "预警事件发送表-分页列表查询")
+    @ApiOperation(value = "预警事件发送表-分页列表查询", notes = "预警事件发送表-分页列表查询")
+    @GetMapping(value = "/pageList")
+    public Result<Object> queryPageLists(AlarmEventSend alarmEventSend,
+                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                         HttpServletRequest req) {
+        try {
+            QueryWrapper<AlarmEventSend> queryWrapper = new QueryWrapper<>();
+            if (!Check.isNull(alarmEventSend.getGroupName())) {
+                queryWrapper.like("group_name", alarmEventSend.getGroupName());
+            }
+            if (!Check.isNull(alarmEventSend.getUserId())) {
+                queryWrapper.like("user_id", alarmEventSend.getUserId());
+            }
+            if (!Check.isNull(alarmEventSend.getAlarmDetail())) {
+                queryWrapper.like("alarm_detail", alarmEventSend.getAlarmDetail());
+            }
+            if (!Check.isNull(alarmEventSend.getMediaType())) {
+                queryWrapper.like("media_type", alarmEventSend.getMediaType());
+            }
+            if (!Check.isNull(alarmEventSend.getAccountId())) {
+                queryWrapper.eq("account_id", alarmEventSend.getAccountId());
+            }
+            if (!Check.isNull(alarmEventSend.getRuleDimension())) {
+                queryWrapper.eq("rule_dimension", alarmEventSend.getRuleDimension());
+            }
+            queryWrapper.orderByDesc("create_time");
+            PageHelper.startPage(pageNo, pageSize);
+            List<AlarmEventSend> list = alarmEventSendService.list(queryWrapper);
+            PageInfo<AlarmEventSend> pageInfo = new PageInfo<>(list);
+            return Result.ok(pageInfo);
+        } catch (Exception e) {
+            log.error("预警历史发送数据-分页列表查询异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
     /**
      * 添加
      *
@@ -127,6 +168,7 @@ public class AlarmEventSendController {
         }
         return result;
     }
+
     /**
      * 编辑
      *

+ 1 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/AlarmEventSend.java

@@ -34,6 +34,7 @@ public class AlarmEventSend {
     @TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "主键id")
     private Long alarmSendId;
+    private Long accountId;
 
     private String userId;
     /**

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

@@ -614,6 +614,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                 send.setAlarmDetail(msg.replace("<br/>", ","));
                 send.setAlarmStatus(NoEn.NO1.valueStr());
                 send.setGroupId(ruleGroup.getId());
+                send.setAccountId(accountId);
                 send.setMediaType((NoEn.NO1.valueInt() == mediaType || NoEn.NO3.valueInt() == mediaType) ? "头条" : "快手");
                 send.setGroupName(ruleGroup.getGroupName());
                 if (CREATIVE.equals(type)) {

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

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

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

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

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

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

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

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

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

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

+ 0 - 25
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCampaignCopyDateJob.java

@@ -1,25 +0,0 @@
-package cn.com.ctop.job.kuaishou.handler;
-
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouCampaignCopyDataService;
-import com.xxl.job.core.handler.annotation.XxlJob;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * 定时复制广告计划下的组+创意
- *
- * @param
- * @author ZHAOXA
- * @return
- * @throws
- */
-@Component
-public class KuaishouCampaignCopyDateJob {
-    @Autowired
-    private IKuaishouCampaignCopyDataService kuaishouCampaignCopyDataService;
-
-    @XxlJob("kuaishouCampaignCopyDateJob")
-    public void execute() throws Exception {
-        kuaishouCampaignCopyDataService.batchCopyCampaign(null);
-    }
-}

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

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

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

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

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

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

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

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

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

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

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

@@ -72,4 +72,6 @@ public class AiKuaishouAccountTargetTemplate {
 	private Date createTime;
 	/**updateTime*/
 	private Date updateTime;
+	private String titlePrefix;
+	private String titleMiddle;
 }

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

@@ -0,0 +1,56 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * ai获取素材上次截止日期
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-01-11
+ */
+@Data
+@TableName("ctop_kuaishou_video_last_time")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_video_last_time对象", description = "ai获取素材上次截止日期")
+public class KuaiShouVideoLastTime {
+
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long Id;
+    /**
+     * 素材最后上新时间
+     */
+    @ApiModelProperty(value = "素材最后上新时间")
+    private Date lastTime;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

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

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

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

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaiShouVideoLastTimeMapper">
+    <select id="getImageListByMd5" resultType="java.lang.String">
+      select
+      signature
+      from ctop_material_cut_frame
+      where video_signature = #{md5}
+      limit 15
+    </select>
+
+</mapper>

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

@@ -4,4 +4,6 @@ import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
 
 public interface IAiKuaishouNewCreateCampaign {
     void kuaishouAiAdsNewMaterialCreativity(AiKuaishouAccountTargetTemplate targetTemplate);
+
+    void kuaishouAiAdsHotMaterialCreativity(AiKuaishouAccountTargetTemplate targetTemplate);
 }

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import com.alibaba.fastjson.JSONArray;
+
+public interface IKuaiShouCreateService {
+    /**
+     * 创建组和计划
+     *
+     * @param oauthToken
+     * @param campaign_id
+     * @param group_list
+     */
+    void createUnitAndCreative(CtopOauthToken oauthToken, Long campaign_id, JSONArray group_list);
+}

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouVideoLastTime;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * @Description: ai获取素材上次截止日期
+ * @Author: jeecg-boot
+ * @Date: 2021-01-11
+ * @Version: V1.0
+ */
+public interface IKuaiShouVideoLastTimeService extends IService<KuaiShouVideoLastTime> {
+
+    List<String> getImageListByMd5(String signature);
+}

+ 93 - 12
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouNewCreateCampaignServiceImpl.java

@@ -12,6 +12,7 @@ import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouNewCreateCampaign;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouStrategyMapCreativeService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouVideoGetMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
@@ -48,6 +49,9 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
     private IKuaiShouImageGetService imageGetService;
     @Autowired
     private IKuaiShouMaterialUploadService materialUploadService;
+    @Autowired
+    private KuaiShouVideoGetMapper videoGetMapper;
+
 
     @Override
     public void kuaishouAiAdsNewMaterialCreativity(AiKuaishouAccountTargetTemplate targetTemplate) {
@@ -64,11 +68,12 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
 
         // 2.2 执行 素造的 视频拉取服务,时间过滤执行 yyyy-MM-dd HH:mm:ss
         // 时间差,单位为分钟
-        int dimeDiff = 5;
-        Date now = new Date();
-        String startTime = DateUtils.formatDate(new Date(now.getTime() - dimeDiff*60*1000),"yyyy-MM-dd HH:mm:ss");
-        String endTime = DateUtils.formatDate(now,"yyyy-MM-dd HH:mm:ss");
-        kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startTime, endTime);
+        int timeStart = -25;
+        int timeEnd = -20;
+        Long now = System.currentTimeMillis();
+        String startTime = DateUtils.formatDate(new Date(now + timeStart*60*1000),"yyyy-MM-dd HH:mm:ss");
+        String endTime = DateUtils.formatDate(new Date(now + timeEnd*60*1000),"yyyy-MM-dd HH:mm:ss");
+        kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startTime,endTime);
 
 
         // 3、获取5分钟内,ctop_kuaishou_video_get 的视频数据,记为 N,如果有数据则执行下面步骤
@@ -84,7 +89,7 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
         JSONArray campaignList = kuaishouInterfaceService.getCampaignList(token, new Date(), new Date(),1);
         boolean isHaveNewCampaign = false;
         Long newCampaignId = 0L;
-        if (campaignList.size()>0){
+        if (null!=campaignList&&campaignList.size()>0){
             for(int i = 0;i<campaignList.size();i++){
                 JSONObject jsonObject = campaignList.getJSONObject(i);
                 if (jsonObject.getString("campaign_name").contains("素材上新")){
@@ -100,7 +105,7 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
             String timestamp = DateUtils.formatDate(campaignDate,"yyyyMMddHHmmss");
             JSONObject campaignParams = new JSONObject();
             campaignParams.put("advertiser_id",token.getAccountId());
-            String campaignName = "户14-上下滑&信息流" + "-素材上新-"+ "剪辑-低价-低价包邮-活动-年龄18岁以上-单出价-"+ timestamp;
+            String campaignName = targetTemplate.getTitlePrefix() + "素材上新"+ targetTemplate.getTitleMiddle()+ timestamp;
             campaignParams.put("campaign_name",campaignName);
             campaignParams.put("type",Integer.parseInt(targetTemplate.getMarketingGoal()));
             campaignParams.put("day_budget",0L);
@@ -116,11 +121,11 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
 
         //3、在“上新”计划中新增广告组,一个素材搭配5张封面,组成一个广告组
         String timestamp = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
-        String unitName = "户14-上下滑&信息流" + "-素材上新-"+ "剪辑-低价-低价包邮-活动-年龄18岁以上-单出价-"+ timestamp;
+        String unitNamePrefix = targetTemplate.getTitlePrefix() + "素材上新"+ targetTemplate.getTitleMiddle()+ timestamp;
         int unitCnt = 0;
         for(KuaiShouVideoGet videoItem: newVideos){
             unitCnt ++;
-            unitName = unitName + "-" + unitCnt;
+            String unitName = unitNamePrefix + "-" + unitCnt;
             JSONObject unitParams = createUnitParams(token, newCampaignId, targetTemplate, unitName);
             Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
             Integer unitCode = (Integer) unitCreateResult.get("code");
@@ -143,6 +148,85 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
         }
     }
 
+    @Override
+    public void kuaishouAiAdsHotMaterialCreativity(AiKuaishouAccountTargetTemplate targetTemplate) {
+        Long accountId = targetTemplate.getAccountId();
+        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId.toString());
+        if(null == token){
+            log.info("token获取失败=>accountId:{}",accountId);
+            return;
+        }
+
+        int days = 14;
+        int highQualityVideoCnt = 100;
+        List<KuaiShouVideoGet>highQualityVideos = videoGetMapper.getHighQualityVideo(accountId,days,highQualityVideoCnt);
+        if (null == highQualityVideos||highQualityVideos.isEmpty()){
+            log.info("此项目下无视频");
+            return;
+        }
+
+        JSONArray campaignList = kuaishouInterfaceService.getCampaignList(token, new Date(), new Date(),1);
+        boolean isHaveHotCampaign = false;
+        Long newCampaignId = 0L;
+        if (null!=campaignList&&campaignList.size()>0){
+            for(int i = 0;i<campaignList.size();i++){
+                JSONObject jsonObject = campaignList.getJSONObject(i);
+                if (jsonObject.getString("campaign_name").contains("爆量素材")){
+                    isHaveHotCampaign = true;
+                    newCampaignId = jsonObject.getLong("campaign_id");
+                    break;
+                }
+            }
+        }
+
+        if (!isHaveHotCampaign){
+            Date campaignDate = new Date();
+            String timestamp = DateUtils.formatDate(campaignDate,"yyyyMMddHHmmss");
+            JSONObject campaignParams = new JSONObject();
+            campaignParams.put("advertiser_id",token.getAccountId());
+            String campaignName = targetTemplate.getTitlePrefix() + "爆量素材"+ targetTemplate.getTitleMiddle() + timestamp;
+            campaignParams.put("campaign_name",campaignName);
+            campaignParams.put("type",Integer.parseInt(targetTemplate.getMarketingGoal()));
+            campaignParams.put("day_budget",0L);
+            Map<String, Object> campaignCreateResult = kuaishouInterfaceService.campaignCreate(token.getAccessToken(), token.getAccountId(), campaignParams);
+            Integer code = (Integer) campaignCreateResult.get("code");
+            String message = (String) campaignCreateResult.get("message");
+            if(code != 0 ){
+                log.info("计划创建失败=>message:{}",message);
+                return;
+            }
+            newCampaignId = (Long) campaignCreateResult.get("campaignId");
+        }
+
+        //3、在“上新”计划中新增广告组,一个素材搭配5张封面,组成一个广告组
+        String timestamp = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss");
+        String unitNamePrefix = targetTemplate.getTitlePrefix() + "爆量素材"+ targetTemplate.getTitleMiddle()+timestamp;
+        int unitCnt = 0;
+        for(KuaiShouVideoGet videoItem: highQualityVideos){
+            unitCnt ++;
+            String unitName = unitNamePrefix + "-" + unitCnt;
+            JSONObject unitParams = createUnitParams(token, newCampaignId, targetTemplate, unitName);
+            Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
+            Integer unitCode = (Integer) unitCreateResult.get("code");
+            String unitMessage = (String) unitCreateResult.get("message");
+            if(unitCode != 0 ){
+                log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
+                continue;
+            }
+            Long unitId = (Long) unitCreateResult.get("unitId");
+
+            // 每个组,搭配5个创意
+            List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
+            List<MaterialImageInfo> orgFrameList = materialImageInfoService.getListByVideoSignature(videoItem.getSignature());
+            if ((null == cutFrameList||cutFrameList.isEmpty())&&(null == orgFrameList|| orgFrameList.isEmpty())){
+                log.info("未获取到视频封面=>videoSignature:{}",videoItem.getSignature());
+                continue;
+            }
+            JSONObject creativeParams = creativeParams(token, unitId, videoItem, targetTemplate);
+            createCreativeByImage(cutFrameList, orgFrameList,token, creativeParams, newCampaignId, unitId, videoItem,targetTemplate.getImageNumber());
+        }
+
+    }
 
 
     private JSONObject creativeParams(CtopOauthToken token,Long unitId,KuaiShouVideoGet videoItem,AiKuaishouAccountTargetTemplate targetTemplate){
@@ -245,7 +329,6 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
             targetJsonObject.put("exclude_population",excludePopulation);
         }
         unitParams.put("target",targetJsonObject);
-
         return unitParams;
     }
 
@@ -292,8 +375,6 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
             // 则调用上传url的方法 kuauiShouImageUpload(url, signature, accountId, oauthToken.getAccessToken());
             return materialUploadService.kuauiShouImageUpload(imageUrl,imageCode,accountId,token);
         }
-
         return imageGet.getImageToken();
     }
-
 }

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

@@ -97,17 +97,17 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
         String endDate = DateUtils.formatDate(new Date(now.getTime() - dimeDiff*60*1000),"yyyy-MM-dd HH:mm:ss");
         kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startDate, endDate)));*/
 
-        JSONObject MaterialSelectMethod = JSONObject.parseObject(strategyTemplate.getMaterialSelectMethod());
+        JSONObject materialSelectMethod = JSONObject.parseObject(strategyTemplate.getMaterialSelectMethod());
         List<KuaiShouVideoGet> newVideos = new ArrayList<KuaiShouVideoGet>();
         List<KuaiShouVideoGet> highQualityVideos = new ArrayList<KuaiShouVideoGet>();
 
-        if (MaterialSelectMethod.containsKey("newMaterialNum")){
-            int newVideoCnt = (int) MaterialSelectMethod.get("newMaterialNum");
+        if (materialSelectMethod.containsKey("newMaterialNum")){
+            int newVideoCnt = (int) materialSelectMethod.get("newMaterialNum");
             newVideos = videoGetService.getNewVideoDescDate(accountId,newVideoCnt);
         }
-        if(MaterialSelectMethod.containsKey("highQualityMaterial")){
-            int days = MaterialSelectMethod.getJSONObject("highQualityMaterial").getInteger("days");
-            int highQualityVideoCnt = MaterialSelectMethod.getJSONObject("highQualityMaterial").getInteger("num");
+        if(materialSelectMethod.containsKey("highQualityMaterial")){
+            int days = materialSelectMethod.getJSONObject("highQualityMaterial").getInteger("days");
+            int highQualityVideoCnt = materialSelectMethod.getJSONObject("highQualityMaterial").getInteger("num");
             highQualityVideos = videoGetMapper.getHighQualityVideo(accountId,days,highQualityVideoCnt);
         }
 

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

@@ -0,0 +1,421 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.MaterialCutFrame;
+import cn.com.ctop.common.module.service.IMaterialCutFrameService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils2;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouCreateService;
+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.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.service.*;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+@Service
+@Slf4j
+public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
+    @Autowired
+    private IKuaishouInterfaceService iKuaishouInterfaceService;
+    @Autowired
+    private IKuaiShouGroupService groupService;
+    @Autowired
+    private IKuaiShouImageGetService imageGetService;
+    @Autowired
+    private IMaterialCutFrameService cutFrameService;
+    @Autowired
+    private IKuaiShouMaterialUploadService uploadService;
+
+    @Override
+    public void createUnitAndCreative(CtopOauthToken oauthToken, Long campaign_id, JSONArray group_list) {
+
+        JSONArray returnArr = new JSONArray();
+        try {
+            for (int i = 0; i < group_list.size(); i++) {
+                JSONObject groupCreateJson = group_list.getJSONObject(i);
+                if (Check.isNull(groupCreateJson)) {
+                    continue;
+                }
+                JSONObject createJson = new JSONObject();
+                createJson.put("advertiser_id", oauthToken.getAccountId());
+                createJson.put("campaign_id", campaign_id);
+                createJson.put("unit_name", groupCreateJson.getString("unit_name")); // 组名称
+                createJson.put("bid_type", groupCreateJson.getString("bid_type")); // 组名称
+                if (!Check.isNull(groupCreateJson.getInteger("use_app_market"))) {
+                    createJson.put("use_app_market", groupCreateJson.getInteger("use_app_market")); // 优先从系统应用商店下载
+                }
+
+                if (!Check.isNull(groupCreateJson.getJSONArray("app_store"))) {
+                    createJson.put("app_store", groupCreateJson.getJSONArray("app_store")); //应用商店列表
+                }
+                if (!Check.isNull(groupCreateJson.getLong("bid"))) {
+                    createJson.put("bid", groupCreateJson.getLong("bid")); //出价
+                }
+                if (!Check.isNull(groupCreateJson.getLong("cpa_bid"))) {
+                    createJson.put("cpa_bid", groupCreateJson.getLong("cpa_bid")); //出价
+                }
+                if (!Check.isNull(groupCreateJson.getInteger("smart_bid"))) {
+                    createJson.put("smart_bid", groupCreateJson.getInteger("smart_bid")); //优先低成本
+                }
+                if (!Check.isNull(groupCreateJson.getInteger("ocpx_action_type"))) {
+                    createJson.put("ocpx_action_type", groupCreateJson.getInteger("ocpx_action_type")); //优化目标
+                }
+                if (!Check.isNull(groupCreateJson.getInteger("deep_conversion_type"))) {
+                    createJson.put("deep_conversion_type", groupCreateJson.getInteger("deep_conversion_type")); //深度转化目标
+                }
+                if (!Check.isNull(groupCreateJson.getDouble("roi_ratio"))) {
+                    createJson.put("roi_ratio", groupCreateJson.getDouble("roi_ratio")); //付费ROI系数
+                }
+                if (!Check.isNull(groupCreateJson.getLong("deep_conversion_bid"))) {
+                    createJson.put("deep_conversion_bid", groupCreateJson.getLong("deep_conversion_bid")); //深度转化目标出价
+                }
+                if (!Check.isNull(groupCreateJson.getJSONArray("scene_id"))) {
+                    createJson.put("scene_id", groupCreateJson.getJSONArray("scene_id")); //资源位置
+                }
+                if (!Check.isNull(groupCreateJson.getInteger("unit_type"))) {
+                    createJson.put("unit_type", groupCreateJson.getInteger("unit_type")); //创意制作方式
+                }
+                if (!Check.isNull(groupCreateJson.getString("begin_time"))) {
+                    createJson.put("begin_time", groupCreateJson.getString("begin_time")); //投放开始时间
+                }
+                if (!Check.isNull(groupCreateJson.getString("end_time"))) {
+                    createJson.put("end_time", groupCreateJson.getString("end_time")); //投放结束时间
+                }
+                if (!Check.isNull(groupCreateJson.getString("schedule_time"))) {
+                    createJson.put("schedule_time", groupCreateJson.getString("schedule_time")); //投放时间段
+                }
+                if (!Check.isNull(groupCreateJson.getLong("day_budget"))) {
+                    createJson.put("day_budget", groupCreateJson.getLong("day_budget")); //投放时间段
+                }
+                if (!Check.isNull(groupCreateJson.getInteger("convert_id"))) {
+                    createJson.put("convert_id", groupCreateJson.getInteger("convert_id")); //投放时间段
+                }
+                if (!Check.isNull(groupCreateJson.getInteger("url_type"))) {
+                    createJson.put("url_type", groupCreateJson.getInteger("url_type")); //url类型
+                }
+                if (!Check.isNull(groupCreateJson.getInteger("web_uri_type"))) {
+                    createJson.put("web_uri_type", groupCreateJson.getInteger("web_uri_type")); //url类型
+                }
+                if (!Check.isNull(groupCreateJson.getString("url"))) {
+                    createJson.put("url", groupCreateJson.getString("url")); //url类型
+                }
+                if (!Check.isNull(groupCreateJson.getString("schema_uri"))) {
+                    createJson.put("schema_uri", groupCreateJson.getString("schema_uri")); //调起链接
+                }
+                if (!Check.isNull(groupCreateJson.getLong("app_id"))) {
+                    createJson.put("app_id", groupCreateJson.getLong("app_id")); //应用ID
+                }
+                if (!Check.isNull(groupCreateJson.getInteger("show_mode"))) {
+                    createJson.put("show_mode", groupCreateJson.getInteger("show_mode")); //创意展现方式
+                }
+                if (!Check.isNull(groupCreateJson.getInteger("speed"))) {
+                    createJson.put("speed", groupCreateJson.getInteger("speed")); //投放方式
+                }
+                if (!Check.isNull(groupCreateJson.getInteger("site_type"))) {
+                    createJson.put("site_type", groupCreateJson.getInteger("site_type")); //预约广告
+                }
+                if (!Check.isNull(groupCreateJson.getInteger("target_action_type")) || !Check.isNull(groupCreateJson.getString("code"))) {
+                    JSONObject gift_data = new JSONObject();
+                    if (!Check.isNull(groupCreateJson.getInteger("target_action_type"))) {
+                        gift_data.put("target_action_type", groupCreateJson.getInteger("target_action_type"));
+                    }
+                    if (!Check.isNull(groupCreateJson.getString("code"))) {
+                        gift_data.put("code", groupCreateJson.getString("code"));
+                    }
+                    createJson.put("gift_data", gift_data); //游戏礼包码
+                }
+                if (!Check.isNull(groupCreateJson.getBoolean("video_landing_page"))) {
+                    createJson.put("video_landing_page", groupCreateJson.getBoolean("video_landing_page")); //是否使用落地页前置功能
+                }
+                if (!Check.isNull(groupCreateJson.getBoolean("auto_target"))) {
+                    createJson.put("auto_target", groupCreateJson.getBoolean("auto_target")); //智能定向
+                }
+                if (!Check.isNull(groupCreateJson.getBoolean("auto_create_photo"))) {
+                    createJson.put("auto_create_photo", groupCreateJson.getBoolean("auto_create_photo")); //是否开启自动生成视频
+                }
+
+                if (!Check.isNull(groupCreateJson.getLong("item_id"))) {
+                    createJson.put("item_id", groupCreateJson.getLong("item_id")); //电商关联Id (小店通)
+                }
+                if (!Check.isNull(groupCreateJson.getLong("merchant_item_put_type"))) {
+                    createJson.put("merchant_item_put_type", groupCreateJson.getLong("merchant_item_put_type")); //电商广告投放类型(小店通)
+                }
+                if (!Check.isNull(groupCreateJson.getLong("fiction_id"))) {
+                    createJson.put("fiction_id", groupCreateJson.getLong("fiction_id")); //小说ID
+                }
+                if (!Check.isNull(groupCreateJson.getLong("template_id"))) {
+                    createJson.put("template_id", groupCreateJson.getLong("template_id")); //定向模板id
+                } else {
+                    JSONObject target = getTarget(groupCreateJson);
+                    if (!Check.isNull(target)) {
+                        createJson.put("getTarget", target); // 定向数据
+                    }
+                }
+                Map<String, Object> unitMap = iKuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), createJson, 1);
+                JSONObject returnJson = new JSONObject();
+                returnJson.put("table_id", groupCreateJson.getLong("table_id"));
+                if ((Integer) unitMap.get("code") == 0) {
+                    Long unitId = (Long) unitMap.get("unitId");
+                    returnJson.put("unit_id", unitId);
+                    returnJson.put("code", 0);
+                    returnJson.put("message", "广告组创建成功");
+                    KuaiShouGroup group = groupService.selectGroupByUnitId(oauthToken.getAccountId(), unitId);
+                    if (!Check.isNull(group)) {
+                        returnJson.put("group_create_time", group.getGroupCreateTime());
+                    }
+                    Thread thread = new Thread() {
+                        @Override
+                        public void run() {
+                            createCreative(oauthToken, unitId, groupCreateJson.getJSONArray("creative_list"));
+                        }
+                    };
+                    thread.start();
+                } else {
+                    returnJson.put("code", -1);
+                    returnJson.put("message", unitMap.get("message"));
+                }
+                returnArr.add(returnJson);
+            }
+            callback("url", returnArr);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("创建组错误!!!!!");
+        }
+    }
+
+
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+
+    /**
+     * 创建广告创意
+     *
+     * @param oauthToken
+     * @param unit_id
+     * @param creative_list
+     */
+    private void createCreative(CtopOauthToken oauthToken, Long unit_id, JSONArray creative_list) {
+        JSONArray returnArr = new JSONArray();
+        try {
+            for (int i = 0; i < creative_list.size(); i++) {
+                JSONObject creativeJson = creative_list.getJSONObject(i);
+                if (Check.isNull(creativeJson)) {
+                    continue;
+                }
+                JSONObject createJson = new JSONObject();
+                createJson.put("advertiser_id", oauthToken.getAccountId());
+                createJson.put("unit_id", unit_id);
+                createJson.put("creative_name", creativeJson.getString("creative_name")); // 创意名称
+                if (!Check.isNull(creativeJson.getLong("photo_id"))) {
+                    createJson.put("photo_id", creativeJson.getLong("photo_id"));  // 视频ID
+                }
+                KuaiShouVideoGet video = videoGetService.getVideoByPhotoId(creativeJson.getLong("photo_id"));
+                if (!Check.isNull(video)) {
+                    createJson.put("creative_material_type", video.getMaterialType());  // 素材类型
+                }
+                if (!Check.isNull(creativeJson.getString("action_bar_text"))) {
+                    createJson.put("action_bar_text", creativeJson.getString("action_bar_text"));  // 行动号召按钮文案
+                }
+                if (!Check.isNull(creativeJson.getString("description"))) {
+                    createJson.put("description", creativeJson.getString("description"));  // 广告语
+                }
+                if (!Check.isNull(creativeJson.getString("sticker_title"))) {
+                    createJson.put("sticker_title", creativeJson.getString("sticker_title"));  // 封面广告语标题
+                }
+                if (!Check.isNull(creativeJson.getString("overlay_type"))) {
+                    createJson.put("overlay_type", creativeJson.getString("overlay_type"));  // 贴纸样式类型
+                }
+                if (!Check.isNull(creativeJson.getString("expose_tag"))) {
+                    createJson.put("expose_tag", creativeJson.getString("expose_tag"));  // 广告标签
+                }
+                if (!Check.isNull(creativeJson.getJSONArray("new_expose_tag"))) {
+                    createJson.put("new_expose_tag", creativeJson.getJSONArray("new_expose_tag"));  // 广告标签2期
+                }
+                if (!Check.isNull(creativeJson.getLong("site_id"))) {
+                    createJson.put("site_id", creativeJson.getLong("site_id"));  // 安卓下载中间页ID
+                }
+                if (!Check.isNull(creativeJson.getString("click_track_url"))) {
+                    createJson.put("click_track_url", creativeJson.getString("click_track_url"));  // 第三方点击检测链接
+                }
+                if (!Check.isNull(creativeJson.getString("impression_url"))) {
+                    createJson.put("impression_url", creativeJson.getString("impression_url"));  // 第三方开始播放监测链接
+                }
+                if (!Check.isNull(creativeJson.getString("ad_photo_played_t3s_url"))) {
+                    createJson.put("ad_photo_played_t3s_url", creativeJson.getString("ad_photo_played_t3s_url"));  // 第三方有效播放监测链接
+                }
+                if (!Check.isNull(creativeJson.getString("actionbar_click_url"))) {
+                    createJson.put("actionbar_click_url", creativeJson.getString("actionbar_click_url"));  // 第三方点击按钮监测链接
+                }
+                if (!Check.isNull(creativeJson.getInteger("creative_category"))) {
+                    createJson.put("creative_category", creativeJson.getInteger("creative_category"));  // 创意分类
+                }
+                if (!Check.isNull(creativeJson.getJSONArray("creative_tag"))) {
+                    createJson.put("creative_tag", creativeJson.getJSONArray("creative_tag"));  // 创意标签
+                }
+                String image_md5 = creativeJson.getString("image_md5");
+                String imageToken = null;
+                if (!Check.isNull(image_md5)) {
+                    imageToken = getImageToken(image_md5, oauthToken.getAccountId(), oauthToken.getAccessToken());
+                }
+                if (!Check.isNull(imageToken)) {
+                    Integer is_sticky = creativeJson.getInteger("is_sticky"); // 是否便利贴
+                    if (is_sticky != 1) {
+                        createJson.put("image_token", imageToken); // 自定义创意封面token
+                    } else {
+                        JSONArray image_tokens = new JSONArray();
+                        image_tokens.add(imageToken);
+                        createJson.put("image_tokens", image_tokens); // 便利贴图片素材token
+                        if (!Check.isNull(creativeJson.getString("short_slogan"))) {
+                            createJson.put("short_slogan", creativeJson.getString("short_slogan"));  // 便利贴创意短广告语
+                        }
+                    }
+                }
+                Map<String, Object> creativeMap = iKuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), createJson, 1);
+                JSONObject returnJson = new JSONObject();
+                returnJson.put("table_id", creativeJson.getLong("table_id"));
+                if ((Integer) creativeMap.get("code") == 0) {
+                    Long creativeId = (Long) creativeMap.get("creativeId");
+                    returnJson.put("creative_id", creativeId);
+                    returnJson.put("unit_id", unit_id);
+                    returnJson.put("code", 0);
+                    returnJson.put("message", "广告创意创建成功");
+                } else {
+                    returnJson.put("code", -1);
+                    returnJson.put("message", creativeMap.get("message"));
+                }
+                returnArr.add(returnJson);
+            }
+            callback("url", returnArr);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void callback(String url, JSONArray requestArr) {
+        JSONObject requestJson = new JSONObject();
+        requestJson.put("callbackData", requestArr);
+        String s = HttpUtils2.httpPostRequest(url, requestJson, null);
+        JSONObject jsonObject = JSONObject.parseObject(s);
+        log.info("回调数据返回结果:{}", jsonObject);
+    }
+
+    private String getImageToken(String md5, Long accountId, String accessToken) {
+        String imageToken = null;
+        QueryWrapper<KuaiShouImageGet> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("signature", md5);
+        queryWrapper.last("limit 1");
+        KuaiShouImageGet imageGet = imageGetService.getOne(queryWrapper);
+        if (!Check.isNull(imageGet)) {
+            imageToken = imageGet.getImageToken();
+        } else {
+            MaterialCutFrame cutFrame = cutFrameService.selectByMd5(md5);
+            if (!Check.isNull(cutFrame)) {
+                imageToken = uploadService.kuauiShouImageUpload(cutFrame.getUrl(), md5, accountId, accessToken);
+            }
+
+        }
+        return imageToken;
+    }
+
+
+    private JSONObject getTarget(JSONObject unitJson) {
+        JSONObject target = new JSONObject();
+        if (!Check.isNull(unitJson.getJSONArray("region"))) {
+            target.put("region", unitJson.getJSONArray("region")); // 地域
+        }
+        if (!Check.isNull(unitJson.getJSONArray("district_ids"))) {
+            target.put("district_ids", unitJson.getJSONArray("district_ids")); // 商圈定向
+        }
+        if (!Check.isNull(unitJson.getInteger("user_type"))) {
+            target.put("user_type", unitJson.getInteger("user_type")); // 用户类型
+        }
+        if (!Check.isNull(unitJson.getInteger("age_min")) || !Check.isNull(unitJson.getInteger("age_max"))) {
+            JSONObject age = new JSONObject();
+            age.put("min", unitJson.getInteger("age_min"));
+            age.put("max", unitJson.getInteger("age_max"));
+            target.put("age", age); //自定义年龄段
+        }
+        if (!Check.isNull(unitJson.getJSONArray("ages_range"))) {
+            target.put("ages_range", unitJson.getInteger("ages_range")); // 固定年龄段
+        }
+        if (!Check.isNull(unitJson.getInteger("gender"))) {
+            target.put("gender", unitJson.getInteger("gender")); // 性别
+        }
+        if (!Check.isNull(unitJson.getInteger("platform_os"))) {
+            target.put("platform_os", unitJson.getInteger("platform_os")); // 操作系统
+        }
+        if (!Check.isNull(unitJson.getInteger("android_osv"))) {
+            target.put("android_osv", unitJson.getInteger("android_osv")); // Android版本
+        }
+        if (!Check.isNull(unitJson.getInteger("ios_osv"))) {
+            target.put("ios_osv", unitJson.getInteger("ios_osv")); // Android版本
+        }
+        if (!Check.isNull(unitJson.getInteger("network"))) {
+            target.put("network", unitJson.getInteger("network")); // 网络环境
+        }
+        if (!Check.isNull(unitJson.getJSONArray("device_brand"))) {
+            target.put("device_brand", unitJson.getJSONArray("device_brand")); // 设备品牌
+        }
+        if (!Check.isNull(unitJson.getJSONArray("device_price"))) {
+            target.put("device_price", unitJson.getJSONArray("device_price")); // 设备价格
+        }
+        if (!Check.isNull(unitJson.getInteger("business_interest_type"))) {
+            target.put("business_interest_type", unitJson.getInteger("business_interest_type")); // 商业兴趣类型
+        }
+        if (!Check.isNull(unitJson.getJSONArray("business_interest"))) {
+            target.put("business_interest", unitJson.getJSONArray("business_interest")); // 商业兴趣
+        }
+        if (!Check.isNull(unitJson.getJSONArray("fans_star"))) {
+            target.put("fans_star", unitJson.getJSONArray("fans_star")); // 网红粉丝
+        }
+        if (!Check.isNull(unitJson.getJSONArray("interest_video"))) {
+            target.put("interest_video", unitJson.getJSONArray("interest_video")); // 兴趣视频用户
+        }
+        if (!Check.isNull(unitJson.getJSONArray("app_interest"))) {
+            target.put("app_interest", unitJson.getJSONArray("app_interest")); // APP行为-按分类
+        }
+        if (!Check.isNull(unitJson.getJSONArray("app_ids"))) {
+            target.put("app_ids", unitJson.getJSONArray("app_ids")); // APP行为-按APP名称
+        }
+        if (!Check.isNull(unitJson.getInteger("filter_converted_level"))) {
+            target.put("filter_converted_level", unitJson.getInteger("filter_converted_level")); // APP行为-按APP名称
+        }
+        if (!Check.isNull(unitJson.getJSONArray("population"))) {
+            target.put("population", unitJson.getJSONArray("population")); // 人群包定向
+        }
+        if (!Check.isNull(unitJson.getJSONArray("exclude_population"))) {
+            target.put("exclude_population", unitJson.getJSONArray("exclude_population")); // 人群包排除
+        }
+        if (!Check.isNull(unitJson.getJSONArray("paid_audience"))) {
+            target.put("paid_audience", unitJson.getJSONArray("paid_audience")); // 付费人群包id
+        }
+        if (!Check.isNull(unitJson.getInteger("is_open")) && unitJson.getInteger("is_open") == 1) {
+            JSONObject intelli_extend = new JSONObject();
+            intelli_extend.put("is_open", unitJson.getInteger("is_open")); // 开启智能扩量
+            if (!Check.isNull(unitJson.getInteger("no_age_break"))) {
+                intelli_extend.put("no_age_break", unitJson.getInteger("no_age_break")); //  不可突破年龄
+            }
+            if (!Check.isNull(unitJson.getInteger("no_gender_break"))) {
+                intelli_extend.put("no_gender_break", unitJson.getInteger("no_gender_break")); //  不可突破性别
+            }
+            if (!Check.isNull(unitJson.getInteger("no_area_break"))) {
+                intelli_extend.put("no_area_break", unitJson.getInteger("no_area_break")); //  不可突破地域
+            }
+            target.put("intelli_extend", intelli_extend); // 智能扩量
+
+        }
+        if (Check.isNull(unitJson.getJSONObject("behavior_interest"))) {
+            // TODO 只是单独结构体 后续需要优化
+            target.put("behavior_interest", unitJson.getJSONObject("behavior_interest")); // 智能扩量
+        }
+        return target;
+    }
+}

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

@@ -0,0 +1,28 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouVideoLastTime;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaiShouVideoLastTimeMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouVideoLastTimeService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * ai获取素材上次截止日期
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-01-11
+ */
+@Service
+public class KuaiShouVideoLastTimeServiceImpl extends ServiceImpl<KuaiShouVideoLastTimeMapper, KuaiShouVideoLastTime> implements IKuaiShouVideoLastTimeService {
+    @Autowired
+    private KuaiShouVideoLastTimeMapper videoLastTimeMapper;
+
+    @Override
+    public List<String> getImageListByMd5(String signature) {
+        return videoLastTimeMapper.getImageListByMd5(signature);
+    }
+}

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

@@ -0,0 +1,262 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouVideoRelateCreatives;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 频库-视频关联创意数查询
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-01-12
+ */
+@Slf4j
+@Api(tags = "频库-视频关联创意数查询")
+@RestController
+@RequestMapping("/kuaishou/kuaishouVideoRelateCreatives")
+public class KuaishouVideoRelateCreativesController {
+    @Autowired
+    private IKuaishouVideoRelateCreativesService kuaishouVideoRelateCreativesService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouVideoRelateCreatives
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "频库-视频关联创意数查询-分页列表查询")
+    @ApiOperation(value = "频库-视频关联创意数查询-分页列表查询", notes = "频库-视频关联创意数查询-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouVideoRelateCreatives>> queryPageList(KuaishouVideoRelateCreatives kuaishouVideoRelateCreatives,
+                                                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                     HttpServletRequest req) {
+        Result<IPage<KuaishouVideoRelateCreatives>> result = new Result<>();
+        QueryWrapper<KuaishouVideoRelateCreatives> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouVideoRelateCreatives, req.getParameterMap());
+        Page<KuaishouVideoRelateCreatives> page = new Page<KuaishouVideoRelateCreatives>(pageNo, pageSize);
+        IPage<KuaishouVideoRelateCreatives> pageList = kuaishouVideoRelateCreativesService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    @PostMapping(value = "/pushVideo")
+    public Result<?> pushVideo(@RequestBody JSONObject data) {
+        return kuaishouVideoRelateCreativesService.pushVideo(data);
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouVideoRelateCreatives
+     * @return
+     */
+    @AutoLog(value = "频库-视频关联创意数查询-添加")
+    @ApiOperation(value = "频库-视频关联创意数查询-添加", notes = "频库-视频关联创意数查询-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouVideoRelateCreatives> add(@RequestBody KuaishouVideoRelateCreatives kuaishouVideoRelateCreatives) {
+        Result<KuaishouVideoRelateCreatives> result = new Result<>();
+        try {
+            kuaishouVideoRelateCreativesService.save(kuaishouVideoRelateCreatives);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouVideoRelateCreatives
+     * @return
+     */
+    @AutoLog(value = "频库-视频关联创意数查询-编辑")
+    @ApiOperation(value = "频库-视频关联创意数查询-编辑", notes = "频库-视频关联创意数查询-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouVideoRelateCreatives> edit(@RequestBody KuaishouVideoRelateCreatives kuaishouVideoRelateCreatives) {
+        Result<KuaishouVideoRelateCreatives> result = new Result<KuaishouVideoRelateCreatives>();
+        KuaishouVideoRelateCreatives kuaishouVideoRelateCreativesEntity = kuaishouVideoRelateCreativesService.getById(kuaishouVideoRelateCreatives.getId());
+        if (kuaishouVideoRelateCreativesEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouVideoRelateCreativesService.updateById(kuaishouVideoRelateCreatives);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "频库-视频关联创意数查询-通过id删除")
+    @ApiOperation(value = "频库-视频关联创意数查询-通过id删除", notes = "频库-视频关联创意数查询-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaishouVideoRelateCreativesService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "频库-视频关联创意数查询-批量删除")
+    @ApiOperation(value = "频库-视频关联创意数查询-批量删除", notes = "频库-视频关联创意数查询-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouVideoRelateCreatives> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouVideoRelateCreatives> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouVideoRelateCreativesService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "频库-视频关联创意数查询-通过id查询")
+    @ApiOperation(value = "频库-视频关联创意数查询-通过id查询", notes = "频库-视频关联创意数查询-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouVideoRelateCreatives> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouVideoRelateCreatives> result = new Result<>();
+        KuaishouVideoRelateCreatives kuaishouVideoRelateCreatives = kuaishouVideoRelateCreativesService.getById(id);
+        if (kuaishouVideoRelateCreatives == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouVideoRelateCreatives);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouVideoRelateCreatives> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouVideoRelateCreatives kuaishouVideoRelateCreatives = JSON.parseObject(deString, KuaishouVideoRelateCreatives.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouVideoRelateCreatives, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouVideoRelateCreatives> pageList = kuaishouVideoRelateCreativesService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "频库-视频关联创意数查询列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouVideoRelateCreatives.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<KuaishouVideoRelateCreatives> listKuaishouVideoRelateCreativess = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouVideoRelateCreatives.class, params);
+                kuaishouVideoRelateCreativesService.saveBatch(listKuaishouVideoRelateCreativess);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouVideoRelateCreativess.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("文件导入失败!");
+    }
+
+}

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

@@ -0,0 +1,72 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 频库-视频关联创意数查询
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-01-12
+ */
+@Data
+@TableName("ctop_kuaishou_video_relate_creatives")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_video_relate_creatives对象", description = "频库-视频关联创意数查询")
+public class KuaishouVideoRelateCreatives {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 视频id
+     */
+    @Excel(name = "视频id", width = 15)
+    @ApiModelProperty(value = "视频id")
+    private Long photoId;
+    private Date statDate;
+    /**
+     * 与此视频id关联的创意总数
+     */
+    @Excel(name = "与此视频id关联的创意总数", width = 15)
+    @ApiModelProperty(value = "与此视频id关联的创意总数")
+    private Integer creativeCount;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

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

@@ -30,9 +30,9 @@ public interface KuaiShouReportDailyMaterialMapper extends BaseMapper<KuaiShouRe
 
     void batchReplace(@Param("addList") List<KuaiShouReportDailyMaterial> addList);
 
-    KuaiShouReportDailyMaterial getEtlDataByParams(@Param("signature")String signature,@Param("date") String date);
+    KuaiShouReportDailyMaterial getEtlDataByParams(@Param("signature")String signature, @Param("date") String date,@Param("projectId")Long projectId);
 
     List<KuaiShouReportDailyMaterial> getSignatureByDate(@Param("date")String date);
 
-
+    List<KuaiShouReportDailyMaterial> getSignatureByDateGroupByProjectId(@Param("date")String date);
 }

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

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -21,7 +22,7 @@ public interface KuaiShouVideoGetMapper extends BaseMapper<KuaiShouVideoGet> {
     List<KuaiShouVideoGetVo> getVideoList(Map<String, Object> requestMap);
 
     List<KuaiShouVideoGet> getHighQualityVideo(long accountId,int days,int num);
-
-
+    List<KuaiShouVideoGet> selectPhotoIdsByAccountId(Long accountId);
+    List<JSONObject> getVideoListByMap(Map<String, Object> requestMap);
 
 }

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

@@ -0,0 +1,23 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouVideoRelateCreatives;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 频库-视频关联创意数查询
+ *
+ * @author: jeecg-boot
+ * @date: 2021-01-12
+ * @cersion: V1.0
+ */
+public interface KuaishouVideoRelateCreativesMapper extends BaseMapper<KuaishouVideoRelateCreatives> {
+
+    void insertBatch(@Param(value = "videolist") List<KuaishouVideoRelateCreatives> videolist);
+
+    List<JSONObject> getVideoListByMap(Map<String, Object> requestMap);
+}

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

@@ -277,6 +277,30 @@
     </select>
 
 
+    <select id="getEtlDataByParams"
+            resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial">
+        select
+        report.channel_type,
+        report.signature,
+        report.cover_url,
+        report.photo_url,
+        min(report.stat_date)as 'stat_date',
+        sum(report.charge)as 'charge',
+        sum(report.photo_click)as 'photo_click',
+        sum(report.photo_show)as 'photo_show',
+        sum(report.aclick)as 'aclick',
+        sum(report.bclick)as 'bclick'
+        from ctop_kuaishou_report_daily_material report
+        left join ctop_user_allocation allocation on allocation.account_id = report.account_id
+        where
+        report.signature = #{signature}
+        and
+        report.stat_date&lt;=#{date}
+        <if test="projectId!=null">
+            and allocation.project_id = #{projectId}
+        </if>
+        group by report.signature
+    </select>
     <select id="getVideoList" parameterType="java.util.Map"
             resultType="cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo">
 
@@ -316,26 +340,6 @@
         ORDER BY
         sum(t1.charge) DESC
     </select>
-    <select id="getEtlDataByParams"
-            resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial">
-        select
-            channel_type,
-            signature,
-            cover_url,
-            photo_url,
-            min(stat_date)as 'stat_date',
-            sum(charge)as 'charge',
-            sum(photo_click)as 'photo_click',
-            sum(photo_show)as 'photo_show',
-            sum(aclick)as 'aclick',
-            sum(bclick)as 'bclick'
-        from ctop_kuaishou_report_daily_material
-        where
-            signature = #{signature}
-        and
-            stat_date&lt;=#{date}
-        group by signature
-    </select>
     <select id="getSignatureByDate"
             resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial">
         select
@@ -349,5 +353,19 @@
         and
             stat_date = #{date}
     </select>
+    <select id="getSignatureByDateGroupByProjectId"
+            resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial">
+        select
+    distinct signature,project_id
+from
+    ctop_kuaishou_report_daily_material report
+    left join ctop_user_allocation allocation on report.account_id = allocation.account_id
+where
+    signature is not null
+    and
+    signature != ''
+    and
+    stat_date = #{date}
+    </select>
 </mapper>
 

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

@@ -58,7 +58,6 @@
     </select>
 
 
-
     <select id="getHighQualityVideo" parameterType="java.util.Map"
             resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
         select * from ctop_kuaishou_video_get
@@ -81,6 +80,34 @@
         )
     </select>
 
+    <select id="selectPhotoIdsByAccountId" parameterType="java.lang.Long"
+            resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
+        select * from ctop_kuaishou_video_get
+        where account_id = #{accountId}
+        and status = 0
+    </select>
+
+    <select id="getVideoListByMap" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        photo_id as 'photo_id',
+        signature as 'signature',
+        stat_date as 'stat_date',
+        channel_type as 'channel_type',
+        url as 'video_url'
+        from ctop_kuaishou_video_get
+        where 1 = 1
+        <if test="accountId != null and accountId != '' ">
+            and account_id = #{accountId}
+        </if>
+        <if test="startTime != null and startTime != '' ">
+            and stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null and endTime != '' ">
+            and stat_date &lt;= #{endTime}
+        </if>
+        group by signature
+        order by stat_date desc
+    </select>
 
 
 </mapper>

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

@@ -0,0 +1,52 @@
+<?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.batch.mapper.KuaishouVideoRelateCreativesMapper">
+
+    <insert id="insertBatch">
+        replace into ctop_kuaishou_video_relate_creatives(
+        account_id,
+        photo_id,
+        creative_count,
+        stat_date
+        )
+        values
+        <foreach collection="videolist" item="video" separator=",">
+            (
+            #{video.accountId},
+            #{video.photoId},
+            #{video.creativeCount},
+            #{video.statDate}
+            )
+        </foreach>
+    </insert>
+
+
+    <select id="getVideoListByMap" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        photo_id as 'photo_id',
+        stat_date as 'stat_date',
+        creative_count as 'creative_count'
+        FROM ctop_kuaishou_video_relate_creatives AS t1
+        JOIN (SELECT ROUND(RAND() * (SELECT MAX(id) FROM
+        ctop_kuaishou_video_relate_creatives
+        where 1 = 1
+        <if test="accountId != null and accountId != '' ">
+            and account_id = #{accountId}
+        </if>
+        <if test="startTime != null and startTime != '' ">
+            and DATE_FORMAT(stat_date,'%Y-%m-%d') &gt;= #{startTime}
+        </if>
+        <if test="endTime != null and endTime != '' ">
+            and DATE_FORMAT(stat_date,'%Y-%m-%d') &lt;= #{endTime}
+        </if>
+        )) AS id) AS t2
+        WHERE t1.id >= t2.id
+        <if test="accountId != null and accountId != '' ">
+            and account_id = #{accountId}
+        </if>
+        <if test="createCount != null and createCount != '' ">
+            AND creative_count &lt;= #{createCount}
+        </if>
+        ORDER BY t1.id ASC LIMIT #{num}
+    </select>
+</mapper>

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

@@ -19,4 +19,6 @@ public interface IKuaiShouCampaignService extends IService<KuaiShouCampaign> {
     List<JSONArray> getJsonArrByAccount(Long accountId, int idSize);
 
     JSONArray queryCampaignIdByAccountId(Long accountId);
+
+    KuaiShouCampaign getCampaignByAccountAndCampaign(Long accountId, Long campaignId);
 }

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

@@ -34,4 +34,6 @@ public interface IKuaiShouGroupService extends IService<KuaiShouGroup> {
     void getGroupListByPage(String accessToken, Long accountId, Long campaignId, int page);
 
     List<KuaiShouGroup> queryUnitInfoByCampaignId(Long accountId, Long campaignId);
+
+    KuaiShouGroup selectGroupByUnitId(Long accountId, Long unitId);
 }

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

@@ -17,10 +17,11 @@ public interface IKuaiShouReportDailyMaterialService extends IService<KuaiShouRe
 
     List<KuaiShouVideoGetVo> getVideoList(Map<String, Object> requestMap);
 
-
     void getMaterialReportByAccountIdAndStatDate(Long accountId, String token, String startDate, String endDate, Integer page);
 
     List<KuaiShouReportDailyMaterial> getSignatureByDate(String date);
 
-    KuaiShouReportDailyMaterial getEtlDataByParams(String signature, String date);
+    KuaiShouReportDailyMaterial getEtlDataByParams(String signature, String date,Long projectId);
+
+    List<KuaiShouReportDailyMaterial> getSignatureByDateGroupByProjectId(String date);
 }

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

@@ -2,7 +2,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
-import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouVideoGetMapper;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -30,7 +30,8 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
 
     List<KuaiShouVideoGet> getNewVideoBetweenTime(Long accountId,String startTime, String endTime);
 
+    List<JSONObject> getVideoListByMap(Map<String, Object> requestMap);
+    List<KuaiShouVideoGet> selectPhotoIdsByAccountId(Long accountId);
 
-
-
+    KuaiShouVideoGet getVideoByPhotoId(Long photo_id);
 }

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

@@ -0,0 +1,25 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouVideoRelateCreatives;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 频库-视频关联创意数查询
+ * @Author: jeecg-boot
+ * @Date: 2021-01-12
+ * @Version: V1.0
+ */
+public interface IKuaishouVideoRelateCreativesService extends IService<KuaishouVideoRelateCreatives> {
+
+    Result pushVideo(JSONObject data);
+
+    void videoRelateCreatives(Long accountId, JSONArray photoIds, Map<String, Object> statdateMap);
+
+    List<JSONObject> getVideoListByMap(Map<String, Object> requestMap);
+}

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

@@ -30,7 +30,6 @@ public class KuaiShouCampaignServiceImpl extends ServiceImpl<KuaiShouCampaignMap
     }
 
 
-
     /**
      * 获取创意
      *
@@ -66,4 +65,15 @@ public class KuaiShouCampaignServiceImpl extends ServiceImpl<KuaiShouCampaignMap
         return campaignMapper.queryCampaignIdByAccountId(accountId);
     }
 
+    @Override
+    public KuaiShouCampaign getCampaignByAccountAndCampaign(Long accountId, Long campaignId) {
+        QueryWrapper<KuaiShouCampaign> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("campaign_id", campaignId);
+        queryWrapper.orderByDesc("create_time");
+        queryWrapper.last("limit 1");
+        KuaiShouCampaign campaign = campaignMapper.selectOne(queryWrapper);
+        return campaign;
+    }
+
 }

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

@@ -117,6 +117,17 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
         return groupMapper.queryUnitInfoByCampaignId(accountId, campaignId);
     }
 
+    @Override
+    public KuaiShouGroup selectGroupByUnitId(Long accountId, Long unitId) {
+        QueryWrapper<KuaiShouGroup> groupQueryWrapper = new QueryWrapper<>();
+        groupQueryWrapper.eq("account_id", accountId);
+        groupQueryWrapper.eq("unit_id", unitId);
+        groupQueryWrapper.orderByDesc("create_time");
+        groupQueryWrapper.last("limit 1");
+        KuaiShouGroup group = groupMapper.selectOne(groupQueryWrapper);
+        return group;
+    }
+
 
     @Override
     public void getGroupByUnitId(String accessToken, Long accountId, Long unitId) {

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

@@ -289,6 +289,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
             executorService.submit(new Runnable() {
                 @Override
                 public void run() {
+
                     Long accountId = template.getAccountId();
                     CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
                     if (Check.isNull(token)) {
@@ -416,6 +417,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
                     } catch (InterruptedException e) {
                         e.printStackTrace();
                     }
+
                 }
             });
         }

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

@@ -105,7 +105,12 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
     }
 
     @Override
-    public KuaiShouReportDailyMaterial getEtlDataByParams(String signature, String date) {
-        return dailyMaterialMapper.getEtlDataByParams(signature,date);
+    public KuaiShouReportDailyMaterial getEtlDataByParams(String signature, String date,Long projectId) {
+        return dailyMaterialMapper.getEtlDataByParams(signature,date,projectId);
+    }
+
+    @Override
+    public List<KuaiShouReportDailyMaterial> getSignatureByDateGroupByProjectId(String date) {
+        return dailyMaterialMapper.getSignatureByDateGroupByProjectId(date);
     }
 }

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

@@ -22,8 +22,6 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 
 /**
  * @Description: 快手-获取视频接口
@@ -122,13 +120,13 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     }
 
     @Override
-    public List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId,Integer aiStatus) {
-        QueryWrapper<KuaiShouVideoGet>queryWrapper = new QueryWrapper<>();
-        if(null!=accountId&&accountId!=0){
-            queryWrapper.eq("account_id",accountId);
+    public List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId, Integer aiStatus) {
+        QueryWrapper<KuaiShouVideoGet> queryWrapper = new QueryWrapper<>();
+        if (null != accountId && accountId != 0) {
+            queryWrapper.eq("account_id", accountId);
         }
-        if(null!=aiStatus&&aiStatus!=0){
-            queryWrapper.eq("ai_status",aiStatus);
+        if (null != aiStatus && aiStatus != 0) {
+            queryWrapper.eq("ai_status", aiStatus);
         }
         queryWrapper.orderByDesc("stat_date");
         return this.list(queryWrapper);
@@ -136,12 +134,12 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
 
 
     @Override
-    public List<KuaiShouVideoGet>getNewVideoDescDate(Long accountId,Integer newVideoCnt){
-        QueryWrapper<KuaiShouVideoGet>queryWrapper = new QueryWrapper<>();
-        if(null!=accountId&&accountId!=0){
-            queryWrapper.eq("account_id",accountId);
+    public List<KuaiShouVideoGet> getNewVideoDescDate(Long accountId, Integer newVideoCnt) {
+        QueryWrapper<KuaiShouVideoGet> queryWrapper = new QueryWrapper<>();
+        if (null != accountId && accountId != 0) {
+            queryWrapper.eq("account_id", accountId);
         }
-        if(null!=newVideoCnt && newVideoCnt>0){
+        if (null != newVideoCnt && newVideoCnt > 0) {
             queryWrapper.orderByDesc("stat_date");
             queryWrapper.last("limit " + newVideoCnt);
         }
@@ -150,16 +148,36 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
 
 
     @Override
-    public List<KuaiShouVideoGet>getNewVideoBetweenTime(Long accountId,String startTime, String endTime){
-        QueryWrapper<KuaiShouVideoGet>queryWrapper = new QueryWrapper<>();
-        if(null!=accountId&&accountId!=0){
-            queryWrapper.eq("account_id",accountId);
+    public List<KuaiShouVideoGet> getNewVideoBetweenTime(Long accountId, String startTime, String endTime) {
+        QueryWrapper<KuaiShouVideoGet> queryWrapper = new QueryWrapper<>();
+        if (null != accountId && accountId != 0) {
+            queryWrapper.eq("account_id", accountId);
         }
-        if(null != startTime && null != endTime){
-            queryWrapper.le("stat_date",endTime);
-            queryWrapper.gt("stat_date",startTime);
+        if (null != startTime && null != endTime) {
+            queryWrapper.le("stat_date", endTime);
+            queryWrapper.gt("stat_date", startTime);
         }
         return this.list(queryWrapper);
     }
 
+    @Override
+    public List<JSONObject> getVideoListByMap(Map<String, Object> requestMap) {
+        return videoGetMapper.getVideoListByMap(requestMap);
+    }
+
+
+    @Override
+    public List<KuaiShouVideoGet> selectPhotoIdsByAccountId(Long accountId) {
+        return videoGetMapper.selectPhotoIdsByAccountId(accountId);
+    }
+
+    @Override
+    public KuaiShouVideoGet getVideoByPhotoId(Long photo_id) {
+        QueryWrapper<KuaiShouVideoGet> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("photo_id", photo_id);
+        queryWrapper.last("limit 1");
+        KuaiShouVideoGet videoGet = videoGetMapper.selectOne(queryWrapper);
+        return videoGet;
+    }
+
 }

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

@@ -698,10 +698,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             var creative = JSONObject.toJavaObject(detailJson, KuaishouReportDailyCreative.class);
             creative.setAccountId(token.getAccountId());
             // 取得MD5
-            String signature = creativeService.getCodeByCreativeId(creative.getCreativeId());
+         /*   String signature = creativeService.getCodeByCreativeId(creative.getCreativeId());
             if (!Check.isNull(signature)) {
                 creative.setSignature(signature);
-            }
+            }*/
             dailyCreativeService.saveOrUpdate(creative);
         }
         getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, campaignIds, creativeIds, page + 1);
@@ -959,19 +959,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     returnMap.put("campaignId", campaignId);
                     returnMap.put("success", true);
                     // 创建成功 拉取广告组信息
+                    Thread.sleep(100);
+                    getCampaign(accessToken, advertiserId, campaignId);
 
-                    Thread thread = new Thread() {
-                        @Override
-                        public void run() {
-                            try {
-                                Thread.sleep(500);
-                            } catch (InterruptedException e) {
-                                e.printStackTrace();
-                            }
-                            getCampaign(accessToken, advertiserId, campaignId);
-                        }
-                    };
-                    thread.start();
 
                 } else {
                     log.error("创建广告计划失败,advertiser_id:{},返回信息:{}", advertiserId, resultJson);
@@ -1028,21 +1018,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     if (!Check.isNull(dataJson)) {
                         Long unitId = dataJson.getLong("unit_id");
-
-                        Thread thread = new Thread() {
-                            @Override
-                            public void run() {
-                                try {
-                                    Thread.sleep(500);
-                                    getKuaiShouGroupService.getGroupByUnitId(accessToken, advertiserId, unitId);
-                                } catch (InterruptedException e) {
-                                    e.printStackTrace();
-                                }
-
-                            }
-
-                        };
-                        thread.start();
+                        Thread.sleep(100);
+                        getKuaiShouGroupService.getGroupByUnitId(accessToken, advertiserId, unitId);
                         returnMap.put("code", 0);
                         returnMap.put("message", "success");
                         returnMap.put("unitId", unitId);
@@ -1155,7 +1132,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
-
     /**
      * 获取 单条 广告计划数据
      *
@@ -1222,7 +1198,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     public JSONArray getGroupList(CtopOauthToken token, Long campaignId, Date startDate,
-                                  Date endDate,int time_filter_type){
+                                  Date endDate, int time_filter_type) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
         JSONObject param = new JSONObject();
         param.put("advertiser_id", token.getAccountId());
@@ -1231,7 +1207,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             param.put("end_date", DateUtils.formatDate(endDate));
         }
 
-        param.put("campaign_id",campaignId);
+        param.put("campaign_id", campaignId);
 
         Map<String, String> headers = new HashMap<>();
         headers.put("Access-Token", token.getAccessToken());
@@ -1257,7 +1233,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
-
     @Override
     public void getGroupList(CtopOauthToken token, Date startDate, Date endDate) {
         getGroupListByPage(token, startDate, endDate, 1);
@@ -1418,8 +1393,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
-
-    public JSONArray getCreativeList(CtopOauthToken token, Long unitId, Date startDate, Date endDate,int timeFilterType){
+    public JSONArray getCreativeList(CtopOauthToken token, Long unitId, Date startDate, Date endDate, int timeFilterType) {
         Long advertiserId = token.getAccountId();
         String accessToken = token.getAccessToken();
 
@@ -1434,8 +1408,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             param.put("end_date", DateUtils.formatDate(endDate));
         }
 
-        param.put("unit_id",unitId);
-        param.put("time_filter_type",timeFilterType);
+        param.put("unit_id", unitId);
+        param.put("time_filter_type", timeFilterType);
 
         String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
         JSONObject resultJson = JSONObject.parseObject(result);
@@ -1457,7 +1431,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
-
     @Override
     public void getCreativeList(CtopOauthToken token, Date startDate, Date endDate) {
         getCreativeListByPage(token.getAccessToken(), token.getAccountId(), startDate, endDate, 1);
@@ -2128,7 +2101,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
                 log.error("快手创建广告创意返回内容为空,advertiser_id:{},入参:{}", advertiserId, requestJson);
                 returnMap.put("code", -1);
-                returnMap.put("message", "上传图片异常");
+                returnMap.put("message", "result is null");
                 returnMap.put("desc", "result is null");
                 returnMap.put("success", false);
             }
@@ -2949,6 +2922,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         }
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
+//        System.out.println(resultJson.toJSONString());
         if (Check.isNull(resultJson)) {
             return;
         }

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

@@ -0,0 +1,148 @@
+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.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouVideoRelateCreatives;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouVideoRelateCreativesMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 频库-视频关联创意数查询
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-01-12
+ */
+@Slf4j
+@Service
+public class KuaishouVideoRelateCreativesServiceImpl extends ServiceImpl<KuaishouVideoRelateCreativesMapper, KuaishouVideoRelateCreatives> implements IKuaishouVideoRelateCreativesService {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private KuaishouVideoRelateCreativesMapper kuaishouVideoRelateCreativesMapper;
+
+    /**
+     * 视频库-推送视频
+     *
+     * @param
+     * @return com.alibaba.fastjson.JSONArray
+     * @throws
+     * @author ZHAOXA
+     */
+    @Override
+    public Result pushVideo(JSONObject data) {
+        try {
+            Long accountId = data.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                return Result.error("请选择广告主");
+            }
+            JSONArray photoIds = data.getJSONArray("photoIds");
+            if (Check.isNull(photoIds)) {
+                return Result.error("请选择视频集");
+            }
+            if (photoIds.size() > 10) {
+                return Result.error("选择视频应少于10条");
+            }
+            JSONArray shareAdvertiserIds = data.getJSONArray("shareAdvertiserIds");
+            if (Check.isNull(shareAdvertiserIds)) {
+                return Result.error("请选择推送账户");
+            }
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_SHARE;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token.getAccessToken());
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", accountId);
+            params.put("photo_ids", photoIds);
+            params.put("share_advertiser_ids", shareAdvertiserIds);
+            System.out.println(params);
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    return Result.ok(resultJson.getJSONObject("data"));
+                } else {
+                    log.info("视频库-推送视频失败,accountId:{},返回信息:{}", accountId, resultJson);
+                    return Result.error("视频库-推送视频失败," + resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            log.error("视频库-推送视频失败", e);
+        }
+        return Result.error("视频库-推送视频失败");
+    }
+
+    /**
+     * 频库-视频关联创意数查询
+     *
+     * @param
+     * @return boolean
+     * @throws
+     * @author ZHAOXA
+     */
+    @Override
+    public void videoRelateCreatives(Long accountId, JSONArray photoIds, Map<String, Object> statdateMap) {
+        try {
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            for (int i = 0; i < photoIds.size(); i++) {
+                String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_RELATE_CREATIVES;
+                Map<String, String> header = new HashMap<>();
+                header.put("Access-Token", token.getAccessToken());
+                header.put("Content-Type", "application/json");
+                JSONObject params = new JSONObject();
+                params.put("advertiser_id", accountId);
+                params.put("photo_ids", photoIds.getJSONArray(i));
+                String result = HttpUtils.httpPostRequest(url, params, header);
+                JSONObject resultJson = JSONObject.parseObject(result);
+                if (!Check.isNull(resultJson)) {
+                    Integer code = resultJson.getInteger("code");
+                    if (code == 0) {
+                        JSONObject data = resultJson.getJSONObject("data");
+                        JSONArray relatedCreatives = data.getJSONArray("related_creatives");
+                        if (!Check.isNull(relatedCreatives) && relatedCreatives.size() > 0) {
+                            List<KuaishouVideoRelateCreatives> videolist = new ArrayList<>();
+                            for (int j = 0; j < relatedCreatives.size(); j++) {
+                                KuaishouVideoRelateCreatives k = new KuaishouVideoRelateCreatives();
+                                JSONObject object = relatedCreatives.getJSONObject(j);
+                                k.setAccountId(accountId);
+                                k.setPhotoId(object.getLong("photo_id"));
+                                k.setCreativeCount(object.getInteger("creative_count"));
+                                k.setStatDate((Date) statdateMap.get(object.getString("photo_id")));
+                                videolist.add(k);
+                            }
+                            kuaishouVideoRelateCreativesMapper.insertBatch(videolist);
+                        }
+                    } else {
+                        log.info("频库-视频关联创意数查询失败,accountId:{},返回信息:{}", accountId, resultJson);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error("频库-视频关联创意数查询失败", e);
+        }
+    }
+
+    @Override
+    public List<JSONObject> getVideoListByMap(Map<String, Object> requestMap) {
+        return kuaishouVideoRelateCreativesMapper.getVideoListByMap(requestMap);
+    }
+}

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

@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
+import com.baomidou.mybatisplus.annotation.TableField;
 
 import java.util.Date;
 
@@ -416,4 +417,7 @@ public class KuaiShouReportDailyMaterial {
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "修改时间")
     private Date updateTime;
+
+    @TableField(exist = false)
+    private Long projectId;
 }

+ 83 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouProjectVideoEtlInfo.java

@@ -0,0 +1,83 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 快手视频项目消耗数据清洗
+ * @author jeecg-boot
+ * @date   2021-01-08
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_kuaishou_project_video_etl_info")
+public class KuaishouProjectVideoEtlInfo {
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**视频唯一标识*/
+	private String videoCode;
+	/**项目id*/
+	private Long projectId;
+	/**初次产生消耗时间*/
+	private String stateDate;
+	/**url*/
+	private String url;
+	/**coverUrl*/
+	private String coverUrl;
+	/**渠道类型*/
+	private String channelType;
+	/**companyName*/
+	private String companyName;
+	/**planId*/
+	private String planId;
+	/**planName*/
+	private String planName;
+	/**clipId*/
+	private String clipId;
+	/**clipName*/
+	private String clipName;
+	/**shotId*/
+	private String shotId;
+	/**shotName*/
+	private String shotName;
+	/**singleWeekCost*/
+	private BigDecimal singleWeekCost;
+	/**twoWeekCost*/
+	private BigDecimal twoWeekCost;
+	/**fourWeekCost*/
+	private BigDecimal fourWeekCost;
+	/**总消耗*/
+	private BigDecimal totalCost;
+	/**photoShow*/
+	private Long photoShow;
+	/**photoClick*/
+	private Long photoClick;
+	/**aclick*/
+	private Long aclick;
+	/**bclick*/
+	private Long bclick;
+	/**createTime*/
+	private Date createTime;
+	/**updateTime*/
+	private Date updateTime;
+
+	public KuaishouProjectVideoEtlInfo(KuaiShouReportDailyMaterial nowData,Long projectId) {
+		this.url = nowData.getPhotoUrl();
+		this.videoCode  = nowData.getSignature();
+		this.stateDate = nowData.getStatDate();
+		this.channelType = nowData.getChannelType()+"";
+		this.coverUrl = nowData.getCoverUrl();
+		this.totalCost = nowData.getCharge();
+		this.photoClick = nowData.getPhotoClick();
+		this.photoShow =  nowData.getPhotoShow();
+		this.aclick = nowData.getAclick();
+		this.bclick = nowData.getBclick();
+		this.projectId = projectId;
+	}
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouProjectVideoEtlInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手视频项目消耗数据清洗
+ * @author: jeecg-boot
+ * @date:   2021-01-08
+ * @cersion: V1.0
+ */
+public interface KuaishouProjectVideoEtlInfoMapper extends BaseMapper<KuaishouProjectVideoEtlInfo> {
+
+}

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

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouProjectVideoEtlInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 快手视频项目消耗数据清洗
+ * @Author: jeecg-boot
+ * @Date:   2021-01-08
+ * @Version: V1.0
+ */
+public interface IKuaishouProjectVideoEtlInfoService extends IService<KuaishouProjectVideoEtlInfo> {
+
+    KuaishouProjectVideoEtlInfo getByProjectVideoEtlInfoByParams(String signature, Long projectId);
+}

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

@@ -14,5 +14,7 @@ import java.util.Date;
 public interface IKuaishouVideoEtlInfoService extends IService<KuaishouVideoEtlInfo> {
     void etlKuaishouVideoInfo(Date date);
 
+    void etlKuaishouVideoInfoGroupByProjectId(Date date);
+
     KuaishouVideoEtlInfo getBySignature(String signature);
 }

+ 31 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouProjectVideoEtlInfoServiceImpl.java

@@ -0,0 +1,31 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouProjectVideoEtlInfo;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouProjectVideoEtlInfoMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouProjectVideoEtlInfoService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 快手视频项目消耗数据清洗
+ * @author jeecg-boot
+ * @date   2021-01-08
+ * @version V1.0
+ */
+@Service
+public class KuaishouProjectVideoEtlInfoServiceImpl extends ServiceImpl<KuaishouProjectVideoEtlInfoMapper, KuaishouProjectVideoEtlInfo> implements IKuaishouProjectVideoEtlInfoService {
+
+    @Override
+    public KuaishouProjectVideoEtlInfo getByProjectVideoEtlInfoByParams(String signature, Long projectId) {
+        QueryWrapper<KuaishouProjectVideoEtlInfo>queryWrapper = new QueryWrapper<>();
+        if(null!=signature&&!signature.trim().equals("")){
+            queryWrapper.eq("video_code",signature);
+        }
+        if(null!=projectId&&projectId!=0){
+            queryWrapper.eq("project_id",projectId);
+        }
+        queryWrapper.last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+}

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

@@ -3,8 +3,10 @@ package cn.com.ctop.kuaishou.modules.report.service.impl;
 import cn.com.ctop.common.module.service.IMaterialAscriptionService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouReportDailyMaterialService;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouProjectVideoEtlInfo;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouVideoEtlInfo;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouVideoEtlInfoMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouProjectVideoEtlInfoService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -51,7 +53,7 @@ public class KuaishouVideoEtlInfoServiceImpl extends ServiceImpl<KuaishouVideoEt
 
                         String signature = material.getSignature();
                         KuaishouVideoEtlInfo etlInfo = this.getBySignature(signature);
-                        KuaiShouReportDailyMaterial nowData = dailyMaterialService.getEtlDataByParams(signature,date);
+                        KuaiShouReportDailyMaterial nowData = dailyMaterialService.getEtlDataByParams(signature,date,null);
                         String minDate = nowData.getStatDate();
                         Integer days = DateUtils.getdaysOfTwoDate(minDate,date);
                         if(null == etlInfo){
@@ -169,6 +171,118 @@ public class KuaishouVideoEtlInfoServiceImpl extends ServiceImpl<KuaishouVideoEt
     }
 
     @Autowired
+    private IKuaishouProjectVideoEtlInfoService kuaishouProjectVideoEtlInfoService;
+    @Override
+    public void etlKuaishouVideoInfoGroupByProjectId(Date getDate) {
+        String date = DateUtils.formatDate(getDate);
+        //1:查询单当日视频信息--以项目汇总
+        List<KuaiShouReportDailyMaterial> materials = dailyMaterialService.getSignatureByDateGroupByProjectId(date);
+        if(null!=materials&&!materials.isEmpty()){
+            CountDownLatch countDownLatch= new CountDownLatch(materials.size());
+            materials.forEach(material->{
+                executorService.submit(()->{
+                    try {
+                        if(null == material.getSignature()||material.getSignature().trim().equals("")){
+                            return;
+                        }
+                        if(null == material.getProjectId()||material.getProjectId() == 0){
+                            return;
+                        }
+
+                        String signature = material.getSignature();
+                        Long projectId = material.getProjectId();
+                        KuaishouProjectVideoEtlInfo etlInfo = kuaishouProjectVideoEtlInfoService.getByProjectVideoEtlInfoByParams(signature,projectId);
+                        KuaiShouReportDailyMaterial nowData = dailyMaterialService.getEtlDataByParams(signature,date,projectId);
+                        String minDate = nowData.getStatDate();
+                        Integer days = DateUtils.getdaysOfTwoDate(minDate,date);
+                        if(null == etlInfo){
+                            //第一次查询的数据
+                            etlInfo = new KuaishouProjectVideoEtlInfo(nowData,projectId);
+                            JSONObject ascription =  materialAscriptionService.getDetailByCode(signature);
+                            String planId = null;
+                            if(null!=ascription){
+                                planId = ascription.getString("planId");
+                                if(null!=planId&&!planId.trim().equals("")){
+                                    etlInfo.setPlanId(planId);
+                                }
+                                String planName =  ascription.getString("planName");
+                                if(null!=planName&&!planName.trim().equals("")){
+                                    etlInfo.setPlanName(planName);
+                                }
+                                String clipId = ascription.getString("clipId");
+                                if(null!=clipId&&!clipId.trim().equals("")){
+                                    etlInfo.setClipId(clipId);
+                                }
+                                String clipName = ascription.getString("clipName");
+                                if(null!=clipName&&!clipName.trim().equals("")){
+                                    etlInfo.setClipName(clipName);
+                                }
+                                String shotId = ascription.getString("shotId");
+                                if(null!=shotId&&!shotId.trim().equals("")){
+                                    etlInfo.setShotId(shotId);
+                                }
+                                String shotName = ascription.getString("shotName");
+                                if(null!=shotName&&!shotName.trim().equals("")){
+                                    etlInfo.setShotName(shotName);
+                                }
+                            }
+                            if(null!=planId){
+                                String companyName = kuaishouVideoEtlInfoMapper.getCompanyNameByUserId(planId);
+                                if (null!=companyName&&!companyName.trim().equals("")){
+                                    etlInfo.setCompanyName(companyName);
+                                }
+                            }
+                            //计算投放总天数
+                            if(days <= 7){
+                                etlInfo.setSingleWeekCost(nowData.getCharge());
+                            }
+                            if(days <= 14){
+                                etlInfo.setTwoWeekCost(nowData.getCharge());
+                            }
+                            if(days <= 28){
+                                etlInfo.setFourWeekCost(nowData.getCharge());
+                            }
+                            etlInfo.setCreateTime(new Date());
+                            etlInfo.setUpdateTime(new Date());
+                            kuaishouProjectVideoEtlInfoService.save(etlInfo);
+                        }else{
+                            //只需要更新汇总数据
+                            etlInfo.setTotalCost(nowData.getCharge());
+                            etlInfo.setAclick(nowData.getAclick());
+                            etlInfo.setBclick(nowData.getBclick());
+                            etlInfo.setPhotoClick(nowData.getPhotoClick());
+                            etlInfo.setPhotoShow(nowData.getPhotoShow());
+                            etlInfo.setUpdateTime(new Date());
+                            //计算投放总天数
+                            if(days <= 7){
+                                etlInfo.setSingleWeekCost(nowData.getCharge());
+                            }
+                            if(days <= 14){
+                                etlInfo.setTwoWeekCost(nowData.getCharge());
+                            }
+                            if(days <= 28){
+                                etlInfo.setFourWeekCost(nowData.getCharge());
+                            }
+                            kuaishouProjectVideoEtlInfoService.updateById(etlInfo);
+                        }
+                    }catch (Exception e){
+
+                    }finally {
+                        countDownLatch.countDown();
+                    }
+                });
+            });
+
+            try {
+                countDownLatch.await();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            log.info("{}数据获取完成",date);
+        }
+    }
+
+    @Autowired
     private IMaterialAscriptionService materialAscriptionService;
     @Override
     public KuaishouVideoEtlInfo getBySignature(String signature) {

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

@@ -166,20 +166,24 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
             wrapper.eq("unit_id",unitDetail.getLong("unit_id"));
             KuaiShouGroup group = kuaiShouGroupService.getOne(wrapper);
             if(group!=null){
-                unit.setId(unitDetail.getLong("unit_id"));
-                unit.setAccountId(accountId);
-                unit.setPlanId(unitDetail.getLong("campaign_id"));
-                unit.setUnitId(unitDetail.getLong("unit_id"));
-                unit.setUnitName(unitDetail.getString("unit_name"));
-                unit.setCharge(unitDetail.getBigDecimal("charge"));
-                //未知优化目标数据存空
-                if(group.getOcpxActionType()!=0){
-                    unit.setConvertNum(handleConvertNum(group.getOcpxActionType(),unitDetail));
-                    if(null!=unit.getConvertNum()&&unit.getConvertNum()!=0){
-                        unit.setConvertCost(unitDetail.getBigDecimal("charge").divide(BigDecimal.valueOf(unit.getConvertNum()), 2, RoundingMode.HALF_UP));
+                Integer status = group.getStatus();
+                Integer putStatus = group.getPutStatus();
+                if((status == 20 || status == 19) && putStatus == 1){
+                    unit.setId(unitDetail.getLong("unit_id"));
+                    unit.setAccountId(accountId);
+                    unit.setPlanId(unitDetail.getLong("campaign_id"));
+                    unit.setUnitId(unitDetail.getLong("unit_id"));
+                    unit.setUnitName(unitDetail.getString("unit_name"));
+                    unit.setCharge(unitDetail.getBigDecimal("charge"));
+                    //未知优化目标数据存空
+                    if(group.getOcpxActionType()!=0){
+                        unit.setConvertNum(handleConvertNum(group.getOcpxActionType(),unitDetail));
+                        if(null!=unit.getConvertNum()&&unit.getConvertNum()!=0){
+                            unit.setConvertCost(unitDetail.getBigDecimal("charge").divide(BigDecimal.valueOf(unit.getConvertNum()), 2, RoundingMode.HALF_UP));
+                        }
                     }
+                    batch.add(unit);
                 }
-                batch.add(unit);
             }
 
         });

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

@@ -0,0 +1,76 @@
+package cn.com.ctop.toutiao.modules.report.entity;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 快手视频项目消耗数据清洗
+ * @author jeecg-boot
+ * @date   2021-01-08
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_bytedance_project_video_etl_info")
+public class BytedanceProjectVideoEtlInfo {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**视频唯一标识*/
+	private String videoCode;
+	/**项目id*/
+	private Long projectId;
+	/**初次产生消耗时间*/
+	private String stateDate;
+	/**url*/
+	private String url;
+	/**coverUrl*/
+	private String coverUrl;
+	/**companyName*/
+	private String companyName;
+	/**planId*/
+	private String planId;
+	/**planName*/
+	private String planName;
+	/**clipId*/
+	private String clipId;
+	/**clipName*/
+	private String clipName;
+	/**shotId*/
+	private String shotId;
+	/**shotName*/
+	private String shotName;
+	/**singleWeekCost*/
+	private java.math.BigDecimal singleWeekCost;
+	/**twoWeekCost*/
+	private BigDecimal twoWeekCost;
+	/**fourWeekCost*/
+	private BigDecimal fourWeekCost;
+	/**总消耗*/
+	private BigDecimal totalCost;
+	/**clickNum*/
+	private Integer clickNum;
+	/**showNum*/
+	private Integer showNum;
+	/**activeNum*/
+	private Integer activeNum;
+	/**convertNum*/
+	private Integer convertNum;
+	/**createTime*/
+	private Date createTime;
+	/**updateTime*/
+	private Date updateTime;
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.toutiao.modules.report.mapper;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceProjectVideoEtlInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手视频项目消耗数据清洗
+ * @author: jeecg-boot
+ * @date:   2021-01-08
+ * @cersion: V1.0
+ */
+public interface BytedanceProjectVideoEtlInfoMapper extends BaseMapper<BytedanceProjectVideoEtlInfo> {
+
+}

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

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

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.toutiao.modules.report.service;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceProjectVideoEtlInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 快手视频项目消耗数据清洗
+ * @Author: jeecg-boot
+ * @Date:   2021-01-08
+ * @Version: V1.0
+ */
+public interface IBytedanceProjectVideoEtlInfoService extends IService<BytedanceProjectVideoEtlInfo> {
+
+}

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

@@ -15,4 +15,6 @@ public interface IBytedanceVideoEtlInfoService extends IService<BytedanceVideoEt
     void etlBytedanceVideoInfo(Date date);
 
     BytedanceVideoEtlInfo getBySignature(String signature);
+
+    void etlBytedanceVideoInfoByProjectId(Date getDate);
 }

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

@@ -0,0 +1,18 @@
+package cn.com.ctop.toutiao.modules.report.service.impl;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceProjectVideoEtlInfo;
+import cn.com.ctop.toutiao.modules.report.mapper.BytedanceProjectVideoEtlInfoMapper;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceProjectVideoEtlInfoService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 快手视频项目消耗数据清洗
+ * @author jeecg-boot
+ * @date   2021-01-08
+ * @version V1.0
+ */
+@Service
+public class BytedanceProjectVideoEtlInfoServiceImpl extends ServiceImpl<BytedanceProjectVideoEtlInfoMapper, BytedanceProjectVideoEtlInfo> implements IBytedanceProjectVideoEtlInfoService {
+
+}

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

@@ -176,4 +176,136 @@ public class BytedanceVideoEtlInfoServiceImpl extends ServiceImpl<BytedanceVideo
         queryWrapper.eq("video_code",signature).last("limit 1");
         return this.getOne(queryWrapper);
     }
+
+    @Override
+    public void etlBytedanceVideoInfoByProjectId(Date getDate) {
+        String date = DateUtils.formatDate(getDate);
+        //1:查询单当日视频信息
+        List<BytedanceVideoEtlInfo> materials = materialDailyService.getSignatureByDate(date);
+        if(null!=materials&&!materials.isEmpty()){
+            CountDownLatch countDownLatch= new CountDownLatch(materials.size());
+            materials.forEach(material->{
+                executorService.submit(()->{
+                    try {
+                        if(null == material.getVideoCode()||material.getVideoCode().trim().equals("")){
+                            return;
+                        }
+                        String signature = material.getVideoCode();
+                        BytedanceVideoEtlInfo etlInfo = this.getBySignature(signature);
+                        BytedanceVideoEtlInfo nowData = materialDailyService.getEtlDataByParams(signature,date);
+                        String minDate = nowData.getStateDate();
+                        Integer days = DateUtils.getdaysOfTwoDate(minDate,date);
+                        if(null == etlInfo){
+                            //第一次查询的数据
+                            etlInfo = nowData;
+                            BigDecimal totalCost = etlInfo.getTotalCost();
+                            JSONObject ascription =  materialAscriptionService.getDetailByCode(signature);
+                            String planId = null;
+                            if(null!=ascription){
+                                planId = ascription.getString("planId");
+                                if(null!=planId&&!planId.trim().equals("")){
+                                    etlInfo.setPlanId(planId);
+                                }
+                                String planName =  ascription.getString("planName");
+                                if(null!=planName&&!planName.trim().equals("")){
+                                    etlInfo.setPlanName(planName);
+                                }
+                                String clipId = ascription.getString("clipId");
+                                if(null!=clipId&&!clipId.trim().equals("")){
+                                    etlInfo.setClipId(clipId);
+                                }
+                                String clipName = ascription.getString("clipName");
+                                if(null!=clipName&&!clipName.trim().equals("")){
+                                    etlInfo.setClipName(clipName);
+                                }
+                                String shotId = ascription.getString("shotId");
+                                if(null!=shotId&&!shotId.trim().equals("")){
+                                    etlInfo.setShotId(shotId);
+                                }
+                                String shotName = ascription.getString("shotName");
+                                if(null!=shotName&&!shotName.trim().equals("")){
+                                    etlInfo.setShotName(shotName);
+                                }
+                            }
+                            if(null!=planId){
+                                String companyName = userAllocationMapper.getCompanyNameByUserId(planId);
+                                if (null!=companyName&&!companyName.trim().equals("")){
+                                    etlInfo.setCompanyName(companyName);
+                                }
+                            }
+                            //计算投放总天数
+                            if(days <= 7){
+                                etlInfo.setSingleWeekCost(nowData.getTotalCost());
+                            }
+                            if(days <= 14){
+                                etlInfo.setTwoWeekCost(nowData.getTotalCost());
+                            }
+                            if(days <= 28){
+                                etlInfo.setFourWeekCost(nowData.getTotalCost());
+                            }
+                            //计算是否有效,爆款
+                            if(totalCost.compareTo(new BigDecimal("5000"))>0){
+                                //此刻成为有效
+                                etlInfo.setEffectDate(date);
+                                etlInfo.setEffectDayNum(days);
+                            }
+                            if(totalCost.compareTo(new BigDecimal("100000"))>0){
+                                //此刻成为爆款
+                                etlInfo.setFaddishDate(date);
+                                etlInfo.setFaddishDayNum(days);
+                            }
+                            etlInfo.setCreateTime(new Date());
+                            etlInfo.setUpdateTime(new Date());
+                            this.save(etlInfo);
+                        }else{
+                            //只需要更新汇总数据
+                            etlInfo.setTotalCost(nowData.getTotalCost());
+                            BigDecimal totalCost = etlInfo.getTotalCost();
+                            etlInfo.setClickNum(nowData.getClickNum());
+                            etlInfo.setShowNum(nowData.getShowNum());
+                            etlInfo.setActiveNum(nowData.getActiveNum());
+                            etlInfo.setConvertNum(nowData.getConvertNum());
+                            etlInfo.setUpdateTime(new Date());
+                            //计算投放总天数
+                            if(days <= 7){
+                                etlInfo.setSingleWeekCost(nowData.getTotalCost());
+                            }
+                            if(days <= 14){
+                                etlInfo.setTwoWeekCost(nowData.getTotalCost());
+                            }
+                            if(days <= 28){
+                                etlInfo.setFourWeekCost(nowData.getTotalCost());
+                            }
+                            if(null == etlInfo.getEffectDayNum()){
+                                if(totalCost.compareTo(new BigDecimal("5000"))>0){
+                                    //此刻成为有效
+                                    etlInfo.setEffectDate(date);
+                                    etlInfo.setEffectDayNum(days);
+                                }
+                            }
+                            if(null == etlInfo.getFaddishDayNum()){
+                                if(totalCost.compareTo(new BigDecimal("100000"))>0){
+                                    //此刻成为爆款
+                                    etlInfo.setFaddishDate(date);
+                                    etlInfo.setFaddishDayNum(days);
+                                }
+                            }
+                            this.updateById(etlInfo);
+                        }
+                    }catch (Exception e){
+
+                    }finally {
+                        countDownLatch.countDown();
+                    }
+                });
+            });
+
+            try {
+                countDownLatch.await();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            log.info("{}数据获取完成",date);
+        }
+    }
 }