Browse Source

导入报错修改

anderx 1 week ago
parent
commit
888dfa30c3

+ 5 - 0
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/entity/XmGoodsEntity.java

@@ -43,24 +43,29 @@ public class XmGoodsEntity extends TenantEntity {
 	private Long xmId;
 
 	@Schema(description = "类型")
+	@NotNull(message = "类型")
 	private String type;
 
 	@Schema(description = "编号")
 	private String code;
 
 	@Schema(description = "名称")
+	@NotNull(message = "名称")
 	private String name;
 
 	@Schema(description = "规格型号")
 	private String model;
 
 	@Schema(description = "单位")
+	@NotNull(message = "单位")
 	private String unit;
 
 	@Schema(description = "单价(元)")
+	@NotNull(message = "单价(元)")
 	private BigDecimal unitPrice;
 
 	@Schema(description = "领用数量")
+	@NotNull(message = "领用数量")
 	private Double useQuantity;
 
 	@Schema(description = "金额")

+ 15 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/excel/listener/XmGoodsImportListener.java

@@ -67,8 +67,22 @@ public class XmGoodsImportListener extends BaseReadListener {
 				errors.add("领取数量须为数字,且大于等于0");
 			}
 			excel.setUseQuantity(tmp);
+		}else{
+			excel.setUseQuantity(0.0);
 		}
-		excel.setAmount(BigDecimal.valueOf(excel.getUseQuantity()).multiply(excel.getUnitPrice()));
+		if(Func.isNotBlank(useQuantity)){
+			excel.setUseQuantity(ValidationUtils.safeParseDouble(useQuantity));
+			if (Func.isNull(excel.getUseQuantity())) {
+				errors.add("领取数量数据格式错误");
+			}
+		}
+		if(Func.isNotBlank(unitPrice)){
+			excel.setUnitPrice(ValidationUtils.safeParseBigDecimal(unitPrice));
+		}
+		if (excel.getUseQuantity() != null && excel.getUnitPrice() != null){
+			excel.setAmount(BigDecimal.valueOf(excel.getUseQuantity()).multiply(excel.getUnitPrice()));
+		}
+
 
 		errors.addAll(ValidationUtils.validate(excel));
 		if (!errors.isEmpty()) {