From cd8e369a7b3b751527090147798c5b81c30bf2d0 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期四, 26 六月 2025 09:06:55 +0800 Subject: [PATCH] 生成任务工作档优化 --- rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/WaveSchedules.java | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/WaveSchedules.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/WaveSchedules.java index 418a8fa..165262d 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/WaveSchedules.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/WaveSchedules.java @@ -13,9 +13,11 @@ import com.vincent.rsf.server.system.constant.GlobalConfigCode; import com.vincent.rsf.server.system.entity.Config; import com.vincent.rsf.server.system.service.ConfigService; +import com.vincent.rsf.server.system.utils.SystemAuthUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; import java.util.List; @@ -53,6 +55,7 @@ * @time 2025/6/23 13:52 */ @Scheduled(cron = "0/15 * * * * ?") + @Transactional(rollbackFor = Exception.class) public void autoGenerateTask() { Config config = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.WAVE_AUTO_EXCE_TASK)); if (Objects.isNull(config) || !Boolean.parseBoolean(config.getVal())) { @@ -60,25 +63,26 @@ } List<Wave> list = waveService.list(new LambdaQueryWrapper<Wave>() .select(Wave::getId) - .eq(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_INIT.val)); + .eq(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_INIT.val)); if (list.isEmpty()) { return; } List<Long> longs = list.stream().map(Wave::getId).collect(Collectors.toList()); List<WaveItem> waveItems = waveItemService.list(new LambdaQueryWrapper<WaveItem>() - .in(WaveItem::getId, longs) - .eq(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_ITEM_EXCE_STATUS_UN.val) - ); + .in(WaveItem::getWaveId, longs) + .eq(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_ITEM_EXCE_STATUS_UN.val)); if (waveItems.isEmpty()) { return; } + Long loginUserId = SystemAuthUtils.getLoginUserId(); Map<Long, List<WaveItem>> listMap = waveItems.stream().collect(Collectors.groupingBy(WaveItem::getWaveId)); listMap.keySet().forEach(waveId -> { + List<Long> itemIds = listMap.get(waveId).stream().map(WaveItem::getId).collect(Collectors.toList()); Map<String, Object> params = new HashMap<>(); params.put("wave", waveId); - params.put("waveItems", waveItems); - waveService.waveToTask(params, waveId); + params.put("waveItem", itemIds); + waveService.waveToTask(params, loginUserId); }); } } -- Gitblit v1.9.1