|
|
@@ -338,6 +338,7 @@ public class TaskPlanService implements TaskPlanServiceInterface {
|
|
|
/**
|
|
|
* 取消计划
|
|
|
*/
|
|
|
+ @Transactional
|
|
|
public boolean cancelPlan(Long id) {
|
|
|
TaskPlanInstance instance = instanceMapper.selectById(id);
|
|
|
if (instance == null || !"active".equals(instance.getStatus())) {
|
|
|
@@ -345,7 +346,23 @@ public class TaskPlanService implements TaskPlanServiceInterface {
|
|
|
}
|
|
|
instance.setStatus("cancelled");
|
|
|
instance.setUpdatedAt(new Date());
|
|
|
- return instanceMapper.updateById(instance) > 0;
|
|
|
+ boolean updated = instanceMapper.updateById(instance) > 0;
|
|
|
+
|
|
|
+ // 级联清理:该方案生成的未完成任务置 cancelled
|
|
|
+ if (updated) {
|
|
|
+ List<Task> pendingTasks = taskMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<Task>()
|
|
|
+ .eq(Task::getSourceType, "plan")
|
|
|
+ .eq(Task::getSourceId, id)
|
|
|
+ .in(Task::getStatus, "pending", "pending_review", "locked", "in_progress"));
|
|
|
+ for (Task t : pendingTasks) {
|
|
|
+ t.setStatus("cancelled");
|
|
|
+ t.setUpdatedAt(new Date());
|
|
|
+ taskMapper.updateById(t);
|
|
|
+ }
|
|
|
+ log.info("取消方案{}并级联清理{}条未完成任务", id, pendingTasks.size());
|
|
|
+ }
|
|
|
+ return updated;
|
|
|
}
|
|
|
|
|
|
/**
|