فهرست منبع

人群包2.0bug修复

zhaoxian 4 سال پیش
والد
کامیت
91f3c1fb81
1فایلهای تغییر یافته به همراه18 افزوده شده و 4 حذف شده
  1. 18 4
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/CrowdListQueryJob.java

+ 18 - 4
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/CrowdListQueryJob.java

@@ -6,15 +6,18 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouPopulationPackageRel;
 import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageMapper;
 import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageRelMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationPackageRelService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -26,9 +29,11 @@ public class CrowdListQueryJob {
     @Autowired
     private IKuaishouPopulationService iKuaishouPopulationService;
     @Autowired
-    private KuaishouPopulationPackageMapper KuaishouPopulationPackageMapper;
+    private KuaishouPopulationPackageMapper kuaishouPopulationPackageMapper;
     @Autowired
     private KuaishouPopulationPackageRelMapper relMapper;
+    @Autowired
+    private IKuaishouPopulationPackageRelService relService;
     static ExecutorService executorService = Executors.newFixedThreadPool(3);
 
     @XxlJob("crowdListQueryJob")
@@ -39,9 +44,11 @@ public class CrowdListQueryJob {
                 list.add(i);
             }
         }
-        List<Long> accountIds = KuaishouPopulationPackageMapper.queryListByStatus();
+        List<JSONObject> objs = kuaishouPopulationPackageMapper.queryListByStatus();
         list.forEach(status -> executorService.submit(() -> {
-            for (Long accountId : accountIds) {
+            for (JSONObject o : objs) {
+                Long accountId = o.getLong("account_id");
+                Long projectId = o.getLong("project_id");
                 CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
                 if (!Check.isNull(token)) {
                     JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(accountId, token.getAccessToken(), status);
@@ -53,7 +60,14 @@ public class CrowdListQueryJob {
                                 for (int j = 0; j < details.size(); j++) {
                                     JSONObject obj = details.getJSONObject(j);
                                     KuaishouPopulationPackageRel rel = JSONObject.parseObject(obj.toJSONString(), KuaishouPopulationPackageRel.class);
-                                    relMapper.updateStatus(rel);
+                                    if (Check.isNull(relMapper.queryByOrientationId(rel.getOrientationId(), rel.getAccountId()))) {
+                                        rel.setProjectId(projectId);
+                                        rel.setDataStatus(1);
+                                        rel.setStatDate(DateUtils.formatDate(new Date()));
+                                        relService.save(rel);
+                                    } else {
+                                        relMapper.updateStatus(rel);
+                                    }
                                 }
                             }
                         }