PoolResidentMapper.xml 16.2 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.PoolResidentMapper">
    
    <resultMap type="com.chinagas.modules.insight.domian.PoolResident" id="PoolResidentResult">
        <result property="id"    column="id"    />
        <result property="area"    column="area"    />
        <result property="entity"    column="entity"    />
        <result property="budgetSubject"    column="budget_subject"    />
        <result property="idNumber"    column="id_number"    />
        <result property="city"    column="city"    />
        <result property="street"    column="street"    />
        <result property="communityName"    column="community_name"    />
        <result property="floor"    column="floor"    />
        <result property="houseNumber"    column="house_number"    />
        <result property="householdName"    column="household_name"    />
        <result property="householdAge"    column="household_age"    />
        <result property="phoneNumber"    column="phone_number"    />
        <result property="resideNumber"    column="reside_number"    />
        <result property="houseType"    column="house_type"    />
        <result property="houseArea"    column="house_area"    />
        <result property="houseYear"    column="house_year"    />
        <result property="houseNature"    column="house_nature"    />
        <result property="resideAttribute"    column="reside_attribute"    />
        <result property="houseAttribute"    column="house_attribute"    />
        <result property="houseStructure"    column="house_structure"    />
        <result property="distance"    column="distance"    />
        <result property="isExist"    column="is_exist"    />
        <result property="isPlan"    column="is_plan"    />
        <result property="isSingleMeter"    column="is_single_meter"    />
        <result property="isSingleKitchen"    column="is_single_kitchen"    />
        <result property="isHeating"    column="is_heating"    />
        <result property="isInstall"    column="is_install"    />
        <result property="currentEnergy"    column="current_energy"    />
        <result property="currentPrice"    column="current_price"    />
        <result property="inclinate"    column="inclinate"    />
        <result property="reason"    column="reason"    />
        <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>

    <sql id="selectPoolResidentVo">
        select id, area,entity, budget_subject, id_number, city, street, community_name, floor, house_number, household_name, household_age, phone_number, reside_number, house_type, house_area, house_year, house_nature, reside_attribute, house_attribute, house_structure, distance, is_exist, is_plan, is_single_meter, is_single_kitchen, is_heating, is_install, current_energy, current_price, inclinate, reason, sys_ctime, sys_utime, create_by, update_by, delete_flag from pool_resident
    </sql>

    <select id="selectPoolResidentList" parameterType="com.chinagas.modules.insight.domian.PoolResident" resultMap="PoolResidentResult">
        <include refid="selectPoolResidentVo"/>
        <where>  
            <if test="area != null  and area != ''"> and area REGEXP #{area}</if>
            <if test="entity != null  and entity != ''"> and entity REGEXP #{entity}</if>
            <if test="budgetSubject != null  and budgetSubject != ''"> and budget_subject REGEXP #{budgetSubject}</if>
            <if test="idNumber != null  and idNumber != ''"> and id_number like concat('%', #{idNumber}, '%')</if>
            <if test="city != null  and city != ''"> and city = #{city}</if>
            <if test="street != null  and street != ''"> and street = #{street}</if>
            <if test="communityName != null  and communityName != ''"> and community_name like concat('%', #{communityName}, '%')</if>
            <if test="floor != null  and floor != ''"> and floor = #{floor}</if>
            <if test="houseNumber != null  and houseNumber != ''"> and house_number = #{houseNumber}</if>
            <if test="householdName != null  and householdName != ''"> and household_name like concat('%', #{householdName}, '%')</if>
            <if test="householdAge != null "> and household_age = #{householdAge}</if>
            <if test="phoneNumber != null  and phoneNumber != ''"> and phone_number = #{phoneNumber}</if>
            <if test="resideNumber != null "> and reside_number = #{resideNumber}</if>
            <if test="houseType != null  and houseType != ''"> and house_type = #{houseType}</if>
            <if test="houseArea != null  and houseArea != ''"> and house_area = #{houseArea}</if>
            <if test="houseYear != null "> and house_year = #{houseYear}</if>
            <if test="houseNature != null "> and house_nature = #{houseNature}</if>
            <if test="resideAttribute != null "> and reside_attribute = #{resideAttribute}</if>
            <if test="houseAttribute != null "> and house_attribute = #{houseAttribute}</if>
            <if test="houseStructure != null "> and house_structure = #{houseStructure}</if>
            <if test="distance != null "> and distance = #{distance}</if>
            <if test="isExist != null "> and is_exist = #{isExist}</if>
            <if test="isPlan != null "> and is_plan = #{isPlan}</if>
            <if test="isSingleMeter != null "> and is_single_meter = #{isSingleMeter}</if>
            <if test="isSingleKitchen != null "> and is_single_kitchen = #{isSingleKitchen}</if>
            <if test="isHeating != null "> and is_heating = #{isHeating}</if>
            <if test="isInstall != null "> and is_install = #{isInstall}</if>
            <if test="currentEnergy != null "> and current_energy = #{currentEnergy}</if>
            <if test="currentPrice != null  and currentPrice != ''"> and current_price = #{currentPrice}</if>
            <if test="inclinate != null "> and inclinate = #{inclinate}</if>
            <if test="reason != null  and reason != ''"> and reason = #{reason}</if>
            <if test="sysCtime != null "> and sys_ctime = #{sysCtime}</if>
            <if test="sysUtime != null "> and sys_utime = #{sysUtime}</if>
            and delete_flag = 0
        </where>
    </select>
    
    <select id="selectPoolResidentById" parameterType="Long" resultMap="PoolResidentResult">
        <include refid="selectPoolResidentVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertPoolResident" parameterType="com.chinagas.modules.insight.domian.PoolResident">
        insert into pool_resident
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="area != null and area != ''">area,</if>
            <if test="entity != null and entity != ''">entity,</if>
            <if test="budgetSubject != null and budgetSubject != ''">budget_subject,</if>
            <if test="idNumber != null and idNumber != ''">id_number,</if>
            <if test="city != null and city != ''">city,</if>
            <if test="street != null and street != ''">street,</if>
            <if test="communityName != null and communityName != ''">community_name,</if>
            <if test="floor != null and floor != ''">floor,</if>
            <if test="houseNumber != null and houseNumber != ''">house_number,</if>
            <if test="householdName != null and householdName != ''">household_name,</if>
            <if test="householdAge != null">household_age,</if>
            <if test="phoneNumber != null and phoneNumber != ''">phone_number,</if>
            <if test="resideNumber != null">reside_number,</if>
            <if test="houseType != null and houseType != ''">house_type,</if>
            <if test="houseArea != null and houseArea != ''">house_area,</if>
            <if test="houseYear != null">house_year,</if>
            <if test="houseNature != null">house_nature,</if>
            <if test="resideAttribute != null">reside_attribute,</if>
            <if test="houseAttribute != null">house_attribute,</if>
            <if test="houseStructure != null">house_structure,</if>
            <if test="distance != null">distance,</if>
            <if test="isExist != null">is_exist,</if>
            <if test="isPlan != null">is_plan,</if>
            <if test="isSingleMeter != null">is_single_meter,</if>
            <if test="isSingleKitchen != null">is_single_kitchen,</if>
            <if test="isHeating != null">is_heating,</if>
            <if test="isInstall != null">is_install,</if>
            <if test="currentEnergy != null">current_energy,</if>
            <if test="currentPrice != null and currentPrice != ''">current_price,</if>
            <if test="inclinate != null">inclinate,</if>
            <if test="reason != null and reason != ''">reason,</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="entity != null and entity != ''">#{entity},</if>
            <if test="budgetSubject != null and budgetSubject != ''">#{budgetSubject},</if>
            <if test="idNumber != null and idNumber != ''">#{idNumber},</if>
            <if test="city != null and city != ''">#{city},</if>
            <if test="street != null and street != ''">#{street},</if>
            <if test="communityName != null and communityName != ''">#{communityName},</if>
            <if test="floor != null and floor != ''">#{floor},</if>
            <if test="houseNumber != null and houseNumber != ''">#{houseNumber},</if>
            <if test="householdName != null and householdName != ''">#{householdName},</if>
            <if test="householdAge != null">#{householdAge},</if>
            <if test="phoneNumber != null and phoneNumber != ''">#{phoneNumber},</if>
            <if test="resideNumber != null">#{resideNumber},</if>
            <if test="houseType != null and houseType != ''">#{houseType},</if>
            <if test="houseArea != null and houseArea != ''">#{houseArea},</if>
            <if test="houseYear != null">#{houseYear},</if>
            <if test="houseNature != null">#{houseNature},</if>
            <if test="resideAttribute != null">#{resideAttribute},</if>
            <if test="houseAttribute != null">#{houseAttribute},</if>
            <if test="houseStructure != null">#{houseStructure},</if>
            <if test="distance != null">#{distance},</if>
            <if test="isExist != null">#{isExist},</if>
            <if test="isPlan != null">#{isPlan},</if>
            <if test="isSingleMeter != null">#{isSingleMeter},</if>
            <if test="isSingleKitchen != null">#{isSingleKitchen},</if>
            <if test="isHeating != null">#{isHeating},</if>
            <if test="isInstall != null">#{isInstall},</if>
            <if test="currentEnergy != null">#{currentEnergy},</if>
            <if test="currentPrice != null and currentPrice != ''">#{currentPrice},</if>
            <if test="inclinate != null">#{inclinate},</if>
            <if test="reason != null and reason != ''">#{reason},</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="updatePoolResident" parameterType="com.chinagas.modules.insight.domian.PoolResident">
        update pool_resident
        <trim prefix="SET" suffixOverrides=",">
            <if test="area != null and area != ''">area = #{area},</if>
            <if test="entity != null and entity != ''">entity = #{entity},</if>
            <if test="budgetSubject != null and budgetSubject != ''">budget_subject = #{budgetSubject},</if>
            <if test="idNumber != null and idNumber != ''">id_number = #{idNumber},</if>
            <if test="city != null and city != ''">city = #{city},</if>
            <if test="street != null and street != ''">street = #{street},</if>
            <if test="communityName != null and communityName != ''">community_name = #{communityName},</if>
            <if test="floor != null and floor != ''">floor = #{floor},</if>
            <if test="houseNumber != null and houseNumber != ''">house_number = #{houseNumber},</if>
            <if test="householdName != null and householdName != ''">household_name = #{householdName},</if>
            <if test="householdAge != null">household_age = #{householdAge},</if>
            <if test="phoneNumber != null and phoneNumber != ''">phone_number = #{phoneNumber},</if>
            <if test="resideNumber != null">reside_number = #{resideNumber},</if>
            <if test="houseType != null and houseType != ''">house_type = #{houseType},</if>
            <if test="houseArea != null and houseArea != ''">house_area = #{houseArea},</if>
            <if test="houseYear != null">house_year = #{houseYear},</if>
            <if test="houseNature != null">house_nature = #{houseNature},</if>
            <if test="resideAttribute != null">reside_attribute = #{resideAttribute},</if>
            <if test="houseAttribute != null">house_attribute = #{houseAttribute},</if>
            <if test="houseStructure != null">house_structure = #{houseStructure},</if>
            <if test="distance != null">distance = #{distance},</if>
            <if test="isExist != null">is_exist = #{isExist},</if>
            <if test="isPlan != null">is_plan = #{isPlan},</if>
            <if test="isSingleMeter != null">is_single_meter = #{isSingleMeter},</if>
            <if test="isSingleKitchen != null">is_single_kitchen = #{isSingleKitchen},</if>
            <if test="isHeating != null">is_heating = #{isHeating},</if>
            <if test="isInstall != null">is_install = #{isInstall},</if>
            <if test="currentEnergy != null">current_energy = #{currentEnergy},</if>
            <if test="currentPrice != null and currentPrice != ''">current_price = #{currentPrice},</if>
            <if test="inclinate != null">inclinate = #{inclinate},</if>
            <if test="reason != null and reason != ''">reason = #{reason},</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="deletePoolResidentById" parameterType="Long">
        delete from pool_resident where id = #{id}
    </delete>

    <delete id="deletePoolResidentByIds" parameterType="String">
        update pool_resident set delete_flag = 1
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <select id="selectPoolResidentByIds" parameterType="Long" resultMap="PoolResidentResult">
        <include refid="selectPoolResidentVo"/>
        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
        where delete_flag = 0
    </select>

    <select id="selectCount1" resultType="java.lang.Integer">
        select count(*)
        from pool_resident
        <where>
            delete_flag = 0
            <if test="entity != null  and entity != ''"> and entity REGEXP #{entity}</if>

        </where>

    </select>

</mapper>