From 42fb200e5c378ab7090e3aa4627faee8912eb67d Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 01 九月 2025 18:15:50 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java |   66 ++++++++++++++++++++++----------
 1 files changed, 45 insertions(+), 21 deletions(-)

diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISMapperServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
similarity index 77%
rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISMapperServiceImpl.java
rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
index 69b042c..954d2b6 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISMapperServiceImpl.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
@@ -1,21 +1,16 @@
 package com.ruoyi.quartz.service.impl;
 
-import com.ruoyi.common.annotation.DataSource;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.entity.SysUserDept;
 import com.ruoyi.common.core.domain.entity.SysUserRole;
-import com.ruoyi.common.enums.DataSourceType;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.quartz.mapper.CollectHISMapper;
-import com.ruoyi.quartz.service.ICollectHISMapperService;
+import com.ruoyi.quartz.service.ICollectHISService;
 import com.smartor.domain.*;
 import com.smartor.mapper.*;
-import com.smartor.service.impl.PatArchiveServiceImpl;
-import com.smartor.service.impl.PatMedInhospServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Service;
@@ -27,9 +22,9 @@
 
 @Slf4j
 @Service
-public class CollectHISMapperServiceImpl implements ICollectHISMapperService {
+public class CollectHISServiceImpl implements ICollectHISService {
     @Autowired
-    private HNGatherPatArchiveMapper hnGatherPatArchiveMapper;
+    private CollectHISMapper chMapper;
 
     @Autowired
     private SysUser2Mapper sysUser2Mapper;
@@ -68,7 +63,7 @@
 
     @Override
     public List<PatArchive> selectPatArchiveList(PatArchive patArchive) {
-        return hnGatherPatArchiveMapper.selectPatArchiveList(patArchive);
+        return chMapper.selectPatArchiveList(patArchive);
     }
 
 //    @Override
@@ -86,11 +81,11 @@
 
     @Override
     public Integer selectPatMedInhospList(PatMedInhosp patMedInhosp) {
-        List<PatMedInhosp> patMedInhospList = hnGatherPatArchiveMapper.selectPatMedInhospList(patMedInhosp);
+        List<PatMedInhosp> patMedInhospList = chMapper.selectPatMedInhospList(patMedInhosp);
         for (PatMedInhosp pm : patMedInhospList) {
             PatArchive patArchive = new PatArchive();
             patArchive.setPatientno(pm.getPatno());
-            List<PatArchive> patArchives = hnGatherPatArchiveMapper.selectPatArchiveList(patArchive);
+            List<PatArchive> patArchives = chMapper.selectPatArchiveList(patArchive);
             if (CollectionUtils.isEmpty(patArchives)) {
                 //绌轰簡鐩存帴涓㈡帀
                 continue;
@@ -104,7 +99,27 @@
                 patArchiveMapper.insertPatArchiveSingle(patArchives.get(0));
                 pm.setPatid(patArchives.get(0).getId());
             }
-            patMedInhospMapper.insertPatMedInhosp(pm);
+            if (!Objects.isNull(patMedInhosp.getStartInHospTime()) && !Objects.isNull(patMedInhosp.getEndInHospTime())) {
+                //鍏ラ櫌
+                pm.setInhospstate("0");
+                pm.setCreateTime(new Date());
+                patMedInhospMapper.insertPatMedInhosp(pm);
+            } else if (!Objects.isNull(patMedInhosp.getStartOutHospTime()) && !Objects.isNull(patMedInhosp.getEndOutHospTime())) {
+                //鍑洪櫌
+                pm.setInhospstate("1");
+                pm.setUpdateTime(new Date());
+                PatMedInhosp pmi = new PatMedInhosp();
+                pmi.setSerialnum(pm.getSerialnum());
+                List<PatMedInhosp> patMedInhospList1 = patMedInhospMapper.selectPatMedInhospList(pmi);
+                if (CollectionUtils.isEmpty(patMedInhospList1)) {
+                    pm.setCreateTime(new Date());
+                    patMedInhospMapper.insertPatMedInhosp(pm);
+                } else {
+                    pm.setInhospid(patMedInhospList1.get(0).getInhospid());
+                    patMedInhospMapper.updatePatMedInhosp(pm);
+                }
+
+            }
         }
         return 0;
     }
@@ -119,16 +134,25 @@
         // 寰幆澶勭悊姣忎竴澶�
         for (LocalDate currentDate = startDate; !currentDate.isAfter(endDate); currentDate = currentDate.plusDays(1)) {
             PatMedInhosp dailyCondition = new PatMedInhosp();
+            //澶勭悊鍏ラ櫌
             LocalDateTime dayStart = currentDate.atStartOfDay();
             LocalDateTime dayEnd = currentDate.atTime(23, 59, 59);
+            dailyCondition.setStartInHospTime(Date.from(dayStart.atZone(ZoneId.systemDefault()).toInstant()));
+            dailyCondition.setEndInHospTime(Date.from(dayEnd.atZone(ZoneId.systemDefault()).toInstant()));
+            selectPatMedInhospList(dailyCondition);
+
+            //澶勭悊鍑洪櫌
+            dailyCondition.setStartInHospTime(null);
+            dailyCondition.setEndInHospTime(null);
             dailyCondition.setStartOutHospTime(Date.from(dayStart.atZone(ZoneId.systemDefault()).toInstant()));
             dailyCondition.setEndOutHospTime(Date.from(dayEnd.atZone(ZoneId.systemDefault()).toInstant()));
-            Integer pi = selectPatMedInhospList(dailyCondition);
+            selectPatMedInhospList(dailyCondition);
 
+            //澶勭悊闂ㄨ瘖
             PatMedOuthosp patMedOuthosp = new PatMedOuthosp();
             patMedOuthosp.setBeginTime(Date.from(dayStart.atZone(ZoneId.systemDefault()).toInstant()));
             patMedOuthosp.setEndTime(Date.from(dayEnd.atZone(ZoneId.systemDefault()).toInstant()));
-            po = selectPatMedOuthospList(patMedOuthosp);
+            selectPatMedOuthospList(patMedOuthosp);
         }
         return true;
     }
@@ -136,14 +160,14 @@
 
     @Override
     public Integer selectPatMedOuthospList(PatMedOuthosp patMedOuthosp) {
-        List<PatMedOuthosp> patMedOuthosps = hnGatherPatArchiveMapper.selectPatMedOuthospList(patMedOuthosp);
+        List<PatMedOuthosp> patMedOuthosps = chMapper.selectPatMedOuthospList(patMedOuthosp);
         log.info("selectPatMedOuthospList鐨勯噰闆嗗埌鐨勬暟閲忎负锛歿}", patMedOuthosps.size());
         Integer i = null;
         for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) {
             //鑾峰彇鎮h�呭熀鏈俊鎭�
             PatArchive patArchive = new PatArchive();
             patArchive.setPatientno(patMedOuthosp1.getPatno());
-            List<PatArchive> patArchives = hnGatherPatArchiveMapper.selectPatArchiveList(patArchive);
+            List<PatArchive> patArchives = chMapper.selectPatArchiveList(patArchive);
 
             //鏍规嵁patno鍒ゆ柇鏈湴鎮h�呭熀鏈俊鎭槸鍚﹀瓨鍦�
             PatArchive pa = new PatArchive();
@@ -166,7 +190,7 @@
 
     @Override
     public Integer selectIcd10List(Icd10 icd10) {
-        List<Icd10> icd10s = hnGatherPatArchiveMapper.selectIcd10List(icd10);
+        List<Icd10> icd10s = chMapper.selectIcd10List(icd10);
         log.info("selectIcd10List鐨勯噰闆嗗埌鐨勬暟閲忎负锛歿}", icd10s.size());
         int i = icd10Mapper.batchIcd10(icd10s);
         return i;
@@ -174,14 +198,14 @@
 
     @Override
     public Integer selectUserList(SysUser sysUser) {
-        List<SysUser> sysUserList = hnGatherPatArchiveMapper.selectUserList(sysUser);
+        List<SysUser> sysUserList = chMapper.selectUserList(sysUser);
         log.info("sysUserList鐨勯噰闆嗗埌鐨勬暟閲忎负锛歿}", sysUserList.size());
         int i = sysUser2Mapper.batchUser(sysUserList);
         for (SysUser sysUser1 : sysUserList) {
             log.info("sysUser1鐨処D涓猴細{}", sysUser1.getUserId());
             log.info("sysUser1鐨凥ISUSERID涓猴細{}", sysUser1.getHisUserId());
             //鏂板鐢ㄦ埛涓庤鑹�
-            SysUserRole yhyjsxx = hnGatherPatArchiveMapper.yhyjsxx(sysUser1);
+            SysUserRole yhyjsxx = chMapper.yhyjsxx(sysUser1);
             if (yhyjsxx == null) continue;
             yhyjsxx.setUserId(sysUser1.getUserId());
             List<SysUserRole> userRoleList = new ArrayList<>();
@@ -190,7 +214,7 @@
 
             //鏂板鐢ㄦ埛涓庨儴闂�
             if (StringUtils.isEmpty(sysUser1.getHisUserId())) continue;
-            SysUserDept sysUserDept = hnGatherPatArchiveMapper.yhyksxx(sysUser1);
+            SysUserDept sysUserDept = chMapper.yhyksxx(sysUser1);
             if (Objects.isNull(sysUserDept) || sysUserDept.getDeptId() == null) continue;
             SysDept dept = new SysDept();
             dept.setHisDeptId(sysUserDept.getDeptId().toString());
@@ -209,7 +233,7 @@
 
     @Override
     public Integer selectDeptList(SysDept dept) {
-        List<SysDept> sysDepts = hnGatherPatArchiveMapper.selectDeptList(dept);
+        List<SysDept> sysDepts = chMapper.selectDeptList(dept);
         log.info("selectDeptList鐨勯噰闆嗗埌鐨勬暟閲忎负锛歿}", sysDepts.size());
         int i = sysDept2Mapper.batchDept(sysDepts);
         return i;

--
Gitblit v1.9.3