From d7e3192804fca756d881af360ffd5eea157ef9ad Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期三, 21 十月 2026 15:45:18 +0800
Subject: [PATCH] 【市一】电话挂断服务

---
 smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml |   55 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
index 9a47f1f..f241ff6 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
@@ -247,18 +247,15 @@
         AND b.del_flag = 0
         AND a.idcardno IS NOT NULL
         <if test="inhospid != null">and b.inhospid = #{inhospid}</if>
-        <if test="startOutHospTime != null ">and date_format(b.endtime,'%y%m%d') &gt;=
-            date_format(#{startOutHospTime},'%y%m%d')
-        </if>
-        <if test="endOutHospTime != null ">and date_format(b.endtime,'%y%m%d') &lt;=
-            date_format(#{endOutHospTime},'%y%m%d')
-        </if>
-        <if test="startInHospTime != null ">and date_format(b.starttime,'%y%m%d') &gt;=
-            date_format(#{startInHospTime},'%y%m%d')
-        </if>
-        <if test="endInHospTime != null ">and date_format(b.starttime,'%y%m%d') &lt;=
-            date_format(#{endInHospTime},'%y%m%d')
-        </if>
+        <!--
+          鏃堕棿鑼冨洿涓嶈鍐欐垚 date_format(b.endtime,'%y%m%d') >= date_format(#{...},'%y%m%d')锛�
+          鍒椾笂濂楀嚱鏁颁細璁� endtime / starttime 涓婄殑绱㈠紩褰诲簳澶辨晥锛堣�屼笖 %y 鏄袱浣嶅勾浠斤級銆�
+          杩欓噷鎶婂嚱鏁版尓鍒板弬鏁颁晶锛岃涔夌瓑浠凤細>= 褰撳ぉ 0 鐐癸紝< 娆℃棩 0 鐐广��
+        -->
+        <if test="startOutHospTime != null ">and b.endtime &gt;= date(#{startOutHospTime})</if>
+        <if test="endOutHospTime != null ">and b.endtime &lt; date(#{endOutHospTime}) + interval 1 day</if>
+        <if test="startInHospTime != null ">and b.starttime &gt;= date(#{startInHospTime})</if>
+        <if test="endInHospTime != null ">and b.starttime &lt; date(#{endInHospTime}) + interval 1 day</if>
         <if test="hospitalname != null  and hospitalname != ''">and hospitalname like concat('%', #{hospitalname},
             '%')
         </if>
@@ -276,7 +273,6 @@
         <if test="orgid != null ">and b.orgid = #{orgid}</if>
         <if test="campusid != null ">and b.campusid = #{campusid}</if>
         <if test="serialnum != null ">and b.serialnum = #{serialnum}</if>
-        <if test="endtime != null ">and b.endtime = #{endtime}</if>
         <if test="patno != null ">and b.patno = #{patno}</if>
         <if test="nurseId != null ">and b.nurse_id = #{nurseId}</if>
         <if test="nurseName != null and nurseName != ''">and b.nurse_name = #{nurseName}</if>
@@ -353,20 +349,12 @@
         <if test="medicalCode != null and medicalCode != ''">and b.medical_code = #{medicalCode}</if>
         <if test="medicalName != null and medicalName != ''">and b.medical_name = #{medicalName}</if>
         <if test="medicalCompany != null and medicalCompany != ''">and b.medical_company = #{medicalCompany}</if>
-        GROUP BY
-        b.inhospid,
-        a.age,
-        a.age_unit,
-        a.telcode,
-        a.id,
-        a.sex
-        <if test="cry != null and cry==1">
-            order by b.endtime desc
-        </if>
-        <if test="cry != null and cry==2">
-            order by b.endtime desc
-        </if>
-        <if test="cry != null and cry==3">
+        <!--
+          鍘熸潵杩欓噷鏈変竴娈� GROUP BY b.inhospid, a.age, a.age_unit, a.telcode, a.id, a.sex銆�
+          b.inhospid 鏄富閿�乤.id = b.patid 鏄竴瀵逛竴鍏宠仈锛屽垎缁勪笉浼氬悎骞朵换浣曡锛屽彧浼氳 MySQL
+          澶氬缓涓�寮犱复鏃惰〃銆佸苟璁╁垎椤电殑 count 鍙樻垚娲剧敓琛ㄣ�傝繖閲岀洿鎺ュ幓鎺夈��
+        -->
+        <if test="cry != null and (cry == 1 or cry == 2 or cry == 3)">
             order by b.endtime desc
         </if>
         <if test="cry != null and cry==0">
@@ -661,6 +649,19 @@
           AND d.del_flag = 0
     </select>
 
+    <!-- 鎵归噺鏌ユ爣绛撅紝鏇夸唬鍒楄〃閫愯璋冪敤 getTagnameBypatid 鐨� N+1 鏌ヨ -->
+    <select id="selectTagnameByPatids" resultType="com.smartor.domain.PatArchivetag">
+        SELECT d.patid      AS patid,
+               GROUP_CONCAT(d.tagname, ', ') AS tagname
+        FROM pat_archivetag d
+        WHERE d.del_flag = 0
+          AND d.patid IN
+        <foreach collection="patids" item="patid" open="(" separator="," close=")">
+            #{patid}
+        </foreach>
+        GROUP BY d.patid
+    </select>
+
 
     <select id="selectPatMedInhospByInhospid" parameterType="Long" resultMap="PatMedInhospResult">
         <include refid="selectPatMedInhospVo"/>

--
Gitblit v1.9.3