From 7de1396e315896dbc72a9d54e44f77434ea90f18 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 14 十二月 2025 23:47:34 +0800
Subject: [PATCH] feat:增加企业微信自动登录

---
 ruoyi-system/src/main/resources/mapper/system/HospDataMapper.xml |  167 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 133 insertions(+), 34 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/HospDataMapper.xml b/ruoyi-system/src/main/resources/mapper/system/HospDataMapper.xml
index 6be16ba..eb79203 100644
--- a/ruoyi-system/src/main/resources/mapper/system/HospDataMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/HospDataMapper.xml
@@ -5,47 +5,146 @@
 <mapper namespace="com.ruoyi.system.mapper.HospDataMapper">
     
     <resultMap type="HospData" id="HospDataResult">
-        <result property="hospId" column="HospID" />
-        <result property="hospName" column="HospName" />
-        <result property="hospCityId" column="HospCityID" />
-        <result property="hospShort" column="HospShort" />
-        <result property="hopsProvince" column="HopsProvince" />
-        <result property="hopsCity" column="HopsCity" />
-        <result property="hopsArea" column="HopsArea" />
-        <result property="hospAddress" column="HospAddress" />
-        <result property="hospTel" column="HospTEL" />
-        <result property="hospUnitId" column="HospUnitID" />
-        <result property="hospState" column="HospState" />
-        <result property="hospOaId" column="HospOAID" />
-        <result property="hospIntroducerId" column="HospIntroducerID" />
-        <result property="hospIntroducerDate" column="HospIntroducerDate" />
-        <result property="hospLevel" column="HospLevel" />
+        <result property="hospId" column="legacy_hosp_id" />
+        <result property="hospName" column="hosp_name" />
+        <result property="hospCityId" column="hosp_city_id" />
+        <result property="hospShort" column="hosp_short" />
+        <result property="hopsProvince" column="hops_province" />
+        <result property="hopsCity" column="hops_city" />
+        <result property="hopsArea" column="hops_area" />
+        <result property="hospAddress" column="hosp_address" />
+        <result property="hospTel" column="hosp_tel" />
+        <result property="hospUnitId" column="hosp_unit_id" />
+        <result property="hospState" column="hosp_state" />
+        <result property="hospOaId" column="hosp_oa_id" />
+        <result property="hospIntroducerId" column="hosp_introducer_id" />
+        <result property="hospIntroducerDate" column="hosp_introducer_date" />
+        <result property="hospLevel" column="hosp_level" />
     </resultMap>
 
-    <select id="searchHospitals" parameterType="String" resultMap="HospDataResult">
-        SELECT TOP 50
-            HospID, HospName, HospCityID, HospShort, 
-            HopsProvince, HopsCity, HopsArea, HospAddress, 
-            HospTEL, HospUnitID, HospState, HospOAID, 
-            HospIntroducerID, HospIntroducerDate, HospLevel
-        FROM HospData
-        WHERE 1=1
+    <select id="searchHospitals" resultMap="HospDataResult">
+        SELECT legacy_hosp_id, hosp_name, hosp_city_id, hosp_short,
+            hops_province, hops_city, hops_area, hosp_address, 
+            hosp_tel, hosp_unit_id, hosp_state, hosp_oa_id, 
+            hosp_introducer_id, hosp_introducer_date, hosp_level
+        FROM tb_hosp_data
+        WHERE status = '0'
+        <!-- 鏈� keyword 灏卞彧鐢� keyword锛屼笉鐢� region -->
         <if test="keyword != null and keyword != ''">
-            AND (HospName LIKE '%' + #{keyword} + '%' 
-                 OR HospAddress LIKE '%' + #{keyword} + '%'
-                 OR HospShort LIKE '%' + #{keyword} + '%')
+        AND (
+            hops_province LIKE CONCAT('%', #{keyword}, '%')
+                OR hops_city LIKE CONCAT('%', #{keyword}, '%')
+                OR hops_area LIKE CONCAT('%', #{keyword}, '%')
+                OR hosp_address LIKE CONCAT('%', #{keyword}, '%')
+                OR hosp_name LIKE CONCAT('%', #{keyword}, '%')
+                OR hosp_short LIKE CONCAT('%', #{keyword}, '%')
+        )
         </if>
-        AND (HospState IS NULL OR HospState = 1)
-        ORDER BY HospName
+        <!-- 娌℃湁 keyword 鏃舵墠鐢� region -->
+        <if test="(keyword == null or keyword == '') and (region != null and region != '')">
+        AND (
+            hops_province LIKE CONCAT('%', #{region}, '%')
+                OR hops_city LIKE CONCAT('%', #{region}, '%')
+                OR hops_area LIKE CONCAT('%', #{region}, '%')
+                OR hosp_address LIKE CONCAT('%', #{region}, '%')
+                OR hosp_name LIKE CONCAT('%', #{region}, '%')
+                OR hosp_short LIKE CONCAT('%', #{region}, '%')
+        )
+        </if>
+        AND (hosp_state IS NULL OR hosp_state = 1)
+        ORDER BY 
+            CASE WHEN hosp_name = '瀹朵腑' THEN 0 ELSE 1 END,
+            hosp_name
     </select>
     
     <select id="selectHospDataById" parameterType="Integer" resultMap="HospDataResult">
         SELECT 
-            HospID, HospName, HospCityID, HospShort, 
-            HopsProvince, HopsCity, HopsArea, HospAddress, 
-            HospTEL, HospUnitID, HospState, HospOAID, 
-            HospIntroducerID, HospIntroducerDate, HospLevel
-        FROM HospData
-        WHERE HospID = #{hospId}
+            legacy_hosp_id, hosp_name, hosp_city_id, hosp_short, 
+            hops_province, hops_city, hops_area, hosp_address, 
+            hosp_tel, hosp_unit_id, hosp_state, hosp_oa_id, 
+            hosp_introducer_id, hosp_introducer_date, hosp_level
+        FROM tb_hosp_data
+        WHERE legacy_hosp_id = #{hospId}
+    </select>
+    
+
+    <select id="getHomeHospId" resultType="java.lang.Integer">
+        select legacy_hosp_id from tb_hosp_data where hosp_name='瀹朵腑'
+    </select>
+    
+
+    <!-- 鏍规嵁鍖婚櫌ID鍒楄〃鏌ヨ鍖婚櫌淇℃伅 -->
+    <select id="selectHospDataByIds" resultMap="HospDataResult">
+        SELECT 
+            legacy_hosp_id, hosp_name, hosp_city_id, hosp_short, 
+            hops_province, hops_city, hops_area, hosp_address, 
+            hosp_tel, hosp_unit_id, hosp_state, hosp_oa_id, 
+            hosp_introducer_id, hosp_introducer_date, hosp_level
+        FROM tb_hosp_data
+        WHERE legacy_hosp_id IN
+        <foreach collection="hospIds" item="hospId" open="(" separator="," close=")">
+            #{hospId}
+        </foreach>
+        <if test="region != null and region != ''">
+        AND (
+            hops_province LIKE CONCAT('%', #{region}, '%')
+                OR hops_city LIKE CONCAT('%', #{region}, '%')
+                OR hosp_short LIKE CONCAT('%', #{region}, '%')
+                OR hops_area LIKE CONCAT('%', #{region}, '%')
+                OR hosp_address LIKE CONCAT('%', #{region}, '%')
+                OR hosp_name LIKE CONCAT('%', #{region}, '%')
+        )
+        </if>
+        AND (hosp_state IS NULL OR hosp_state = 1)
+        ORDER BY hosp_name
+    </select>
+    
+    <!-- 鏍规嵁閮ㄩ棬鍖哄煙閰嶇疆鏌ヨ鍖婚櫌锛堟敮鎸佸绾у尯鍩熻繃婊わ級 -->
+    <select id="searchHospitalsByDeptRegion" resultMap="HospDataResult">
+        SELECT DISTINCT
+            h.legacy_hosp_id, h.hosp_name, h.hosp_city_id, h.hosp_short, 
+            h.hops_province, h.hops_city, h.hops_area, h.hosp_address, 
+            h.hosp_tel, h.hosp_unit_id, h.hosp_state, h.hosp_oa_id, 
+            h.hosp_introducer_id, h.hosp_introducer_date, h.hosp_level
+        FROM tb_hosp_data h
+        WHERE (h.hosp_state IS NULL OR h.hosp_state = 1)
+        AND h.status = '0'
+        AND EXISTS (
+            SELECT 1 FROM sys_dept_region r
+            WHERE r.dept_id = #{deptId}
+            AND r.status = '0'
+            AND (
+                -- 鍖哄煙绫诲瀷锛氬湴鍩熻寖鍥村尮閰�
+                (r.region_type = 'AREA' AND (
+                    -- 鐪佷唤鍖归厤锛堜负绌哄垯璺宠繃锛�
+                    (r.province IS NULL OR r.province = '' OR h.hops_province LIKE CONCAT('%', r.province, '%'))
+                    -- 鍩庡競鍖归厤锛堜负绌哄垯璺宠繃锛�
+                    AND (r.city IS NULL OR r.city = '' OR h.hops_city LIKE CONCAT('%', r.city, '%'))
+                    -- 鍘�/鍖哄尮閰嶏紙涓虹┖鍒欒烦杩囷級
+                    AND (r.area IS NULL OR r.area = '' OR h.hops_area LIKE CONCAT('%', r.area, '%'))
+                    -- 璇︾粏鍦板潃鍖归厤锛堜负绌哄垯璺宠繃锛�
+                    AND (r.address IS NULL OR r.address = '' OR h.hosp_address LIKE CONCAT('%', r.address, '%'))
+                ))
+                -- 鍖哄煙绫诲瀷锛氭寚瀹氬尰闄㈠尮閰�
+                OR (r.region_type = 'HOSPITAL' AND r.hospital_name IS NOT NULL AND r.hospital_name != '' AND (
+                    h.hosp_name LIKE CONCAT('%', r.hospital_name, '%')
+                    OR h.hosp_short LIKE CONCAT('%', r.hospital_name, '%')
+                ))
+            )
+        )
+        <!-- 鍏抽敭璇嶆悳绱� -->
+        <if test="keyword != null and keyword != ''">
+        AND (
+            h.hops_province LIKE CONCAT('%', #{keyword}, '%')
+            OR h.hops_city LIKE CONCAT('%', #{keyword}, '%')
+            OR h.hops_area LIKE CONCAT('%', #{keyword}, '%')
+            OR h.hosp_address LIKE CONCAT('%', #{keyword}, '%')
+            OR h.hosp_name LIKE CONCAT('%', #{keyword}, '%')
+            OR h.hosp_short LIKE CONCAT('%', #{keyword}, '%')
+        )
+        </if>
+        ORDER BY 
+            CASE WHEN h.hosp_name = '瀹朵腑' THEN 0 ELSE 1 END,
+            h.hosp_name
     </select>
 </mapper>

--
Gitblit v1.9.1