fix(outbound): 解决出库物料扫描记录中的空指针异常问题

- 添加 Objects 工具类导入用于空值检查
- 为 batchNo 字段添加安全的 getter 方法,避免空指针异常
- 为 serialNo 字段添加安全的 getter 方法,避免空指针异常
- 为 binNo 字段添加安全的 getter 方法,避免空指针异常
- 更新所有组合键方法使用新的安全 getter 方法
- 确保在构建组合键时正确处理空值情况
This commit is contained in:
曹鹏飞 2026-03-20 11:58:15 +08:00
parent 5738a4309e
commit 6983786067
1 changed files with 22 additions and 9 deletions

View File

@ -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();
}
}