From 2a3d4e4c082403aeb31d4c1c499a6107ffa835af Mon Sep 17 00:00:00 2001
From: sinake <sinake1@qq.com>
Date: 星期六, 13 九月 2025 14:22:55 +0800
Subject: [PATCH] 同步数据接口和随访率改成只有已完成

---
 .idea/jarRepositories.xml                                                           |   16 +
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java |  239 +++++++++++++++++++++++++++--
 ruoyi-admin/pom.xml                                                                 |    6 
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/CollectHISController.java    |    7 
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ICollectHISService.java         |   11 +
 ruoyi-admin/src/main/resources/application.yml                                      |    4 
 smartor/src/main/java/com/smartor/mapper/PatMedInhospMapper.java                    |    2 
 ruoyi-quartz/src/main/resources/mapper/quartz/CollectHISMapper.xml                  |   22 ++
 smartor/src/main/java/com/smartor/domain/PatArchive.java                            |    6 
 smartor/src/main/java/com/smartor/domain/PatMedOuthosp.java                         |    4 
 ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUserDept.java     |    7 
 smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml                    |   73 +++++++++
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java                        |    3 
 smartor/src/main/java/com/smartor/domain/PatMedInhosp.java                          |    6 
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java       |    2 
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/CollectHISMapper.java            |   28 +++
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/UtilsMapper.java                 |   28 +++
 ruoyi-quartz/src/main/resources/mapper/quartz/UtilsMapper.xml                       |    7 
 ruoyi-common/src/main/java/com/ruoyi/common/utils/sms/smsUtils.java                 |    3 
 19 files changed, 435 insertions(+), 39 deletions(-)

diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 0507aeb..24d19a8 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -9,6 +9,11 @@
     <remote-repository>
       <option name="id" value="central" />
       <option name="name" value="Central Repository" />
+      <option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Central Repository" />
       <option name="url" value="https://repo.maven.apache.org/maven2" />
     </remote-repository>
     <remote-repository>
@@ -32,14 +37,19 @@
       <option name="url" value="https://repo1.maven.org/maven2" />
     </remote-repository>
     <remote-repository>
+      <option name="id" value="aliyun" />
+      <option name="name" value="aliyun" />
+      <option name="url" value="https://maven.aliyun.com/repository/public" />
+    </remote-repository>
+    <remote-repository>
       <option name="id" value="snapshots" />
       <option name="name" value="Snapshot Repositories" />
       <option name="url" value="http://211.90.241.109:7008/repository/maven-snapshots/" />
     </remote-repository>
     <remote-repository>
-      <option name="id" value="aliyun" />
-      <option name="name" value="aliyun" />
-      <option name="url" value="https://maven.aliyun.com/repository/public" />
+      <option name="id" value="central" />
+      <option name="name" value="central" />
+      <option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
     </remote-repository>
     <remote-repository>
       <option name="id" value="central" />
diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml
index c83d8c9..8f2bf2c 100644
--- a/ruoyi-admin/pom.xml
+++ b/ruoyi-admin/pom.xml
@@ -180,6 +180,12 @@
             <artifactId>postgresql</artifactId>
             <version>42.6.0</version> <!-- 璇锋牴鎹渶瑕侀�夋嫨鏈�鏂扮増鏈� -->
         </dependency>
+        <!--oracle-->
+        <dependency>
+            <groupId>com.oracle.database.jdbc</groupId>
+            <artifactId>ojdbc8</artifactId>
+            <scope>runtime</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index ee520fe..24f1d1f 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -114,8 +114,8 @@
   mapperLocations: classpath*:mapper/**/*Mapper.xml
   # 鍔犺浇鍏ㄥ眬鐨勯厤缃枃浠�
   configLocation: classpath:mybatis/mybatis-config.xml
-  configuration:
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+  #configuration:
+  #  log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
 
 # 娌冲崡SSO閰嶇疆锛堜附姘寸敤涓嶅埌锛�
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUserDept.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUserDept.java
index ea0120d..f8b00b9 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUserDept.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUserDept.java
@@ -32,6 +32,13 @@
     private Long userId;
 
     /**
+     * 鐢ㄦ埛缂栧彿
+     */
+    @ApiModelProperty("鐢ㄦ埛缂栧彿")
+    @Excel(name = "鐢ㄦ埛缂栧彿")
+    private String userCode;
+
+    /**
      * 閮ㄩ棬绫诲瀷
      */
     @ApiModelProperty("閮ㄩ棬绫诲瀷")
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/sms/smsUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sms/smsUtils.java
index 99a2fc2..2ec23d9 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/sms/smsUtils.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sms/smsUtils.java
@@ -36,7 +36,8 @@
                 "\"timestamp\": " + timestamp + "," +
                 "\"sign\": \"" + sign + "\"" +
                 "}";
-        return HttpUtil.postJsonRequest(url, jsonMsg);
+        String sendMsg=HttpUtil.postJsonRequest(url, jsonMsg);
+        return sendMsg;
 
     }
 }
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/CollectHISController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/CollectHISController.java
index a5b760f..0de0204 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/CollectHISController.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/CollectHISController.java
@@ -31,9 +31,10 @@
     @PostMapping("/collect")
     @ApiOperation("鍚屾鐥呬汉鐩稿叧鏁版嵁")
     public AjaxResult hnDataGather(@RequestBody HnDataGatherVO hnDataGatherVO) {
-        log.info("寮�濮嬫寜澶╁悓姝ョ敤鎴锋暟鎹紝鏃堕棿鑼冨洿: {} 鍒� {}", hnDataGatherVO.getStartTime(), hnDataGatherVO.getEndTime());
-        Boolean aBoolean = ichService.hnDataGather(hnDataGatherVO);
-        return AjaxResult.success(aBoolean);
+
+        //Boolean aBoolean = ichService.hnDataGather(hnDataGatherVO);
+       Integer count= ichService.sync();
+        return AjaxResult.success(count);
     }
 
     /**
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/CollectHISMapper.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/CollectHISMapper.java
index 44c9a95..7da1dab 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/CollectHISMapper.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/CollectHISMapper.java
@@ -12,6 +12,8 @@
 import com.smartor.domain.PatMedOuthosp;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 
 import java.util.List;
 import java.util.Map;
@@ -43,7 +45,7 @@
      * @param sysUser
      * @return
      */
-    public SysUserDept yhyksxx(SysUser sysUser);
+    public List<SysUserDept> yhyksxx(SysUser sysUser);
 
     /**
      * 鍑哄叆闄俊鎭�
@@ -94,4 +96,28 @@
      * @return 閮ㄩ棬淇℃伅闆嗗悎
      */
     public List<SysDept> selectDeptList(SysDept dept);
+
+    /**
+     * 鏌ヨ杩斿洖strign sql
+     * @param sql
+     * @return
+     */
+    @Select({"${sql}"})
+    String getSqlString(@Param("sql") String sql);
+
+    /**
+     * 鏌ヨsql
+     * @param sql
+     * @return
+     */
+    @Select({"${sql}"})
+    List<Map<String, Object>> getList(@Param("sql") String sql);
+
+
+    /**
+     * 鏌ヨsql
+     * @param sql
+     */
+    @Update({"${sql}"})
+    Integer updateSql(@Param("sql") String sql);
 }
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/UtilsMapper.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/UtilsMapper.java
new file mode 100644
index 0000000..ab0ded7
--- /dev/null
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/UtilsMapper.java
@@ -0,0 +1,28 @@
+package com.ruoyi.quartz.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface UtilsMapper {
+
+    /**
+     * 鏌ヨsql
+     * @param sql
+     * @return
+     */
+    @Select({"${sql}"})
+    List<Map<String, Object>> getList(@Param("sql") String sql);
+
+    /**
+     * 鏇存柊sql
+     * @param sql
+     */
+    @Update({"${sql}"})
+    Integer updateSql(@Param("sql") String sql);
+}
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ICollectHISService.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ICollectHISService.java
index 6a38783..205ec30 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ICollectHISService.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ICollectHISService.java
@@ -7,6 +7,15 @@
 import java.util.List;
 
 public interface ICollectHISService {
+
+    /**
+     * 鏁版嵁閲囬泦
+     *
+     * @param
+     * @return
+     */
+    public Integer sync();
+
     /**
      * 鏌ヨ鎮h�呮。妗堝垪琛�
      *
@@ -24,7 +33,7 @@
     public Integer selectPatMedInhospList(PatMedInhosp patMedInhosp);
 
     /**
-     * 娌冲崡鏁版嵁閲囬泦
+     * 鏁版嵁閲囬泦
      *
      * @param patMedInhosp
      * @return
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
index 80a5a2f..d5101e7 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
@@ -6,6 +6,7 @@
 import com.ruoyi.common.core.domain.entity.SysUserRole;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.quartz.mapper.CollectHISMapper;
+import com.ruoyi.quartz.mapper.UtilsMapper;
 import com.ruoyi.quartz.service.ICollectHISService;
 import com.smartor.domain.*;
 import com.smartor.mapper.*;
@@ -20,6 +21,7 @@
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Service
@@ -57,6 +59,9 @@
     @Autowired
     private ShardingMapper shardingMapper;
 
+    @Autowired
+    private UtilsMapper utilsMapper;
+
     private static final long SHARDING_THRESHOLD = 5_000_000L;
     private static final String PAT_ARCHIVE_TABLE = "pat_archive";
     private static final String PAT_MED_INHOSP_TABLE = "pat_med_inhosp";
@@ -79,6 +84,189 @@
 //        return 0; // 杩斿洖0琛ㄧず浠诲姟宸叉彁浜ゅ埌鍚庡彴鎵ц
 //    }
 
+    /**
+     * 鍚屾浠诲姟
+     * @param
+     * @return
+     */
+    @Override
+    public Integer sync() {
+        Integer count = 0;
+        List<Map<String, Object>> syncList = utilsMapper.getList("SELECT id,syncName,DATE_FORMAT(ADDDATE(startTime, INTERVAL -1 MINUTE), '%Y-%m-%d %H:%i:%s') startTime  FROM sys_sync_time  where state=0");
+        if (syncList.size() > 0) {
+            String endTime = chMapper.getSqlString("select sysdate from healthy_inhosp where rownum=1");
+            //鍚屾鎮h�呭熀鏈俊鎭�
+//            List<Map<String, Object>> syncTemp = syncList.stream().filter(row -> row.get("syncName").equals("pat_archive")).collect(Collectors.toList());
+//            if (syncTemp.size() > 0) {
+//                count+=syncArchive(syncTemp.get(0).get("startTime") + "", endTime);
+//                utilsMapper.updateSql("update sys_sync_time set startTime='"+endTime+"' where syncName='pat_archive' ");
+//            }
+
+            //鍚屾浣忛櫌鐥呬汉淇℃伅
+            List<Map<String, Object>> syncTemp = syncList.stream().filter(row -> row.get("syncName").equals("pat_med_inhosp")).collect(Collectors.toList());
+            if (syncTemp.size() > 0) {
+                count+=syncMedInhosp(syncTemp.get(0).get("startTime") + "", endTime);
+                utilsMapper.updateSql("update sys_sync_time set startTime='"+endTime+"' where syncName='pat_med_inhosp' ");
+            }
+
+            //鍚屾闂ㄨ瘖淇℃伅
+            syncTemp = syncList.stream().filter(row -> row.get("syncName").equals("pat_med_outhosp")).collect(Collectors.toList());
+            if (syncTemp.size() > 0) {
+                count+=syncOuthosp(syncTemp.get(0).get("startTime") + "", endTime);
+                utilsMapper.updateSql("update sys_sync_time set startTime='"+endTime+"' where syncName='pat_med_outhosp' ");
+            }
+
+
+        } else {
+            log.info("鍚屾浠诲姟鏃堕棿sys_sync_time琛ㄤ腑娌℃湁闇�瑕佸悓姝ョ殑浠诲姟");
+        }
+        return count;
+    }
+
+    /**
+     * 鍚屾鎮h�呭熀鏈俊鎭�
+     * @param
+     * @return
+     */
+    private  Integer syncArchive(String startTime,String endTime) {
+        Integer count = 0;
+        PatArchive pa = new PatArchive();
+        pa.setLastStartTime(startTime);
+        pa.setLastEndTime(endTime);
+        List<PatArchive> patArchives = chMapper.selectPatArchiveList(pa);
+        log.info("鍙悓鎮h�呭熀鏈俊鎭暟閲�" + patArchives.size());
+        for (PatArchive pm : patArchives) {
+            try {
+                PatArchive pa1 = new PatArchive();
+                pa1.setPatientno(pm.getPatientno());
+                List<PatArchive> patArchives1 = patArchiveMapper.selectPatArchiveList(pa1);
+                if (CollectionUtils.isNotEmpty(patArchives1)) {
+                    pm.setId(patArchives1.get(0).getId());
+                    pm.setUpdateTime(new Date());
+                    count += patArchiveMapper.updatePatArchive(pm);
+                } else {
+                    pm.setCreateTime(new Date());
+                    count += patArchiveMapper.insertPatArchiveSingle(pm);
+
+                }
+            }catch (Exception ex){
+                log.info("鍙悓鎮h�呭熀鏈俊鎭�:"+ex.getMessage());
+            }
+        }
+
+        return count;
+    }
+
+    /**
+     * 鍚屾鍑哄叆闄俊鎭�
+     * @param
+     * @return
+     */
+    private  Integer syncMedInhosp(String startTime,String endTime) {
+        Integer count = 0;
+        PatMedInhosp patMedInhosp = new PatMedInhosp();
+        patMedInhosp.setLastStartTime(startTime);
+        patMedInhosp.setLastEndTime(endTime);
+        List<PatMedInhosp> patMedInhospList = chMapper.selectPatMedInhospList(patMedInhosp);
+        log.info("鍙悓姝ュ嚭鍏ラ櫌鏁伴噺" + patMedInhospList.size());
+        for (PatMedInhosp pm : patMedInhospList) {
+            try {
+                //鎮h�呭熀鏈俊鎭�
+                PatArchive patArchive = new PatArchive();
+                patArchive.setPatientno(pm.getPatno());
+                List<PatArchive> patArchives = chMapper.selectPatArchiveList(patArchive);
+                if (patArchives.size() > 0) {
+                    PatArchive pa1 = new PatArchive();
+                    pa1.setPatientno(pm.getPatno());
+                    List<PatArchive> patArchives1 = patArchiveMapper.selectPatArchiveList(pa1);
+                    if (CollectionUtils.isNotEmpty(patArchives1)) {
+                        patArchives.get(0).setId(patArchives1.get(0).getId());
+                        patArchives.get(0).setUpdateTime(new Date());
+                        count += patArchiveMapper.updatePatArchive(patArchives.get(0));
+                    } else {
+                        patArchives.get(0).setCreateTime(new Date());
+                        count += patArchiveMapper.insertPatArchiveSingle(patArchives.get(0));
+
+                    }
+                }
+            }catch (Exception ex) {
+                log.info("鍚屾偅鑰呭熀鏈俊鎭�:" + ex.getMessage());
+            }
+
+            try {
+                //鍚屾鍑哄叆闄�
+                PatMedInhosp pmi = new PatMedInhosp();
+                pmi.setSerialnum(pm.getSerialnum());
+                List<PatMedInhosp> patMedInhospList1 = patMedInhospMapper.selectPatMedInhospListBySerialnum(pmi);
+                if (patMedInhospList1.size() == 0) {
+                    pm.setCreateTime(new Date());
+                    count += patMedInhospMapper.insertPatMedInhosp(pm);
+                } else {
+                    pm.setInhospid(patMedInhospList1.get(0).getInhospid());
+                    pm.setUpdateTime(new Date());
+                    count += patMedInhospMapper.updatePatMedInhosp(pm);
+                }
+            } catch (Exception ex) {
+                log.info("鍚屾鍑哄叆闄�:" + ex.getMessage());
+            }
+        }
+        return count;
+    }
+
+    /**
+     * 鍚屾闂ㄨ瘖淇℃伅
+     * @param
+     * @return
+     */
+    private  Integer syncOuthosp(String startTime,String endTime) {
+        Integer count = 0;
+        PatMedOuthosp patMedOuthosp = new PatMedOuthosp();
+        patMedOuthosp.setLastStartTime(startTime);
+        patMedOuthosp.setLastEndTime(endTime);
+        List<PatMedOuthosp> patMedOuthosps = chMapper.selectPatMedOuthospList(patMedOuthosp);
+        log.info("鍚屾闂ㄨ瘖淇℃伅鏁伴噺" + patMedOuthosps.size());
+        for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) {
+            try {
+                //鎮h�呭熀鏈俊鎭�
+                PatArchive patArchive = new PatArchive();
+                patArchive.setPatientno(patMedOuthosp1.getPatno());
+                List<PatArchive> patArchives = chMapper.selectPatArchiveList(patArchive);
+                if (patArchives.size() > 0) {
+                    PatArchive pa1 = new PatArchive();
+                    pa1.setPatientno(patMedOuthosp1.getPatno());
+                    List<PatArchive> patArchives1 = patArchiveMapper.selectPatArchiveList(pa1);
+                    if (CollectionUtils.isNotEmpty(patArchives1)) {
+                        patArchives.get(0).setId(patArchives1.get(0).getId());
+                        patArchives.get(0).setUpdateTime(new Date());
+                        count += patArchiveMapper.updatePatArchive(patArchives.get(0));
+                    } else {
+                        patArchives.get(0).setCreateTime(new Date());
+                        count += patArchiveMapper.insertPatArchiveSingle(patArchives.get(0));
+
+                    }
+                }
+            }catch (Exception ex) {
+                log.info("鍚屾偅鑰呭熀鏈俊鎭�:" + ex.getMessage());
+            }
+
+            try {
+                PatMedOuthosp patMedOuthospTemp = new PatMedOuthosp();
+                patMedOuthospTemp.setSerialnum(patMedOuthosp1.getSerialnum());
+                List<PatMedOuthosp> patMedOuthospsTemp = chMapper.selectPatMedOuthospList(patMedOuthosp);
+                if (patMedOuthospsTemp.size() > 0) {
+                    patMedOuthosp1.setUpdateTime(new Date());
+                    patMedOuthosp1.setId(patMedOuthospsTemp.get(0).getId());
+                    count += patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1);
+                } else {
+                    patMedOuthosp1.setCreateTime(new Date());
+                    count += patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp1);
+                }
+            } catch (Exception ex) {
+                log.info("鍚屾鍑哄叆闄�:" + ex.getMessage());
+            }
+        }
+        return count;
+    }
 
     @Override
     public Integer selectPatMedInhospList(PatMedInhosp patMedInhosp) {
@@ -221,32 +409,39 @@
     public Integer selectUserList(SysUser sysUser) {
         List<SysUser> sysUserList = chMapper.selectUserList(sysUser);
         log.info("sysUserList鐨勯噰闆嗗埌鐨勬暟閲忎负锛歿}", sysUserList.size());
-        int i = sysUser2Mapper.batchUser(sysUserList);
+        int i =0;// sysUser2Mapper.batchUser(sysUserList);
         for (SysUser sysUser1 : sysUserList) {
-            log.info("sysUser1鐨処D涓猴細{}", sysUser1.getUserId());
-            log.info("sysUser1鐨凥ISUSERID涓猴細{}", sysUser1.getHisUserId());
-            //鏂板鐢ㄦ埛涓庤鑹�
-            SysUserRole yhyjsxx = chMapper.yhyjsxx(sysUser1);
-            if (yhyjsxx == null) continue;
-            yhyjsxx.setUserId(sysUser1.getUserId());
-            List<SysUserRole> userRoleList = new ArrayList<>();
-            userRoleList.add(yhyjsxx);
-            sysUserRoleMapper.batchUserRole(userRoleList);
+//            log.info("sysUser1鐨処D涓猴細{}", sysUser1.getUserId());
+//            log.info("sysUser1鐨凥ISUSERID涓猴細{}", sysUser1.getHisUserId());
+//            //鏂板鐢ㄦ埛涓庤鑹�
+//            SysUserRole yhyjsxx = chMapper.yhyjsxx(sysUser1);
+//            if (yhyjsxx != null&&yhyjsxx.getUserId()!=null) {
+//                yhyjsxx.setUserId(sysUser1.getUserId());
+//                List<SysUserRole> userRoleList = new ArrayList<>();
+//                userRoleList.add(yhyjsxx);
+//                sysUserRoleMapper.batchUserRole(userRoleList);
+//            }
+            if (StringUtils.isEmpty(sysUser1.getHisUserId())) continue;
+            SysUser suTemp=new SysUser();
+            suTemp.setHisUserId(sysUser1.getHisUserId());
+            List<SysUser> usersTemp= sysUser2Mapper.selectUserList(suTemp);
+            if (usersTemp.size()>0) {
+                sysUser1.setUserId(usersTemp.get(0).getUserId());
+                sysUser2Mapper.updateUser(sysUser1);
+            }else{
+                sysUser2Mapper.insertUser(sysUser1);
+                usersTemp= sysUser2Mapper.selectUserList(suTemp);
+            }
 
             //鏂板鐢ㄦ埛涓庨儴闂�
-            if (StringUtils.isEmpty(sysUser1.getHisUserId())) continue;
-            SysUserDept sysUserDept = chMapper.yhyksxx(sysUser1);
-            if (Objects.isNull(sysUserDept) || sysUserDept.getDeptId() == null) continue;
-            SysDept dept = new SysDept();
-            dept.setHisDeptId(sysUserDept.getDeptId().toString());
-            List<SysDept> sysDepts = sysDept2Mapper.selectDeptList(dept);
-            if (CollectionUtils.isNotEmpty(sysDepts)) {
-                sysUserDept.setDeptId(sysDepts.get(0).getDeptId());
-                sysUserDept.setDeptCode(sysDepts.get(0).getDeptCode());
-            }
-            sysUserDept.setUserId(sysUser1.getUserId());
-            sysUserDeptMapper.insertSysUserDept(sysUserDept);
+            List<SysUserDept> sysUserDept = chMapper.yhyksxx(sysUser1);
+            for(SysUserDept sud :sysUserDept) {
+                if (usersTemp.size()>0) {
+                    sud.setUserId(usersTemp.get(0).getUserId());
+                    sysUserDeptMapper.insertSysUserDept(sud);
+                }
 
+            }
         }
 
         return i;
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
index 30ae035..e8d87d5 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -771,9 +771,8 @@
     public void collectHIS() {
         try {
             // HIS鏁版嵁閲囬泦
-            HnDataGatherVO hnDataGatherVO = new HnDataGatherVO();
             log.info("銆恉ealHisData銆慔IS寮�濮嬮噰闆嗘暟鎹�");
-            ichService.hnDataGather(hnDataGatherVO);
+            ichService.sync();
             log.info("銆恉ealHisData銆慔IS缁撴潫閲囬泦鏁版嵁");
         } catch (Exception e) {
             log.error("銆恉ealHisData銆慔IS鏁版嵁閲囬泦寮傚父", e);
diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/CollectHISMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/CollectHISMapper.xml
index ab2ed3a..358f030 100644
--- a/ruoyi-quartz/src/main/resources/mapper/quartz/CollectHISMapper.xml
+++ b/ruoyi-quartz/src/main/resources/mapper/quartz/CollectHISMapper.xml
@@ -372,8 +372,7 @@
     </select>
 
     <select id="yhyksxx" parameterType="com.ruoyi.common.core.domain.entity.SysUser" resultMap="SysUserDeptResult">
-        select user_id, user_code, dept_type,dept_code as
-        dept_id,dept_name,deptparent,del_flag,orgid
+        select user_id, user_code, dept_type,dept_code as dept_id,dept_code,dept_name,deptparent,del_flag,orgid
         FROM healthy_user_dept
         <where>
             user_id != 'admin'
@@ -414,6 +413,12 @@
             <if test="casePersonAge != null ">and case_person_age = #{casePersonAge}</if>
             <if test="filterDrname != null ">and filter_drname = #{filterDrname}</if>
             <if test="filterDrcode != null ">and filter_drcode = #{filterDrcode}</if>
+            <if test="lastStartTime != null and lastStartTime != ''">
+                and to_char(last_Update_Time, 'YYYY-MM-DD HH24:MI:SS') >= #{lastStartTime}
+            </if>
+            <if test="lastEndTime != null and lastEndTime != ''">
+                and to_char(last_Update_Time, 'YYYY-MM-DD HH24:MI:SS') &lt;= #{lastEndTime}
+            </if>
         </where>
     </select>
 
@@ -511,6 +516,12 @@
             <if test="outWayId != null ">and b.out_way_id = #{outWayId}</if>
             <if test="outWayName != null ">and b.out_way_name = #{outWayName}</if>
             <if test="orgid != null ">and b.orgid = #{orgid}</if>
+            <if test="lastStartTime != null and lastStartTime != ''">
+                and to_char(last_Update_Time, 'YYYY-MM-DD HH24:MI:SS') >= #{lastStartTime}
+            </if>
+            <if test="lastEndTime != null and lastEndTime != ''">
+                and to_char(last_Update_Time, 'YYYY-MM-DD HH24:MI:SS') &lt;= #{lastEndTime}
+            </if>
         </where>
     </select>
 
@@ -546,7 +557,12 @@
             <if test="endTime != null ">
                 and to_char(admitdate, 'YYYY-MM-DD HH24:MI:SS') &lt;= to_char(#{endTime}, 'YYYY-MM-DD HH24:MI:SS')
             </if>
-
+            <if test="lastStartTime != null and lastStartTime != ''">
+                and to_char(last_Update_Time, 'YYYY-MM-DD HH24:MI:SS') >= #{lastStartTime}
+            </if>
+            <if test="lastEndTime != null and lastEndTime != ''">
+                and to_char(last_Update_Time, 'YYYY-MM-DD HH24:MI:SS') &lt;= #{lastEndTime}
+            </if>
         </where>
     </select>
 
diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/UtilsMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/UtilsMapper.xml
new file mode 100644
index 0000000..e04d94d
--- /dev/null
+++ b/ruoyi-quartz/src/main/resources/mapper/quartz/UtilsMapper.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.quartz.mapper.UtilsMapper">
+
+</mapper>
\ No newline at end of file
diff --git a/smartor/src/main/java/com/smartor/domain/PatArchive.java b/smartor/src/main/java/com/smartor/domain/PatArchive.java
index 8a8701c..0481c35 100644
--- a/smartor/src/main/java/com/smartor/domain/PatArchive.java
+++ b/smartor/src/main/java/com/smartor/domain/PatArchive.java
@@ -416,4 +416,10 @@
     @ApiModelProperty("ps")
     private Integer ps;
 
+    @ApiModelProperty(value = "鏈�鍚庡紑濮嬫椂闂�")
+    private String lastStartTime;
+
+    @ApiModelProperty(value = "鏈�鍚庣粨鏉熸椂闂�")
+    private String lastEndTime;
+
 }
diff --git a/smartor/src/main/java/com/smartor/domain/PatMedInhosp.java b/smartor/src/main/java/com/smartor/domain/PatMedInhosp.java
index e2d662a..69b3d78 100644
--- a/smartor/src/main/java/com/smartor/domain/PatMedInhosp.java
+++ b/smartor/src/main/java/com/smartor/domain/PatMedInhosp.java
@@ -463,4 +463,10 @@
     @ApiModelProperty("缁忕鍖荤敓")
     @Excel(name = " 缁忕鍖荤敓 ")
     private String managementDoctorCode;
+
+    @ApiModelProperty(value = "鏈�鍚庡紑濮嬫椂闂�")
+    private String lastStartTime;
+
+    @ApiModelProperty(value = "鏈�鍚庣粨鏉熸椂闂�")
+    private String lastEndTime;
 }
diff --git a/smartor/src/main/java/com/smartor/domain/PatMedOuthosp.java b/smartor/src/main/java/com/smartor/domain/PatMedOuthosp.java
index b56d265..0ed79a0 100644
--- a/smartor/src/main/java/com/smartor/domain/PatMedOuthosp.java
+++ b/smartor/src/main/java/com/smartor/domain/PatMedOuthosp.java
@@ -229,6 +229,10 @@
     @ApiModelProperty(value = "鏄惁鏈夐殢璁�0娌℃湁;>=1鏈夐殢璁� ")
     private String serverState;
 
+    @ApiModelProperty(value = "鏈�鍚庡紑濮嬫椂闂�")
+    private String lastStartTime;
 
+    @ApiModelProperty(value = "鏈�鍚庣粨鏉熸椂闂�")
+    private String lastEndTime;
 
 }
diff --git a/smartor/src/main/java/com/smartor/mapper/PatMedInhospMapper.java b/smartor/src/main/java/com/smartor/mapper/PatMedInhospMapper.java
index 8f5b310..1116ce8 100644
--- a/smartor/src/main/java/com/smartor/mapper/PatMedInhospMapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/PatMedInhospMapper.java
@@ -35,6 +35,8 @@
      */
     public List<PatMedInhosp> selectPatMedInhospList(PatMedInhosp patMedInhosp);
 
+    public List<PatMedInhosp> selectPatMedInhospListBySerialnum(PatMedInhosp patMedInhosp);
+
     public List<PatMedInhosp> selectPatMedInhospListByCondition(PatMedInhospVO patMedInhospVO);
 
     /**
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
index 010442c..0827106 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -2312,7 +2312,7 @@
                 if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) {
                     serviceSubtaskStatistic.setPendingFollowUp(serviceSubtaskStatistic.getPendingFollowUp() + 1L);
                 }
-                if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate() == 1 || serviceSubtask.getSendstate() == 3 || serviceSubtask.getSendstate() == 6)) {
+                if (serviceSubtask.getSendstate() != null && ( serviceSubtask.getSendstate() == 6)) {
                     serviceSubtaskStatistic.setFollowUpSuccess(serviceSubtaskStatistic.getFollowUpSuccess() + 1L);
                 }
                 if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 5) {
diff --git a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
index 986f899..272f207 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
@@ -300,6 +300,78 @@
             order by b.starttime desc
         </if>
     </select>
+
+    <select id="selectPatMedInhospListBySerialnum" parameterType="com.smartor.domain.PatMedInhosp" resultMap="PatMedInhospResult">
+        select
+        b.inhospid,
+        b.nurse_id,
+        b.nurse_name,
+        b.patname,
+        b.management_doctor,
+        b.management_doctor_code,
+        b.out_way_id,
+        b.out_way_name,
+        b.deptcheck_flag,
+        b.wardcheck_flag,
+        b.diagcheck_flag,
+        b.inhospstate,
+        b.patno,
+        b.inhospno,
+        b.serialnum,
+        b.hospitalname,
+        b.hospitalcode,
+        b.hospitaldistrictcode,
+        b.hospitaldistrictname,
+        b.icd10code,
+        b.diagname,
+        b.starttime,
+        b.endtime,
+        b.deptcode,
+        b.deptname,
+        b.roomno,
+        b.bed_no,
+        b.orgid,
+        b.del_flag,
+        b.update_by,
+        b.update_time,
+        b.create_by,
+        b.create_time,
+        b.isupload,
+        b.upload_time,
+        b.patid,
+        b.leavediagname,
+        b.leaveicd10code,
+        b.drcode,
+        b.drname,
+        b.schemestatus,
+        b.generalschemestatus,
+        b.leaveldeptcode,
+        b.leaveldeptname,
+        b.hospitaldistrictid,
+        b.leavehospitaldistrictcode,
+        b.leavehospitaldistrictname,
+        b.leavehospitaldistrictid,
+        b.deptid,
+        b.leaveldeptid,
+        b.long_task_reason,
+        b.schemetime,
+        b.fuflag,
+        b.fudate,
+        b.fuperiod,
+        b.futypecode,
+        b.futypedesc,
+        b.fuadvice,
+        b.fuspecialadvice
+        FROM
+        pat_med_inhosp b
+
+        <where>
+            <if test="serialnum != null ">and b.serialnum = #{serialnum}</if>
+
+        </where>
+        order by b.inhospid desc
+    </select>
+
     <select id="selectPatMedInhospListByCondition" parameterType="com.smartor.domain.PatMedInhospVO"
             resultMap="PatMedInhospResult">
         select CONCAT( a.age, a.age_unit ) AS age,
@@ -415,6 +487,7 @@
         order by b.inhospid desc
     </select>
 
+
     <select id="getTagnameBypatid" parameterType="Long" resultType="string">
         SELECT GROUP_CONCAT(d.tagname, ', ')
         FROM pat_archivetag d

--
Gitblit v1.9.3