提交 ce78a979 作者: 925993793@qq.com

自定义专题绑定信息源变更通知采集,另起线程处理,不影响主业务逻辑

上级 4afc74d5
......@@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@Service
......@@ -197,35 +198,37 @@ public class ConfigurationMessageService {
public void bindInfoSourceSend(String subjectId){
try {
remoteModelService.delSubjectCache(subjectId);
} catch (Exception e) {
log.error("删除专题缓存失败{}",e.getMessage(),e);
}
Subject byId = subjectService.getSubjectOrEventById(subjectId);
if (byId == null || byId.getStatus() == null || byId.getStatus() != 1) {
log.info("未查询到专题或专题未启用");
return;
}
//只有启用状态的专题才需要通知采集更新绑定数据
List<String> bindIds = getAllInfoSourceIds(subjectId);
String getparam ;
if (CollectionUtil.isNotEmpty(bindIds)) {
getparam = getparam(byId, null, bindIds);
}else {
log.info("专题未绑定信息源,通知采集清空");
getparam = getparam(byId, null, new ArrayList<>());
}
String post = caiJiCenterHttpService.allInfosourcebindUrl(getparam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
if (ObjectUtil.isEmpty(code) || code != 200) {
log.error("专题信息源配置通知采集失败{}",post);
throw new RuntimeException("专题信息源配置通知采集失败");
}
log.info("{}专题信息源配置通知采集结束",byId.getSubjectName());
CompletableFuture.runAsync(() -> {
try {
remoteModelService.delSubjectCache(subjectId);
} catch (Exception e) {
log.error("删除专题缓存失败{}",e.getMessage(),e);
}
Subject byId = subjectService.getSubjectOrEventById(subjectId);
if (byId == null || byId.getStatus() == null || byId.getStatus() != 1) {
log.info("未查询到专题或专题未启用");
return;
}
//只有启用状态的专题才需要通知采集更新绑定数据
List<String> bindIds = getAllInfoSourceIds(subjectId);
String getparam ;
if (CollectionUtil.isNotEmpty(bindIds)) {
getparam = getparam(byId, null, bindIds);
}else {
log.info("专题未绑定信息源,通知采集清空");
getparam = getparam(byId, null, new ArrayList<>());
}
String post = caiJiCenterHttpService.allInfosourcebindUrl(getparam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
if (ObjectUtil.isEmpty(code) || code != 200) {
log.error("专题信息源配置通知采集失败{}",post);
throw new RuntimeException("专题信息源配置通知采集失败");
}
log.info("{}专题信息源配置通知采集结束",byId.getSubjectName());
});
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论