From 5716d46783bbbd77088ba7fbb3ec74c3aa3d6cf2 Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Tue, 16 Dec 2025 13:27:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=B8=8A=E7=9A=84=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E5=AF=B9=E5=BA=94=E7=9A=84=E6=A0=87=E7=AD=BEHeight?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=96=99=E5=8F=B7=E5=B8=A6=E5=B0=BE?= =?UTF-8?q?=E7=BC=80widh=E5=8F=96=E5=B0=BE=E7=BC=80=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=B8=A6=E5=B0=BE=E7=BC=80=E4=B9=9F=E4=B8=8D=E6=98=AFkg?= =?UTF-8?q?=E7=9A=84=EF=BC=8Cwidth=E5=8F=96=E6=89=B9=E6=AC=A1=E6=9C=80?= =?UTF-8?q?=E5=90=8E=E4=B8=80=E6=AE=B5=EF=BC=8Clength=3D=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E9=99=A4=E4=BB=A5width=E5=86=8D=E4=B9=98=E4=BB=A51000?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ProductionInboundServiceImpl.java | 44 +++++++++++++++++- .../service/impl/SalesReturnServiceImpl.java | 45 +++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gaotao/modules/production/service/impl/ProductionInboundServiceImpl.java b/src/main/java/com/gaotao/modules/production/service/impl/ProductionInboundServiceImpl.java index e5e98a4..b219c7f 100644 --- a/src/main/java/com/gaotao/modules/production/service/impl/ProductionInboundServiceImpl.java +++ b/src/main/java/com/gaotao/modules/production/service/impl/ProductionInboundServiceImpl.java @@ -818,7 +818,49 @@ public class ProductionInboundServiceImpl implements ProductionInboundService { if (dto.getHeight() != null && dto.getHeight() > 0) { handlingUnit.setHeight(BigDecimal.valueOf(dto.getHeight())); } - + // width 和length是根据料号判断的,如果料号带尾缀,比如70001234-0250, + // 那么width就是250,如果不带尾缀且单位不是kg,width就是1000 + String partNo = inData.getPartNo(); + if (partNo != null && partNo.contains("-")) { + String[] parts = partNo.split("-"); + String suffix = parts[parts.length - 1]; + try { + int widthVal = Integer.parseInt(suffix); + handlingUnit.setWidth(BigDecimal.valueOf(widthVal)); + } catch (NumberFormatException e) { + handlingUnit.setWidth(null); + } + } else { + // 不带尾缀的料号 + if (dto.getUom() != null && !dto.getUom().equalsIgnoreCase("KG") && + !dto.getUom().equalsIgnoreCase("kg")) { + // 从batchNo的最后一段获取width,例如:1347654-1-4-3-500 -> 500 + String batchNo = inData.getBatchNo(); + if (batchNo != null && batchNo.contains("-")) { + String[] batchParts = batchNo.split("-"); + String lastPart = batchParts[batchParts.length - 1]; + try { + int widthVal = Integer.parseInt(lastPart); + handlingUnit.setWidth(BigDecimal.valueOf(widthVal)); + } catch (NumberFormatException e) { + handlingUnit.setWidth(BigDecimal.valueOf(1000)); // 解析失败时默认1000 + } + } else { + handlingUnit.setWidth(BigDecimal.valueOf(1000)); // 没有批次号时默认1000 + } + } else { + handlingUnit.setWidth(null); + } + } + // length就是数量除以width再乘以1000 + if (handlingUnit.getWidth() != null && handlingUnit.getWidth().compareTo(BigDecimal.ZERO) > 0) { + BigDecimal length = handlingUnit.getQty() + .divide(handlingUnit.getWidth(), 6, RoundingMode.HALF_UP) + .multiply(BigDecimal.valueOf(1000)); + handlingUnit.setLength(length); + } else { + handlingUnit.setLength(null); + } // 保存HandlingUnit主记录并检查返回值 boolean saveResult = handlingUnitService.save(handlingUnit); if (!saveResult) { diff --git a/src/main/java/com/gaotao/modules/salesreturn/service/impl/SalesReturnServiceImpl.java b/src/main/java/com/gaotao/modules/salesreturn/service/impl/SalesReturnServiceImpl.java index 276793d..e0dd422 100644 --- a/src/main/java/com/gaotao/modules/salesreturn/service/impl/SalesReturnServiceImpl.java +++ b/src/main/java/com/gaotao/modules/salesreturn/service/impl/SalesReturnServiceImpl.java @@ -353,6 +353,51 @@ public class SalesReturnServiceImpl implements SalesReturnService { handlingUnit.setHeight(BigDecimal.valueOf(dto.getHeight())); } handlingUnit.setExpiredDate(dto.getExpiryDate()!=null ? dto.getExpiryDate() : null); + + // width 和length是根据料号判断的,如果料号带尾缀,比如70001234-0250, + // 那么width就是250,如果不带尾缀且单位不是kg,width就是1000 + String partNo = inData.getPartNo(); + if (partNo != null && partNo.contains("-")) { + String[] parts = partNo.split("-"); + String suffix = parts[parts.length - 1]; + try { + int widthVal = Integer.parseInt(suffix); + handlingUnit.setWidth(BigDecimal.valueOf(widthVal)); + } catch (NumberFormatException e) { + handlingUnit.setWidth(null); + } + } else { + // 不带尾缀的料号 + if (dto.getInvUOM() != null && !dto.getInvUOM().equalsIgnoreCase("KG") && + !dto.getInvUOM().equalsIgnoreCase("kg")) { + // 从batchNo的最后一段获取width,例如:1347654-1-4-3-500 -> 500 + String batchNo = inData.getBatchNo(); + if (batchNo != null && batchNo.contains("-")) { + String[] batchParts = batchNo.split("-"); + String lastPart = batchParts[batchParts.length - 1]; + try { + int widthVal = Integer.parseInt(lastPart); + handlingUnit.setWidth(BigDecimal.valueOf(widthVal)); + } catch (NumberFormatException e) { + handlingUnit.setWidth(BigDecimal.valueOf(1000)); // 解析失败时默认1000 + } + } else { + handlingUnit.setWidth(BigDecimal.valueOf(1000)); // 没有批次号时默认1000 + } + } else { + handlingUnit.setWidth(null); + } + } + // length就是数量除以width再乘以1000 + if (handlingUnit.getWidth() != null && handlingUnit.getWidth().compareTo(BigDecimal.ZERO) > 0) { + BigDecimal length = handlingUnit.getQty() + .divide(handlingUnit.getWidth(), 6, RoundingMode.HALF_UP) + .multiply(BigDecimal.valueOf(1000)); + handlingUnit.setLength(length); + } else { + handlingUnit.setLength(null); + } + // 保存HandlingUnit主记录并检查返回值 boolean saveResult = handlingUnitService.save(handlingUnit); if (!saveResult) {