syh 5 роки тому
батько
коміт
d9b85624d1
17 змінених файлів з 343 додано та 315 видалено
  1. 7 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  2. 14 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  3. 2 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouMaterialsLoadJob.java
  4. 3 0
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadImageServiceImpl.java
  5. 4 1
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java
  6. 2 2
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouMaterialsLoadJob.java
  7. 38 20
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  8. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouImageGet.java
  9. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java
  10. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouImageGetMapper.xml
  11. 3 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java
  12. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupService.java
  13. 3 16
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  14. 186 179
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  15. 30 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  16. 6 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java
  17. 38 79
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

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

@@ -165,6 +165,8 @@ public class MaterialInfoController {
                                                      HttpServletRequest req) {
 
         Result<IPage<MaterialInfo>> result = new Result<>();
+        String materialName = materialInfo.getMaterialName();
+        materialInfo.setMaterialName(null);
         QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
         Object createTime = materialInfo.getCreateTime();
         materialInfo.setCreateTime(null);
@@ -201,6 +203,10 @@ public class MaterialInfoController {
                 }
             }
         }
+        if (!Check.isNull(materialName)) {
+            queryWrapper.like("material_name", materialName);
+
+        }
         Page<MaterialInfo> page = new Page<>(pageNo, pageSize);
         IPage<MaterialInfo> pageList = materialInfoService.page(page, queryWrapper);
         List<MaterialInfo> materialInfoList = pageList.getRecords();
@@ -494,7 +500,7 @@ public class MaterialInfoController {
         Object createTime = materialInfo.getCreateTime();
         materialInfo.setCreateTime(null);
         Long projectId = materialInfo.getProjectId();
-        if(projectId != null){
+        if (projectId != null) {
             queryWrapper.eq("project_id", projectId);
         }
         queryWrapper.in("code", effiList);

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

@@ -139,12 +139,9 @@ public class TestController {
 
         try {
 
-
             Thread thread = new Thread() {
                 @Override
                 public void run() {
-
-
                     QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
                     tokenQueryWrapper.eq("media_id", 2);
                     List<CtopOauthToken> list = tokenService.list(tokenQueryWrapper);
@@ -155,10 +152,20 @@ public class TestController {
                             @Override
                             public void run() {
                                 try {
-                                    //获取全量视频素材数据
-                                    kuaishouInterfaceService.getVideoList(token, null, null);
-                                    // 获取图片信息数据
-                                    //   kuaishouInterfaceService.getImageList(token, startDate, endDate);
+                                    kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1);
+                                    String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                                    String videoEndDate = DateUtils.addDay(nowDate, -180);
+                                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                                    Date end = simpleDateFormat.parse(nowDate);
+                                    Date start = simpleDateFormat.parse(videoEndDate);
+                                    List<Date> dates = DateUtils.findDates(start, end);
+                                    for (int i = 0; i < dates.size(); i++) {
+                                        String formatDate = simpleDateFormat.format(dates.get(i));
+                                        kuaishouInterfaceService.getVideoList(token, formatDate);
+                                        kuaishouInterfaceService.getImageList(token, formatDate);
+                                        Thread.sleep(500);
+                                    }
+
                                 } catch (Exception e) {
                                     e.printStackTrace();
                                 } finally {

+ 2 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouMaterialsLoadJob.java

@@ -2,7 +2,6 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -43,9 +42,9 @@ public class KuaishouMaterialsLoadJob implements Job {
                             try {
 
                                 //获取全量视频素材数据
-                                kuaishouInterfaceService.getVideoList(token, startDate, endDate);
+                                kuaishouInterfaceService.getVideoList(token, DateUtils.getNowDate("yyyy-MM-dd"));
                                 // 获取图片信息数据
-                                kuaishouInterfaceService.getImageList(token, startDate, endDate);
+                                kuaishouInterfaceService.getImageList(token, DateUtils.getNowDate("yyyy-MM-dd"));
                             } catch (Exception e) {
                                 e.printStackTrace();
                             } finally {

+ 3 - 0
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadImageServiceImpl.java

@@ -13,6 +13,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.ParseException;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpEntity;
@@ -98,6 +99,8 @@ public class MaterialUploadImageServiceImpl implements IMaterialUploadImageServi
                                             if (!Check.isNull(type)) {
                                                 imageGet.setMaterialType(type);
                                             }
+                                            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                                            imageGet.setStatDate(DateUtils.parseDate(nowDate, "yyyy-MM-dd"));
                                             imageGet.setSignature(signature);
                                             imageGet.setImageToken(image_token);
                                             imageGetService.saveOrUpdate(imageGet);

+ 4 - 1
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java

@@ -21,6 +21,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.FileSystemResource;
@@ -191,7 +192,6 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                             try {
                                 log.info("快手文件多线程上传:{},accountId:{}", Thread.currentThread().getName(), accountId);
                                 String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_UPLOAD;
-
                                 String result = exceptInfoForRestTemplate(url, requestJson, headerMap);
                                 JSONObject resultJson = JSONObject.parseObject(result);
                                 if (!Check.isNull(resultJson)) {
@@ -221,6 +221,9 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                             }
                                             videoGet.setPhotoId(photoId);
                                             videoGet.setSignature(signature);
+                                            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                                            videoGet.setStatDate(DateUtils.parseDate(nowDate, "yyyy-MM-dd"));
+                                            videoGet.setCoverUrl(materialInfo.getUrl() + "?x-oss-process=video/snapshot,t_10000,m_fast");
                                             kuaiShouVideoGetService.saveOrUpdate(videoGet);
                                             materialUploadImageService.uploadImage(videoGet.getSignature(), accountId, ctopOauthToken.getAccessToken());
 

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

@@ -34,9 +34,9 @@ public class KuaishouMaterialsLoadJob {
         executorService = Executors.newFixedThreadPool(8);
         tokens.forEach(token -> executorService.submit(() -> {
             //获取全量视频素材数据
-            kuaishouInterfaceService.getVideoList(token, startDate, endDate);
+            kuaishouInterfaceService.getVideoList(token, DateUtils.getNowDate("yyyy-MM-dd"));
             // 获取图片信息数据
-            kuaishouInterfaceService.getImageList(token, startDate, endDate);
+            kuaishouInterfaceService.getImageList(token, DateUtils.getNowDate("yyyy-MM-dd"));
         }));
         XxlJobLogger.log("快手物料数据同步完成");
         return ReturnT.SUCCESS;

+ 38 - 20
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -24,6 +24,7 @@ import io.swagger.annotations.Api;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -133,7 +134,7 @@ public class BatchController {
             Thread thread2 = new Thread() {
                 @Override
                 public void run() {
-                    iKuaishouInterfaceService.getVideoList(oauthToken, null, null);
+                    iKuaishouInterfaceService.getVideoList(oauthToken, DateUtils.getNowDate("yyyy-MM-dd"));
                 }
             };
             thread2.start();
@@ -664,8 +665,13 @@ public class BatchController {
             if (Check.isNull(requestJson)) {
                 throw new Exception("入参为空");
             }
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("账号信息为空");
+            }
 
-            JSONObject unitJson = batchService.createUnit(requestJson);
+            JSONObject unitJson = batchService.createUnit(requestJson, token);
             result.setSuccess(true);
             result.setResult(unitJson);
 
@@ -941,7 +947,7 @@ public class BatchController {
                         if (!Check.isNull(updateMap)) {
                             Integer code = (Integer) updateMap.get("code");
                             if (code == 0) {
-                                iKuaishouInterfaceService.getGroup(token.getAccessToken(), accountId, unitId);
+                                kuaiShouGroupService.getGroupByUnitId(token.getAccessToken(), accountId, unitId);
                             } else {
                                 JSONObject failJson = new JSONObject();
                                 failJson.put("message", updateMap.get("message"));
@@ -1006,7 +1012,7 @@ public class BatchController {
                                 Map<String, Object> updateDeepMap = updateService.updateUnitDeepConversionBid(token.getAccessToken(), accountId, unitId, deepConversionBid, userId);
                             }
                         }
-                        iKuaishouInterfaceService.getGroup(token.getAccessToken(), accountId, unitId);
+                        kuaiShouGroupService.getGroupByUnitId(token.getAccessToken(), accountId, unitId);
                         if (!Check.isNull(updateMap)) {
                             Integer code = (Integer) updateMap.get("code");
                             if (code != 0) {
@@ -1049,7 +1055,7 @@ public class BatchController {
         Result<IPage<KuaiShouImageGet>> result = new Result<>();
         try {
             QueryWrapper<KuaiShouImageGet> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouImageGet, req.getParameterMap());
-            queryWrapper.orderByDesc("create_time");
+            queryWrapper.orderByDesc("stat_date");
             Page<KuaiShouImageGet> page = new Page<>(pageNo, pageSize);
             IPage<KuaiShouImageGet> pageList = kuaiShouImageGetService.page(page, queryWrapper);
             result.setSuccess(true);
@@ -1071,15 +1077,15 @@ public class BatchController {
     @GetMapping(value = "/getVideoList")
     public Result<IPage<KuaiShouVideoGet>> getVideoList(KuaiShouVideoGet kuaiShouVideoGet, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                        @RequestParam(name = "startDate", defaultValue = "2010-01-01") String startDate,
-                                                        @RequestParam(name = "endDate", defaultValue = "2100-01-01") String endDate, HttpServletRequest req) {
+                                                        @RequestParam(name = "startDate", defaultValue = "") String startDate,
+                                                        @RequestParam(name = "endDate", defaultValue = "") String endDate, HttpServletRequest req) {
         Result<IPage<KuaiShouVideoGet>> result = new Result<>();
         try {
             QueryWrapper<KuaiShouVideoGet> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouVideoGet, req.getParameterMap());
-            startDate = startDate + " 00:00:00";
-            endDate = endDate + " 23:59:59";
-            queryWrapper.between("create_time", startDate, endDate);
-            queryWrapper.orderByDesc("create_time");
+            if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
+                queryWrapper.between("stat_date", startDate, endDate);
+            }
+            queryWrapper.orderByDesc("stat_date");
             Page<KuaiShouVideoGet> page = new Page<>(pageNo, pageSize);
             IPage<KuaiShouVideoGet> pageList = kuaiShouVideoGetService.page(page, queryWrapper);
             result.setSuccess(true);
@@ -1622,6 +1628,15 @@ public class BatchController {
     public Result<JSONObject> batchCopyUnit(@RequestBody JSONObject requestJson) {
         Result<JSONObject> result = new Result<>();
         try {
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户id不能为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到token信息");
+            }
+
             if (Check.isNull(requestJson)) {
                 throw new Exception("入参为空");
             }
@@ -1629,10 +1644,8 @@ public class BatchController {
             if (Check.isNull(unitIds)) {
                 throw new Exception("请选择需要修改的广告组");
             }
-            Long accountId = requestJson.getLong("accountId");
-            Long copyToCampaignId = requestJson.getLong("copyToCampaignId");
-
 
+            Long copyToCampaignId = requestJson.getLong("copyToCampaignId");
             JSONObject returnJson = new JSONObject();
             JSONArray failArr = new JSONArray();
             for (int i = 0; i < unitIds.size(); i++) {
@@ -1640,7 +1653,7 @@ public class BatchController {
                 if (Check.isNull(unitId)) {
                     continue;
                 }
-
+                kuaiShouGroupService.getGroupByUnitId(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitId);
                 QueryWrapper<KuaiShouGroup> queryWrapper = new QueryWrapper<>();
                 queryWrapper.eq("account_id", accountId);
                 queryWrapper.eq("unit_id", unitId);
@@ -1658,7 +1671,7 @@ public class BatchController {
                     unitName = unitNameStr;
                 }
                 group.setUnitName(unitName + RandomUtil.verifyCode());
-                JSONObject unitJson = batchService.copyUnit(group, copyToCampaignId);
+                JSONObject unitJson = batchService.copyUnit(group, copyToCampaignId, oauthToken);
                 if (!Check.isNull(unitJson)) {
                     Integer code = unitJson.getInteger("code");
                     if (code != 0) {
@@ -1694,10 +1707,15 @@ public class BatchController {
     public Result<JSONObject> copyUnit(@RequestBody JSONObject requestJson) {
         Result<JSONObject> result = new Result<>();
         try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
             JSONObject returnJson = new JSONObject();
 
-            Long accountId = requestJson.getLong("accountId");
             Long unitId = requestJson.getLong("unitId");
+            kuaiShouGroupService.getGroupByUnitId(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitId);
             Long copyToCampaignId = requestJson.getLong("copyToCampaignId");
             JSONArray failArr = new JSONArray();
             Integer createCount = requestJson.getInteger("createCount");
@@ -1705,7 +1723,7 @@ public class BatchController {
                 throw new Exception("请选择迭代次数");
             }
             if (createCount == 1) {
-                JSONObject createJson = batchService.createUnit(requestJson);
+                JSONObject createJson = batchService.createUnit(requestJson, oauthToken);
                 if (!Check.isNull(createJson)) {
                     failArr = createJson.getJSONArray("fail");
                 }
@@ -1732,7 +1750,7 @@ public class BatchController {
                     for (int i = 0; i < createCount; i++) {
                         String randomName = unitName + RandomUtil.verifyCode();
                         group.setUnitName(randomName);
-                        JSONObject copyUnitJson = batchService.copyUnit(group, copyToCampaignId);
+                        JSONObject copyUnitJson = batchService.copyUnit(group, copyToCampaignId, oauthToken);
                         if (copyUnitJson.getInteger("code") != 0) {
                             JSONObject errJson = new JSONObject();
                             errJson.put("message", copyUnitJson.getString("message"));
@@ -1753,7 +1771,7 @@ public class BatchController {
                                 continue;
                             }
                             group.setUnitName(copyUnitName);
-                            JSONObject copyUnitJson = batchService.copyUnit(group, copyToCampaignId);
+                            JSONObject copyUnitJson = batchService.copyUnit(group, copyToCampaignId, oauthToken);
                             if (copyUnitJson.getInteger("code") != 0) {
                                 JSONObject errJson = new JSONObject();
                                 errJson.put("message", copyUnitJson.getString("message"));

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

@@ -82,6 +82,7 @@ public class KuaiShouImageGet {
     @Excel(name = "图片 md5", width = 15)
     @ApiModelProperty(value = "图片 md5")
     private String signature;
+    private Date statDate;
     /**
      * 创建时间
      */

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

@@ -74,6 +74,8 @@ public class KuaiShouVideoGet {
 
     private String signature;
 
+    private Date statDate;
+
 
     private Integer materialType;
     /**

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

@@ -14,6 +14,7 @@
         material_type,
         signature,
         image_token,
+        stat_date,
         create_time,
         update_time
         )
@@ -30,6 +31,7 @@
             #{image.materialType},
             #{image.signature},
             #{image.imageToken},
+            #{image.statDate},
             #{image.createTime},
             #{image.updateTime}
             )

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

@@ -58,7 +58,7 @@ public interface IBatchService {
      * @param requestJson
      * @return
      */
-    JSONObject createUnit(JSONObject requestJson) throws Exception;
+    JSONObject createUnit(JSONObject requestJson,CtopOauthToken oauthToken) throws Exception;
 
     /**
      * 批量复制广告组
@@ -66,7 +66,7 @@ public interface IBatchService {
      * @param copyToCampaignId
      * @return
      */
-    JSONObject copyUnit(KuaiShouGroup group, Long copyToCampaignId);
+    JSONObject copyUnit(KuaiShouGroup group, Long copyToCampaignId, CtopOauthToken oauthToken);
 
 
     /**
@@ -110,7 +110,7 @@ public interface IBatchService {
      * @param requestJson
      * @return
      */
-    JSONObject updateUnit(JSONObject requestJson,CtopOauthToken token) throws Exception;
+    JSONObject updateUnit(JSONObject requestJson, CtopOauthToken token) throws Exception;
 
     /**
      * 修改广告创意

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

@@ -12,4 +12,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
 public interface IKuaiShouGroupService extends IService<KuaiShouGroup> {
 
     void getGroupList(String accessToken, Long accountId);
+
+    void getGroupByUnitId(String accessToken, Long accountId, Long unitId);
 }

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

@@ -139,16 +139,6 @@ public interface IKuaishouInterfaceService {
 
 
     /**
-     * 获取广告组信息 单条
-     *
-     * @param accessToken
-     * @param advertiserId
-     * @param
-     */
-    void getGroup(String accessToken, Long advertiserId, Long unitId);
-
-
-    /**
      * 获取创意列表
      *
      * @param token
@@ -309,10 +299,9 @@ public interface IKuaishouInterfaceService {
      * 获取视频列表
      *
      * @param token
-     * @param startDate
-     * @param endDate
+     * @param statDate
      */
-    void getVideoList(CtopOauthToken token, Date startDate, Date endDate);
+    void getVideoList(CtopOauthToken token, String statDate);
 
 
     /**
@@ -411,10 +400,8 @@ public interface IKuaishouInterfaceService {
      * 获取快手图片列表
      *
      * @param token
-     * @param startDate
-     * @param endDate
      */
-    void getImageList(CtopOauthToken token, Date startDate, Date endDate);
+    void getImageList(CtopOauthToken token, String statDate);
 
 
     /**

+ 186 - 179
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java

@@ -169,12 +169,8 @@ public class BatchServiceImpl implements IBatchService {
      * @return
      */
     @Override
-    public JSONObject createUnit(JSONObject requestJson) throws Exception {
-        Long accountId = requestJson.getLong("accountId");
-        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
-        if (Check.isNull(oauthToken)) {
-            throw new Exception("未获取到账户信息");
-        }
+    public JSONObject createUnit(JSONObject requestJson, CtopOauthToken oauthToken) throws Exception {
+
 
         JSONObject unitJson = new JSONObject();
 
@@ -408,7 +404,7 @@ public class BatchServiceImpl implements IBatchService {
                     unitJson.put("unit_name", unitName);
                 }
 
-                Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), accountId, unitJson);
+                Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitJson);
                 if (!Check.isNullMap(returnUnitMap)) {
                     Integer code = (Integer) returnUnitMap.get("code");
                     if (code == 0) {
@@ -428,7 +424,7 @@ public class BatchServiceImpl implements IBatchService {
                                     @Override
                                     public void run() {
                                         try {
-                                            copyCreative(accountId, unitId, copyUnitId);
+                                            copyCreative(oauthToken.getAccountId(), unitId, copyUnitId);
                                         } catch (Exception e) {
                                             e.printStackTrace();
                                         }
@@ -465,14 +461,9 @@ public class BatchServiceImpl implements IBatchService {
 
 
     @Override
-    public JSONObject copyUnit(KuaiShouGroup group, Long copyToCampaignId) {
+    public JSONObject copyUnit(KuaiShouGroup group, Long copyToCampaignId, CtopOauthToken oauthToken) {
         JSONObject returnJson = new JSONObject();
         try {
-            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(group.getAccountId());
-            if (Check.isNull(oauthToken)) {
-                throw new Exception("未获取到token信息");
-            }
-
             JSONObject unitJson = new JSONObject();
             unitJson.put("campaign_id", copyToCampaignId);
 
@@ -1002,186 +993,202 @@ public class BatchServiceImpl implements IBatchService {
      */
     @Override
     public JSONObject updateUnit(JSONObject requestJson, CtopOauthToken token) throws Exception {
+        JSONObject returnJson = new JSONObject();
+        try {
 
-        JSONObject unitJson = new JSONObject();
-        unitJson.put("advertiser_id", token.getAccountId());
-
-        Long unitId = requestJson.getLong("unitId");
-        if (Check.isNull(unitId)) {
-            throw new Exception("请选择广告组");
-        }
+            JSONObject unitJson = new JSONObject();
+            unitJson.put("advertiser_id", token.getAccountId());
 
-        unitJson.put("unit_id", unitId);
-        // 广告组名称
-        if (!Check.isNull(requestJson.getString("unitName"))) {
-            unitJson.put("unit_name", requestJson.getString("unitName"));
-        }
-        // 出价
-        if (!Check.isNull(requestJson.getLong("bid"))) {
-            unitJson.put("bid", requestJson.getLong("bid"));
-        }
-        // 深度转化出价
-        if (!Check.isNull(requestJson.getLong("cpaBid"))) {
-            unitJson.put("cpa_bid", requestJson.getLong("cpaBid"));
-        }
-        // 深度转化目标出价
-        if (!Check.isNull(requestJson.getLong("deepConversionBid"))) {
-            unitJson.put("deep_conversion_bid", requestJson.getLong("deepConversionBid"));
-        }
-        //投放开始时间
-        if (!Check.isNull(requestJson.getString("beginTime"))) {
+            Long unitId = requestJson.getLong("unitId");
+            if (Check.isNull(unitId)) {
+                throw new Exception("请选择广告组");
+            }
 
-            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-            boolean beginTimeBoolean = DateUtils.compare(requestJson.getString("beginTime"), nowDate);
-            if (beginTimeBoolean) {
-                unitJson.put("begin_time", nowDate);
-            } else {
-                unitJson.put("begin_time", requestJson.getString("beginTime"));
+            unitJson.put("unit_id", unitId);
+            // 广告组名称
+            if (!Check.isNull(requestJson.getString("unitName"))) {
+                unitJson.put("unit_name", requestJson.getString("unitName"));
+            }
+            // 出价
+            if (!Check.isNull(requestJson.getLong("bid"))) {
+                unitJson.put("bid", requestJson.getLong("bid"));
+            }
+            // 深度转化出价
+            if (!Check.isNull(requestJson.getLong("cpaBid"))) {
+                unitJson.put("cpa_bid", requestJson.getLong("cpaBid"));
+            }
+            // 深度转化目标出价
+            if (!Check.isNull(requestJson.getLong("deepConversionBid"))) {
+                unitJson.put("deep_conversion_bid", requestJson.getLong("deepConversionBid"));
             }
+            //投放开始时间
+            if (!Check.isNull(requestJson.getString("beginTime"))) {
 
+                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                boolean beginTimeBoolean = DateUtils.compare(requestJson.getString("beginTime"), nowDate);
+                if (beginTimeBoolean) {
+                    unitJson.put("begin_time", nowDate);
+                } else {
+                    unitJson.put("begin_time", requestJson.getString("beginTime"));
+                }
 
-        }
-        // 投放结束时间
-        if (!Check.isNull(requestJson.getString("endTime"))) {
-            unitJson.put("end_time", requestJson.getString("endTime"));
-        }
-        // 投放时间段
-        if (!Check.isNull(requestJson.getString("scheduleTime"))) {
-            unitJson.put("schedule_time", requestJson.getString("scheduleTime"));
-        }
-        // 广告组单日预算
-        if (!Check.isNull(requestJson.getLong("dayBudget"))) {
-            unitJson.put("day_budget", requestJson.getLong("dayBudget"));
-        }
-        // url类型
-        if (!Check.isNull(requestJson.getInteger("urlType"))) {
-            unitJson.put("url_type", requestJson.getInteger("urlType"));
-        }
-        // url
-        if (!Check.isNull(requestJson.getString("url"))) {
-            unitJson.put("url", requestJson.getString("url"));
-        }
-        // appId
-        if (!Check.isNull(requestJson.getLong("appId"))) {
-            unitJson.put("app_id", requestJson.getLong("appId"));
-        }
 
-        // 创意展现方式
-        if (!Check.isNull(requestJson.getInteger("showMode"))) {
-            unitJson.put("show_mode", requestJson.getInteger("showMode"));
-        }
-        //投放方式
-        if (!Check.isNull(requestJson.getInteger("speed"))) {
-            unitJson.put("speed", requestJson.getInteger("speed"));
-        }
+            }
+            // 投放结束时间
+            if (!Check.isNull(requestJson.getString("endTime"))) {
+                unitJson.put("end_time", requestJson.getString("endTime"));
+            }
+            // 投放时间段
+            if (!Check.isNull(requestJson.getString("scheduleTime"))) {
+                unitJson.put("schedule_time", requestJson.getString("scheduleTime"));
+            }
+            // 广告组单日预算
+            if (!Check.isNull(requestJson.getLong("dayBudget"))) {
+                unitJson.put("day_budget", requestJson.getLong("dayBudget"));
+            }
+            // url类型
+            if (!Check.isNull(requestJson.getInteger("urlType"))) {
+                unitJson.put("url_type", requestJson.getInteger("urlType"));
+            }
+            // url
+            if (!Check.isNull(requestJson.getString("url"))) {
+                unitJson.put("url", requestJson.getString("url"));
+            }
+            // appId
+            if (!Check.isNull(requestJson.getLong("appId"))) {
+                unitJson.put("app_id", requestJson.getLong("appId"));
+            }
 
+            // 创意展现方式
+            if (!Check.isNull(requestJson.getInteger("showMode"))) {
+                unitJson.put("show_mode", requestJson.getInteger("showMode"));
+            }
+            //投放方式
+            if (!Check.isNull(requestJson.getInteger("speed"))) {
+                unitJson.put("speed", requestJson.getInteger("speed"));
+            }
 
-        // -----------------用户定向-----------
-        JSONObject targetJson = new JSONObject();
+            // 优先从系统应用商店下载
+            if (!Check.isNull(requestJson.getInteger("useAppMarket"))) {
+                unitJson.put("use_app_market", requestJson.getInteger("useAppMarket"));
+            }
+            // 转化目标
+            if (!Check.isNull(requestJson.getInteger("convertId"))) {
+                unitJson.put("convert_id", requestJson.getInteger("convertId"));
+            }
 
-        // 地域
-        if (!Check.isNull(requestJson.getJSONArray("region"))) {
-            targetJson.put("region", requestJson.getJSONArray("region"));
-        }
 
-        // 自定义年龄段
-        JSONArray ageArr = requestJson.getJSONArray("age");
-        if (!Check.isNull(ageArr)) {
-            JSONObject ageJson = new JSONObject();
-            ageJson.put("min", ageArr.get(0));
-            ageJson.put("max", ageArr.get(1));
-            targetJson.put("age", ageJson);
-        }
-        // 固定年龄段
-        if (!Check.isNull(requestJson.getJSONArray("agesRange"))) {
-            targetJson.put("ages_range", requestJson.getJSONArray("agesRange"));
-        }
-        // 性别
-        if (!Check.isNull(requestJson.getInteger("gender"))) {
-            targetJson.put("gender", requestJson.getInteger("gender"));
-        }
-        //操作系统
-        if (!Check.isNull(requestJson.getInteger("platformOs"))) {
-            targetJson.put("platform_os", requestJson.getInteger("platformOs"));
-        }
-        //Android版本
-        if (!Check.isNull(requestJson.getInteger("androidOsv"))) {
-            targetJson.put("android_osv", requestJson.getInteger("androidOsv"));
-        }
-        // iOS版本
-        if (!Check.isNull(requestJson.getInteger("iosOsv"))) {
-            targetJson.put("ios_osv", requestJson.getInteger("iosOsv"));
-        }
-        //网络环境
-        if (!Check.isNull(requestJson.getInteger("network"))) {
-            targetJson.put("network", requestJson.getInteger("network"));
-        }
-        //设备品牌
-        if (!Check.isNull(requestJson.getJSONArray("deviceBrand"))) {
-            targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
-        }
-        //设备价格
-        if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
-            targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
-        }
-        //商业兴趣类型
-        if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
-            targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
-        }
-        // 商业兴趣
-        if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
-            targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
-        }
-        //网红粉丝
-        if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
-            targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
-        }
-        //兴趣视频用户
-        if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
-            targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
-        }
-        // APP行为-按分类
-        if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
-            targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
-        }
-        // APP行为-按APP名称
-        if (!Check.isNull(requestJson.getJSONArray("appIds"))) {
-            targetJson.put("app_ids", requestJson.getJSONArray("appIds"));
-        }
-        // 人群包定向
-        if (!Check.isNull(requestJson.getJSONArray("population"))) {
-            targetJson.put("population", requestJson.getJSONArray("population"));
-        }
-        // 人群包排除
-        if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
-            targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
-        }
+            // -----------------用户定向-----------
+            JSONObject targetJson = new JSONObject();
 
-        JSONObject intelliExtendJson = new JSONObject();
+            // 地域
+            if (!Check.isNull(requestJson.getJSONArray("region"))) {
+                targetJson.put("region", requestJson.getJSONArray("region"));
+            }
 
-        // 开启智能扩量
-        if (!Check.isNull(requestJson.getInteger("isOpen"))) {
-            intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
-        }
-        //不可突破年龄
-        if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
-            intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
-        }
-        //不可突破性别
-        if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
-            intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
-        }
-        // 不可突破地域
-        if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
-            intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
-        }
-        if (!Check.isNull(intelliExtendJson)) {
-            targetJson.put("intelli_extend", intelliExtendJson);
-        }
+            // 自定义年龄段
+            JSONArray ageArr = requestJson.getJSONArray("age");
+            if (!Check.isNull(ageArr)) {
+                JSONObject ageJson = new JSONObject();
+                ageJson.put("min", ageArr.get(0));
+                ageJson.put("max", ageArr.get(1));
+                targetJson.put("age", ageJson);
+            }
+            // 固定年龄段
+            if (!Check.isNull(requestJson.getJSONArray("agesRange"))) {
+                targetJson.put("ages_range", requestJson.getJSONArray("agesRange"));
+            }
+            // 性别
+            if (!Check.isNull(requestJson.getInteger("gender"))) {
+                targetJson.put("gender", requestJson.getInteger("gender"));
+            }
+            //操作系统
+            if (!Check.isNull(requestJson.getInteger("platformOs"))) {
+                targetJson.put("platform_os", requestJson.getInteger("platformOs"));
+            }
+            //Android版本
+            if (!Check.isNull(requestJson.getInteger("androidOsv"))) {
+                targetJson.put("android_osv", requestJson.getInteger("androidOsv"));
+            }
+            // iOS版本
+            if (!Check.isNull(requestJson.getInteger("iosOsv"))) {
+                targetJson.put("ios_osv", requestJson.getInteger("iosOsv"));
+            }
+            //网络环境
+            if (!Check.isNull(requestJson.getInteger("network"))) {
+                targetJson.put("network", requestJson.getInteger("network"));
+            }
+            //设备品牌
+            if (!Check.isNull(requestJson.getJSONArray("deviceBrand"))) {
+                targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
+            }
+            //设备价格
+            if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
+                targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
+            }
+            //商业兴趣类型
+            if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
+                targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
+            }
+            // 商业兴趣
+            if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
+                targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
+            }
+            //网红粉丝
+            if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
+                targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
+            }
+            //兴趣视频用户
+            if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
+                targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
+            }
+            // APP行为-按分类
+            if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
+                targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
+            }
+            // APP行为-按APP名称
+            if (!Check.isNull(requestJson.getJSONArray("appIds"))) {
+                targetJson.put("app_ids", requestJson.getJSONArray("appIds"));
+            }
+            // 人群包定向
+            if (!Check.isNull(requestJson.getJSONArray("population"))) {
+                targetJson.put("population", requestJson.getJSONArray("population"));
+            }
+            // 人群包排除
+            if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
+                targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
+            }
 
-        unitJson.put("target", targetJson);
+            JSONObject intelliExtendJson = new JSONObject();
 
-        JSONObject returnJson = updateService.updateUnit(token.getAccessToken(), unitJson);
+            // 开启智能扩量
+            if (!Check.isNull(requestJson.getInteger("isOpen"))) {
+                intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
+            }
+            //不可突破年龄
+            if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
+                intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
+            }
+            //不可突破性别
+            if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
+                intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
+            }
+            // 不可突破地域
+            if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
+                intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
+            }
+            if (!Check.isNull(intelliExtendJson)) {
+                targetJson.put("intelli_extend", intelliExtendJson);
+            }
+
+            unitJson.put("target", targetJson);
+
+            returnJson = updateService.updateUnit(token.getAccessToken(), unitJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
         return returnJson;
     }
 

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

@@ -54,7 +54,6 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
      */
     @Override
     public void getGroupList(String accessToken, Long accountId) {
-
         QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
         campaignQueryWrapper.eq("account_id", accountId);
         campaignQueryWrapper.eq("status", 4);
@@ -109,6 +108,36 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
     }
 
 
+    @Override
+    public void getGroupByUnitId(String accessToken, Long accountId, Long unitId) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        param.put("unit_id", unitId);
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", accessToken);
+        headers.put("Content-Type", "application/json");
+
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (Check.isNull(resultJson)) {
+            log.error("获取广告组接口异常,advertiserId:{}", accountId);
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        if (null == code || code != 0) {
+            log.error("获取广告组返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+        addGroupV2(accountId, details);
+    }
+
+
     private void addGroupV2(Long advertiserId, JSONArray details) {
         if (!Check.isNull(details)) {
             List<KuaiShouGroup> groups = new ArrayList<>();

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

@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.batch.entity.*;
 import cn.com.ctop.kuaishou.modules.batch.mapper.*;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONObject;
@@ -113,6 +114,8 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
      * @param dayBudget
      * @return
      */
+    @Autowired
+    private IKuaiShouGroupService groupService;
     @Override
     public Map<String, Object> updateUnitDayBudget(String token, Long advertiserId, Long unitId, Long dayBudget, String loginId) {
         Map<String, Object> returnMap = new HashMap<>();
@@ -148,7 +151,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                         log.info("修改广告组预算本地记录添加成功,unitId:{}", unitId);
                     }
                     // 重新请求数据
-                    interfaceService.getGroup(token, advertiserId, unitId);
+                    groupService.getGroupByUnitId(token, advertiserId, unitId);
                     returnMap.put("code", 0);
                     returnMap.put("success", true);
                     returnMap.put("message", "修改成功");
@@ -369,7 +372,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                         deleteMap.put("unit_id", unitId);
                         groupMapper.deleteByMap(deleteMap);
                     } else {
-                        interfaceService.getGroup(token, advertiserId, unitId);
+                        groupService.getGroupByUnitId(token, advertiserId, unitId);
                     }
 
 
@@ -592,7 +595,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                     if (!Check.isNull(data)) {
                         try {
                             Thread.sleep(500);
-                            interfaceService.getGroup(accessToken, unitJson.getLong("advertiser_id"), data.getLong("unit_id"));
+                            groupService.getGroupByUnitId(accessToken, unitJson.getLong("advertiser_id"), data.getLong("unit_id"));
                         } catch (InterruptedException e) {
                             e.printStackTrace();
                         }

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

@@ -47,6 +47,7 @@ import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -63,10 +64,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     @Autowired
     private KuaiShouGroupMapper groupMapper;
     @Autowired
-    private KuaiShouAppInfoMapper appInfoMapper;
-    @Autowired
-    private KuaiShouScheduleMapper shouScheduleMapper;
-    @Autowired
     private IKuaiShouCreativeService creativeService;
     @Autowired
     private KuaiShouConversionInfosMapper conversionInfosMapper;
@@ -97,8 +94,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     @Autowired
     private MaterialInfoMapper materialInfoMapper;
     @Autowired
-    private KuaiShouGroupTargetMapper groupTargetMapper;
-    @Autowired
     private KuaiShouTargetingTagsMapper targetingTagsMapper;
     @Autowired
     private KuaishouReportDailyAccountMapper dailyAccountMapper;
@@ -134,6 +129,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     private IKuaiShouDailyFlowsService kuaiShouDailyFlowsService;
     @Autowired
     private IKuaishouPopulationService populationService;
+    @Autowired
+    private IKuaiShouGroupService getKuaiShouGroupService;
 
 
     @Override
@@ -184,11 +181,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
 
     @Override
-    public void getVideoList(CtopOauthToken token, Date startDate, Date endDate) {
-        getVideoListByPage(token, startDate, endDate, 1);
+    public void getVideoList(CtopOauthToken token, String statDate) {
+        getVideoListByPage(token, statDate, 1);
     }
 
-    private void getVideoListByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
+    private void getVideoListByPage(CtopOauthToken token, String statDate, int page) {
         try {
             log.info("获取视频数据,accountId:{}", token.getAccountId());
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
@@ -199,9 +196,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             param.put("advertiser_id", token.getAccountId());
             param.put("page_size", 500);
             param.put("page", page);
-            if (startDate != null && endDate != null) {
-                param.put("start_date", DateUtils.formatDate(startDate));
-                param.put("end_date", DateUtils.formatDate(endDate));
+            if (!Check.isNull(statDate)) {
+                param.put("start_date", statDate);
+                param.put("end_date", statDate);
             }
             String result = HttpUtils.httpPostRequest(url, param, headers);
             JSONObject resultJson = JSONObject.parseObject(result);
@@ -221,6 +218,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
                 kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
                 kuaiShouVideoGet.setAccountId(token.getAccountId());
+                kuaiShouVideoGet.setStatDate(DateUtils.parseDate(statDate, "yyyy-MM-dd"));
                 kuaiShouVideoGet.setUpdateTime(new Date());
                 Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
                 if (!Check.isNull(type)) {
@@ -228,7 +226,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 }
                 kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
             }
-            getVideoListByPage(token, startDate, endDate, page + 1);
+            getVideoListByPage(token, statDate, page + 1);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -887,9 +885,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         //获取全量创意数据
         getCreativeList(token, null, null);
         //获取全量视频素材数据
-        getVideoList(token, null, null);
+
         //获取图片信息数据
-        getImageList(token, null, null);
+
 
         getAppList(token.getAccountId(), token.getAccessToken());
 
@@ -900,6 +898,18 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
         historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
 
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String videoEndDate = DateUtils.addDay(nowDate, -180);
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date end = simpleDateFormat.parse(nowDate);
+        Date start = simpleDateFormat.parse(videoEndDate);
+        List<Date> dates = DateUtils.findDates(start, end);
+        for (int i = 0; i < dates.size(); i++) {
+            String formatDate = simpleDateFormat.format(dates.get(i));
+            getVideoList(token, formatDate);
+            getImageList(token, formatDate);
+        }
+
 
     }
 
@@ -972,6 +982,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      * @param requestJson
      * @return
      */
+
+
     @Override
     public Map<String, Object> adUnitCreate(String accessToken, Long advertiserId, JSONObject requestJson) {
         Map<String, Object> returnMap = new HashMap<>();
@@ -999,7 +1011,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                             public void run() {
                                 try {
                                     Thread.sleep(500);
-                                    getGroup(accessToken, advertiserId, unitId);
+                                    getKuaiShouGroupService.getGroupByUnitId(accessToken, advertiserId, unitId);
                                 } catch (InterruptedException e) {
                                     e.printStackTrace();
                                 }
@@ -1184,60 +1196,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
-    /**
-     * 根据 id 获取组
-     *
-     * @param accessToken
-     * @param advertiserId
-     * @param unitId
-     */
-    @Override
-    public void getGroup(String accessToken, Long advertiserId, Long unitId) {
-
-        Map<String, Object> map = new HashMap<>();
-        map.put("unit_id", unitId);
-        map.put("account_id", advertiserId);
-        groupMapper.deleteByMap(map);
-        appInfoMapper.deleteByMap(map);
-        shouScheduleMapper.deleteByMap(map);
-
-        Map<String, String> headers = new HashMap<>();
-        headers.put("Access-Token", accessToken);
-        headers.put("Content-Type", " application/json");
-
-        JSONObject param = new JSONObject();
-        param.put("advertiser_id", advertiserId);
-        param.put("unit_id", unitId);
-
-        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
-        try {
-            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
-            JSONObject resultJson = JSONObject.parseObject(result);
-            if (!Check.isNull(resultJson)) {
-                Integer code = resultJson.getInteger("code");
-                if (code == 0) {
-                    JSONObject dataJson = resultJson.getJSONObject("data");
-                    if (!Check.isNull(dataJson)) {
-                        JSONArray details = dataJson.getJSONArray("details");
-                        if (!Check.isNull(details)) {
-                            addGroup(advertiserId, details);
-                        }
-
-                    } else {
-                        log.error("获取广告组返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
-                    }
-                } else {
-                    log.error("获取广告组返回结果为空,advertiserId:{}", advertiserId);
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-
-    }
-
-
     private void addGroup(Long advertiserId, JSONArray details) {
         if (!Check.isNull(details)) {
             List<KuaiShouGroup> groups = new ArrayList<>();
@@ -2528,15 +2486,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      * 查询图片列表
      */
     @Override
-    public void getImageList(CtopOauthToken token, Date startDate, Date endDate) {
-        getImageList(token, startDate, endDate, 1);
+    public void getImageList(CtopOauthToken token, String statDate) {
+        getImageList(token, statDate, 1);
     }
 
 
     /**
      * 查询图片列表
      */
-    private void getImageList(CtopOauthToken token, Date startDate, Date endDate, int page) {
+    private void getImageList(CtopOauthToken token, String statDate, int page) {
         try {
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_LIST;
             Map<String, String> headers = new HashMap<String, String>();
@@ -2546,9 +2504,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             //传参
             JSONObject param = new JSONObject();
             param.put("advertiser_id", token.getAccountId());
-            if (startDate != null && endDate != null) {
-                param.put("startDate", DateUtils.formatDate(startDate));
-                param.put("endDate", DateUtils.formatDate(endDate));
+            if (!Check.isNull(statDate)) {
+                param.put("startDate", DateUtils.formatDate(statDate));
+                param.put("endDate", DateUtils.formatDate(statDate));
             }
             param.put("page_size", 500);
             param.put("page", page);
@@ -2585,13 +2543,14 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 if (!Check.isNull(type)) {
                     kuaiShouImageGet.setMaterialType(type);
                 }
+                kuaiShouImageGet.setStatDate(DateUtils.parseDate(statDate, "yyyy-MM-dd"));
 
                 kuaiShouImageGet.setCreateTime(new Date());
                 kuaiShouImageGet.setUpdateTime(new Date());
                 imageGets.add(kuaiShouImageGet);
             }
             kuaiShouImageGetService.replaceBatch(imageGets);
-            getImageList(token, startDate, endDate, page + 1);
+            getImageList(token, statDate, page + 1);
         } catch (Exception e) {
             e.printStackTrace();
 
@@ -2904,9 +2863,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         JSONObject dataJson = resultJson.getJSONObject("data");
         if (!Check.isNull(dataJson)) {
             Integer total_count = dataJson.getInteger("total_count");
-            if (total_count > 2000) {
+           /* if (total_count > 2000) {
                 return;
-            }
+            }*/
             JSONArray details = dataJson.getJSONArray("details");
             if (Check.isNull(details)) {
                 return;