|
@@ -5,6 +5,7 @@ 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.entity.KuaishouCrowdPack;
|
|
import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouCrowdPackMapper;
|
|
import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouCrowdPackMapper;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouCrowdPackService;
|
|
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;
|
|
@@ -22,31 +23,52 @@ import java.util.concurrent.Executors;
|
|
public class CrowdListQueryJob {
|
|
public class CrowdListQueryJob {
|
|
@Autowired
|
|
@Autowired
|
|
private ICtopOauthTokenService tokenService;
|
|
private ICtopOauthTokenService tokenService;
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private KuaishouCrowdPackMapper crowdPackMapper;
|
|
private KuaishouCrowdPackMapper crowdPackMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaishouPopulationService iKuaishouPopulationService;
|
|
private IKuaishouPopulationService iKuaishouPopulationService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouCrowdPackService crowdPackService;
|
|
|
|
|
|
static ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
static ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
|
|
|
|
@XxlJob("crowdListQueryJob")
|
|
@XxlJob("crowdListQueryJob")
|
|
public void execute() {
|
|
public void execute() {
|
|
List<Integer> list = new ArrayList<>();
|
|
List<Integer> list = new ArrayList<>();
|
|
- for (int i = 0; i <= 7; i++) {
|
|
|
|
- list.add(i);
|
|
|
|
|
|
+ for (int i = 0; i <= 6; i++) {
|
|
|
|
+ if (i != 2) {
|
|
|
|
+ list.add(i);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
list.forEach(status -> executorService.submit(() -> {
|
|
list.forEach(status -> executorService.submit(() -> {
|
|
List<KuaishouCrowdPack> crowdList = crowdPackMapper.queryListByStatus();
|
|
List<KuaishouCrowdPack> crowdList = crowdPackMapper.queryListByStatus();
|
|
for (KuaishouCrowdPack crowdPack : crowdList) {
|
|
for (KuaishouCrowdPack crowdPack : crowdList) {
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(crowdPack.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(crowdPack.getAccountId());
|
|
- JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(crowdPack.getAccountId(), token.getAccessToken(), crowdPack.getStatus());
|
|
|
|
|
|
+ JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(crowdPack.getAccountId(), token.getAccessToken(), status);
|
|
if (jsonObject.getInteger("code") == 0) {
|
|
if (jsonObject.getInteger("code") == 0) {
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
if (!Check.isNull(data)) {
|
|
if (!Check.isNull(data)) {
|
|
JSONArray details = data.getJSONArray("details");
|
|
JSONArray details = data.getJSONArray("details");
|
|
if (details.size() > 0) {
|
|
if (details.size() > 0) {
|
|
- crowdPackMapper.updateBatch(details);
|
|
|
|
|
|
+ JSONArray datas = new JSONArray();
|
|
|
|
+ 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 {
|
|
|
|
+ datas.add(obj);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ crowdPackMapper.updateBatch(datas);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|