From 6659135780e718758417efde4c8c351c69e3755b Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 11 十二月 2025 15:52:19 +0800
Subject: [PATCH] 代码提交
---
smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java | 177 +++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 149 insertions(+), 28 deletions(-)
diff --git a/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java
index 29c84e4..988b5af 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java
@@ -1,5 +1,9 @@
package com.smartor.service.impl;
+import java.time.LocalDate;
+import java.time.Period;
+import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
import java.util.*;
import com.ruoyi.common.core.domain.entity.SysDept;
@@ -11,7 +15,9 @@
import com.smartor.domain.*;
import com.smartor.mapper.*;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.smartor.service.IPatMedOuthospService;
import org.springframework.util.CollectionUtils;
@@ -41,6 +47,9 @@
private ServiceTaskdiagMapper serviceTaskdiagMapper;
@Autowired
+ private ServiceTaskdeptMapper serviceTaskdeptMapper;
+
+ @Autowired
private PatArchiveMapper patArchiveMapper;
@@ -62,9 +71,85 @@
* @return 鎮h�呴棬璇婅褰�
*/
@Override
+ @Cacheable(value = "selectPatMedOuthospList", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#patMedOuthosp.toString().getBytes())", unless = "#result == null or #result.isEmpty()")
public List<PatMedOuthosp> selectPatMedOuthospList(PatMedOuthosp patMedOuthosp) {
List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.selectPatMedOuthospList(patMedOuthosp);
+ for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) {
+ PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp1.getPatid());
+ if (patArchive.getBirthdate() != null) {
+ Map<String, String> map = calculateAge(patArchive.getBirthdate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now());
+ patArchive.setAge(ObjectUtils.isNotEmpty(map.get("age")) ? Long.valueOf(map.get("age")) : null);
+ patArchive.setAgeUnit(map.get("ageUnit"));
+ patArchive.setAge2(ObjectUtils.isNotEmpty(map.get("age2")) ? Long.valueOf(map.get("age2")) : null);
+ patArchive.setAgeUnit2(map.get("ageUnit2"));
+ patMedOuthosp1.setAge(patArchive.getAge() + patArchive.getAgeUnit() + patArchive.getAge2() + patArchive.getAgeUnit2());
+ patMedOuthosp1.setTelcode(patArchive.getTelcode());
+ patMedOuthosp1.setIdcardno(patArchive.getIdcardno());
+ }
+ ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO();
+ serviceSubtaskVO.setPatid(patMedOuthosp1.getPatid());
+ List<Long> sendstates = new ArrayList<>();
+ sendstates.add(1L);
+ sendstates.add(2L);
+ sendstates.add(3L);
+ serviceSubtaskVO.setSendstates(sendstates);
+ serviceSubtaskVO.setServiceType("3");
+ List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskBySendstate(serviceSubtaskVO);
+ if (!CollectionUtils.isEmpty(serviceSubtaskList)) patMedOuthosp1.setServerState("1");
+ }
return patMedOuthosps;
+ }
+
+ public Map<String, String> calculateAge(LocalDate birthdate, LocalDate today) {
+ if (birthdate == null || today.isBefore(birthdate)) {
+ return null;
+ }
+ Map<String, String> ageMap = new HashMap<>();
+
+ Period period = Period.between(birthdate, today);
+ long totalDays = ChronoUnit.DAYS.between(birthdate, today);
+ long totalMonths = ChronoUnit.MONTHS.between(birthdate, today);
+
+ int years = period.getYears();
+ int months = period.getMonths();
+ int days = period.getDays();
+
+ String ageUnit;
+ Integer age;
+ String ageUnit2 = null;
+ Integer age2 = null;
+
+ if (totalDays < 30) {
+ // 灏忎簬 1 涓湀锛屾寜澶╄绠�
+ ageUnit = "澶�";
+ age = (int) totalDays;
+ ageMap.put("age", age != null ? age.toString() : null);
+ ageMap.put("ageUnit", ageUnit);
+ ageMap.put("age2", null);
+ ageMap.put("ageUnit2", null);
+ } else if (totalMonths < 12) {
+ // 灏忎簬 涓�骞达紝鎸夋湀 + 澶╄绠�
+ ageUnit = "鏈�";
+ age = (int) totalMonths;
+ ageUnit2 = "澶�";
+ age2 = days;
+ ageMap.put("age", age != null ? age.toString() : null);
+ ageMap.put("ageUnit", ageUnit);
+ ageMap.put("age2", age2 != null ? age2.toString() : null);
+ ageMap.put("ageUnit2", ageUnit2);
+ } else {
+ // 澶т簬绛変簬 涓�骞达紝鎸夊勾 + 鏈堣绠�
+ ageUnit = "宀�";
+ age = years;
+ ageUnit2 = "鏈�";
+ age2 = months;
+ ageMap.put("age", age != null ? age.toString() : null);
+ ageMap.put("ageUnit", ageUnit);
+ ageMap.put("age2", age2 != null ? age2.toString() : null);
+ ageMap.put("ageUnit2", ageUnit2);
+ }
+
+ return ageMap;
}
/**
@@ -116,16 +201,16 @@
@Override
public PatMedRes selectPatMedOuthospCount(PatMedReq patMedReq) {
- // 鑾峰彇褰撳墠鐧婚檰浜虹殑閮ㄩ棬鏉冮檺
- if (CollectionUtils.isEmpty(patMedReq.getDeptcodeList())) {
- Long userId = SecurityUtils.getUserId();
- List<SysDept> sysDepts = sysUserDeptMapper.selectDeptListByUserId(userId);
- List<String> deptCode = new ArrayList<>();
- for (SysDept sysDept : sysDepts) {
- deptCode.add(sysDept.getDeptId().toString());
- }
- patMedReq.setDeptcodeList(deptCode);
- }
+// // 鑾峰彇褰撳墠鐧婚檰浜虹殑閮ㄩ棬鏉冮檺
+// if (CollectionUtils.isEmpty(patMedReq.getDeptcodeList())) {
+// Long userId = SecurityUtils.getUserId();
+// List<SysDept> sysDepts = sysUserDeptMapper.selectDeptListByUserId(userId);
+// List<String> deptCode = new ArrayList<>();
+// for (SysDept sysDept : sysDepts) {
+// deptCode.add(sysDept.getDeptId().toString());
+// }
+// patMedReq.setDeptcodeList(deptCode);
+// }
return patMedOuthospMapper.selectPatMedOuthospCount(patMedReq);
}
@@ -149,20 +234,37 @@
patMedOuthosp.setDiagcheckFlag("0");
List<PatMedOuthosp> patMedOuthosps = selectPatMedOuthospList(patMedOuthosp);
for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) {
+ PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp1.getPatid());
+
+ //鏍规嵁鎮h�呯瀹わ紝鑾峰彇璇ョ柧鐥呯殑闀挎湡浠诲姟
+ ServiceTaskdept serviceTaskdept = new ServiceTaskdept();
+ serviceTaskdept.setLongtask(1L);
+ serviceTaskdept.setDeptCode(patMedOuthosp1.getDeptcode());
+ serviceTaskdept.setServiceType("3");
+ List<ServiceTaskdept> serviceTaskdeptList = serviceTaskdeptMapper.selectServiceTaskdeptList(serviceTaskdept);
+ if (org.apache.commons.collections4.CollectionUtils.isEmpty(serviceTaskdeptList) || serviceTaskdeptList.size() == 0) {
+ patMedOuthosp1.setDeptcheckFlag("2");
+ patMedOuthosp1.setRemark("閫氳繃閮ㄩ棬,娌℃湁鎵惧埌闂ㄨ瘖闅忚浠诲姟ID");
+ patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1);
+ } else {
+ for (ServiceTaskdept serviceTaskdept1 : serviceTaskdeptList) {
+ writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedOuthosp1, patArchive, 1);
+ }
+ }
+
// 鏍规嵁鎮h�呯殑鐤剧梾锛岃幏鍙栬鐤剧梾鐨勯暱鏈熶换鍔�
ServiceTaskdiag serviceTaskdiag = new ServiceTaskdiag();
serviceTaskdiag.setLongtask(1L);
serviceTaskdiag.setIcd10code(patMedOuthosp1.getIcd10code());
List<ServiceTaskdiag> serviceTaskdiags = serviceTaskdiagMapper.selectServiceTaskdiagList(serviceTaskdiag);
- PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp1.getPatid());
//濡傛灉閮ㄩ棬妯℃澘涓虹┖锛堝皢deptIsNull璁剧疆涓簍rue锛�
if (org.apache.commons.collections4.CollectionUtils.isEmpty(serviceTaskdiags) || serviceTaskdiags.size() == 0) {
patMedOuthosp1.setDiagcheckFlag("2");
- patMedOuthosp1.setRemark("閫氳繃icd10,娌℃湁鎵惧埌闅忚浠诲姟ID");
+ patMedOuthosp1.setRemark("閫氳繃icd10,娌℃湁鎵惧埌闂ㄨ瘖闅忚浠诲姟ID");
patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1);
} else {
for (ServiceTaskdiag serviceTaskdept1 : serviceTaskdiags) {
- writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedOuthosp1, patArchive);
+ writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedOuthosp1, patArchive, 2);
}
}
@@ -170,16 +272,24 @@
return 1;
}
- private void writeInSubTask(Long taskid, Boolean check, PatMedOuthosp patMedOuthosp, PatArchive patArchive) {
+ /**
+ * @param taskid
+ * @param check
+ * @param patMedOuthosp
+ * @param patArchive
+ * @param type 1 绉戝 2 鐤剧梾
+ */
+ private void writeInSubTask(Long taskid, Boolean check, PatMedOuthosp patMedOuthosp, PatArchive patArchive, Integer type) {
ServiceTask st = new ServiceTask();
st.setTaskid(taskid);
st.setSendState(2L);
List<ServiceTask> serviceTasks = serviceTaskMapper.selectServiceTaskList(st);
if (org.apache.commons.collections4.CollectionUtils.isEmpty(serviceTasks)) {
- log.error("璇ユ偅鑰呯柧鐥呴殢璁块暱鏈熶换鍔′笉瀛樺湪,浠诲姟ID涓猴細{}", taskid);
- patMedOuthosp.setDiagcheckFlag("2");
- patMedOuthosp.setRemark("璇ユ偅鑰呯柧鐥呴殢璁块暱鏈熶换鍔′笉瀛樺湪,浠诲姟ID涓�:" + taskid);
+ log.info("璇ユ偅鑰呯柧鐥呴殢璁块暱鏈熶换鍔′笉瀛樺湪,浠诲姟ID涓猴細{}", taskid);
+ if (type == 1) patMedOuthosp.setDiagcheckFlag("2");
+ if (type == 2) patMedOuthosp.setDeptcheckFlag("2");
+ patMedOuthosp.setRemark("璇ユ偅鑰呴棬璇婇殢璁块暱鏈熶换鍔′笉瀛樺湪,浠诲姟ID涓�:" + taskid);
patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp);
return;
}
@@ -195,7 +305,7 @@
subtask.setSendstate(2L);
subtask.setTaskid(taskid);
List<ServiceSubtask> selectServiceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(subtask);
- log.error("璇ユ偅鑰呭緟鎵ц鐨勪换鍔�:{}", selectServiceSubtaskList);
+ log.info("璇ユ偅鑰呭緟鎵ц鐨勪换鍔�:{}", CollectionUtils.isEmpty(selectServiceSubtaskList) ? null : selectServiceSubtaskList.size());
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(selectServiceSubtaskList) && selectServiceSubtaskList.size() > 0) {
for (ServiceSubtask serviceSubtask1 : selectServiceSubtaskList) {
if (Objects.isNull(serviceSubtask1.getLongSendTime())) {
@@ -204,22 +314,21 @@
}
//灏嗕箣鍓嶇殑鍋滄帀
- serviceSubtask1.setSendstate(4L);
- serviceSubtask1.setRemark("鐤剧梾鎮h�呭啀鍏ラ櫌");
- serviceSubtask1.setResult("error");
+ serviceSubtask1.setSendstate(6L);
+ serviceSubtask1.setRemark("鎮h�呭凡缁忓洖闄㈠璇�");
+ serviceSubtask1.setResult("success");
serviceSubtask1.setFinishtime(new Date());
serviceSubtask1.setUpdateBy(serviceTask.getUpdateBy());
serviceSubtaskMapper.updateServiceSubtask(serviceSubtask1);
//閲嶆柊鏂板瀛愪换鍔�
i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
-
}
} else {
if (StringUtils.isEmpty(serviceSubtask.getPhone())) {
serviceSubtask.setRemark("鎵嬫満鍙蜂负绌�");
serviceSubtask.setSendstate(4L);
serviceSubtask.setResult("error");
- serviceSubtask.setFinishtime(new Date());
+// serviceSubtask.setFinishtime(new Date());
}
serviceSubtask.setCreateBy(serviceTask.getCreateBy());
serviceSubtask.setCreateTime(new Date());
@@ -230,7 +339,7 @@
serviceSubtask.setRemark("鎵嬫満鍙蜂负绌�");
serviceSubtask.setSendstate(4L);
serviceSubtask.setResult("error");
- serviceSubtask.setFinishtime(new Date());
+// serviceSubtask.setFinishtime(new Date());
}
serviceSubtask.setCreateBy(serviceTask.getCreateBy());
@@ -241,14 +350,16 @@
//灏哻heck_flag鏀规垚1锛堝凡澶勭悊锛�
PatMedOuthosp patMedOuthosp1 = new PatMedOuthosp();
patMedOuthosp1.setId(patMedOuthosp.getId());
- patMedOuthosp1.setDiagcheckFlag("1");
+ if (type == 1) patMedOuthosp1.setDiagcheckFlag("2");
+ if (type == 2) patMedOuthosp1.setDeptcheckFlag("2");
patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1);
} else {
//鐢熸垚瀛愪换鍔″け璐ワ紝
- log.error("鐢熸垚瀛愪换鍔″け璐erviceSubtask涓猴細{}", serviceSubtask);
+ log.info("鐢熸垚瀛愪换鍔″け璐erviceSubtask鐨則askid涓猴細{},patid涓猴細{}", serviceSubtask.getTaskid(), serviceSubtask.getPatid());
PatMedOuthosp pmo = new PatMedOuthosp();
pmo.setId(patMedOuthosp.getId());
- pmo.setDiagcheckFlag("2");
+ if (type == 1) pmo.setDiagcheckFlag("2");
+ if (type == 2) pmo.setDeptcheckFlag("2");
pmo.setRemark("鐢熸垚瀛愪换鍔″け璐�");
patMedOuthospMapper.updatePatMedOuthosp(pmo);
}
@@ -263,6 +374,8 @@
serviceSubtask.setDrcode(patMedOuthosp.getDrcode());
serviceSubtask.setDrname(patMedOuthosp.getDrname());
serviceSubtask.setDeptcode(patMedOuthosp.getDeptcode());
+ serviceSubtask.setInhospid(patMedOuthosp.getId());
+ serviceSubtask.setHospno(patMedOuthosp.getOuthospno());
serviceSubtask.setDeptname(patMedOuthosp.getDeptname());
serviceSubtask.setTemplateid(serviceTask.getTemplateid());
serviceSubtask.setTemplatename(serviceTask.getTemplatename());
@@ -284,16 +397,24 @@
serviceSubtask.setUpdateTime(new Date());
serviceSubtask.setUpdateBy(serviceTask.getUpdateBy());
serviceSubtask.setUpdateTime(new Date());
+ serviceSubtask.setVisitDeptCode(patMedOuthosp.getDeptcode());
+ serviceSubtask.setVisitDeptName(patMedOuthosp.getDeptname());
+ serviceSubtask.setUpdateTime(new Date());
//璁剧疆鍙戦�佹椂闂�
if (serviceTask.getSendDay() == null) serviceTask.setSendDay(1L);
Date newDate = addDays(patMedOuthosp.getAdmitdate(), serviceTask.getSendDay().intValue());
+ if (patMedOuthosp.getFudate() != null) {
+ //濡傛灉闂ㄨ瘖琛ㄦ湁鎸囧畾闅忚鏃堕棿锛岄偅灏辩敤鎸囧畾鐨�
+ newDate = patMedOuthosp.getFudate();
+ }
serviceSubtask.setLongSendTime(newDate);
+ serviceSubtask.setVisitTime(newDate);
//鎮h�呭彂閫佹椂闂�
if (StringUtils.isNotEmpty(patArchive.getNotrequiredFlag()) && patArchive.getNotrequiredFlag().equals("1")) {
String remark = patArchive.getNotrequiredreason();
serviceSubtask.setRemark(remark);
serviceSubtask.setResult("error");
- serviceSubtask.setFinishtime(new Date());
+// serviceSubtask.setFinishtime(new Date());
//涓嶆墽琛�
serviceSubtask.setSendstate(4L);
}
--
Gitblit v1.9.3