From 1fb7fc160753c4283f7b84c14f931d87b6c922e4 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 10 七月 2025 14:58:05 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/mapper/SysDept2Mapper.java                   |   13 +
 smartor/src/main/java/com/smartor/mapper/Icd10Mapper.java                      |    3 
 .idea/modules.xml                                                              |    4 
 smartor/src/main/java/com/smartor/mapper/SysUser2Mapper.java                   |    8 +
 smartor/src/main/java/com/smartor/mapper/PatMedOuthospMapper.java              |   38 ++++++
 smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java |   48 +++++++
 smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml              |  104 +++++++++++++++++
 ruoyi-admin/src/main/resources/logback.xml                                     |    2 
 smartor/src/main/resources/mapper/smartor/Icd10Mapper.xml                      |   40 ++++++
 .idea/misc.xml                                                                 |    3 
 smartor/src/main/resources/mapper/smartor/SysDeptMapper.xml                    |   54 ++++++++
 smartor/src/main/resources/mapper/smartor/SysUserMapper.xml                    |   42 ++++++
 12 files changed, 341 insertions(+), 18 deletions(-)

diff --git a/.idea/misc.xml b/.idea/misc.xml
index 25daa30..00118d8 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
+  <component name="ExternalStorageConfigurationManager" enabled="true" />
   <component name="MavenProjectsManager">
     <option name="originalFiles">
       <list>
@@ -8,4 +9,4 @@
     </option>
   </component>
   <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
-</project>
\ No newline at end of file
+</project>
diff --git a/.idea/modules.xml b/.idea/modules.xml
index b6443bd..8a75ce6 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,6 @@
 <project version="4">
   <component name="ProjectModuleManager">
     <modules>
-      <module fileurl="file://$PROJECT_DIR$/ruoyi.iml" filepath="$PROJECT_DIR$/ruoyi.iml" />
       <module fileurl="file://$PROJECT_DIR$/ruoyi-admin/ruoyi-admin.iml" filepath="$PROJECT_DIR$/ruoyi-admin/ruoyi-admin.iml" />
       <module fileurl="file://$PROJECT_DIR$/ruoyi-common/ruoyi-common.iml" filepath="$PROJECT_DIR$/ruoyi-common/ruoyi-common.iml" />
       <module fileurl="file://$PROJECT_DIR$/ruoyi-framework/ruoyi-framework.iml" filepath="$PROJECT_DIR$/ruoyi-framework/ruoyi-framework.iml" />
@@ -10,7 +9,6 @@
       <module fileurl="file://$PROJECT_DIR$/ruoyi-quartz/ruoyi-quartz.iml" filepath="$PROJECT_DIR$/ruoyi-quartz/ruoyi-quartz.iml" />
       <module fileurl="file://$PROJECT_DIR$/ruoyi-system/ruoyi-system.iml" filepath="$PROJECT_DIR$/ruoyi-system/ruoyi-system.iml" />
       <module fileurl="file://$PROJECT_DIR$/smartor/smartor.iml" filepath="$PROJECT_DIR$/smartor/smartor.iml" />
-      <module fileurl="file://$PROJECT_DIR$/ruoyi-admin/smartor-admin.iml" filepath="$PROJECT_DIR$/ruoyi-admin/smartor-admin.iml" />
     </modules>
   </component>
-</project>
\ No newline at end of file
+</project>
diff --git a/ruoyi-admin/src/main/resources/logback.xml b/ruoyi-admin/src/main/resources/logback.xml
index ab17872..96dd132 100644
--- a/ruoyi-admin/src/main/resources/logback.xml
+++ b/ruoyi-admin/src/main/resources/logback.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
     <!-- 鏃ュ織瀛樻斁璺緞 8095-->
-    <property name="log.path" value="D:/health/logs"/>
+    <property name="log.path" value="E:/health/logs"/>
     <!-- 鏃ュ織瀛樻斁璺緞 8096-->
     <!--    <property name="log.path" value="D:/lihu/logs"/>-->
     <!-- 涓芥按鏃ュ織瀛樻斁璺緞 -->
diff --git a/smartor/src/main/java/com/smartor/mapper/Icd10Mapper.java b/smartor/src/main/java/com/smartor/mapper/Icd10Mapper.java
index 0c040de..2354f6f 100644
--- a/smartor/src/main/java/com/smartor/mapper/Icd10Mapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/Icd10Mapper.java
@@ -37,6 +37,9 @@
      */
     public int insertIcd10(Icd10 icd10);
 
+    public int batchIcd10(List<Icd10> icd10s);
+
+
     /**
      * 淇敼鐤剧梾
      *
diff --git a/smartor/src/main/java/com/smartor/mapper/PatMedOuthospMapper.java b/smartor/src/main/java/com/smartor/mapper/PatMedOuthospMapper.java
index ddd332c..8a00b1b 100644
--- a/smartor/src/main/java/com/smartor/mapper/PatMedOuthospMapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/PatMedOuthospMapper.java
@@ -6,6 +6,7 @@
 import com.smartor.domain.PatMedReq;
 import com.smartor.domain.PatMedRes;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 鎮h�呴棬璇婅褰昅apper鎺ュ彛
@@ -39,6 +40,8 @@
      */
     public int insertPatMedOuthosp(PatMedOuthosp patMedOuthosp);
 
+    public int batchPatMedOuthosp(List<PatMedOuthosp> patMedOuthosps);
+
     /**
      * 淇敼鎮h�呴棬璇婅褰�
      *
@@ -66,4 +69,39 @@
     PatMedRes selectPatMedOuthospCount(PatMedReq patMedReq);
 
     public List<PatMedRes> getDeptRanking(PatMedReq patMedReq);
+
+    /**
+     * 鑾峰彇琛ㄧ殑鏁伴噺
+     *
+     * @return
+     */
+    int countPatMedOuthosp();
+
+    /**
+     * 淇敼琛ㄥ悕
+     *
+     * @return
+     */
+    void renameTable(@Param("oldName") String oldName, @Param("newName") String newName);
+
+    /**
+     * 鍒涘缓鏂拌〃
+     *
+     * @param templateName
+     * @param newName
+     */
+    void createPatMedOuthosp(@Param("templateName") String templateName, @Param("newName") String newName);
+
+
+    void setAutoIncrement(@Param("tableName") String tableName, @Param("autoInc") long autoInc);
+
+    // 鏌ヨ鎵�鏈� pat_med_outhosp 寮�澶寸殑琛ㄥ悕
+    List<String> getAllOuthospTableNames();
+
+    // 鏌ヨ鎸囧畾琛ㄧ殑鏈�澶d
+    Long getMaxIdFromTable(@Param("tableName") String tableName);
+
+    void createOrReplaceView(@Param("viewSql") String viewSql);
 }
+
+
diff --git a/smartor/src/main/java/com/smartor/mapper/SysDept2Mapper.java b/smartor/src/main/java/com/smartor/mapper/SysDept2Mapper.java
index c438dcc..95a5967 100644
--- a/smartor/src/main/java/com/smartor/mapper/SysDept2Mapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/SysDept2Mapper.java
@@ -12,8 +12,7 @@
  * @author ruoyi
  */
 @Mapper
-public interface SysDept2Mapper
-{
+public interface SysDept2Mapper {
     /**
      * 鏌ヨ閮ㄩ棬绠$悊鏁版嵁
      *
@@ -25,7 +24,7 @@
     /**
      * 鏍规嵁瑙掕壊ID鏌ヨ閮ㄩ棬鏍戜俊鎭�
      *
-     * @param roleId 瑙掕壊ID
+     * @param roleId            瑙掕壊ID
      * @param deptCheckStrictly 閮ㄩ棬鏍戦�夋嫨椤规槸鍚﹀叧鑱旀樉绀�
      * @return 閫変腑閮ㄩ棬鍒楄〃
      */
@@ -91,6 +90,14 @@
     public int insertDept(SysDept dept);
 
     /**
+     * 鎵归噺鏂板閮ㄩ棬淇℃伅
+     *
+     * @param depts 閮ㄩ棬淇℃伅
+     * @return 缁撴灉
+     */
+    public int batchDept(List<SysDept> depts);
+
+    /**
      * 淇敼閮ㄩ棬淇℃伅
      *
      * @param dept 閮ㄩ棬淇℃伅
diff --git a/smartor/src/main/java/com/smartor/mapper/SysUser2Mapper.java b/smartor/src/main/java/com/smartor/mapper/SysUser2Mapper.java
index 884efaf..684c797 100644
--- a/smartor/src/main/java/com/smartor/mapper/SysUser2Mapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/SysUser2Mapper.java
@@ -62,6 +62,14 @@
     public int insertUser(SysUser user);
 
     /**
+     * 鎵归噺鏂板鐢ㄦ埛淇℃伅
+     *
+     * @param user 鐢ㄦ埛淇℃伅
+     * @return 缁撴灉
+     */
+    public int batchUser(List<SysUser> users);
+
+    /**
      * 淇敼鐢ㄦ埛淇℃伅
      *
      * @param user 鐢ㄦ埛淇℃伅
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
index 73f905f..c8e8bb5 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -826,6 +826,9 @@
     @Override
     public Boolean addFinshJZInfo(Map dataMap) {
         log.info("ServiceExternalServiceImpl---addFinshJZInfo鐨勬柊澧炵殑鍊间负锛歿}", dataMap);
+        //鍏堝琛ㄨ繘琛岀淮鎶�
+        tableMaintenance();
+
         Map yeWuXX = (Map) dataMap.get("YeWuXX");
         Map XiaoXiTou = (Map) dataMap.get("XiaoXiTou");
         String FaSongJGID = ObjectUtils.isNotEmpty(XiaoXiTou.get("FaSongJGID")) ? XiaoXiTou.get("FaSongJGID").toString() : null;
@@ -908,10 +911,53 @@
         if (i > 0) {
             return true;
         }
-
         return false;
     }
 
+
+    public void tableMaintenance() {
+        // 1. 鍒ゆ柇琛ㄦ暟鎹噺
+        int count = patMedOuthospMapper.countPatMedOuthosp();
+        if (count > 3000000) {
+            // 2. 鍐疯棌琛ㄥ苟鏂板缓
+            String timeSuffix = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+            String oldName = "pat_med_outhosp";
+            String newName = oldName + "_" + timeSuffix;
+
+            // 鍐疯棌
+            patMedOuthospMapper.renameTable(oldName, newName);
+
+            // 3. 璁$畻鎵�鏈夎〃鐨勬渶澶d
+            List<String> tableNames = patMedOuthospMapper.getAllOuthospTableNames();
+            long maxId = 0;
+            for (String tableName : tableNames) {
+                Long tableMaxId = patMedOuthospMapper.getMaxIdFromTable(tableName);
+                if (tableMaxId != null && tableMaxId > maxId) {
+                    maxId = tableMaxId;
+                }
+            }
+
+            // 4. 鏂板缓
+            patMedOuthospMapper.createPatMedOuthosp(oldName, newName);
+
+            // 5. 璁剧疆鏂拌〃鑷璧峰鍊�
+            patMedOuthospMapper.setAutoIncrement(oldName, maxId + 1);
+
+            // 6. 鏇存柊/鏂板缓瑙嗗浘
+            // 閲嶆柊鑾峰彇鎵�鏈夎〃鍚嶏紙鍖呭惈鍒氭柊寤虹殑涓昏〃锛�
+            List<String> allTables = patMedOuthospMapper.getAllOuthospTableNames();
+            StringBuilder sb = new StringBuilder();
+            sb.append("CREATE OR REPLACE VIEW v_pat_med_outhosp AS ");
+            for (int i = 0; i < allTables.size(); i++) {
+                sb.append("SELECT * FROM ").append(allTables.get(i));
+                if (i < allTables.size() - 1) {
+                    sb.append(" UNION ALL ");
+                }
+            }
+            patMedOuthospMapper.createOrReplaceView(sb.toString());
+        }
+    }
+
     @Override
     public Boolean addDiseaseInfo(Map dataMap) {
         log.info("ServiceExternalServiceImpl---addDiseaseInfo鐨勬柊澧炵殑鍊间负锛歿}", dataMap);
diff --git a/smartor/src/main/resources/mapper/smartor/Icd10Mapper.xml b/smartor/src/main/resources/mapper/smartor/Icd10Mapper.xml
index 527dc20..3447bc3 100644
--- a/smartor/src/main/resources/mapper/smartor/Icd10Mapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/Icd10Mapper.xml
@@ -103,6 +103,46 @@
         </trim>
     </insert>
 
+    <insert id="batchIcd10">
+        insert into icd10
+        (
+        icdcode,
+        icdname,
+        icdpym,
+        icdwbm,
+        orgid,
+        del_flag,
+        create_by,
+        create_time,
+        update_by,
+        update_time,
+        pid,
+        guid,
+        lastflag,
+        chimedflag,
+        his_icdid)
+        VALUES
+        <foreach collection="list" item="item" separator=",">
+            (
+            #{item.icdcode},
+            #{item.icdname},
+            #{item.icdpym},
+            #{item.icdwbm},
+            #{item.orgid},
+            #{item.delFlag},
+            #{item.createBy},
+            #{item. createTime},
+            #{item.updateBy},
+            #{item.updateTime},
+            #{item.pid},
+            #{item.guid},
+            #{item.lastflag},
+            #{item.chimedflag},
+            #{item.  hisIcdid,}
+            )
+        </foreach>
+    </insert>
+
     <update id="updateIcd10" parameterType="com.smartor.domain.Icd10">
         update icd10
         <trim prefix="SET" suffixOverrides=",">
diff --git a/smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml
index 84fedd6..6822850 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml
@@ -130,7 +130,6 @@
             </if>
             <if test="patid != null ">and pmo.patid = #{patid}</if>
             <if test="patno != null ">and pmo.patno = #{patno}</if>
-            <if test="orgid != null  and orgid != ''">and pmo.orgid = #{orgid}</if>
             <if test="outhospno != null  and outhospno != ''">and pmo.outhospno = #{outhospno}</if>
             <if test="diagcheckFlag != null  and diagcheckFlag != ''">and pmo.diagcheck_flag = #{diagcheckFlag}</if>
         </where>
@@ -210,6 +209,78 @@
             <if test="remark != null">#{remark},</if>
         </trim>
     </insert>
+
+    <insert id="batchPatMedOuthosp">
+        insert into pat_med_outhosp
+        (
+        serialnum,
+        patid,
+        hospitalname,
+        hospitalcode,
+        icd10code,
+        diagname,
+        deptcode,
+        deptname,
+        drcode,
+        drname,
+        admitdate,
+        orgid,
+        del_flag,
+        update_by,
+        update_time,
+        create_by,
+        create_time,
+        isupload,
+        upload_time,
+        schemestatus,
+        deptid,
+        schemetime,
+        hpi,
+        mainsuit,
+        outhospno,
+        patname,
+        guid,
+        patno,
+        diagcheck_flag,
+        remark)
+        values
+        <foreach collection="list" item="item" separator=",">
+            (
+            #{item.serialnum},
+            #{item.patid},
+            #{item.hospitalname},
+            #{item.hospitalcode},
+            #{item.icd10code},
+            #{item.diagname},
+            #{item.deptcode},
+            #{item.deptname},
+            #{item.drcode},
+            #{item.drname},
+            #{item.admitdate},
+            #{item.orgid},
+            #{item.delFlag},
+            #{item.updateBy},
+            #{item.updateTime},
+            #{item.createBy},
+            #{item.createTime},
+            #{item.isupload},
+            #{item.uploadTime},
+            #{item.schemestatus},
+            #{item.deptid},
+            #{item.schemetime},
+            #{item.hpi},
+            #{item.hpi},
+            #{item.mainsuit},
+            #{item.outhospno},
+            #{item.patname},
+            #{item.guid},
+            #{item.patno},
+            #{item.diagcheckFlag},
+            #{item.remark}
+            )
+        </foreach>
+    </insert>
+
 
     <update id="updatePatMedOuthosp" parameterType="com.smartor.domain.PatMedOuthosp">
         update pat_med_outhosp
@@ -297,4 +368,35 @@
             </if>
         </where>
     </select>
+
+    <!-- PatMedOuthospMapper.xml -->
+    <select id="countPatMedOuthosp" resultType="int">
+        SELECT COUNT(*) FROM pat_med_outhosp
+    </select>
+
+    <update id="renameTable">
+        RENAME TABLE ${oldName} TO ${newName}
+    </update>
+
+    <update id="createPatMedOuthosp">
+        CREATE TABLE ${newName} LIKE ${templateName}
+    </update>
+
+    <update id="setAutoIncrement">
+        ALTER TABLE ${tableName} AUTO_INCREMENT = #{autoInc}
+    </update>
+
+    <select id="getAllOuthospTableNames" resultType="String">
+        SELECT table_name FROM information_schema.tables
+        WHERE table_schema = DATABASE() AND table_name LIKE 'pat_med_outhosp%'
+    </select>
+
+    <select id="getMaxIdFromTable" resultType="Long">
+        SELECT IFNULL(MAX(id), 0) FROM ${tableName}
+    </select>
+
+    <update id="createOrReplaceView">
+        ${viewSql}
+    </update>
+
 </mapper>
diff --git a/smartor/src/main/resources/mapper/smartor/SysDeptMapper.xml b/smartor/src/main/resources/mapper/smartor/SysDeptMapper.xml
index 13bd562..089aa5e 100644
--- a/smartor/src/main/resources/mapper/smartor/SysDeptMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/SysDeptMapper.xml
@@ -57,7 +57,8 @@
         where d.del_flag = '0'
         <if test="deptId != null and deptId != 0">
             AND dept_id = #{deptId}
-        </if> <if test="type != null">
+        </if>
+        <if test="type != null">
             AND type = #{type}
         </if>
         <if test="parentId != null and parentId != 0">
@@ -112,7 +113,7 @@
                d.orgid,
                d.his_dept_id,
                d.his_parent_id
-               (select dept_name from sys_dept where dept_id = d.parent_id) parent_name
+                   (select dept_name from sys_dept where dept_id = d.parent_id) parent_name
         from sys_dept d
         where d.dept_id = #{deptId}
     </select>
@@ -132,7 +133,7 @@
                d.orgid,
                d.his_dept_id,
                d.his_parent_id
-               d.status
+            d.status
         from sys_dept d
         where del_flag = 0
           and d.dept_code = #{deptCode}
@@ -171,6 +172,53 @@
         where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
     </select>
 
+
+    <insert id="batchDept">
+        insert into sys_dept(
+        dept_id,
+        parent_id,
+        dept_name,
+        ancestors,
+        order_num,
+        leader,
+        phone,
+        email,
+        status,
+        dept_code,
+        dept_type,
+        create_by,
+        his_dept_id,
+        his_parent_id,
+        type,
+        guid,
+        orgid,
+        create_time
+        ) values
+        <foreach collection="list" item="item" separator=",">
+            (
+            #{item.deptId},
+            #{item.parentId},
+            #{item.deptName},
+            #{item.ancestors},
+            #{item.orderNum},
+            #{item.leader},
+            #{item.phone},
+            #{item.email},
+            #{item.status},
+            #{item.deptCode},
+            #{item.deptType},
+            #{item.createBy},
+            #{item.hisDeptId},
+            #{item.hisParentId},
+            #{item.type},
+            #{item.guid},
+            #{item.orgid},
+            now()
+            )
+        </foreach>
+    </insert>
+
+
     <insert id="insertDept" parameterType="com.ruoyi.common.core.domain.entity.SysDept">
         insert into sys_dept(
         <if test="deptId != null and deptId != 0">dept_id,</if>
diff --git a/smartor/src/main/resources/mapper/smartor/SysUserMapper.xml b/smartor/src/main/resources/mapper/smartor/SysUserMapper.xml
index 861e149..515c620 100644
--- a/smartor/src/main/resources/mapper/smartor/SysUserMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/SysUserMapper.xml
@@ -309,6 +309,43 @@
         )
     </insert>
 
+
+    <insert id="batchUser">
+        insert into sys_user(
+        user_id, dept_id, user_name, nick_name, email, avatar, phonenumber, sex, password, status, create_by, remark,
+        user_type, dept_info, hosp_info, searchscope, id_card, title, job_phone, birthday, his_user_id, guid, orgid,
+        create_time
+        ) values
+        <foreach collection="list" item="item" separator=",">
+            (
+            #{item.userId},
+            #{item.deptId},
+            #{item.userName},
+            #{item.nickName},
+            #{item.email},
+            #{item.avatar},
+            #{item.phonenumber},
+            #{item.sex},
+            #{item.password},
+            #{item.status},
+            #{item.createBy},
+            #{item.remark},
+            #{item.userType},
+            #{item.deptInfo},
+            #{item.hospInfo},
+            #{item.searchscope},
+            #{item.idCard},
+            #{item.title},
+            #{item.jobPhone},
+            #{item.birthday},
+            #{item.hisUserId},
+            #{item.guid},
+            #{item.orgid},
+            now()
+            )
+        </foreach>
+    </insert>
+
     <update id="updateUser" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
         update sys_user
         <set>
@@ -344,11 +381,6 @@
         where user_id = #{userId}
     </update>
 
-    <update id="updateUserStatus" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
-        update sys_user
-        set status = #{status}
-        where user_id = #{userId}
-    </update>
 
     <update id="updateUserAvatar" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
         update sys_user

--
Gitblit v1.9.3