Browse Source

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

zhaoxian 4 years ago
parent
commit
328911738c

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

@@ -8,11 +8,11 @@ import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
 import com.alibaba.fastjson.JSONArray;
 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.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
@@ -36,9 +36,14 @@ import java.util.*;
 @RequestMapping("/ctop/aiKuaishouAdvertiserStrategy")
 public class AiKuaishouAdvertiserStrategyController {
     @Autowired
+    private IKuaishouVideoRelateCreativesService kuaishouVideoRelateCreativesService;
+    @Autowired
     private IAiKuaishouAdvertiserStrategyService aiKuaishouAdvertiserStrategyService;
     @Autowired
+    private IUserAllocationService allocationService;
+    @Autowired
     private ISysRoleService sysRoleService;
+
     /**
      * 分页列表查询
      *
@@ -48,7 +53,6 @@ public class AiKuaishouAdvertiserStrategyController {
      * @param req
      * @return
      */
-    @ApiOperation(value = "快手账户策略设置信息表-分页列表查询", notes = "快手账户策略设置信息表-分页列表查询")
     @GetMapping(value = "/list")
     public Result<IPage<AiKuaishouAdvertiserStrategy>> queryPageList(AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy,
                                                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@@ -82,16 +86,12 @@ public class AiKuaishouAdvertiserStrategyController {
         return result;
     }
 
-    @Autowired
-    private IUserAllocationService allocationService;
-
     /**
      * 添加
      *
      * @param aiKuaishouAdvertiserStrategy
      * @return
      */
-    @ApiOperation(value = "快手账户策略设置信息表-添加", notes = "快手账户策略设置信息表-添加")
     @PostMapping(value = "/add")
     public Result<AiKuaishouAdvertiserStrategy> add(@RequestBody AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy) {
         Result<AiKuaishouAdvertiserStrategy> result = new Result<>();
@@ -112,6 +112,13 @@ public class AiKuaishouAdvertiserStrategyController {
                 aiKuaishouAdvertiserStrategy.setAppId(appId);
             }
             aiKuaishouAdvertiserStrategyService.save(aiKuaishouAdvertiserStrategy);
+            Thread thread = new Thread(){
+                @Override
+                public void run() {
+                    kuaishouVideoRelateCreativesService.videoRelateCreatives(aiKuaishouAdvertiserStrategy.getAccountId());
+                }
+            };
+            thread.start();
             result.success("添加成功!");
         } catch (Exception e) {
             log.error(e.getMessage(), e);
@@ -119,7 +126,6 @@ public class AiKuaishouAdvertiserStrategyController {
         }
         return result;
     }
-
     /**
      * 编辑
      *
@@ -205,7 +211,6 @@ public class AiKuaishouAdvertiserStrategyController {
      * @param id
      * @return
      */
-    @ApiOperation(value = "快手账户策略设置信息表-通过id删除", notes = "快手账户策略设置信息表-通过id删除")
     @DeleteMapping(value = "/delete")
     public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
         try {
@@ -223,7 +228,6 @@ public class AiKuaishouAdvertiserStrategyController {
      * @param ids
      * @return
      */
-    @ApiOperation(value = "快手账户策略设置信息表-批量删除", notes = "快手账户策略设置信息表-批量删除")
     @DeleteMapping(value = "/deleteBatch")
     public Result<AiKuaishouAdvertiserStrategy> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
         Result<AiKuaishouAdvertiserStrategy> result = new Result<>();
@@ -242,7 +246,6 @@ public class AiKuaishouAdvertiserStrategyController {
      * @param id
      * @return
      */
-    @ApiOperation(value = "快手账户策略设置信息表-通过id查询", notes = "快手账户策略设置信息表-通过id查询")
     @GetMapping(value = "/queryById")
     public Result<AiKuaishouAdvertiserStrategy> queryById(@RequestParam(name = "id", required = true) String id) {
         Result<AiKuaishouAdvertiserStrategy> result = new Result<>();
@@ -255,4 +258,9 @@ public class AiKuaishouAdvertiserStrategyController {
         }
         return result;
     }
+
+    @GetMapping(value = "testCreate")
+    public Map<String,Object> testCreate(Long accountId){
+        return aiKuaishouAdvertiserStrategyService.testCreate(accountId);
+    }
 }

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

@@ -3,6 +3,8 @@ package cn.com.ctop.kuaishou.modules.ai.service;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.Map;
+
 /**
  * @Description: 快手账户策略设置信息表
  * @Author: jeecg-boot
@@ -13,4 +15,5 @@ public interface IAiKuaishouAdvertiserStrategyService extends IService<AiKuaisho
 
     AiKuaishouAdvertiserStrategy getByAccountId(Long accountId);
 
+    Map<String, Object> testCreate(Long accountId);
 }

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

@@ -1,12 +1,22 @@
 package cn.com.ctop.kuaishou.modules.ai.service.impl;
 
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaishouAdvertiserStrategyMapper;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * 快手账户策略设置信息表
  * @author jeecg-boot
@@ -15,7 +25,10 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuaishouAdvertiserStrategyMapper, AiKuaishouAdvertiserStrategy> implements IAiKuaishouAdvertiserStrategyService {
-
+    public static final String TEST_CREATIVE_URL= "http://139.186.27.96:31012/ai_historical_missing_material";
+    public static final String TEST_PROGRAM_CREATIVE_URL= "http://139.186.27.96:31012/ai_programme_new_material";
+    @Autowired
+    private IUserAllocationService userAllocationService;
     @Override
     public AiKuaishouAdvertiserStrategy getByAccountId(Long accountId) {
         QueryWrapper<AiKuaishouAdvertiserStrategy>queryWrapper =new QueryWrapper<>();
@@ -24,4 +37,39 @@ public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuais
         queryWrapper.last("limit 1");
         return this.getOne(queryWrapper);
     }
+
+    @Override
+    public Map<String, Object> testCreate(Long accountId) {
+        Map<String,Object>result = new HashMap<>();
+        if(null == accountId||accountId == 0){
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy = this.getByAccountId(accountId);
+        if(null == aiKuaishouAdvertiserStrategy||null == aiKuaishouAdvertiserStrategy.getStatus()||aiKuaishouAdvertiserStrategy.getStatus()!=1){
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        UserAllocation allocation = userAllocationService.getByAccountId(accountId);
+        if(null == allocation){
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        JSONObject params = new JSONObject();
+        params.put("account_id",accountId);
+        params.put("test_video_cnt",1);
+        String request = null;
+        //程序化
+        if(aiKuaishouAdvertiserStrategy.getOpenProgramCreate() == 1){
+            request = HttpUtils.httpPostRequest(TEST_PROGRAM_CREATIVE_URL,params,new HashMap<>());
+        }else{
+            request = HttpUtils.httpPostRequest(TEST_CREATIVE_URL, params, new HashMap<>());
+        }
+        JSONObject requestObject = JSONObject.parseObject(request);
+        String message = requestObject.getString("message");
+        Integer code = requestObject.getInteger("code");
+        result.put("code",code);
+        result.put("message",message);
+        return result;
+    }
 }

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

@@ -68,15 +68,12 @@ public class KuaishouAccountSpeedExploreLogServiceImpl extends ServiceImpl<Kuais
 // TODO       kuaishouInterfaceService.getAdvertiserGroupReportDaily(token,startDate,endDate);
         //3:根据转化目标查询相应的符合条件的广告组数据
         //优化目标 2 行为数 180 激活数 53 表单数 190 付费 191 首日ROI
-        Integer convertType = kuaishouAccountSpeedExploreLog.getConvertType();
         //查询相关符合条件的广告组数据
         List<SpeedExploreGroupVO> speedExploreGroupVos = this.getSpeedExploreGroupVOSByParams(DateUtils.formatDate(endDate),kuaishouAccountSpeedExploreLog.getAccountId(),kuaishouAccountSpeedExploreLog.getConvertType(),kuaishouAccountSpeedExploreLog.getConvertCount(),kuaishouAccountSpeedExploreLog.getGroupCount());
         if(null==speedExploreGroupVos||speedExploreGroupVos.isEmpty()){
             speedExploreGroupVos.forEach(speedExploreGroupVO -> {
                 //触发加速探索逻辑
                 kuaishouGroupExploreService.unitOpenSpeedExplore(speedExploreGroupVO.getAccountId(),speedExploreGroupVO.getUnitId(),kuaishouAccountSpeedExploreLog.getGroupAccount(),kuaishouAccountSpeedExploreLog.getId());
-                //缺广告组加速探索记录数据表
-
             });
         }
 

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

@@ -29,4 +29,6 @@ public interface IKuaishouVideoRelateCreativesService extends IService<KuaishouV
     List<JSONObject> getVideoZeroListByMap(Map<String, Object> requestMap);
 
     List<JSONObject> getHistoryTopVideoList(Map<String, Object> requestMap);
+
+    void videoRelateCreatives(Long accountId);
 }

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

@@ -149,7 +149,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         param.put("page", page);
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
-        System.err.println(resultJson);
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");
         if (null == code || code != 0) {

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

@@ -9,6 +9,7 @@ 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;
@@ -20,11 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 import java.util.*;
 
 /**
@@ -175,4 +171,33 @@ public class KuaishouVideoRelateCreativesServiceImpl extends ServiceImpl<Kuaisho
     public List<JSONObject> getHistoryTopVideoList(Map<String, Object> requestMap) {
         return kuaishouVideoRelateCreativesMapper.getHistoryTopVideoList(requestMap);
     }
+
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+
+    @Override
+    public 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 < 20) {
+                    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);
+            this.videoRelateCreatives(accountId, dateList, statdateMap);
+        }
+    }
 }