From f3d71f95e7c848e411335924d9092d39d88f2623 Mon Sep 17 00:00:00 2001 From: liuhongrui Date: Mon, 3 Mar 2025 16:31:00 +0800 Subject: [PATCH] up --- .../PatientInformationController.java | 16 +++++++++----- .../service/IPatientService.java | 8 +++++++ .../service/impl/PatientServiceImpl.java | 21 ++++++++++++++++++- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/controller/PatientInformationController.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/controller/PatientInformationController.java index 4b387c00..443d6c75 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/controller/PatientInformationController.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/controller/PatientInformationController.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import com.core.common.utils.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -11,10 +12,6 @@ import org.springframework.web.bind.annotation.*; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.core.common.core.domain.R; import com.core.common.enums.AssignSeqEnum; -import com.core.common.utils.AssignSeqUtil; -import com.core.common.utils.ChineseConvertUtils; -import com.core.common.utils.MessageUtils; -import com.core.common.utils.StringUtils; import com.core.common.utils.bean.BeanUtils; import com.openhis.administration.domain.Patient; import com.openhis.administration.service.IPatientService; @@ -184,7 +181,11 @@ public class PatientInformationController { patient.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(patient.getName())); // 设置五笔首拼 patient.setWbStr(ChineseConvertUtils.toWBFirstLetter(patient.getName())); - + //设置死亡时间 + if(patientService.isFuture(patientInformationDto.getDeceasedDate())){ + return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00003, new Object[] {"死亡时间未来时"})); + } + patient.setDeceasedDate(DateUtils.parseDate(patientInformationDto.getDeceasedDate())); // 调用服务层保存病人信息 boolean savePatientSuccess = patientService.save(patient); @@ -212,6 +213,11 @@ public class PatientInformationController { patient.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(patient.getName())); // 设置五笔首拼 patient.setWbStr(ChineseConvertUtils.toWBFirstLetter(patient.getName())); + //设置死亡时间 + if(patientService.isFuture(patientInformationDto.getDeceasedDate())){ + return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] {"死亡时间未来时"})); + } + patient.setDeceasedDate(DateUtils.parseDate(patientInformationDto.getDeceasedDate())); // 调用服务层更新病人信息 return patientService.updateById(patient) diff --git a/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/IPatientService.java b/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/IPatientService.java index 41a9a251..c56301c1 100644 --- a/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/IPatientService.java +++ b/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/IPatientService.java @@ -20,4 +20,12 @@ public interface IPatientService extends IService { * @return 出生日 */ Date extractBirthday(String idCard); + + /** + * 判断日期是否为未来时间 + * + * @param date 字符串日期 + * @return 是/否 + */ + boolean isFuture(String date); } \ No newline at end of file diff --git a/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/impl/PatientServiceImpl.java b/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/impl/PatientServiceImpl.java index 13e358f8..83e0ea11 100644 --- a/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/impl/PatientServiceImpl.java +++ b/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/impl/PatientServiceImpl.java @@ -23,7 +23,7 @@ public class PatientServiceImpl extends ServiceImpl impl /** * 从身份证号码中提取生日 - * + * * @param idCard 身份证号 * @return 出生日 */ @@ -43,4 +43,23 @@ public class PatientServiceImpl extends ServiceImpl impl return Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()); } + @Override + public boolean isFuture(String dateString) { + // 创建 DateTimeFormatter 对象,并设置所需的日期时间格式 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); + + try { + // 解析字符串为 LocalDate 对象 + LocalDate dateToCheck = LocalDate.parse(dateString, formatter); + // 获取当前日期 + LocalDate currentDate = LocalDate.now(); + // 检查日期是否是未来的时间 + return dateToCheck.isAfter(currentDate); + } catch (Exception e) { + e.printStackTrace(); + // 解析失败或其他异常,返回 false 或根据需要处理异常 + return false; + } + } + } \ No newline at end of file