diff --git a/src/main/java/com/biutag/supervision/service/Warning/impl/WarningBusinessServiceImpl.java b/src/main/java/com/biutag/supervision/service/Warning/impl/WarningBusinessServiceImpl.java index e9124af..103acd6 100644 --- a/src/main/java/com/biutag/supervision/service/Warning/impl/WarningBusinessServiceImpl.java +++ b/src/main/java/com/biutag/supervision/service/Warning/impl/WarningBusinessServiceImpl.java @@ -118,6 +118,7 @@ public class WarningBusinessServiceImpl implements WarningBusinessService { @Transactional(rollbackFor = Exception.class) public void save(WarningSaveRequest request) { UserAuth user = UserContextHolder.getCurrentUser(); + validateWarningHandler(request.getReportId(), user); // 更新项目监督信息(由后端自动获取) ReportProject project = new ReportProject(); @@ -135,6 +136,7 @@ public class WarningBusinessServiceImpl implements WarningBusinessService { @Transactional(rollbackFor = Exception.class) public void submit(WarningSubmitRequest request) { UserAuth user = UserContextHolder.getCurrentUser(); + validateWarningHandler(request.getReportId(), user); // 1. 更新项目监督信息(由后端自动获取) ReportProject project = new ReportProject(); @@ -185,6 +187,7 @@ public class WarningBusinessServiceImpl implements WarningBusinessService { @Transactional(rollbackFor = Exception.class) public void end(WarningEndRequest request) { UserAuth user = UserContextHolder.getCurrentUser(); + validateWarningHandler(request.getReportId(), user); // 1. 更新项目状态(由后端自动获取预警监督人和时间) ReportProject project = new ReportProject(); @@ -594,6 +597,30 @@ public class WarningBusinessServiceImpl implements WarningBusinessService { return flows.isEmpty() ? null : flows.get(0).getId(); } + /** + * 校验当前用户是否为预警待办处理人。 + * 首次预警没有待处理流程时允许操作;存在待处理流程时,仅允许对应处理人操作。 + */ + private void validateWarningHandler(String reportId, UserAuth user) { + List pendingFlows = flowMapper.selectList( + new LambdaQueryWrapper() + .eq(ReportFlow::getReportId, reportId) + .eq(ReportFlow::getType, "warning") + .eq(ReportFlow::getApproverState, FlowStateEnum.Start.getLabel()) + .orderByDesc(ReportFlow::getAreportTime) + .last("LIMIT 1") + ); + if (pendingFlows.isEmpty()) { + return; + } + + ReportFlow pendingFlow = pendingFlows.get(0); + if (!StrUtil.equals(user.getUserName(), pendingFlow.getApproverId())) { + String handler = StrUtil.isBlank(pendingFlow.getApprover()) ? "其他人员" : pendingFlow.getApprover(); + throw new RuntimeException("该项目当前由" + handler + "处理,请勿重复操作"); + } + } + /** * 保存预警内容 */