提交 1ec473d0 作者: 925993793@qq.com

【自定义专题】增加信息源标签(地域)逻辑

上级 cd73ee57
package com.zzsn.event.controller; package com.zzsn.event.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
...@@ -12,6 +16,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; ...@@ -12,6 +16,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.obs.services.model.PutObjectResult; import com.obs.services.model.PutObjectResult;
import com.zzsn.event.constant.Result; import com.zzsn.event.constant.Result;
import com.zzsn.event.constant.TreeNodeInfo;
import com.zzsn.event.entity.*; import com.zzsn.event.entity.*;
import com.zzsn.event.es.EsService; import com.zzsn.event.es.EsService;
import com.zzsn.event.feign.api.RemoteModelService; import com.zzsn.event.feign.api.RemoteModelService;
...@@ -134,6 +139,9 @@ public class SubjectManageController { ...@@ -134,6 +139,9 @@ public class SubjectManageController {
@Value("${caiji.projectName:克虏宝测试}") @Value("${caiji.projectName:克虏宝测试}")
private String projectName; private String projectName;
@Value("${infoSource.commonLabel:}")
private String commonSourceLabels;
/** /**
* 专题列表-资讯转换时使用 * 专题列表-资讯转换时使用
* *
...@@ -892,8 +900,9 @@ public class SubjectManageController { ...@@ -892,8 +900,9 @@ public class SubjectManageController {
*/ */
@GetMapping("/subjectBindMainLabelList") @GetMapping("/subjectBindMainLabelList")
public Result<?> subjectBindMainLabelList(@RequestParam String subjectId) { public Result<?> subjectBindMainLabelList(@RequestParam String subjectId) {
// List<InfoSourceLabelVO> bindList = clbLabelService.subjectBindMainLabelList(subjectId); //List<InfoSourceLabelVO> bindList = clbLabelService.subjectBindMainLabelList(subjectId);
List<String> bindList = clbLabelService.subjectBindMainLabelList(subjectId); //List<String> bindList = clbLabelService.subjectBindMainLabelList(subjectId);
List<LabelDictItemVO> bindList = clbLabelService.subjectBindMainLabels(subjectId);
return Result.OK(bindList); return Result.OK(bindList);
} }
...@@ -971,15 +980,121 @@ public class SubjectManageController { ...@@ -971,15 +980,121 @@ public class SubjectManageController {
return Result.OK(); return Result.OK();
} }
/**
* 信息源标签列表(通用信息源)
*
* @author lkg
* @date 2025/9/2
*/
@GetMapping("/commonInfoSourceLabelList")
public Result<?> getCommonInfoSourceLabelList(){
List<String> labelIdList = Arrays.asList(commonSourceLabels.split(","));
List<ClbLabel> clbLabels = clbLabelService.listByIds(labelIdList);
sortByAnotherList(clbLabels, labelIdList);
Map<String, String> relationMap = clbLabels.stream().collect(Collectors.toMap(ClbLabel::getDictCode, ClbLabel::getId));
List<String> dictCodeList = clbLabels.stream().map(ClbLabel::getDictCode).collect(Collectors.toList());
List<SysDictItem> dictItems = sysDictItemService.listByDictCodes(dictCodeList);
//构造树型结构
List<TreeNode<String>> nodeList = new ArrayList<>();
for (SysDictItem dictItem : dictItems) {
TreeNode<String> treeNode = new TreeNode<>();
//对象转map
Map<String, Object> extra = BeanUtil.beanToMap(dictItem,false,true);
treeNode.setExtra(extra);
treeNode.setId(dictItem.getId());
treeNode.setName(dictItem.getItemText());
if (dictItem.getPid().equals(TreeNodeInfo.ROOT_PID_VALUE)) {
treeNode.setParentId(relationMap.get(dictItem.getDictCode()));
} else {
treeNode.setParentId(dictItem.getPid());
}
nodeList.add(treeNode);
}
//信息源标签 作为父级
clbLabels.forEach(e -> {
TreeNode<String> treeNode = new TreeNode<>();
//对象转map
Map<String, Object> extra = BeanUtil.beanToMap(e,false,true);
treeNode.setExtra(extra);
treeNode.setId(e.getId());
treeNode.setName(e.getLabelName());
treeNode.setParentId("0");
nodeList.add(treeNode);
});
List<Tree<String>> treeList = TreeUtil.build(nodeList, TreeNodeInfo.ROOT_PID_VALUE);
return Result.OK(treeList);
}
//目标集合按照另一个集合的顺序排序
private void sortByAnotherList(List<ClbLabel> list, List<String> anotherList) {
list.sort((o1, o2) -> {
int index1 = anotherList.indexOf(o1.getId());
int index2 = anotherList.indexOf(o2.getId());
if (index1 != -1) {
index1 = list.size() - index1;
}
if (index2 != -1) {
index2 = list.size() - index2;
}
return index2 - index1;
});
}
/** /**
* 绑定信息源标签数据 * 绑定信息源标签数据
* *
* @param infoSourceMainLabelVO 参数 * @param params 参数[subjectId,infoSourceMainLabel]
* @author lkg * @author lkg
* @date 2025/1/3 * @date 2025/1/3
*/ */
@PostMapping("/bindInfoSourceMainLabel") @PostMapping("/bindInfoSourceMainLabel")
public Result<?> bindInfoSourceMainLabel(@RequestBody InfoSourceMainLabelVO infoSourceMainLabelVO) { public Result<?> bindInfoSourceMainLabel(@RequestBody Map<String,Object> params) {
Object subjectId = params.get("subjectId");
if (ObjectUtil.isEmpty(subjectId)) {
return Result.FAIL("专题id不能为空");
}
Object infoSourceMainLabel = params.get("infoSourceMainLabel");
if (ObjectUtil.isEmpty(infoSourceMainLabel)) {
return Result.FAIL("信息源标签不能为空");
}
//支持全部删除
//不管有没有传值,先删后增
LambdaQueryWrapper<SubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SubjectInfoSourceMap::getSubjectId, subjectId).eq(SubjectInfoSourceMap::getType, 312);
int count = subjectInfoSourceMapService.count(queryWrapper);
if (count > 0) {
subjectInfoSourceMapService.remove(queryWrapper);
}
List<SubjectInfoSourceMap> dataList = new ArrayList<>();
List<InfoSourceMainLabelVO> infoSourceMainLabelList = JSON.parseArray(JSON.toJSONString(infoSourceMainLabel), InfoSourceMainLabelVO.class);
for (InfoSourceMainLabelVO infoSourceMainLabelVO : infoSourceMainLabelList) {
List<String> labelList = infoSourceMainLabelVO.getInfoSourceLabelItemList();
String labelCode = infoSourceMainLabelVO.getLabelCode();
for (String labelItemCode : labelList) {
SubjectInfoSourceMap subjectInfoSourceMap = new SubjectInfoSourceMap();
subjectInfoSourceMap.setSubjectId(subjectId.toString());
subjectInfoSourceMap.setSourceId(labelCode);
subjectInfoSourceMap.setSourceItemId(labelItemCode);
subjectInfoSourceMap.setType(312);
UserVo currentUser = UserUtil.getLoginUser();
subjectInfoSourceMap.setCreateBy(currentUser.getUsername());
subjectInfoSourceMap.setCreateTime(new Date());
dataList.add(subjectInfoSourceMap);
}
}
if (CollectionUtils.isNotEmpty(dataList)) {
subjectInfoSourceMapService.saveBatch(dataList);
}
//同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectId.toString());
return Result.OK();
}
public Result<?> bindInfoSourceMainLabel_old(@RequestBody InfoSourceMainLabelVO infoSourceMainLabelVO) {
String subjectId = infoSourceMainLabelVO.getSubjectId(); String subjectId = infoSourceMainLabelVO.getSubjectId();
if (StringUtils.isEmpty(subjectId)) { if (StringUtils.isEmpty(subjectId)) {
......
...@@ -2570,9 +2570,14 @@ public class EsService { ...@@ -2570,9 +2570,14 @@ public class EsService {
//信息源标签 //信息源标签
List<Label> labelList = searchCondition.getLabelList(); List<Label> labelList = searchCondition.getLabelList();
if (CollectionUtils.isNotEmpty(labelList)) { if (CollectionUtils.isNotEmpty(labelList)) {
List<String> collect = labelList.stream().map(label -> label.getLabelMark() + "-" + label.getRelationId()).collect(Collectors.toList()); //同类标签之间 或 的关系;不同类标签之间 与 的关系
TermsQueryBuilder relationIdQuery = QueryBuilders.termsQuery("labels.relationId", collect); Map<String, List<Label>> labelMap = labelList.stream().collect(Collectors.groupingBy(Label::getLabelMark));
boolQuery.must(QueryBuilders.nestedQuery("labels", relationIdQuery, ScoreMode.None)); for (Map.Entry<String, List<Label>> entry : labelMap.entrySet()) {
List<Label> value = entry.getValue();
List<String> collect = value.stream().map(label -> label.getLabelMark() + "-" + label.getRelationId()).collect(Collectors.toList());
TermsQueryBuilder relationIdQuery = QueryBuilders.termsQuery("labels.relationId", collect);
boolQuery.must(QueryBuilders.nestedQuery("labels", relationIdQuery, ScoreMode.None));
}
} }
String sourceId = searchCondition.getSourceId(); String sourceId = searchCondition.getSourceId();
if (StringUtils.isNotBlank(sourceId)) { if (StringUtils.isNotBlank(sourceId)) {
......
...@@ -3,6 +3,7 @@ package com.zzsn.event.mapper; ...@@ -3,6 +3,7 @@ package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.ClbLabel; import com.zzsn.event.entity.ClbLabel;
import com.zzsn.event.vo.InfoSourceLabelVO; import com.zzsn.event.vo.InfoSourceLabelVO;
import com.zzsn.event.vo.LabelDictItemVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -38,4 +39,5 @@ public interface ClbLabelMapper extends BaseMapper<ClbLabel> { ...@@ -38,4 +39,5 @@ public interface ClbLabelMapper extends BaseMapper<ClbLabel> {
List<InfoSourceLabelVO> labelInfoByType(@Param("labelTypeId") String labelTypeId); List<InfoSourceLabelVO> labelInfoByType(@Param("labelTypeId") String labelTypeId);
List<String> subjectBindMainLabelList(@Param("subjectId") String subjectId); List<String> subjectBindMainLabelList(@Param("subjectId") String subjectId);
List<LabelDictItemVO> subjectBindMainLabels(@Param("subjectId") String subjectId);
} }
...@@ -20,6 +20,7 @@ import java.util.List; ...@@ -20,6 +20,7 @@ import java.util.List;
public interface SysDictItemMapper extends BaseMapper<SysDictItem> { public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
List<SysDictItem> listByDictCode(@Param("dictCode") String dictCode); List<SysDictItem> listByDictCode(@Param("dictCode") String dictCode);
List<SysDictItem> listByDictCodes(@Param("dictCodes") List<String> dictCodes);
SysDictItem dictItemInfoByName(@Param("dictCode") String dictCode,@Param("itemName") String itemName); SysDictItem dictItemInfoByName(@Param("dictCode") String dictCode,@Param("itemName") String itemName);
......
...@@ -30,5 +30,10 @@ ...@@ -30,5 +30,10 @@
from subject_info_source_map m from subject_info_source_map m
where m.subject_id = #{subjectId} and m.type = 312 where m.subject_id = #{subjectId} and m.type = 312
</select> </select>
<select id="subjectBindMainLabels" resultType="com.zzsn.event.vo.LabelDictItemVO">
select m.source_id as label_code,label.label_name, m.source_item_id as label_item_code
from subject_info_source_map m inner join clb_label label on m.source_id = label.label_code
where m.subject_id = #{subjectId} and m.type = 312
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -6,6 +6,16 @@ ...@@ -6,6 +6,16 @@
select * from sys_dict_item item inner join sys_dict dict on item.dict_id = dict.id select * from sys_dict_item item inner join sys_dict dict on item.dict_id = dict.id
where dict.dict_code = #{dictCode} and item.status = 1 where dict.dict_code = #{dictCode} and item.status = 1
</select> </select>
<select id="listByDictCodes" resultType="com.zzsn.event.entity.SysDictItem">
select item.*,dict.dict_code from sys_dict_item item inner join sys_dict dict on item.dict_id = dict.id
where item.status = 1
<if test="dictCodes != null and dictCodes.size() > 0">
and dict.dict_code in
<foreach collection="dictCodes" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<select id="dictItemInfoByName" resultType="com.zzsn.event.entity.SysDictItem"> <select id="dictItemInfoByName" resultType="com.zzsn.event.entity.SysDictItem">
select * from sys_dict_item item inner join sys_dict dict on item.dict_id = dict.id select * from sys_dict_item item inner join sys_dict dict on item.dict_id = dict.id
where dict.dict_code = #{dictCode} and item.item_text = #{itemName} where dict.dict_code = #{dictCode} and item.item_text = #{itemName}
......
...@@ -3,6 +3,7 @@ package com.zzsn.event.service; ...@@ -3,6 +3,7 @@ package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.ClbLabel; import com.zzsn.event.entity.ClbLabel;
import com.zzsn.event.vo.InfoSourceLabelVO; import com.zzsn.event.vo.InfoSourceLabelVO;
import com.zzsn.event.vo.LabelDictItemVO;
import java.util.List; import java.util.List;
...@@ -35,4 +36,5 @@ public interface ClbLabelService extends IService<ClbLabel> { ...@@ -35,4 +36,5 @@ public interface ClbLabelService extends IService<ClbLabel> {
List<InfoSourceLabelVO> labelInfoByType(String labelTypeId); List<InfoSourceLabelVO> labelInfoByType(String labelTypeId);
List<String> subjectBindMainLabelList(String subjectId); List<String> subjectBindMainLabelList(String subjectId);
List<LabelDictItemVO> subjectBindMainLabels(String subjectId);
} }
...@@ -19,6 +19,8 @@ public interface SysDictItemService extends IService<SysDictItem> { ...@@ -19,6 +19,8 @@ public interface SysDictItemService extends IService<SysDictItem> {
List<SysDictItem> listByDictCode(String dictCode); List<SysDictItem> listByDictCode(String dictCode);
List<SysDictItem> listByDictCodes(List<String> dictCodes);
SysDictItem dictItemInfoByName(String dictCode, String itemName); SysDictItem dictItemInfoByName(String dictCode, String itemName);
/** /**
......
...@@ -6,6 +6,7 @@ import com.zzsn.event.entity.ClbLabel; ...@@ -6,6 +6,7 @@ import com.zzsn.event.entity.ClbLabel;
import com.zzsn.event.mapper.ClbLabelMapper; import com.zzsn.event.mapper.ClbLabelMapper;
import com.zzsn.event.service.ClbLabelService; import com.zzsn.event.service.ClbLabelService;
import com.zzsn.event.vo.InfoSourceLabelVO; import com.zzsn.event.vo.InfoSourceLabelVO;
import com.zzsn.event.vo.LabelDictItemVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -35,4 +36,9 @@ public class ClbLabelServiceImpl extends ServiceImpl<ClbLabelMapper, ClbLabel> i ...@@ -35,4 +36,9 @@ public class ClbLabelServiceImpl extends ServiceImpl<ClbLabelMapper, ClbLabel> i
public List<String> subjectBindMainLabelList(String subjectId) { public List<String> subjectBindMainLabelList(String subjectId) {
return baseMapper.subjectBindMainLabelList(subjectId); return baseMapper.subjectBindMainLabelList(subjectId);
} }
@Override
public List<LabelDictItemVO> subjectBindMainLabels(String subjectId) {
return baseMapper.subjectBindMainLabels(subjectId);
}
} }
...@@ -232,8 +232,10 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -232,8 +232,10 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
@Override @Override
public Boolean configVerification(SubjectParamsCheckVO subjectParamsCheckVO) { public Boolean configVerification(SubjectParamsCheckVO subjectParamsCheckVO) {
//新
SubjectSimpleVO subjectSimpleVO = subjectParamsCheckVO.getSubjectSimpleVO(); SubjectSimpleVO subjectSimpleVO = subjectParamsCheckVO.getSubjectSimpleVO();
String subjectId = subjectSimpleVO.getId(); String subjectId = subjectSimpleVO.getId();
//旧
SubjectDetailVO subjectDetailVO = queryInfo(subjectId); SubjectDetailVO subjectDetailVO = queryInfo(subjectId);
Date firstOpenTime = subjectDetailVO.getFirstOpenTime(); Date firstOpenTime = subjectDetailVO.getFirstOpenTime();
//未启用过的可以直接修改,校验通过 //未启用过的可以直接修改,校验通过
......
...@@ -33,6 +33,10 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi ...@@ -33,6 +33,10 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
public List<SysDictItem> listByDictCode(String dictCode) { public List<SysDictItem> listByDictCode(String dictCode) {
return this.baseMapper.listByDictCode(dictCode); return this.baseMapper.listByDictCode(dictCode);
} }
@Override
public List<SysDictItem> listByDictCodes(List<String> dictCodes) {
return this.baseMapper.listByDictCodes(dictCodes);
}
@Override @Override
public SysDictItem dictItemInfoByName(String dictCode, String itemName) { public SysDictItem dictItemInfoByName(String dictCode, String itemName) {
......
package com.zzsn.event.vo;
import lombok.Data;
/**
* 标签-字典
*
* @author lkg
* @date 2025/9/3
*/
@Data
public class LabelDictItemVO {
/**标签编码*/
private String labelCode;
/**标签名称*/
private String labelName;
/**标签应用数据字典对应的字典值(itemValue)*/
private String labelItemCode;
}
...@@ -180,6 +180,7 @@ infoSource: ...@@ -180,6 +180,7 @@ infoSource:
waitInfoRemove: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/waitInfoRemove waitInfoRemove: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/waitInfoRemove
columnListByWait: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnListByWait columnListByWait: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnListByWait
columnDetail: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnDetail columnDetail: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnDetail
commonLabel: 1935224186961723394,1935224004379475969
ai-article: ai-article:
thematicColumnConfig-url: http://1.95.77.159:10089/reportManage/thematicInformationColumn/column/getThematicColumnConfig thematicColumnConfig-url: http://1.95.77.159:10089/reportManage/thematicInformationColumn/column/getThematicColumnConfig
caiji: caiji:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论