<?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.ruoyi.system.mapper.projectV2.ZsyzKgxxMapper">
    
    <resultMap type="ZsyzKgxx" id="ZsyzKgxxResult">
        <result property="id"    column="id"    />
        <result property="xmId"    column="xm_id"    />
        <result property="xmbh"    column="xmbh"    />
        <result property="xmxsmc"    column="xmxsmc"    />
        <result property="xmmc"    column="xmmc"    />
        <result property="kgrq"    column="kgrq"    />
        <result property="njgrq"    column="njgrq"    />
        <result property="sscrq"    column="sscrq"    />
        <result property="ntcsj"    column="ntcsj"    />
        <result property="rtsj"    column="rtsj"    />
        <result property="nrtsj"    column="nrtsj"    />
        <result property="kggjrsjh"    column="kggjrsjh"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="czwt"    column="czwt"    />
    </resultMap>

    <sql id="selectZsyzKgxxVo">
        select id, xm_id, xmbh,xmxsmc,czwt, xmmc, kgrq, njgrq, sscrq, ntcsj, rtsj, nrtsj, kggjrsjh, create_by, create_time, update_by, update_time, remark from zsyz_kgxx
    </sql>

    <select id="selectZsyzKgxxList" parameterType="ZsyzKgxx" resultMap="ZsyzKgxxResult">
        <include refid="selectZsyzKgxxVo"/>
        <where>  
            <if test="xmId != null "> and xm_id = #{xmId}</if>
            <if test="xmbh != null  and xmbh != ''"> and xmbh = #{xmbh}</if>
            <if test="xmxsmc != null  and xmxsmc != ''"> and xmxsmc = #{xmxsmc}</if>
            <if test="xmmc != null  and xmmc != ''"> and xmmc = #{xmmc}</if>
            <if test="kgrq != null "> and kgrq = #{kgrq}</if>
            <if test="njgrq != null "> and njgrq = #{njgrq}</if>
            <if test="sscrq != null "> and sscrq = #{sscrq}</if>
            <if test="ntcsj != null "> and ntcsj = #{ntcsj}</if>
            <if test="rtsj != null "> and rtsj = #{rtsj}</if>
            <if test="nrtsj != null "> and nrtsj = #{nrtsj}</if>
            <if test="kggjrsjh != null  and kggjrsjh != ''"> and kggjrsjh = #{kggjrsjh}</if>
        </where>
        order by update_time desc
    </select>
    
    <select id="selectZsyzKgxxById" parameterType="Long" resultMap="ZsyzKgxxResult">
        <include refid="selectZsyzKgxxVo"/>
        where xm_id = #{id}
    </select>
        
    <insert id="insertZsyzKgxx" parameterType="ZsyzKgxx" useGeneratedKeys="true" keyProperty="id">
        insert into zsyz_kgxx
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="xmId != null">xm_id,</if>
            <if test="xmbh != null">xmbh,</if>
            <if test="xmxsmc != null">xmxsmc,</if>
            <if test="xmmc != null">xmmc,</if>
            <if test="kgrq != null">kgrq,</if>
            <if test="njgrq != null">njgrq,</if>
            <if test="sscrq != null">sscrq,</if>
            <if test="ntcsj != null">ntcsj,</if>
            <if test="rtsj != null">rtsj,</if>
            <if test="nrtsj != null">nrtsj,</if>
            <if test="kggjrsjh != null and kggjrsjh != ''">kggjrsjh,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="czwt != null">czwt,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="xmId != null">#{xmId},</if>
            <if test="xmbh != null">#{xmbh},</if>
            <if test="xmxsmc != null">#{xmxsmc},</if>
            <if test="xmmc != null">#{xmmc},</if>
            <if test="kgrq != null">#{kgrq},</if>
            <if test="njgrq != null">#{njgrq},</if>
            <if test="sscrq != null">#{sscrq},</if>
            <if test="ntcsj != null">#{ntcsj},</if>
            <if test="rtsj != null">#{rtsj},</if>
            <if test="nrtsj != null">#{nrtsj},</if>
            <if test="kggjrsjh != null and kggjrsjh != ''">#{kggjrsjh},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="czwt != null">#{czwt},</if>
         </trim>
    </insert>

    <update id="updateZsyzKgxx" parameterType="ZsyzKgxx">
        update zsyz_kgxx
        <trim prefix="SET" suffixOverrides=",">
            <if test="xmId != null">xm_id = #{xmId},</if>
            <if test="xmbh != null">xmbh = #{xmbh},</if>
            <if test="xmxsmc != null">xmxsmc = #{xmxsmc},</if>
            <if test="xmmc != null">xmmc = #{xmmc},</if>
            <if test="kgrq != null">kgrq = #{kgrq},</if>
            <if test="njgrq != null">njgrq = #{njgrq},</if>
            <if test="sscrq != null">sscrq = #{sscrq},</if>
            <if test="ntcsj != null">ntcsj = #{ntcsj},</if>
            <if test="rtsj != null">rtsj = #{rtsj},</if>
            <if test="rtsj == null">rtsj = null,</if>
            <if test="nrtsj != null">nrtsj = #{nrtsj},</if>
            <if test="nrtsj == null">nrtsj = null,</if>
            <if test="kggjrsjh != null and kggjrsjh != ''">kggjrsjh = #{kggjrsjh},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="czwt != null">czwt = #{czwt},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteZsyzKgxxById" parameterType="Long">
        delete from zsyz_kgxx where id = #{id}
    </delete>

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