| | |
| | | String curLoc; |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) { |
| | | curLoc = task.getTargLoc(); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) { |
| | | curLoc = task.getTargLoc(); |
| | | if (StringUtils.isBlank(curLoc)) { |
| | | return task; |
| | | } |
| | | } else { |
| | | curLoc = task.getOrgLoc(); |
| | | } |
| | |
| | | rcsApi != null ? rcsApi.getPort() : "null"); |
| | | return; |
| | | } |
| | | |
| | | // 同料箱号规则:101 任务所在料箱号下若已存在 196/198/199/200 任务,则不向 RCS 发送该 101 任务(/api/open/bus/submit) |
| | | List<Integer> higherStatuses = Arrays.asList(TaskStsType.AWAIT.id, TaskStsType.COMPLETE_OUT.id, TaskStsType.WAVE_SEED.id, TaskStsType.UPDATED_OUT.id); |
| | | List<Task> higherTasks = this.list(new LambdaQueryWrapper<Task>() |
| | | .in(Task::getTaskStatus, higherStatuses) |
| | | .isNotNull(Task::getBarcode) |
| | | .ne(Task::getBarcode, "")); |
| | | Set<String> barcodesWithHigher = higherTasks.stream().map(Task::getBarcode).filter(StringUtils::isNotBlank).collect(Collectors.toSet()); |
| | | List<Task> toSend = tasks.stream() |
| | | .filter(t -> { |
| | | if (TaskStsType.GENERATE_OUT.id.equals(t.getTaskStatus()) && StringUtils.isNotBlank(t.getBarcode()) && barcodesWithHigher.contains(t.getBarcode())) { |
| | | log.debug("同料箱号{}下已存在196/198/199/200任务,跳过101任务下发:taskId={}", t.getBarcode(), t.getId()); |
| | | return false; |
| | | } |
| | | return true; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | if (toSend.isEmpty()) { |
| | | log.debug("过滤后无待下发任务"); |
| | | return; |
| | | } |
| | | tasks = toSend; |
| | | |
| | | String pubTakUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.pubTask; |
| | | |
| | | |
| | | for (Task task : tasks) { |
| | | WcsTaskParams taskParams = new WcsTaskParams(); |
| | | List<TaskItemParam> items = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | // 空板入库无任务明细,仅更新库位为空板(D)、任务状态为库存更新完成 |
| | | if (TaskType.TASK_TYPE_EMPITY_IN.type.equals(task.getTaskType())) { |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()) |
| | | .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type) |
| | | .set(Loc::getUpdateBy, loginUserId) |
| | | .set(Loc::getUpdateTime, new Date()))) { |
| | | throw new CoolException("空板入库库位状态修改失败!!"); |
| | | } |
| | | if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) { |
| | | throw new CoolException("空板入库任务状态修改失败!!"); |
| | | } |
| | | reportInOutResultToCloud(task, loc, Collections.emptyList(), null, true); |
| | | return; |
| | | } |
| | | if (taskItems.isEmpty()) { |
| | | throw new CoolException("任务明细不存在!!"); |
| | | } |
| | |
| | | throw new CoolException("组拖状态修改失败!!"); |
| | | } |
| | | |
| | | // 组托入库完成后累加订单及明细的已收数量,用于后续判断整单是否可置为已完成 |
| | | Map<Long, Double> orderIdToAdd = new HashMap<>(); |
| | | Map<Long, Double> itemIdToAdd = new HashMap<>(); |
| | | for (WaitPakinItem p : pakinItems) { |
| | | if (StringUtils.isBlank(p.getAsnCode())) { |
| | | continue; |
| | | } |
| | | WkOrder order = asnOrderService.getOne(new LambdaQueryWrapper<WkOrder>().eq(WkOrder::getCode, p.getAsnCode())); |
| | | if (order == null) { |
| | | continue; |
| | | } |
| | | double addQty = (p.getAnfme() != null ? p.getAnfme() : 0.0); |
| | | orderIdToAdd.merge(order.getId(), addQty, Double::sum); |
| | | if (p.getAsnItemId() != null) { |
| | | itemIdToAdd.merge(p.getAsnItemId(), addQty, Double::sum); |
| | | } |
| | | } |
| | | for (Map.Entry<Long, Double> e : orderIdToAdd.entrySet()) { |
| | | WkOrder o = asnOrderService.getById(e.getKey()); |
| | | if (o != null) { |
| | | Double newQty = QuantityUtils.roundToScale(QuantityUtils.add(o.getQty() != null ? o.getQty() : 0.0, e.getValue())); |
| | | o.setQty(newQty); |
| | | if (!asnOrderService.updateById(o)) { |
| | | throw new CoolException("入库单完成数量更新失败!!"); |
| | | } |
| | | } |
| | | } |
| | | for (Map.Entry<Long, Double> e : itemIdToAdd.entrySet()) { |
| | | WkOrderItem oi = asnOrderItemService.getById(e.getKey()); |
| | | if (oi != null) { |
| | | Double newQty = QuantityUtils.roundToScale(QuantityUtils.add(oi.getQty() != null ? oi.getQty() : 0.0, e.getValue())); |
| | | oi.setQty(newQty); |
| | | if (!asnOrderItemService.updateById(oi)) { |
| | | throw new CoolException("入库单明细完成数量更新失败!!"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /**修改库位状态为F.在库*/ |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).eq(Loc::getCode, task.getTargLoc()))) { |
| | | throw new CoolException("库位状态修改失败!!"); |