add 代替标准号、被代替标准号
This commit is contained in:
@@ -187,4 +187,15 @@ CREATE TABLE `laws_update_record`
|
||||
alter table laws_update_record
|
||||
comment '更新记录';
|
||||
|
||||
DROP TABLE IF EXISTS `laws_replaced_standard`;
|
||||
CREATE TABLE `laws_replaced_standard`
|
||||
(
|
||||
`id` varchar(36) NOT NULL PRIMARY KEY COMMENT '主键ID',
|
||||
`replaced` varchar(50) COMMENT '代替标准',
|
||||
`replaced_by` varchar(50) COMMENT '被代替标准',
|
||||
`type` int(1) COMMENT '类型(1-代替、2-引用)'
|
||||
) COMMENT = '代替标准';
|
||||
alter table laws_replaced_standard
|
||||
comment '代替标准';
|
||||
|
||||
|
||||
|
||||
@@ -60,12 +60,20 @@ public class FieldCommon {
|
||||
public static final String STANDARD_SYSTEM = "standard_system";
|
||||
// 标准类别
|
||||
public static final String STANDARD_CLASS = "standard_class";
|
||||
|
||||
// 代替标准号
|
||||
public static final String REPLACED_STANDARD = "substitute_standard_number";
|
||||
// 被代替标准号
|
||||
public static final String REPLACED_BY_STANDARD = "replaced_by_standard_number";
|
||||
// 引用标准
|
||||
public static final String REFERENCE_STANDARD = "reference_standard";
|
||||
// 被引用标准
|
||||
public static final String REFERENCED_STANDARD = "referenced_standard";
|
||||
|
||||
// 字典值统一后缀
|
||||
public static final String _DICT_TEXT = "_dictText";
|
||||
// 树节点编码
|
||||
public static final String NODE_CODE = "nodeCode";
|
||||
// 分隔符
|
||||
public static final String SEPARATOR = ",";
|
||||
// 中文双引号
|
||||
public static final String QUOTE = "“";
|
||||
|
||||
|
||||
+76
-12
@@ -16,6 +16,7 @@ import com.jero.modules.laws.common.vo.ManyStandardSelectionBox;
|
||||
import com.jero.modules.laws.common.vo.ManyStandardSelectionBoxVO;
|
||||
import com.jero.modules.laws.standard.entity.LawsNodeRelation;
|
||||
import com.jero.modules.laws.standard.service.ILawsNodeRelationService;
|
||||
import com.jero.modules.laws.standard.service.ILawsReplacedStandardService;
|
||||
import com.jero.modules.laws.standard.service.ILawsUpdateRecordService;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
@@ -70,6 +71,8 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
private ISysDictItemService sysDictItemService;
|
||||
@Autowired
|
||||
private ILawsNodeRelationService lawsNodeRelationService;
|
||||
@Autowired
|
||||
private ILawsReplacedStandardService lawsReplacedStandardService;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
@@ -152,6 +155,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
List<SysDictItem> dictItemList = getDictItemList(fieldList);
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
String id = (String) initMap.get("id");
|
||||
String standardNumber = (String) initMap.get(FieldCommon.STANDARD_NUMBER);
|
||||
for (Map.Entry<String, Object> entryMap : initMap.entrySet()) {
|
||||
String key = entryMap.getKey();
|
||||
String value = "";
|
||||
@@ -165,22 +169,47 @@ 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, ","));
|
||||
}
|
||||
}
|
||||
processSpecificFieldValue(resultMap, key, id, standardNumber);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 13:43
|
||||
* @Description: 查询返回特殊值处理
|
||||
**/
|
||||
private void processSpecificFieldValue(Map<String, Object> resultMap, String key,
|
||||
String id, String standardNumber) {
|
||||
// 如果是标准体系(单独处理)
|
||||
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, ","));
|
||||
}
|
||||
}
|
||||
// 如果是代替标准(单独处理)
|
||||
if (FieldCommon.REPLACED_STANDARD.equals(key)) {
|
||||
resultMap.put(key, lawsReplacedStandardService.getReplaced(standardNumber, 1));
|
||||
}
|
||||
// 如果是被代替标准(单独处理)
|
||||
if (FieldCommon.REPLACED_BY_STANDARD.equals(key)) {
|
||||
resultMap.put(key, lawsReplacedStandardService.getReplacedBy(standardNumber, 1));
|
||||
}
|
||||
// 如果是引用标准(单独处理)
|
||||
if (FieldCommon.REFERENCE_STANDARD.equals(key)) {
|
||||
resultMap.put(key, lawsReplacedStandardService.getReplaced(standardNumber, 2));
|
||||
}
|
||||
// 如果是被引用标准(单独处理)
|
||||
if (FieldCommon.REFERENCED_STANDARD.equals(key)) {
|
||||
resultMap.put(key, lawsReplacedStandardService.getReplacedBy(standardNumber, 2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -327,6 +356,9 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
// 将更新数据库的标准体系字段设置为空
|
||||
parameterMap.put(FieldCommon.STANDARD_SYSTEM, "");
|
||||
|
||||
// 处理新增和编辑时的代替标准、引用标准
|
||||
processReplaced(parameterMap, standardNumber);
|
||||
|
||||
// 获取操作模块
|
||||
String module = (String) parameterMap.get(FieldCommon.MODULE);
|
||||
|
||||
@@ -397,6 +429,10 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
}
|
||||
// 将更新数据库的标准体系字段设置为空
|
||||
parameterMap.put(FieldCommon.STANDARD_SYSTEM, "");
|
||||
|
||||
// 处理新增和编辑时的代替标准、引用标准
|
||||
processReplaced(parameterMap, standardNumber);
|
||||
|
||||
// 获取操作模块
|
||||
String module = parameterMap.get(FieldCommon.MODULE).toString();
|
||||
parameterMap.remove(FieldCommon.MODULE);
|
||||
@@ -458,6 +494,34 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
return MessageUtils.getMessage(ResultCommon.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 11:53
|
||||
* @Description: 处理新增和编辑时的代替标准、引用标准
|
||||
**/
|
||||
private void processReplaced(Map<String, Object> parameterMap, String standardNumber) {
|
||||
// 代替标准
|
||||
String replacedStandard = (String) parameterMap.get(FieldCommon.REPLACED_STANDARD);
|
||||
// 先删除已经存储的关联
|
||||
lawsReplacedStandardService.removeRelation(standardNumber, 1);
|
||||
if (StringUtils.isNotBlank(replacedStandard)) {
|
||||
// 再添加新的关联
|
||||
lawsReplacedStandardService.addRelation(replacedStandard, standardNumber, 1);
|
||||
parameterMap.put(FieldCommon.REPLACED_STANDARD, "");
|
||||
parameterMap.put(FieldCommon.REPLACED_BY_STANDARD, "");
|
||||
}
|
||||
// 引用标准
|
||||
String referenceStandard = (String) parameterMap.get(FieldCommon.REFERENCE_STANDARD);
|
||||
// 先删除已经存储的关联
|
||||
lawsReplacedStandardService.removeRelation(standardNumber, 2);
|
||||
if (StringUtils.isNotBlank(referenceStandard)) {
|
||||
// 再添加新的关联
|
||||
lawsReplacedStandardService.addRelation(referenceStandard, standardNumber, 2);
|
||||
parameterMap.put(FieldCommon.REFERENCE_STANDARD, "");
|
||||
parameterMap.put(FieldCommon.REFERENCED_STANDARD, "");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/12 15:40
|
||||
|
||||
-3
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.MessageUtils;
|
||||
import com.jero.modules.laws.common.constant.FieldCommon;
|
||||
import com.jero.modules.laws.common.constant.ResultCommon;
|
||||
@@ -18,13 +17,11 @@ import com.jero.modules.tag.entity.LawsTag;
|
||||
import com.jero.modules.tag.enums.TableNameEnum;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.jero.modules.laws.standard.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 代替标准
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-09-19
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("laws_replaced_standard")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="laws_replaced_standard对象", description="代替标准")
|
||||
public class LawsReplacedStandard implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键ID*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
private java.lang.String id;
|
||||
/**代替标准*/
|
||||
@Excel(name = "代替标准", width = 15)
|
||||
@ApiModelProperty(value = "代替标准")
|
||||
private java.lang.String replaced;
|
||||
/**被代替标准*/
|
||||
@Excel(name = "被代替标准", width = 15)
|
||||
@ApiModelProperty(value = "被代替标准")
|
||||
private java.lang.String replacedBy;
|
||||
/**类型(1-代替、2-引用)*/
|
||||
@Excel(name = "类型(1-代替、2-引用)", width = 15)
|
||||
@ApiModelProperty(value = "类型(1-代替、2-引用)")
|
||||
private java.lang.Integer type;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.jero.modules.laws.standard.mapper;
|
||||
|
||||
import com.jero.modules.laws.standard.entity.LawsReplacedStandard;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 代替标准
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-09-19
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface LawsReplacedStandardMapper extends BaseMapper<LawsReplacedStandard> {
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?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.jero.modules.laws.standard.mapper.LawsReplacedStandardMapper">
|
||||
<resultMap id="LawsReplacedStandardResultMap" type="com.jero.modules.laws.standard.entity.LawsReplacedStandard">
|
||||
<id column="id" property="id" />
|
||||
<result column="replaced" property="replaced" />
|
||||
<result column="replaced_by" property="replacedBy" />
|
||||
<result column="type" property="type" />
|
||||
</resultMap>
|
||||
</mapper>
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.jero.modules.laws.standard.service;
|
||||
|
||||
import com.jero.modules.laws.standard.entity.LawsReplacedStandard;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 代替标准
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-09-19
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ILawsReplacedStandardService extends IService<LawsReplacedStandard> {
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 11:03
|
||||
* @Description: 添加代替标准关联
|
||||
**/
|
||||
void addRelation(String replaced, String replacedBy, Integer type);
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 11:07
|
||||
* @Description: 删除代替标准关联
|
||||
**/
|
||||
void removeRelation(String replacedBy, Integer type);
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 11:31
|
||||
* @Description: 获取代替标准
|
||||
**/
|
||||
String getReplaced(String standardNumber, Integer type);
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 11:31
|
||||
* @Description: 获取被代替标准
|
||||
**/
|
||||
String getReplacedBy(String standardNumber, Integer type);
|
||||
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package com.jero.modules.laws.standard.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.modules.laws.standard.entity.LawsReplacedStandard;
|
||||
import com.jero.modules.laws.standard.mapper.LawsReplacedStandardMapper;
|
||||
import com.jero.modules.laws.standard.service.ILawsReplacedStandardService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 代替标准
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-09-19
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = JeroBootException.class)
|
||||
public class LawsReplacedStandardServiceImpl extends ServiceImpl<LawsReplacedStandardMapper, LawsReplacedStandard> implements ILawsReplacedStandardService {
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 11:06
|
||||
* @Description: 添加代替标准关联
|
||||
**/
|
||||
@Override
|
||||
public void addRelation(String replaced, String replacedBy, Integer type) {
|
||||
// 如果代替的标准为空
|
||||
if (StringUtils.isBlank(replaced)) {
|
||||
return;
|
||||
}
|
||||
// 添加新的关联
|
||||
List<String> replacedList = Arrays.asList(replaced.split(","));
|
||||
List<LawsReplacedStandard> replacedStandardList = new ArrayList<>();
|
||||
replacedList.forEach(e -> {
|
||||
LawsReplacedStandard replacedStandard = new LawsReplacedStandard();
|
||||
replacedStandard.setReplaced(e);
|
||||
replacedStandard.setReplacedBy(replacedBy);
|
||||
replacedStandard.setType(type);
|
||||
replacedStandardList.add(replacedStandard);
|
||||
});
|
||||
saveBatch(replacedStandardList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 11:08
|
||||
* @Description: 删除代替标准关联
|
||||
**/
|
||||
@Override
|
||||
public void removeRelation(String replacedBy, Integer type) {
|
||||
LambdaQueryWrapper<LawsReplacedStandard> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(LawsReplacedStandard::getReplacedBy, replacedBy);
|
||||
queryWrapper.eq(LawsReplacedStandard::getType, type);
|
||||
remove(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 11:32
|
||||
* @Description: 获取代替标准
|
||||
**/
|
||||
@Override
|
||||
public String getReplaced(String standardNumber, Integer type) {
|
||||
LambdaQueryWrapper<LawsReplacedStandard> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(LawsReplacedStandard::getReplacedBy, standardNumber);
|
||||
queryWrapper.eq(LawsReplacedStandard::getType, type);
|
||||
List<LawsReplacedStandard> replacedStandardList = list(queryWrapper);
|
||||
if (CollectionUtils.isEmpty(replacedStandardList)) {
|
||||
return "";
|
||||
}
|
||||
List<String> replacedList = replacedStandardList.stream()
|
||||
.map(LawsReplacedStandard::getReplaced).collect(Collectors.toList());
|
||||
return StringUtils.join(replacedList, ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/19 11:32
|
||||
* @Description: 获取被代替标准
|
||||
**/
|
||||
@Override
|
||||
public String getReplacedBy(String standardNumber, Integer type) {
|
||||
LambdaQueryWrapper<LawsReplacedStandard> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(LawsReplacedStandard::getReplaced, standardNumber);
|
||||
queryWrapper.eq(LawsReplacedStandard::getType, type);
|
||||
List<LawsReplacedStandard> replacedStandardList = list(queryWrapper);
|
||||
if (CollectionUtils.isEmpty(replacedStandardList)) {
|
||||
return "";
|
||||
}
|
||||
List<String> replacedByList = replacedStandardList.stream()
|
||||
.map(LawsReplacedStandard::getReplacedBy).collect(Collectors.toList());
|
||||
return StringUtils.join(replacedByList, ",");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user