From df76f79ee0b770dabbd45c3947fb3481c54e6670 Mon Sep 17 00:00:00 2001 From: Zzm0809 <934230207@qq.com> Date: Tue, 26 Dec 2023 15:44:30 +0800 Subject: [PATCH] fix JobLifeCycle --- .../java/org/dinky/service/impl/TaskServiceImpl.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java index cb8855ba06..dc6ba84416 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java @@ -487,6 +487,7 @@ public void initTenantByTaskId(Integer id) { } @Override + @Transactional(rollbackFor = Exception.class) public boolean changeTaskLifeRecyle(Integer taskId, JobLifeCycle lifeCycle) throws SqlExplainExcepition { TaskDTO task = getTaskInfoById(taskId); task.setStep(lifeCycle.getValue()); @@ -504,7 +505,14 @@ public boolean changeTaskLifeRecyle(Integer taskId, JobLifeCycle lifeCycle) thro Integer taskVersionId = taskVersionService.createTaskVersionSnapshot(task); task.setVersionId(taskVersionId); } - return saveOrUpdate(task.buildTask()); + boolean saved = saveOrUpdate(task.buildTask()); + if (saved && Asserts.isNotNull(task.getJobInstanceId())) { + JobInstance jobInstance = jobInstanceService.getById(task.getJobInstanceId()); + jobInstance.setStep(lifeCycle.getValue()); + jobInstanceService.updateById(jobInstance); + log.info("jobInstance [{}] step change to {}", jobInstance.getJid(), lifeCycle.getValue()); + } + return saved; } @Override