소스 검색

校验撤回时间

caixiaofeng 1 년 전
부모
커밋
0077eb258e
1개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  1. 10 0
      flow-workflow/flow-workflow-biz/src/main/java/com/flow/service/impl/FlowInstanceServiceImpl.java

+ 10 - 0
flow-workflow/flow-workflow-biz/src/main/java/com/flow/service/impl/FlowInstanceServiceImpl.java

@@ -112,6 +112,16 @@ public class FlowInstanceServiceImpl extends BaseServiceImpl<FlowInstanceDao, Fl
     @Override
     public void cancel(List<String> instanceIds) {
         for (String instanceId : instanceIds) {
+            FlowInstance instance = this.getInstance(instanceId);
+            if (instance.getStatus() != ProcessStatus.RUNNING) {
+                throw new BaseException("流程已结束,不能撤回");
+            }
+            Integer cancelDays = instance.getCancelDays();
+            LocalDateTime startTime = instance.getStartTime();
+            startTime.plusDays(cancelDays);
+            if (LocalDateTime.now().isAfter(startTime)) {
+                throw new BaseException("流程撤回时间已过");
+            }
             taskService.createTaskQuery().processInstanceId(instanceId).list().forEach(task -> {
                 flowTaskService.updateStatus(task.getId(), ProcessStatus.CANCELED);
             });