From 85338f79f062e31d1dbb391e99c2ff2ef63f960d Mon Sep 17 00:00:00 2001 From: shenzhouyu Date: Sat, 22 Nov 2025 12:21:11 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E6=96=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ProductionReturnServiceImpl.java | 42 +++++++++++++++++-- .../production/ProductionReturnMapper.xml | 5 +++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gaotao/modules/production/service/impl/ProductionReturnServiceImpl.java b/src/main/java/com/gaotao/modules/production/service/impl/ProductionReturnServiceImpl.java index 7b6eeaa..3b78577 100644 --- a/src/main/java/com/gaotao/modules/production/service/impl/ProductionReturnServiceImpl.java +++ b/src/main/java/com/gaotao/modules/production/service/impl/ProductionReturnServiceImpl.java @@ -191,6 +191,16 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { transCommonRequestDto.setSourceNo(returnDto.getWorkOrderNo()); Double seqNo = 1.0; + List allLocation = productionReturnMapper.getAllLocation(returnDto.getSite()); + Map locationWarehouseMap = allLocation.stream() + .filter(loc -> loc != null + && loc.getLocationId() != null + && !loc.getLocationId().trim().isEmpty()) + .collect(Collectors.toMap( + loc -> loc.getLocationId().trim(), + Location::getWarehouseId, + (oldVal, newVal) -> newVal + )); // 处理每个选择的物料 for (WorkOrderMaterialDto material : returnDto.getSelectedMaterials()) { // 创建出库记录详情 @@ -199,8 +209,11 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { subDto.setPartNo(returnDto.getComponentPartNo()); subDto.setSubNo(material.getLabelCode()); subDto.setBatchNo(material.getBatchNo()); - subDto.setWarehouseId(material.getWarehouseId()); subDto.setLocationId(material.getLocationId()); + String targetWarehouseId = locationWarehouseMap.get(material.getLocationId()); + if (targetWarehouseId != null) { + subDto.setWarehouseId(targetWarehouseId); + } subDto.setTransQty(material.getIssueQty().toString()); subDto.setDirection("+"); subDto.setWdrNo(material.getWdrNo()); @@ -230,7 +243,10 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { HandlingUnit hu = new HandlingUnit(); hu.setUnitId(material.getLabelCode()); hu.setLocationId(material.getLocationId()); - + String targetWarehouseId = locationWarehouseMap.get(material.getLocationId()); + if (targetWarehouseId != null) { + hu.setWarehouseId(targetWarehouseId); + } String unitId = material.getLabelCode(); if (unitId != null && huMap.containsKey(unitId)) { //减去要出的hu上的数量 @@ -348,6 +364,16 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { transCommonRequestDto.setSourceNo(returnDto.getNotifyNo()); Double seqNo = 1.0; + List allLocation = productionReturnMapper.getAllLocation(returnDto.getSite()); + Map locationWarehouseMap = allLocation.stream() + .filter(loc -> loc != null + && loc.getLocationId() != null + && !loc.getLocationId().trim().isEmpty()) + .collect(Collectors.toMap( + loc -> loc.getLocationId().trim(), + Location::getWarehouseId, + (oldVal, newVal) -> newVal + )); // 处理每个选择的物料 for (WorkOrderMaterialDto material : returnDto.getSelectedMaterials()) { // 验证物料匹配 @@ -369,8 +395,12 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { subDto.setPartNo(returnDto.getComponentPartNo()); subDto.setSubNo(material.getLabelCode()); subDto.setBatchNo(material.getBatchNo()); - subDto.setWarehouseId(material.getWarehouseId()); subDto.setLocationId(material.getLocationId()); + String targetWarehouseId = locationWarehouseMap.get(material.getLocationId()); + if (targetWarehouseId != null) { + subDto.setWarehouseId(targetWarehouseId); + } + subDto.setTransQty(material.getIssueQty().toString()); subDto.setDirection("+"); subDto.setWdrNo(material.getWdrNo()); @@ -401,7 +431,11 @@ public class ProductionReturnServiceImpl implements ProductionReturnService { for (WorkOrderMaterialDto material : returnDto.getSelectedMaterials()) { HandlingUnit hu = new HandlingUnit(); hu.setUnitId(material.getLabelCode()); - hu.setLocationId(material.getLocationId()); + hu.setWarehouseId(material.getWarehouseId()); + String targetWarehouseId = locationWarehouseMap.get(material.getLocationId()); + if (targetWarehouseId != null) { + hu.setWarehouseId(targetWarehouseId); + } String unitId = material.getLabelCode(); if (unitId != null && huMap.containsKey(unitId)) { diff --git a/src/main/resources/mapper/production/ProductionReturnMapper.xml b/src/main/resources/mapper/production/ProductionReturnMapper.xml index 4882ac7..9e98078 100644 --- a/src/main/resources/mapper/production/ProductionReturnMapper.xml +++ b/src/main/resources/mapper/production/ProductionReturnMapper.xml @@ -56,6 +56,11 @@ WHEN #{hu.unitId} THEN #{hu.locationId} END, + warehouse_id = CASE unit_id + + WHEN #{hu.unitId} THEN #{hu.warehouseId} + + END, qty = CASE unit_id WHEN #{hu.unitId} THEN #{hu.qty}