From b17665b2645701d6eea22ab9d4662b76c97dd6e3 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 09 十月 2025 16:17:26 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/service/impl/HNGatherPatArchiveServiceImpl.java |   45 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/service/impl/HNGatherPatArchiveServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/HNGatherPatArchiveServiceImpl.java
index 934a87a..d1496e0 100644
--- a/smartor/src/main/java/com/smartor/service/impl/HNGatherPatArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/HNGatherPatArchiveServiceImpl.java
@@ -104,7 +104,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;
     }
@@ -112,23 +132,32 @@
     @Override
     public Boolean hnDataGather(HnDataGatherVO hnDataGatherVO) {
 
-        LocalDate startDate = hnDataGatherVO.getStartOutHospTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
-        LocalDate endDate = hnDataGatherVO.getEndOutHospTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+        LocalDate startDate = hnDataGatherVO.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+        LocalDate endDate = hnDataGatherVO.getEndTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
 
         Integer po = null;
         // 寰幆澶勭悊姣忎竴澶�
         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;
     }
@@ -175,6 +204,9 @@
     @Override
     public Integer selectUserList(SysUser sysUser) {
         List<SysUser> sysUserList = hnGatherPatArchiveMapper.selectUserList(sysUser);
+        if (CollectionUtils.isEmpty(sysUserList)) return null;
+
+
         log.info("sysUserList鐨勯噰闆嗗埌鐨勬暟閲忎负锛歿}", sysUserList.size());
         int i = sysUser2Mapper.batchUser(sysUserList);
         for (SysUser sysUser1 : sysUserList) {
@@ -211,7 +243,8 @@
     public Integer selectDeptList(SysDept dept) {
         List<SysDept> sysDepts = hnGatherPatArchiveMapper.selectDeptList(dept);
         log.info("selectDeptList鐨勯噰闆嗗埌鐨勬暟閲忎负锛歿}", sysDepts.size());
-        int i = sysDept2Mapper.batchDept(sysDepts);
+        int i = 0;
+        if (CollectionUtils.isNotEmpty(sysDepts)) i = sysDept2Mapper.batchDept(sysDepts);
         return i;
     }
 

--
Gitblit v1.9.3