提交 5b84ca14 作者: 925993793@qq.com

【fix】专题绑定标签字段替换;文件导入优化,表头顺序可不一致

上级 33cf89ef
package com.zzsn.event.controller; 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.Document;
import com.aspose.words.SaveFormat; import com.aspose.words.SaveFormat;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
...@@ -14,6 +16,7 @@ import com.zzsn.event.service.*; ...@@ -14,6 +16,7 @@ import com.zzsn.event.service.*;
import com.zzsn.event.util.*; import com.zzsn.event.util.*;
import com.zzsn.event.util.user.UserUtil; import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo; import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.FileDataVO;
import com.zzsn.event.vo.InfoDataSearchCondition; import com.zzsn.event.vo.InfoDataSearchCondition;
import com.zzsn.event.vo.LabelModelVo; import com.zzsn.event.vo.LabelModelVo;
import com.zzsn.event.vo.es.AttachmentInfo; import com.zzsn.event.vo.es.AttachmentInfo;
...@@ -321,20 +324,23 @@ public class FileController { ...@@ -321,20 +324,23 @@ public class FileController {
if ("xls".equals(fileSuffix) || "xlsx".equals(fileSuffix)) { if ("xls".equals(fileSuffix) || "xlsx".equals(fileSuffix)) {
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
try { try {
byte[] fileData = multipartFile.getBytes(); ExcelReader reader = ExcelUtil.getReader(multipartFile.getInputStream());
//读取文件内容 Map<String, String> header = new HashMap<>();
List<List<String>> lists; header.put("标题", "title");
if ("xls".equals(fileSuffix)) { header.put("作者", "author");
lists = ExcelExportUtil.readExcelXls(new ByteArrayInputStream(fileData), true,1, 7); header.put("来源", "origin");
} else { header.put("资讯类型", "classificationType");
lists = ExcelExportUtil.readExcelXlsx(new ByteArrayInputStream(fileData), true,1, 7); header.put("原文链接", "sourceAddress");
} header.put("发布时间", "publishDate");
informationService.importDataInfo(lists,subjectId); header.put("正文内容", "content");
reader.setHeaderAlias(header);
List<FileDataVO> informationList = reader.read(0, 1, FileDataVO.class);
informationService.importDataInfo(informationList,subjectId);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
}); });
return Result.OK("正在进行处理"); return Result.OK("数据正在处理,请稍后查看");
} else { } else {
return Result.FAIL(500, "不支持的文件类型"); return Result.FAIL(500, "不支持的文件类型");
} }
......
...@@ -356,7 +356,7 @@ public class InformationController { ...@@ -356,7 +356,7 @@ public class InformationController {
*/ */
@PostMapping(value = "/modifyLabel") @PostMapping(value = "/modifyLabel")
public Result<?> modifyLabel(@RequestBody DataBindLabelFrom bindLabelFrom) { public Result<?> modifyLabel(@RequestBody DataBindLabelFrom bindLabelFrom) {
List<Node> nodes = subjectDictMapService.boundList(bindLabelFrom.getSubjectId()); List<DictVO> nodes = subjectDictMapService.boundList(bindLabelFrom.getSubjectId());
informationService.modifyLabel(bindLabelFrom,nodes); informationService.modifyLabel(bindLabelFrom,nodes);
return Result.OK(); return Result.OK();
} }
......
...@@ -292,7 +292,7 @@ public class RelationBindController { ...@@ -292,7 +292,7 @@ public class RelationBindController {
*/ */
@GetMapping("/boundLabelList") @GetMapping("/boundLabelList")
public Result<?> boundLabelList(@RequestParam String subjectId){ public Result<?> boundLabelList(@RequestParam String subjectId){
List<Node> boundList = subjectDictMapService.boundList(subjectId); List<DictVO> boundList = subjectDictMapService.boundList(subjectId);
return Result.OK(boundList); return Result.OK(boundList);
} }
} }
package com.zzsn.event.entity; package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
...@@ -99,4 +100,10 @@ public class SysDictItem implements Serializable { ...@@ -99,4 +100,10 @@ public class SysDictItem implements Serializable {
*/ */
private Integer level; private Integer level;
/**
* 字典编码
*/
@TableField(exist = false)
private String dictCode;
} }
...@@ -3,6 +3,7 @@ package com.zzsn.event.mapper; ...@@ -3,6 +3,7 @@ package com.zzsn.event.mapper;
import com.zzsn.event.entity.SubjectDictMap; import com.zzsn.event.entity.SubjectDictMap;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.DictVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -24,7 +25,7 @@ public interface SubjectDictMapMapper extends BaseMapper<SubjectDictMap> { ...@@ -24,7 +25,7 @@ public interface SubjectDictMapMapper extends BaseMapper<SubjectDictMap> {
* @author lkg * @author lkg
* @date 2025/3/28 * @date 2025/3/28
*/ */
List<Node> boundList(@Param("subjectId") String subjectId); List<DictVO> boundList(@Param("subjectId") String subjectId);
} }
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
<select id="boundList" resultType="com.zzsn.event.util.tree.Node"> <select id="boundList" resultType="com.zzsn.event.vo.DictVO">
select d.id,d.dict_name as name from subject_dict_map m 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 inner join clb_system.sys_dict d on m.dict_id = d.id
where m.subject_id = #{subjectId} where m.subject_id = #{subjectId}
</select> </select>
......
...@@ -131,7 +131,7 @@ public interface InformationService { ...@@ -131,7 +131,7 @@ public interface InformationService {
* @author lkg * @author lkg
* @date 2025/3/31 * @date 2025/3/31
*/ */
void modifyLabel(DataBindLabelFrom dataBindLabelFrom,List<Node> boundList); void modifyLabel(DataBindLabelFrom dataBindLabelFrom,List<DictVO> boundList);
/** /**
* 审核 * 审核
...@@ -217,7 +217,7 @@ public interface InformationService { ...@@ -217,7 +217,7 @@ public interface InformationService {
* @author lkg * @author lkg
* @date 2025/2/5 * @date 2025/2/5
*/ */
void importDataInfo(List<List<String>> lists, String subjectId); void importDataInfo(List<FileDataVO> lists, String subjectId);
/** /**
* 移除专题下的数据-研究中心 * 移除专题下的数据-研究中心
......
...@@ -3,6 +3,7 @@ package com.zzsn.event.service; ...@@ -3,6 +3,7 @@ package com.zzsn.event.service;
import com.zzsn.event.entity.SubjectDictMap; import com.zzsn.event.entity.SubjectDictMap;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.DictVO;
import com.zzsn.event.vo.SubjectBindLabelParam; import com.zzsn.event.vo.SubjectBindLabelParam;
import java.util.List; import java.util.List;
...@@ -30,5 +31,5 @@ public interface SubjectDictMapService extends IService<SubjectDictMap> { ...@@ -30,5 +31,5 @@ public interface SubjectDictMapService extends IService<SubjectDictMap> {
* @author lkg * @author lkg
* @date 2025/3/28 * @date 2025/3/28
*/ */
List<Node> boundList(String subjectId); List<DictVO> boundList(String subjectId);
} }
...@@ -610,7 +610,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -610,7 +610,7 @@ public class InformationServiceImpl implements InformationService {
} }
@Override @Override
public void modifyLabel(DataBindLabelFrom dataBindLabelFrom,List<Node> boundList) { public void modifyLabel(DataBindLabelFrom dataBindLabelFrom,List<DictVO> boundList) {
DisplayInfo info = (DisplayInfo) esOpUtil.getInfoById(dataBindLabelFrom.getIndex(), dataBindLabelFrom.getId(), DisplayInfo.class); DisplayInfo info = (DisplayInfo) esOpUtil.getInfoById(dataBindLabelFrom.getIndex(), dataBindLabelFrom.getId(), DisplayInfo.class);
if (info != null) { if (info != null) {
List<Label> newLabels = new ArrayList<>(); List<Label> newLabels = new ArrayList<>();
...@@ -618,7 +618,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -618,7 +618,7 @@ public class InformationServiceImpl implements InformationService {
for (SysDictItem sysDictItem : dictItemList) { for (SysDictItem sysDictItem : dictItemList) {
Label label = new Label(); Label label = new Label();
label.setRelationId(sysDictItem.getId()); label.setRelationId(sysDictItem.getId());
label.setLabelMark(sysDictItem.getDictId()); label.setLabelMark(sysDictItem.getDictCode());
label.setRelationName(sysDictItem.getItemText()); label.setRelationName(sysDictItem.getItemText());
newLabels.add(label); newLabels.add(label);
} }
...@@ -937,25 +937,25 @@ public class InformationServiceImpl implements InformationService { ...@@ -937,25 +937,25 @@ public class InformationServiceImpl implements InformationService {
} }
@Override @Override
public void importDataInfo(List<List<String>> lists, String subjectId) { public void importDataInfo(List<FileDataVO> lists, String subjectId) {
if (CollectionUtil.isNotEmpty(lists)) { if (CollectionUtil.isNotEmpty(lists)) {
String index = Constants.SUBJECT_INDEX + "_" + DateUtils.getYear(); String index = Constants.SUBJECT_INDEX + "_" + DateUtils.getYear();
List<SpecialInformation> dataList = new ArrayList<>(); List<SpecialInformation> dataList = new ArrayList<>();
for (List<String> info : lists) { for (FileDataVO info : lists) {
SpecialInformation specialInformation = new SpecialInformation(); SpecialInformation specialInformation = new SpecialInformation();
specialInformation.setId(codeGenerateUtil.geneIdNo(Constants.DATA_ADD_ID, 8)); specialInformation.setId(codeGenerateUtil.geneIdNo(Constants.DATA_ADD_ID, 8));
if (StringUtils.isNotEmpty(info.get(0))) { if (StringUtils.isNotEmpty(info.getTitle())) {
specialInformation.setTitle(info.get(0)); specialInformation.setTitle(info.getTitle());
} }
if (StringUtils.isNotEmpty(info.get(1))) { if (StringUtils.isNotEmpty(info.getAuthor())) {
specialInformation.setAuthor(info.get(1)); specialInformation.setAuthor(info.getAuthor());
} }
if (StringUtils.isNotEmpty(info.get(2))) { if (StringUtils.isNotEmpty(info.getOrigin())) {
specialInformation.setOrigin(info.get(2)); specialInformation.setOrigin(info.getOrigin());
specialInformation.setSid(info.get(2)); specialInformation.setSid(info.getOrigin());
} }
if (StringUtils.isNotEmpty(info.get(3))) { String library = info.getClassificationType();
String library = info.get(3); if (StringUtils.isNotEmpty(library)) {
SysDictItem dictItem = sysDictItemService.dictItemInfoByName("Thematic_Library", library); SysDictItem dictItem = sysDictItemService.dictItemInfoByName("Thematic_Library", library);
if (dictItem != null) { if (dictItem != null) {
specialInformation.setClassificationType(Integer.parseInt(dictItem.getItemValue())); specialInformation.setClassificationType(Integer.parseInt(dictItem.getItemValue()));
...@@ -965,14 +965,14 @@ public class InformationServiceImpl implements InformationService { ...@@ -965,14 +965,14 @@ public class InformationServiceImpl implements InformationService {
} else { } else {
specialInformation.setClassificationType(0); specialInformation.setClassificationType(0);
} }
if (StringUtils.isNotEmpty(info.get(4))) { if (StringUtils.isNotEmpty(info.getSourceAddress())) {
specialInformation.setSourceAddress(info.get(4)); specialInformation.setSourceAddress(info.getSourceAddress());
} }
if (StringUtils.isNotEmpty(info.get(5))) { if (StringUtils.isNotEmpty(info.getPublishDate())) {
specialInformation.setPublishDate(EsDateUtil.esFieldDateFormat(info.get(5))); specialInformation.setPublishDate(EsDateUtil.esFieldDateFormat(info.getPublishDate()));
} }
if (StringUtils.isNotEmpty(info.get(6))) { if (StringUtils.isNotEmpty(info.getContent())) {
specialInformation.setContent(info.get(6)); specialInformation.setContent(info.getContent());
} }
specialInformation.setCheckStatus(1); specialInformation.setCheckStatus(1);
specialInformation.setDeleteFlag(0); specialInformation.setDeleteFlag(0);
......
...@@ -7,6 +7,7 @@ import com.zzsn.event.entity.SubjectDictMap; ...@@ -7,6 +7,7 @@ import com.zzsn.event.entity.SubjectDictMap;
import com.zzsn.event.service.SubjectDictMapService; import com.zzsn.event.service.SubjectDictMapService;
import com.zzsn.event.mapper.SubjectDictMapMapper; import com.zzsn.event.mapper.SubjectDictMapMapper;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.DictVO;
import com.zzsn.event.vo.SubjectBindLabelParam; import com.zzsn.event.vo.SubjectBindLabelParam;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -42,7 +43,7 @@ public class SubjectDictMapServiceImpl extends ServiceImpl<SubjectDictMapMapper, ...@@ -42,7 +43,7 @@ public class SubjectDictMapServiceImpl extends ServiceImpl<SubjectDictMapMapper,
} }
@Override @Override
public List<Node> boundList(String subjectId) { public List<DictVO> boundList(String subjectId) {
return baseMapper.boundList(subjectId); return baseMapper.boundList(subjectId);
} }
} }
......
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;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论