feat: 被代替标准自动废止逻辑需求变更

This commit is contained in:
2024-03-04 09:57:57 +08:00
parent 27e7a7f5d0
commit 8ba58d07b8
3 changed files with 41 additions and 20 deletions
@@ -17,6 +17,7 @@ import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.LoginUser; import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.MessageUtils; import com.jero.common.util.MessageUtils;
import com.jero.common.util.MinioUtil; import com.jero.common.util.MinioUtil;
import com.jero.modules.activiti.process.common.enums.StandardStateEnum;
import com.jero.modules.activiti.process.fb.service.IProcessFbStandardConsultationService; import com.jero.modules.activiti.process.fb.service.IProcessFbStandardConsultationService;
import com.jero.modules.laws.common.constant.FieldCommon; import com.jero.modules.laws.common.constant.FieldCommon;
import com.jero.modules.laws.common.mapper.LawsCommonMapper; import com.jero.modules.laws.common.mapper.LawsCommonMapper;
@@ -667,7 +668,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
parameterMap.put(FieldCommon.STANDARD_SYSTEM, ""); parameterMap.put(FieldCommon.STANDARD_SYSTEM, "");
// 处理新增和编辑时的代替标准、引用标准 // 处理新增和编辑时的代替标准、引用标准
processReplaced(parameterMap, standardNumber); processReplaced(parameterMap, standardNumber, module);
// 获取要操作的表名 // 获取要操作的表名
String tableName = TableNameEnum.getTableName(module); String tableName = TableNameEnum.getTableName(module);
@@ -819,7 +820,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
String standardNumber = singleStandard.getStandardNumber(); String standardNumber = singleStandard.getStandardNumber();
// 处理新增和编辑时的代替标准、引用标准 // 处理新增和编辑时的代替标准、引用标准
processReplaced(parameterMap, standardNumber); processReplaced(parameterMap, standardNumber, module);
// 获取数据库里没修改的数据 // 获取数据库里没修改的数据
Map<String, Object> oldDataMap = getByIdAndModule(id, module, "2", standardNumber); Map<String, Object> oldDataMap = getByIdAndModule(id, module, "2", standardNumber);
@@ -938,14 +939,30 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
* @Date: 2023/9/19 11:53 * @Date: 2023/9/19 11:53
* @Description: 处理新增和编辑时的代替标准、引用标准 * @Description: 处理新增和编辑时的代替标准、引用标准
**/ **/
private void processReplaced(Map<String, Object> parameterMap, String standardNumber) { private void processReplaced(Map<String, Object> parameterMap, String standardNumber, String module) {
// 代替标准 // 代替标准
String replacedStandard = (String) parameterMap.get(FieldCommon.REPLACED_STANDARD); String replacedStandard = (String) parameterMap.get(FieldCommon.REPLACED_STANDARD);
// 获取标准状态
String standardState = (String) parameterMap.get(FieldCommon.STANDARD_STATE);
// 如果标准状态不是现行有效则不处理代替标准
boolean replaceFlag = false;
if (StringUtils.isNotBlank(standardState)) {
// 企标需要自动拼装标准号
if (module.equals(TableNameEnum.ENTERPRISE_STANDARDS.getValue())) {
if (standardState.equals(StandardStateEnum.CURRENTLY_EFFECTIVE.getStateValue())) {
replaceFlag = true;
}
} else {
if (standardState.equals(OutStandardStateEnum.CURRENTLY_EFFECTIVE.getStateValue())) {
replaceFlag = true;
}
}
}
// 先删除已经存储的关联 // 先删除已经存储的关联
lawsReplacedStandardService.removeRelation(standardNumber, 1); lawsReplacedStandardService.removeRelation(standardNumber, 1);
if (StringUtils.isNotBlank(replacedStandard)) { if (StringUtils.isNotBlank(replacedStandard)) {
// 再添加新的关联 // 再添加新的关联
lawsReplacedStandardService.addRelation(replacedStandard, standardNumber, 1); lawsReplacedStandardService.addRelationWithReplaceFlag(replacedStandard, standardNumber, 1, replaceFlag);
/*parameterMap.put(FieldCommon.REPLACED_STANDARD, ""); /*parameterMap.put(FieldCommon.REPLACED_STANDARD, "");
parameterMap.put(FieldCommon.REPLACED_BY_STANDARD, "");*/ parameterMap.put(FieldCommon.REPLACED_BY_STANDARD, "");*/
} }
@@ -955,7 +972,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
lawsReplacedStandardService.removeRelation(standardNumber, 2); lawsReplacedStandardService.removeRelation(standardNumber, 2);
if (StringUtils.isNotBlank(referenceStandard)) { if (StringUtils.isNotBlank(referenceStandard)) {
// 再添加新的关联 // 再添加新的关联
lawsReplacedStandardService.addRelation(referenceStandard, standardNumber, 2); lawsReplacedStandardService.addRelationWithReplaceFlag(referenceStandard, standardNumber, 2, replaceFlag);
/*parameterMap.put(FieldCommon.REFERENCE_STANDARD, ""); /*parameterMap.put(FieldCommon.REFERENCE_STANDARD, "");
parameterMap.put(FieldCommon.REFERENCED_STANDARD, "");*/ parameterMap.put(FieldCommon.REFERENCED_STANDARD, "");*/
} }
@@ -18,6 +18,13 @@ public interface ILawsReplacedStandardService extends IService<LawsReplacedStand
**/ **/
void addRelation(String replaced, String replacedBy, Integer type); void addRelation(String replaced, String replacedBy, Integer type);
/**
* @Author: caihaohan
* @Date: 2024/3/4 9:45
* @Description: 添加代替标准关联(通过标识控制是否更改标准状态为废止)
**/
void addRelationWithReplaceFlag(String replaced, String replacedBy, Integer type, boolean replaceFlag);
/** /**
* @Author: liao * @Author: liao
* @Date: 2023/9/19 11:03 * @Date: 2023/9/19 11:03
@@ -43,6 +43,16 @@ public class LawsReplacedStandardServiceImpl extends ServiceImpl<LawsReplacedSta
**/ **/
@Override @Override
public void addRelation(String replaced, String replacedBy, Integer type) { public void addRelation(String replaced, String replacedBy, Integer type) {
this.addRelationWithReplaceFlag(replaced, replacedBy, type, true);
}
/**
* @Author: liao
* @Date: 2023/9/19 11:06
* @Description: 添加代替标准关联
**/
@Override
public void addRelationWithReplaceFlag(String replaced, String replacedBy, Integer type, boolean replaceFlag) {
// 如果代替的标准为空 // 如果代替的标准为空
if (StringUtils.isBlank(replaced)) { if (StringUtils.isBlank(replaced)) {
return; return;
@@ -59,7 +69,7 @@ public class LawsReplacedStandardServiceImpl extends ServiceImpl<LawsReplacedSta
}); });
saveBatch(replacedStandardList); saveBatch(replacedStandardList);
if (1 == type) { if (1 == type && replaceFlag) {
// 代替的标准号变成废止状态 // 代替的标准号变成废止状态
lawsCommonService.updateToAbolish(replacedList); lawsCommonService.updateToAbolish(replacedList);
} }
@@ -68,20 +78,7 @@ public class LawsReplacedStandardServiceImpl extends ServiceImpl<LawsReplacedSta
@Override @Override
public void addRelationOldSystemSync(String replaced, String replacedBy, Integer type) { public void addRelationOldSystemSync(String replaced, String replacedBy, Integer type) {
// 如果代替的标准为空 // 如果代替的标准为空
if (StringUtils.isBlank(replaced)) { this.addRelationWithReplaceFlag(replaced, replacedBy, type, false);
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);
} }
/** /**