<?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.IndividualReportMapper">

    <!-- 动态插入个人报告信息 -->
    <insert id="insertIndividualReport" parameterType="com.chinaweal.aiccs.aicepsqy.entity.datamove.IndividualReportModel" useGeneratedKeys="false">
        insert into TRIndividualReportTemp_${entity.reportYear} (
            IndividualID,
            EntId,
            UserName,
            Scope,
            IsPartyMember,
            IsPartyCommittee,
            EmpNumber,
            PartyMemberNum,
            PartyIsShow,
            GraduatesNum,
            GraduatesIsShow,
            SoldiersNum,
            SoldiersIsShow,
            DisabilityNum,
            DisabilityIsShow,
            UnemploymentNum,
            UnemploymentIsShow,
            TotalFunds,
            OutputAmount,
            OutputIsShow,
            SalesAmount,
            SalesIsShow,
            RetailAmount,
            RetailIsShow,
            MarkupMode,
            ReportIsShow,
            EntNameissame,
            Userissame,
            MarkupModeissame,
            Scopeissame,
            Addressissame,
            RatGro,
            RatGroIsShow,
            ColGraNum,
            RetSolNum,
            DisPerNum,
            UneNum,
            Coinid,
            ReportYear
        )
        values
            (
                #{entity.individualID},
                #{entity.entId},
                #{entity.userName,jdbcType=VARCHAR},
                #{entity.scope,jdbcType=VARCHAR},
                #{entity.isPartyMember,jdbcType=CHAR},
                #{entity.isPartyCommittee,jdbcType=CHAR},
                #{entity.empNumber,jdbcType=NUMERIC},
                #{entity.partyMemberNum,jdbcType=NUMERIC},
                #{entity.partyIsShow,jdbcType=CHAR},
                #{entity.graduatesNum,jdbcType=NUMERIC},
                #{entity.graduatesIsShow,jdbcType=CHAR},
                #{entity.soldiersNum,jdbcType=NUMERIC},
                #{entity.soldiersIsShow,jdbcType=CHAR},
                #{entity.disabilityNum,jdbcType=NUMERIC},
                #{entity.disabilityIsShow,jdbcType=CHAR},
                #{entity.unemploymentNum,jdbcType=NUMERIC},
                #{entity.unemploymentIsShow,jdbcType=CHAR},
                #{entity.totalFunds,jdbcType=NUMERIC},
                #{entity.outputAmount,jdbcType=NUMERIC},
                #{entity.outputIsShow,jdbcType=CHAR},
                #{entity.salesAmount,jdbcType=NUMERIC},
                #{entity.salesIsShow,jdbcType=CHAR},
                #{entity.retailAmount,jdbcType=NUMERIC},
                #{entity.retailIsShow,jdbcType=CHAR},
                #{entity.markupMode,jdbcType=VARCHAR},
                #{entity.reportIsShow,jdbcType=CHAR},
                #{entity.entNameissame,jdbcType=CHAR},
                #{entity.userissame,jdbcType=CHAR},
                #{entity.markupModeissame,jdbcType=CHAR},
                #{entity.scopeissame,jdbcType=CHAR},
                #{entity.addressissame,jdbcType=CHAR},
                #{entity.ratGro,jdbcType=NUMERIC},
                #{entity.ratGroIsShow,jdbcType=CHAR},
                #{entity.colGraNum,jdbcType=NUMERIC},
                #{entity.retSolNum,jdbcType=NUMERIC},
                #{entity.disPerNum,jdbcType=NUMERIC},
                #{entity.uneNum,jdbcType=NUMERIC},
                #{entity.coinid,jdbcType=VARCHAR},
                #{entity.reportYear}
            )
    </insert>

    <insert id="insertIndividualReportzs" parameterType="com.chinaweal.aiccs.aicepsqy.entity.datamove.IndividualReportModel" useGeneratedKeys="false">
        insert into TRIndividualReport_${entity.reportYear} (
            IndividualID,
            EntId,
            UserName,
            Scope,
            IsPartyMember,
            IsPartyCommittee,
            EmpNumber,
            PartyMemberNum,
            PartyIsShow,
            GraduatesNum,
            GraduatesIsShow,
            SoldiersNum,
            SoldiersIsShow,
            DisabilityNum,
            DisabilityIsShow,
            UnemploymentNum,
            UnemploymentIsShow,
            TotalFunds,
            OutputAmount,
            OutputIsShow,
            SalesAmount,
            SalesIsShow,
            RetailAmount,
            RetailIsShow,
            MarkupMode,
            ReportIsShow,
            EntNameissame,
            Userissame,
            MarkupModeissame,
            Scopeissame,
            Addressissame,
            RatGro,
            RatGroIsShow,
            ColGraNum,
            RetSolNum,
            DisPerNum,
            UneNum,
            Coinid,
            ReportYear
        )
        values
            (
                #{entity.individualID},
                #{entity.entId},
                #{entity.userName,jdbcType=VARCHAR},
                #{entity.scope,jdbcType=VARCHAR},
                #{entity.isPartyMember,jdbcType=CHAR},
                #{entity.isPartyCommittee,jdbcType=CHAR},
                #{entity.empNumber,jdbcType=NUMERIC},
                #{entity.partyMemberNum,jdbcType=NUMERIC},
                #{entity.partyIsShow,jdbcType=CHAR},
                #{entity.graduatesNum,jdbcType=NUMERIC},
                #{entity.graduatesIsShow,jdbcType=CHAR},
                #{entity.soldiersNum,jdbcType=NUMERIC},
                #{entity.soldiersIsShow,jdbcType=CHAR},
                #{entity.disabilityNum,jdbcType=NUMERIC},
                #{entity.disabilityIsShow,jdbcType=CHAR},
                #{entity.unemploymentNum,jdbcType=NUMERIC},
                #{entity.unemploymentIsShow,jdbcType=CHAR},
                #{entity.totalFunds,jdbcType=NUMERIC},
                #{entity.outputAmount,jdbcType=NUMERIC},
                #{entity.outputIsShow,jdbcType=CHAR},
                #{entity.salesAmount,jdbcType=NUMERIC},
                #{entity.salesIsShow,jdbcType=CHAR},
                #{entity.retailAmount,jdbcType=NUMERIC},
                #{entity.retailIsShow,jdbcType=CHAR},
                #{entity.markupMode,jdbcType=VARCHAR},
                #{entity.reportIsShow,jdbcType=CHAR},
                #{entity.entNameissame,jdbcType=CHAR},
                #{entity.userissame,jdbcType=CHAR},
                #{entity.markupModeissame,jdbcType=CHAR},
                #{entity.scopeissame,jdbcType=CHAR},
                #{entity.addressissame,jdbcType=CHAR},
                #{entity.ratGro,jdbcType=NUMERIC},
                #{entity.ratGroIsShow,jdbcType=CHAR},
                #{entity.colGraNum,jdbcType=NUMERIC},
                #{entity.retSolNum,jdbcType=NUMERIC},
                #{entity.disPerNum,jdbcType=NUMERIC},
                #{entity.uneNum,jdbcType=NUMERIC},
                #{entity.coinid,jdbcType=VARCHAR},
                #{entity.reportYear}
            )
    </insert>

    <!-- 动态查询：根据EntityNo和ReportYear -->
    <select id="selectIndividualByEntityNoAndReportYear"
            resultType="com.chinaweal.aiccs.aicepsqy.entity.datamove.IndividualReportModel">
        select
            IndividualID,
            EntId,
            UserName,
            Scope,
            IsPartyMember,
            IsPartyCommittee,
            EmpNumber,
            PartyMemberNum,
            PartyIsShow,
            GraduatesNum,
            GraduatesIsShow,
            SoldiersNum,
            SoldiersIsShow,
            DisabilityNum,
            DisabilityIsShow,
            UnemploymentNum,
            UnemploymentIsShow,
            TotalFunds,
            OutputAmount,
            OutputIsShow,
            SalesAmount,
            SalesIsShow,
            RetailAmount,
            RetailIsShow,
            MarkupMode,
            ReportIsShow,
            EntNameissame,
            Userissame,
            MarkupModeissame,
            Scopeissame,
            Addressissame,
            RatGro,
            RatGroIsShow,
            ColGraNum,
            RetSolNum,
            DisPerNum,
            UneNum,
            Coinid,
            ReportYear
        from TRIndividualReport_${reportYear}
        where EntId = #{entId}
          and ReportYear = #{reportYear} and Dstate !='2'
    </select>

    <!-- 动态更新：根据entId和ReportYear -->
    <update id="updateIndividualByEntityNoAndReportYear"
            parameterType="com.chinaweal.aiccs.aicepsqy.entity.datamove.IndividualReportModel">
        update TRIndividualReport_${reportYear}
        set
            IndividualID = #{entity.individualID},
            EntId = #{entity.entId},
            UserName = #{entity.userName,jdbcType=VARCHAR},
            Scope = #{entity.scope,jdbcType=VARCHAR},
            IsPartyMember = #{entity.isPartyMember,jdbcType=CHAR},
            IsPartyCommittee = #{entity.isPartyCommittee,jdbcType=CHAR},
            EmpNumber = #{entity.empNumber,jdbcType=NUMERIC},
            PartyMemberNum = #{entity.partyMemberNum,jdbcType=NUMERIC},
            PartyIsShow = #{entity.partyIsShow,jdbcType=CHAR},
            GraduatesNum = #{entity.graduatesNum,jdbcType=NUMERIC},
            GraduatesIsShow = #{entity.graduatesIsShow,jdbcType=CHAR},
            SoldiersNum = #{entity.soldiersNum,jdbcType=NUMERIC},
            SoldiersIsShow = #{entity.soldiersIsShow,jdbcType=CHAR},
            DisabilityNum = #{entity.disabilityNum,jdbcType=NUMERIC},
            DisabilityIsShow = #{entity.disabilityIsShow,jdbcType=CHAR},
            UnemploymentNum = #{entity.unemploymentNum,jdbcType=NUMERIC},
            UnemploymentIsShow = #{entity.unemploymentIsShow,jdbcType=CHAR},
            TotalFunds = #{entity.totalFunds,jdbcType=NUMERIC},
            OutputAmount = #{entity.outputAmount,jdbcType=NUMERIC},
            OutputIsShow = #{entity.outputIsShow,jdbcType=CHAR},
            SalesAmount = #{entity.salesAmount,jdbcType=NUMERIC},
            SalesIsShow = #{entity.salesIsShow,jdbcType=CHAR},
            RetailAmount = #{entity.retailAmount,jdbcType=NUMERIC},
            RetailIsShow = #{entity.retailIsShow,jdbcType=CHAR},
            MarkupMode = #{entity.markupMode,jdbcType=VARCHAR},
            ReportIsShow = #{entity.reportIsShow,jdbcType=CHAR},
            EntNameissame = #{entity.entNameissame,jdbcType=CHAR},
            Userissame = #{entity.userissame,jdbcType=CHAR},
            MarkupModeissame = #{entity.markupModeissame,jdbcType=CHAR},
            Scopeissame = #{entity.scopeissame,jdbcType=CHAR},
            Addressissame = #{entity.addressissame,jdbcType=CHAR},
            RatGro = #{entity.ratGro,jdbcType=NUMERIC},
            RatGroIsShow = #{entity.ratGroIsShow,jdbcType=CHAR},
            ColGraNum = #{entity.colGraNum,jdbcType=NUMERIC},
            RetSolNum = #{entity.retSolNum,jdbcType=NUMERIC},
            DisPerNum = #{entity.disPerNum,jdbcType=NUMERIC},
            UneNum = #{entity.uneNum,jdbcType=NUMERIC},
            Coinid = #{entity.coinid,jdbcType=VARCHAR},
            ReportYear = #{entity.reportYear},
            updateDate = getdate()
        where
            entId = #{entId}
          and ReportYear = #{reportYear} and Dstate !='2'
    </update>

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

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