浏览代码

Merge remote-tracking branch 'origin/V1.1.3' into V1.1.3

zhaoxian 4 年之前
父节点
当前提交
200e0b7d46
共有 23 个文件被更改,包括 316 次插入126 次删除
  1. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java
  2. 18 7
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEtlVideoJob.java
  3. 5 47
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouMaterialControer.java
  4. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaiShouVideoLastTimeMapper.java
  5. 12 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaiShouVideoLastTimeMapper.xml
  6. 3 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaiShouVideoLastTimeService.java
  7. 17 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java
  8. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouVideoLastTimeServiceImpl.java
  9. 6 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateController.java
  10. 3 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouReportDailyMaterialMapper.java
  11. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouVideoGetMapper.java
  12. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml
  13. 38 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml
  14. 0 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouVideoRelateCreativesMapper.xml
  15. 8 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java
  16. 29 14
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java
  17. 62 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java
  18. 1 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  19. 1 35
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/entity/EtlKuaishouVideoInfo.java
  20. 0 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/EtlKuaishouVideoInfoServiceImpl.java
  21. 2 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaishouReportVideoDailyMapper.java
  22. 77 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportVideoDailyMapper.xml
  23. 5 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaishouReportVideoDailyServiceImpl.java

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

@@ -500,7 +500,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
             MaterialInfo info = new MaterialInfo();
             Long projectId = json.getLong("projectId");
             String code = json.getString("code");
-            info.setId(code + projectId);
+            info.setId(UUID.randomUUID().toString().replace("-", ""));
             info.setCode(code);
             if (!Check.isNull(json.getString("watermarkUrl"))) {
                 info.setWatermarkUrl(json.getString("watermarkUrl"));

+ 18 - 7
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEtlVideoJob.java

@@ -1,7 +1,7 @@
 package cn.com.ctop.job.kuaishou.handler;
 
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 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;
@@ -13,21 +13,32 @@ import java.util.Date;
 public class KuaishouEtlVideoJob {
     @Autowired
     private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+
     @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);
+        Date startDate = DateUtils.addDay(new Date(), -2);
+        for (int i = 0; i <= 2; i++) {
+            Date getDate = DateUtils.addDay(startDate, i);
             kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
         }
     }
 
     @XxlJob("kuaishouEtlProjectVideoJob")
     public void kuaishouEtlProjectVideoJob() throws Exception {
-        Date startDate = DateUtils.addDay(new Date(),-2);
-        for(int i=0;i<=2;i++){
-            Date getDate = DateUtils.addDay(startDate,i);
+        Date startDate = DateUtils.addDay(new Date(), -2);
+        for (int i = 0; i <= 2; i++) {
+            Date getDate = DateUtils.addDay(startDate, i);
             kuaishouVideoEtlInfoService.etlKuaishouVideoInfoGroupByProjectId(getDate);
         }
     }
+
+    @XxlJob("kuaishouEtlVideoBaseInfoJob")
+    public void kuaishouEtlVideoBaseInfoJob() throws Exception {
+        String statDate = DateUtils.getStartTime(DateUtils.addDay(new Date(), -1));
+        videoGetService.etlVideoBaseInfoByStaDate(statDate);
+    }
+
+
 }

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

@@ -5,7 +5,6 @@ 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;
@@ -94,8 +93,6 @@ public class KuaiShouMaterialControer {
                 throw new Exception("未获取账号授权信息");
             }
             String appVersion = requestJson.getString("appVersion");
-            // String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-            //  iKuaishouInterfaceService.getVideoList(token, nowDate, nowDate);
             KuaiShouVideoLastTime videoLastTime = lastTimeService.getById(accountId);
             Date startTime;
             Date endDate = new Date();
@@ -147,7 +144,6 @@ public class KuaiShouMaterialControer {
      */
     @PostMapping(value = "/getHistoryVideoList")
     public JSONObject getHistoryVideoList(@RequestBody JSONObject requestJson) {
-        // log.info("获取历史素材入参:{}", requestJson);
         JSONObject returnJson = new JSONObject();
         try {
             if (Check.isNull(requestJson)) {
@@ -186,20 +182,7 @@ public class KuaiShouMaterialControer {
             }
             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("material_type", videoGet.getMaterialType());
-                        materialJson.put("channel_type", videoGet.getChannelType());
-                        materialJson.put("photo_name", videoGet.getPhotoName());
-                        List<String> imageList = lastTimeService.getImageListByMd5(signature);
-                        materialJson.put("imageList", imageList);
-                    }
-                }
+                materialList = videoGetService.getVideoInfoAndImageList(materialList);
                 returnJson.put("code", 0);
                 returnJson.put("message", "SUCCESS");
                 returnJson.put("data", materialList);
@@ -224,7 +207,7 @@ public class KuaiShouMaterialControer {
      */
     @PostMapping(value = "/getHistoryTopVideoList")
     public JSONObject getHistoryTopVideoList(@RequestBody JSONObject requestJson) {
-      //   log.info("获取历史Top素材入参:{}", requestJson);
+        //   log.info("获取历史Top素材入参:{}", requestJson);
         JSONObject returnJson = new JSONObject();
         try {
             if (Check.isNull(requestJson)) {
@@ -257,19 +240,7 @@ public class KuaiShouMaterialControer {
             }
             List<JSONObject> materialList = relateCreativesService.getHistoryTopVideoList(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("video_url", videoGet.getUrl());
-                        materialJson.put("material_type", videoGet.getMaterialType());
-                        materialJson.put("channel_type", videoGet.getChannelType());
-                        materialJson.put("photo_name", videoGet.getPhotoName());
-                        List<String> imageList = lastTimeService.getImageListByMd5(signature);
-                        materialJson.put("imageList", imageList);
-                    }
-                }
+                materialList = videoGetService.getVideoInfoAndImageList(materialList);
                 returnJson.put("code", 0);
                 returnJson.put("message", "SUCCESS");
                 returnJson.put("data", materialList);
@@ -294,7 +265,7 @@ public class KuaiShouMaterialControer {
      */
     @PostMapping(value = "/getCreateZeroVideoList")
     public JSONObject getHistoryCreateVideoList(@RequestBody JSONObject requestJson) {
-      //  log.info("获取关联创意数为0素材入参:{}", requestJson);
+        //  log.info("获取关联创意数为0素材入参:{}", requestJson);
         JSONObject returnJson = new JSONObject();
         try {
             if (Check.isNull(requestJson)) {
@@ -328,20 +299,7 @@ public class KuaiShouMaterialControer {
             }
             List<JSONObject> materialList = relateCreativesService.getVideoZeroListByMap(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());
-                        materialJson.put("material_type", videoGet.getMaterialType());
-                        materialJson.put("photo_name", videoGet.getPhotoName());
-                        List<String> imageList = lastTimeService.getImageListByMd5(signature);
-                        materialJson.put("imageList", imageList);
-                    }
-                }
+                materialList = videoGetService.getVideoInfoAndImageList(materialList);
                 returnJson.put("code", 0);
                 returnJson.put("message", "SUCCESS");
                 returnJson.put("data", materialList);

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

@@ -1,7 +1,9 @@
 package cn.com.ctop.kuaishou.modules.ai.mapper;
 
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouVideoLastTime;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -15,4 +17,6 @@ import java.util.List;
 public interface KuaiShouVideoLastTimeMapper extends BaseMapper<KuaiShouVideoLastTime> {
 
     List<String> getImageListByMd5(String signature);
+
+    List<JSONObject> getImageListByMd5List(@Param("codeList") List<String> videoCodeList);
 }

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

@@ -9,4 +9,16 @@
       limit 15
     </select>
 
+    <select id="getImageListByMd5List" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        video_signature,
+        signature
+        from ctop_material_cut_frame t1
+        where t1.video_signature in
+        <foreach collection="codeList" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
 </mapper>

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

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.ai.service;
 
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouVideoLastTime;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -14,4 +15,6 @@ import java.util.List;
 public interface IKuaiShouVideoLastTimeService extends IService<KuaiShouVideoLastTime> {
 
     List<String> getImageListByMd5(String signature);
+
+    List<JSONObject> getImageListByMd5List(List<String> videoCodeList);
 }

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

@@ -60,7 +60,22 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
             }
             String group_uuid = groupCreateJson.getString("group_uuid");
             try {
+
+                Integer unit_type = groupCreateJson.getInteger("unit_type");
+                if (Check.isNull(unit_type)) {
+                    throw new Exception("请选择创意制作方式");
+                }
+                if (unit_type == 4) { //  自定义创意
+                    if (Check.isNull(groupCreateJson.getJSONArray("creative_list"))) {
+                        throw new Exception("组下面创意信息不能为空");
+                    }
+                } else if (unit_type == 7) { // 程序化创意
+                    if (Check.isNull(groupCreateJson.getJSONObject("programCreative"))) {
+                        throw new Exception("组下程序化创意信息不能为空");
+                    }
+                }
                 JSONObject createJson = new JSONObject();
+                createJson.put("unit_type", groupCreateJson.getInteger("unit_type")); //创意制作方式
                 createJson.put("advertiser_id", oauthToken.getAccountId());
                 createJson.put("campaign_id", campaign_id);
                 createJson.put("unit_name", groupCreateJson.getString("unit_name")); // 组名称
@@ -98,11 +113,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                     sceneId = groupCreateJson.getJSONArray("scene_id").getInteger(0);
                     createJson.put("scene_id", groupCreateJson.getJSONArray("scene_id")); //资源位置
                 }
-                Integer unit_type = groupCreateJson.getInteger("unit_type");
-                if (Check.isNull(unit_type)) {
-                    throw new Exception("请选择创意制作方式");
-                }
-                createJson.put("unit_type", groupCreateJson.getInteger("unit_type")); //创意制作方式
+
                 if (!Check.isNull(groupCreateJson.getString("begin_time"))) {
                     createJson.put("begin_time", groupCreateJson.getString("begin_time")); //投放开始时间
                 }
@@ -436,6 +447,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                     returnJson.put("code", 0);
                     returnJson.put("message", "程序化创意创建成功");
                 } else {
+                    log.error("创建程序化创意失败,accountId:{},返回结果:{},入参:{}", oauthToken.getAccountId(), resultJson.getString("message"), programCreativeJson);
                     returnJson.put("code", -1);
                     returnJson.put("message", resultJson.getString("message"));
                 }

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

@@ -3,6 +3,7 @@ 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.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -25,4 +26,9 @@ public class KuaiShouVideoLastTimeServiceImpl extends ServiceImpl<KuaiShouVideoL
     public List<String> getImageListByMd5(String signature) {
         return videoLastTimeMapper.getImageListByMd5(signature);
     }
+
+    @Override
+    public List<JSONObject> getImageListByMd5List(List<String> videoCodeList) {
+        return videoLastTimeMapper.getImageListByMd5List(videoCodeList);
+    }
 }

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

@@ -56,7 +56,7 @@ public class KuaishouTemplateController {
     private ICtopOauthTokenService oauthTokenService;
 
 
-    @AutoLog(value = "快手-定向模板-分页列表查询")
+    /*@AutoLog(value = "快手-定向模板-分页列表查询")
     @ApiOperation(value = "快手-定向模板-分页列表查询", notes = "快手-定向模板-分页列表查询")
     @GetMapping(value = "/list")
     public Result<List<JSONObject>> list(Long accountId,Integer platformOs) {
@@ -65,7 +65,10 @@ public class KuaishouTemplateController {
         result.setSuccess(true);
         result.setResult(list);
         return result;
-    }
+    }*/
+
+
+
     /**
      * 分页列表查询
      *
@@ -77,7 +80,7 @@ public class KuaishouTemplateController {
      */
     @AutoLog(value = "快手-定向模板-分页列表查询")
     @ApiOperation(value = "快手-定向模板-分页列表查询", notes = "快手-定向模板-分页列表查询")
-    @GetMapping(value = "/queryPageList")
+    @GetMapping(value = "/list")
     public Result<IPage<KuaishouTemplate>> queryPageList(KuaishouTemplate kuaishouTemplate,
                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,

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

@@ -4,6 +4,7 @@ import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterialVo;
 import cn.com.ctop.kuaishou.modules.report.entity.VideoGetvo;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -35,4 +36,6 @@ public interface KuaiShouReportDailyMaterialMapper extends BaseMapper<KuaiShouRe
     List<KuaiShouReportDailyMaterial> getSignatureByDate(@Param("date")String date);
 
     List<KuaiShouReportDailyMaterial> getSignatureByDateGroupByProjectId(@Param("date")String date);
+
+    List<JSONObject> getVideoInfoByList(@Param("photoIdList") List<Long> photoIdList);
 }

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

@@ -28,4 +28,8 @@ public interface KuaiShouVideoGetMapper extends BaseMapper<KuaiShouVideoGet> {
     List<JSONObject> getVideoListByMap(Map<String, Object> requestMap);
 
     List<KuaiShouVideoGet> getPhotoIdsByParams(Long accountId, String signature);
+
+    void etlVideoBaseInfoByStaDate(@Param("statDate") String statDate);
+
+    List<JSONObject> getVideoInfoByPhotoIds(@Param("photoIdList") List<Long> photoIdList);
 }

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

@@ -367,5 +367,19 @@ where
     and
     stat_date = #{date}
     </select>
+    <select id="getVideoInfoByList" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        photo_id as 'photoId',
+        signature as 'signature',
+        channel_type as 'channelType'
+        from ctop_etl_kuaishou_video_base_info
+        where photo_id in
+        <foreach collection="photoIdList" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        and signature is not null
+        group by photo_id
+    </select>
 </mapper>
 

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

@@ -125,4 +125,42 @@
         and signature = #{signature}
         and status = 0
     </select>
+
+    <insert id="etlVideoBaseInfoByStaDate">
+    replace INTO ctop_etl_kuaishou_video_base_info (
+	signature,
+	channel_type,
+	photo_id,
+    photo_name,
+    material_type
+    ) SELECT
+	signature,
+	channel_type,
+	photo_id,
+    photo_name,
+    material_type
+  FROM
+	ctop_kuaishou_video_get
+	where  stat_date &gt;= #{statDate}
+	and signature is not null
+   GROUP BY
+	photo_id
+ </insert>
+
+    <select id="getVideoInfoByPhotoIds" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        photo_id as 'photoId',
+        signature as 'signature',
+        channel_type as 'channelType',
+        photo_name as 'photoName',
+        material_type as 'materialType'
+        from ctop_etl_kuaishou_video_base_info
+        where photo_id in
+        <foreach collection="photoIdList" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        and signature is not null
+        group by photo_id
+    </select>
 </mapper>

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

@@ -83,7 +83,6 @@
     <select id="getHistoryTopVideoList" resultType="com.alibaba.fastjson.JSONObject">
         select
         t2.photo_id,
-        t1.signature,
         t1.charge
         FROM
         (

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

@@ -16,7 +16,6 @@ import java.util.Map;
  */
 
 
-
 public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
     void replaceBatch(List<KuaiShouVideoGet> videoGets);
 
@@ -24,11 +23,11 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
 
     List<KuaiShouVideoGetVo> getVideoList(Map<String, Object> stringObjectMap);
 
-    List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId,Integer videoAiStatus);
+    List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId, Integer videoAiStatus);
 
-    List<KuaiShouVideoGet> getNewVideoDescDate(Long accountId,Integer newVideoCnt);
+    List<KuaiShouVideoGet> getNewVideoDescDate(Long accountId, Integer newVideoCnt);
 
-    List<KuaiShouVideoGet> getNewVideoBetweenTime(Long accountId,String startTime, String endTime);
+    List<KuaiShouVideoGet> getNewVideoBetweenTime(Long accountId, String startTime, String endTime);
 
     List<JSONObject> getVideoListByMap(Map<String, Object> requestMap);
 
@@ -36,5 +35,10 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
 
     KuaiShouVideoGet getVideoByPhotoId(Long photo_id);
 
+    void etlVideoBaseInfoByStaDate(String statDate);
+
+    List<JSONObject> getVideoInfoAndImageList(List<JSONObject> materialList);
+
     List<KuaiShouVideoGet> getVideoInfoGroupBySignature(String date);
+
 }

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

@@ -6,10 +6,8 @@ import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouReportDailyMaterialMapper;
 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.VideoGetvo;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -57,16 +55,13 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
         param.put("advertiser_id", accountId);
         param.put("temporal_granularity", "DAILY");
         param.put("view_type", 5);
-        param.put("page_size", 1000);
+        param.put("page_size", 2000);
         param.put("page", page);
-
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
-    //    log.info("快手返回数据:{}",resultJson);
         if (Check.isNull(resultJson)) {
             return;
         }
-
         Integer total_count = resultJson.getInteger("total_count");
         if (total_count == 0) {
             return;
@@ -75,9 +70,8 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
         if (Check.isNull(details)) {
             return;
         }
-
         List<KuaiShouReportDailyMaterial> addList = new ArrayList<>();
-        long l1 = System.currentTimeMillis();
+        List<Long> photoIdList = new ArrayList<>();
         for (int i = 0; i < details.size(); i++) {
             JSONObject detailJson = details.getJSONObject(i);
             detailJson.put("photo_like", detailJson.getInteger("like"));
@@ -85,28 +79,49 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
             detailJson.put("photo_comment", detailJson.getInteger("comment"));
             detailJson.put("photo_show", detailJson.getInteger("show"));
             KuaiShouReportDailyMaterial material = JSONObject.toJavaObject(detailJson, KuaiShouReportDailyMaterial.class);
-            VideoGetvo videoGetvo = dailyMaterialMapper.getVideoGetByPhotoId(material.getPhotoId());
+           /* VideoGetvo videoGetvo = dailyMaterialMapper.getVideoGetByPhotoId(material.getPhotoId());
             if (!Check.isNull(videoGetvo)) {
                 material.setChannelType(videoGetvo.getChannelType());
                 material.setSignature(videoGetvo.getSignature());
-            }
+            }*/
             material.setAccountId(accountId);
-
+            photoIdList.add(material.getPhotoId());
             addList.add(material);
         }
-  //      log.info("addList:{}",addList);
+        addList = this.getVideoInfoByList(addList, photoIdList);
         dailyMaterialMapper.batchReplace(addList);
         getMaterialReportByAccountIdAndStatDate(accountId, token, startDate, endDate, page + 1);
     }
 
+    private List<KuaiShouReportDailyMaterial> getVideoInfoByList(List<KuaiShouReportDailyMaterial> addList, List<Long> photoIdList) {
+        if (Check.isNull(photoIdList)) {
+            return null;
+        }
+        List<JSONObject> videoInfoList = dailyMaterialMapper.getVideoInfoByList(photoIdList);
+        Map<Long, JSONObject> videoMap = new HashMap<>();
+        for (int i = 0; i < videoInfoList.size(); i++) {
+            JSONObject jsonObject = videoInfoList.get(i);
+            videoMap.put(jsonObject.getLong("photoId"), jsonObject);
+        }
+        for (KuaiShouReportDailyMaterial dailyMaterial : addList) {
+            JSONObject jsonObject = videoMap.get(dailyMaterial.getPhotoId());
+            if (Check.isNull(jsonObject)) {
+                continue;
+            }
+            dailyMaterial.setSignature(jsonObject.getString("signature"));
+            dailyMaterial.setChannelType(jsonObject.getInteger("channelType"));
+        }
+        return addList;
+    }
+
     @Override
     public List<KuaiShouReportDailyMaterial> getSignatureByDate(String date) {
         return dailyMaterialMapper.getSignatureByDate(date);
     }
 
     @Override
-    public KuaiShouReportDailyMaterial getEtlDataByParams(String signature, String date,Long projectId) {
-        return dailyMaterialMapper.getEtlDataByParams(signature,date,projectId);
+    public KuaiShouReportDailyMaterial getEtlDataByParams(String signature, String date, Long projectId) {
+        return dailyMaterialMapper.getEtlDataByParams(signature, date, projectId);
     }
 
     @Override

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

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.service.IMaterialCutFrameService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.LoadFileUtil;
+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.entity.vo.KuaiShouVideoGetVo;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouVideoGetMapper;
@@ -20,6 +21,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -40,6 +42,9 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     @Value("${oss.replace.download}")
     private String downloadUrl;
 
+    @Autowired
+    private IKuaiShouVideoLastTimeService lastTimeService;
+
     @Override
     public void replaceBatch(List<KuaiShouVideoGet> videoGets) {
         videoGetMapper.replaceBatch(videoGets);
@@ -163,7 +168,6 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
         return videoGetMapper.getVideoListByMap(requestMap);
     }
 
-
     @Override
     public List<KuaiShouVideoGet> selectPhotoIdsByAccountId(Long accountId) {
         return videoGetMapper.selectPhotoIdsByAccountId(accountId);
@@ -179,11 +183,66 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     }
 
     @Override
+    public void etlVideoBaseInfoByStaDate(String statDate) {
+        videoGetMapper.etlVideoBaseInfoByStaDate(statDate);
+    }
+
+    @Override
+    public List<JSONObject> getVideoInfoAndImageList(List<JSONObject> materialList) {
+        List<Long> photoIdList = new ArrayList();
+        for (int i = 0; i < materialList.size(); i++) {
+            JSONObject materialJson = materialList.get(i);
+            photoIdList.add(materialJson.getLong("photo_id"));
+        }
+        Map<Long, JSONObject> materialMap = new HashMap<>();
+        List<String> videoCodeList = new ArrayList<>();
+
+        List<JSONObject> videoList = videoGetMapper.getVideoInfoByPhotoIds(photoIdList);
+        Map<String, List<String>> imageMap = new HashMap<>();
+        for (int i = 0; i < videoList.size(); i++) {
+            JSONObject jsonObject = videoList.get(i);
+            materialMap.put(jsonObject.getLong("photoId"), jsonObject);
+            videoCodeList.add(jsonObject.getString("signature"));
+            imageMap.put(jsonObject.getString("signature"), new ArrayList<>());
+        }
+        imageMap = this.getImageListByMd5(videoCodeList, imageMap);
+        for (int i = 0; i < materialList.size(); i++) {
+            JSONObject materialJson = materialList.get(i);
+            Long photoId = materialJson.getLong("photo_id");
+            JSONObject jsonObject = materialMap.get(photoId);
+            if (Check.isNull(jsonObject)) {
+                continue;
+            }
+            String signature = jsonObject.getString("signature");
+            materialJson.put("signature", signature);
+            materialJson.put("material_type", jsonObject.getInteger("materialType"));
+            materialJson.put("channel_type", jsonObject.getString("channelType"));
+            materialJson.put("photo_name", jsonObject.getString("photoName"));
+            List<String> imageList = imageMap.get(signature);
+            materialJson.put("imageList", imageList);
+        }
+        return materialList;
+    }
+
+    private Map<String, List<String>> getImageListByMd5(List<String> videoCodeList, Map<String, List<String>> imageMap) {
+        List<JSONObject> imageList = lastTimeService.getImageListByMd5List(videoCodeList);
+        for (int i = 0; i < imageList.size(); i++) {
+            JSONObject jsonObject = imageList.get(i);
+            if (Check.isNull(jsonObject)) {
+                continue;
+            }
+            String video_signature = jsonObject.getString("video_signature");
+            List<String> jsonObjects = imageMap.get(video_signature);
+            jsonObjects.add(jsonObject.getString("signature"));
+        }
+        return imageMap;
+    }
+
+    @Override
     public List<KuaiShouVideoGet> getVideoInfoGroupBySignature(String date) {
         QueryWrapper<KuaiShouVideoGet> queryWrapper = new QueryWrapper<>();
-        queryWrapper.isNotNull("signature").likeRight("stat_date",date);
+        queryWrapper.isNotNull("signature").likeRight("stat_date", date);
         queryWrapper.groupBy("signature");
         return this.list(queryWrapper);
     }
-
 }

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

@@ -2106,7 +2106,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             Map<String, String> header = new HashMap<String, String>();
             header.put("Content-Type", " application/json");
             header.put("Access-Token", accessToken);
-
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), header);
             JSONObject resultJson = JSONObject.parseObject(result);
             log.info("快手创建创意返回:accountId:{},返回结果{}", advertiserId, resultJson);
@@ -2140,9 +2139,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     }
                 } else {
                     if (code == 500000 && count <= 4) {
-                        creativeCreate(accessToken, advertiserId, requestJson, count + 1);
+                        batchCreativeCreate(accessToken, advertiserId, requestJson, count + 1, userId);
                     }
-
                     if (code == 400001 && "/rest/openapi/v2/creative/batch/update调用已超日限,次日可恢复调用".equals(resultJson.getString("message"))) {
                         overRunSendMessageService.creativeOverRunSendMessage(advertiserId, userId);
                     }

+ 1 - 35
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/entity/EtlKuaishouVideoInfo.java

@@ -30,74 +30,40 @@ public class EtlKuaishouVideoInfo {
 
 	/**id*/
 	@TableId(type = IdType.AUTO)
-    @ApiModelProperty(value = "id")
 	private Long id;
 	/**视频唯一标识*/
-	@Excel(name = "视频唯一标识", width = 15)
-    @ApiModelProperty(value = "视频唯一标识")
 	private String videoCode;
 	/**初次产生消耗时间*/
-	@Excel(name = "初次产生消耗时间", width = 15, format = "yyyy-MM-dd")
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
-    @DateTimeFormat(pattern="yyyy-MM-dd")
-    @ApiModelProperty(value = "初次产生消耗时间")
 	private Date stateDate;
 	/**url*/
-	@Excel(name = "url", width = 15)
-    @ApiModelProperty(value = "url")
 	private String url;
 	/**coverUrl*/
-	@Excel(name = "coverUrl", width = 15)
-    @ApiModelProperty(value = "coverUrl")
 	private String coverUrl;
 	/**渠道类型*/
-	@Excel(name = "渠道类型", width = 15)
-    @ApiModelProperty(value = "渠道类型")
 	private String channelType;
 	/**渠道名称*/
-	@Excel(name = "渠道名称", width = 15)
-    @ApiModelProperty(value = "渠道名称")
 	private String channelName;
 	/**companyName*/
-	@Excel(name = "companyName", width = 15)
-    @ApiModelProperty(value = "companyName")
+	private String companyId;
 	private String companyName;
 	/**planId*/
-	@Excel(name = "planId", width = 15)
-    @ApiModelProperty(value = "planId")
 	private String planId;
 	/**planName*/
-	@Excel(name = "planName", width = 15)
-    @ApiModelProperty(value = "planName")
 	private String planName;
 	/**clipId*/
-	@Excel(name = "clipId", width = 15)
-    @ApiModelProperty(value = "clipId")
 	private String clipId;
 	/**clipName*/
-	@Excel(name = "clipName", width = 15)
-    @ApiModelProperty(value = "clipName")
 	private String clipName;
 	/**shotId*/
-	@Excel(name = "shotId", width = 15)
-    @ApiModelProperty(value = "shotId")
 	private String shotId;
 	/**shotName*/
-	@Excel(name = "shotName", width = 15)
-    @ApiModelProperty(value = "shotName")
 	private String shotName;
 	/**designTeamLeaderId*/
-	@Excel(name = "designTeamLeaderId", width = 15)
-    @ApiModelProperty(value = "designTeamLeaderId")
 	private String designTeamLeaderId;
 	/**designTeamLeaderName*/
-	@Excel(name = "designTeamLeaderName", width = 15)
-    @ApiModelProperty(value = "designTeamLeaderName")
 	private String designTeamLeaderName;
 	/**createTime*/
-    @ApiModelProperty(value = "createTime")
 	private Date createTime;
 	/**updateTime*/
-    @ApiModelProperty(value = "updateTime")
 	private Date updateTime;
 }

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

@@ -19,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.awt.*;
 import java.util.Date;
 import java.util.List;
 

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

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportVideoDaily;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 快手视频分日报表信息
@@ -10,5 +11,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @cersion: V1.0
  */
 public interface EtlKuaishouReportVideoDailyMapper extends BaseMapper<EtlKuaishouReportVideoDaily> {
-
+    void etlKuaishouVideoReportDailyByDate(@Param(value = "data") String date);
 }

+ 77 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportVideoDailyMapper.xml

@@ -2,4 +2,81 @@
 <!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.EtlKuaishouReportVideoDailyMapper">
 
+    <insert id="etlKuaishouVideoReportDailyByDate">
+        replace into ctop_etl_kuaishou_report_video_daily (
+    stat_date,
+    video_code,
+    charge,
+    photo_show,
+    aclick,
+    photo_share,
+    photo_comment,
+    photo_like,
+    follow,
+    cancel_follow,
+    report,
+    block,
+    negative,
+    download_started,
+    download_completed,
+    activation,
+    submit,
+    photo_click,
+    event_pay_first_day,
+    event_pay_purchase_amount_first_day,
+    event_pay,
+    event_pay_purchase_amount,
+    event_register,
+    event_jin_jian_app,
+    event_credit_grant_app,
+    event_order_paid,
+    event_order_paid_purchase_amount,
+    event_jin_jian_landing_page ,
+    event_credit_grant_landing_page ,
+    event_next_day_stay_cost ,
+    event_order_paid_cost ,
+    event_next_day_stay,
+    form_cost ,
+    form_count,
+    play_3s_count
+) select  stat_date,
+        signature as video_code,
+        sum(charge) as charge,
+        sum(photo_show) as photo_show,
+        sum(aclick)as aclick,
+        sum(photo_share)as photo_share,
+        sum(photo_comment)as photo_comment,
+        sum(photo_like)as photo_like,
+        sum(follow)as follow,
+        sum(cancel_follow) as cancel_follow,
+        sum(report)as report,
+        sum(block)as block,
+        sum(negative)as negative ,
+        sum(download_started)as download_started ,
+        sum(download_completed)as download_completed,
+        sum(activation)as activation ,
+        sum(submit)as submit ,
+        sum(photo_click)as photo_click ,
+        sum(event_pay_first_day)as event_pay_first_day ,
+        sum(event_pay_purchase_amount_first_day)as event_pay_purchase_amount_first_day ,
+        sum(event_pay)as event_pay ,
+        sum(event_pay_purchase_amount)as event_pay_purchase_amount ,
+        sum(event_register)as event_register ,
+        sum(event_jin_jian_app)as event_jin_jian_app ,
+        sum(event_credit_grant_app)as event_credit_grant_app ,
+        sum(event_order_paid)as event_order_paid ,
+        sum(event_order_paid_purchase_amount)as event_order_paid_purchase_amount ,
+        sum(event_jin_jian_landing_page)as event_jin_jian_landing_page ,
+        sum(event_credit_grant_landing_page)as event_credit_grant_landing_page ,
+        sum(event_next_day_stay_cost)as event_next_day_stay_cost ,
+        sum(event_order_paid_cost)as event_order_paid_cost ,
+        sum(event_next_day_stay )as event_next_day_stay,
+        sum(form_cost)as form_cost ,
+        sum(form_count )as form_count,
+        sum(play_3s_ratio*photo_show)as play_3s_count
+from ctop_kuaishou_report_daily_material
+where stat_date = #{date}
+  and signature is not null
+group by signature;
+    </insert>
 </mapper>

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

@@ -6,6 +6,8 @@ import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouReportVideoDailyS
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+
 /**
  * 快手视频分日报表信息
  * @author jeecg-boot
@@ -14,9 +16,11 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class EtlKuaishouReportVideoDailyServiceImpl extends ServiceImpl<EtlKuaishouReportVideoDailyMapper, EtlKuaishouReportVideoDaily> implements IEtlKuaishouReportVideoDailyService {
+    @Resource
+    private EtlKuaishouReportVideoDailyMapper etlKuaishouReportVideoDailyMapper;
     @Override
     public void etlKuaishouVideoReportDaily(String date){
         //1:根据日期查询当前素材消耗数据
-
+        etlKuaishouReportVideoDailyMapper.etlKuaishouVideoReportDailyByDate(date);
     }
 }