Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

syh 4 vuotta sitten
vanhempi
commit
589e7f6e6a
21 muutettua tiedostoa jossa 1005 lisäystä ja 72 poistoa
  1. 19 19
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  3. 9 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  4. 0 25
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCampaignCopyDateJob.java
  5. 76 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouVideoRelateCreativesJob.java
  6. 161 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouMaterialControer.java
  7. 56 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaiShouVideoLastTime.java
  8. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaiShouVideoLastTimeMapper.java
  9. 12 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaiShouVideoLastTimeMapper.xml
  10. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaiShouVideoLastTimeService.java
  11. 28 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouVideoLastTimeServiceImpl.java
  12. 262 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouVideoRelateCreativesController.java
  13. 72 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouVideoRelateCreatives.java
  14. 4 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouVideoGetMapper.java
  15. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouVideoRelateCreativesMapper.java
  16. 28 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml
  17. 23 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouVideoRelateCreativesMapper.xml
  18. 3 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java
  19. 23 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouVideoRelateCreativesService.java
  20. 30 20
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java
  21. 144 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouVideoRelateCreativesServiceImpl.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类型的时间值

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

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

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

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

+ 0 - 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);
-    }
-}

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

@@ -0,0 +1,76 @@
+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.IKuaishouVideoRelateCreativesService;
+import com.alibaba.fastjson.JSONArray;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+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;
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+
+    @XxlJob("kuaishouVideoRelateCreativesJob")
+    public void execute() throws Exception {
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        tokens.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);
+        }
+    }
+}

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

@@ -0,0 +1,161 @@
+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.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+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/Ai")
+public class KuaiShouMaterialControer {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService iKuaishouInterfaceService;
+    @Autowired
+    private IKuaiShouVideoLastTimeService lastTimeService;
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+
+    /**
+     * 查询上新素材
+     *
+     * @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不能为空");
+            }
+            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;
+    }
+
+
+}

+ 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>

+ 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);
+}

+ 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;
+}

+ 4 - 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;
 
@@ -22,6 +23,7 @@ public interface KuaiShouVideoGetMapper extends BaseMapper<KuaiShouVideoGet> {
 
     List<KuaiShouVideoGet> getHighQualityVideo(long accountId,int days,int num);
 
-
-
+    List<KuaiShouVideoGet> selectPhotoIdsByAccountId(Long accountId);
+    List<JSONObject> getVideoListByMap(Map<String, Object> requestMap);
+    List<KuaiShouVideoGet> selectPhotoIdsByAccountId(Long accountId);
 }

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

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

+ 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>

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

@@ -0,0 +1,23 @@
+<?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>
+
+</mapper>

+ 3 - 4
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,6 @@ 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);
 }

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

@@ -0,0 +1,23 @@
+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.Map;
+
+/**
+ * @Description: 频库-视频关联创意数查询
+ * @Author: jeecg-boot
+ * @Date: 2021-01-12
+ * @Version: V1.0
+ */
+public interface IKuaishouVideoRelateCreativesService extends IService<KuaishouVideoRelateCreatives> {
+
+    public Result pushVideo(JSONObject data);
+
+    public void videoRelateCreatives(Long accountId, JSONArray photoIds, Map<String,Object> statdateMap);
+
+}

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

@@ -19,11 +19,10 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 
 /**
  * @Description: 快手-获取视频接口
@@ -122,13 +121,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 +135,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 +149,27 @@ 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);
+    }
+
 }

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

@@ -0,0 +1,144 @@
+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.KuaiShouVideoGet;
+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.IKuaiShouVideoGetService;
+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);
+                }
+            }
+        } 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);
+        }
+    }
+}