提交 ce70b2fb 作者: obcy

【信息源组绑定解绑--信息源变动通知采集逻辑修改】

上级 6ba8a2c5
......@@ -23,6 +23,6 @@ public interface RemoteSystemService {
@GetMapping("/sys/api/listItemByDictCode")
Object getDictList(@RequestParam("dictCode") String dictCode);
String getDictList(@RequestParam("dictCode") String dictCode);
}
......@@ -28,4 +28,6 @@ public interface SubjectAdditionMapper extends BaseMapper<SubjectAddition> {
List<SubjectAddition> pageListBySubjectIdAndType(String subjectId, int type, int offset, Integer pageSize);
int count(String subjectId, int type);
List<String> getSubjectBindInfoSourceIds(@Param("subjectId") String subjectId);
}
......@@ -75,10 +75,10 @@
WHERE
b.id IS NOT NULL
<if test="infoSourceMain.infoAddress!=null and infoSourceMain.infoAddress != ''">
and a.infoAddress like CONCAT('%',#{infoSourceMain.infoAddress},'%')
and a.info_address like CONCAT('%',#{infoSourceMain.infoAddress},'%')
</if>
<if test="infoSourceMain.infoName!=null and infoSourceMain.infoName != ''">
and a.infoName like CONCAT('%',#{infoSourceMain.infoName},'%')
and a.info_name like CONCAT('%',#{infoSourceMain.infoName},'%')
</if>
<if test="infoSourceMain.code!=null and infoSourceMain.code != ''">
and a.code like CONCAT('%',#{infoSourceMain.code},'%')
......
......@@ -251,4 +251,131 @@
select count(1) from subject_addition where subject_id=#{subjectId} and addition_type=#{type}
</select>
<select id="getSubjectBindInfoSourceIds" resultType="java.lang.String">
SELECT
distinct x.id
FROM
(
SELECT
iso.id
FROM
subject_info_source_map sm
INNER JOIN info_source iso ON sm.source_id = iso.id
WHERE
sm.type IN ( 1, 6 )
AND sm.subject_id = #{subjectId} UNION
SELECT
iso.id
FROM
subject_info_source_map sm
INNER JOIN info_source_main im ON im.id = sm.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sm.type IN ( 31, 36 )
AND sm.subject_id = #{subjectId} UNION
SELECT
iso.id
FROM
subject_info_source_map sim
INNER JOIN info_source_group_map m ON m.group_id = sim.source_id
INNER JOIN info_source iso ON m.source_id = iso.id
WHERE
sim.type IN ( 2, 5 )
AND sim.subject_id = #{subjectId} UNION
SELECT
iso.id
FROM
subject_info_source_map sim
INNER JOIN info_source_main_group_map m ON m.group_id = sim.source_id
INNER JOIN info_source_main im ON im.id = m.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sim.type IN ( 32, 35 )
AND sim.subject_id = #{subjectId} UNION
SELECT
isoo.id
FROM
subject_info_source_map smm
INNER JOIN clb_label_info_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source isoo ON lam.entity_code = isoo.id
WHERE
smm.type IN ( 12, 15 )
AND smm.subject_id = #{subjectId} UNION
SELECT
isoo.id
FROM
subject_info_source_map smm
INNER JOIN clb_label_main_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source_main im ON lam.entity_code = im.id
INNER JOIN info_source isoo ON im.id = isoo.info_source_id
WHERE
smm.type IN ( 312, 315 )
AND smm.subject_id = #{subjectId}
) x
WHERE
1 = 1
AND x.id NOT IN (
SELECT DISTINCT
y.source_id
FROM
(
SELECT
m.source_id
FROM
info_source_group_map m
WHERE
m.group_id IN ( SELECT source_id FROM subject_info_source_map WHERE type = 4 AND subject_id = #{subjectId} GROUP BY source_id ) UNION
SELECT
iso.id
FROM
subject_info_source_map sim
INNER JOIN info_source_main_group_map m ON m.group_id = sim.source_id
INNER JOIN info_source_main im ON im.id = m.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sim.type = 34
AND sim.subject_id = #{subjectId} UNION
SELECT
sm.source_id
FROM
subject_info_source_map sm
WHERE
type = 3
AND sm.subject_id = #{subjectId} UNION
SELECT
iso.id
FROM
subject_info_source_map sm
INNER JOIN info_source_main im ON im.id = sm.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sm.type = 33
AND sm.subject_id = #{subjectId} UNION
SELECT
isoo.id
FROM
subject_info_source_map smm
INNER JOIN clb_label_info_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source isoo ON lam.entity_code = isoo.id
WHERE
smm.type = 14
AND smm.subject_id = #{subjectId} UNION
SELECT
isoo.id
FROM
subject_info_source_map smm
INNER JOIN clb_label_main_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source_main im ON lam.entity_code = im.id
INNER JOIN info_source isoo ON im.id = isoo.info_source_id
WHERE
smm.type = 314
AND smm.subject_id = #{subjectId}
) y
)
</select>
</mapper>
\ No newline at end of file
......@@ -127,182 +127,6 @@ public class ConfigurationMessageService {
@Autowired(required = false)
private RemoteModelService remoteModelService;
/**
* 绑定解绑信息源
* option 绑定,解绑
* idsType 绑定或者解绑的类型
*
* */
public void sendConfigurationMessage(String subjectId, List<String> ids,String option,String idsType) {
if (ids == null || ids.size() == 0) {
return;
}
Subject byId = subjectService.getById(subjectId);
if (byId == null) {
return;
}
if (OptionType.BIND.getCode().equals(option)) {
//绑定
if (MessageType.INFOSOURCE_GROUP.getCode().equals(idsType)) {
//绑定信息源组
List<String> infoSourceIds = infoSourceService.listByGroupIds(ids);
List<String> excludeIds = getExcludeIds(subjectId);
if (CollectionUtil.isNotEmpty(excludeIds)) {
infoSourceIds.removeAll(excludeIds);
}
if (infoSourceIds!= null && infoSourceIds.size() > 0) {
caiJiCenterHttpService.infosourcebindUrl(getparam(byId,OptionType.BIND.getValue(),infoSourceIds));
}
} else if (MessageType.INFOSOURCE.getCode().equals(idsType)) {
//绑定信息源
List<String> excludeIds = getExcludeIds(subjectId);
if (CollectionUtil.isNotEmpty(excludeIds)) {
ids.removeAll(excludeIds);
}
if (ids!= null && ids.size() > 0) {
caiJiCenterHttpService.infosourcebindUrl(getparam(byId,OptionType.BIND.getValue(),ids));
}
} else if (MessageType.INFOSOURCE_LABEL.getCode().equals(idsType)) {
//绑定信息源标签
List<String> excludeIds = getExcludeIds(subjectId);
if (CollectionUtil.isNotEmpty(excludeIds)) {
ids.removeAll(excludeIds);
}
if (ids!= null && ids.size() > 0) {
caiJiCenterHttpService.infosourcebindUrl(getparam(byId,OptionType.BIND.getValue(),ids));
}
}
} else if (OptionType.UNBIND.getCode().equals(option)) {
//解绑
if (MessageType.INFOSOURCE_GROUP.getCode().equals(idsType)) {
//解绑信息源组
List<String> bindIds = getBindIds(subjectId);
List<String> infoSourceIds = infoSourceService.listByGroupIds(ids);
if (infoSourceIds!= null && infoSourceIds.size() > 0) {
if (CollectionUtil.isNotEmpty(bindIds)) {
infoSourceIds.removeAll(bindIds);
}
if (CollectionUtil.isNotEmpty(infoSourceIds)) {
caiJiCenterHttpService.infosourcebindUrl(getparam(byId,OptionType.UNBIND.getValue(),infoSourceIds));
}
}
} else if (MessageType.INFOSOURCE.getCode().equals(idsType)) {
//解绑信息源
if (ids!= null && ids.size() > 0) {
List<String> bindIds = getBindIds(subjectId);
if (CollectionUtil.isNotEmpty(bindIds)) {
ids.removeAll(bindIds);
}
caiJiCenterHttpService.infosourcebindUrl(getparam(byId,OptionType.UNBIND.getValue(),ids));
}
} else if (MessageType.INFOSOURCE_LABEL.getCode().equals(idsType)) {
//解绑信息源标签
List<String> bindIds = getBindIds(subjectId);
if (CollectionUtil.isNotEmpty(bindIds)) {
ids.removeAll(bindIds);
}
if (ids!= null && ids.size() > 0) {
caiJiCenterHttpService.infosourcebindUrl(getparam(byId,OptionType.UNBIND.getValue(),ids));
}
}
}
}
public void sendConfigurationMessage(String subjectId,List<String> old,List<String> now,String option) {
Subject byId = subjectService.getById(subjectId);
if (byId == null) {
return;
}
if (OptionType.UNBIND.getCode().equals(option)) {
if (CollectionUtil.isEmpty(old)) {
return;
}
old.removeAll(now);
if (CollectionUtil.isNotEmpty(old)) {
String getparam = getparam(byId, OptionType.UNBIND.getValue(), old);
String post = caiJiCenterHttpService.infosourcebindUrl(getparam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
if (ObjectUtil.isEmpty(code) || code != 200) {
log.error("解绑信息源通知采集失败{}",post);
throw new RuntimeException("解绑信息源通知采集失败");
}
}
}else {
List<String> bindIds = new ArrayList<>();
if (CollectionUtil.isNotEmpty(now)) {
bindIds.addAll(now);
}
if (CollectionUtil.isNotEmpty(old)) {
bindIds.removeAll(old);
}
if (CollectionUtil.isNotEmpty(bindIds)) {
String getparam = getparam(byId, OptionType.BIND.getValue(), bindIds);
log.info("绑定信息源通知采集{}",getparam);
String post = caiJiCenterHttpService.infosourcebindUrl(getparam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
if (ObjectUtil.isEmpty(code) || code != 200) {
log.error("绑定信息源通知采集失败{}",post);
throw new RuntimeException("绑定信息源通知采集失败");
}
}
}
}
public void sendKeyWordsConfigurationMessage(String subjectId, List<String> keywordsIds, String option) {
Subject byId = subjectService.getById(subjectId);
if (byId == null) {
return;
}
if (CollectionUtil.isEmpty(keywordsIds)) {
return;
}
List<KeyWords> keyWords = keyWordsService.listByIds(keywordsIds);
if (OptionType.UNBIND.getCode().equals(option)) {
String keyWordsParam = getKeyWordsParam(byId, OptionType.UNBIND.getValue(), keyWords);
log.info("解绑关键词通知采集{}",keyWordsParam);
String post = caiJiCenterHttpService.keyWordsbindUrl(keyWordsParam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
if (ObjectUtil.isEmpty(code) || code != 200) {
log.error("解绑关键词通知采集失败{}",post);
throw new RuntimeException("解绑关键词通知采集失败");
}
}else {
String keyWordsParam = getKeyWordsParam(byId, OptionType.BIND.getValue(), keyWords);
log.info("绑定关键词通知采集{}",keyWordsParam);
String post = caiJiCenterHttpService.keyWordsbindUrl(keyWordsParam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
if (ObjectUtil.isEmpty(code) || code != 200) {
log.error("绑定关键词通知采集失败{}",post);
throw new RuntimeException("绑定关键词通知采集失败");
}
}
}
public void bindKeyWordsSend(String subjectId) {
try {
remoteModelService.delSubjectCache(subjectId);
......@@ -486,12 +310,8 @@ public class ConfigurationMessageService {
if (StrUtil.isBlank(subjectId)) {
return new ArrayList<>();
}
List<String> bindIds = getBindIds(subjectId);
List<String> excludeIds = getExcludeIds(subjectId);
if (CollectionUtil.isNotEmpty(excludeIds)) {
bindIds.removeAll(excludeIds);
}
return bindIds.stream().distinct().collect(Collectors.toList());
return getBindIds(subjectId);
}
......@@ -553,58 +373,7 @@ public class ConfigurationMessageService {
}
private List<String> getBindIds(String subjectId) {
//查询绑定的信息源id
List<String> excludeIds = new ArrayList<>();
List<SubjectInfoSourceMap> excludeInfoSource = iSubjectInfoSourceMapService.list(Wrappers.<SubjectInfoSourceMap>lambdaQuery()
.select(SubjectInfoSourceMap::getSourceId)
.eq(SubjectInfoSourceMap::getSubjectId, subjectId)
.eq(SubjectInfoSourceMap::getType, BindTypeEnum.INFO_SOURCE.getvalue())
);
if (excludeInfoSource != null && excludeInfoSource.size() > 0) {
excludeIds.addAll(excludeInfoSource.stream().map(SubjectInfoSourceMap::getSourceId).collect(Collectors.toList()));
}
//查询绑定的标签信息源id
List<SubjectInfoSourceMap> excludeInfoSourceLabel = iSubjectInfoSourceMapService.list(Wrappers.<SubjectInfoSourceMap>lambdaQuery()
.select(SubjectInfoSourceMap::getSourceId,SubjectInfoSourceMap::getSourceItemId)
.eq(SubjectInfoSourceMap::getSubjectId, subjectId)
.in(SubjectInfoSourceMap::getType, Arrays.asList(BindTypeEnum.INFO_SOURCE_LABEL.getvalue(),BindTypeEnum.DIRECTIONA_INFO_SOURCE_LABEL.getvalue()))
);
Set<String> labelCode = new HashSet<>();
Set<String> labelItemCode = new HashSet<>();
if (excludeInfoSourceLabel!= null && excludeInfoSourceLabel.size() > 0) {
excludeInfoSourceLabel.forEach(e -> {
labelCode.add(e.getSourceId());
labelItemCode.add(e.getSourceItemId());
});
List<ClbLabelInfoSourceMap> list = clbLabelInfoSourceMapService.list(Wrappers.<ClbLabelInfoSourceMap>lambdaQuery()
.in(ClbLabelInfoSourceMap::getLabelCode,labelCode)
.in(ClbLabelInfoSourceMap::getLabelItemCode,labelItemCode)
);
if (CollectionUtil.isNotEmpty(list)){
List<String> infoSourceCodes = list.stream().map(ClbLabelInfoSourceMap::getEntityCode).distinct().collect(Collectors.toList());
List<InfoSource> list1 = iInfoSourceService.list(Wrappers.<InfoSource>lambdaQuery().select(InfoSource::getId).in(InfoSource::getId, infoSourceCodes));
if (CollectionUtil.isNotEmpty(list1)){
List<String> collect = list1.stream().map(InfoSource::getId).collect(Collectors.toList());
excludeIds.addAll(collect);
}
}
}
//查询绑定的的信息源组下的所有信息源id
List<SubjectInfoSourceMap> excludeInfoSourceGroup = iSubjectInfoSourceMapService.list(Wrappers.<SubjectInfoSourceMap>lambdaQuery()
.select(SubjectInfoSourceMap::getSourceId)
.eq(SubjectInfoSourceMap::getSubjectId, subjectId)
.in(SubjectInfoSourceMap::getType, Arrays.asList(BindTypeEnum.INFO_SOURCE_GROUP.getvalue(),BindTypeEnum.DIRECTIONA_INFO_SOURCE_GROUP.getvalue()))
);
if (excludeInfoSourceGroup!= null && excludeInfoSourceGroup.size() > 0) {
List<String> groupIds = excludeInfoSourceGroup.stream().map(SubjectInfoSourceMap::getSourceId).collect(Collectors.toList());
List<String> groupInfoSourceIds = infoSourceService.listByGroupIds(groupIds);
excludeIds.addAll(groupInfoSourceIds);
}
return excludeIds;
return subjectAdditionMapper.getSubjectBindInfoSourceIds(subjectId);
}
......
......@@ -167,7 +167,7 @@ public class InfoSourceMainServiceImpl extends ServiceImpl<InfoSourceMainMapper,
return jsonObject;
}
private List<SysDictItem> getDictList(String dictCode){
Object dictList = remoteSystemService.getDictList(dictCode);
String dictList = remoteSystemService.getDictList(dictCode);
return JSONUtil.toList(JSONUtil.parseArray(dictList), SysDictItem.class);
}
}
......@@ -1021,6 +1021,18 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
unBindLabels(subjectPage);
}
//解绑信息源组
if (StrUtil.equals(subjectPage.getSourceType(),"4")) {
unBindInfoSourceMainGroup(subjectPage);
}
//解绑信息源
if (StrUtil.equals(subjectPage.getSourceType(),"5")) {
unBindInfoSourceMain(subjectPage);
}
//解绑标签
if (StrUtil.equals(subjectPage.getSourceType(),"6")) {
unBindLabelsMain(subjectPage);
}
configurationMessageService.bindInfoSourceSend(subjectPage.getId());
}
......@@ -1091,6 +1103,27 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
}
}
private void unBindInfoSourceMainGroup(SubjectPage subjectPage) {
String sourceBindType = subjectPage.getSourceBindType();
List<String> idList = subjectPage.getBindIds();
if (CollectionUtil.isEmpty(idList)) {
return;
}
if (StrUtil.equals(sourceBindType, "1")) {
//解绑通用信息源组
unbindInfoSource(subjectPage, idList, BindTypeEnum.INFO_MAIN_SOURCE_GROUP.getvalue());
}
if (StrUtil.equals(sourceBindType, "2")) {
//解绑定向信息源组
unbindInfoSource(subjectPage, idList, BindTypeEnum.DIRECTIONA_MAIN_INFO_SOURCE_GROUP.getvalue());
}
if (StrUtil.equals(sourceBindType, "3")) {
//解绑屏蔽信息源组
unbindInfoSource(subjectPage, idList, BindTypeEnum.EXCLUDE_MAIN_INFO_SOURCE_GROUP.getvalue());
}
}
private void unBindLabels(SubjectPage subjectPage) {
String sourceBindType = subjectPage.getSourceBindType();
......@@ -1111,6 +1144,25 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
unBindLabel(subjectPage, BindTypeEnum.EXCLUDE_INFO_SOURCE_LABEL.getvalue());
}
}
private void unBindLabelsMain(SubjectPage subjectPage) {
String sourceBindType = subjectPage.getSourceBindType();
List<BindLabelVo> bindLabels = subjectPage.getBindLabels();
if (CollectionUtil.isEmpty(bindLabels)) {
return;
}
if (StrUtil.equals(sourceBindType, "1")) {
//解绑通用标签
unBindLabel(subjectPage, BindTypeEnum.INFO_SOURCE_MAIN_LABEL.getvalue());
}
if (StrUtil.equals(sourceBindType, "2")) {
//解绑定向标签
unBindLabel(subjectPage, BindTypeEnum.DIRECTIONA_INFO_MAIN_SOURCE_LABEL.getvalue());
}
if (StrUtil.equals(sourceBindType, "3")) {
//解绑屏蔽标签
unBindLabel(subjectPage, BindTypeEnum.EXCLUDE_INFO_MAIN_SOURCE_LABEL.getvalue());
}
}
private void unBindLabel(SubjectPage subjectPage, Integer type) {
List<BindLabelVo> bindLabels = subjectPage.getBindLabels();
......@@ -1151,6 +1203,25 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
unbindInfoSource(subjectPage, idList, BindTypeEnum.EXCLUDE_INFO_SOURCE.getvalue());
}
}
private void unBindInfoSourceMain(SubjectPage subjectPage) {
String sourceBindType = subjectPage.getSourceBindType();
List<String> idList = subjectPage.getBindIds();
if (CollectionUtil.isEmpty(idList)) {
return;
}
if (StrUtil.equals(sourceBindType, "1")) {
//解绑通用信息源
unbindInfoSource(subjectPage, idList, BindTypeEnum.INFO_MAIN_SOURCE.getvalue());
}
if (StrUtil.equals(sourceBindType, "2")) {
//解绑定向信息源
unbindInfoSource(subjectPage, idList, BindTypeEnum.DIRECTIONA_MAIN_INFO_SOURCE.getvalue());
}
if (StrUtil.equals(sourceBindType, "3")) {
//解绑屏蔽信息源
unbindInfoSource(subjectPage, idList, BindTypeEnum.EXCLUDE_MAIN_INFO_SOURCE.getvalue());
}
}
private void unbindInfoSource(SubjectPage subjectPage, List<String> idList, Integer bindType) {
iSubjectInfoSourceMapService.deleteInfoSourceIds(subjectPage.getId(), idList, bindType);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论