| | |
| | | * 自动生成库位明细 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Scheduled(cron = "0/25 * * * * ?") |
| | | // @Scheduled(cron = "0/25 * * * * ?") |
| | | public void insertRandomMats() { |
| | | List<Loc> list = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type)); |
| | | for (Loc loc : list) { |
| | |
| | | // } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/9/1 |
| | | * @description: 自动完成盘点功能 |
| | | * @version 1.0 |
| | | * 自动完成盘点/拣料:盘点出库逐条处理;拣料出库按箱码分组,同一箱码下全部任务拣完才扣减并生成拣料入库(与PDA确认逻辑一致)。 |
| | | */ |
| | | @Scheduled(cron = "0/25 * * * * ?") |
| | | // @Scheduled(cron = "0/25 * * * * ?") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void autoCheckComplete() { |
| | | //获取任务列表中,为盘点出库的任务 |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() |
| | | .in(Task::getTaskType, Arrays.asList(TaskType.TASK_TYPE_CHECK_OUT.type, |
| | | TaskType.TASK_TYPE_PICK_IN.type, |
| | | TaskType.TASK_TYPE_PICK_AGAIN_OUT.type, |
| | | TaskType.TASK_TYPE_CHECK_IN.type))); |
| | | |
| | | if (!tasks.isEmpty()) { |
| | | tasks.forEach(task -> { |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) { |
| | | if (task.getTaskStatus().equals(TaskStsType.COMPLETE_IN.id)) { |
| | | |
| | | } |
| | | } else { |
| | | if (task.getTaskStatus().equals(TaskStsType.WAVE_SEED.id)) { |
| | | if (!stationService.update(new LambdaUpdateWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, task.getTargSite()) |
| | | .set(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_R.type))) { |
| | | log.error("站点状态修改完成失败,当前任务状态:", task.getTaskStatus()); |
| | | // throw new CoolException("站点状态修改失败!!"); |
| | | } |
| | | try { |
| | | taskService.pickOrCheckTask(task.getId(), task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type) ? Constants.TASK_TYPE_OUT_CHECK : ""); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("error====>", e); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | if (tasks.isEmpty()) { |
| | | return; |
| | | } |
| | | // 拣料出库:按箱码分组,仅当该箱码下所有任务都拣完才处理(扣减并生成拣料入库或库存扣完不生成) |
| | | Map<String, List<Task>> pickOutByBarcode = tasks.stream() |
| | | .filter(t -> TaskType.TASK_TYPE_PICK_AGAIN_OUT.type.equals(t.getTaskType()) && TaskStsType.WAVE_SEED.id.equals(t.getTaskStatus())) |
| | | .collect(Collectors.groupingBy(t -> t.getBarcode() != null ? t.getBarcode() : "")); |
| | | for (Map.Entry<String, List<Task>> e : pickOutByBarcode.entrySet()) { |
| | | if (e.getKey().isEmpty()) continue; |
| | | List<Task> barcodeTasks = e.getValue(); |
| | | List<Long> taskIds = barcodeTasks.stream().map(Task::getId).collect(Collectors.toList()); |
| | | List<TaskItem> items = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getTaskId, taskIds)); |
| | | boolean allPicked = items.stream().allMatch(ti -> |
| | | ti.getQty() != null && ti.getAnfme() != null && ti.getQty().compareTo(ti.getAnfme()) >= 0); |
| | | if (!allPicked) continue; |
| | | for (Task task : barcodeTasks) { |
| | | try { |
| | | taskService.pickOrCheckTask(task.getId(), ""); |
| | | } catch (Exception ex) { |
| | | log.error("autoCheckComplete 拣料出库 taskId={} error", task.getId(), ex); |
| | | } |
| | | } |
| | | } |
| | | // 盘点出库:逐条处理(不按箱码聚合) |
| | | tasks.stream() |
| | | .filter(t -> TaskType.TASK_TYPE_CHECK_OUT.type.equals(t.getTaskType()) && TaskStsType.WAVE_SEED.id.equals(t.getTaskStatus())) |
| | | .forEach(task -> { |
| | | if (!stationService.update(new LambdaUpdateWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, task.getTargSite()) |
| | | .set(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_R.type))) { |
| | | log.error("站点状态修改完成失败,当前任务状态:", task.getTaskStatus()); |
| | | } |
| | | try { |
| | | taskService.pickOrCheckTask(task.getId(), Constants.TASK_TYPE_OUT_CHECK); |
| | | } catch (Exception e) { |
| | | log.error("autoCheckComplete 盘点出库 taskId={} error", task.getId(), e); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | |
| | | if (Cools.isEmpty(autoRunArea)) { |
| | | return; |
| | | } |
| | | List<Integer> array = new ArrayList<>(); |
| | | List<String> list = new ArrayList<>(); |
| | | for (char c : autoRunArea.toCharArray()) { |
| | | switch (c) { |
| | | case '1': |
| | | xx(LocGroupConstant.FAR_RIGHT_LOC_ROW_LIST); |
| | | array.addAll(LocGroupConstant.FAR_RIGHT_LOC_ROW_LIST); |
| | | list.addAll(StaGroupConstant.FAR_RIGHT_STA_ROW_LIST); |
| | | break; |
| | | case '2': |
| | | xx(LocGroupConstant.RIGHT_LOC_ROW_LIST); |
| | | array.addAll(LocGroupConstant.RIGHT_LOC_ROW_LIST); |
| | | list.addAll(StaGroupConstant.RIGHT_STA_ROW_LIST); |
| | | break; |
| | | case '3': |
| | | xx(LocGroupConstant.MIDDLE_LOC_ROW_LIST); |
| | | array.addAll(LocGroupConstant.MIDDLE_LOC_ROW_LIST); |
| | | list.addAll(StaGroupConstant.MIDDLE_STA_ROW_LIST); |
| | | break; |
| | | case '4': |
| | | xx(LocGroupConstant.LEFT_LOC_ROW_LIST); |
| | | array.addAll(LocGroupConstant.LEFT_LOC_ROW_LIST); |
| | | list.addAll(StaGroupConstant.LEFT_STA_ROW_LIST); |
| | | break; |
| | | case '5': |
| | | xx(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST); |
| | | array.addAll(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST); |
| | | list.addAll(StaGroupConstant.FAR_LEFT_STA_ROW_LIST); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | xx(array); |
| | | |
| | | } |
| | | |
| | | private void xx(List<Integer> locGroupList) { |
| | | Integer startRow = Collections.min(locGroupList); |