浏览代码

添加广告组学习状态字段----优化更新头条素材类型sql执行速度

syh 4 年之前
父节点
当前提交
4c14558d5e

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

@@ -29,6 +29,7 @@ public class KuaishouAccountSpeedExploreLog {
 	private BigDecimal groupAccount;
 	/**groupCount*/
 	private Integer groupCount;
+	private Integer convertType;
 	/**convertCount*/
 	private Integer convertCount;
 	/**userId*/

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

@@ -13,7 +13,7 @@ import java.util.Map;
  */
 public interface IKuaishouAccountSpeedExploreLogService extends IService<KuaishouAccountSpeedExploreLog> {
 
-    Map<String, Object> openSpeedExplore(KuaishouAccountSpeedExploreLog kuaishouAccountSpeedExploreLog);
+    Map<String, Object> openSpeedExplore(KuaishouAccountSpeedExploreLog kuaishouAccountSpeedExploreLog)throws Exception;
 
     KuaishouAccountSpeedExploreLog getByParams(Long accountId, Integer status);
 }

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

@@ -1,14 +1,21 @@
 package cn.com.ctop.kuaishou.modules.ai.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.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountSpeedExploreLog;
 import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAccountSpeedExploreLogMapper;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountSpeedExploreLogService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -20,9 +27,12 @@ import java.util.Map;
  */
 @Service
 public class KuaishouAccountSpeedExploreLogServiceImpl extends ServiceImpl<KuaishouAccountSpeedExploreLogMapper, KuaishouAccountSpeedExploreLog> implements IKuaishouAccountSpeedExploreLogService {
-
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
     @Override
-    public Map<String, Object> openSpeedExplore(KuaishouAccountSpeedExploreLog kuaishouAccountSpeedExploreLog) {
+    public Map<String, Object> openSpeedExplore(KuaishouAccountSpeedExploreLog kuaishouAccountSpeedExploreLog) throws Exception{
         Map<String,Object> result = new HashMap<>();
         //查询当前账户是否加速探索中
         KuaishouAccountSpeedExploreLog getEntity = this.getByParams(kuaishouAccountSpeedExploreLog.getAccountId(),1);
@@ -34,10 +44,28 @@ public class KuaishouAccountSpeedExploreLogServiceImpl extends ServiceImpl<Kuais
         kuaishouAccountSpeedExploreLog.setStatus(1);
         this.save(kuaishouAccountSpeedExploreLog);
         //触发加速探索任务
-
+        this.startSpeedExplore(kuaishouAccountSpeedExploreLog);
         return result;
     }
 
+    private void startSpeedExplore(KuaishouAccountSpeedExploreLog kuaishouAccountSpeedExploreLog) throws Exception{
+        Date endDate = new Date();
+        String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
+        SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
+        Date startDate = sim.parse(anotherDay);
+        CtopOauthToken token = tokenService.getTokenByAccountId(kuaishouAccountSpeedExploreLog.getAccountId());
+        //1: 拉取账户下所有的广告组信息
+        kuaishouInterfaceService.getGroupList(token, startDate, endDate);
+        //2: 查询处于学习期的广告组数据
+        kuaishouInterfaceService.getAdvertiserGroupReportDaily(token,startDate,endDate);
+        //3:根据转化目标查询相应的符合条件的广告组数据
+        //优化目标 2 行为数 180 激活数 53 表单数 190 付费 191 首日ROI
+        Integer convertType = kuaishouAccountSpeedExploreLog.getConvertType();
+
+
+
+    }
+
     @Override
     public KuaishouAccountSpeedExploreLog getByParams(Long accountId, Integer status) {
         QueryWrapper<KuaishouAccountSpeedExploreLog> queryWrapper = new QueryWrapper<>();