<?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">

<!-- rscp_area_image_total -->
<mapper namespace="com.upyuns.platform.rs.datacenter.mapper.RscpAreaImageTotalMapper">
    <!-- This code was generated by TableGo tools, mark 1 begin. -->
    <!-- 字段映射 -->
    <resultMap id="rscpAreaImageTotalMap" type="com.upyuns.platform.rs.datacenter.entity.RscpAreaImageTotal">
        <result column="id" property="id" jdbcType="VARCHAR" />
        <result column="area_no" property="areaNo" jdbcType="VARCHAR" />
        <result column="area_no_detail" property="areaNoDetail" jdbcType="VARCHAR" typeHandler="com.upyuns.platform.rs.datacenter.mybatis.ArrayTypeHandler"/>
        <result column="image_row_col" property="imageRowCol" jdbcType="VARCHAR" />
        <result column="image_satellite_type" property="imageSatelliteType" jdbcType="VARCHAR" />
        <result column="image_resolution" property="imageResolution" jdbcType="VARCHAR"  typeHandler="com.upyuns.platform.rs.datacenter.mybatis.ArrayTypeHandler"/>
        <result column="image_spectrum_type" property="imageSpectrumType" jdbcType="VARCHAR"  typeHandler="com.upyuns.platform.rs.datacenter.mybatis.ArrayTypeHandler"/>
        <result column="image_sensor_type" property="imageSensorType" jdbcType="VARCHAR" />
        <result column="begin_time" property="beginTime" jdbcType="VARCHAR" />
        <result column="update_time" property="updateTime" jdbcType="VARCHAR" />
        <result column="gemo" property="gemo" jdbcType="VARCHAR" />
        <result column="range" property="range" jdbcType="VARCHAR" />
        <result column="num" property="num" jdbcType="INTEGER" />
        <result column="is_cover" property="isCover" jdbcType="VARCHAR" typeHandler="com.upyuns.platform.rs.datacenter.mybatis.ArrayTypeHandler"/>
        <result column="image_area" property="imageArea" jdbcType="VARCHAR" typeHandler="com.upyuns.platform.rs.datacenter.mybatis.ArrayTypeHandler"/>
        <result column="data_id" property="dataId" jdbcType="VARCHAR" />
        <result column="image_cloudage" property="imageCloudage" jdbcType="INTEGER" />
        <result column="image_product_type" property="imageProductType" jdbcType="VARCHAR" />
        <result column="name" property="name" jdbcType="VARCHAR" />
        <result column="thumbnail_path" property="thumbnailPath" jdbcType="VARCHAR" />
        <result column="is_del" property="isDel" jdbcType="INTEGER" />
        <result column="image_is_save" property="imageIsSave" jdbcType="INTEGER" />
    </resultMap>
    <!-- This code was generated by TableGo tools, mark 1 end. -->
    
    <!-- This code was generated by TableGo tools, mark 2 begin. -->
    <!-- 表查询字段 -->
    <sql id="allColumns">
        rait.id, rait.area_no, rait.area_no_detail, rait.image_row_col, rait.image_satellite_type, rait.image_resolution, rait.image_spectrum_type, rait.image_sensor_type, 
        rait.begin_time, rait.update_time, rait.gemo, rait.range, rait.num, rait.is_cover, rait.image_area, rait.data_id, 
        rait.image_cloudage, rait.image_product_type, rait.name, rait.thumbnail_path, rait.is_del, rait.image_is_save
    </sql>
    <!-- This code was generated by TableGo tools, mark 2 end. -->

    <select id="queryDataList" resultMap="rscpAreaImageTotalMap">
        select st_asgeojson(range,16,0) as range, *
        <include refid="geomSelectSql" />
        limit 5000
        offset 0;
    </select>


    <sql id="geomSelectSql" >
        from rscp_area_image_total
        <where>
            <if test="saSensor != null">
                and
                <foreach collection="saSensor" item="sa" open="(" separator=" or " close=")">
                    image_satellite_type = #{sa.satellite}
                    <if test="sa.sensors != null and sa.sensors.size > 0">
                        and image_sensor_type in
                        <foreach collection="sa.sensors" item="sensor" open="(" separator="," close=")">
                            #{sensor}
                        </foreach>
                    </if>
                </foreach>
            </if>
            <if test="resolution != null">
                and #{resolution} = any(image_resolution)
            </if>
            <if test="startDateTime != null">
                and begin_time &gt;= #{startDateTime}
            </if>
            <if test="endDateTime != null">
                and begin_time &lt;= #{endDateTime}
            </if>
            <if test="cloud != null">
                and image_cloudage &lt;= #{cloud}
            </if>
            <if test="areaNo != null">
                <if test="provinceNo != null">
                    and area_no = #{provinceNo} and #{areaNo} = any(area_no_detail)
                </if>
                <if test="provinceNo == null">
                    and area_no = #{areaNo}
                </if>
            </if>
        </where>
    </sql>
</mapper>