PoolResidentLedgerMapper.xml 22 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.insight.mapper.PoolResidentLedgerMapper">

    <resultMap type="com.chinagas.modules.insight.domian.PoolResidentLedger" id="PoolResidentLedgerResult">
        <result property="id" column="id"/>
        <result property="area" column="area"/>
        <result property="areaName" column="area_name"/>
        <result property="entity" column="entity"/>
        <result property="entityName" column="entity_name"/>
        <result property="accounting" column="accounting"/>
        <result property="accountingName" column="accounting_name"/>
        <result property="address" column="address"/>
        <result property="administrativeVillage" column="administrative_village"/>
        <result property="natureVillage" column="nature_village"/>
        <result property="totalHousehold" column="total_household"/>
        <result property="houseType" column="house_type"/>
        <result property="coveredHousehold" column="covered_household"/>
        <result property="signHousehold" column="sign_household"/>
        <result property="marketType" column="market_type"/>
        <result property="businessType" column="business_type"/>
        <result property="signType" column="sign_type"/>
        <result property="businessArea" column="business_area"/>
        <result property="fullAmount" column="full_amount"/>
        <result property="byStages" column="by_stages"/>
        <result property="unpaid" column="unpaid"/>
        <result property="actual" column="actual"/>
        <result property="installCondition" column="install_condition"/>
        <result property="noInstallCondition" column="no_install_condition"/>
        <result property="financeConfirm" column="finance_confirm"/>
        <result property="ventilation" column="ventilation"/>
        <result property="actualFire" column="actual_fire"/>
        <result property="intoRemodel" column="into_remodel"/>
        <result property="currentConfirm" column="current_confirm"/>
        <result property="afterConfirm" column="after_confirm"/>
        <result property="lastConfirm" column="last_confirm"/>
        <result property="distance" column="distance"/>
        <result property="status" column="status"/>
        <result property="statusName" column="status_name"/>
        <result property="sysCtime" column="sys_ctime"/>
        <result property="sysUtime" column="sys_utime"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
        <result property="deleteFlag" column="delete_flag"/>
        <result property="developStatus" column="develop_status"/>
    </resultMap>

    <resultMap type="com.chinagas.modules.insight.vo.PoolCountVO" id="PoolResidentLedgerResult1">
        <result property="days" column="days"/>
        <result property="count" column="count"/>
    </resultMap>

    <sql id="selectPoolResidentLedgerVo">
        select id,
               area,
               area_name,
               entity,
               entity_name,
               accounting,
               accounting_name,
               address,
               administrative_village,
               nature_village,
               total_household,
               house_type,
               covered_household,
               sign_household,
               market_type,
               business_type,
               sign_type,
               business_area,
               full_amount,
               by_stages,
               unpaid,
               actual,
               install_condition,
               no_install_condition,
               finance_confirm,
               ventilation,
               actual_fire,
               into_remodel,
               current_confirm,
               after_confirm,
               last_confirm,
               distance,
               status,
               status_name,
               sys_ctime,
               sys_utime,
               create_by,
               update_by,
               delete_flag,
               develop_status
        from pool_resident_ledger
    </sql>

    <select id="selectPoolResidentLedgerList" parameterType="com.chinagas.modules.insight.domian.PoolResidentLedger"
            resultMap="PoolResidentLedgerResult">
        <include refid="selectPoolResidentLedgerVo"/>
        <where>
            <if test="id != null ">and id = #{id}</if>
            <if test="area != null  and area != ''">and area REGEXP #{area}</if>
            <if test="areaName != null  and areaName != ''">and area_name like concat('%', #{areaName}, '%')</if>
            <if test="entity != null  and entity != ''">and entity REGEXP #{entity}</if>
            <if test="entityName != null  and entityName != ''">and entity_name like concat('%', #{entityName}, '%')
            </if>
            <if test="accounting != null  and accounting != ''">and accounting REGEXP #{accounting}</if>
            <if test="accountingName != null  and accountingName != ''">and accounting_name like concat('%',
                #{accountingName}, '%')
            </if>
            <if test="address != null  and address != ''">and address like concat ('%', #{address}, '%')</if>
            <if test="administrativeVillage != null  and administrativeVillage != ''">and administrative_village like
                concat('%', #{administrativeVillage}, '%')
            </if>
            <if test="natureVillage != null  and natureVillage != ''">and nature_village like concat('%',
                #{natureVillage}, '%')
            </if>
            <if test="totalHousehold != null ">and total_household = #{totalHousehold}</if>
            <if test="houseType != null ">and house_type = #{houseType}</if>
            <if test="coveredHousehold != null ">and covered_household = #{coveredHousehold}</if>
            <if test="signHousehold != null ">and sign_household = #{signHousehold}</if>
            <if test="marketType != null ">and market_type = #{marketType}</if>
            <if test="businessType != null ">and business_type = #{businessType}</if>
            <if test="signType != null ">and sign_type = #{signType}</if>
            <if test="businessArea != null ">and business_area = #{businessArea}</if>
            <if test="fullAmount != null ">and full_amount = #{fullAmount}</if>
            <if test="byStages != null ">and by_stages = #{byStages}</if>
            <if test="unpaid != null ">and unpaid = #{unpaid}</if>
            <if test="actual != null ">and actual = #{actual}</if>
            <if test="installCondition != null ">and install_condition = #{installCondition}</if>
            <if test="noInstallCondition != null ">and no_install_condition = #{noInstallCondition}</if>
            <if test="financeConfirm != null ">and finance_confirm = #{financeConfirm}</if>
            <if test="ventilation != null ">and ventilation = #{ventilation}</if>
            <if test="actualFire != null ">and actual_fire = #{actualFire}</if>
            <if test="intoRemodel != null ">and into_remodel = #{intoRemodel}</if>
            <if test="currentConfirm != null ">and current_confirm = #{currentConfirm}</if>
            <if test="afterConfirm != null ">and after_confirm = #{afterConfirm}</if>
            <if test="lastConfirm != null ">and last_confirm = #{lastConfirm}</if>
            <if test="distance != null ">and distance = #{distance}</if>
            <if test="status != null ">and status = #{status}</if>
            <if test="statusName != null  and statusName != ''">and status_name REGEXP #{statusName}</if>
            <if test="sysCtime != null ">and sys_ctime = #{sysCtime}</if>
            <if test="sysUtime != null ">and sys_utime = #{sysUtime}</if>
            <if test="developStatus != null ">and develop_status = #{developStatus}</if>
            and delete_flag = 0 order by sys_ctime DESC
        </where>
    </select>

    <select id="selectPoolResidentLedgerById" parameterType="Long" resultMap="PoolResidentLedgerResult">
        <include refid="selectPoolResidentLedgerVo"/>
        where id = #{id}
    </select>

    <insert id="insertPoolResidentLedger" parameterType="com.chinagas.modules.insight.domian.PoolResidentLedger">
        insert into pool_resident_ledger
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="area != null and area != ''">area,</if>
            <if test="areaName != null and areaName != ''">area_name,</if>
            <if test="entity != null and entity != ''">entity,</if>
            <if test="entityName != null and entityName != ''">entity_name,</if>
            <if test="accounting != null and accounting != ''">accounting,</if>
            <if test="accountingName != null and accountingName != ''">accounting_name,</if>
            <if test="address != null and address != ''">address,</if>
            <if test="administrativeVillage != null and administrativeVillage != ''">administrative_village,</if>
            <if test="natureVillage != null and natureVillage != ''">nature_village,</if>
            <if test="totalHousehold != null">total_household,</if>
            <if test="houseType != null">house_type,</if>
            <if test="coveredHousehold != null">covered_household,</if>
            <if test="signHousehold != null">sign_household,</if>
            <if test="marketType != null">market_type,</if>
            <if test="businessType != null">business_type,</if>
            <if test="signType != null">sign_type,</if>
            <if test="businessArea != null">business_area,</if>
            <if test="fullAmount != null">full_amount,</if>
            <if test="byStages != null">by_stages,</if>
            <if test="unpaid != null">unpaid,</if>
            <if test="actual != null">actual,</if>
            <if test="installCondition != null">install_condition,</if>
            <if test="noInstallCondition != null">no_install_condition,</if>
            <if test="financeConfirm != null">finance_confirm,</if>
            <if test="ventilation != null">ventilation,</if>
            <if test="actualFire != null">actual_fire,</if>
            <if test="intoRemodel != null">into_remodel,</if>
            <if test="currentConfirm != null">current_confirm,</if>
            <if test="afterConfirm != null">after_confirm,</if>
            <if test="lastConfirm != null">last_confirm,</if>
            <if test="distance != null">distance,</if>
            <if test="status != null">status,</if>
            <if test="statusName != null and statusName != ''">status_name,</if>
            <if test="sysCtime != null">sys_ctime,</if>
            <if test="sysUtime != null">sys_utime,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="deleteFlag != null">delete_flag,</if>
            <if test="developStatus != null">develop_status,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="area != null and area != ''">#{area},</if>
            <if test="areaName != null and areaName != ''">#{areaName},</if>
            <if test="entity != null and entity != ''">#{entity},</if>
            <if test="entityName != null and entityName != ''">#{entityName},</if>
            <if test="accounting != null and accounting != ''">#{accounting},</if>
            <if test="accountingName != null and accountingName != ''">#{accountingName},</if>
            <if test="address != null and address != ''">#{address},</if>
            <if test="administrativeVillage != null and administrativeVillage != ''">#{administrativeVillage},</if>
            <if test="natureVillage != null and natureVillage != ''">#{natureVillage},</if>
            <if test="totalHousehold != null">#{totalHousehold},</if>
            <if test="houseType != null">#{houseType},</if>
            <if test="coveredHousehold != null">#{coveredHousehold},</if>
            <if test="signHousehold != null">#{signHousehold},</if>
            <if test="marketType != null">#{marketType},</if>
            <if test="businessType != null">#{businessType},</if>
            <if test="signType != null">#{signType},</if>
            <if test="businessArea != null">#{businessArea},</if>
            <if test="fullAmount != null">#{fullAmount},</if>
            <if test="byStages != null">#{byStages},</if>
            <if test="unpaid != null">#{unpaid},</if>
            <if test="actual != null">#{actual},</if>
            <if test="installCondition != null">#{installCondition},</if>
            <if test="noInstallCondition != null">#{noInstallCondition},</if>
            <if test="financeConfirm != null">#{financeConfirm},</if>
            <if test="ventilation != null">#{ventilation},</if>
            <if test="actualFire != null">#{actualFire},</if>
            <if test="intoRemodel != null">#{intoRemodel},</if>
            <if test="currentConfirm != null">#{currentConfirm},</if>
            <if test="afterConfirm != null">#{afterConfirm},</if>
            <if test="lastConfirm != null">#{lastConfirm},</if>
            <if test="distance != null">#{distance},</if>
            <if test="status != null">#{status},</if>
            <if test="statusName != null and statusName != ''">#{statusName},</if>
            <if test="sysCtime != null">#{sysCtime},</if>
            <if test="sysUtime != null">#{sysUtime},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="deleteFlag != null">#{deleteFlag},</if>
            <if test="developStatus != null">#{developStatus},</if>
        </trim>
    </insert>

    <update id="updatePoolResidentLedger" parameterType="com.chinagas.modules.insight.domian.PoolResidentLedger">
        update pool_resident_ledger
        <trim prefix="SET" suffixOverrides=",">
            <if test="area != null and area != ''">area = #{area},</if>
            <if test="areaName != null and areaName != ''">area_name = #{areaName},</if>
            <if test="entity != null and entity != ''">entity = #{entity},</if>
            <if test="entityName != null and entityName != ''">entity_name = #{entityName},</if>
            <if test="accounting != null and accounting != ''">accounting = #{accounting},</if>
            <if test="accountingName != null and accountingName != ''">accounting_name = #{accountingName},</if>
            <if test="address != null and address != ''">address = #{address},</if>
            <if test="administrativeVillage != null and administrativeVillage != ''">administrative_village =
                #{administrativeVillage},
            </if>
            <if test="natureVillage != null and natureVillage != ''">nature_village = #{natureVillage},</if>
            <if test="totalHousehold != null">total_household = #{totalHousehold},</if>
            <if test="houseType != null">house_type = #{houseType},</if>
            <if test="coveredHousehold != null">covered_household = #{coveredHousehold},</if>
            <if test="signHousehold != null">sign_household = #{signHousehold},</if>
            <if test="marketType != null">market_type = #{marketType},</if>
            <if test="businessType != null">business_type = #{businessType},</if>
            <if test="signType != null">sign_type = #{signType},</if>
            <if test="businessArea != null">business_area = #{businessArea},</if>
            <if test="fullAmount != null">full_amount = #{fullAmount},</if>
            <if test="byStages != null">by_stages = #{byStages},</if>
            <if test="unpaid != null">unpaid = #{unpaid},</if>
            <if test="actual != null">actual = #{actual},</if>
            <if test="installCondition != null">install_condition = #{installCondition},</if>
            <if test="noInstallCondition != null">no_install_condition = #{noInstallCondition},</if>
            <if test="financeConfirm != null">finance_confirm = #{financeConfirm},</if>
            <if test="ventilation != null">ventilation = #{ventilation},</if>
            <if test="actualFire != null">actual_fire = #{actualFire},</if>
            <if test="intoRemodel != null">into_remodel = #{intoRemodel},</if>
            <if test="currentConfirm != null">current_confirm = #{currentConfirm},</if>
            <if test="afterConfirm != null">after_confirm = #{afterConfirm},</if>
            <if test="lastConfirm != null">last_confirm = #{lastConfirm},</if>
            <if test="distance != null">distance = #{distance},</if>
            <if test="status != null">status = #{status},</if>
            <if test="statusName != null and statusName != ''">status_name = #{statusName},</if>
            <if test="sysCtime != null">sys_ctime = #{sysCtime},</if>
            <if test="sysUtime != null">sys_utime = #{sysUtime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
            <if test="developStatus != null">develop_status = #{developStatus},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePoolResidentLedgerById" parameterType="Long">
        delete
        from pool_resident_ledger
        where id = #{id}
    </delete>

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

    <select id="selectPoolResidentLedgerByIds" parameterType="Long" resultMap="PoolResidentLedgerResult">
        <include refid="selectPoolResidentLedgerVo"/>
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
    <select id="selectCount" resultType="java.lang.Integer">
        select count(*)
        from pool_resident_ledger
        <where>
            <if test="entity != null  and entity != ''">and entity in
                <foreach item="entity" collection="entity" open="(" separator="," close=")">
                    #{entity}
                </foreach>
            </if>
            <if test="area != null  and area != ''">and area = #{area}</if>
            <if test="developStatus != null ">and develop_status = #{developStatus}</if>
        </where>
    </select>
    <select id="selectCount1" resultType="java.lang.Integer">
        select sum(case develop_status when '1' then (total_household-finance_confirm) else 0 end)+sum(case develop_status when '0' then install_condition else 0 end)
        from pool_resident_ledger
        <where>
            <if test="area != null  and area != ''">and area = #{area}</if>
        </where>
    </select>
    <select id="selectCountForArea" resultType="java.lang.Integer">
        select count(*)
        from pool_resident_ledger
        <where>
            <if test="entity != null  and entity != ''">and entity = #{entity}</if>
        </where>
    </select>
    <select id="selectCountDays" resultMap="PoolResidentLedgerResult1">
        select CURDATE() - INTERVAL 6 day AS days,if(bbb.count = 0,0,bbb.count) AS count
        from (select count(1) as count from pool_resident_ledger  where date(sys_ctime)=CURDATE() - INTERVAL 6 DAY AND entity = 1136) as bbb
        UNION
        select CURDATE() - INTERVAL 5 day AS days,if(bbb.count = 0,0,bbb.count) AS count
        from (select count(1) as count from pool_resident_ledger  where date(sys_ctime)=CURDATE() - INTERVAL 5 DAY AND entity = 1136) as bbb
        UNION
        select CURDATE() - INTERVAL 4 day AS days,if(bbb.count = 0,0,bbb.count) AS count
        from (select count(1) as count from pool_resident_ledger  where date(sys_ctime)=CURDATE() - INTERVAL 4 DAY AND entity = 1136) as bbb
        UNION
        select CURDATE() - INTERVAL 3 day AS days,if(bbb.count = 0,0,bbb.count) AS count
        from (select count(1) as count from pool_resident_ledger  where date(sys_ctime)=CURDATE() - INTERVAL 3 DAY AND entity = 1136) as bbb
        UNION
        select CURDATE() - INTERVAL 2 day AS days,if(bbb.count = 0,0,bbb.count) AS count
        from (select count(1) as count from pool_resident_ledger  where date(sys_ctime)=CURDATE() - INTERVAL 2 DAY AND entity = 1136) as bbb
        UNION
        select CURDATE() - INTERVAL 1 day AS days,if(bbb.count = 0,0,bbb.count) AS count
        from (select count(1) as count from pool_resident_ledger  where date(sys_ctime)=CURDATE() - INTERVAL 1 DAY AND entity = 1136) as bbb
        UNION
        select CURDATE() - INTERVAL 0 day AS days,if(bbb.count = 0,0,bbb.count) AS count
        from (select count(1) as count from pool_resident_ledger  where date(sys_ctime)=CURDATE() - INTERVAL 0 DAY AND entity = 1136) as bbb
    </select>
    <select id="selectCountUndeveloped" resultType="java.lang.Integer">
        select SUM(install_condition)
        from pool_resident_ledger
        <where>
            <if test="entity != null  and entity != ''">and entity in
                <foreach item="entity" collection="entity" open="(" separator="," close=")">
                    #{entity}
                </foreach>
            </if>
            <if test="area != null  and area != ''">and area = #{area}</if>
            <if test="developStatus != null ">and develop_status = #{developStatus}</if>
        </where>
    </select>
    <select id="selectCountDeveloped" resultType="java.lang.Integer">
        select SUM(total_household) - SUM(finance_confirm)
        from pool_resident_ledger
        <where>
            <if test="entity != null  and entity != ''">and entity in
                <foreach item="entity" collection="entity" open="(" separator="," close=")">
                    #{entity}
                </foreach>
            </if>
            <if test="area != null  and area != ''">and area = #{area}</if>
            <if test="developStatus != null ">and develop_status = #{developStatus}</if>
        </where>
    </select>
</mapper>