| | |
| | | } |
| | | |
| | | tasks.forEach(task -> { |
| | | TaskLog taskLog = new TaskLog(); |
| | | BeanUtils.copyProperties(task, taskLog); |
| | | taskLog.setTaskId(task.getId()).setId(null); |
| | | if (!taskLogService.save(taskLog)) { |
| | | throw new CoolException("任务历史档保存失败!!"); |
| | | // 只对出库 200 做同箱码检查:同箱码下若有 101/196/198/199 等(未到 200)则跳过,等全部 200 才一次处理;拣料入库 100 不受影响 |
| | | List<Task> toProcess = Collections.singletonList(task); |
| | | if (TaskStsType.UPDATED_OUT.id.equals(task.getTaskStatus()) && TaskType.TASK_TYPE_PICK_AGAIN_OUT.type.equals(task.getTaskType()) && StringUtils.isNotBlank(task.getBarcode())) { |
| | | long not200 = taskService.count(new LambdaQueryWrapper<Task>() |
| | | .eq(Task::getBarcode, task.getBarcode()) |
| | | .ne(Task::getTaskStatus, TaskStsType.UPDATED_OUT.id)); |
| | | if (not200 > 0) { |
| | | return; // 同箱码尚有 101/196/198/199 等非 200 任务,不处理,继续等待 |
| | | } |
| | | // 同箱码已全部 200:一次性处理该箱码下所有 200 拣料出库(合计扣减、更新库存、生成一张拣料入库单、更新库位状态) |
| | | List<Task> all200 = taskService.list(new LambdaQueryWrapper<Task>() |
| | | .eq(Task::getBarcode, task.getBarcode()) |
| | | .eq(Task::getTaskType, TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) |
| | | .eq(Task::getTaskStatus, TaskStsType.UPDATED_OUT.id) |
| | | .orderByAsc(Task::getId)); |
| | | if (!all200.isEmpty()) { |
| | | taskService.processPickOutBarcodeAll200(all200); |
| | | toProcess = all200; |
| | | } |
| | | } |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | for (Task t : toProcess) { |
| | | TaskLog taskLog = new TaskLog(); |
| | | BeanUtils.copyProperties(t, taskLog); |
| | | taskLog.setTaskId(t.getId()).setId(null); |
| | | if (!taskLogService.save(taskLog)) { |
| | | throw new CoolException("任务历史档保存失败!!"); |
| | | } |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, t.getId())); |
| | | |
| | | // 上报ERP暂时注释(/rsf-open-api/erp/report/order) |
| | | // if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) { |
| | |
| | | // reportMsgService.reportOrderItem(wkOrderItem); |
| | | // } |
| | | // } else |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) { |
| | | if (t.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) { |
| | | // 入库类型仅转历史,不上报ERP(已注释) |
| | | } else if ((task.getTaskType() >= TaskType.TASK_TYPE_OUT.type && task.getTaskType() <= TaskType.TASK_TYPE_EMPITY_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)) { |
| | | } else if ((t.getTaskType() >= TaskType.TASK_TYPE_OUT.type && t.getTaskType() <= TaskType.TASK_TYPE_EMPITY_OUT.type) |
| | | || t.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)) { |
| | | /**判断单据是否完成:波次下发、按单下发(点击下发任务)完成后均将出库单置为完结*/ |
| | | Set<Long> orderIdsToDone = new HashSet<>(); |
| | | if (task.getResource() != null && task.getResource().equals(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)) { |
| | | if (t.getResource() != null && t.getResource().equals(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)) { |
| | | Set<Long> longSet = taskItems.stream() |
| | | .map(TaskItem::getSourceId) |
| | | .filter(Objects::nonNull) |
| | |
| | | orderIdsToDone.addAll(waveOrderRelas.stream().map(WaveOrderRela::getOrderId).collect(Collectors.toSet())); |
| | | } |
| | | } |
| | | } else if (task.getResource() != null && task.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val)) { |
| | | } else if (t.getResource() != null && t.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val)) { |
| | | // 按单下发:任务明细 sourceId 为出库单ID |
| | | Set<Long> ids = taskItems.stream() |
| | | .map(TaskItem::getSourceId) |
| | |
| | | |
| | | //出库单上报RCS修改库位状态 |
| | | try { |
| | | reportStationStatus(task); |
| | | reportStationStatus(t); |
| | | } catch (Exception e) { |
| | | logger.error("任务{}上报RCS修改库位状态失败。任务编码:{}", task.getId(), task.getTaskCode(), e); |
| | | logger.error("任务{}上报RCS修改库位状态失败。任务编码:{}", t.getId(), t.getTaskCode(), e); |
| | | // 不抛出异常,避免中断定时任务 |
| | | } |
| | | } |
| | |
| | | TaskItemLog itemLog = new TaskItemLog(); |
| | | BeanUtils.copyProperties(item, itemLog); |
| | | itemLog.setId(null) |
| | | .setTaskId(task.getId()) |
| | | .setTaskId(t.getId()) |
| | | .setLogId(taskLog.getId()) |
| | | .setTaskItemId(item.getId()); |
| | | itemLogs.add(itemLog); |
| | | } |
| | | |
| | | locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId())); |
| | | locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, t.getId())); |
| | | |
| | | |
| | | if (!taskService.removeById(task.getId())) { |
| | | if (!taskService.removeById(t.getId())) { |
| | | throw new CoolException("原始任务删除失败!!"); |
| | | } |
| | | |
| | |
| | | if (!taskItemLogService.saveBatch(itemLogs)) { |
| | | throw new CoolException("任务明细历史档保存失败!!"); |
| | | } |
| | | if (!taskItemService.remove(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()))) { |
| | | if (!taskItemService.remove(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, t.getId()))) { |
| | | throw new CoolException("原始任务明细删除失败!!"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |