<?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.hzya.frame.grpU8.nxproof.gbizbsyrec.dao.impl.GbiZbsyrecDaoImpl">
    <resultMap id="get-GbiZbsyrecEntity-result" type="com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity">
        <result property="module" column="module" jdbcType="VARCHAR"/>
        <result property="djlx" column="djlx" />
        <result property="gsdm" column="gsdm" />
        <result property="kjnd" column="kjnd" />
        <result property="djId" column="djId" />
        <result property="djflh" column="djflh"/>
        <result property="djflmx" column="djflmx" />
        <result property="djywrq" column="djywrq" />
        <result property="djzt" column="djzt" />
        <result property="jhId" column="jhId" />
        <result property="djje" column="djje" />
        <result property="sl" column="sl" />
        <result property="djzy" column="djzy" />
        <result property="szfx" column="szfx" />
        <result property="zblb" column="zblb" />
        <result property="jdzb" column="jdzb" />
        <result property="czlx" column="czlx" />
        <result property="zzbz" column="zzbz" />
        <result property="ywdjId" column="ywdjId" />


    </resultMap>

   <sql id="gbiZbsyrecEntity_Base_Column_List">
  GSDM,KJND
   </sql>

    <select id="GbiZbsyrecEntity_list_base" resultMap="get-GbiZbsyrecEntity-result" parameterType="com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity">
        select
        *
        from
        GBI_ZBSYREC
        <trim prefix="where" prefixOverrides="and">
            <if test="gsdm != null and gsdm !='' ">  GSDM = #{gsdm} </if>
            <if test="kjnd != null and kjnd !='' "> and KJND = #{kjnd} </if>
            <if test="module != null and module !='' "> and MODULE = #{module} </if>
            <if test="djlx != null and djlx !='' "> and DJLX = #{djlx} </if>
            <if test="djId != null and djId !='' ">and DJID =#{djId} </if>
            <if test="djflh != null and djflh !=''"> and DJFLH =#{djflh} </if>
            <if test="djflmx != null and djflmx !='' ">and DJFLMX =#{djflmx}</if>
            <if test="djywrq != null and djywrq !='' ">and DJYWRQ =#{djywrq} </if>
            <if test="djzt != null and djzt !='' ">and DJZT =#{djzt}</if>
            <if test="jhId != null and jhId !='' ">and JHID =#{jhId} </if>
            <if test="djje != null and djje !='' ">and DJJE =#{djje}</if>
            <if test="sl != null and sl !=''">and SL =#{sl} </if>
            <if test="djzy != null and djzy !='' ">and DJZY =#{djzy} </if>
            <if test="szfx != null and szfx !='' ">and SZFX =#{szfx} </if>
            <if test="zblb != null and zblb !='' ">and ZBLB =#{zblb} </if>
            <if test="jdzb != null and jdzb !='' ">and JDBZ =#{jdzb} </if>
            <if test="czlx != null and czlx !='' ">and CZLX =#{czlx} </if>
            <if test="zzbz != null and zzbz !='' ">and ZZBZ =#{zzbz}</if>
            <if test="ywdjId != null and ywdjId !='' ">and YWDJID =#{ywdjId} </if>
        </trim>
    </select>

    <!--根据业务参考号查询单个数据-->
    <select id="GbiZbsyrecEntity_list_base_one" resultMap="get-GbiZbsyrecEntity-result" parameterType="com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity">
        select
        *
        from
        GBI_ZBSYREC
       where DJID= #{djId}
    </select>

    <insert id="GbiZbsyrecEntity_insert" parameterType="com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity">
        insert into GBI_ZBSYREC(
        <if test="ywdjId != null and ywdjId !='' "> YWDJID,</if>
        <if test="kjnd != null and kjnd !='' "> KJND, </if>
        <if test="module != null and module !='' "> MODULE, </if>
        <if test="djlx != null and djlx !='' "> DJLX, </if>
        <if test="djId != null and djId !='' "> DJID, </if>
        <if test="djflh != null and djflh !=''"> DJFLH, </if>
        <if test="djflmx != null and djflmx !='' "> DJFLMX, </if>
        <if test="djywrq != null and djywrq !='' "> DJYWRQ, </if>
        <if test="djzt != null and djzt !='' "> DJZT,</if>
        <if test="jhId != null and jhId !='' "> JHID, </if>
        <if test="djje != null and djje !='' "> DJJE ,</if>
        <if test="sl != null and sl !=''"> SL, </if>
        <if test="djzy != null and djzy !='' "> DJZY, </if>
        <if test="szfx != null and szfx !='' "> SZFX, </if>
        <if test="zblb != null and zblb !='' "> ZBLB, </if>
        <if test="jdzb != null and jdzb !='' "> JDBZ, </if>
        <if test="czlx != null and czlx !='' "> CZLX, </if>
        <if test="zzbz != null and zzbz !='' "> ZZBZ,</if>
        <if test="gsdm != null and gsdm !='' "> GSDM</if>
        )
        values (
        <if test="ywdjId != null and ywdjId !='' "> #{ywdjId},</if>
        <if test="kjnd != null and kjnd !='' "> #{kjnd}, </if>
        <if test="module != null and module !='' "> #{module}, </if>
        <if test="djlx != null and djlx !='' "> #{djlx}, </if>
        <if test="djId != null and djId !='' "> #{djId}, </if>
        <if test="djflh != null and djflh !=''"> #{djflh}, </if>
        <if test="djflmx != null and djflmx !='' "> #{djflmx}, </if>
        <if test="djywrq != null and djywrq !='' "> #{djywrq}, </if>
        <if test="djzt != null and djzt !='' "> #{djzt},</if>
        <if test="jhId != null and jhId !='' "> #{jhId}, </if>
        <if test="djje != null and djje !='' "> #{djje},</if>
        <if test="sl != null and sl !=''"> #{sl}, </if>
        <if test="djzy != null and djzy !='' "> #{djzy}, </if>
        <if test="szfx != null and szfx !='' "> #{szfx}, </if>
        <if test="zblb != null and zblb !='' "> #{zblb}, </if>
        <if test="jdzb != null and jdzb !='' "> #{jdzb}, </if>
        <if test="czlx != null and czlx !='' "> #{czlx}, </if>
        <if test="zzbz != null and zzbz !='' "> #{zzbz},</if>
        <if test="gsdm != null and gsdm !='' "> #{gsdm}</if>
        )
    </insert>

    <delete id="GbiZbsyrecEntity_delete" parameterType="com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity">
		delete from GBI_ZBSYREC  where KJND=#{kjnd} and DJID= #{djId}
	</delete>

    <delete id="GbiZbsyrecEntity_delete_gsp" parameterType="com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity">
		delete FROM gbi_zbsyrec where GSDM =#{gsdm} and KJND=#{kjnd} and MODULE='GSP' and abs(DJFLMX)=${djflmx} AND DJJE > 0
	</delete>

    <delete id="GbiZbsyrecEntity_delete_oer" parameterType="com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity">
		delete FROM gbi_zbsyrec where GSDM =#{gsdm} and KJND=#{kjnd} and MODULE='OER' and djlx=#{djlx} and djid=#{djId} AND DJFLMX=#{djflmx}
	</delete>
    <delete id="GbiZbsyrecEntity_delete_mlid" parameterType="com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity">
		delete FROM gbi_zbsyrec where GSDM =#{gsdm} and KJND=#{kjnd} and djid=#{djId}
	</delete>

    <!--删除 单据删除时使用-->
    <delete  id="GbiZbsyrecEntity_delete_del"  parameterType="com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity">
        DELETE
        FROM
            gbi_zbsyrec
        WHERE
            GSDM = #{gsdm}
          AND KJND = #{kjnd}
          AND (
                (
                    MODULE = #{module}
                    AND DJFLMX = #{djflmx}
                    )
                OR (
                    MODULE = #{module}
                    AND DJFLMX =#{djflmx}
                    )
            );
    </delete>
    <!--删除 单据删除时使用-->
    <delete  id="GbiZbsyrecEntity_delete_dels"  parameterType="com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity">
        DELETE
        FROM
            gbi_zbsyrec
        WHERE
            GSDM = #{gsdm}
          AND KJND = #{kjnd}
          AND (MODULE = #{module} OR MODULE = #{module})
          AND abs(DJFLMX) = #{djflmx}
    </delete>

    <!-- 修改 单据送审时使用   -->
    <update id="GbiZbsyrecEntity_update" parameterType="com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity">
        UPDATE GBI_ZBSYREC
        SET DJZT = '1'
        WHERE
            GSDM = #{gsdm}
          AND KJND = #{kjnd}
          AND MODULE = #{module}
          AND DJLX = #{djlx}
          AND DJID = #{djId}
          AND (DJFLMX = #{djflmx})
    </update>

</mapper>
