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

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

上级 33cf89ef
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;
......@@ -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, "不支持的文件类型");
}
......
......@@ -356,7 +356,7 @@ public class InformationController {
*/
@PostMapping(value = "/modifyLabel")
public Result<?> modifyLabel(@RequestBody DataBindLabelFrom bindLabelFrom) {
List<Node> nodes = subjectDictMapService.boundList(bindLabelFrom.getSubjectId());
List<DictVO> nodes = subjectDictMapService.boundList(bindLabelFrom.getSubjectId());
informationService.modifyLabel(bindLabelFrom,nodes);
return Result.OK();
}
......
......@@ -292,7 +292,7 @@ public class RelationBindController {
*/
@GetMapping("/boundLabelList")
public Result<?> boundLabelList(@RequestParam String subjectId){
List<Node> boundList = subjectDictMapService.boundList(subjectId);
List<DictVO> boundList = subjectDictMapService.boundList(subjectId);
return Result.OK(boundList);
}
}
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;
}
......@@ -3,6 +3,7 @@ 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;
......@@ -24,7 +25,7 @@ public interface SubjectDictMapMapper extends BaseMapper<SubjectDictMap> {
* @author lkg
* @date 2025/3/28
*/
List<Node> boundList(@Param("subjectId") String subjectId);
List<DictVO> boundList(@Param("subjectId") String subjectId);
}
......
......@@ -12,8 +12,8 @@
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<select id="boundList" resultType="com.zzsn.event.util.tree.Node">
select d.id,d.dict_name as name from subject_dict_map m
<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>
......
......@@ -131,7 +131,7 @@ public interface InformationService {
* @author lkg
* @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 {
* @author lkg
* @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;
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;
......@@ -30,5 +31,5 @@ public interface SubjectDictMapService extends IService<SubjectDictMap> {
* @author lkg
* @date 2025/3/28
*/
List<Node> boundList(String subjectId);
List<DictVO> boundList(String subjectId);
}
......@@ -610,7 +610,7 @@ public class InformationServiceImpl implements InformationService {
}
@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);
if (info != null) {
List<Label> newLabels = new ArrayList<>();
......@@ -618,7 +618,7 @@ public class InformationServiceImpl implements InformationService {
for (SysDictItem sysDictItem : dictItemList) {
Label label = new Label();
label.setRelationId(sysDictItem.getId());
label.setLabelMark(sysDictItem.getDictId());
label.setLabelMark(sysDictItem.getDictCode());
label.setRelationName(sysDictItem.getItemText());
newLabels.add(label);
}
......@@ -937,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 + "_" + 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()));
......@@ -965,14 +965,14 @@ 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);
......
......@@ -7,6 +7,7 @@ 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;
......@@ -42,7 +43,7 @@ public class SubjectDictMapServiceImpl extends ServiceImpl<SubjectDictMapMapper,
}
@Override
public List<Node> boundList(String subjectId) {
public List<DictVO> boundList(String 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论