|
@@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.Hashtable;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
@@ -45,12 +46,13 @@ public class CrowdListQueryJob {
|
|
|
}
|
|
|
}
|
|
|
List<JSONObject> objs = kuaishouPopulationPackageMapper.queryListByStatus();
|
|
|
- list.forEach(status -> executorService.submit(() -> {
|
|
|
- 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)) {
|
|
|
+ objs.forEach(o -> executorService.submit(() -> {
|
|
|
+ Long accountId = o.getLong("account_id");
|
|
|
+ Long projectId = o.getLong("project_id");
|
|
|
+ Hashtable newIds = new Hashtable();
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
+ if (!Check.isNull(token)) {
|
|
|
+ for (Integer status : list) {
|
|
|
JSONObject jsonObject = iKuaishouPopulationService.getPopulationList(accountId, token.getAccessToken(), status);
|
|
|
if (jsonObject.getInteger("code") == 0) {
|
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
@@ -60,12 +62,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);
|
|
|
+ newIds.put(rel.getOrientationId(), rel.getOrientationId());
|
|
|
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 {
|
|
|
+ rel.setDataStatus(1);
|
|
|
relMapper.updateStatus(rel);
|
|
|
}
|
|
|
}
|
|
@@ -73,6 +77,19 @@ public class CrowdListQueryJob {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //查询现有的人群包ID集
|
|
|
+ List<Long> oldOrientationIds = relMapper.queryByOrientationId(null, accountId);
|
|
|
+ if (oldOrientationIds.size() != newIds.size()) {
|
|
|
+ for (Long id : oldOrientationIds) {
|
|
|
+ if (!newIds.contains(id)) {
|
|
|
+ KuaishouPopulationPackageRel rel = new KuaishouPopulationPackageRel();
|
|
|
+ rel.setDataStatus(0);
|
|
|
+ rel.setOrientationId(id);
|
|
|
+ rel.setAccountId(accountId);
|
|
|
+ relMapper.updateStatus(rel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}));
|
|
|
XxlJobHelper.log("快手人群报表更新成功");
|