<?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.goldenwater.slaj.hazard.mapper.TBusiHazCountMapper">
    <resultMap type="com.goldenwater.slaj.hazard.domain.TBusiHazCount" id="TBusiHazCountResult">
        <result property="guid" column="guid"/>
        <result property="orgGuid" column="org_guid"/>
        <result property="createTime" column="create_time"/>
        <result property="ybYbs" column="yb_ybs"/>
        <result property="yxYbHaz" column="yx_yb_haz"/>
        <result property="zdYbs" column="zd_ybs"/>
        <result property="yxZdHaz" column="yx_zd_haz"/>
        <result property="ybsNum" column="ybs_num"/>
        <result property="alrhaz" column="alrhaz"/>
        <result property="hazBsl" column="haz_bsl"/>
        <result property="engNum" column="eng_num"/>
        <result property="hazYbGkl" column="haz_yb_gkl"/>
        <result property="ybGkHaz" column="yb_gk_haz"/>
        <result property="ybHaz" column="yb_haz"/>
        <result property="hazZdGkl" column="haz_zd_gkl"/>
        <result property="zdGkHaz" column="zd_gk_haz"/>
        <result property="zdHaz" column="zd_haz"/>
        <result property="totGkl" column="tot_gkl"/>
        <result property="alrEngNum" column="alr_eng_num"/>
        <result property="orgName" column="org_name"/>
    </resultMap>
    <sql id="selectTBusiHazCountVo">
        select c.guid, c.org_guid, c.create_time, c.yb_ybs, c.yx_yb_haz, c.zd_ybs, c.yx_zd_haz,
               c.ybs_num, c.alrhaz, c.haz_bsl, c.eng_num, c.haz_yb_gkl, c.yb_gk_haz, c.yb_haz,
               c.haz_zd_gkl, c.zd_gk_haz, c.zd_haz, c.tot_gkl, c.alr_eng_num,
               o.org_name
        from t_busi_haz_count c
        left join att_org_base o on c.org_guid = o.guid
    </sql>
    <select id="selectTBusiHazCountByGuid" parameterType="String" resultMap="TBusiHazCountResult">
        <include refid="selectTBusiHazCountVo"/>
        where c.guid = #{guid}
    </select>
    <select id="selectTBusiHazCountList" parameterType="com.goldenwater.slaj.hazard.domain.TBusiHazCount" resultMap="TBusiHazCountResult">
        <include refid="selectTBusiHazCountVo"/>
        <where>
            <if test="orgGuid != null and orgGuid != ''">AND c.org_guid = #{orgGuid}</if>
            <if test="guid != null and guid != ''">AND c.guid = #{guid}</if>
            <if test="orgName != null and orgName != ''">AND o.org_name like '%' || #{orgName} || '%'</if>
            <if test="wiunProp != null and wiunProp != ''">AND EXISTS (SELECT 1 FROM att_org_ext ext WHERE ext.org_guid = c.org_guid AND ext.wiun_prop = #{wiunProp})</if>
            <if test="beginCreateTime != null and beginCreateTime != ''">AND c.create_time >= #{beginCreateTime}</if>
            <if test="endCreateTime != null and endCreateTime != ''">AND c.create_time &lt;= #{endCreateTime}</if>
        </where>
    </select>
    <insert id="insertTBusiHazCount" parameterType="com.goldenwater.slaj.hazard.domain.TBusiHazCount">
        insert into t_busi_haz_count (
            guid, org_guid, create_time, yb_ybs, yx_yb_haz, zd_ybs, yx_zd_haz,
            ybs_num, alrhaz, haz_bsl, eng_num, haz_yb_gkl, yb_gk_haz, yb_haz,
            haz_zd_gkl, zd_gk_haz, zd_haz, tot_gkl, alr_eng_num
        ) values (
            #{guid}, #{orgGuid}, #{createTime}, #{ybYbs}, #{yxYbHaz}, #{zdYbs}, #{yxZdHaz},
            #{ybsNum}, #{alrhaz}, #{hazBsl}, #{engNum}, #{hazYbGkl}, #{ybGkHaz}, #{ybHaz},
            #{hazZdGkl}, #{zdGkHaz}, #{zdHaz}, #{totGkl}, #{alrEngNum}
        )
    </insert>
    <update id="updateTBusiHazCount" parameterType="com.goldenwater.slaj.hazard.domain.TBusiHazCount">
        update t_busi_haz_count
        <set>
            <if test="orgGuid != null">org_guid = #{orgGuid},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="ybYbs != null">yb_ybs = #{ybYbs},</if>
            <if test="yxYbHaz != null">yx_yb_haz = #{yxYbHaz},</if>
            <if test="zdYbs != null">zd_ybs = #{zdYbs},</if>
            <if test="yxZdHaz != null">yx_zd_haz = #{yxZdHaz},</if>
            <if test="ybsNum != null">ybs_num = #{ybsNum},</if>
            <if test="alrhaz != null">alrhaz = #{alrhaz},</if>
            <if test="hazBsl != null">haz_bsl = #{hazBsl},</if>
            <if test="engNum != null">eng_num = #{engNum},</if>
            <if test="hazYbGkl != null">haz_yb_gkl = #{hazYbGkl},</if>
            <if test="ybGkHaz != null">yb_gk_haz = #{ybGkHaz},</if>
            <if test="ybHaz != null">yb_haz = #{ybHaz},</if>
            <if test="hazZdGkl != null">haz_zd_gkl = #{hazZdGkl},</if>
            <if test="zdGkHaz != null">zd_gk_haz = #{zdGkHaz},</if>
            <if test="zdHaz != null">zd_haz = #{zdHaz},</if>
            <if test="totGkl != null">tot_gkl = #{totGkl},</if>
            <if test="alrEngNum != null">alr_eng_num = #{alrEngNum},</if>
        </set>
        where guid = #{guid}
    </update>
    <delete id="deleteTBusiHazCountByGuid" parameterType="String">
        delete from t_busi_haz_count where guid = #{guid}
    </delete>
    <delete id="deleteTBusiHazCountByGuids" parameterType="String">
        delete from t_busi_haz_count where guid in
        <foreach item="guid" collection="array" open="(" separator="," close=")">
            #{guid}
        </foreach>
    </delete>
</mapper>
