فهرست منبع

校验撤回时间

caixiaofeng 11 ماه پیش
والد
کامیت
0077eb258e

+ 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);
             });