<?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.tuoheng.admin.mapper.FlightDataMapper">

    <resultMap id="BaseResultMap" type="com.tuoheng.admin.entity.FlightData">
        <id column="id" jdbcType="INTEGER" property="id" />
        <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
        <result column="inspection_id" jdbcType="VARCHAR" property="inspectionId" />
        <result column="dept_id" jdbcType="BIGINT" property="deptId" />
        <result column="record_id" jdbcType="BIGINT" property="recordId" />
        <result column="attach_r_d" jdbcType="BIGINT" property="attachRD" />
        <result column="uav_id" jdbcType="BIGINT" property="uavId" />
        <result column="uav_no" jdbcType="VARCHAR" property="uavNo" />
        <result column="ht" jdbcType="VARCHAR" property="ht" />
        <result column="bat" jdbcType="VARCHAR" property="bat" />
        <result column="duration" jdbcType="VARCHAR" property="duration" />
        <result column="absp" jdbcType="VARCHAR" property="absp" />
        <result column="remaining_flight_time" jdbcType="VARCHAR" property="remainingFlightTime" />
        <result column="satellite" jdbcType="VARCHAR" property="satellite" />
        <result column="lng" jdbcType="VARCHAR" property="lng" />
        <result column="lat" jdbcType="VARCHAR" property="lat" />
        <result column="altitude" jdbcType="VARCHAR" property="altitude" />
        <result column="ultrasonic" jdbcType="VARCHAR" property="ultrasonic" />
        <result column="pitch" jdbcType="VARCHAR" property="pitch" />
        <result column="roll" jdbcType="VARCHAR" property="roll" />
        <result column="yaw" jdbcType="VARCHAR" property="yaw" />
        <result column="airspeed" jdbcType="VARCHAR" property="airspeed" />
        <result column="velocity" jdbcType="VARCHAR" property="velocity" />
        <result column="timestamp" jdbcType="VARCHAR" property="timestamp" />
        <result column="is_srt" jdbcType="INTEGER" property="isSrt" />
        <result column="create_user" jdbcType="VARCHAR" property="createUser" />
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
        <result column="update_user" jdbcType="VARCHAR" property="updateUser" />
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
        <result column="mark" jdbcType="INTEGER" property="mark" />
    </resultMap>

    <sql id="Base_Column_List">
    id, tenant_id, inspection_id, box_sn, lng, lat, altitude, ultrasonic, pitch, roll, yaw, airspeed,
    velocity, `timestamp`, is_srt, create_user, create_time, update_user, update_time, mark
    </sql>

    <select id="selectListByInspectionId" resultMap="BaseResultMap">
       select
       <include refid="Base_Column_List"/>
       from th_flight_data
       where inspection_id = #{id}
       and mark = 1
       order by timestamp asc
    </select>

    <!-- 批量新增问题图片 -->
    <insert id="addBatch" parameterType="com.tuoheng.admin.entity.FlightData">
        insert into th_flight_data (id, tenant_id, inspection_id, dept_id, record_id, attach_r_d, uav_id, uav_no, ht, bat, duration, absp, remaining_flight_time, satellite,
                                    box_sn, lng, lat, gpssingal, hspeed, vspeed, alt, ysingal, tsingal, voltage, dist_to_home, flytime, mileage,
                                    altitude, ultrasonic, pitch, roll, yaw, airspeed, velocity, `timestamp`, is_srt, armed, mode, create_user, create_time)
        values
        <foreach collection="list" item="item" separator=",">
            (
            #{item.id,jdbcType=VARCHAR},
            #{item.tenantId,jdbcType=VARCHAR},
            #{item.inspectionId,jdbcType=VARCHAR},
            #{item.deptId,jdbcType=BIGINT},
            #{item.recordId,jdbcType=BIGINT},
            #{item.attachRD,jdbcType=BIGINT},
            #{item.uavId,jdbcType=BIGINT},
            #{item.uavNo,jdbcType=VARCHAR},
            #{item.ht,jdbcType=VARCHAR},
            #{item.bat,jdbcType=VARCHAR},
            #{item.duration,jdbcType=VARCHAR},
            #{item.absp,jdbcType=VARCHAR},
            #{item.remainingFlightTime,jdbcType=VARCHAR},
            #{item.satellite,jdbcType=VARCHAR},
            #{item.boxSn,jdbcType=VARCHAR},
            #{item.lng,jdbcType=VARCHAR},
            #{item.lat,jdbcType=VARCHAR},
            #{item.gpssingal,jdbcType=VARCHAR},
            #{item.hspeed,jdbcType=VARCHAR},
            #{item.vspeed,jdbcType=VARCHAR},
            #{item.alt,jdbcType=VARCHAR},
            #{item.ysingal,jdbcType=VARCHAR},
            #{item.tsingal,jdbcType=VARCHAR},
            #{item.voltage,jdbcType=VARCHAR},
            #{item.distToHome,jdbcType=VARCHAR},
            #{item.flytime,jdbcType=VARCHAR},
            #{item.mileage,jdbcType=VARCHAR},
            #{item.altitude,jdbcType=VARCHAR},
            #{item.ultrasonic,jdbcType=VARCHAR},
            #{item.pitch,jdbcType=VARCHAR},
            #{item.roll,jdbcType=VARCHAR},
            #{item.yaw,jdbcType=VARCHAR},

            #{item.airspeed,jdbcType=VARCHAR},
            #{item.velocity,jdbcType=VARCHAR},
            #{item.timestamp,jdbcType=VARCHAR},
            #{item.isSrt,jdbcType=TINYINT},
            #{item.armed,jdbcType=TINYINT},
            #{item.mode,jdbcType=VARCHAR},
            #{item.createUser,jdbcType=VARCHAR},
            #{item.createTime,jdbcType=TIMESTAMP}
            )
        </foreach>
    </insert>




</mapper>