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) {