| | |
| | | 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; |
| | |
| | | * @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())) { |
| | |
| | | } |
| | | 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); |
| | | }); |
| | | } |