diff --git a/oms_web/oms_vue/src/views/inventory/outer/components/GenerateDeliveryForm.vue b/oms_web/oms_vue/src/views/inventory/outer/components/GenerateDeliveryForm.vue index 2d6abc05..e08d8a7b 100644 --- a/oms_web/oms_vue/src/views/inventory/outer/components/GenerateDeliveryForm.vue +++ b/oms_web/oms_vue/src/views/inventory/outer/components/GenerateDeliveryForm.vue @@ -157,6 +157,8 @@ export default { tabDataMap: {}, // 各采购单页签是否处于导入态:{ [purchaseNo]: true } isImportedTabs: {}, + // 各采购单页签是否为“指定发货”:{ [purchaseNo]: true } + assignTabs: {}, // 切换页签恢复勾选期间忽略 selection-change suppressSelectionChange: false, // 请求序号,避免快速切换页签时旧响应覆盖新页签 @@ -392,11 +394,11 @@ export default { - Number(this.productData.deliveryGenerateQuantity || 0) - Number(this.productData.deliveryConfirmQuantity || 0); }, - // 所有导入页签的已选行,用于提交 productSnDataList + // 所有导入页签的已选行,用于提交 productSnDataList(指定发货页签不参与,走 assignSnDataList) getImportedProductSnDataList() { const list = []; Object.keys(this.isImportedTabs).forEach(purchaseNo => { - if (!this.isImportedTabs[purchaseNo]) return; + if (!this.isImportedTabs[purchaseNo] || this.assignTabs[purchaseNo]) return; const rows = this.selectedSnMap[purchaseNo] || {}; Object.keys(rows).forEach(productSn => { list.push(rows[productSn]); @@ -404,6 +406,21 @@ export default { }); return list; }, + // 所有指定发货页签的已选行,用于提交 assignSnDataList + getAssignSnDataList() { + const list = []; + Object.keys(this.assignTabs).forEach(purchaseNo => { + if (!this.assignTabs[purchaseNo]) return; + const rows = this.selectedSnMap[purchaseNo] || {}; + Object.keys(rows).forEach(productSn => { + list.push({ + productSn, + licenseKey: rows[productSn].licenseKey + }); + }); + }); + return list; + }, handleDownloadTemplate() { exportDownloadTemplateData({ productCode: this.queryParams.productCode, @@ -506,6 +523,7 @@ export default { } const purchaseNo = this.activePurchaseNo; this.$set(this.isImportedTabs, purchaseNo, true); + this.$set(this.assignTabs, purchaseNo, false); this.$set(this.tabDataMap, purchaseNo, { rows, total: rows.length, @@ -549,6 +567,7 @@ export default { } this.$set(this.isImportedTabs, purchaseNo, true); + this.$set(this.assignTabs, purchaseNo, true); this.$set(this.tabDataMap, purchaseNo, { rows, total: rows.length, @@ -594,6 +613,7 @@ export default { outerCode: this.outerData.outerCode, detailId: this.productData.id, productSnDataList: this.getImportedProductSnDataList(), + assignSnDataList: this.getAssignSnDataList(), orderCode: this.queryParams.orderCode, }; @@ -623,6 +643,7 @@ export default { this.selectedSnMap = {}; this.tabDataMap = {}; this.isImportedTabs = {}; + this.assignTabs = {}; this.suppressSelectionChange = false; this.lastActivePurchaseNo = ''; this.loadedTab = ''; diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index ac267162..f06c71b8 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -58,7 +58,7 @@ spring: time-zone: GMT+8 date-format: yyyy-MM-dd HH:mm:ss profiles: - active: dev + active: prod # 文件上传 servlet: multipart: diff --git a/ruoyi-admin/src/main/resources/logback.xml b/ruoyi-admin/src/main/resources/logback.xml index 60a15b09..ede6e534 100644 --- a/ruoyi-admin/src/main/resources/logback.xml +++ b/ruoyi-admin/src/main/resources/logback.xml @@ -1,8 +1,8 @@ - - + + diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/InventoryDelivery.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/InventoryDelivery.java index 2d0671f3..ba3bbf2d 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/InventoryDelivery.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/InventoryDelivery.java @@ -79,6 +79,8 @@ public class InventoryDelivery extends BaseEntity private String approveStatus; private List productSnList; private List productSnDataList; + /** 指定发货的SN明细:SN已存在于库存且未发货,发货时只更新库存为出库,不再生成入库单 */ + private List assignSnDataList; diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/InventoryInfoMapper.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/InventoryInfoMapper.java index 4a7e0643..e3d836b4 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/InventoryInfoMapper.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/InventoryInfoMapper.java @@ -46,6 +46,15 @@ public interface InventoryInfoMapper */ public int updateInventoryInfo(InventoryInfo inventoryInfo); + /** + * 指定发货:将已入库且未发货的SN直接更新为出库 + * 只更新出库相关字段,保留入库单号、仓库、入库价、应付账单号等原值 + * + * @param inventoryInfo 产品库存 + * @return 结果 + */ + public int updateOutForAssignDelivery(InventoryInfo inventoryInfo); + /** * 删除产品库存 * diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/InventoryDeliveryServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/InventoryDeliveryServiceImpl.java index cb6292b3..c982aba1 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/InventoryDeliveryServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/InventoryDeliveryServiceImpl.java @@ -143,7 +143,8 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService, List productSnList = inventoryDelivery.getProductSnList(); List productSnDataList = inventoryDelivery.getProductSnDataList(); - if (CollUtil.isEmpty(productSnList) && CollUtil.isEmpty(productSnDataList)) { + List assignSnDataList = inventoryDelivery.getAssignSnDataList(); + if (CollUtil.isEmpty(productSnList) && CollUtil.isEmpty(productSnDataList) && CollUtil.isEmpty(assignSnDataList)) { throw new ServiceException("发货清单为空,保存失败"); } @@ -267,7 +268,45 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService, BigDecimal bigDecimal = inventoryOuterMapper.selectOutPriceByCode(inventoryDelivery.getOuterCode()); List detailList = new ArrayList<>(); - if (CollUtil.isEmpty(productSnDataList)) { + // 已由“指定发货/导入”清单处理的SN,用于校验手工勾选的SN是否被遗漏 + Set handledSnSet = new HashSet<>(); + // ══════════════════════════════════════════════════════ + // 指定发货:SN已入库且未发货,直接把库存置为出库 + // 不生成入库单/应付单,不增加可用库存;保留入库单号、仓库、入库价、应付账单号等原值 + // ══════════════════════════════════════════════════════ + if (CollUtil.isNotEmpty(assignSnDataList)) { + List assignSnList = assignSnDataList.stream().map(InventoryInfo::getProductSn).collect(Collectors.toList()); + Map existingAssignMap = new HashMap<>(); + for (InventoryInfo existInfo : inventoryInfoMapper.listByProductSnList(assignSnList)) { + existingAssignMap.put(existInfo.getProductSn(), existInfo); + } + for (InventoryInfo assignInfo : assignSnDataList) { + String productSn = assignInfo.getProductSn(); + InventoryInfo existInfo = existingAssignMap.get(productSn); + if (existInfo == null) { + throw new ServiceException(String.format("SN码[%s]在库存中不存在,发货失败", productSn)); + } + if (StringUtils.isNotEmpty(existInfo.getOuterCode()) || StringUtils.isNotEmpty(existInfo.getOrderCode())) { + throw new ServiceException(String.format("SN码[%s]已发货或已绑定订单,发货失败", productSn)); + } + InventoryInfo updateInfo = new InventoryInfo(); + updateInfo.setProductSn(productSn); + updateInfo.setInventoryStatus(InventoryInfo.InventoryStatusEnum.OUTER.getCode()); + updateInfo.setOuterCode(inventoryDelivery.getOuterCode()); + updateInfo.setOrderCode(inventoryDelivery.getOrderCode()); + updateInfo.setOuterPrice(bigDecimal); + updateInfo.setLicenseKey(assignInfo.getLicenseKey()); + updateInfo.setUpdateBy(currentUserId); + updateInfo.setUpdateTime(nowDate); + inventoryInfoMapper.updateOutForAssignDelivery(updateInfo); + handledSnSet.add(productSn); + + OmsInventoryDeliveryDetail detail = new OmsInventoryDeliveryDetail(); + detail.setProductSn(productSn); + detailList.add(detail); + } + } + if (CollUtil.isEmpty(productSnDataList) && CollUtil.isEmpty(assignSnDataList)) { List inventoryInfoList = productSnList.stream().map(item -> { InventoryInfo info = new InventoryInfo(); info.setProductSn(item); @@ -287,7 +326,7 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService, if (!maintenanceOnly) { inventoryInfoService.saveBatch(inventoryInfoList); } - } else { + } else if (CollUtil.isNotEmpty(productSnDataList)) { Long warehouseId = productSnDataList.get(0).getWarehouseId(); if (warehouseId!=null && !warehouseId.equals(inventoryDelivery.getWarehouseId())){ throw new ServiceException("发货数据仓库与出库单仓库不一致,请确认后重试"); @@ -299,12 +338,20 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService, inventoryInfo.setUpdateTime(nowDate); inventoryInfo.setOuterPrice(bigDecimal); inventoryInfo.setOrderCode(inventoryDelivery.getOrderCode()); + handledSnSet.add(inventoryInfo.getProductSn()); OmsInventoryDeliveryDetail detail = new OmsInventoryDeliveryDetail(); detail.setProductSn(inventoryInfo.getProductSn()); detailList.add(detail); } omsInventoryInnerService.importByOuter(productSnDataList, inventoryDelivery.getProductCode(), inventoryDelivery.getPurchaseNo(), inventoryDelivery.getItemId()); } + // 指定发货/导入与手工勾选混用时,避免手工勾选的SN被静默丢弃 + if ((CollUtil.isNotEmpty(productSnDataList) || CollUtil.isNotEmpty(assignSnDataList)) && CollUtil.isNotEmpty(productSnList)) { + List unhandledSnList = productSnList.stream().filter(item -> !handledSnSet.contains(item)).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(unhandledSnList)) { + throw new ServiceException(String.format("SN码%s未参与本次指定发货/导入清单,请确认发货方式后重试", unhandledSnList)); + } + } InventoryOuterDetail inventoryOuterDetail = new InventoryOuterDetail(); inventoryOuterDetail.setId(inventoryDelivery.getDetailId()); inventoryOuterDetail.setWarehouseId(inventoryDelivery.getWarehouseId()); diff --git a/ruoyi-sip/src/main/resources/mapper/inventory/InventoryInfoMapper.xml b/ruoyi-sip/src/main/resources/mapper/inventory/InventoryInfoMapper.xml index 8f9d5d66..64bdf10c 100644 --- a/ruoyi-sip/src/main/resources/mapper/inventory/InventoryInfoMapper.xml +++ b/ruoyi-sip/src/main/resources/mapper/inventory/InventoryInfoMapper.xml @@ -228,6 +228,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + + update oms_inventory_info + set inventory_status = #{inventoryStatus}, + outer_code = #{outerCode}, + order_code = #{orderCode}, + outer_price = #{outerPrice}, + update_by = #{updateBy}, + update_time = #{updateTime} + + , license_key = #{licenseKey} + + where product_sn = #{productSn} + update oms_inventory_info set inventory_status = 0,outer_code=null