feat: 老法规国标准入性推荐性体系关联导入
This commit is contained in:
+29
-25
@@ -1,31 +1,26 @@
|
|||||||
package com.jero.modules.laws.oldSystem.controller;
|
package com.jero.modules.laws.oldSystem.controller;
|
||||||
|
|
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||||
|
import com.jero.common.aspect.annotation.AutoLog;
|
||||||
|
import com.jero.modules.laws.oldSystem.service.OldSystemDepartRelationService;
|
||||||
|
import com.jero.modules.laws.oldSystem.service.OldSystemService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: Mzaxd
|
* @author: Mzaxd
|
||||||
* @Date: 2023/11/10 14:46
|
* @Date: 2023/11/10 14:46
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
|
||||||
import com.jero.common.api.vo.Result;
|
|
||||||
import com.jero.common.aspect.annotation.AutoLog;
|
|
||||||
import com.jero.common.aspect.annotation.Translation;
|
|
||||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
|
||||||
import com.jero.modules.laws.oldSystem.service.OldSystemDepartRelationService;
|
|
||||||
import com.jero.modules.laws.oldSystem.service.OldSystemService;
|
|
||||||
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.http.HttpResponse;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
@ApiSupport(order = 10101)
|
@ApiSupport(order = 10101)
|
||||||
@Api(tags="老法规系统")
|
@Api(tags="老法规系统")
|
||||||
@RestController
|
@RestController
|
||||||
@@ -127,13 +122,22 @@ public class OldSystemController {
|
|||||||
oldSystemService.importEsStandSystem(file, response);
|
oldSystemService.importEsStandSystem(file, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/importGbStandSystem")
|
@PostMapping("/importGbStandSystemApproval")
|
||||||
@AutoLog(value = "老法规系统-导入国标体系")
|
@AutoLog(value = "老法规系统-导入国标体系(准入性)")
|
||||||
@ApiOperation(value="老法规系统-导入国标体系", notes="老法规系统-导入国标体系", produces = "application/octet-stream")
|
@ApiOperation(value="老法规系统-导入国标体系(准入性)", notes="老法规系统-导入国标体系(准入性)", produces = "application/octet-stream")
|
||||||
@ApiOperationSupport(order = 10)
|
@ApiOperationSupport(order = 10)
|
||||||
public void importGbStandSystem(@RequestParam("file") MultipartFile file,
|
public void importGbStandSystemApproval(@RequestParam("file") MultipartFile file,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
oldSystemService.importGbStandSystem(file, response);
|
oldSystemService.importGbStandSystem(file, response, "approval");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/importGbStandSystemRecommend")
|
||||||
|
@AutoLog(value = "老法规系统-导入国标体系(推荐性)")
|
||||||
|
@ApiOperation(value="老法规系统-导入国标体系(推荐性)", notes="老法规系统-导入国标体系(推荐性)", produces = "application/octet-stream")
|
||||||
|
@ApiOperationSupport(order = 11)
|
||||||
|
public void importGbStandSystemRecommend(@RequestParam("file") MultipartFile file,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
oldSystemService.importGbStandSystem(file, response, "recommend");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.jero.modules.laws.oldSystem.entity;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Mzaxd
|
||||||
|
* @Date: 2023/11/29 11:47
|
||||||
|
*
|
||||||
|
* 对应标准权限-1所有人.xlsx
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class GBStandSystem {
|
||||||
|
|
||||||
|
|
||||||
|
@Excel(name = "标准号")
|
||||||
|
@ApiModelProperty(value = "标准号")
|
||||||
|
private String standardNumber;
|
||||||
|
|
||||||
|
@Excel(name = "标准名称")
|
||||||
|
@ApiModelProperty(value = "标准名称")
|
||||||
|
private String standardName;
|
||||||
|
|
||||||
|
@Excel(name = "标准分类")
|
||||||
|
@ApiModelProperty(value = "标准分类")
|
||||||
|
private String standardType;
|
||||||
|
|
||||||
|
@Excel(name = "制修订状态")
|
||||||
|
@ApiModelProperty(value = "制修订状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Excel(name = "错误信息")
|
||||||
|
@ApiModelProperty(value = "错误信息")
|
||||||
|
private String errorInfo;
|
||||||
|
|
||||||
|
public boolean isEmptyRow() {
|
||||||
|
return
|
||||||
|
standardNumber == null &&
|
||||||
|
standardName == null &&
|
||||||
|
standardType == null &&
|
||||||
|
status == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNoNeedImport() {
|
||||||
|
return status == null || !status.equals("发布");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -80,6 +80,6 @@ public interface OldSystemService {
|
|||||||
* @param file
|
* @param file
|
||||||
* @param response
|
* @param response
|
||||||
*/
|
*/
|
||||||
void importGbStandSystem(MultipartFile file, HttpServletResponse response);
|
void importGbStandSystem(MultipartFile file, HttpServletResponse response, String type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+157
-22
@@ -122,6 +122,9 @@ public class OldSystemServiceImpl implements OldSystemService {
|
|||||||
@Resource
|
@Resource
|
||||||
private ILawsEnterpriseStandardService esService;
|
private ILawsEnterpriseStandardService esService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ILawsDomesticStandardService gbService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ILawsTreeNodeService treeNodeService;
|
private ILawsTreeNodeService treeNodeService;
|
||||||
|
|
||||||
@@ -973,15 +976,6 @@ public class OldSystemServiceImpl implements OldSystemService {
|
|||||||
log.info("企标体系导入结束");
|
log.info("企标体系导入结束");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取父节点的nodeCode
|
|
||||||
private String getParentNodeCode(String nodeCode) {
|
|
||||||
if (nodeCode.length() > 3) {
|
|
||||||
return nodeCode.substring(0, nodeCode.length() - 3);
|
|
||||||
} else {
|
|
||||||
return null; // 没有父节点
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 在您的类中添加这个方法
|
// 在您的类中添加这个方法
|
||||||
private String buildPathToRoot(String nodeId, Map<String, LawsTreeNode> nodeIdMap) {
|
private String buildPathToRoot(String nodeId, Map<String, LawsTreeNode> nodeIdMap) {
|
||||||
// 获取当前节点
|
// 获取当前节点
|
||||||
@@ -999,8 +993,107 @@ public class OldSystemServiceImpl implements OldSystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importGbStandSystem(MultipartFile file, HttpServletResponse response) {
|
public void importGbStandSystem(MultipartFile file, HttpServletResponse response, String type) {
|
||||||
|
List<GBStandSystem> errImportList = new ArrayList<>();
|
||||||
|
// 验证文件是否为压缩格式file.getContentType()).contains("xls")
|
||||||
|
if (!Objects.requireNonNull(file.getOriginalFilename()).contains("xls")) {
|
||||||
|
throw new JeroBootException("文件格式不正确,请上传Excel。");
|
||||||
|
}
|
||||||
|
ImportParams params = new ImportParams();
|
||||||
|
params.setTitleRows(0);
|
||||||
|
params.setNeedSave(true);
|
||||||
|
|
||||||
|
// 获取所有企标转为Map
|
||||||
|
// 筛选有oldSystemId的数据
|
||||||
|
LambdaQueryWrapper<LawsDomesticStandard> gbWrapper = new LambdaQueryWrapper<>();
|
||||||
|
List<LawsDomesticStandard> gbList = gbService.list(gbWrapper.eq(LawsDomesticStandard::getDelFlag, YesOrNoEnum.NO.getValue()));
|
||||||
|
Map<String, LawsDomesticStandard> gbMap = gbList.stream().collect(Collectors.toMap(LawsDomesticStandard::getStandardNumber, o -> o));
|
||||||
|
|
||||||
|
// 获取所有企标体系节点并转为Map
|
||||||
|
String moduleCode = TableNameEnum.DOMESTIC_REGULATIONS.getValue();
|
||||||
|
LambdaQueryWrapper<LawsTreeNode> treeNodeWrapper = new LambdaQueryWrapper<>();
|
||||||
|
treeNodeWrapper.eq(LawsTreeNode::getModuleCode, moduleCode);
|
||||||
|
treeNodeWrapper.eq(LawsTreeNode::getDelFlag, YesOrNoEnum.NO.getValue());
|
||||||
|
List<LawsTreeNode> treeNodeList = treeNodeService.list(treeNodeWrapper);
|
||||||
|
Map<String, LawsTreeNode> nodeNameMap = treeNodeList.stream().collect(Collectors.toMap(LawsTreeNode::getNodeName, o -> o));
|
||||||
|
|
||||||
|
// 获取数据
|
||||||
|
List<GBStandSystem> datalist;
|
||||||
|
List<String> gbIdList = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
// 获取当前时间戳(毫秒)
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
@Cleanup
|
||||||
|
InputStream inputStream = file.getInputStream();
|
||||||
|
datalist = ExcelImportUtil.importExcel(inputStream, GBStandSystem.class, params);
|
||||||
|
// 删除空行
|
||||||
|
datalist.removeIf(GBStandSystem::isEmptyRow);
|
||||||
|
// 删除不需要导入的行
|
||||||
|
datalist.removeIf(GBStandSystem::isNoNeedImport);
|
||||||
|
// 区分数据
|
||||||
|
log.info("获取数据成功,总数据条数:{}", datalist.size());
|
||||||
|
// 获取当前时间戳(毫秒)
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
// 计算执行时间(毫秒)
|
||||||
|
long executionTime = endTime - startTime;
|
||||||
|
log.info("数据转换执行时间:" + executionTime + " 毫秒");
|
||||||
|
|
||||||
|
for (GBStandSystem gbStandSystem : datalist) {
|
||||||
|
try {
|
||||||
|
// 校验体系
|
||||||
|
String standardType = gbStandSystem.getStandardType();
|
||||||
|
if (StrUtil.isNotBlank(standardType)) {
|
||||||
|
// 如果有/的话,只取第一个/后面的数据,无论后面有没有/
|
||||||
|
if (standardType.contains("/")) {
|
||||||
|
standardType = standardType.substring(standardType.indexOf("/") + 1);
|
||||||
|
}
|
||||||
|
// 根据当前数据的id找到对应的企标
|
||||||
|
LawsDomesticStandard gb = gbMap.get(gbStandSystem.getStandardNumber());
|
||||||
|
if (gb == null) {
|
||||||
|
throw new JeroBootException("未找到该国标,标准编号:" + gbStandSystem.getStandardNumber()
|
||||||
|
+ ",标准名称:" + gbStandSystem.getStandardName());
|
||||||
|
}
|
||||||
|
if (type.equals("approval")) {
|
||||||
|
if (!standardType.endsWith("标准")) {
|
||||||
|
standardType = standardType + "标准";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 到Map中找到对应的体系
|
||||||
|
LawsTreeNode treeNode = nodeNameMap.get(standardType.trim());
|
||||||
|
if (treeNode == null) {
|
||||||
|
throw new JeroBootException("未找到对应的体系,标准编号:" + gbStandSystem.getStandardNumber()
|
||||||
|
+ "体系名称:" + gbStandSystem.getStandardType());
|
||||||
|
} else {
|
||||||
|
gbIdList.add(gb.getId());
|
||||||
|
lawsNodeRelationService.addRelation(treeNode.getId(), null, gb.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("错误数据:{}", gbStandSystem.toString());
|
||||||
|
gbStandSystem.setErrorInfo(e.getMessage());
|
||||||
|
errImportList.add(gbStandSystem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 修改所有国标的状态为推荐
|
||||||
|
LambdaUpdateWrapper<LawsDomesticStandard> dsWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
dsWrapper.in(LawsDomesticStandard::getId, gbIdList);
|
||||||
|
if (type.equals("approval")) {
|
||||||
|
dsWrapper.set(LawsDomesticStandard::getStandardProperty, "SN001");
|
||||||
|
} else {
|
||||||
|
dsWrapper.set(LawsDomesticStandard::getStandardProperty, "SN002");
|
||||||
|
}
|
||||||
|
gbService.update(dsWrapper);
|
||||||
|
log.info("国标体系导入成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("导入失败;{}", e.getMessage());
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!errImportList.isEmpty()) {
|
||||||
|
log.info("导入失败数据条数:{}", errImportList.size());
|
||||||
|
String fileName = type.equals("approval") ? "GBStandSystemErrorData(Approval).xls" : "GBStandSystemErrorData(Recommend).xls";
|
||||||
|
this.exportWithExcel(response, errImportList, fileName);
|
||||||
|
}
|
||||||
|
log.info("国标体系导入结束");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsChinese(String text) {
|
public boolean containsChinese(String text) {
|
||||||
@@ -1036,10 +1129,16 @@ public class OldSystemServiceImpl implements OldSystemService {
|
|||||||
o.getBzfl().contains("行业标准")).collect(Collectors.toList());
|
o.getBzfl().contains("行业标准")).collect(Collectors.toList());
|
||||||
log.info("国标相关数据条数:{}", gbDatalist.size());
|
log.info("国标相关数据条数:{}", gbDatalist.size());
|
||||||
|
|
||||||
// 过滤字段 根据标准号字段去重
|
// 首先,使用Map来记录每个标准号出现的次数
|
||||||
gbDatalist = gbDatalist.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()
|
Map<String, Long> frequencyMap = gbDatalist.stream()
|
||||||
-> new TreeSet<>(Comparator.comparing(OldSystemImportDTO::getBzh))), ArrayList::new));
|
.collect(Collectors.groupingBy(OldSystemImportDTO::getBzh, Collectors.counting()));
|
||||||
log.info("根据标准号去重后的国标相关数据条数:{}", gbDatalist.size());
|
|
||||||
|
// 然后,过滤掉那些出现次数超过1次的数据
|
||||||
|
gbDatalist = gbDatalist.stream()
|
||||||
|
.filter(dto -> frequencyMap.get(dto.getBzh()) == 1)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
log.info("删除掉所有重复的数据后相关数据条数:{}", gbDatalist.size());
|
||||||
|
|
||||||
// 找到所有人 并且用 姓名加工号做key
|
// 找到所有人 并且用 姓名加工号做key
|
||||||
Map<String, SysUser> allUserMap = sysUserService.list().stream().collect(Collectors.toMap(o -> o.getRealname() + o.getUsername(), o -> o));
|
Map<String, SysUser> allUserMap = sysUserService.list().stream().collect(Collectors.toMap(o -> o.getRealname() + o.getUsername(), o -> o));
|
||||||
@@ -1064,6 +1163,13 @@ public class OldSystemServiceImpl implements OldSystemService {
|
|||||||
if (defaultUser == null) {
|
if (defaultUser == null) {
|
||||||
throw new JeroBootException("未找到默认用户");
|
throw new JeroBootException("未找到默认用户");
|
||||||
}
|
}
|
||||||
|
// 获取所有企标体系节点并转为Map
|
||||||
|
String moduleCode = TableNameEnum.DOMESTIC_REGULATIONS.getValue();
|
||||||
|
LambdaQueryWrapper<LawsTreeNode> treeNodeWrapper = new LambdaQueryWrapper<>();
|
||||||
|
treeNodeWrapper.eq(LawsTreeNode::getModuleCode, moduleCode);
|
||||||
|
treeNodeWrapper.eq(LawsTreeNode::getDelFlag, YesOrNoEnum.NO.getValue());
|
||||||
|
List<LawsTreeNode> treeNodeList = treeNodeService.list(treeNodeWrapper);
|
||||||
|
Map<String, LawsTreeNode> nodeNameMap = treeNodeList.stream().collect(Collectors.toMap(LawsTreeNode::getNodeName, o -> o));
|
||||||
// 转换数据
|
// 转换数据
|
||||||
List<LawsDomesticStandard> gbList = new ArrayList<>();
|
List<LawsDomesticStandard> gbList = new ArrayList<>();
|
||||||
for (OldSystemImportDTO dto : gbDatalist) {
|
for (OldSystemImportDTO dto : gbDatalist) {
|
||||||
@@ -1155,6 +1261,22 @@ public class OldSystemServiceImpl implements OldSystemService {
|
|||||||
ossFileList.add(ossFile);
|
ossFileList.add(ossFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 校验体系
|
||||||
|
String bzfl = dto.getBzfl();
|
||||||
|
if (StrUtil.isNotBlank(bzfl)) {
|
||||||
|
// 如果有/的话,只取第一个/后面的数据,无论后面有没有/
|
||||||
|
if (bzfl.contains("/")) {
|
||||||
|
bzfl = bzfl.substring(bzfl.indexOf("/") + 1);
|
||||||
|
}
|
||||||
|
// 到Map中找到对应的体系
|
||||||
|
LawsTreeNode treeNode = nodeNameMap.get(bzfl.trim());
|
||||||
|
if (treeNode != null) {
|
||||||
|
gb.setStandardSystem(treeNode.getId());
|
||||||
|
} else {
|
||||||
|
throw new JeroBootException("未找到对应的体系,标准编号:" + dto.getBzh() + "体系名称:" + bzfl);
|
||||||
|
}
|
||||||
|
}
|
||||||
gb.setIsAsmsImport("0");
|
gb.setIsAsmsImport("0");
|
||||||
gbList.add(gb);
|
gbList.add(gb);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1210,6 +1332,10 @@ public class OldSystemServiceImpl implements OldSystemService {
|
|||||||
}
|
}
|
||||||
entity.setSubstituteStandardNumber(null);
|
entity.setSubstituteStandardNumber(null);
|
||||||
entity.setReplacedByStandardNumber(null);
|
entity.setReplacedByStandardNumber(null);
|
||||||
|
|
||||||
|
String nodeId = entity.getStandardSystem();
|
||||||
|
entity.setStandardSystem(null);
|
||||||
|
|
||||||
// 构建updateWrapper 将其余字段全部设为null
|
// 构建updateWrapper 将其余字段全部设为null
|
||||||
if (existingEntity != null) {
|
if (existingEntity != null) {
|
||||||
// 如果存在,则执行更新操作
|
// 如果存在,则执行更新操作
|
||||||
@@ -1221,6 +1347,7 @@ public class OldSystemServiceImpl implements OldSystemService {
|
|||||||
domesticStandardService.save(entity);
|
domesticStandardService.save(entity);
|
||||||
}
|
}
|
||||||
String standardId = entity.getId();
|
String standardId = entity.getId();
|
||||||
|
|
||||||
// 保存文件关联
|
// 保存文件关联
|
||||||
List<OSSFile> ossFiles = standardNumberToFileMap.get(entity.getStandardNumber());
|
List<OSSFile> ossFiles = standardNumberToFileMap.get(entity.getStandardNumber());
|
||||||
if (ossFiles != null && !ossFiles.isEmpty()) {
|
if (ossFiles != null && !ossFiles.isEmpty()) {
|
||||||
@@ -1228,6 +1355,11 @@ public class OldSystemServiceImpl implements OldSystemService {
|
|||||||
ossFile.setStandardId(standardId);
|
ossFile.setStandardId(standardId);
|
||||||
ossFileService.save(ossFile);
|
ossFileService.save(ossFile);
|
||||||
}
|
}
|
||||||
|
// 保存体系
|
||||||
|
if (StrUtil.isNotBlank(nodeId)) {
|
||||||
|
lawsNodeRelationService.removeByStandardId(standardId);
|
||||||
|
lawsNodeRelationService.addRelation(nodeId, null, standardId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
log.info("老法规国标覆盖导入完成");
|
log.info("老法规国标覆盖导入完成");
|
||||||
// 获取当前时间戳(毫秒)
|
// 获取当前时间戳(毫秒)
|
||||||
@@ -1285,17 +1417,20 @@ public class OldSystemServiceImpl implements OldSystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void oldSysESImport(List<OldSystemImportDTO> esDatalist, List<OldSystemImportDTO> errImportList) {
|
private void oldSysESImport(List<OldSystemImportDTO> esDatalist, List<OldSystemImportDTO> errImportList) {
|
||||||
|
esDatalist = esDatalist.stream().filter(o -> o.getBzfl().contains("企业标准"))
|
||||||
|
.collect(Collectors.toList());
|
||||||
log.info("企标相关数据条数:{}", esDatalist.size());
|
log.info("企标相关数据条数:{}", esDatalist.size());
|
||||||
|
|
||||||
// 过滤字段 根据标准号字段去重
|
// 首先,使用Map来记录每个标准号出现的次数
|
||||||
// esDatalist = esDatalist.stream()
|
Map<String, Long> frequencyMap = esDatalist.stream()
|
||||||
// .collect(Collectors.collectingAndThen(
|
.collect(Collectors.groupingBy(OldSystemImportDTO::getBzh, Collectors.counting()));
|
||||||
// Collectors.toCollection(() -> new TreeSet<>(Comparator
|
|
||||||
// .comparing(OldSystemImportDTO::getBzh)
|
|
||||||
// .thenComparing(dto -> !dto.getBzzt().equals("现行有效")))), // 确保“现行有效”状态的记录优先
|
|
||||||
// ArrayList::new));
|
|
||||||
|
|
||||||
log.info("根据标准号和标准状态去重后的企标相关数据条数:{}", esDatalist.size());
|
// 然后,过滤掉那些出现次数超过1次的数据
|
||||||
|
esDatalist = esDatalist.stream()
|
||||||
|
.filter(dto -> frequencyMap.get(dto.getBzh()) == 1)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
log.info("删除掉所有重复的数据后相关数据条数:{}", esDatalist.size());
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
// 转换数据
|
// 转换数据
|
||||||
|
|||||||
+3
-3
@@ -81,7 +81,7 @@ public class LawsTreeNodeController extends JeroController<LawsTreeNode, ILawsTr
|
|||||||
@AutoLog(value = "企业标准-添加")
|
@AutoLog(value = "企业标准-添加")
|
||||||
@ApiOperation(value = "企业标准-添加", notes = "企业标准-添加")
|
@ApiOperation(value = "企业标准-添加", notes = "企业标准-添加")
|
||||||
@PostMapping(value = "/enterprise/add")
|
@PostMapping(value = "/enterprise/add")
|
||||||
public Result<T> addEN(@RequestBody LawsTreeNode lawsTreeNode) {
|
public synchronized Result<T> addEN(@RequestBody LawsTreeNode lawsTreeNode) {
|
||||||
lawsTreeNode.setModuleCode(TableNameEnum.ENTERPRISE_STANDARDS.getValue());
|
lawsTreeNode.setModuleCode(TableNameEnum.ENTERPRISE_STANDARDS.getValue());
|
||||||
lawsTreeNodeService.saveTreeNodeData(lawsTreeNode);
|
lawsTreeNodeService.saveTreeNodeData(lawsTreeNode);
|
||||||
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
||||||
@@ -91,7 +91,7 @@ public class LawsTreeNodeController extends JeroController<LawsTreeNode, ILawsTr
|
|||||||
@AutoLog(value = "国内标准-添加")
|
@AutoLog(value = "国内标准-添加")
|
||||||
@ApiOperation(value = "国内标准-添加", notes = "国内标准-添加")
|
@ApiOperation(value = "国内标准-添加", notes = "国内标准-添加")
|
||||||
@PostMapping(value = "/domestic/add")
|
@PostMapping(value = "/domestic/add")
|
||||||
public Result<T> addGB(@RequestBody LawsTreeNode lawsTreeNode) {
|
public synchronized Result<T> addGB(@RequestBody LawsTreeNode lawsTreeNode) {
|
||||||
lawsTreeNode.setModuleCode(TableNameEnum.DOMESTIC_REGULATIONS.getValue());
|
lawsTreeNode.setModuleCode(TableNameEnum.DOMESTIC_REGULATIONS.getValue());
|
||||||
lawsTreeNodeService.saveTreeNodeData(lawsTreeNode);
|
lawsTreeNodeService.saveTreeNodeData(lawsTreeNode);
|
||||||
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
||||||
@@ -101,7 +101,7 @@ public class LawsTreeNodeController extends JeroController<LawsTreeNode, ILawsTr
|
|||||||
@AutoLog(value = "海外标准-添加")
|
@AutoLog(value = "海外标准-添加")
|
||||||
@ApiOperation(value = "海外标准-添加", notes = "海外标准-添加")
|
@ApiOperation(value = "海外标准-添加", notes = "海外标准-添加")
|
||||||
@PostMapping(value = "/overseas/add")
|
@PostMapping(value = "/overseas/add")
|
||||||
public Result<T> addFB(@RequestBody LawsTreeNode lawsTreeNode) {
|
public synchronized Result<T> addFB(@RequestBody LawsTreeNode lawsTreeNode) {
|
||||||
lawsTreeNode.setModuleCode(TableNameEnum.FOREIGN_REGULATIONS.getValue());
|
lawsTreeNode.setModuleCode(TableNameEnum.FOREIGN_REGULATIONS.getValue());
|
||||||
lawsTreeNodeService.saveTreeNodeData(lawsTreeNode);
|
lawsTreeNodeService.saveTreeNodeData(lawsTreeNode);
|
||||||
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
||||||
|
|||||||
Reference in New Issue
Block a user