feat: 修复部分数据解析异常的问题

This commit is contained in:
han0
2024-06-03 15:57:59 +08:00
parent 9bb201b460
commit d65898eeee
3 changed files with 6 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
package mjkf.xinke.main.model.db; package mjkf.xinke.main.model.db;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
@@ -87,7 +88,7 @@ public class FujianSurvey extends Model<FujianSurvey> {
if (this.getName().isEmpty()) { if (this.getName().isEmpty()) {
throw new IllegalArgumentException("名称为空"); throw new IllegalArgumentException("名称为空");
} }
if (((Integer) this.getPrice().intValue()).equals(0)) { if (ObjectUtil.isEmpty(this.getPrice())) {
throw new IllegalArgumentException("缺少价格"); throw new IllegalArgumentException("缺少价格");
} }
} }

View File

@@ -12,6 +12,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
/** /**
@@ -65,6 +66,7 @@ public class SanmingSteel extends Model<SanmingSteel> {
public SanmingSteel () {} public SanmingSteel () {}
public SanmingSteel (Row row) { public SanmingSteel (Row row) {
row.getCell(1).setCellType(CellType.STRING);
this.setName(row.getCell(0).getStringCellValue()); this.setName(row.getCell(0).getStringCellValue());
this.setSpec(row.getCell(1).getStringCellValue()); this.setSpec(row.getCell(1).getStringCellValue());
this.setMaterial(row.getCell(2).getStringCellValue()); this.setMaterial(row.getCell(2).getStringCellValue());

View File

@@ -3,6 +3,7 @@ package mjkf.xinke.main.model.db;
import com.baomidou.mybatisplus.extension.activerecord.Model; import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data; import lombok.Data;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -30,6 +31,7 @@ public class SteelEntity<T extends Model<?>> extends Model<T> {
} }
public void fromRow(Row row) { public void fromRow(Row row) {
row.getCell(1).setCellType(CellType.STRING);
this.setName(row.getCell(0).getStringCellValue()); this.setName(row.getCell(0).getStringCellValue());
this.setSpec(row.getCell(1).getStringCellValue()); this.setSpec(row.getCell(1).getStringCellValue());
this.setMaterial(row.getCell(2).getStringCellValue()); this.setMaterial(row.getCell(2).getStringCellValue());