提交 fb64d8ca 作者: 925993793@qq.com

1.报告数据接口;2.增加组合标签的查询条件逻辑

上级 31fb8907
...@@ -14,12 +14,17 @@ import com.zzsn.event.service.*; ...@@ -14,12 +14,17 @@ import com.zzsn.event.service.*;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 专题/事件关系绑定 * 专题/事件关系绑定
...@@ -49,6 +54,8 @@ public class RelationBindController { ...@@ -49,6 +54,8 @@ public class RelationBindController {
private SubjectService subjectService; private SubjectService subjectService;
@Autowired @Autowired
private SubjectDictMapService subjectDictMapService; private SubjectDictMapService subjectDictMapService;
@Autowired
private SysDictItemService dictItemService;
/** /**
* 项目列表 * 项目列表
...@@ -295,4 +302,33 @@ public class RelationBindController { ...@@ -295,4 +302,33 @@ public class RelationBindController {
List<DictVO> boundList = subjectDictMapService.boundList(subjectId); List<DictVO> boundList = subjectDictMapService.boundList(subjectId);
return Result.OK(boundList); return Result.OK(boundList);
} }
/**
* 专题已经绑定的标签(包含标签值)-树型结构----创建专题报告任务时使用
*
* @param subjectId 专题id
* @author lkg
* @date 2025/3/28
*/
@GetMapping("/boundLabelTreeList")
public Result<?> boundLabelTreeList(@RequestParam String subjectId){
List<DictTreeVO> list = new ArrayList<>();
List<DictVO> boundList = subjectDictMapService.boundList(subjectId);
boundList.forEach(dictVO -> {
DictTreeVO dictTreeVO = new DictTreeVO();
BeanUtils.copyProperties(dictVO, dictTreeVO);
dictTreeVO.setYnItem(false);
list.add(dictTreeVO);
});
List<String> dictIds = boundList.stream().map(DictVO::getId).collect(Collectors.toList());
List<DictTreeVO> itemTreeList = dictItemService.dictItemTreeList(dictIds);
Map<String, List<DictTreeVO>> dictMap = itemTreeList.stream().collect(Collectors.groupingBy(DictTreeVO::getDictId));
for (DictTreeVO dictTreeVO : list) {
if (dictMap.containsKey(dictTreeVO.getId())) {
List<DictTreeVO> dictTreeVOS = dictMap.get(dictTreeVO.getId());
dictTreeVO.setChildren(dictTreeVOS);
}
}
return Result.OK(list);
}
} }
package com.zzsn.event.controller.reportData;
import java.lang.annotation.*;
/**
* 字段描述注解
*
* @author lkg
* @date 2025/4/9
*/
@Documented
@Target(ElementType.FIELD) //说明该注解只能放在字段上面
@Retention(RetentionPolicy.RUNTIME)
public @interface FieldDescription {
/**
* 字段描述
*/
String value() default "";
/**
* 是否有效
*/
boolean valid() default true;
}
package com.zzsn.event.controller.reportData;
import lombok.Data;
/**
* 报告资讯返回对象
*
* @author lkg
* @date 2025/4/9
*/
@Data
public class ReportDataVO {
//信息id
private String id;
//标题
private String title;
//摘要
private String summary;
//正文
private String content;
//带标签正文
private String contentWithTag;
//语言
private String lang;
//来源(信息来源)
private String origin;
//发布时间
private String publishDate;
//发布地址
private String sourceAddress;
//得分
private Double score;
//专题库类型(0: 其它 1:政策;2:领导讲话;3:专家观点;4:企业案例)
private Integer classificationType;
//删除标记(1:删除;0:保留)
private Integer deleteFlag;
//专题id
private String subjectId;
//专题名称
private String subjectName;
//审核操作(0:未审核 1:审核通过 2:审核未通过 3:暂定 默认值为0)
private Integer checkStatus;
/**原创性*/
private String originality;
//入库时间
private String createDate;
}
package com.zzsn.event.controller.reportData;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zzsn.event.vo.es.Label;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
@Data
public class SearchCondition {
//专题id
@FieldDescription(value = "专题id")
private String subjectId;
//搜索范围(all、title、content、origin)
@FieldDescription(value = "搜索范围")
private String searchScope;
//搜索词
@FieldDescription(value = "搜索词")
private String searchWord;
//开始时间
@FieldDescription(value = "开始时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
//结束时间
@FieldDescription(value = "结束时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
//专题库类型(对应字典编码为【Thematic_Library】的数据字典值)
@FieldDescription(value = "专题库类型")
private List<Integer> classificationType;
/**原创性(0-非原创;1-原创;2-疑似)*/
@FieldDescription(value = "原创性")
private String originality;
//审核操作(0:未审核 1:审核通过 2:审核未通过 3:暂定 默认值为0)
@FieldDescription(value = "审核状态")
private Integer checkStatus;
//删除标记(1:删除;0:未删除)
@FieldDescription(value = "删除标记")
private Integer deleteFlag = 0;
//爬虫类型
@FieldDescription(value = "爬虫类型")
private String crawler;
/**----企业类标签筛选----**/
//企业类标签id集合
@FieldDescription(value = "企业类标签id集合")
private List<String> enterpriseLabelTypeIds;
//企业信用代码集合
@FieldDescription(value = "企业信用代码集合")
private List<String> socialCreditCodeList;
/**----企业类标签id集合----**/
//专题关联标签值id集合
@FieldDescription(value = "专题关联标签值id集合")
private List<String> labelIds;
//正负面标签
@FieldDescription(value = "正负面标签")
private String tendencyLabelId;
//地域标签id集合
@FieldDescription(value = "地域标签id集合")
private List<String> areaLabelIds;
//专题关联信息源标签集合
@FieldDescription(value = "专题关联信息源标签集合",valid = false)
private List<Label> infoSourceLabelList;
//是否免审核(1-是;0-否)
@FieldDescription(value = "免审核状态")
private Integer isFreeCheck;
//得分范围-研究中心
//最小得分
@FieldDescription(value = "最小得分")
private Integer minScore;
//最大得分
@FieldDescription(value = "最大得分")
private Integer maxScore;
//es查询字段数组
@FieldDescription(value = "查询字段数组")
private String[] fetchFields;
//排除字段数组
@FieldDescription(value = "排除字段数组")
private String[] excludeFields = new String[]{"content", "contentWithTag"};
//排序参数
//排序字段
@FieldDescription(value = "排序字段")
private String column = "publishDate";
//排序方式 asc/desc
@FieldDescription(value = "排序方式")
private String order = "desc";
//置顶排序是否起效(1-是;0-否)
@FieldDescription(value = "置顶排序是否起效")
private Integer topSortValid = 0;
//分页参数
//当前页
@FieldDescription(value = "当前页")
private Integer pageNo = 1;
//每页返回条数
@FieldDescription(value = "每页返回条数")
private Integer pageSize = 10;
}
...@@ -2121,6 +2121,18 @@ public class EsService { ...@@ -2121,6 +2121,18 @@ public class EsService {
if (StringUtils.isNotBlank(crawler)) { if (StringUtils.isNotBlank(crawler)) {
boolQuery.must(QueryBuilders.termQuery("source.keyword", crawler)); boolQuery.must(QueryBuilders.termQuery("source.keyword", crawler));
} }
//组合标签查询(不同类标签之间是与的关系,同一类标签之间是或的关系),示例: "a1,a2;c1,c2;e1,e2"
String composeSearchLabelIds = searchCondition.getComposeSearchLabelIds();
if (StringUtils.isNotEmpty(composeSearchLabelIds)) {
//分号隔开的标签查询用且的关系
String[] split = composeSearchLabelIds.split(";");
for (String items : split) {
List<String> ids = Arrays.asList(items.split(","));
NestedQueryBuilder nestedQueryBuilder = QueryBuilders
.nestedQuery("labels", QueryBuilders.termsQuery("labels.relationId",ids), ScoreMode.None);
boolQuery.must(nestedQueryBuilder);
}
}
//关联标签id集合 //关联标签id集合
List<String> labelIds = searchCondition.getLabelIds(); List<String> labelIds = searchCondition.getLabelIds();
if (CollectionUtils.isNotEmpty(labelIds)) { if (CollectionUtils.isNotEmpty(labelIds)) {
......
...@@ -2,6 +2,7 @@ package com.zzsn.event.mapper; ...@@ -2,6 +2,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.SysDictItem; import com.zzsn.event.entity.SysDictItem;
import com.zzsn.event.vo.DictTreeVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -21,4 +22,14 @@ public interface SysDictItemMapper extends BaseMapper<SysDictItem> { ...@@ -21,4 +22,14 @@ public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
List<SysDictItem> listByDictCode(@Param("dictCode") String dictCode); List<SysDictItem> listByDictCode(@Param("dictCode") String dictCode);
SysDictItem dictItemInfoByName(@Param("dictCode") String dictCode,@Param("itemName") String itemName); SysDictItem dictItemInfoByName(@Param("dictCode") String dictCode,@Param("itemName") String itemName);
/**
* 获取字典值信息
*
* @param dictIds 字典id集合
* @return
* @author lkg
* @date 2024/12/30
*/
List<DictTreeVO> dictItemList(List<String> dictIds);
} }
...@@ -57,4 +57,5 @@ ...@@ -57,4 +57,5 @@
#{id} #{id}
</foreach> </foreach>
</select> </select>
</mapper> </mapper>
...@@ -10,4 +10,15 @@ ...@@ -10,4 +10,15 @@
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}
</select> </select>
</mapper>
\ No newline at end of file <select id="dictItemList" resultType="com.zzsn.event.vo.DictTreeVO">
select item.id,item.item_text as name,item.pid,dict.id as dictId from sys_dict_item item inner join sys_dict dict on item.dict_id = dict.id
where item.status = 1
<if test="dictIds != null and dictIds.size() > 0">
and dict.id in
<foreach collection="dictIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>
...@@ -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.SysDictItem; import com.zzsn.event.entity.SysDictItem;
import com.zzsn.event.vo.CountVO; import com.zzsn.event.vo.CountVO;
import com.zzsn.event.vo.DictTreeVO;
import java.util.List; import java.util.List;
...@@ -29,4 +30,14 @@ public interface SysDictItemService extends IService<SysDictItem> { ...@@ -29,4 +30,14 @@ public interface SysDictItemService extends IService<SysDictItem> {
* @date 2024/12/30 * @date 2024/12/30
*/ */
void changeKey(List<CountVO> dataList, List<SysDictItem> dictItemList); void changeKey(List<CountVO> dataList, List<SysDictItem> dictItemList);
/**
* 获取字典值信息-树型结构
*
* @param dictIds 字典id集合
* @return
* @author lkg
* @date 2024/12/30
*/
List<DictTreeVO> dictItemTreeList(List<String> dictIds);
} }
...@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.SysDictItem; import com.zzsn.event.entity.SysDictItem;
import com.zzsn.event.mapper.SysDictItemMapper; import com.zzsn.event.mapper.SysDictItemMapper;
import com.zzsn.event.service.SysDictItemService; import com.zzsn.event.service.SysDictItemService;
import com.zzsn.event.util.tree.TreeUtil;
import com.zzsn.event.vo.CountVO; import com.zzsn.event.vo.CountVO;
import com.zzsn.event.vo.DictTreeVO;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -66,4 +68,12 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi ...@@ -66,4 +68,12 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
} }
} }
} }
@Override
public List<DictTreeVO> dictItemTreeList(List<String> dictIds) {
List<DictTreeVO> itemList = baseMapper.dictItemList(dictIds);
List<DictTreeVO> tree = TreeUtil.tree(itemList, "0");
tree.forEach(e -> e.setPid(e.getDictId()));
return tree;
}
} }
package com.zzsn.event.util;
import com.zzsn.event.controller.reportData.FieldDescription;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/**
* 实体字段工具类
*
* @author lkg
* @date 2025/4/9
*/
public class FieldUtil {
public static List<Map<String, Object>> fieldDetails(Class<?> clazz) {
List<Map<String, Object>> list = new ArrayList<>();
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
Map<String, Object> fieldMap = new TreeMap<>();
FieldDescription fieldAnnotation = field.getAnnotation(FieldDescription.class);
if (fieldAnnotation != null && fieldAnnotation.valid()) {
fieldMap.put("fieldName", field.getName());
fieldMap.put("fieldType", field.getType().getSimpleName());
fieldMap.put("fieldDescription", fieldAnnotation.value());
if (List.class.isAssignableFrom(field.getType())) {
Class<?> elementType = getCollectionElementType(field.getGenericType());
if (elementType.isAssignableFrom(Integer.class)) {
fieldMap.put("fieldType", field.getType().getSimpleName() + "<Integer>");
} else if (elementType.isAssignableFrom(String.class )) {
fieldMap.put("fieldType", field.getType().getSimpleName() + "<String>");
} else {
List<Map<String, Object>> children = fieldDetails(elementType);
fieldMap.put("children", children);
}
}
list.add(fieldMap);
}
}
return list;
}
private static Class<?> getCollectionElementType(java.lang.reflect.Type collectionType) {
if (collectionType instanceof java.lang.reflect.ParameterizedType) {
java.lang.reflect.ParameterizedType aType = (java.lang.reflect.ParameterizedType) collectionType;
java.lang.reflect.Type[] fieldArgTypes = aType.getActualTypeArguments();
for (java.lang.reflect.Type fieldArgType : fieldArgTypes) {
return (Class<?>) fieldArgType; // 返回第一个元素的类型,通常集合只有一个泛型参数
}
}
return Object.class; // 如果没有找到泛型类型,返回Object类
}
}
package com.zzsn.event.vo;
import com.zzsn.event.util.tree.Node;
import lombok.Data;
/**
*
*
* @author lkg
* @date 2025/4/1
*/
@Data
public class DictTreeVO extends Node {
private Boolean ynItem = true;
private String dictId;
}
...@@ -69,6 +69,10 @@ public class InfoDataSearchCondition { ...@@ -69,6 +69,10 @@ public class InfoDataSearchCondition {
//爬虫类型 //爬虫类型
private String crawler; private String crawler;
//组合标签查询(不同类标签之间是与的关系,同一类标签之间是或的关系),示例: "a,b;c,d;e,f"
private String composeSearchLabelIds;
/**----企业类标签筛选----**/ /**----企业类标签筛选----**/
//企业类标签id集合 //企业类标签id集合
private List<String> enterpriseLabelTypeIds; private List<String> enterpriseLabelTypeIds;
......
package com.zzsn.event.vo.es; package com.zzsn.event.vo.es;
import com.zzsn.event.controller.reportData.FieldDescription;
import lombok.Data; import lombok.Data;
/** /**
...@@ -11,6 +12,7 @@ public class Label { ...@@ -11,6 +12,7 @@ public class Label {
private String hitRemarks; private String hitRemarks;
//标签标识 //标签标识
@FieldDescription(value = "标签标识")
private String labelMark; private String labelMark;
//标签备注 //标签备注
...@@ -20,9 +22,11 @@ public class Label { ...@@ -20,9 +22,11 @@ public class Label {
private String sourceId; private String sourceId;
//关联标签id //关联标签id
@FieldDescription(value = "标签id")
private String relationId; private String relationId;
//关联标签名称 //关联标签名称
@FieldDescription(value = "标签名称")
private String relationName; private String relationName;
//得分 //得分
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论