| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String processCrossDockInbound(OrderPakin order, OrderDomainParam param, Long userId) { |
| | | log.info("开始处理越库入库单,订单号:{}", order.getOrderNo()); |
| | | log.info("开始处理越库入库单,订单号:{},订单类型:{}", order.getOrderNo(), order.getDocType()); |
| | | |
| | | Date now = new Date(); |
| | | |
| | | // 步骤1:设置入库单为已上报状态(跳过ERP上报流程) |
| | | log.info("步骤1:设置入库单[{}]为已上报状态", order.getOrderNo()); |
| | | if (!orderPakinService.updateSettle(order.getId(), 6L, userId)) { |
| | | throw new CoolException("设置入库单为已上报状态失败"); |
| | | log.info("步骤1:设置入库单[{}]为已上报状态,订单ID:{}", order.getOrderNo(), order.getId()); |
| | | boolean updateResult = orderPakinService.updateSettle(order.getId(), 6L, userId); |
| | | log.info("步骤1:更新入库单状态结果:{}", updateResult); |
| | | if (!updateResult) { |
| | | throw new CoolException("设置入库单为已上报状态失败,订单ID:" + order.getId()); |
| | | } |
| | | // 验证状态是否更新成功 |
| | | OrderPakin updatedOrder = orderPakinService.selectById(order.getId()); |
| | | if (updatedOrder != null) { |
| | | log.info("步骤1:验证入库单状态更新,订单号:{},当前状态:{}", updatedOrder.getOrderNo(), updatedOrder.getSettle()); |
| | | if (!updatedOrder.getSettle().equals(6L)) { |
| | | throw new CoolException("入库单状态更新失败,期望状态:6,实际状态:" + updatedOrder.getSettle()); |
| | | } |
| | | } |
| | | |
| | | // 步骤2:更新明细完成数量并创建虚拟库位库存 |
| | |
| | | new EntityWrapper<OrderDetlPakin>().eq("order_id", order.getId())); |
| | | |
| | | for (OrderDetlPakin orderDetl : orderDetls) { |
| | | // 2.1 更新完成数量 |
| | | orderDetl.setQty(orderDetl.getAnfme()); |
| | | // 2.1 更新完成数量和作业数量(越库订单立即完成,不需要实际作业) |
| | | orderDetl.setQty(orderDetl.getAnfme()); // 完成数量等于申请数量 |
| | | orderDetl.setWorkQty(orderDetl.getAnfme()); // 作业数量等于申请数量 |
| | | orderDetl.setUpdateBy(userId); |
| | | orderDetl.setUpdateTime(now); |
| | | if (!orderDetlPakinService.updateById(orderDetl)) { |
| | |
| | | } |
| | | |
| | | // 步骤3:获取越库出库单类型 |
| | | Long outboundDocTypeId = crossDockProperties.getOutboundDocTypeId(); |
| | | log.info("步骤3:获取越库出库单类型,docId={}", outboundDocTypeId); |
| | | // 优先使用用户选择的出库订单类型,如果没有则使用配置的默认类型 |
| | | Long outboundDocTypeId = param.getOutboundDocType(); |
| | | if (outboundDocTypeId == null) { |
| | | outboundDocTypeId = crossDockProperties.getOutboundDocTypeId(); |
| | | log.info("步骤3:用户未选择出库订单类型,使用配置的默认类型,docId={}", outboundDocTypeId); |
| | | } else { |
| | | log.info("步骤3:使用用户选择的出库订单类型,docId={}", outboundDocTypeId); |
| | | } |
| | | DocType crossDockOutDocType = docTypeService.selectById(outboundDocTypeId); |
| | | if (crossDockOutDocType == null) { |
| | | throw new CoolException("越库出库单类型不存在,docId=" + outboundDocTypeId); |
| | | } |
| | | log.info("步骤3:出库订单类型名称:{}", crossDockOutDocType.getDocName()); |
| | | |
| | | // 步骤4:创建越库出库单主档 |
| | | log.info("步骤4:创建越库出库单主档"); |
| | |
| | | outDetl.setId(null); // 清除ID,让数据库自动生成 |
| | | outDetl.setOrderId(outOrder.getId()); |
| | | outDetl.setOrderNo(outOrderNo); |
| | | outDetl.setAnfme(inDetl.getAnfme()); // 申请数量等于入库单明细的申请数量 |
| | | outDetl.setQty(inDetl.getAnfme()); // 完成数量等于申请数量 |
| | | outDetl.setWorkQty(inDetl.getAnfme()); |
| | | outDetl.setWorkQty(inDetl.getAnfme()); // 作业数量等于申请数量 |
| | | outDetl.setCreateBy(userId); |
| | | outDetl.setCreateTime(now); |
| | | outDetl.setUpdateBy(userId); |