|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.enums.TaskStsType; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.service.*; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.service.impl.WaveDetlLogServiceImpl; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.service.impl.WaveDetlServiceImpl; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.service.impl.WaveLogServiceImpl; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.service.impl.WaveServiceImpl; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.entity.Dict; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.service.DictService; | 
|---|
|  |  |  | import com.zy.asrs.wms.utils.OrderUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  | private WaveSeedService waveSeedService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DictService dictService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WaveServiceImpl waveService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WaveLogServiceImpl waveLogService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WaveDetlServiceImpl waveDetlService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WaveDetlLogServiceImpl waveDetlLogService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author Ryan | 
|---|
|  |  |  | * @date 2025/6/20 | 
|---|
|  |  |  | * @description: 更新波次明细,加入历史档 | 
|---|
|  |  |  | * @version 1.0 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Scheduled(cron = "0/30 * * * * ? ") | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | public void addWaveHistories() { | 
|---|
|  |  |  | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskSts, TaskStsType.UPDATED_OUT.id)); | 
|---|
|  |  |  | if (tasks.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (Task task : tasks) { | 
|---|
|  |  |  | List<TaskDetl> detls = taskDetlService.list(new LambdaQueryWrapper<TaskDetl>().eq(TaskDetl::getTaskId, task.getId())); | 
|---|
|  |  |  | if (detls.isEmpty()) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Set<Long> waveIds = detls.stream().map(TaskDetl::getWaveId).collect(Collectors.toSet()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (waveIds.isEmpty()) { | 
|---|
|  |  |  | throw new CoolException("波次信息为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Wave> waves = waveService.list(new LambdaQueryWrapper<Wave>().in(Wave::getId, waveIds)); | 
|---|
|  |  |  | for (Wave wave : waves) { | 
|---|
|  |  |  | WaveLog waveLog = new WaveLog(); | 
|---|
|  |  |  | waveLog.sync(wave); | 
|---|
|  |  |  | waveLog.setId(null); | 
|---|
|  |  |  | if (!waveLogService.save(waveLog)) { | 
|---|
|  |  |  | throw new CoolException("波次转历史失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WaveDetl> waveDetls = waveDetlService.list(new LambdaQueryWrapper<WaveDetl>().eq(WaveDetl::getWaveId, wave.getId())); | 
|---|
|  |  |  | for (WaveDetl waveDetl : waveDetls) { | 
|---|
|  |  |  | WaveDetlLog waveDetlLog = new WaveDetlLog(); | 
|---|
|  |  |  | waveDetlLog.sync(waveDetl); | 
|---|
|  |  |  | waveDetlLog.setId(null); | 
|---|
|  |  |  | waveDetlLog.setWaveId(waveLog.getId()); | 
|---|
|  |  |  | if (!waveDetlLogService.save(waveDetlLog)) { | 
|---|
|  |  |  | throw new CoolException("波次明细转历史失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!waveDetlService.removeById(waveDetl.getId())) { | 
|---|
|  |  |  | throw new CoolException("波次明细删除失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!waveService.removeById(wave.getId())) { | 
|---|
|  |  |  | throw new CoolException("波次删除失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * modifty: | 
|---|