zjj
6 天以前 4114759a57d73661937f28a765fb8a67c017b14b
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/WaveSchedules.java
@@ -16,6 +16,7 @@
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 +54,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,24 +62,24 @@
        }
        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;
        }
        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);
            params.put("waveItem", itemIds);
            waveService.waveToTask(params, waveId);
        });
    }