update 标准法规-标准体系
This commit is contained in:
+26
@@ -151,6 +151,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
private Map<String, Object> processResultMap(Map<String, Object> initMap, List<LawsTag> fieldList) {
|
||||
List<SysDictItem> dictItemList = getDictItemList(fieldList);
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
String id = (String) initMap.get("id");
|
||||
for (Map.Entry<String, Object> entryMap : initMap.entrySet()) {
|
||||
String key = entryMap.getKey();
|
||||
String value = "";
|
||||
@@ -164,6 +165,18 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
// 对返回的字段值做处理
|
||||
processResultFieldValue(key, value, fieldList, resultMap, dictItemList);
|
||||
}
|
||||
// 如果是标准体系(单独处理)
|
||||
if (FieldCommon.STANDARD_SYSTEM.equals(key)) {
|
||||
List<LawsNodeRelation> nodeRelationList = lawsNodeRelationService.getListByStandardId(id);
|
||||
if (CollectionUtils.isNotEmpty(nodeRelationList)) {
|
||||
List<String> nodeIdList = nodeRelationList.stream()
|
||||
.map(LawsNodeRelation::getNodeId).collect(Collectors.toList());
|
||||
List<String> nodeNameList = nodeRelationList.stream()
|
||||
.map(LawsNodeRelation::getNodeName).collect(Collectors.toList());
|
||||
resultMap.put(key, StringUtils.join(nodeIdList, ","));
|
||||
resultMap.put(key + FieldCommon._DICT_TEXT, StringUtils.join(nodeNameList, ","));
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
@@ -363,6 +376,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
* @Description: 编辑数据
|
||||
**/
|
||||
@Override
|
||||
@Transactional
|
||||
public String commonEdit(Map<String, Object> parameterMap) {
|
||||
// 法规编号不能为空
|
||||
String standardNumber = (String) parameterMap.get(FieldCommon.STANDARD_NUMBER);
|
||||
@@ -374,6 +388,13 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
if (StringUtils.isBlank(standardName)) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_STANDARD_NAME, "");
|
||||
}
|
||||
// 标准体系不能为空
|
||||
String standardSystem = (String) parameterMap.get(FieldCommon.STANDARD_SYSTEM);
|
||||
if (StringUtils.isBlank(standardSystem)) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, FieldCommon.STANDARD_SYSTEM);
|
||||
}
|
||||
// 将更新数据库的标准体系字段设置为空
|
||||
parameterMap.put(FieldCommon.STANDARD_SYSTEM, "");
|
||||
// 获取操作模块
|
||||
String module = parameterMap.get(FieldCommon.MODULE).toString();
|
||||
parameterMap.remove(FieldCommon.MODULE);
|
||||
@@ -427,6 +448,11 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
if (!oldStr.equals(content)) {
|
||||
lawsUpdateRecordService.addRecord(standardNumber, content);
|
||||
}
|
||||
|
||||
// 对标准体系做处理
|
||||
lawsNodeRelationService.removeByStandardId(id);
|
||||
lawsNodeRelationService.addRelation(standardSystem, standardNumber);
|
||||
|
||||
return MessageUtils.getMessage(ResultCommon.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
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;
|
||||
@@ -54,4 +55,8 @@ public class LawsNodeRelation implements Serializable {
|
||||
@Excel(name = "所属模块编码", width = 15)
|
||||
@ApiModelProperty(value = "所属模块编码(1国标、2外标、3企标)")
|
||||
private java.lang.String moduleCode;
|
||||
|
||||
@ApiModelProperty(value = "节点name")
|
||||
@TableField(exist = false)
|
||||
private java.lang.String nodeName;
|
||||
}
|
||||
|
||||
+16
@@ -3,6 +3,8 @@ package com.jero.modules.laws.standard.service;
|
||||
import com.jero.modules.laws.standard.entity.LawsNodeRelation;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 树型节点关联
|
||||
* @Author: jero-boot
|
||||
@@ -32,4 +34,18 @@ public interface ILawsNodeRelationService extends IService<LawsNodeRelation> {
|
||||
**/
|
||||
void addRelation(String nodeIds, String standardNumber);
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 9:20
|
||||
* @Description: 根据标准id进行删除
|
||||
**/
|
||||
void removeByStandardId(String standardId);
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 9:32
|
||||
* @Description: 根据标准id查询列表
|
||||
**/
|
||||
List<LawsNodeRelation> getListByStandardId(String standardId);
|
||||
|
||||
}
|
||||
|
||||
+58
-2
@@ -9,6 +9,7 @@ import com.jero.modules.laws.standard.mapper.LawsNodeRelationMapper;
|
||||
import com.jero.modules.laws.standard.service.ILawsNodeRelationService;
|
||||
import com.jero.modules.laws.standard.service.ILawsTreeNodeService;
|
||||
import com.spire.ms.System.Collections.ArrayList;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -17,6 +18,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -50,7 +52,7 @@ public class LawsNodeRelationServiceImpl extends ServiceImpl<LawsNodeRelationMap
|
||||
// 根据nodeCode查询nodeId
|
||||
LambdaQueryWrapper<LawsTreeNode> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(LawsTreeNode::getNodeCode, nodeCode);
|
||||
LawsTreeNode treeNode = lawsTreeNodeService.getOne(queryWrapper);
|
||||
String nodeId = lawsTreeNodeService.getOne(queryWrapper).getId();
|
||||
|
||||
|
||||
// 批量添加到数据库
|
||||
@@ -58,7 +60,7 @@ public class LawsNodeRelationServiceImpl extends ServiceImpl<LawsNodeRelationMap
|
||||
idList.forEach(id -> {
|
||||
LawsNodeRelation relation = new LawsNodeRelation();
|
||||
relation.setNodeCode(nodeCode);
|
||||
relation.setNodeId(treeNode.getId());
|
||||
relation.setNodeId(nodeId);
|
||||
relation.setUniqueRelationFlag(id);
|
||||
relationList.add(relation);
|
||||
});
|
||||
@@ -91,7 +93,61 @@ public class LawsNodeRelationServiceImpl extends ServiceImpl<LawsNodeRelationMap
|
||||
String standardId = singleStandard.getId();
|
||||
|
||||
List<String> nodeIdList = Arrays.asList(nodeIds.split(","));
|
||||
// 根据nodeId查询nodeCode
|
||||
LambdaQueryWrapper<LawsTreeNode> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(LawsTreeNode::getId, nodeIdList);
|
||||
List<LawsTreeNode> treeNodeList = lawsTreeNodeService.list(queryWrapper);
|
||||
// 批量添加到数据库
|
||||
List<LawsNodeRelation> relationList = new ArrayList();
|
||||
nodeIdList.forEach(nodeId -> {
|
||||
LawsNodeRelation relation = new LawsNodeRelation();
|
||||
String nodeCode = treeNodeList.stream().filter(treeNode -> nodeId.equals(treeNode.getId()))
|
||||
.map(LawsTreeNode::getNodeCode).collect(Collectors.toList()).get(0);
|
||||
relation.setNodeCode(nodeCode);
|
||||
relation.setNodeId(nodeId);
|
||||
relation.setUniqueRelationFlag(standardId);
|
||||
relationList.add(relation);
|
||||
});
|
||||
saveBatch(relationList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 9:21
|
||||
* @Description: 根据标准id进行删除
|
||||
**/
|
||||
@Override
|
||||
public void removeByStandardId(String standardId) {
|
||||
LambdaQueryWrapper<LawsNodeRelation> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(LawsNodeRelation::getUniqueRelationFlag, standardId);
|
||||
remove(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 9:33
|
||||
* @Description: 根据标准id查询列表
|
||||
**/
|
||||
@Override
|
||||
public List<LawsNodeRelation> getListByStandardId(String standardId) {
|
||||
LambdaQueryWrapper<LawsNodeRelation> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(LawsNodeRelation::getUniqueRelationFlag, standardId);
|
||||
List<LawsNodeRelation> nodeRelationList = list(queryWrapper);
|
||||
if (CollectionUtils.isEmpty(nodeRelationList)) {
|
||||
return null;
|
||||
}
|
||||
List<String> nodeIdList = nodeRelationList.stream()
|
||||
.map(LawsNodeRelation::getNodeId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<LawsTreeNode> treeQueryWrapper = new LambdaQueryWrapper<>();
|
||||
treeQueryWrapper.in(LawsTreeNode::getId, nodeIdList);
|
||||
List<LawsTreeNode> treeNodeList = lawsTreeNodeService.list(treeQueryWrapper);
|
||||
nodeRelationList.forEach(nodeRelation -> {
|
||||
String nodeName = treeNodeList.stream().filter(treeNode ->
|
||||
nodeRelation.getNodeId().equals(treeNode.getId()))
|
||||
.collect(Collectors.toList()).get(0).getNodeName();
|
||||
nodeRelation.setNodeName(nodeName);
|
||||
});
|
||||
return nodeRelationList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user