wlzboy
2025-11-02 2cd31915236257e325b49f2e86f6912512e1f7ce
ruoyi-system/src/main/resources/mapper/system/SysTaskEmergencyMapper.xml
@@ -223,8 +223,21 @@
    <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
        limit 100
        <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>
    
    <!-- 查询待同步调度单的任务(已同步服务单但未同步调度单) -->
@@ -233,8 +246,44 @@
        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
        limit 100
        <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>
</mapper>