新疆大屏
This commit is contained in:
+29
-2
@@ -3,6 +3,10 @@ package com.renkang.anyan.model.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Data
|
||||
@Schema(title="重点关爱趋势预警信息",description="重点关爱趋势预警信息")
|
||||
public class CareUserListVo {
|
||||
@@ -19,7 +23,10 @@ public class CareUserListVo {
|
||||
private Integer age;
|
||||
|
||||
@Schema(title = "性别")
|
||||
private String sex;
|
||||
private String sexCode;
|
||||
|
||||
@Schema(title = "身份证号")
|
||||
private String idNo;
|
||||
|
||||
@Schema(title = "工作单位")
|
||||
private String workUnit ;
|
||||
@@ -160,5 +167,25 @@ public class CareUserListVo {
|
||||
return Math.round(bmi * 10) / 10.0;
|
||||
}
|
||||
|
||||
|
||||
public Integer getAge() {
|
||||
if (age != null) {
|
||||
return age;
|
||||
}
|
||||
if (idNo == null || idNo.length() != 18) {
|
||||
return null; // 身份证号无效时返回null
|
||||
}
|
||||
try {
|
||||
// 截取出生日期字符串
|
||||
String birthDateStr = idNo.substring(6, 14);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
LocalDate birthDate = LocalDate.parse(birthDateStr, formatter);
|
||||
LocalDate now = LocalDate.now();
|
||||
if (birthDate.isAfter(now)) {
|
||||
return null; // 出生日期在未来,返回null
|
||||
}
|
||||
return Period.between(birthDate, now).getYears();
|
||||
} catch (Exception e) {
|
||||
return null; // 解析异常返回null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user