<?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.djhk.uav.sysPolice.mapper.PoliceInfoEsMapper">
    
    <resultMap type="com.djhk.uav.sysPolice.domain.PoliceInfoEs" id="PoliceInfoEsResult">
        <result property="fhRksj"    column="FH_RKSJ"    />
        <result property="GXSJ"    column="GXSJ"    />
        <result property="HH"    column="HH"    />
        <result property="HIVECODE"    column="HIVECODE"    />
        <result property="JGBM"    column="JGBM"    />
        <result property="JH"    column="JH"    />
        <result property="MC"    column="MC"    />
        <result property="mdId"    column="MD_ID"    />
        <result property="RYID"    column="RYID"    />
        <result property="RYTX"    column="RYTX"    />
        <result property="SFYX"    column="SFYX"    />
        <result property="SFZH"    column="SFZH"    />
        <result property="XM"    column="XM"    />
        <result property="XTMC"    column="XTMC"    />
        <result property="ZW"    column="ZW"    />
        <result property="ZZJGID"    column="ZZJGID"    />
    </resultMap>

    <sql id="selectPoliceInfoEsVo">
        select FH_RKSJ, GXSJ, HH, HIVECODE, JGBM, JH, MC, MD_ID, RYID, RYTX, SFYX, SFZH, XM, XTMC, ZW, ZZJGID from police_info_es
    </sql>

    <select id="selectPoliceInfoEsList" parameterType="com.djhk.uav.sysPolice.domain.PoliceInfoEs" resultMap="PoliceInfoEsResult">
        <include refid="selectPoliceInfoEsVo"/>
        <where>  
            <if test="fhRksj != null  and fhRksj != ''"> and FH_RKSJ = #{fhRksj}</if>
            <if test="GXSJ != null  and GXSJ != ''"> and GXSJ = #{GXSJ}</if>
            <if test="HH != null  and HH != ''"> and HH = #{HH}</if>
            <if test="HIVECODE != null  and HIVECODE != ''"> and HIVECODE = #{HIVECODE}</if>
            <if test="JGBM != null  and JGBM != ''"> and JGBM = #{JGBM}</if>
            <if test="JH != null  and JH != ''"> and JH = #{JH}</if>
            <if test="MC != null  and MC != ''"> and MC like concat('%', #{MC}, '%')</if>
            <if test="mdId != null  and mdId != ''"> and MD_ID = #{mdId}</if>
            <if test="RYID != null  and RYID != ''"> and RYID = #{RYID}</if>
            <if test="RYTX != null  and RYTX != ''"> and RYTX = #{RYTX}</if>
            <if test="SFYX != null  and SFYX != ''"> and SFYX = #{SFYX}</if>
            <if test="SFZH != null  and SFZH != ''"> and SFZH = #{SFZH}</if>
            <if test="XM != null  and XM != ''"> and XM = #{XM}</if>
            <if test="XTMC != null  and XTMC != ''"> and XTMC = #{XTMC}</if>
            <if test="ZW != null  and ZW != ''"> and ZW = #{ZW}</if>
             and ZW != 'GLY'
            AND jh is NOT NULL
            <if test="ZZJGID != null  and ZZJGID != ''"> and ZZJGID = #{ZZJGID}</if>
        </where>
    </select>
    
    <select id="selectPoliceInfoEsByFhRksj" parameterType="String" resultMap="PoliceInfoEsResult">
        <include refid="selectPoliceInfoEsVo"/>
        where FH_RKSJ = #{fhRksj}
    </select>
        
    <insert id="insertPoliceInfoEs" parameterType="com.djhk.uav.sysPolice.domain.PoliceInfoEs">
        insert into police_info_es
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fhRksj != null">FH_RKSJ,</if>
            <if test="GXSJ != null">GXSJ,</if>
            <if test="HH != null">HH,</if>
            <if test="HIVECODE != null">HIVECODE,</if>
            <if test="JGBM != null">JGBM,</if>
            <if test="JH != null">JH,</if>
            <if test="MC != null">MC,</if>
            <if test="mdId != null">MD_ID,</if>
            <if test="RYID != null">RYID,</if>
            <if test="RYTX != null">RYTX,</if>
            <if test="SFYX != null">SFYX,</if>
            <if test="SFZH != null">SFZH,</if>
            <if test="XM != null">XM,</if>
            <if test="XTMC != null">XTMC,</if>
            <if test="ZW != null">ZW,</if>
            <if test="ZZJGID != null">ZZJGID,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fhRksj != null">#{fhRksj},</if>
            <if test="GXSJ != null">#{GXSJ},</if>
            <if test="HH != null">#{HH},</if>
            <if test="HIVECODE != null">#{HIVECODE},</if>
            <if test="JGBM != null">#{JGBM},</if>
            <if test="JH != null">#{JH},</if>
            <if test="MC != null">#{MC},</if>
            <if test="mdId != null">#{mdId},</if>
            <if test="RYID != null">#{RYID},</if>
            <if test="RYTX != null">#{RYTX},</if>
            <if test="SFYX != null">#{SFYX},</if>
            <if test="SFZH != null">#{SFZH},</if>
            <if test="XM != null">#{XM},</if>
            <if test="XTMC != null">#{XTMC},</if>
            <if test="ZW != null">#{ZW},</if>
            <if test="ZZJGID != null">#{ZZJGID},</if>
         </trim>
    </insert>

    <update id="updatePoliceInfoEs" parameterType="com.djhk.uav.sysPolice.domain.PoliceInfoEs">
        update police_info_es
        <trim prefix="SET" suffixOverrides=",">
            <if test="GXSJ != null">GXSJ = #{GXSJ},</if>
            <if test="HH != null">HH = #{HH},</if>
            <if test="HIVECODE != null">HIVECODE = #{HIVECODE},</if>
            <if test="JGBM != null">JGBM = #{JGBM},</if>
            <if test="JH != null">JH = #{JH},</if>
            <if test="MC != null">MC = #{MC},</if>
            <if test="mdId != null">MD_ID = #{mdId},</if>
            <if test="RYID != null">RYID = #{RYID},</if>
            <if test="RYTX != null">RYTX = #{RYTX},</if>
            <if test="SFYX != null">SFYX = #{SFYX},</if>
            <if test="SFZH != null">SFZH = #{SFZH},</if>
            <if test="XM != null">XM = #{XM},</if>
            <if test="XTMC != null">XTMC = #{XTMC},</if>
            <if test="ZW != null">ZW = #{ZW},</if>
            <if test="ZZJGID != null">ZZJGID = #{ZZJGID},</if>
        </trim>
        where FH_RKSJ = #{fhRksj}
    </update>
    <update id="truncate">
        TRUNCATE TABLE police_info_es;
    </update>

    <delete id="deletePoliceInfoEsByFhRksj" parameterType="String">
        delete from police_info_es where FH_RKSJ = #{fhRksj}
    </delete>

    <delete id="deletePoliceInfoEsByFhRksjs" parameterType="String">
        delete from police_info_es where FH_RKSJ in 
        <foreach item="fhRksj" collection="array" open="(" separator="," close=")">
            #{fhRksj}
        </foreach>
    </delete>
</mapper>
