|
@@ -3,9 +3,7 @@ package cn.com.ctop.job.kuaishou.handler;
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouCrowdPackMapper;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouCrowdPackService;
|
|
|
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouPopulationPackageMapper;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -24,13 +22,10 @@ public class CrowdListQueryJob {
|
|
@Autowired
|
|
@Autowired
|
|
private ICtopOauthTokenService tokenService;
|
|
private ICtopOauthTokenService tokenService;
|
|
@Autowired
|
|
@Autowired
|
|
- private KuaishouCrowdPackMapper crowdPackMapper;
|
|
|
|
- @Autowired
|
|
|
|
private IKuaishouPopulationService iKuaishouPopulationService;
|
|
private IKuaishouPopulationService iKuaishouPopulationService;
|
|
@Autowired
|
|
@Autowired
|
|
- private IKuaishouCrowdPackService crowdPackService;
|
|
|
|
-
|
|
|
|
- static ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
|
|
|
|
+ private KuaishouPopulationPackageMapper KuaishouPopulationPackageMapper;
|
|
|
|
+ static ExecutorService executorService = Executors.newFixedThreadPool(3);
|
|
|
|
|
|
@XxlJob("crowdListQueryJob")
|
|
@XxlJob("crowdListQueryJob")
|
|
public void execute() {
|
|
public void execute() {
|
|
@@ -40,31 +35,20 @@ public class CrowdListQueryJob {
|
|
list.add(i);
|
|
list.add(i);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ List<Long> accountIds = KuaishouPopulationPackageMapper.queryListByStatus();
|
|
list.forEach(status -> executorService.submit(() -> {
|
|
list.forEach(status -> executorService.submit(() -> {
|
|
- List<KuaishouCrowdPack> crowdList = crowdPackMapper.queryListByStatus();
|
|
|
|
- for (KuaishouCrowdPack crowdPack : crowdList) {
|
|
|
|
- CtopOauthToken token = tokenService.getTokenByAccountId(crowdPack.getAccountId());
|
|
|
|
- JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(crowdPack.getAccountId(), token.getAccessToken(), status);
|
|
|
|
- if (jsonObject.getInteger("code") == 0) {
|
|
|
|
- JSONObject data = jsonObject.getJSONObject("data");
|
|
|
|
- if (!Check.isNull(data)) {
|
|
|
|
- JSONArray details = data.getJSONArray("details");
|
|
|
|
- if (details.size() > 0) {
|
|
|
|
- for (int j = 0; j < details.size(); j++) {
|
|
|
|
- JSONObject obj = details.getJSONObject(j);
|
|
|
|
- if (Check.isNull(crowdPackMapper.queryByAccountId(obj.getLong("account_id"), obj.getLong("orientation_id")))) {
|
|
|
|
- KuaishouCrowdPack oldPack = crowdPackMapper.queryByAccountId(null, obj.getLong("orientation_id"));
|
|
|
|
- KuaishouCrowdPack crowdPackEntity = JSONObject.toJavaObject(obj, KuaishouCrowdPack.class);
|
|
|
|
- if (!Check.isNull(oldPack)) {
|
|
|
|
- crowdPackEntity.setStatDate(oldPack.getStatDate());
|
|
|
|
- crowdPackEntity.setUrl(oldPack.getUrl());
|
|
|
|
- crowdPackEntity.setSignature(oldPack.getSignature());
|
|
|
|
- }
|
|
|
|
- crowdPackEntity.setMessage("PUSH OK");
|
|
|
|
- crowdPackEntity.setDataStatus(1);
|
|
|
|
- crowdPackService.save(crowdPackEntity);
|
|
|
|
- } else {
|
|
|
|
- crowdPackMapper.update(obj);
|
|
|
|
|
|
+ for (Long accountId : accountIds) {
|
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
|
+ if (!Check.isNull(token)) {
|
|
|
|
+ JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(accountId, token.getAccessToken(), status);
|
|
|
|
+ if (jsonObject.getInteger("code") == 0) {
|
|
|
|
+ JSONObject data = jsonObject.getJSONObject("data");
|
|
|
|
+ if (!Check.isNull(data)) {
|
|
|
|
+ JSONArray details = data.getJSONArray("details");
|
|
|
|
+ if (details.size() > 0) {
|
|
|
|
+ for (int j = 0; j < details.size(); j++) {
|
|
|
|
+ JSONObject obj = details.getJSONObject(j);
|
|
|
|
+ KuaishouPopulationPackageMapper.updateStatus(obj.getLong("account_id"), obj.getLong("orientation_id"), obj.getInteger("status"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|