<?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.base.track.mapper.TrbutDataMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.base.track.model.entity.TrbutData">
        <id column="id" property="id"/>
        <result column="pit_time" property="pitTime"/>
        <result column="start_azimuth" property="startAzimuth"/>
        <result column="receive_start_time" property="receiveStartTime"/>
        <result column="receive_end_time" property="receiveEndTime"/>
        <result column="exit_time" property="exitTime"/>
        <result column="end_azimuth" property="endAzimuth"/>
        <result column="highest_elevation_angle" property="highestElevationAngle"/>
        <result column="highest_azimuth" property="highestAzimuth"/>
        <result column="orbit_num" property="orbitNum"/>
        <result column="satellite_id" property="satelliteId"/>
        <result column="station_id" property="stationId"/>
        <result column="station_code" property="stationCode"/>
        <result column="duration" property="duration"/>
    </resultMap>

    <sql id="selTrButDataVo">
        id
        ,pit_time,start_azimuth,receive_start_time,receive_end_time,exit_time,end_azimuth,
        highest_elevation_angle,highest_azimuth,orbit_num,satellite_id,station_id
    </sql>

    <delete id="deleteByDate" parameterType="string">
        delete
        from trbut_data
        where pit_time >= #{startTime}
          and pit_time <![CDATA[<=]]> #{endTime}
    </delete>

    <select id="selTrButData" parameterType="com.base.track.model.entity.CxStationVo" resultMap="BaseResultMap">
        select
        *
        from trbut_data
        <where>
            <if test="ids != null and  ids.size()>0">
                id in
                <foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="codes != null and  codes.size()>0">
                satellite_code in
                <foreach collection="codes" index="index" item="code" open="(" separator="," close=")">
                    #{code}
                </foreach>
            </if>
            <if test="cxStartTime!=null">
                and receive_start_time &gt;= #{cxStartTime}
            </if>
            <if test="cxEndTime!=null">
                and receive_end_time &lt;= #{cxEndTime}
            </if>
            <if test="stationType!=null and stationType!=''">
                and station_type = #{stationType}
            </if>
            <if test="minCircle!=null and minCircle!=''">
                and orbit_num &gt;= #{minCircle}
            </if>
            <if test="maxCircle!=null and maxCircle!=''">
                and orbit_num &lt;= #{maxCircle}
            </if>
        </where>
    </select>
</mapper>
