fix: 修复空字段导致的导入问题

This commit is contained in:
han0
2024-06-03 17:22:24 +08:00
parent d65898eeee
commit ae6212db49
3 changed files with 20 additions and 17 deletions

View File

@@ -57,10 +57,11 @@ public class AsphaltDomestic extends Model<AsphaltDomestic> {
public AsphaltDomestic () {} public AsphaltDomestic () {}
public AsphaltDomestic (Row row) { public AsphaltDomestic (Row row) {
this.setName(row.getCell(0).getStringCellValue()); var policy = Row.MissingCellPolicy.CREATE_NULL_AS_BLANK;
this.setPrice(BigDecimal.valueOf(row.getCell(1).getNumericCellValue())); this.setName(row.getCell(0, policy).getStringCellValue());
this.setDate(row.getCell(2).getLocalDateTimeCellValue().toLocalDate()); this.setPrice(BigDecimal.valueOf(row.getCell(1, policy).getNumericCellValue()));
this.setFrom(row.getCell(3).getStringCellValue()); this.setDate(row.getCell(2, policy).getLocalDateTimeCellValue().toLocalDate());
this.setFrom(row.getCell(3, policy).getStringCellValue());
} }
public AsphaltDomestic update(AsphaltDomestic item) { public AsphaltDomestic update(AsphaltDomestic item) {

View File

@@ -66,13 +66,14 @@ public class SanmingSteel extends Model<SanmingSteel> {
public SanmingSteel () {} public SanmingSteel () {}
public SanmingSteel (Row row) { public SanmingSteel (Row row) {
var policy = Row.MissingCellPolicy.CREATE_NULL_AS_BLANK;
row.getCell(1).setCellType(CellType.STRING); row.getCell(1).setCellType(CellType.STRING);
this.setName(row.getCell(0).getStringCellValue()); this.setName(row.getCell(0, policy).getStringCellValue());
this.setSpec(row.getCell(1).getStringCellValue()); this.setSpec(row.getCell(1, policy).getStringCellValue());
this.setMaterial(row.getCell(2).getStringCellValue()); this.setMaterial(row.getCell(2, policy).getStringCellValue());
this.setPrice(BigDecimal.valueOf(row.getCell(3).getNumericCellValue())); this.setPrice(BigDecimal.valueOf(row.getCell(3, policy).getNumericCellValue()));
this.setFluctuating(BigDecimal.valueOf(row.getCell(4).getNumericCellValue())); this.setFluctuating(BigDecimal.valueOf(row.getCell(4, policy).getNumericCellValue()));
this.setDate(row.getCell(5).getLocalDateTimeCellValue().toLocalDate()); this.setDate(row.getCell(5, policy).getLocalDateTimeCellValue().toLocalDate());
} }
public SanmingSteel update(SanmingSteel item) { public SanmingSteel update(SanmingSteel item) {

View File

@@ -31,14 +31,15 @@ public class SteelEntity<T extends Model<?>> extends Model<T> {
} }
public void fromRow(Row row) { public void fromRow(Row row) {
var policy = Row.MissingCellPolicy.CREATE_NULL_AS_BLANK;
row.getCell(1).setCellType(CellType.STRING); row.getCell(1).setCellType(CellType.STRING);
this.setName(row.getCell(0).getStringCellValue()); this.setName(row.getCell(0, policy).getStringCellValue());
this.setSpec(row.getCell(1).getStringCellValue()); this.setSpec(row.getCell(1, policy).getStringCellValue());
this.setMaterial(row.getCell(2).getStringCellValue()); this.setMaterial(row.getCell(2, policy).getStringCellValue());
this.setSource(row.getCell(3).getStringCellValue()); this.setSource(row.getCell(3, policy).getStringCellValue());
this.setPrice(BigDecimal.valueOf(row.getCell(4).getNumericCellValue())); this.setPrice(BigDecimal.valueOf(row.getCell(4, policy).getNumericCellValue()));
this.setFluctuating(BigDecimal.valueOf(row.getCell(5).getNumericCellValue())); this.setFluctuating(BigDecimal.valueOf(row.getCell(5, policy).getNumericCellValue()));
this.setDate(row.getCell(6).getLocalDateTimeCellValue().toLocalDate()); this.setDate(row.getCell(6, policy).getLocalDateTimeCellValue().toLocalDate());
} }
public SteelEntity() {} public SteelEntity() {}