调整年龄插入
This commit is contained in:
parent
e88c2f25b3
commit
f685389455
@ -81,10 +81,34 @@ public class NumberUtils {
|
||||
* @param idCard 身份证号码
|
||||
* @return 年龄
|
||||
*/
|
||||
public static Integer calculateAgeFromIdCard(String idCard) {
|
||||
String yearStr = idCard.substring(6, 10); // 提取出生年份(假设为18位身份证)
|
||||
public static String calculateAgeFromIdCard(String idCard) {
|
||||
if (StrUtil.isBlank(idCard) || idCard.length() < 18) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 提取出生年月日
|
||||
String yearStr = idCard.substring(6, 10); // 出生年份
|
||||
String monthStr = idCard.substring(10, 12); // 出生月份
|
||||
String dayStr = idCard.substring(12, 14); // 出生日期
|
||||
|
||||
int birthYear = Integer.parseInt(yearStr);
|
||||
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
|
||||
return currentYear - birthYear;
|
||||
int birthMonth = Integer.parseInt(monthStr);
|
||||
int birthDay = Integer.parseInt(dayStr);
|
||||
|
||||
// 获取当前日期
|
||||
Calendar current = Calendar.getInstance();
|
||||
int currentYear = current.get(Calendar.YEAR);
|
||||
int currentMonth = current.get(Calendar.MONTH) + 1; // Calendar.MONTH 从0开始
|
||||
int currentDay = current.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
// 计算年龄
|
||||
int age = currentYear - birthYear;
|
||||
|
||||
// 如果当前月份小于出生月份,或者当前月份等于出生月份但当前日期小于出生日期,年龄减1
|
||||
if (currentMonth < birthMonth || (currentMonth == birthMonth && currentDay < birthDay)) {
|
||||
age--;
|
||||
}
|
||||
|
||||
return String.valueOf(age);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ public class ecgdataPageReqVO extends PageParam {
|
||||
private String gender;
|
||||
|
||||
@Schema(description = "年龄")
|
||||
private Integer age;
|
||||
private String age;
|
||||
|
||||
@Schema(description = "佩戴开始时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
|
||||
@ -36,7 +36,7 @@ public class ecgdataRespVO {
|
||||
|
||||
@Schema(description = "年龄")
|
||||
@ExcelProperty("年龄")
|
||||
private Integer age;
|
||||
private String age;
|
||||
|
||||
@Schema(description = "佩戴开始时间")
|
||||
@ExcelProperty("佩戴开始时间")
|
||||
|
||||
@ -29,7 +29,7 @@ public class ecgdataSaveReqVO {
|
||||
private String gender;
|
||||
|
||||
@Schema(description = "年龄")
|
||||
private Integer age;
|
||||
private String age;
|
||||
|
||||
@Schema(description = "佩戴开始时间")
|
||||
private LocalDateTime wearstarttime;
|
||||
|
||||
@ -34,7 +34,7 @@ public class EraRespVO {
|
||||
|
||||
@Schema(description = "年龄")
|
||||
@ExcelProperty("年龄")
|
||||
private Integer age;
|
||||
private String age;
|
||||
|
||||
@Schema(description = "机构ID", example = "29370")
|
||||
@ExcelProperty("机构ID")
|
||||
|
||||
@ -27,7 +27,7 @@ public class Spo2infoPageReqVO extends PageParam {
|
||||
private String gender;
|
||||
|
||||
@Schema(description = "年龄")
|
||||
private Integer age;
|
||||
private String age;
|
||||
|
||||
@Schema(description = "佩戴时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
|
||||
@ -34,7 +34,7 @@ public class Spo2infoRespVO {
|
||||
|
||||
@Schema(description = "年龄")
|
||||
@ExcelProperty("年龄")
|
||||
private Integer age;
|
||||
private String age;
|
||||
|
||||
@Schema(description = "佩戴时间")
|
||||
@ExcelProperty("佩戴时间")
|
||||
|
||||
@ -27,7 +27,7 @@ public class Spo2infoSaveReqVO {
|
||||
private String gender;
|
||||
|
||||
@Schema(description = "年龄")
|
||||
private Integer age;
|
||||
private String age;
|
||||
|
||||
@Schema(description = "佩戴时间")
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.staticecg.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.staticecg.StaticecgDO;
|
||||
import cn.iocoder.yudao.module.system.service.staticecg.StaticecgService;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.patientinfo.vo.patientinfoRespVO;
|
||||
|
||||
@Tag(name = "管理后台 - 静态心电图数据")
|
||||
@RestController
|
||||
@ -47,8 +48,8 @@ public class StaticecgController {
|
||||
@PostMapping("/insert-ecg-patient-data")
|
||||
@Operation(summary = "批量新增ECG患者数据")
|
||||
@ApiAccessLog(operateType = CREATE)
|
||||
public CommonResult<Boolean> insertEcgPatientData(@Valid @RequestBody List<StaticecgSaveReqVO> createReqVOList) {
|
||||
staticecgService.insertEcgPatientDataList(createReqVOList);
|
||||
public CommonResult<Boolean> insertEcgPatientData(@Valid @RequestBody List<patientinfoRespVO> patientInfoList) {
|
||||
staticecgService.insertEcgPatientDataList(patientInfoList);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ public class ecgdataDO{
|
||||
* 年龄
|
||||
*/
|
||||
@TableField("age")
|
||||
private Integer age;
|
||||
private String age;
|
||||
/**
|
||||
* 佩戴开始时间
|
||||
*/
|
||||
|
||||
@ -51,7 +51,7 @@ public class EraDO {
|
||||
* 年龄
|
||||
*/
|
||||
@TableField("age")
|
||||
private Integer age;
|
||||
private String age;
|
||||
/**
|
||||
* 机构ID
|
||||
*/
|
||||
|
||||
@ -52,7 +52,7 @@ public class Spo2infoDO {
|
||||
* 年龄
|
||||
*/
|
||||
@TableField("age")
|
||||
private Integer age;
|
||||
private String age;
|
||||
/**
|
||||
* 佩戴时间
|
||||
*/
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package cn.iocoder.yudao.module.system.service.abpm;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.patientinfo.vo.patientinfoRespVO;
|
||||
import com.alibaba.excel.util.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -100,6 +102,12 @@ public class abpmServiceImpl implements abpmService {
|
||||
abpm.setExamid(examId);
|
||||
abpm.setName(patientInfo.getName());
|
||||
abpm.setGender(patientInfo.getGender());
|
||||
// 根据身份证号计算年龄
|
||||
String idCard = patientInfo.getIdcard();
|
||||
if (StringUtils.isNotBlank(idCard)) {
|
||||
String age = NumberUtils.calculateAgeFromIdCard(idCard);
|
||||
abpm.setAge(age);
|
||||
}
|
||||
abpm.setOrgid(patientInfo.getOrgid());
|
||||
abpm.setOrgname(patientInfo.getOrgname());
|
||||
abpm.setStatus(0); // 默认状态:0未申请
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.system.service.arterial;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import com.alibaba.excel.util.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -99,6 +101,12 @@ public class arterialServiceImpl implements arterialService {
|
||||
arterial.setExamid(examId);
|
||||
arterial.setName(patientInfo.getName());
|
||||
arterial.setGender(patientInfo.getGender());
|
||||
// 根据身份证号计算年龄
|
||||
String idCard = patientInfo.getIdcard();
|
||||
if (StringUtils.isNotBlank(idCard)) {
|
||||
String age = NumberUtils.calculateAgeFromIdCard(idCard);
|
||||
arterial.setAge(age);
|
||||
}
|
||||
arterial.setOrgid(patientInfo.getOrgid());
|
||||
arterial.setOrgname(patientInfo.getOrgname());
|
||||
arterial.setStatus(0); // 默认状态:0申请中
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.system.service.cgm;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import com.alibaba.excel.util.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -101,6 +103,12 @@ public class CgmServiceImpl implements CgmService {
|
||||
cgm.setName(patientInfo.getName());
|
||||
cgm.setGender(patientInfo.getGender());
|
||||
cgm.setOrgid(patientInfo.getOrgid());
|
||||
// 根据身份证号计算年龄
|
||||
String idCard = patientInfo.getIdcard();
|
||||
if (StringUtils.isNotBlank(idCard)) {
|
||||
String age = NumberUtils.calculateAgeFromIdCard(idCard);
|
||||
cgm.setAge(age);
|
||||
}
|
||||
cgm.setOrgname(patientInfo.getOrgname());
|
||||
cgm.setStatus(0); // 默认状态:0申请中
|
||||
cgmDataList.add(cgm);
|
||||
|
||||
@ -7,7 +7,6 @@ import com.alibaba.excel.util.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.ecgdata.vo.*;
|
||||
@ -150,7 +149,7 @@ public class ecgdataServiceImpl implements ecgdataService {
|
||||
// 根据身份证号计算年龄
|
||||
String idCard = patientInfo.getIdcard();
|
||||
if (StringUtils.isNotBlank(idCard)) {
|
||||
Integer age = NumberUtils.calculateAgeFromIdCard(idCard);
|
||||
String age = NumberUtils.calculateAgeFromIdCard(idCard);
|
||||
ecgdata.setAge(age);
|
||||
}
|
||||
ecgdata.setOrgid(patientInfo.getOrgid());
|
||||
|
||||
@ -106,7 +106,7 @@ public class EraServiceImpl implements EraService {
|
||||
// 根据身份证号计算年龄
|
||||
String idCard = patientInfo.getIdcard();
|
||||
if (StringUtils.isNotBlank(idCard)) {
|
||||
Integer age = NumberUtils.calculateAgeFromIdCard(idCard);
|
||||
String age = NumberUtils.calculateAgeFromIdCard(idCard);
|
||||
eraDO.setAge(age);
|
||||
}
|
||||
eraDO.setOrgid(patientInfo.getOrgid());
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.system.service.pft;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import com.alibaba.excel.util.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -78,6 +80,12 @@ public class PftServiceImpl implements PftService {
|
||||
pft.setExamid(examId);
|
||||
pft.setName(patientInfo.getName());
|
||||
pft.setGender(patientInfo.getGender());
|
||||
// 根据身份证号计算年龄
|
||||
String idCard = patientInfo.getIdcard();
|
||||
if (StringUtils.isNotBlank(idCard)) {
|
||||
String age = NumberUtils.calculateAgeFromIdCard(idCard);
|
||||
pft.setAge(age);
|
||||
}
|
||||
pft.setOrgid(patientInfo.getOrgid());
|
||||
pft.setOrgname(patientInfo.getOrgname());
|
||||
pft.setStatus(0); // 默认状态:0申请中
|
||||
|
||||
@ -65,7 +65,7 @@ public class Spo2infoServiceImpl implements Spo2infoService {
|
||||
// 根据身份证号计算年龄
|
||||
String idCard = patientInfo.getIdcard();
|
||||
if (StringUtils.isNotBlank(idCard)) {
|
||||
Integer age = NumberUtils.calculateAgeFromIdCard(idCard);
|
||||
String age = NumberUtils.calculateAgeFromIdCard(idCard);
|
||||
spo2infoDO.setAge(age);
|
||||
}
|
||||
spo2infoDO.setOrgid(patientInfo.getOrgid());
|
||||
|
||||
@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.system.controller.admin.staticecg.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.staticecg.StaticecgDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.patientinfo.vo.patientinfoRespVO;
|
||||
|
||||
/**
|
||||
* 静态心电图数据 Service 接口
|
||||
@ -62,8 +63,8 @@ public interface StaticecgService {
|
||||
/**
|
||||
* 批量插入ECG患者数据
|
||||
*
|
||||
* @param createReqVOList 批量创建信息
|
||||
* @param patientInfoList 患者信息列表
|
||||
*/
|
||||
void insertEcgPatientDataList(List<StaticecgSaveReqVO> createReqVOList);
|
||||
void insertEcgPatientDataList(List<patientinfoRespVO> patientInfoList);
|
||||
|
||||
}
|
||||
@ -12,6 +12,9 @@ import cn.iocoder.yudao.module.system.dal.dataobject.staticecg.StaticecgDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.patientinfo.vo.patientinfoRespVO;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import com.alibaba.excel.util.StringUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.staticecg.StaticecgMapper;
|
||||
|
||||
@ -89,24 +92,30 @@ public class StaticecgServiceImpl implements StaticecgService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void insertEcgPatientDataList(List<StaticecgSaveReqVO> createReqVOList) {
|
||||
if (CollUtil.isEmpty(createReqVOList)) {
|
||||
return;
|
||||
public void insertEcgPatientDataList(List<patientinfoRespVO> patientInfoList) {
|
||||
if (CollUtil.isNotEmpty(patientInfoList)) {
|
||||
List<StaticecgDO> staticecgDOList = new ArrayList<>();
|
||||
for (patientinfoRespVO patientInfo : patientInfoList) {
|
||||
StaticecgDO staticecgDO = new StaticecgDO();
|
||||
|
||||
staticecgDO.setRegid(patientInfo.getRegid());
|
||||
String examId = UUID.randomUUID().toString().replaceAll("-", ""); // 去除横线保持简洁
|
||||
staticecgDO.setExamid(examId);
|
||||
staticecgDO.setName(patientInfo.getName());
|
||||
staticecgDO.setGender(patientInfo.getGender());
|
||||
// 根据身份证号计算年龄
|
||||
String idCard = patientInfo.getIdcard();
|
||||
if (StringUtils.isNotBlank(idCard)) {
|
||||
String age = NumberUtils.calculateAgeFromIdCard(idCard);
|
||||
staticecgDO.setAge(age);
|
||||
}
|
||||
staticecgDO.setOrgid(patientInfo.getOrgid());
|
||||
staticecgDO.setOrgname(patientInfo.getOrgname());
|
||||
staticecgDOList.add(staticecgDO);
|
||||
}
|
||||
// 批量插入ECG患者数据
|
||||
staticecgMapper.insertBatch(staticecgDOList);
|
||||
}
|
||||
// 批量转换为 DO 对象
|
||||
List<StaticecgDO> staticecgList = BeanUtils.toBean(createReqVOList, StaticecgDO.class);
|
||||
|
||||
// 为每条记录设置默认值
|
||||
for (StaticecgDO staticecg : staticecgList) {
|
||||
// 生成UUID作为examid,去除横线
|
||||
String examId = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
staticecg.setExamid(examId);
|
||||
// 设置默认状态:0未申请
|
||||
staticecg.setStatus(0);
|
||||
}
|
||||
|
||||
// 批量插入
|
||||
staticecgMapper.insertBatch(staticecgList);
|
||||
}
|
||||
|
||||
}
|
||||
@ -108,7 +108,7 @@ aj:
|
||||
cache-number: 1000 # local 缓存的阈值,达到这个值,清除缓存
|
||||
timing-clear: 180 # local定时清除过期缓存(单位秒),设置为0代表不执行
|
||||
type: blockPuzzle # 验证码类型 default两种都实例化。 blockPuzzle 滑块拼图 clickWord 文字点选
|
||||
water-mark: 芋道源码 # 右下角水印文字(我的水印),可使用 https://tool.chinaz.com/tools/unicode.aspx 中文转 Unicode,Linux 可能需要转 unicode
|
||||
water-mark: 艾康菲 # 右下角水印文字(我的水印),可使用 https://tool.chinaz.com/tools/unicode.aspx 中文转 Unicode,Linux 可能需要转 unicode
|
||||
interference-options: 0 # 滑动干扰项(0/1/2)
|
||||
req-frequency-limit-enable: false # 接口请求次数一分钟限制是否开启 true|false
|
||||
req-get-lock-limit: 5 # 验证失败 5 次,get接口锁定
|
||||
|
||||
Loading…
Reference in New Issue
Block a user