From 656d6f8029f8bf9b2daa9dcc89101a879a70b860 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期三, 03 十二月 2025 23:10:05 +0800
Subject: [PATCH] feat:优先添加执行人

---
 ruoyi-system/src/main/resources/mapper/system/SysTaskEmergencyMapper.xml |  183 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 178 insertions(+), 5 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/SysTaskEmergencyMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysTaskEmergencyMapper.xml
index 081a4e3..a7f2760 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysTaskEmergencyMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysTaskEmergencyMapper.xml
@@ -14,13 +14,17 @@
         <result property="patientIdCard"           column="patient_id_card"         />
         <result property="patientCondition"        column="patient_condition"       />
         <result property="hospitalOutName"         column="hospital_out_name"       />
+        <result property="hospitalOutId"           column="hospital_out_id"         />
         <result property="hospitalOutDepartment"   column="hospital_out_department" />
+        <result property="hospitalOutDepartmentId" column="hospital_out_department_id" />
         <result property="hospitalOutBedNumber"    column="hospital_out_bed_number" />
         <result property="hospitalOutAddress"      column="hospital_out_address"    />
         <result property="hospitalOutLongitude"    column="hospital_out_longitude"  />
         <result property="hospitalOutLatitude"     column="hospital_out_latitude"   />
         <result property="hospitalInName"          column="hospital_in_name"        />
+        <result property="hospitalInId"            column="hospital_in_id"          />
         <result property="hospitalInDepartment"    column="hospital_in_department"  />
+        <result property="hospitalInDepartmentId"  column="hospital_in_department_id" />
         <result property="hospitalInBedNumber"     column="hospital_in_bed_number"  />
         <result property="hospitalInAddress"       column="hospital_in_address"     />
         <result property="hospitalInLongitude"     column="hospital_in_longitude"   />
@@ -29,6 +33,19 @@
         <result property="transferPrice"           column="transfer_price"          />
         <result property="passengerContact"        column="passenger_contact"       />
         <result property="passengerPhone"          column="passenger_phone"         />
+        <result property="diseaseIds"              column="disease_ids"             />
+        <result property="documentTypeId"          column="document_type_id"        />
+        <result property="taskTypeId"              column="task_type_id"            />
+        <result property="legacyServiceOrdId"      column="legacy_service_ord_id"   />
+        <result property="legacyDispatchOrdId"     column="legacy_dispatch_ord_id"  />
+        <result property="syncStatus"              column="sync_status"             />
+        <result property="syncTime"                column="sync_time"               />
+        <result property="syncErrorMsg"            column="sync_error_msg"          />
+        <result property="dispatchSyncStatus"      column="dispatch_sync_status"    />
+        <result property="dispatchSyncTime"        column="dispatch_sync_time"      />
+        <result property="dispatchSyncErrorMsg"    column="dispatch_sync_error_msg" />
+        <result property="needResync"              column="need_resync"             />
+        <result property="legacyServiceOrdNo"      column="legacy_service_ord_no"   />
         <result property="createTime"              column="create_time"             />
         <result property="updateTime"              column="update_time"             />
         <result property="createBy"                column="create_by"               />
@@ -37,12 +54,14 @@
 
     <sql id="selectSysTaskEmergencyVo">
         select id, task_id, patient_contact, patient_phone, patient_name, patient_gender, 
-               patient_id_card, patient_condition, hospital_out_name, hospital_out_department, 
-               hospital_out_bed_number, hospital_out_address, hospital_out_longitude, 
-               hospital_out_latitude, hospital_in_name, hospital_in_department, 
-               hospital_in_bed_number, hospital_in_address, hospital_in_longitude, 
+               patient_id_card, patient_condition, hospital_out_name, hospital_out_id, hospital_out_department, 
+               hospital_out_department_id, hospital_out_bed_number, hospital_out_address, hospital_out_longitude, 
+               hospital_out_latitude, hospital_in_name, hospital_in_id, hospital_in_department, 
+               hospital_in_department_id, hospital_in_bed_number, hospital_in_address, hospital_in_longitude, 
                hospital_in_latitude, transfer_distance, transfer_price, passenger_contact, 
-               passenger_phone, create_time, update_time, create_by, update_by
+               passenger_phone, disease_ids, document_type_id, task_type_id, legacy_service_ord_id, legacy_dispatch_ord_id, 
+               sync_status, sync_time, sync_error_msg, dispatch_sync_status, dispatch_sync_time, dispatch_sync_error_msg, need_resync, legacy_service_ord_no,
+               create_time, update_time, create_by, update_by
         from sys_task_emergency
     </sql>
 
@@ -67,13 +86,17 @@
             <if test="patientIdCard != null">patient_id_card,</if>
             <if test="patientCondition != null">patient_condition,</if>
             <if test="hospitalOutName != null">hospital_out_name,</if>
+            <if test="hospitalOutId != null">hospital_out_id,</if>
             <if test="hospitalOutDepartment != null">hospital_out_department,</if>
+            <if test="hospitalOutDepartmentId != null">hospital_out_department_id,</if>
             <if test="hospitalOutBedNumber != null">hospital_out_bed_number,</if>
             <if test="hospitalOutAddress != null">hospital_out_address,</if>
             <if test="hospitalOutLongitude != null">hospital_out_longitude,</if>
             <if test="hospitalOutLatitude != null">hospital_out_latitude,</if>
             <if test="hospitalInName != null">hospital_in_name,</if>
+            <if test="hospitalInId != null">hospital_in_id,</if>
             <if test="hospitalInDepartment != null">hospital_in_department,</if>
+            <if test="hospitalInDepartmentId != null">hospital_in_department_id,</if>
             <if test="hospitalInBedNumber != null">hospital_in_bed_number,</if>
             <if test="hospitalInAddress != null">hospital_in_address,</if>
             <if test="hospitalInLongitude != null">hospital_in_longitude,</if>
@@ -82,6 +105,19 @@
             <if test="transferPrice != null">transfer_price,</if>
             <if test="passengerContact != null">passenger_contact,</if>
             <if test="passengerPhone != null">passenger_phone,</if>
+            <if test="diseaseIds != null">disease_ids,</if>
+            <if test="documentTypeId != null">document_type_id,</if>
+            <if test="taskTypeId != null">task_type_id,</if>
+            <if test="legacyServiceOrdId != null">legacy_service_ord_id,</if>
+            <if test="legacyDispatchOrdId != null">legacy_dispatch_ord_id,</if>
+            <if test="syncStatus != null">sync_status,</if>
+            <if test="syncTime != null">sync_time,</if>
+            <if test="syncErrorMsg != null">sync_error_msg,</if>
+            <if test="dispatchSyncStatus != null">dispatch_sync_status,</if>
+            <if test="dispatchSyncTime != null">dispatch_sync_time,</if>
+            <if test="dispatchSyncErrorMsg != null">dispatch_sync_error_msg,</if>
+            <if test="needResync != null">need_resync,</if>
+            <if test="legacyServiceOrdNo != null">legacy_service_ord_no,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="createBy != null">create_by,</if>
@@ -96,13 +132,17 @@
             <if test="patientIdCard != null">#{patientIdCard},</if>
             <if test="patientCondition != null">#{patientCondition},</if>
             <if test="hospitalOutName != null">#{hospitalOutName},</if>
+            <if test="hospitalOutId != null">#{hospitalOutId},</if>
             <if test="hospitalOutDepartment != null">#{hospitalOutDepartment},</if>
+            <if test="hospitalOutDepartmentId != null">#{hospitalOutDepartmentId},</if>
             <if test="hospitalOutBedNumber != null">#{hospitalOutBedNumber},</if>
             <if test="hospitalOutAddress != null">#{hospitalOutAddress},</if>
             <if test="hospitalOutLongitude != null">#{hospitalOutLongitude},</if>
             <if test="hospitalOutLatitude != null">#{hospitalOutLatitude},</if>
             <if test="hospitalInName != null">#{hospitalInName},</if>
+            <if test="hospitalInId != null">#{hospitalInId},</if>
             <if test="hospitalInDepartment != null">#{hospitalInDepartment},</if>
+            <if test="hospitalInDepartmentId != null">#{hospitalInDepartmentId},</if>
             <if test="hospitalInBedNumber != null">#{hospitalInBedNumber},</if>
             <if test="hospitalInAddress != null">#{hospitalInAddress},</if>
             <if test="hospitalInLongitude != null">#{hospitalInLongitude},</if>
@@ -111,6 +151,19 @@
             <if test="transferPrice != null">#{transferPrice},</if>
             <if test="passengerContact != null">#{passengerContact},</if>
             <if test="passengerPhone != null">#{passengerPhone},</if>
+            <if test="diseaseIds != null">#{diseaseIds},</if>
+            <if test="documentTypeId != null">#{documentTypeId},</if>
+            <if test="taskTypeId != null">#{taskTypeId},</if>
+            <if test="legacyServiceOrdId != null">#{legacyServiceOrdId},</if>
+            <if test="legacyDispatchOrdId != null">#{legacyDispatchOrdId},</if>
+            <if test="syncStatus != null">#{syncStatus},</if>
+            <if test="syncTime != null">#{syncTime},</if>
+            <if test="syncErrorMsg != null">#{syncErrorMsg},</if>
+            <if test="dispatchSyncStatus != null">#{dispatchSyncStatus},</if>
+            <if test="dispatchSyncTime != null">#{dispatchSyncTime},</if>
+            <if test="dispatchSyncErrorMsg != null">#{dispatchSyncErrorMsg},</if>
+            <if test="needResync != null">#{needResync},</if>
+            <if test="legacyServiceOrdNo != null">#{legacyServiceOrdNo},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="createBy != null">#{createBy},</if>
@@ -128,13 +181,17 @@
             <if test="patientIdCard != null">patient_id_card = #{patientIdCard},</if>
             <if test="patientCondition != null">patient_condition = #{patientCondition},</if>
             <if test="hospitalOutName != null">hospital_out_name = #{hospitalOutName},</if>
+            <if test="hospitalOutId != null">hospital_out_id = #{hospitalOutId},</if>
             <if test="hospitalOutDepartment != null">hospital_out_department = #{hospitalOutDepartment},</if>
+            <if test="hospitalOutDepartmentId != null">hospital_out_department_id = #{hospitalOutDepartmentId},</if>
             <if test="hospitalOutBedNumber != null">hospital_out_bed_number = #{hospitalOutBedNumber},</if>
             <if test="hospitalOutAddress != null">hospital_out_address = #{hospitalOutAddress},</if>
             <if test="hospitalOutLongitude != null">hospital_out_longitude = #{hospitalOutLongitude},</if>
             <if test="hospitalOutLatitude != null">hospital_out_latitude = #{hospitalOutLatitude},</if>
             <if test="hospitalInName != null">hospital_in_name = #{hospitalInName},</if>
+            <if test="hospitalInId != null">hospital_in_id = #{hospitalInId},</if>
             <if test="hospitalInDepartment != null">hospital_in_department = #{hospitalInDepartment},</if>
+            <if test="hospitalInDepartmentId != null">hospital_in_department_id = #{hospitalInDepartmentId},</if>
             <if test="hospitalInBedNumber != null">hospital_in_bed_number = #{hospitalInBedNumber},</if>
             <if test="hospitalInAddress != null">hospital_in_address = #{hospitalInAddress},</if>
             <if test="hospitalInLongitude != null">hospital_in_longitude = #{hospitalInLongitude},</if>
@@ -143,6 +200,19 @@
             <if test="transferPrice != null">transfer_price = #{transferPrice},</if>
             <if test="passengerContact != null">passenger_contact = #{passengerContact},</if>
             <if test="passengerPhone != null">passenger_phone = #{passengerPhone},</if>
+            <if test="diseaseIds != null">disease_ids = #{diseaseIds},</if>
+            <if test="documentTypeId != null">document_type_id = #{documentTypeId},</if>
+            <if test="taskTypeId != null">task_type_id = #{taskTypeId},</if>
+            <if test="legacyServiceOrdId != null">legacy_service_ord_id = #{legacyServiceOrdId},</if>
+            <if test="legacyDispatchOrdId != null">legacy_dispatch_ord_id = #{legacyDispatchOrdId},</if>
+            <if test="syncStatus != null">sync_status = #{syncStatus},</if>
+            <if test="syncTime != null">sync_time = #{syncTime},</if>
+            <if test="syncErrorMsg != null">sync_error_msg = #{syncErrorMsg},</if>
+            <if test="dispatchSyncStatus != null">dispatch_sync_status = #{dispatchSyncStatus},</if>
+            <if test="dispatchSyncTime != null">dispatch_sync_time = #{dispatchSyncTime},</if>
+            <if test="dispatchSyncErrorMsg != null">dispatch_sync_error_msg = #{dispatchSyncErrorMsg},</if>
+            <if test="needResync != null">need_resync = #{needResync},</if>
+            <if test="legacyServiceOrdNo != null">legacy_service_ord_no = #{legacyServiceOrdNo},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
         </trim>
@@ -157,4 +227,107 @@
         delete from sys_task_emergency where task_id = #{taskId}
     </delete>
 
+    <!-- 鏌ヨ寰呭悓姝ョ殑鎬ユ晳杞繍浠诲姟 -->
+    <select id="selectPendingSyncTasks" resultMap="SysTaskEmergencyResult">
+        <include refid="selectSysTaskEmergencyVo"/>
+        where (sync_status = 0 or sync_status = 3)
+          and task_id in (
+              select task_id from sys_task 
+              where task_type = 'EMERGENCY_TRANSFER'                
+                and del_flag = '0'
+          )
+        order by id asc
+        <if test="offset != null and limit != null">
+            limit #{offset}, #{limit}
+        </if>
+        <if test="offset == null and limit != null">
+            limit #{limit}
+        </if>
+        <if test="offset == null and limit == null">
+            limit 100
+        </if>
+    </select>
+    
+    <!-- 鏌ヨ寰呭悓姝ヨ皟搴﹀崟鐨勪换鍔★紙宸插悓姝ユ湇鍔″崟浣嗘湭鍚屾璋冨害鍗曪級 -->
+    <select id="selectPendingDispatchSyncTasks" resultMap="SysTaskEmergencyResult">
+        <include refid="selectSysTaskEmergencyVo"/>
+        where sync_status = 2 
+          and legacy_service_ord_id is not null 
+          and (dispatch_sync_status = 0 or dispatch_sync_status = 3 or dispatch_sync_status is null)
+          and task_id in (
+              select task_id from sys_task 
+              where task_type = 'EMERGENCY_TRANSFER'
+                and task_status not in ('COMPLETED', 'CANCELLED')  <!-- 杩囨护宸插畬鎴�/宸插彇娑堢殑浠诲姟 -->
+                and del_flag = '0'
+          )
+        order by id asc
+        <if test="offset != null and limit != null">
+            limit #{offset}, #{limit}
+        </if>
+        <if test="offset == null and limit != null">
+            limit #{limit}
+        </if>
+        <if test="offset == null and limit == null">
+            limit 100
+        </if>
+    </select>
+    
+    <!-- 鏌ヨ宸插悓姝ヨ皟搴﹀崟涓旂姸鎬佹湭瀹屾垚鐨勪换鍔★紙鐢ㄤ簬鐘舵�佸悓姝ワ級 -->
+    <select id="selectSyncedTasksForStatusUpdate" resultMap="SysTaskEmergencyResult">
+        <include refid="selectSysTaskEmergencyVo"/>
+        where dispatch_sync_status = 2 
+          and legacy_dispatch_ord_id is not null
+          and task_id in (
+              select task_id from sys_task 
+              where task_type = 'EMERGENCY_TRANSFER'
+                and del_flag = '0'
+          )
+        order by id asc
+        <if test="offset != null and limit != null">
+            limit #{offset}, #{limit}
+        </if>
+        <if test="offset == null and limit != null">
+            limit #{limit}
+        </if>
+        <if test="offset == null and limit == null">
+            limit 200
+        </if>
+    </select>
+    
+    <!-- 鏍规嵁鏃х郴缁熸湇鍔″崟ID鏌ヨ鎬ユ晳杞繍浠诲姟鎵╁睍淇℃伅 -->
+    <select id="selectByLegacyServiceOrdId" parameterType="Long" resultMap="SysTaskEmergencyResult">
+        <include refid="selectSysTaskEmergencyVo"/>
+        where legacy_service_ord_id = #{legacyServiceOrdId}
+    </select>
+    
+    <!-- 鏍规嵁鏃х郴缁熻皟搴﹀崟ID鏌ヨ鎬ユ晳杞繍浠诲姟鎵╁睍淇℃伅 -->
+    <select id="selectByLegacyDispatchOrdId" parameterType="Long" resultMap="SysTaskEmergencyResult">
+        <include refid="selectSysTaskEmergencyVo"/>
+        where legacy_dispatch_ord_id = #{legacyDispatchOrdId}
+    </select>
+    
+    <!-- 鏌ヨ闇�瑕侀噸鏂板悓姝ョ殑浠诲姟锛堣溅杈嗘垨浜哄憳鍙樻洿锛� -->
+    <select id="selectNeedResyncTasks" resultMap="SysTaskEmergencyResult">
+        <include refid="selectSysTaskEmergencyVo"/>
+        where need_resync = 1
+          and dispatch_sync_status = 2 
+          and legacy_dispatch_ord_id is not null
+          and task_id in (
+              select task_id from sys_task 
+              where task_type = 'EMERGENCY_TRANSFER'
+                and task_status not in ('COMPLETED', 'CANCELLED')
+                and del_flag = '0'
+          )
+        order by id asc
+        <if test="offset != null and limit != null">
+            limit #{offset}, #{limit}
+        </if>
+        <if test="offset == null and limit != null">
+            limit #{limit}
+        </if>
+        <if test="offset == null and limit == null">
+            limit 100
+        </if>
+    </select>
+
 </mapper>

--
Gitblit v1.9.1