提交 9a26e983 作者: obcy

Merge remote-tracking branch 'origin/event_fusion' into event_fusion

package com.zzsn.event.controller;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.aspose.words.Document;
import com.aspose.words.SaveFormat;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
......@@ -14,6 +16,7 @@ import com.zzsn.event.service.*;
import com.zzsn.event.util.*;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.FileDataVO;
import com.zzsn.event.vo.InfoDataSearchCondition;
import com.zzsn.event.vo.LabelModelVo;
import com.zzsn.event.vo.es.AttachmentInfo;
......@@ -294,7 +297,7 @@ public class FileController {
*/
@GetMapping("/downloadResearchTemplate")
public void downloadResearchTemplate(HttpServletResponse response) {
String filePath = "subjectDataImport/上传Excel模板.xls";
String filePath = "subjectDataImport/上传Excel模板.xlsx";
commonService.downloadTemplate(response, filePath);
}
......@@ -321,20 +324,23 @@ public class FileController {
if ("xls".equals(fileSuffix) || "xlsx".equals(fileSuffix)) {
CompletableFuture.runAsync(() -> {
try {
byte[] fileData = multipartFile.getBytes();
//读取文件内容
List<List<String>> lists;
if ("xls".equals(fileSuffix)) {
lists = ExcelExportUtil.readExcelXls(new ByteArrayInputStream(fileData), true,1, 7);
} else {
lists = ExcelExportUtil.readExcelXlsx(new ByteArrayInputStream(fileData), true,1, 7);
}
informationService.importDataInfo(lists,subjectId);
ExcelReader reader = ExcelUtil.getReader(multipartFile.getInputStream());
Map<String, String> header = new HashMap<>();
header.put("标题", "title");
header.put("作者", "author");
header.put("来源", "origin");
header.put("资讯类型", "classificationType");
header.put("原文链接", "sourceAddress");
header.put("发布时间", "publishDate");
header.put("正文内容", "content");
reader.setHeaderAlias(header);
List<FileDataVO> informationList = reader.read(0, 1, FileDataVO.class);
informationService.importDataInfo(informationList,subjectId);
} catch (IOException e) {
e.printStackTrace();
}
});
return Result.OK("正在进行处理");
return Result.OK("数据正在处理,请稍后查看");
} else {
return Result.FAIL(500, "不支持的文件类型");
}
......
......@@ -12,9 +12,8 @@ import com.zzsn.event.entity.SubjectUserCondition;
import com.zzsn.event.enums.LabelTypeEnum;
import com.zzsn.event.es.EsService;
import com.zzsn.event.service.*;
import com.zzsn.event.util.HttpUtil;
import com.zzsn.event.util.PythonUtil;
import com.zzsn.event.util.user.AuthUtil;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
......@@ -24,11 +23,9 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
......@@ -56,6 +53,8 @@ public class InformationController {
@Autowired
private SysBaseLabelTypeService sysBaseLabelTypeService;
@Autowired
private SubjectDictMapService subjectDictMapService;
@Autowired
private PythonUtil pythonUtil;
......@@ -349,6 +348,20 @@ public class InformationController {
}
/**
* 编辑标签
*
* @param bindLabelFrom 参数
* @author lkg
* @date 2024/12/19
*/
@PostMapping(value = "/modifyLabel")
public Result<?> modifyLabel(@RequestBody DataBindLabelFrom bindLabelFrom) {
List<DictVO> nodes = subjectDictMapService.boundList(bindLabelFrom.getSubjectId());
informationService.modifyLabel(bindLabelFrom,nodes);
return Result.OK();
}
/**
* 批量删除-专题库(逻辑删除)
*
* @param map 删除参数
......
......@@ -47,6 +47,8 @@ public class RelationBindController {
private InfoSourceGroupService infoSourceGroupService;
@Autowired
private SubjectService subjectService;
@Autowired
private SubjectDictMapService subjectDictMapService;
/**
* 项目列表
......@@ -267,5 +269,30 @@ public class RelationBindController {
return Result.OK(bindKeyWordsList);
}
/**
* 专题绑定标签(用于人工打标)
*
* @param bindLabelParam 绑定参数
* @author lkg
* @date 2025/3/28
*/
@PostMapping("/bindLabels")
public Result<?> bindLabels(@RequestBody SubjectBindLabelParam bindLabelParam){
subjectDictMapService.modify(bindLabelParam);
return Result.OK();
}
/**
* 专题已经绑定的标签(用于人工打标)
*
* @param subjectId 专题id
* @author lkg
* @date 2025/3/28
*/
@GetMapping("/boundLabelList")
public Result<?> boundLabelList(@RequestParam String subjectId){
List<DictVO> boundList = subjectDictMapService.boundList(subjectId);
return Result.OK(boundList);
}
}
......@@ -45,7 +45,7 @@ public class StatisticalAnalysisController {
@Autowired
private ClbLabelService clbLabelService;
@Autowired
private InformationService informationService;
private InformationService informationService;
/**
* 概述分析
......@@ -106,8 +106,8 @@ public class StatisticalAnalysisController {
public Result<List<CountVO>> dataTrend(@RequestBody InfoDataSearchCondition searchCondition) {
List<CountVO> dataList = new ArrayList<>();
List<SysDictItem> dictItemList = sysDictItemService.listByDictCode("Thematic_Library");
List<String> includeValues = dictItemList.stream().map(SysDictItem::getItemValue).collect(Collectors.toList());
searchCondition.setIncludeValues(includeValues.toArray(new String[0]));
String[] includeValues = dictItemList.stream().map(SysDictItem::getItemValue).toArray(String[]::new);
searchCondition.setIncludeValues(includeValues);
if (CollectionUtils.isEmpty(searchCondition.getIds()) && searchCondition.getNum() == null) {
dataList = esService.groupByDate(searchCondition);
} else {
......
package com.zzsn.event.controller.thirdApi;
import com.zzsn.event.constant.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
*
* @author lkg
* @date 2025/2/20
*/
@Slf4j
@RestController
@RequestMapping("/subject/api")
public class SubjectAPi {
public Result<?> pageList(String name,Integer type){
return null;
}
}
......@@ -44,9 +44,6 @@ public class InfoSource implements Serializable {
/**国家*/
@ApiModelProperty(value = "国家")
private String country;
/**是否境外*/
@ApiModelProperty(value = "是否境外")
private String ynOther;
/**地区*/
@ApiModelProperty(value = "地区")
private String area;
......
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 专题-字典关系表
* @TableName subject_dict_map
*/
@Data
@TableName("subject_dict_map")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SubjectDictMap implements Serializable {
/**
* 主键id
*/
@TableId("id")
private String id;
/**
* 专题id
*/
@TableField("subject_id")
private String subjectId;
/**
* 字典id
*/
@TableField("dict_id")
private String dictId;
/**
* 创建人
*/
@TableField("create_by")
private String createBy;
/**
* 创建时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@TableField("create_time")
private Date createTime;
}
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
......@@ -99,4 +100,10 @@ public class SysDictItem implements Serializable {
*/
private Integer level;
/**
* 字典编码
*/
@TableField(exist = false)
private String dictCode;
}
package com.zzsn.event.mapper;
import com.zzsn.event.entity.SubjectDictMap;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.DictVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author lenovo
* @description 针对表【subject_dict_map(专题-字典关系表)】的数据库操作Mapper
* @createDate 2025-03-28 11:56:32
* @Entity com.zzsn.event.entity.SubjectDictMap
*/
@Mapper
public interface SubjectDictMapMapper extends BaseMapper<SubjectDictMap> {
/**
* 专题绑定的数据字典信息
*
* @param subjectId 专题id
* @author lkg
* @date 2025/3/28
*/
List<DictVO> boundList(@Param("subjectId") String subjectId);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zzsn.event.mapper.SubjectDictMapMapper">
<resultMap id="BaseResultMap" type="com.zzsn.event.entity.SubjectDictMap">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="subjectId" column="subject_id" jdbcType="VARCHAR"/>
<result property="dictId" column="dict_id" jdbcType="INTEGER"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<select id="boundList" resultType="com.zzsn.event.vo.DictVO">
select d.id,d.dict_code as code,d.dict_name as name from subject_dict_map m
inner join clb_system.sys_dict d on m.dict_id = d.id
where m.subject_id = #{subjectId}
</select>
</mapper>
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.ClbFileOperationLog;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.DisplayInfo;
......@@ -123,6 +124,16 @@ public interface InformationService {
void updateInfo(JSONObject jsonObject, UserVo userVo);
/**
* 资讯绑定标签
*
* @param dataBindLabelFrom 绑定参数
* @param boundList 专题绑定的标签(数据字典)集合
* @author lkg
* @date 2025/3/31
*/
void modifyLabel(DataBindLabelFrom dataBindLabelFrom,List<DictVO> boundList);
/**
* 审核
*
* @param map 审核参数
......@@ -206,7 +217,7 @@ public interface InformationService {
* @author lkg
* @date 2025/2/5
*/
void importDataInfo(List<List<String>> lists, String subjectId);
void importDataInfo(List<FileDataVO> lists, String subjectId);
/**
* 移除专题下的数据-研究中心
......
package com.zzsn.event.service;
import com.zzsn.event.entity.SubjectDictMap;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.DictVO;
import com.zzsn.event.vo.SubjectBindLabelParam;
import java.util.List;
/**
* @author lenovo
* @description 针对表【subject_dict_map(专题-字典关系表)】的数据库操作Service
* @createDate 2025-03-28 11:56:32
*/
public interface SubjectDictMapService extends IService<SubjectDictMap> {
/**
* 专题绑定数据字典
*
* @param bindLabelParam 绑定参数
* @author lkg
* @date 2025/3/28
*/
void modify(SubjectBindLabelParam bindLabelParam);
/**
* 专题绑定的数据字典信息
*
* @param subjectId 专题id
* @author lkg
* @date 2025/3/28
*/
List<DictVO> boundList(String subjectId);
}
......@@ -20,6 +20,7 @@ import com.zzsn.event.es.EsService;
import com.zzsn.event.mapper.SubjectMapper;
import com.zzsn.event.service.*;
import com.zzsn.event.util.*;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.user.AuthUtil;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
......@@ -350,7 +351,7 @@ public class InformationServiceImpl implements InformationService {
info.setContent(contentNoTag2);
}
info.setPublishDate(EsDateUtil.esFieldDateMapping(info.getPublishDate()));
if (type == 2) {
if (null != type && type == 2) {
//获取附件信息
if (info.getAttachmentIds() != null && info.getAttachmentIds().size() > 0) {
List<AttachmentInfo> attachmentInfoList = new ArrayList<>();
......@@ -374,9 +375,8 @@ public class InformationServiceImpl implements InformationService {
info.setAttachmentInfos(attachmentInfoList);
info.setYnArticle(false);
}
CompletableFuture.runAsync(() -> addReadNum(info, index));
}
CompletableFuture.runAsync(() -> addReadNum(info, index));
return info;
}
......@@ -610,6 +610,42 @@ public class InformationServiceImpl implements InformationService {
}
@Override
public void modifyLabel(DataBindLabelFrom dataBindLabelFrom,List<DictVO> boundList) {
DisplayInfo info = (DisplayInfo) esOpUtil.getInfoById(dataBindLabelFrom.getIndex(), dataBindLabelFrom.getId(), DisplayInfo.class);
if (info != null) {
List<Label> newLabels = new ArrayList<>();
List<SysDictItem> dictItemList = dataBindLabelFrom.getDictItemList();
for (SysDictItem sysDictItem : dictItemList) {
Label label = new Label();
label.setRelationId(sysDictItem.getId());
label.setLabelMark(sysDictItem.getDictCode());
label.setRelationName(sysDictItem.getItemText());
newLabels.add(label);
}
List<Label> labels = info.getLabels();
if (CollectionUtils.isNotEmpty(labels)) {
List<String> dictCodes = new ArrayList<>();
boundList.forEach(node -> dictCodes.add(node.getCode()));
List<Label> collect = labels.stream().filter(label -> dictCodes.contains(label.getLabelMark())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
List<String> dictItemIds = new ArrayList<>();
dictItemList.forEach(sysDictItem -> dictItemIds.add(sysDictItem.getId()));
for (Label label : collect) {
if (dictItemIds.contains(label.getRelationId())) {
newLabels.add(label);
}
}
}
List<Label> otherCollect = labels.stream().filter(label -> !dictCodes.contains(label.getLabelMark())).collect(Collectors.toList());
newLabels.addAll(otherCollect);
}
List<Label> finalList = newLabels.stream().collect(Collectors.collectingAndThen(Collectors.toMap(Label::getRelationId, p -> p, (p1, p2) -> p1), map -> new ArrayList<>(map.values())));
info.setLabels(finalList);
esOpUtil.docUpdateById(dataBindLabelFrom.getIndex(), info.getId(), JSON.toJSONString(info));
}
}
@Override
public void checkInfo(Map<String, Object> map, UserVo userVo) {
List<Map<String, String>> ids = (List<Map<String, String>>) map.get("ids");
Integer checkStatus = (Integer) map.get("checkStatus");
......@@ -888,7 +924,7 @@ public class InformationServiceImpl implements InformationService {
}
specialInformation.setCreateDate(cn.hutool.core.date.DateUtil.format(new Date(), "yyyy-MM-dd'T'HH:mm:ss"));
specialInformation.setProcessDate(specialInformation.getCreateDate());
String index = Constants.SUBJECT_INDEX;
String index = Constants.SUBJECT_INDEX + "_" + DateUtils.getYear();
esOpUtil.docSavaByEntity(index, specialInformation.getId(), specialInformation);
clbFileOperationLog.getClbFileOperationLogDetails().add(clbFileOperationLogDetailsService.buildFailDetails(info.get(1), info.get(5), info.get(7)));
} catch (NumberFormatException e) {
......@@ -901,25 +937,25 @@ public class InformationServiceImpl implements InformationService {
}
@Override
public void importDataInfo(List<List<String>> lists, String subjectId) {
public void importDataInfo(List<FileDataVO> lists, String subjectId) {
if (CollectionUtil.isNotEmpty(lists)) {
String index = Constants.SUBJECT_INDEX;
String index = Constants.SUBJECT_INDEX + "_" + DateUtils.getYear();
List<SpecialInformation> dataList = new ArrayList<>();
for (List<String> info : lists) {
for (FileDataVO info : lists) {
SpecialInformation specialInformation = new SpecialInformation();
specialInformation.setId(codeGenerateUtil.geneIdNo(Constants.DATA_ADD_ID, 8));
if (StringUtils.isNotEmpty(info.get(0))) {
specialInformation.setTitle(info.get(0));
if (StringUtils.isNotEmpty(info.getTitle())) {
specialInformation.setTitle(info.getTitle());
}
if (StringUtils.isNotEmpty(info.get(1))) {
specialInformation.setAuthor(info.get(1));
if (StringUtils.isNotEmpty(info.getAuthor())) {
specialInformation.setAuthor(info.getAuthor());
}
if (StringUtils.isNotEmpty(info.get(2))) {
specialInformation.setOrigin(info.get(2));
specialInformation.setSid(info.get(2));
if (StringUtils.isNotEmpty(info.getOrigin())) {
specialInformation.setOrigin(info.getOrigin());
specialInformation.setSid(info.getOrigin());
}
if (StringUtils.isNotEmpty(info.get(3))) {
String library = info.get(3);
String library = info.getClassificationType();
if (StringUtils.isNotEmpty(library)) {
SysDictItem dictItem = sysDictItemService.dictItemInfoByName("Thematic_Library", library);
if (dictItem != null) {
specialInformation.setClassificationType(Integer.parseInt(dictItem.getItemValue()));
......@@ -929,19 +965,20 @@ public class InformationServiceImpl implements InformationService {
} else {
specialInformation.setClassificationType(0);
}
if (StringUtils.isNotEmpty(info.get(4))) {
specialInformation.setSourceAddress(info.get(4));
if (StringUtils.isNotEmpty(info.getSourceAddress())) {
specialInformation.setSourceAddress(info.getSourceAddress());
}
if (StringUtils.isNotEmpty(info.get(5))) {
specialInformation.setPublishDate(EsDateUtil.esFieldDateFormat(info.get(5)));
if (StringUtils.isNotEmpty(info.getPublishDate())) {
specialInformation.setPublishDate(EsDateUtil.esFieldDateFormat(info.getPublishDate()));
}
if (StringUtils.isNotEmpty(info.get(6))) {
specialInformation.setContent(info.get(6));
if (StringUtils.isNotEmpty(info.getContent())) {
specialInformation.setContent(info.getContent());
}
specialInformation.setCheckStatus(1);
specialInformation.setDeleteFlag(0);
specialInformation.setTopNum(0);
specialInformation.setDataFrom(1);
specialInformation.setScore(0D);
specialInformation.setSubjectId(subjectId);
String format = DateUtil.dateToString(new Date(), "yyyy-MM-dd'T'HH:mm:ss");
specialInformation.setCreateDate(format);
......@@ -1156,7 +1193,11 @@ public class InformationServiceImpl implements InformationService {
if (StringUtils.isNotEmpty(origin)) {
LambdaQueryWrapper<InfoSource> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(InfoSource::getSiteName, origin);
InfoSource infoSource = infoSourceService.getOne(queryWrapper);
List<InfoSource> list = infoSourceService.list(queryWrapper);
InfoSource infoSource = null;
if (CollectionUtils.isNotEmpty(list)) {
infoSource = list.get(0);
}
if (infoSource != null) {
String sid = infoSource.getId();
sidList.add(sid);
......
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.SubjectDictMap;
import com.zzsn.event.service.SubjectDictMapService;
import com.zzsn.event.mapper.SubjectDictMapMapper;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.DictVO;
import com.zzsn.event.vo.SubjectBindLabelParam;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author lenovo
* @description 针对表【subject_dict_map(专题-字典关系表)】的数据库操作Service实现
* @createDate 2025-03-28 11:56:32
*/
@Service
public class SubjectDictMapServiceImpl extends ServiceImpl<SubjectDictMapMapper, SubjectDictMap> implements SubjectDictMapService{
@Override
public void modify(SubjectBindLabelParam bindLabelParam) {
String subjectId = bindLabelParam.getSubjectId();
List<String> dictIdList = bindLabelParam.getDictIdList();
LambdaQueryWrapper<SubjectDictMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SubjectDictMap::getSubjectId,subjectId);
int count = this.count(queryWrapper);
if (count > 0) {
this.remove(queryWrapper);
}
List<SubjectDictMap> subjectDictMaps = new ArrayList<>();
for (String dictId : dictIdList) {
SubjectDictMap subjectDictMap = new SubjectDictMap();
subjectDictMap.setSubjectId(subjectId);
subjectDictMap.setDictId(dictId);
subjectDictMaps.add(subjectDictMap);
}
this.saveBatch(subjectDictMaps);
}
@Override
public List<DictVO> boundList(String subjectId) {
return baseMapper.boundList(subjectId);
}
}
package com.zzsn.event.vo;
import com.zzsn.event.entity.SysDictItem;
import lombok.Data;
import java.util.List;
/**
* 资讯绑定标签请求参数
*
* @author lkg
* @date 2025/3/28
*/
@Data
public class DataBindLabelFrom {
/**索引*/
private String index;
/**资讯id*/
private String id;
/**专题id*/
private String subjectId;
/**字典id*/
private List<SysDictItem> dictItemList;
}
package com.zzsn.event.vo;
import lombok.Data;
/**
*
*
* @author lkg
* @date 2025/4/1
*/
@Data
public class DictVO {
private String id;
private String code;
private String name;
}
package com.zzsn.event.vo;
import lombok.Data;
/**
*
*
* @author lkg
* @date 2025/4/1
*/
@Data
public class FileDataVO {
private String title;
private String content;
private String author;
private String origin;
private String sourceAddress;
private String classificationType;
private String publishDate;
}
package com.zzsn.event.vo;
import lombok.Data;
import java.util.List;
/**
* 专题绑定标签参数
*
* @author lkg
* @date 2025/3/28
*/
@Data
public class SubjectBindLabelParam {
/**专题id*/
private String subjectId;
/**数据字典id集合*/
private List<String> dictIdList;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论