From 526ef20b9adf370e5cec21773e3bed3934960791 Mon Sep 17 00:00:00 2001 From: han0 Date: Thu, 30 Nov 2023 16:56:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(material-task):=20=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E7=A6=8F=E5=B7=9E=E4=BA=A4=E9=80=9A=E5=B1=80=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xinke/main/model/db/FujianSurvey.java | 7 ++++ .../main/model/db/FuzhouHighwayBureau.java | 35 ++++++++++++++++--- .../model/db/FuzhouTransportationBureau.java | 35 ++++++++++++++++--- 3 files changed, 69 insertions(+), 8 deletions(-) diff --git a/src/main/java/mjkf/xinke/main/model/db/FujianSurvey.java b/src/main/java/mjkf/xinke/main/model/db/FujianSurvey.java index d04866d..c9e2c0a 100644 --- a/src/main/java/mjkf/xinke/main/model/db/FujianSurvey.java +++ b/src/main/java/mjkf/xinke/main/model/db/FujianSurvey.java @@ -84,9 +84,16 @@ public class FujianSurvey extends Model { this.setPrice(BigDecimal.valueOf(row.getCell(5, policy).getNumericCellValue())); this.setTax(((Double) row.getCell(6, policy).getNumericCellValue()).intValue()); this.setDate(row.getCell(7, policy).getLocalDateTimeCellValue().toLocalDate()); + if (this.getName().isEmpty()) { + throw new IllegalArgumentException("名称为空"); + } + if (((Integer) this.getPrice().intValue()).equals(0)) { + throw new IllegalArgumentException("缺少价格"); + } } public FujianSurvey update(FujianSurvey item) { + this.setMaterialId(item.getMaterialId()); this.setName(item.getName()); this.setSpec(item.getSpec()); this.setPrice(item.getPrice()); diff --git a/src/main/java/mjkf/xinke/main/model/db/FuzhouHighwayBureau.java b/src/main/java/mjkf/xinke/main/model/db/FuzhouHighwayBureau.java index 670c87f..be98992 100644 --- a/src/main/java/mjkf/xinke/main/model/db/FuzhouHighwayBureau.java +++ b/src/main/java/mjkf/xinke/main/model/db/FuzhouHighwayBureau.java @@ -12,6 +12,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; /** @@ -49,6 +50,18 @@ public class FuzhouHighwayBureau extends Model { @TableField("`DATE`") private LocalDate date; + @ApiModelProperty("材料id") + @TableField("`MATERIAL_ID`") + private String materialId; + + @ApiModelProperty("单位") + @TableField("`UNIT`") + private String unit; + + @ApiModelProperty("品牌") + @TableField("`BRAND`") + private String brand; + @Override public Serializable pkVal() { return this.id; @@ -57,16 +70,30 @@ public class FuzhouHighwayBureau extends Model { public FuzhouHighwayBureau () {} public FuzhouHighwayBureau (Row row) { - this.setName(row.getCell(0).getStringCellValue()); - this.setSpec(row.getCell(1).getStringCellValue()); - this.setPrice(BigDecimal.valueOf(row.getCell(2).getNumericCellValue())); - this.setDate(row.getCell(3).getLocalDateTimeCellValue().toLocalDate()); + var policy = Row.MissingCellPolicy.CREATE_NULL_AS_BLANK; + row.getCell(0, policy).setCellType(CellType.STRING); + this.setMaterialId(row.getCell(0, policy).getStringCellValue()); + this.setName(row.getCell(1, policy).getStringCellValue()); + this.setSpec(row.getCell(2, policy).getStringCellValue()); + this.setUnit(row.getCell(3, policy).getStringCellValue()); + this.setBrand(row.getCell(4, policy).getStringCellValue()); + this.setPrice(BigDecimal.valueOf(row.getCell(5, policy).getNumericCellValue())); + this.setDate(row.getCell(6, policy).getLocalDateTimeCellValue().toLocalDate()); + if (this.getName().isEmpty()) { + throw new IllegalArgumentException("名称为空"); + } + if (((Integer) this.getPrice().intValue()).equals(0)) { + throw new IllegalArgumentException("缺少价格"); + } } public FuzhouHighwayBureau update(FuzhouHighwayBureau item) { + this.setMaterialId(item.getMaterialId()); this.setName(item.getName()); this.setSpec(item.getSpec()); this.setPrice(item.getPrice()); + this.setUnit(item.getUnit()); + this.setBrand(item.getBrand()); this.setDate(item.getDate()); return this; } diff --git a/src/main/java/mjkf/xinke/main/model/db/FuzhouTransportationBureau.java b/src/main/java/mjkf/xinke/main/model/db/FuzhouTransportationBureau.java index 0dc8563..8133752 100644 --- a/src/main/java/mjkf/xinke/main/model/db/FuzhouTransportationBureau.java +++ b/src/main/java/mjkf/xinke/main/model/db/FuzhouTransportationBureau.java @@ -12,6 +12,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; /** @@ -49,6 +50,18 @@ public class FuzhouTransportationBureau extends Model