fix(emergency): 修复一人一案接口VARCHAR列映射Double报类型转换异常
达梦库 EMP_PERSON_FILE 表的 BMI/HEIGHT/WEIGHT/WEIGHT_TARGET 等 列为 VARCHAR 类型,MyBatis 映射到 Double 时报类型转换异常, 将对应 VO 字段改为 String,并在 getBmi() 中解析字符串做保留一位小数。
This commit is contained in:
+14
-8
@@ -63,19 +63,19 @@ public class OnePersonCaseVO {
|
|||||||
private Integer flagFat;
|
private Integer flagFat;
|
||||||
|
|
||||||
@Schema(title = "BMI")
|
@Schema(title = "BMI")
|
||||||
private Double bmi;
|
private String bmi;
|
||||||
|
|
||||||
@Schema(title = "身高")
|
@Schema(title = "身高")
|
||||||
private Double height;
|
private String height;
|
||||||
|
|
||||||
@Schema(title = "体重")
|
@Schema(title = "体重")
|
||||||
private Double weight;
|
private String weight;
|
||||||
|
|
||||||
@Schema(title = "体重管理目标")
|
@Schema(title = "体重管理目标")
|
||||||
private Double targetWeight;
|
private String targetWeight;
|
||||||
|
|
||||||
@Schema(title = "目标BMI")
|
@Schema(title = "目标BMI")
|
||||||
private Double targetBmi;
|
private String targetBmi;
|
||||||
|
|
||||||
@Schema(title = "目前BMI监测值")
|
@Schema(title = "目前BMI监测值")
|
||||||
private String bmiCurrent;
|
private String bmiCurrent;
|
||||||
@@ -244,12 +244,18 @@ public class OnePersonCaseVO {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* BMI 保留一位小数
|
* BMI 保留一位小数
|
||||||
|
* 数据库 BMI 列为 VARCHAR,这里解析为数值后四舍五入
|
||||||
*/
|
*/
|
||||||
public Double getBmi() {
|
public String getBmi() {
|
||||||
if (bmi == null) {
|
if (bmi == null || bmi.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Math.round(bmi * 10) / 10.0;
|
try {
|
||||||
|
double v = Double.parseDouble(bmi.trim());
|
||||||
|
return String.valueOf(Math.round(v * 10) / 10.0);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return bmi;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user