CustomerRecoveryProgressMapper.xml 14 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.CustomerRecoveryProgressMapper">
    
    <resultMap type="com.chinagas.modules.insight.domian.CustomerRecoveryProgress" id="CustomerRecoveryProgressResult">
        <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="custNo"    column="cust_no"    />
        <result property="custName"    column="cust_name"    />
        <result property="industry"    column="industry"    />
        <result property="status"    column="status"    />
        <result property="yearConsumption"    column="year_consumption"    />
        <result property="lossTime"    column="loss_time"    />
        <result property="lossReason"    column="loss_reason"    />
        <result property="recoverTime"    column="recover_time"    />
        <result property="workPlan"    column="work_plan"    />
        <result property="completion"    column="completion"    />
        <result property="remark"    column="remark"    />
        <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"    />
    </resultMap>

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

    <sql id="selectCustomerRecoveryProgressVo">
        select id, area, area_name, entity, entity_name, accounting, accounting_name, cust_no, cust_name, industry, status, year_consumption, loss_time, loss_reason, recover_time, work_plan, completion, remark, sys_ctime, sys_utime, create_by, update_by, delete_flag from customer_recovery_progress
    </sql>

    <select id="selectCustomerRecoveryProgressList" parameterType="com.chinagas.modules.insight.domian.CustomerRecoveryProgress" resultMap="CustomerRecoveryProgressResult">
        <include refid="selectCustomerRecoveryProgressVo"/>
        <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="custNo != null  and custNo != ''"> and cust_no like concat('%', #{custNo}, '%')</if>
            <if test="custName != null  and custName != ''"> and cust_name like concat('%', #{custName}, '%')</if>
            <if test="industry != null  and industry != ''"> and industry = #{industry}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="yearConsumption != null "> and year_consumption = #{yearConsumption}</if>
            <if test="lossTime != null "> and loss_time = #{lossTime}</if>
            <if test="lossReason != null  and lossReason != ''"> and loss_reason = #{lossReason}</if>
            <if test="recoverTime != null "> and recover_time = #{recoverTime}</if>
            <if test="workPlan != null  and workPlan != ''"> and work_plan = #{workPlan}</if>
            <if test="completion != null  and completion != ''"> and completion = #{completion}</if>
            <if test="sysCtime != null "> and sys_ctime = #{sysCtime}</if>
            <if test="sysUtime != null "> and sys_utime = #{sysUtime}</if>
            and delete_flag = 0 order by sys_ctime DESC
        </where>
    </select>
    
    <select id="selectCustomerRecoveryProgressById" parameterType="Long" resultMap="CustomerRecoveryProgressResult">
        <include refid="selectCustomerRecoveryProgressVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCustomerRecoveryProgress" parameterType="com.chinagas.modules.insight.domian.CustomerRecoveryProgress">
        insert into customer_recovery_progress
        <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="custNo != null and custNo != ''">cust_no,</if>
            <if test="custName != null and custName != ''">cust_name,</if>
            <if test="industry != null and industry != ''">industry,</if>
            <if test="status != null">status,</if>
            <if test="yearConsumption != null">year_consumption,</if>
            <if test="lossTime != null">loss_time,</if>
            <if test="lossReason != null and lossReason != ''">loss_reason,</if>
            <if test="recoverTime != null">recover_time,</if>
            <if test="workPlan != null and workPlan != ''">work_plan,</if>
            <if test="completion != null and completion != ''">completion,</if>
            <if test="remark != null and remark != ''">remark,</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>
         </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="custNo != null and custNo != ''">#{custNo},</if>
            <if test="custName != null and custName != ''">#{custName},</if>
            <if test="industry != null and industry != ''">#{industry},</if>
            <if test="status != null">#{status},</if>
            <if test="yearConsumption != null">#{yearConsumption},</if>
            <if test="lossTime != null">#{lossTime},</if>
            <if test="lossReason != null and lossReason != ''">#{lossReason},</if>
            <if test="recoverTime != null">#{recoverTime},</if>
            <if test="workPlan != null and workPlan != ''">#{workPlan},</if>
            <if test="completion != null and completion != ''">#{completion},</if>
            <if test="remark != null and remark != ''">#{remark},</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>
         </trim>
    </insert>

    <update id="updateCustomerRecoveryProgress" parameterType="com.chinagas.modules.insight.domian.CustomerRecoveryProgress">
        update customer_recovery_progress
        <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="custNo != null and custNo != ''">cust_no = #{custNo},</if>
            <if test="custName != null and custName != ''">cust_name = #{custName},</if>
            <if test="industry != null and industry != ''">industry = #{industry},</if>
            <if test="status != null">status = #{status},</if>
            <if test="yearConsumption != null">year_consumption = #{yearConsumption},</if>
            <if test="lossTime != null">loss_time = #{lossTime},</if>
            <if test="lossReason != null and lossReason != ''">loss_reason = #{lossReason},</if>
            <if test="recoverTime != null">recover_time = #{recoverTime},</if>
            <if test="workPlan != null and workPlan != ''">work_plan = #{workPlan},</if>
            <if test="completion != null and completion != ''">completion = #{completion},</if>
            <if test="remark != null and remark != ''">remark = #{remark},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCustomerRecoveryProgressById" parameterType="Long">
        delete from customer_recovery_progress where id = #{id}
    </delete>

    <delete id="deleteCustomerRecoveryProgressByIds" parameterType="String">
        delete from customer_recovery_progress
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <select id="selectCustomerRecoveryProgressByIds" parameterType="Long" resultMap="CustomerRecoveryProgressResult">
        <include refid="selectCustomerRecoveryProgressVo"/>
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
    <select id="selectExist" resultMap="CustomerRecoveryProgressResult">
        <include refid="selectCustomerRecoveryProgressVo"/>
        where cust_no = #{custNo}
        and delete_flag = 0
        limit 1
    </select>
    <select id="selectCount" resultType="java.lang.Integer">
        select count(*)
        from customer_recovery_progress
        <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>
        </where>
    </select>
    <select id="selectCount1" resultType="java.lang.Integer">
        select count(*)
        from customer_recovery_progress
        <where>
            <if test="area != null  and area != ''"> and area = #{area}</if>
        </where>
    </select>
    <select id="selectCountForArea" resultType="java.lang.Integer">
        select count(*)
        from customer_recovery_progress
        <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 customer_recovery_progress  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 customer_recovery_progress  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 customer_recovery_progress  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 customer_recovery_progress  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 customer_recovery_progress  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 customer_recovery_progress  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 customer_recovery_progress  where date(sys_ctime)=CURDATE() - INTERVAL 0 DAY AND entity = 1136) as bbb
    </select>
</mapper>