diff --git a/src/main/java/com/gaotao/modules/crossAreaTransfer/service/impl/CrossAreaTransferServiceImpl.java b/src/main/java/com/gaotao/modules/crossAreaTransfer/service/impl/CrossAreaTransferServiceImpl.java index ddbce6f..29e6288 100644 --- a/src/main/java/com/gaotao/modules/crossAreaTransfer/service/impl/CrossAreaTransferServiceImpl.java +++ b/src/main/java/com/gaotao/modules/crossAreaTransfer/service/impl/CrossAreaTransferServiceImpl.java @@ -149,7 +149,7 @@ public class CrossAreaTransferServiceImpl extends ServiceImpl outboundParams = new ArrayList<>(); outboundParams.add(site); // 参数1: site @@ -160,7 +160,7 @@ public class CrossAreaTransferServiceImpl extends ServiceImpl> outboundResultList = procedureMapper.getProcedureData("GetSaveLabelVerification", outboundParams); @@ -178,34 +178,41 @@ public class CrossAreaTransferServiceImpl extends ServiceImpl inboundParams = new ArrayList<>(); inboundParams.add(site); // 参数1: site inboundParams.add(buNo); // 参数2: buNo - inboundParams.add(""); // 参数3: 空字符串 + // 参数3: 传递出库返回的transNo + inboundParams.add(outboundTransNo != null && !"null".equals(outboundTransNo) && !"*".equals(outboundTransNo) ? outboundTransNo : ""); inboundParams.add(""); // 参数4: 空字符串 inboundParams.add(""); // 参数5: 空字符串 inboundParams.add("label".equals(transferMode) ? "标签" : "库位"); // 参数6: 扫描的类型 "标签/库位" inboundParams.add(sourceLocation); // 参数7: 扫描的标签条码/库位号 inboundParams.add(targetLocation != null ? targetLocation : ""); // 参数8: 保存时的库位(目标库位) - inboundParams.add("跨区调拨-入库"); // 参数9: 跨区调拨-入库 + inboundParams.add("调拨入库"); // 参数9: 调拨入库 inboundParams.add(operator); // 参数10: 当前登陆人 List> inboundResultList = procedureMapper.getProcedureData("GetSaveLabelVerification", inboundParams); @@ -223,17 +230,20 @@ public class CrossAreaTransferServiceImpl extends ServiceImpl= originalQuantity) { - throw new RuntimeException("拆分数量必须大于0且小于原数量"); + if (splitCount <= 0) { + throw new RuntimeException("拆分张数必须大于0"); } - - // 1. 生成新的标签条码 - TransNoControl transNoControl = transNoControlService.getTransNo(site, "LabelNo", buNo); - if (transNoControl == null) { - throw new RuntimeException("生成标签条码失败"); - } - String newLabelCode = transNoControl.getNewTransNo(); - - if (newLabelCode == null || newLabelCode.trim().isEmpty()) { - throw new RuntimeException("生成新标签条码失败"); + if (splitQuantity <= 0 || totalSplitQuantity >= originalQuantity) { + throw new RuntimeException("拆分总数量必须大于0且小于原数量"); } // 2. 更新原标签的库存数量 @@ -115,45 +111,61 @@ public class LabelSplitMergeServiceImpl extends ServiceImpl insertParams = new HashMap<>(); - insertParams.put("site", site); - insertParams.put("buNo", buNo); - insertParams.put("rollNo", newLabelCode); - insertParams.put("parentRollNo", newLabelCode); - insertParams.put("partNo", partNo); - insertParams.put("labelTypeTb", params.get("labelTypeTb")); - insertParams.put("labelType", params.get("labelType")); - insertParams.put("warehouseId", warehouseId); - insertParams.put("locationId", locationId); - insertParams.put("batchNo", batchNo); - insertParams.put("wdr", params.get("wdr")); - insertParams.put("statusTb", params.get("statusTb")); - insertParams.put("status", params.get("status")); - insertParams.put("firstInDate", params.get("firstInDate")); - insertParams.put("latestInDate", new Date()); - insertParams.put("activeDate", new Date()); - insertParams.put("inQty", splitQuantity); - insertParams.put("outQty", 0.0f); - insertParams.put("qtyOnHand", splitQuantity); - insertParams.put("qtyReserved", 0.0f); - insertParams.put("freezeFlag", params.get("freezeFlag")); - insertParams.put("manufactureDate", params.get("manufactureDate")); - insertParams.put("expiredDate", params.get("expiredDate")); - insertParams.put("orderref0", "标签拆分入库"); - insertParams.put("orderref1", params.get("orderref1")); - insertParams.put("orderref2", params.get("orderref2")); - insertParams.put("orderref3", params.get("orderref3")); - - int insertCount = labelSplitMergeMapper.insertInventoryStock(insertParams); - if (insertCount == 0) { - throw new RuntimeException("创建新标签库存失败"); - } + // 3. 循环创建多张新标签的库存记录 + List newLabelCodes = new ArrayList<>(); + for (int i = 0; i < splitCount; i++) { + // 生成新的标签条码 + TransNoControl transNoControl = transNoControlService.getTransNo(site, "LabelNo", buNo); + if (transNoControl == null) { + throw new RuntimeException("生成标签条码失败"); + } + String newLabelCode = transNoControl.getNewTransNo(); - // 5. 生成标签变动事务记录 - generateSplitTransaction(site, buNo, warehouseId, originalLabelCode, newLabelCode, partNo, batchNo, splitQuantity, remainingQuantity, locationId); + if (newLabelCode == null || newLabelCode.trim().isEmpty()) { + throw new RuntimeException("生成新标签条码失败"); + } + newLabelCodes.add(newLabelCode); + + // 创建新标签的库存记录 + Map insertParams = new HashMap<>(); + insertParams.put("site", site); + insertParams.put("buNo", buNo); + insertParams.put("rollNo", newLabelCode); + insertParams.put("parentRollNo", newLabelCode); + insertParams.put("partNo", partNo); + insertParams.put("labelTypeTb", params.get("labelTypeTb")); + insertParams.put("labelType", params.get("labelType")); + insertParams.put("warehouseId", warehouseId); + insertParams.put("locationId", locationId); + insertParams.put("batchNo", batchNo); + insertParams.put("wdr", params.get("wdr")); + insertParams.put("statusTb", params.get("statusTb")); + insertParams.put("status", params.get("status")); + insertParams.put("firstInDate", params.get("firstInDate")); + insertParams.put("latestInDate", new Date()); + insertParams.put("activeDate", new Date()); + insertParams.put("inQty", splitQuantity); + insertParams.put("outQty", 0.0f); + insertParams.put("qtyOnHand", splitQuantity); + insertParams.put("qtyReserved", 0.0f); + insertParams.put("freezeFlag", params.get("freezeFlag")); + insertParams.put("manufactureDate", params.get("manufactureDate")); + insertParams.put("expiredDate", params.get("expiredDate")); + insertParams.put("orderref0", "标签拆分入库"); + insertParams.put("orderref1", params.get("orderref1")); + insertParams.put("orderref2", params.get("orderref2")); + insertParams.put("orderref3", params.get("orderref3")); + + int insertCount = labelSplitMergeMapper.insertInventoryStock(insertParams); + if (insertCount == 0) { + throw new RuntimeException("创建新标签库存失败"); + } - // 6. 获取打印参数列表(拆分需要打印两张标签:原标签和新标签) + // 生成标签变动事务记录 + generateSplitTransaction(site, buNo, warehouseId, originalLabelCode, newLabelCode, partNo, batchNo, splitQuantity, remainingQuantity, locationId); + } + + // 6. 获取打印参数列表(拆分需要打印多张标签:原标签 + 所有新标签) List> printList = new ArrayList<>(); try { // 原标签打印参数 @@ -164,25 +176,30 @@ public class LabelSplitMergeServiceImpl extends ServiceImpl printData2 = wmsPrintDao.callUspPartLabelTemplate( - site, buNo, "*", "", "", "", partNo, "", newLabelCode - ); - if (printData2 != null) { - printList.add(printData2); + // 所有新标签打印参数 + for (String newLabelCode : newLabelCodes) { + Map printData = wmsPrintDao.callUspPartLabelTemplate( + site, buNo, "*", "", "", "", partNo, "", newLabelCode + ); + if (printData != null) { + printList.add(printData); + } } } catch (Exception e) { logger.warn("获取打印参数失败,不影响拆分操作", e); } Map result = new HashMap<>(); - result.put("newLabelCode", newLabelCode); + result.put("newLabelCode", newLabelCodes.isEmpty() ? "" : newLabelCodes.get(0)); // 兼容旧版本 + result.put("newLabelCodes", newLabelCodes); // 新版本返回所有新标签 result.put("originalQuantity", originalQuantity); + result.put("splitCount", splitCount); result.put("splitQuantity", splitQuantity); + result.put("totalSplitQuantity", totalSplitQuantity); result.put("remainingQuantity", remainingQuantity); result.put("printList", printList); - logger.info("标签拆分成功,原标签: {}, 新标签: {}, 拆分数量: {}", originalLabelCode, newLabelCode, splitQuantity); + logger.info("标签拆分成功,原标签: {}, 新标签: {}, 拆分张数: {}, 每张数量: {}", originalLabelCode, newLabelCodes, splitCount, splitQuantity); return result; } catch (Exception e) { diff --git a/src/main/resources/mapper/warehouse/LabelTransactionLogMapper.xml b/src/main/resources/mapper/warehouse/LabelTransactionLogMapper.xml index 3ca1364..75457c5 100644 --- a/src/main/resources/mapper/warehouse/LabelTransactionLogMapper.xml +++ b/src/main/resources/mapper/warehouse/LabelTransactionLogMapper.xml @@ -41,7 +41,7 @@ - AND a.document_type IN ('跨区调拨-出库', '跨区调拨-入库') + AND a.document_type IN ('调拨出库', '调拨入库') AND a.document_type = #{query.documentType} @@ -97,7 +97,7 @@ - AND a.document_type IN ('跨区调拨-出库', '跨区调拨-入库') + AND a.document_type IN ('调拨出库', '调拨入库') AND a.document_type = #{query.documentType}