<?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.chinaweal.aiccs.aicepsqy.mapper.datamove.PartyBuildInfoMapper">

    <!-- 动态插入党建信息 -->
    <insert id="insertPartyBuildInfo" parameterType="com.chinaweal.aiccs.aicepsqy.entity.datamove.PartyBuildInfoModel" useGeneratedKeys="false">
        <![CDATA[
        insert into
            TRPartyBuildInfoTemp_${entity.reportYear}(
            PartyId,EntID,EntityNo,NumParM,NumParMIsShow,ParIns,ParInsIsShow,
            ResParMSign,ResParMSignIsShow,ResParSecSign,ResParSecSignIsShow, ReportYear
        )
        values
            (
                #{entity.partyId},#{entity.entId},#{entity.entityNo},
                #{entity.numParM,jdbcType=NUMERIC},
                #{entity.numParMIsShow,jdbcType=CHAR},
                #{entity.parIns,jdbcType=CHAR},
                #{entity.parInsIsShow,jdbcType=CHAR},
                #{entity.resParMSign,jdbcType=CHAR},
                #{entity.resParMSignIsShow,jdbcType=CHAR},
                #{entity.resParSecSign,jdbcType=CHAR},
                #{entity.resParSecSignIsShow,jdbcType=CHAR},
                #{entity.reportYear}
            )
        ]]>
    </insert>

    <insert id="insertPartyBuildInfozs" parameterType="com.chinaweal.aiccs.aicepsqy.entity.datamove.PartyBuildInfoModel" useGeneratedKeys="false">
        <![CDATA[
        insert into
            TRPartyBuildInfo_${entity.reportYear}(
            PartyId,EntID,EntityNo,NumParM,NumParMIsShow,ParIns,ParInsIsShow,
            ResParMSign,ResParMSignIsShow,ResParSecSign,ResParSecSignIsShow, ReportYear
        )
        values
            (
                #{entity.partyId},#{entity.entId},#{entity.entityNo},
                #{entity.numParM,jdbcType=NUMERIC},
                #{entity.numParMIsShow,jdbcType=CHAR},
                #{entity.parIns,jdbcType=CHAR},
                #{entity.parInsIsShow,jdbcType=CHAR},
                #{entity.resParMSign,jdbcType=CHAR},
                #{entity.resParMSignIsShow,jdbcType=CHAR},
                #{entity.resParSecSign,jdbcType=CHAR},
                #{entity.resParSecSignIsShow,jdbcType=CHAR},
                #{entity.reportYear}
            )
        ]]>
    </insert>

    <!-- 动态查询：根据EntityNo和ReportYear -->
    <select id="selectPartyBuildByEntityNoAndReportYear"
            resultType="com.chinaweal.aiccs.aicepsqy.entity.datamove.PartyBuildInfoModel">
        <![CDATA[
        select
            PartyId,EntID,EntityNo,NumParM,NumParMIsShow,ParIns,ParInsIsShow,
            ResParMSign,ResParMSignIsShow,ResParSecSign,ResParSecSignIsShow, ReportYear
        from TRPartyBuildInfo_${reportYear}
        where EntityNo = #{entityNo}
          and ReportYear = #{reportYear} and Dstate !='2'
        ]]>
    </select>

    <!-- 动态更新：根据EntityNo和ReportYear -->
    <update id="updatePartyBuildByEntityNoAndReportYear"
            parameterType="com.chinaweal.aiccs.aicepsqy.entity.datamove.PartyBuildInfoModel">
        <![CDATA[
        update TRPartyBuildInfo_${reportYear}
        set
            PartyId = #{entity.partyId},
            EntID = #{entity.entId},
            NumParM = #{entity.numParM,jdbcType=NUMERIC},
            NumParMIsShow = #{entity.numParMIsShow,jdbcType=CHAR},
            ParIns = #{entity.parIns,jdbcType=CHAR},
            ParInsIsShow = #{entity.parInsIsShow,jdbcType=CHAR},
            ResParMSign = #{entity.resParMSign,jdbcType=CHAR},
            ResParMSignIsShow = #{entity.resParMSignIsShow,jdbcType=CHAR},
            ResParSecSign = #{entity.resParSecSign,jdbcType=CHAR},
            ResParSecSignIsShow = #{entity.resParSecSignIsShow,jdbcType=CHAR},
            ReportYear = #{entity.reportYear},
            updateDate = getdate()
        where
            EntityNo = #{entityNo}
          and ReportYear = #{reportYear} and Dstate !='2'
        ]]>
    </update>

    <delete id="deleteByPartyBuildId">
    <![CDATA[
        delete from TRPartyBuildInfoTemp_${reportYear}
        where  EntID = #{entid}
        ]]>
    </delete>

    <delete id="deleteByPartyBuildIdzs">
    <![CDATA[
        delete from TRPartyBuildInfo_${reportYear}
        where  EntID = #{entid}
        ]]>
    </delete>

</mapper>
