Browse Source

feat: 预警流程加上限制

master
buaixuexideshitongxue 2 weeks ago
parent
commit
81975f6c41
  1. 27
      src/main/java/com/biutag/supervision/service/Warning/impl/WarningBusinessServiceImpl.java

27
src/main/java/com/biutag/supervision/service/Warning/impl/WarningBusinessServiceImpl.java

@ -118,6 +118,7 @@ public class WarningBusinessServiceImpl implements WarningBusinessService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void save(WarningSaveRequest request) { public void save(WarningSaveRequest request) {
UserAuth user = UserContextHolder.getCurrentUser(); UserAuth user = UserContextHolder.getCurrentUser();
validateWarningHandler(request.getReportId(), user);
// 更新项目监督信息(由后端自动获取) // 更新项目监督信息(由后端自动获取)
ReportProject project = new ReportProject(); ReportProject project = new ReportProject();
@ -135,6 +136,7 @@ public class WarningBusinessServiceImpl implements WarningBusinessService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void submit(WarningSubmitRequest request) { public void submit(WarningSubmitRequest request) {
UserAuth user = UserContextHolder.getCurrentUser(); UserAuth user = UserContextHolder.getCurrentUser();
validateWarningHandler(request.getReportId(), user);
// 1. 更新项目监督信息(由后端自动获取) // 1. 更新项目监督信息(由后端自动获取)
ReportProject project = new ReportProject(); ReportProject project = new ReportProject();
@ -185,6 +187,7 @@ public class WarningBusinessServiceImpl implements WarningBusinessService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void end(WarningEndRequest request) { public void end(WarningEndRequest request) {
UserAuth user = UserContextHolder.getCurrentUser(); UserAuth user = UserContextHolder.getCurrentUser();
validateWarningHandler(request.getReportId(), user);
// 1. 更新项目状态(由后端自动获取预警监督人和时间) // 1. 更新项目状态(由后端自动获取预警监督人和时间)
ReportProject project = new ReportProject(); ReportProject project = new ReportProject();
@ -594,6 +597,30 @@ public class WarningBusinessServiceImpl implements WarningBusinessService {
return flows.isEmpty() ? null : flows.get(0).getId(); return flows.isEmpty() ? null : flows.get(0).getId();
} }
/**
* 校验当前用户是否为预警待办处理人
* 首次预警没有待处理流程时允许操作存在待处理流程时仅允许对应处理人操作
*/
private void validateWarningHandler(String reportId, UserAuth user) {
List<ReportFlow> pendingFlows = flowMapper.selectList(
new LambdaQueryWrapper<ReportFlow>()
.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 + "处理,请勿重复操作");
}
}
/** /**
* 保存预警内容 * 保存预警内容
*/ */

Loading…
Cancel
Save