feat(1.4.0-beta1): 1. 修复重试任务批量删除失败问题
This commit is contained in:
parent
abe08bed5c
commit
c32d1c5426
@ -41,7 +41,7 @@ public class RetryController {
|
||||
@LoginRequired
|
||||
@PutMapping("status")
|
||||
public int updateRetryTaskStatus(@RequestBody RetryUpdateStatusRequestVO retryUpdateStatusRequestVO) {
|
||||
return retryService.updateRetryTaskStatus(retryUpdateStatusRequestVO);
|
||||
return retryService.updateRetryStatus(retryUpdateStatusRequestVO);
|
||||
}
|
||||
|
||||
@LoginRequired
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.aizuda.snailjob.server.web.model.request;
|
||||
|
||||
import com.aizuda.snailjob.common.core.enums.RetryStatusEnum;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 重试数据模型
|
||||
|
@ -30,7 +30,7 @@ public interface RetryService {
|
||||
* @param retryUpdateStatusRequestVO 更新重试任务状态请求模型
|
||||
* @return
|
||||
*/
|
||||
int updateRetryTaskStatus(RetryUpdateStatusRequestVO retryUpdateStatusRequestVO);
|
||||
int updateRetryStatus(RetryUpdateStatusRequestVO retryUpdateStatusRequestVO);
|
||||
|
||||
/**
|
||||
* 手动新增重试任务
|
||||
|
@ -54,8 +54,10 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
@ -83,6 +85,8 @@ public class RetryServiceImpl implements RetryService {
|
||||
private List<TaskGenerator> taskGenerators;
|
||||
@Autowired
|
||||
private RetryTaskLogMessageMapper retryTaskLogMessageMapper;
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
@Override
|
||||
public PageResult<List<RetryResponseVO>> getRetryPage(RetryQueryVO queryVO) {
|
||||
@ -141,7 +145,7 @@ public class RetryServiceImpl implements RetryService {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateRetryTaskStatus(RetryUpdateStatusRequestVO requestVO) {
|
||||
public int updateRetryStatus(RetryUpdateStatusRequestVO requestVO) {
|
||||
|
||||
RetryStatusEnum retryStatusEnum = RetryStatusEnum.getByStatus(requestVO.getRetryStatus());
|
||||
if (Objects.isNull(retryStatusEnum)) {
|
||||
@ -178,13 +182,6 @@ public class RetryServiceImpl implements RetryService {
|
||||
retryLogMetaDTO.setTimestamp(DateUtils.toNowMilli());
|
||||
SnailJobLog.REMOTE.info("=============手动操作完成============. <|>{}<|>", retryLogMetaDTO);
|
||||
}
|
||||
//
|
||||
// RetryTask retryTask = new RetryTask();
|
||||
// retryTask.setTaskStatus(requestVO.getRetryStatus());
|
||||
// retryTaskMapper.update(retryTask, new LambdaUpdateWrapper<RetryTask>()
|
||||
// .eq(RetryTask::getNamespaceId, namespaceId)
|
||||
// .eq(RetryTask::getUniqueId, retry.getUniqueId())
|
||||
// .eq(RetryTask::getGroupName, retry.getGroupName()));
|
||||
|
||||
retry.setUpdateDt(LocalDateTime.now());
|
||||
return retryTaskAccess.updateById(retry);
|
||||
@ -351,6 +348,7 @@ public class RetryServiceImpl implements RetryService {
|
||||
|
||||
String namespaceId = UserSessionUtils.currentUserSession().getNamespaceId();
|
||||
|
||||
transactionTemplate.execute((status -> {
|
||||
map.forEach(((sceneName, retryTaskDTOS) -> {
|
||||
TaskContext taskContext = new TaskContext();
|
||||
taskContext.setSceneName(sceneName);
|
||||
@ -360,7 +358,15 @@ public class RetryServiceImpl implements RetryService {
|
||||
taskContext.setTaskInfos(TaskContextConverter.INSTANCE.convert(retryTaskDTOS));
|
||||
|
||||
// 生成任务
|
||||
try {
|
||||
taskGenerator.taskGenerator(taskContext);
|
||||
} catch (DuplicateKeyException e) {
|
||||
throw new SnailJobServerException("namespaceId:[{}] groupName:[{}] sceneName:[{}] 任务已经存在",
|
||||
namespaceId, parseLogsVO.getGroupName(), sceneName);
|
||||
}
|
||||
|
||||
}));
|
||||
return Boolean.TRUE;
|
||||
}));
|
||||
|
||||
return waitInsertList.size();
|
||||
|
@ -197,7 +197,7 @@ public class RetryTaskServiceImpl implements RetryTaskService {
|
||||
|
||||
List<RetryTask> retryTasks = retryTaskMapper.selectList(
|
||||
new LambdaQueryWrapper<RetryTask>()
|
||||
.in(RetryTask::getTaskStatus, List.of(RetryStatusEnum.FINISH.getStatus(), RetryStatusEnum.MAX_COUNT.getStatus()))
|
||||
.in(RetryTask::getTaskStatus, RetryTaskStatusEnum.TERMINAL_STATUS_SET)
|
||||
.eq(RetryTask::getNamespaceId, namespaceId)
|
||||
.in(RetryTask::getId, ids));
|
||||
Assert.notEmpty(retryTasks, () -> new SnailJobServerException("数据不存在"));
|
||||
@ -216,8 +216,11 @@ public class RetryTaskServiceImpl implements RetryTaskService {
|
||||
@Override
|
||||
public Boolean stopById(Long id) {
|
||||
|
||||
Retry retry = retryMapper.selectById(id);
|
||||
Assert.notNull(retry, () -> new SnailJobServerException("没有可执行的任务"));
|
||||
RetryTask retryTask = retryTaskMapper.selectById(id);
|
||||
Assert.notNull(retryTask, () -> new SnailJobServerException("没有可执行的任务"));
|
||||
|
||||
Retry retry = retryMapper.selectById(retryTask.getRetryId());
|
||||
Assert.notNull(retry, () -> new SnailJobServerException("任务不存在"));
|
||||
|
||||
TaskStopJobDTO taskStopJobDTO = RetryConverter.INSTANCE.toTaskStopJobDTO(retry);
|
||||
taskStopJobDTO.setOperationReason(RetryOperationReasonEnum.MANNER_STOP.getReason());
|
||||
|
Loading…
Reference in New Issue
Block a user