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