skyouc
1 天以前 f2833c7f3e01c997e94a66bd5dd9be738b5c6cc7
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/WaveSchedules.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.common.constant.Constants;
import com.vincent.rsf.server.manager.entity.Wave;
@@ -10,6 +11,7 @@
import com.vincent.rsf.server.manager.enums.WaveItemExceStatus;
import com.vincent.rsf.server.manager.service.WaveItemService;
import com.vincent.rsf.server.manager.service.WaveService;
import com.vincent.rsf.server.manager.service.impl.TaskItemServiceImpl;
import com.vincent.rsf.server.system.constant.GlobalConfigCode;
import com.vincent.rsf.server.system.entity.Config;
import com.vincent.rsf.server.system.service.ConfigService;
@@ -19,10 +21,7 @@
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -44,7 +43,8 @@
    @Autowired
    private ConfigService configService;
    @Autowired
    private TaskItemServiceImpl taskItemService;
    /**
@@ -55,23 +55,30 @@
    * @time 2025/6/23 13:52
    */
    @Scheduled(cron = "0/15 * * * * ?")
    @Transactional(rollbackFor = Exception.class)
//    @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())) {
            return;
        }
        List<Wave> list = waveService.list(new LambdaQueryWrapper<Wave>()
                        .select(Wave::getId)
                        .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<Wave> list = waveService.list(new LambdaQueryWrapper<Wave>()
//                        .select(Wave::getId)
//                        .in(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_INIT.val
//                                , WaveExceStatus.WAVE_EXCE_STATUS_EXCING.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::getWaveId, longs)
                .eq(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_ITEM_EXCE_STATUS_UN.val));
                .in(WaveItem::getExceStatus, Arrays.asList(WaveItemExceStatus.WAVE_ITEM_EXCE_STATUS_UN.val
                        , WaveItemExceStatus.WAVE_EXCE_STATUS_ING.val)));
        waveItemService.update(new LambdaUpdateWrapper<WaveItem>()
                .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_ING.val)
                .apply("anfme > work_qty")
        );
        if (waveItems.isEmpty()) {
            return;
        }
@@ -85,4 +92,5 @@
            waveService.waveToTask(params, loginUserId);
        });
    }
}