Browse Source

加速探索定时任务

syh 4 years ago
parent
commit
fdddcbd1e8

+ 31 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouGroupExploreJob.java

@@ -0,0 +1,31 @@
+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.kuaishou.modules.report.service.IKuaishouGroupExploreService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.text.ParseException;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class KuaishouGroupExploreJob {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouGroupExploreService kuaishouGroupExploreService;
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+    @XxlJob("kuaishouGroupExploreReportJob")
+    public void execute() throws ParseException {
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        tokens.forEach(token -> executorService.submit(() ->
+                kuaishouGroupExploreService.getReportByAccount(token))
+        );
+        XxlJobHelper.log("快手物料数据同步完成");
+    }
+}

+ 3 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouGroupExploreService.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.report.service;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -23,6 +24,7 @@ public interface IKuaishouGroupExploreService extends IService<KuaishouGroupExpl
 
     Result<Object> querySpeedExploreReport(JSONObject data);
 
-
     void unitOpenSpeedExplore(Long accountId, Long unitId, BigDecimal groupAccount,Long accountExploreId);
+
+    void getReportByAccount(CtopOauthToken token);
 }

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

@@ -4,6 +4,7 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouGroupSpeedExploreLog;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouGroupSpeedExploreLogService;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouGroupExploreMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouGroupExploreService;
@@ -31,7 +32,8 @@ import java.util.Map;
 public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupExploreMapper, KuaishouGroupExplore> implements IKuaishouGroupExploreService {
     @Autowired
     private ICtopOauthTokenService tokenService;
-
+    @Autowired
+    private IKuaishouGroupSpeedExploreLogService groupSpeedExploreLogService;
 
     /**
      * 查询加速探索信息
@@ -254,7 +256,12 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
             groupSpeedExploreLog.setStatus(StatusCode.COMMON_SERVER_ERROR.getCode());
             groupSpeedExploreLog.setMessage(StatusCode.COMMON_SERVER_ERROR.getDesc());
         }
+        groupSpeedExploreLogService.save(groupSpeedExploreLog);
+    }
 
+    @Override
+    public void getReportByAccount(CtopOauthToken token) {
+        //1:查询此账户下设置了加速探索的组
     }