Commit 774ff248 by 王志超

feat: 行动项必填项校验

parent 41de0331
Pipeline #86382 failed with stages
in 30 seconds
package com.netease.mail.yanxuan.change.biz.biz;
import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
import com.netease.mail.yanxuan.change.common.util.DateUtils;
import com.netease.mail.yanxuan.change.dal.entity.ChangeExecRecord;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeExecConfigReq;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import java.util.List;
......@@ -49,5 +53,34 @@ public class ChangeExecRecordBiz {
return changeExecRecord;
}).collect(Collectors.toList());
}
/**
* 校验行动项的必填字段
*
* @param changeExecProjectList 行动项列表
*/
public void validateChangeExecProjectRequiredFields(List<ChangeExecConfigReq> changeExecProjectList) {
if (CollectionUtils.isEmpty(changeExecProjectList)) {
return;
}
changeExecProjectList.forEach(c -> {
if (StringUtils.isBlank(c.getChangeExecUser())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更行动人不能为空");
}
if (StringUtils.isBlank(c.getChangeExecUserEmail())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更行动人邮箱不能为空");
}
if (StringUtils.isBlank(c.getChangeRiskDesc())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更风险描述不能为空");
}
if (StringUtils.isBlank(c.getChangeExecProject())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中行动项内容不能为空");
}
if (c.getChangeExecFinishTime() == null || c.getChangeExecFinishTime() <= 0) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更完成时间不能为空");
}
});
}
}
......@@ -257,23 +257,7 @@ public class ChangeFlowBiz {
// 校验变更行动方案中是否有重复的变更行动人
validateDuplicateChangeExecUser(changeExecProject);
// 校验每个行动项的必填字段
changeExecProject.forEach(c -> {
if (StringUtils.isBlank(c.getChangeExecUser())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更行动人不能为空");
}
if (StringUtils.isBlank(c.getChangeExecUserEmail())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更行动人邮箱不能为空");
}
if (StringUtils.isBlank(c.getChangeRiskDesc())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更风险描述不能为空");
}
if (StringUtils.isBlank(c.getChangeExecProject())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中行动项内容不能为空");
}
if (c.getChangeExecFinishTime() == null || c.getChangeExecFinishTime() <= 0) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更完成时间不能为空");
}
});
changeExecRecordBiz.validateChangeExecProjectRequiredFields(changeExecProject);
// 结束时间不可晚于第二天定时任务执行时间
Long tomorrowSpecificTime = DateUtils.getTomorrowSpecificTime("00:00:00");
Assert.isTrue(changeFlowCreateReq.getChangeConfirmResultTime() >= tomorrowSpecificTime, "时间不可晚于下次执行时间");
......@@ -661,6 +645,8 @@ public class ChangeFlowBiz {
}
// 校验变更行动方案中是否有重复的变更行动人
validateDuplicateChangeExecUser(changeExecProjectList);
// 校验每个行动项的必填字段
changeExecRecordBiz.validateChangeExecProjectRequiredFields(changeExecProjectList);
changeRecord.setParentChangeClassId(changeFlowSubmitReq.getParentChangeClassId());
changeRecord.setSonChangeClassId(changeFlowSubmitReq.getSonChangeClassId());
List<String> execDepartmentList = changeExecProjectList.stream().map(ChangeExecConfigReq::getChangeExecDepartment)
......@@ -686,7 +672,7 @@ public class ChangeFlowBiz {
log.debug("[NEW_CHANGE_FLOW_START] delete id:{}, changeExecCount:{}", changeRecord.getId(), changeExecCount);
// 保存变更行动方案记录
List<ChangeExecRecord> changeExecRecords = changeExecRecordBiz.buildChangeExecRecord(changeRecord.getId(),
changeFlowSubmitReq.getChangeExecProjectList(), null, null);
changeExecProjectList, null, null);
changeExecRecords.forEach(exec -> changeFlowExecService.saveRecord(exec));
// 更新附件,覆盖操作,先删除,后插入
Integer fileCount = changeFileService.deleteByChangeRecordId(changeRecord.getId());
......
......@@ -207,22 +207,11 @@ public class ChangeSubFlowBiz {
String.format("行动项的部门+人组合必须与子单记录一致。子单记录:部门[%s],行动人[%s];当前行动项:部门[%s],行动人[%s]",
expectedDepartment, expectedUserEmail, dept, userEmail));
}
// 校验必填字段
if (StringUtils.isBlank(execConfig.getChangeExecUser())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更行动人不能为空");
}
if (StringUtils.isBlank(execConfig.getChangeRiskDesc())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更风险描述不能为空");
}
if (StringUtils.isBlank(execConfig.getChangeExecProject())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中行动项内容不能为空");
}
if (execConfig.getChangeExecFinishTime() == null || execConfig.getChangeExecFinishTime() <= 0) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更完成时间不能为空");
}
});
// 校验所有行动项的必填字段(使用公共方法)
changeExecRecordBiz.validateChangeExecProjectRequiredFields(changeExecProjectList);
// 删除子单下所有行动项
changeFlowExecService.deleteBySubFlowRecordId(subFlowRecord.getId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment