<?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.spd.sw.dao.GysDao">
       <!--  select * from scdlyb.t_grid_data t where t.dTime='20220623104124'  -->
     <select id="getAirGirdList" resultType="java.util.HashMap"  parameterType="map"> 
	    <![CDATA[
	     select * from ${TableName} t where t.dTime=#{sTime}
		]]>
		<if test = "element != null and element != ''">
		and t.element = #{element}
		</if>
    </select>
    
       <select id="getRealWarnInfoList" resultType="java.util.HashMap"  parameterType="map"> 
	    <![CDATA[
	    select t.station_id_c,z.Station_Name,t.${sType} from scdlyb.t_awshour_rain t left join scdlyb.t_station z on z.Station_Id_C=t.station_id_c
 where t.datetime =#{sTime}  and t.${sType}>=20
		]]>
    </select>
    
     <select id="getForWarnInfoList" resultType="java.util.HashMap"  parameterType="map"> 
	    <![CDATA[
	    select * from scdlyb.t_grid_warninfo t 
 where t.dTime =#{sTime}  and t.fTime =#{fTime} and t.level=#{Level} and t.hour=#{Hour}
		]]>
    </select>

    <select id="getSpecialData" resultType="map">
        <![CDATA[
                select SUM,COUNT,station_id_c,datetime, a.maxhourspan , a.sfhour,a.areacode,a.element,a.level from scfies.t_${table}${stationID}  a
                    where a.maxHourspan<=${maxHourspan}

	    ]]>


        <if test="areaCode != null">
            ${areaCode}
        </if>

        <if test="level != null">
            and a.level ${level}
        </if>

        <if test="element != null">
            and  a.element = #{element}
        </if>

        <![CDATA[

                  and a.sfHour = ${sfHour} and a.preHour=${preHour} and a.datetime>=#{starttime} and a.datetime<=#{endtime}

        ]]>
    </select>

    <select id="getAvgData1" resultType="map">
        <![CDATA[

        select SUM ,COUNT,station_id_c,datetime, a.maxhourspan , a.sfhour,element  from scfies.t_${table}_cal_prov_${stationID}  a
        where a.maxHourspan<=${maxHourspan}
          and a.level ${level} and  a.element = '${element}'
            ]]>


        <![CDATA[
                          and a.sfHour = ${sfHour} and a.preHour=${preHour} and a.datetime>='${starttime}' and a.datetime<='${endtime}'




        ]]>
    </select>

    <select id="getAvgData2" resultType="map">
        <![CDATA[

                select SUM,COUNT,datetime, a.maxhourspan , a.sfhour  from scfies.t_${table}_cal_city_${stationID}  a
                    where a.maxHourspan<=${maxHourspan}
                           and a.level ${level} and  a.element = '${element}'
            ]]>
        <if test="areaCode != null">
            ${areaCode}
        </if>
        <![CDATA[
                          and a.sfHour = ${sfHour} and a.preHour=${preHour} and a.datetime>='${starttime}' and a.datetime<='${endtime}'


	    ]]>

    </select>

    <select id="getLevel" resultType="map">
        <![CDATA[
        select  SUM,COUNT, a.level, a.element as element from scfies.t_${table}${stationID} a where
        a.maxHourspan<=${maxHourspan}




        ]]>

        <if test="element != null">
            and  a.element = #{element}
        </if>

        and a.level ${level}
        <if test="areaCode != null">
            ${areaCode}
        </if>
        <![CDATA[
                           and a.sfHour=${sfHour}
                           and a.preHour=${preHour} and a.datetime>=#{starttime} and a.datetime<=#{endtime}

	    ]]>
    </select>

    <select id="getTimeRangeAvgData1" resultType="map">
        <![CDATA[
        select  sum(SUM) as SUM, sum(COUNT) as COUNT, a.level from scfies.t_${table}_cal_prov_${stationID} a where
        a.maxHourspan<=${maxHourspan} and  a.element = '${element}'
        ]]>
        and a.level ${level}
        <if test="areaCode != null">
            ${areaCode}
        </if>
        <![CDATA[
                           and a.sfHour=${sfHour}
                           and a.preHour=${preHour} and a.datetime>='${starttime}' and a.datetime<='${endtime}'
group by a.level
        order by  level asc
	    ]]>
    </select>

    <select id="getAvgTemTime" resultType="map">
    select  round(avg(${type}),2) as ${dataTypes},datetime,maxhourspan,prehour,sfhour from scfies.t_${table}_tem_ey where 1=1 ${stationSql} ${areacode}
          <![CDATA[
        and maxhourspan <=${maxHourSpan}
        and sfhour =${sfHour}  and prehour = ${preHour}  and datetime >= '${startTime}' and datetime <= '${endTime}' group by maxhourspan,datetime
    order by datetime asc,maxHourspan asc
    ]]>
</select>

    <select id="getAvgTemTime1" resultType="map">
        select  round(avg(${type}),2) as ${dataTypes},datetime,maxhourspan,prehour,sfhour from scfies.t_${table}_tem_ey where 1=1    ${stationSql} ${areacode}
    <![CDATA[
            and maxhourspan <=${maxHourSpan}
            and sfhour =${sfHour}  and prehour = ${preHour}  and datetime >= '${startTime}' and datetime <= '${endTime}' group by maxhourspan,datetime
        order by datetime asc,maxHourspan asc
        ]]>
    </select>

    <select id="queryData" resultType="map">
         <![CDATA[

        select a.*, a.datetime, date_format(datetime, '%Y-%c-%d') as datetimeStr ,b.station_name, b.lat, b.lon  from scfies.t_${table} a
                                                                                                                         left join scfies.t_station b on a.STATION_ID_C=b.Station_Id_C
        where 1=1  ${stationId}
				 and a.maxHourspan=${maxHourspan}
          and a.level ${preLevel}
            ${areaCode}
          and a.preHour=${preHour}

          and a.datetime=#{endtime}
        order by a.datetime asc



        ]]>
    </select>


</mapper> 