McBasicCmtyMapper.xml 21.9 KB
<?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.chinagas.modules.schsf.mapper.McBasicCmtyMapper">

    <resultMap type="com.chinagas.modules.schsf.domain.McBasicCmty" id="McBasicCmtyResult">
        <result property="id"    column="id"    />
        <result property="fiscalYear"    column="fiscal_year"    />
        <result property="regionName"    column="region_name"    />
        <result property="groupName"    column="group_name"    />
        <result property="companyName"    column="company_name"    />
        <result property="companyCode"    column="company_code"    />
        <result property="province"    column="province"    />
        <result property="city"    column="city"    />
        <result property="district"    column="district"    />
        <result property="street"    column="street"    />
        <result property="vlgOrCmty"    column="vlg_or_cmty"    />
        <result property="respPerson"    column="resp_person"    />
        <result property="urbRurCls"    column="urb_rur_cls"    />
        <result property="projectTypeName"    column="project_type_name"    />
        <result property="commHh"    column="comm_hh"    />
        <result property="acctFyStartConf"    column="acct_fy_start_conf"    />
        <result property="acctPrevRecov"    column="acct_prev_recov"    />
        <result property="acctPrevCharged"    column="acct_prev_charged"    />
        <result property="currFyNewRecovered"    column="curr_fy_new_recovered"    />
        <result property="totalCharged"    column="total_charged"    />
        <result property="qtrTargetCompany"    column="qtr_target_company"    />
        <result property="hhGsgCharged"    column="hh_gsg_charged"    />
        <result property="hhGsgUncharged"    column="hh_gsg_uncharged"    />
        <result property="hhGsgTotal"    column="hh_gsg_total"    />
        <result property="hhNewFull"    column="hh_new_full"    />
        <result property="hhNewInstall"    column="hh_new_install"    />
        <result property="hhPrevFull"    column="hh_prev_full"    />
        <result property="hhPrevInstDp"    column="hh_prev_inst_dp"    />
        <result property="hhUnchg"    column="hh_unchg"    />
        <result property="hhUnchgConf"    column="hh_unchg_conf"    />
        <result property="hhUnchgScan"    column="hh_unchg_scan"    />
        <result property="hhEvCumPaid"    column="hh_ev_cum_paid"    />
        <result property="hhEvInst"    column="hh_ev_inst"    />
        <result property="hhEvFull"    column="hh_ev_full"    />
        <result property="hhEvIgnite"    column="hh_ev_ignite"    />
        <result property="hhEvCumSetup"    column="hh_ev_cum_setup"    />
        <result property="hhEvCumGas"    column="hh_ev_cum_gas"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="defFlag"    column="def_flag"    />
    </resultMap>

    <sql id="selectMcBasicCmtyVo">
        select m.id, m.fiscal_year, m.region_name, m.group_name, m.company_name, m.company_code, m.province, m.city, m.district, m.street, m.vlg_or_cmty, m.resp_person, m.urb_rur_cls, m.project_type_name, m.comm_hh, m.acct_fy_start_conf, m.acct_prev_recov, m.acct_prev_charged, m.curr_fy_new_recovered, m.total_charged, m.qtr_target_company, m.hh_gsg_charged, m.hh_gsg_uncharged, m.hh_gsg_total, m.hh_new_full, m.hh_new_install, m.hh_prev_full, m.hh_prev_inst_dp, m.hh_unchg, m.hh_unchg_conf,
               m.hh_unchg_scan, m.hh_ev_cum_paid, m.hh_ev_inst, m.hh_ev_full, m.hh_ev_ignite, m.hh_ev_cum_setup, m.hh_ev_cum_gas, m.remark, m.create_time, m.create_by, m.update_time, m.update_by, m.def_flag
        FROM mc_basic_cmty m
        left join sys_user u on u.user_id = m.create_by
        left join sys_dept d on d.dept_id = m.company_code
    </sql>

    <select id="selectMcBasicCmtyList" parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo" resultMap="McBasicCmtyResult">
        <include refid="selectMcBasicCmtyVo"/>
        where 1=1
            <if test="fiscalYear != null "> and fiscal_year = #{fiscalYear}</if>
            <if test="regionName != null  and regionName != ''"> and region_name like concat('%', #{regionName}, '%')</if>
            <if test="groupName != null  and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
            <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
            <if test="companyCode != null  and companyCode != ''"> and company_code = #{companyCode}</if>
            <if test="province != null  and province != ''"> and province = #{province}</if>
            <if test="city != null  and city != ''"> and city = #{city}</if>
            <if test="district != null  and district != ''"> and district = #{district}</if>
            <if test="street != null  and street != ''"> and street = #{street}</if>
            <if test="vlgOrCmty != null  and vlgOrCmty != ''"> and vlg_or_cmty = #{vlgOrCmty}</if>
            <if test="respPerson != null  and respPerson != ''"> and resp_person = #{respPerson}</if>
            <if test="urbRurCls != null  and urbRurCls != ''"> and urb_rur_cls = #{urbRurCls}</if>
            <if test="projectTypeName != null  and projectTypeName != ''"> and project_type_name like concat('%', #{projectTypeName}, '%')</if>
            <if test="commHh != null "> and comm_hh = #{commHh}</if>
            <if test="acctFyStartConf != null "> and acct_fy_start_conf = #{acctFyStartConf}</if>
            <if test="acctPrevRecov != null "> and acct_prev_recov = #{acctPrevRecov}</if>
            <if test="acctPrevCharged != null "> and acct_prev_charged = #{acctPrevCharged}</if>
            <if test="currFyNewRecovered != null "> and curr_fy_new_recovered = #{currFyNewRecovered}</if>
            <if test="totalCharged != null "> and total_charged = #{totalCharged}</if>
            <if test="qtrTargetCompany != null "> and qtr_target_company = #{qtrTargetCompany}</if>
            <if test="hhGsgCharged != null "> and hh_gsg_charged = #{hhGsgCharged}</if>
            <if test="hhGsgUncharged != null "> and hh_gsg_uncharged = #{hhGsgUncharged}</if>
            <if test="hhGsgTotal != null "> and hh_gsg_total = #{hhGsgTotal}</if>
            <if test="hhNewFull != null "> and hh_new_full = #{hhNewFull}</if>
            <if test="hhNewInstall != null "> and hh_new_install = #{hhNewInstall}</if>
            <if test="hhPrevFull != null "> and hh_prev_full = #{hhPrevFull}</if>
            <if test="hhPrevInstDp != null "> and hh_prev_inst_dp = #{hhPrevInstDp}</if>
            <if test="hhUnchg != null "> and hh_unchg = #{hhUnchg}</if>
            <if test="hhUnchgConf != null "> and hh_unchg_conf = #{hhUnchgConf}</if>
            <if test="hhUnchgScan != null "> and hh_unchg_scan = #{hhUnchgScan}</if>
            <if test="hhEvCumPaid != null "> and hh_ev_cum_paid = #{hhEvCumPaid}</if>
            <if test="hhEvInst != null "> and hh_ev_inst = #{hhEvInst}</if>
            <if test="hhEvFull != null "> and hh_ev_full = #{hhEvFull}</if>
            <if test="hhEvIgnite != null "> and hh_ev_ignite = #{hhEvIgnite}</if>
            <if test="hhEvCumSetup != null "> and hh_ev_cum_setup = #{hhEvCumSetup}</if>
            <if test="hhEvCumGas != null "> and hh_ev_cum_gas = #{hhEvCumGas}</if>
            <if test="defFlag != null  and defFlag != ''"> and m.def_flag = #{defFlag}</if>
            <if test="startFiscalYear != null  and startFiscalYear != ''"> and m.fiscal_year &gt;= #{startFiscalYear}</if>
            <if test="finishFiscalYear != null  and finishFiscalYear != ''"> and m.fiscal_year &lt;= #{finishFiscalYear}</if>
            <!-- 数据范围过滤 -->
            ${params.dataScope}
        order by m.update_time desc
    </select>

    <select id="selectMcBasicCmtyById" parameterType="Long" resultMap="McBasicCmtyResult">
        <include refid="selectMcBasicCmtyVo"/>
        where id = #{id}
    </select>

    <insert id="insertMcBasicCmty" parameterType="com.chinagas.modules.schsf.domain.McBasicCmty"    useGeneratedKeys="true" keyProperty="id">
        insert into mc_basic_cmty
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="fiscalYear != null">fiscal_year,</if>
            <if test="regionName != null and regionName != ''">region_name,</if>
            <if test="groupName != null and groupName != ''">group_name,</if>
            <if test="companyName != null and companyName != ''">company_name,</if>
            <if test="companyCode != null and companyCode != ''">company_code,</if>
            <if test="province != null">province,</if>
            <if test="city != null">city,</if>
            <if test="district != null">district,</if>
            <if test="street != null">street,</if>
            <if test="vlgOrCmty != null">vlg_or_cmty,</if>
            <if test="respPerson != null">resp_person,</if>
            <if test="urbRurCls != null">urb_rur_cls,</if>
            <if test="projectTypeName != null">project_type_name,</if>
            <if test="commHh != null">comm_hh,</if>
            <if test="acctFyStartConf != null">acct_fy_start_conf,</if>
            <if test="acctPrevRecov != null">acct_prev_recov,</if>
            <if test="acctPrevCharged != null">acct_prev_charged,</if>
            <if test="currFyNewRecovered != null">curr_fy_new_recovered,</if>
            <if test="totalCharged != null">total_charged,</if>
            <if test="qtrTargetCompany != null">qtr_target_company,</if>
            <if test="hhGsgCharged != null">hh_gsg_charged,</if>
            <if test="hhGsgUncharged != null">hh_gsg_uncharged,</if>
            <if test="hhGsgTotal != null">hh_gsg_total,</if>
            <if test="hhNewFull != null">hh_new_full,</if>
            <if test="hhNewInstall != null">hh_new_install,</if>
            <if test="hhPrevFull != null">hh_prev_full,</if>
            <if test="hhPrevInstDp != null">hh_prev_inst_dp,</if>
            <if test="hhUnchg != null">hh_unchg,</if>
            <if test="hhUnchgConf != null">hh_unchg_conf,</if>
            <if test="hhUnchgScan != null">hh_unchg_scan,</if>
            <if test="hhEvCumPaid != null">hh_ev_cum_paid,</if>
            <if test="hhEvInst != null">hh_ev_inst,</if>
            <if test="hhEvFull != null">hh_ev_full,</if>
            <if test="hhEvIgnite != null">hh_ev_ignite,</if>
            <if test="hhEvCumSetup != null">hh_ev_cum_setup,</if>
            <if test="hhEvCumGas != null">hh_ev_cum_gas,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="defFlag != null and defFlag != ''">def_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="fiscalYear != null">#{fiscalYear},</if>
            <if test="regionName != null and regionName != ''">#{regionName},</if>
            <if test="groupName != null and groupName != ''">#{groupName},</if>
            <if test="companyName != null and companyName != ''">#{companyName},</if>
            <if test="companyCode != null and companyCode != ''">#{companyCode},</if>
            <if test="province != null">#{province},</if>
            <if test="city != null">#{city},</if>
            <if test="district != null">#{district},</if>
            <if test="street != null">#{street},</if>
            <if test="vlgOrCmty != null">#{vlgOrCmty},</if>
            <if test="respPerson != null">#{respPerson},</if>
            <if test="urbRurCls != null">#{urbRurCls},</if>
            <if test="projectTypeName != null">#{projectTypeName},</if>
            <if test="commHh != null">#{commHh},</if>
            <if test="acctFyStartConf != null">#{acctFyStartConf},</if>
            <if test="acctPrevRecov != null">#{acctPrevRecov},</if>
            <if test="acctPrevCharged != null">#{acctPrevCharged},</if>
            <if test="currFyNewRecovered != null">#{currFyNewRecovered},</if>
            <if test="totalCharged != null">#{totalCharged},</if>
            <if test="qtrTargetCompany != null">#{qtrTargetCompany},</if>
            <if test="hhGsgCharged != null">#{hhGsgCharged},</if>
            <if test="hhGsgUncharged != null">#{hhGsgUncharged},</if>
            <if test="hhGsgTotal != null">#{hhGsgTotal},</if>
            <if test="hhNewFull != null">#{hhNewFull},</if>
            <if test="hhNewInstall != null">#{hhNewInstall},</if>
            <if test="hhPrevFull != null">#{hhPrevFull},</if>
            <if test="hhPrevInstDp != null">#{hhPrevInstDp},</if>
            <if test="hhUnchg != null">#{hhUnchg},</if>
            <if test="hhUnchgConf != null">#{hhUnchgConf},</if>
            <if test="hhUnchgScan != null">#{hhUnchgScan},</if>
            <if test="hhEvCumPaid != null">#{hhEvCumPaid},</if>
            <if test="hhEvInst != null">#{hhEvInst},</if>
            <if test="hhEvFull != null">#{hhEvFull},</if>
            <if test="hhEvIgnite != null">#{hhEvIgnite},</if>
            <if test="hhEvCumSetup != null">#{hhEvCumSetup},</if>
            <if test="hhEvCumGas != null">#{hhEvCumGas},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="defFlag != null and defFlag != ''">#{defFlag},</if>
         </trim>
    </insert>

    <update id="updateMcBasicCmty" parameterType="com.chinagas.modules.schsf.domain.McBasicCmty">
        update mc_basic_cmty
        <trim prefix="SET" suffixOverrides=",">
            <if test="fiscalYear != null">fiscal_year = #{fiscalYear},</if>
            <if test="regionName != null and regionName != ''">region_name = #{regionName},</if>
            <if test="groupName != null and groupName != ''">group_name = #{groupName},</if>
            <if test="companyName != null and companyName != ''">company_name = #{companyName},</if>
            <if test="companyCode != null and companyCode != ''">company_code = #{companyCode},</if>
            <if test="province != null">province = #{province},</if>
            <if test="city != null">city = #{city},</if>
            <if test="district != null">district = #{district},</if>
            <if test="street != null">street = #{street},</if>
            <if test="vlgOrCmty != null">vlg_or_cmty = #{vlgOrCmty},</if>
            <if test="respPerson != null">resp_person = #{respPerson},</if>
            <if test="urbRurCls != null">urb_rur_cls = #{urbRurCls},</if>
            <if test="projectTypeName != null">project_type_name = #{projectTypeName},</if>
            <if test="commHh != null">comm_hh = #{commHh},</if>
            <if test="acctFyStartConf != null">acct_fy_start_conf = #{acctFyStartConf},</if>
            <if test="acctPrevRecov != null">acct_prev_recov = #{acctPrevRecov},</if>
            <if test="acctPrevCharged != null">acct_prev_charged = #{acctPrevCharged},</if>
            <if test="currFyNewRecovered != null">curr_fy_new_recovered = #{currFyNewRecovered},</if>
            <if test="totalCharged != null">total_charged = #{totalCharged},</if>
            <if test="qtrTargetCompany != null">qtr_target_company = #{qtrTargetCompany},</if>
            <if test="hhGsgCharged != null">hh_gsg_charged = #{hhGsgCharged},</if>
            <if test="hhGsgUncharged != null">hh_gsg_uncharged = #{hhGsgUncharged},</if>
            <if test="hhGsgTotal != null">hh_gsg_total = #{hhGsgTotal},</if>
            <if test="hhNewFull != null">hh_new_full = #{hhNewFull},</if>
            <if test="hhNewInstall != null">hh_new_install = #{hhNewInstall},</if>
            <if test="hhPrevFull != null">hh_prev_full = #{hhPrevFull},</if>
            <if test="hhPrevInstDp != null">hh_prev_inst_dp = #{hhPrevInstDp},</if>
            <if test="hhUnchg != null">hh_unchg = #{hhUnchg},</if>
            <if test="hhUnchgConf != null">hh_unchg_conf = #{hhUnchgConf},</if>
            <if test="hhUnchgScan != null">hh_unchg_scan = #{hhUnchgScan},</if>
            <if test="hhEvCumPaid != null">hh_ev_cum_paid = #{hhEvCumPaid},</if>
            <if test="hhEvInst != null">hh_ev_inst = #{hhEvInst},</if>
            <if test="hhEvFull != null">hh_ev_full = #{hhEvFull},</if>
            <if test="hhEvIgnite != null">hh_ev_ignite = #{hhEvIgnite},</if>
            <if test="hhEvCumSetup != null">hh_ev_cum_setup = #{hhEvCumSetup},</if>
            <if test="hhEvCumGas != null">hh_ev_cum_gas = #{hhEvCumGas},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="defFlag != null and defFlag != ''">def_flag = #{defFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMcBasicCmtyById" parameterType="Long">
        delete from mc_basic_cmty where id = #{id}
    </delete>

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

    <select id="getDistinctRegionList" resultType="com.chinagas.modules.schsf.domain.dto.CompanyDto"
            parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo">
        SELECT DISTINCT t.region_name as 'value',t.region_name as 'label'
        FROM mc_basic_cmty t
        left join sys_user u on u.user_id = t.create_by
        left join sys_dept d on d.dept_id = t.company_code
        WHERE 1=1
        <if test="defFlag != null  and defFlag != ''"> and t.def_flag = #{defFlag}</if>
        <if test="fiscalYear != null "> and t.fiscal_year = #{fiscalYear}</if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="getDistinctGroupList" resultType="com.chinagas.modules.schsf.domain.dto.CompanyDto"
            parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo">
        SELECT DISTINCT t.group_name as 'value',t.group_name as 'label'
        FROM mc_basic_cmty t
        left join sys_user u on u.user_id = t.create_by
        left join sys_dept d on d.dept_id = t.company_code
        WHERE 1=1
        <if test="regionName != null  and regionName != ''"> and t.region_name = #{regionName}</if>
        <if test="defFlag != null  and defFlag != ''"> and t.def_flag = #{defFlag}</if>
        <if test="fiscalYear != null "> and t.fiscal_year = #{fiscalYear}</if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}

    </select>

    <select id="getDistinctCompanyList" resultType="com.chinagas.modules.schsf.domain.McBasicCmty"
            parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo">
        SELECT DISTINCT
        t.company_code as 'companyCode',
        t.company_name as 'companyName',
        t.urb_rur_cls as 'urbRurCls'
        FROM mc_basic_cmty t
                 left join sys_user u on u.user_id = t.create_by
                 left join sys_dept d on d.dept_id = t.company_code
        WHERE 1 = 1
        <if test="groupName != null  and groupName != ''">
            and t.group_name = #{groupName}
        </if>
        <if test="regionName != null  and regionName != ''">
            and t.region_name = #{regionName}
        </if>
        <if test="defFlag != null  and defFlag != ''">
            and t.def_flag = #{defFlag}
        </if>
        <if test="fiscalYear != null">
            and t.fiscal_year = #{fiscalYear}
        </if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectVlgOrCmtyList" resultMap="McBasicCmtyResult" parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo">
        SELECT DISTINCT t.vlg_or_cmty
        FROM mc_basic_cmty t
                 left join sys_user u on u.user_id = t.create_by
                 left join sys_dept d on d.dept_id = t.company_code
        WHERE 1 = 1
        <if test="groupName != null  and groupName != ''">
            and t.group_name = #{groupName}
        </if>
        <if test="regionName != null  and regionName != ''">
            and t.region_name = #{regionName}
        </if>
        <if test="defFlag != null  and defFlag != ''">
            and t.def_flag = #{defFlag}
        </if>
        <if test="fiscalYear != null">
            and t.fiscal_year = #{fiscalYear}
        </if>
        <if test="companyName != null  and companyName != ''">
            and t.company_name = #{companyName}
        </if>
        <if test="companyCode != null  and companyCode != ''">
            and t.company_code = #{companyCode}
        </if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectMcBasicCmtyByData" resultMap="McBasicCmtyResult" parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo">
        <include refid="selectMcBasicCmtyVo"/>
        where 1=1
        and fiscal_year = #{fiscalYear}
        and region_name = #{regionName}
        and group_name =  #{groupName}
        and company_name = #{companyName}
        and company_code = #{companyCode}
        and province = #{province}
        and city = #{city}
        and district = #{district}
        and street = #{street}
        and vlg_or_cmty = #{vlgOrCmty}
    </select>
</mapper>