From 698378606739a40c6134c624c1e1af4bbadc22b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Fri, 20 Mar 2026 11:58:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(outbound):=20=E8=A7=A3=E5=86=B3=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E7=89=A9=E6=96=99=E6=89=AB=E6=8F=8F=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E7=A9=BA=E6=8C=87=E9=92=88=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 Objects 工具类导入用于空值检查 - 为 batchNo 字段添加安全的 getter 方法,避免空指针异常 - 为 serialNo 字段添加安全的 getter 方法,避免空指针异常 - 为 binNo 字段添加安全的 getter 方法,避免空指针异常 - 更新所有组合键方法使用新的安全 getter 方法 - 确保在构建组合键时正确处理空值情况 --- .../pojo/document/OutMaterialScanRecord.java | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/document/OutMaterialScanRecord.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/document/OutMaterialScanRecord.java index bec7fa6c..ddfae7b2 100644 --- a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/document/OutMaterialScanRecord.java +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/document/OutMaterialScanRecord.java @@ -9,6 +9,7 @@ import org.springframework.data.mongodb.core.mapping.Document; import java.math.BigDecimal; import java.time.Instant; +import java.util.Objects; @Data @Accessors(chain = true) @@ -43,11 +44,19 @@ public class OutMaterialScanRecord { */ private String batchNo; + public String getBatchNo() { + return Objects.isNull(batchNo) ? "" : batchNo; + } + /** * 序列号 */ private String serialNo; + public String getSerialNo() { + return Objects.isNull(serialNo) ? "" : serialNo; + } + /** * 工厂编号 */ @@ -63,6 +72,10 @@ public class OutMaterialScanRecord { */ private String binNo; + public String getBinNo() { + return Objects.isNull(binNo) ? "" : binNo; + } + /** * 数量 */ @@ -125,62 +138,62 @@ public class OutMaterialScanRecord { private String key; public String getKey() { - return this.materialNo + "|" + this.batchNo + "|" + this.serialNo + "|" + this.factoryNo + "|" + this.warehouseNo; + return this.materialNo + "|" + this.getBatchNo() + "|" + this.getSerialNo() + "|" + this.factoryNo + "|" + this.warehouseNo; } @Transient private String key1; public String getKey1() { - return this.materialNo + "|" + this.serialNo; + return this.materialNo + "|" + this.getSerialNo(); } @Transient private String key3; public String getKey3() { - return this.serialNo + "|" + this.ext; + return this.getSerialNo() + "|" + this.ext; } @Transient private String key4; public String getKey4() { - return ebelp + "|" + this.materialNo + "|" + this.batchNo; + return ebelp + "|" + this.materialNo + "|" + this.getBatchNo(); } @Transient private String key5; public String getKey5() { - return this.ebelp + "|" + this.serialNo; + return this.ebelp + "|" + this.getSerialNo(); } @Transient private String key6; public String getKey6() { - return this.rspos + "|" + this.serialNo; + return this.rspos + "|" + this.getSerialNo(); } @Transient private String key7; public String getKey7() { - return materialNo + "|" + batchNo; + return materialNo + "|" + getBatchNo(); } @Transient private String key8; public String getKey8() { - return materialNo + "|" + batchNo + "|" + this.serialNo; + return materialNo + "|" + getBatchNo() + "|" + this.getSerialNo(); } @Transient private String key9; public String getKey9() { - return materialNo + "|" + batchNo + "|" + this.serialNo + "|" + this.binNo; + return materialNo + "|" + getBatchNo() + "|" + this.getSerialNo() + "|" + this.getBinNo(); } }