mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-17 09:14:39 +08:00
update 优化 删除流程实例同时删除抄送内容
This commit is contained in:
parent
e49f02f89e
commit
c29ecbd847
@ -195,7 +195,10 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
|||||||
}
|
}
|
||||||
// 发送事件
|
// 发送事件
|
||||||
processDeleteHandler(flowInstances);
|
processDeleteHandler(flowInstances);
|
||||||
return insService.remove(StreamUtils.toList(flowInstances, FlowInstance::getId));
|
List<Long> instanceIds = StreamUtils.toList(flowInstances, FlowInstance::getId);
|
||||||
|
// 删除抄送任务关联的用户记录
|
||||||
|
deleteCopyTaskUsers(instanceIds);
|
||||||
|
return insService.remove(instanceIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -214,8 +217,11 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
|||||||
}
|
}
|
||||||
// 发送事件
|
// 发送事件
|
||||||
processDeleteHandler(flowInstances);
|
processDeleteHandler(flowInstances);
|
||||||
|
List<Long> validInstanceIds = StreamUtils.toList(flowInstances, FlowInstance::getId);
|
||||||
|
// 删除抄送任务关联的用户记录
|
||||||
|
deleteCopyTaskUsers(validInstanceIds);
|
||||||
// 删除实例
|
// 删除实例
|
||||||
return insService.remove(instanceIds);
|
return insService.remove(validInstanceIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -234,16 +240,56 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
|||||||
}
|
}
|
||||||
// 发送事件
|
// 发送事件
|
||||||
processDeleteHandler(flowInstances);
|
processDeleteHandler(flowInstances);
|
||||||
List<FlowTask> flowTaskList = flwTaskService.selectByInstIds(instanceIds);
|
List<Long> validInstanceIds = StreamUtils.toList(flowInstances, FlowInstance::getId);
|
||||||
if (CollUtil.isNotEmpty(flowTaskList)) {
|
List<FlowTask> flowTaskList = flwTaskService.selectByInstIds(validInstanceIds);
|
||||||
FlowEngine.userService().deleteByTaskIds(StreamUtils.toList(flowTaskList, FlowTask::getId));
|
List<Long> taskIds = new ArrayList<>(StreamUtils.toList(flowTaskList, FlowTask::getId));
|
||||||
}
|
taskIds.addAll(selectCopyTaskIds(validInstanceIds));
|
||||||
FlowEngine.taskService().deleteByInsIds(instanceIds);
|
deleteTaskUsers(taskIds);
|
||||||
FlowEngine.hisTaskService().deleteByInsIds(instanceIds);
|
FlowEngine.taskService().deleteByInsIds(validInstanceIds);
|
||||||
FlowEngine.insService().removeByIds(instanceIds);
|
FlowEngine.hisTaskService().deleteByInsIds(validInstanceIds);
|
||||||
|
FlowEngine.insService().removeByIds(validInstanceIds);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询流程实例下的抄送任务id
|
||||||
|
*
|
||||||
|
* @param instanceIds 流程实例id
|
||||||
|
* @return 抄送任务id
|
||||||
|
*/
|
||||||
|
private List<Long> selectCopyTaskIds(List<Long> instanceIds) {
|
||||||
|
if (CollUtil.isEmpty(instanceIds)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<FlowHisTask> copyTaskList = flowHisTaskMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<>(FlowHisTask.class)
|
||||||
|
.select(FlowHisTask::getTaskId)
|
||||||
|
.eq(FlowHisTask::getFlowStatus, TaskStatusEnum.COPY.getStatus())
|
||||||
|
.in(FlowHisTask::getInstanceId, instanceIds)
|
||||||
|
);
|
||||||
|
return StreamUtils.toList(copyTaskList, FlowHisTask::getTaskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除抄送任务关联的用户记录
|
||||||
|
*
|
||||||
|
* @param instanceIds 流程实例id
|
||||||
|
*/
|
||||||
|
private void deleteCopyTaskUsers(List<Long> instanceIds) {
|
||||||
|
deleteTaskUsers(selectCopyTaskIds(instanceIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务关联的用户记录
|
||||||
|
*
|
||||||
|
* @param taskIds 任务id
|
||||||
|
*/
|
||||||
|
private void deleteTaskUsers(List<Long> taskIds) {
|
||||||
|
if (CollUtil.isNotEmpty(taskIds)) {
|
||||||
|
FlowEngine.userService().deleteByTaskIds(taskIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void processDeleteHandler(List<FlowInstance> flowInstances) {
|
private void processDeleteHandler(List<FlowInstance> flowInstances) {
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user