|
|
|
@ -195,9 +195,10 @@ public class DispatchConfigApprovalServiceImpl extends EnBaseServiceImpl<Dispatc |
|
|
|
return R.fail("记录不存在"); |
|
|
|
return R.fail("记录不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 只有审批中状态才能审批(一级或二级)
|
|
|
|
// 只有审批中状态才能审批(一级、二级或三级)
|
|
|
|
if (!DispatchConfigApprovalConst.STATUS_LEVEL1_APPROVING.equals(entity.getStatus()) |
|
|
|
if (!DispatchConfigApprovalConst.STATUS_LEVEL1_APPROVING.equals(entity.getStatus()) |
|
|
|
&& !DispatchConfigApprovalConst.STATUS_LEVEL2_APPROVING.equals(entity.getStatus()) |
|
|
|
&& !DispatchConfigApprovalConst.STATUS_LEVEL2_APPROVING.equals(entity.getStatus()) |
|
|
|
|
|
|
|
&& !DispatchConfigApprovalConst.STATUS_LEVEL3_APPROVING.equals(entity.getStatus()) |
|
|
|
&& !DispatchConfigApprovalConst.STATUS_REJECTED.equals(entity.getStatus())) { |
|
|
|
&& !DispatchConfigApprovalConst.STATUS_REJECTED.equals(entity.getStatus())) { |
|
|
|
return R.fail("只有审批中的记录才能进行审批"); |
|
|
|
return R.fail("只有审批中的记录才能进行审批"); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -221,18 +222,27 @@ public class DispatchConfigApprovalServiceImpl extends EnBaseServiceImpl<Dispatc |
|
|
|
// 根据当前状态判断属于哪个审批节点
|
|
|
|
// 根据当前状态判断属于哪个审批节点
|
|
|
|
Integer currentNode = null; |
|
|
|
Integer currentNode = null; |
|
|
|
String currentNodeName = null; |
|
|
|
String currentNodeName = null; |
|
|
|
|
|
|
|
|
|
|
|
if (DispatchConfigApprovalConst.STATUS_LEVEL1_APPROVING.equals(entity.getStatus())) { |
|
|
|
if (DispatchConfigApprovalConst.STATUS_LEVEL1_APPROVING.equals(entity.getStatus())) { |
|
|
|
currentNode = 1; |
|
|
|
currentNode = 1; |
|
|
|
currentNodeName = "室主任审批"; |
|
|
|
currentNodeName = "室主任审批"; |
|
|
|
} else if (DispatchConfigApprovalConst.STATUS_LEVEL2_APPROVING.equals(entity.getStatus())) { |
|
|
|
} else if (DispatchConfigApprovalConst.STATUS_LEVEL2_APPROVING.equals(entity.getStatus())) { |
|
|
|
currentNode = 2; |
|
|
|
currentNode = 2; |
|
|
|
currentNodeName = "领导审批"; |
|
|
|
currentNodeName = "领导审批"; |
|
|
|
|
|
|
|
} else if (DispatchConfigApprovalConst.STATUS_LEVEL3_APPROVING.equals(entity.getStatus())) { |
|
|
|
|
|
|
|
currentNode = 3; |
|
|
|
|
|
|
|
currentNodeName = "分派配置维护员审批"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 动态查询当前节点的所有审批人
|
|
|
|
// 动态查询当前节点的所有审批人
|
|
|
|
List<DispatchConfigApprovalRecord> currentLevelAuditors = |
|
|
|
List<DispatchConfigApprovalRecord> currentLevelAuditors = null; |
|
|
|
currentNode == 1 ? approvalRecordMapper.selectLevel1Auditors() : approvalRecordMapper.selectLevel2Auditors(); |
|
|
|
if (currentNode == 1) { |
|
|
|
|
|
|
|
currentLevelAuditors = approvalRecordMapper.selectLevel1Auditors(); |
|
|
|
|
|
|
|
} else if (currentNode == 2) { |
|
|
|
|
|
|
|
currentLevelAuditors = approvalRecordMapper.selectLevel2Auditors(); |
|
|
|
|
|
|
|
} else if (currentNode == 3) { |
|
|
|
|
|
|
|
currentLevelAuditors = approvalRecordMapper.selectLevel3Auditors(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(currentLevelAuditors)) { |
|
|
|
if (CollUtil.isEmpty(currentLevelAuditors)) { |
|
|
|
return R.fail("当前节点没有审批人"); |
|
|
|
return R.fail("当前节点没有审批人"); |
|
|
|
@ -247,7 +257,6 @@ public class DispatchConfigApprovalServiceImpl extends EnBaseServiceImpl<Dispatc |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 如果当前用户不是当前节点的审批人
|
|
|
|
|
|
|
|
if (!isAuditor) { |
|
|
|
if (!isAuditor) { |
|
|
|
return R.fail("您不是当前审批节点的审批人"); |
|
|
|
return R.fail("您不是当前审批节点的审批人"); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -255,9 +264,9 @@ public class DispatchConfigApprovalServiceImpl extends EnBaseServiceImpl<Dispatc |
|
|
|
// 检查当前用户是否已经审批过
|
|
|
|
// 检查当前用户是否已经审批过
|
|
|
|
QueryWrapper<DispatchConfigApprovalRecord> recordQuery = new QueryWrapper<>(); |
|
|
|
QueryWrapper<DispatchConfigApprovalRecord> recordQuery = new QueryWrapper<>(); |
|
|
|
recordQuery.eq("APPROVAL_ID", id) |
|
|
|
recordQuery.eq("APPROVAL_ID", id) |
|
|
|
.eq("AUDITOR_ID", currentUserId) |
|
|
|
.eq("AUDITOR_ID", currentUserId) |
|
|
|
.eq("APPROVAL_NODE", currentNode) |
|
|
|
.eq("APPROVAL_NODE", currentNode) |
|
|
|
.eq("IS_DELETED", 0); |
|
|
|
.eq("IS_DELETED", 0); |
|
|
|
DispatchConfigApprovalRecord existingRecord = approvalRecordMapper.selectOne(recordQuery); |
|
|
|
DispatchConfigApprovalRecord existingRecord = approvalRecordMapper.selectOne(recordQuery); |
|
|
|
|
|
|
|
|
|
|
|
if (existingRecord != null) { |
|
|
|
if (existingRecord != null) { |
|
|
|
@ -280,48 +289,56 @@ public class DispatchConfigApprovalServiceImpl extends EnBaseServiceImpl<Dispatc |
|
|
|
newRecord.setUpdateUser(currentUserId); |
|
|
|
newRecord.setUpdateUser(currentUserId); |
|
|
|
approvalRecordMapper.insert(newRecord); |
|
|
|
approvalRecordMapper.insert(newRecord); |
|
|
|
|
|
|
|
|
|
|
|
// 如果审批驳回,直接驳回到发起人,并删除审批记录
|
|
|
|
// 如果审批驳回,直接驳回到发起人
|
|
|
|
if (DispatchConfigApprovalConst.AUDIT_RESULT_REJECT.equals(result)) { |
|
|
|
if (DispatchConfigApprovalConst.AUDIT_RESULT_REJECT.equals(result)) { |
|
|
|
entity.setStatus(DispatchConfigApprovalConst.STATUS_REJECTED); |
|
|
|
entity.setStatus(DispatchConfigApprovalConst.STATUS_REJECTED); |
|
|
|
entity.setUpdateUser(currentUserId); |
|
|
|
entity.setUpdateUser(currentUserId); |
|
|
|
entity.setUpdateTime(now); |
|
|
|
entity.setUpdateTime(now); |
|
|
|
updateById(entity); |
|
|
|
updateById(entity); |
|
|
|
|
|
|
|
|
|
|
|
return R.success("审批已驳回"); |
|
|
|
return R.success("审批已驳回"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 审批通过,检查当前节点是否全部通过
|
|
|
|
// ========== 审批通过逻辑 ==========
|
|
|
|
// 查询当前节点已通过的审批人数
|
|
|
|
|
|
|
|
QueryWrapper<DispatchConfigApprovalRecord> passedQuery = new QueryWrapper<>(); |
|
|
|
if (currentNode == 1 || currentNode == 2) { |
|
|
|
passedQuery.eq("APPROVAL_ID", id) |
|
|
|
// 一级和二级:所有审批人都通过才能进入下一节点(会签)
|
|
|
|
.eq("APPROVAL_NODE", currentNode) |
|
|
|
// 查询当前节点已通过的审批人数
|
|
|
|
.eq("AUDIT_RESULT", DispatchConfigApprovalConst.AUDIT_RESULT_PASS) |
|
|
|
QueryWrapper<DispatchConfigApprovalRecord> passedQuery = new QueryWrapper<>(); |
|
|
|
.eq("IS_DELETED", 0); |
|
|
|
passedQuery.eq("APPROVAL_ID", id) |
|
|
|
List<DispatchConfigApprovalRecord> passedList = approvalRecordMapper.selectList(passedQuery); |
|
|
|
.eq("APPROVAL_NODE", currentNode) |
|
|
|
Set<Long> passedAuditorIds |
|
|
|
.eq("AUDIT_RESULT", DispatchConfigApprovalConst.AUDIT_RESULT_PASS) |
|
|
|
= passedList.stream().map(DispatchConfigApprovalRecord::getAuditorId).collect(Collectors.toSet()); |
|
|
|
.eq("IS_DELETED", 0); |
|
|
|
|
|
|
|
List<DispatchConfigApprovalRecord> passedList = approvalRecordMapper.selectList(passedQuery); |
|
|
|
Set<Long> auditorIds = currentLevelAuditors.stream().map(DispatchConfigApprovalRecord::getAuditorId).collect(Collectors.toSet()); |
|
|
|
Set<Long> passedAuditorIds = passedList.stream() |
|
|
|
|
|
|
|
.map(DispatchConfigApprovalRecord::getAuditorId) |
|
|
|
// 检查当前节点的所有审批人是否都已通过
|
|
|
|
.collect(Collectors.toSet()); |
|
|
|
boolean allPassed = passedAuditorIds.containsAll(auditorIds); |
|
|
|
|
|
|
|
|
|
|
|
Set<Long> auditorIds = currentLevelAuditors.stream() |
|
|
|
if (allPassed) { |
|
|
|
.map(DispatchConfigApprovalRecord::getAuditorId) |
|
|
|
// 当前节点所有人都通过了
|
|
|
|
.collect(Collectors.toSet()); |
|
|
|
if (currentNode == 1) { |
|
|
|
|
|
|
|
// 一级审批全部通过,进入二级审批
|
|
|
|
// 检查当前节点的所有审批人是否都已通过
|
|
|
|
entity.setStatus(DispatchConfigApprovalConst.STATUS_LEVEL2_APPROVING); |
|
|
|
boolean allPassed = passedAuditorIds.containsAll(auditorIds); |
|
|
|
entity.setUpdateUser(currentUserId); |
|
|
|
|
|
|
|
entity.setUpdateTime(now); |
|
|
|
if (allPassed) { |
|
|
|
updateById(entity); |
|
|
|
if (currentNode == 1) { |
|
|
|
|
|
|
|
// 一级审批全部通过,进入二级审批
|
|
|
|
} else if (currentNode == 2) { |
|
|
|
entity.setStatus(DispatchConfigApprovalConst.STATUS_LEVEL2_APPROVING); |
|
|
|
// 二级审批全部通过,审批完成
|
|
|
|
} else if (currentNode == 2) { |
|
|
|
entity.setStatus(DispatchConfigApprovalConst.STATUS_APPROVED); |
|
|
|
// 二级审批全部通过,进入三级审批
|
|
|
|
|
|
|
|
entity.setStatus(DispatchConfigApprovalConst.STATUS_LEVEL3_APPROVING); |
|
|
|
|
|
|
|
} |
|
|
|
entity.setUpdateUser(currentUserId); |
|
|
|
entity.setUpdateUser(currentUserId); |
|
|
|
entity.setUpdateTime(now); |
|
|
|
entity.setUpdateTime(now); |
|
|
|
updateById(entity); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (currentNode == 3) { |
|
|
|
|
|
|
|
// 三级:任意一人审批通过即可完成(或签)
|
|
|
|
|
|
|
|
entity.setStatus(DispatchConfigApprovalConst.STATUS_APPROVED); |
|
|
|
|
|
|
|
entity.setUpdateUser(currentUserId); |
|
|
|
|
|
|
|
entity.setUpdateTime(now); |
|
|
|
|
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return R.success("审批成功"); |
|
|
|
return R.success("审批成功"); |
|
|
|
|