<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.focusareasHisTory" name="重点领域统计">


    <select id="getFocusAreasCount" parameterType="com.scpyun.platform.jilinsscgsdp.bean.dto.FocusAreasStatisticsDTO"
            resultType="Integer">
        SELECT count(*) FROM ji_warning_focus_areas_history
        <where>
            statistical_time &gt;= CONCAT(YEAR(NOW()), '-01')
            AND statistical_time &lt;= CONCAT(YEAR(NOW()), '-12')
            <if test="alarmLevel == 1 or alarmLevel == 2">
                AND alarm_level = #{alarmLevel}
            </if>
            <if test="cityId != null and cityId != ''">
                AND area_level = 2 AND region_code = #{cityId}
            </if>
            <if test="areaId != null and areaId != ''">
                AND area_level = 3 AND region_code = #{areaId}
            </if>
            <if test="cityId == null and _user.company_grade == '2'.toString()">
                AND area_level = 1
            </if>
            <if test="cityId == null and _user.company_grade == '3'.toString()">
                AND area_level = 2 AND region_code = #{_user.company_id}
            </if>
            <if test="cityId == null and _user.company_grade == '4'.toString()">
                AND area_level = 3 AND region_code = #{_user.company_id}
            </if>
        </where>
    </select>
    <insert id="insertFocusArea" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.FocusAreas">
        INSERT INTO ji_warning_focus_areas_history (
        event_category_id,
        percentage,
        count,
        statistical_time,
        region_code,
        area_level,
        alarm_level,
        create_time
        )
        VALUES (
        #{eventCategoryId},
        #{percentage},
        #{count},
        #{statisticalTime},
        #{regionCode},
        #{areaLevel},
        #{alarmLevel},
        now()
        )
    </insert>



</mapper>
