<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.multictrl.modules.business.dao.FlightTaskDao">

    <select id="getLatestRouteTask" resultType="com.multictrl.modules.business.entity.FlightTaskEntity">
        SELECT *
        FROM bus_flight_task
        where dock_sn = #{dockSn}
        order by create_date desc limit 1
    </select>

    <select id="getPreviousTask" resultType="com.multictrl.modules.business.entity.FlightTaskEntity">
        SELECT *
        FROM bus_flight_task
        WHERE create_date > (SELECT create_date FROM bus_flight_task WHERE task_id = #{param1})
        <if test="param2 != null and param2.trim() != ''">
            and dock_sn = #{param2}
        </if>
        ORDER BY create_date ASC LIMIT 1;
    </select>
</mapper>