PoolIndustryAndCommerceMapper.xml 13.6 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.PoolIndustryAndCommerceMapper">
    
    <resultMap type="com.chinagas.modules.insight.domian.PoolIndustryAndCommerce" id="PoolIndustryAndCommerceResult">
        <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="clientName"    column="client_name"    />
        <result property="taxpayerNumber"    column="taxpayer_number"    />
        <result property="clientAddress"    column="client_address"    />
        <result property="clientQuality"    column="client_quality"    />
        <result property="industry"    column="industry"    />
        <result property="predictDay"    column="predict_day"    />
        <result property="predictYear"    column="predict_year"    />
        <result property="predictInstall"    column="predict_install"    />
        <result property="status"    column="status"    />
        <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="selectPoolIndustryAndCommerceVo">
        select id, area, area_name, entity, entity_name, accounting, accounting_name, client_name, taxpayer_number, client_address, client_quality, industry, predict_day, predict_year, predict_install, status, sys_ctime, sys_utime, create_by, update_by, delete_flag from pool_industry_and_commerce
    </sql>

    <select id="selectPoolIndustryAndCommerceList" parameterType="com.chinagas.modules.insight.domian.PoolIndustryAndCommerce" resultMap="PoolIndustryAndCommerceResult">
        <include refid="selectPoolIndustryAndCommerceVo"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="area != null  and area != ''"> and area = #{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="clientName != null  and clientName != ''"> and client_name like concat('%', #{clientName}, '%')</if>
            <if test="taxpayerNumber != null  and taxpayerNumber != ''"> and taxpayer_number = #{taxpayerNumber}</if>
            <if test="clientAddress != null  and clientAddress != ''"> and client_address = #{clientAddress}</if>
            <if test="clientQuality != null "> and client_quality = #{clientQuality}</if>
            <if test="industry != null  and industry != ''"> and industry = #{industry}</if>
            <if test="predictDay != null  and predictDay != ''"> and predict_day = #{predictDay}</if>
            <if test="predictYear != null  and predictYear != ''"> and predict_year = #{predictYear}</if>
            <if test="predictInstall != null "> and predict_install = #{predictInstall}</if>
            <if test="status != null "> and status REGEXP #{status}</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="selectPoolIndustryAndCommerceById" parameterType="Long" resultMap="PoolIndustryAndCommerceResult">
        <include refid="selectPoolIndustryAndCommerceVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertPoolIndustryAndCommerce" parameterType="com.chinagas.modules.insight.domian.PoolIndustryAndCommerce">
        insert into pool_industry_and_commerce
        <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="clientName != null and clientName != ''">client_name,</if>
            <if test="taxpayerNumber != null and taxpayerNumber != ''">taxpayer_number,</if>
            <if test="clientAddress != null and clientAddress != ''">client_address,</if>
            <if test="clientQuality != null">client_quality,</if>
            <if test="industry != null and industry != ''">industry,</if>
            <if test="predictDay != null and predictDay != ''">predict_day,</if>
            <if test="predictYear != null and predictYear != ''">predict_year,</if>
            <if test="predictInstall != null">predict_install,</if>
            <if test="status != null">status,</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="clientName != null and clientName != ''">#{clientName},</if>
            <if test="taxpayerNumber != null and taxpayerNumber != ''">#{taxpayerNumber},</if>
            <if test="clientAddress != null and clientAddress != ''">#{clientAddress},</if>
            <if test="clientQuality != null">#{clientQuality},</if>
            <if test="industry != null and industry != ''">#{industry},</if>
            <if test="predictDay != null and predictDay != ''">#{predictDay},</if>
            <if test="predictYear != null and predictYear != ''">#{predictYear},</if>
            <if test="predictInstall != null">#{predictInstall},</if>
            <if test="status != null">#{status},</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="updatePoolIndustryAndCommerce" parameterType="com.chinagas.modules.insight.domian.PoolIndustryAndCommerce">
        update pool_industry_and_commerce
        <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="clientName != null and clientName != ''">client_name = #{clientName},</if>
            <if test="taxpayerNumber != null and taxpayerNumber != ''">taxpayer_number = #{taxpayerNumber},</if>
            <if test="clientAddress != null and clientAddress != ''">client_address = #{clientAddress},</if>
            <if test="clientQuality != null">client_quality = #{clientQuality},</if>
            <if test="industry != null and industry != ''">industry = #{industry},</if>
            <if test="predictDay != null and predictDay != ''">predict_day = #{predictDay},</if>
            <if test="predictYear != null and predictYear != ''">predict_year = #{predictYear},</if>
            <if test="predictInstall != null">predict_install = #{predictInstall},</if>
            <if test="status != null">status = #{status},</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="deletePoolIndustryAndCommerceById" parameterType="Long">
        delete from pool_industry_and_commerce where id = #{id}
    </delete>

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

    <select id="selectPoolIndustryAndCommerceByIds" parameterType="Long" resultMap="PoolIndustryAndCommerceResult">
        <include refid="selectPoolIndustryAndCommerceVo"/>
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>

    <select id="selectExist" resultMap="PoolIndustryAndCommerceResult">
        <include refid="selectPoolIndustryAndCommerceVo"/>
        where taxpayer_number = #{taxpayerNumber}
        and delete_flag = 0
        limit 1
    </select>
    <select id="selectCount" resultType="java.lang.Integer">
        select count(*)
        from pool_industry_and_commerce
        <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 pool_industry_and_commerce
        <where>
            <if test="area != null  and area != ''"> and area = #{area}</if>
        </where>
    </select>
    <select id="selectCountForArea" resultType="java.lang.Integer">
        select count(*)
        from pool_industry_and_commerce
        <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_industry_and_commerce  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_industry_and_commerce  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_industry_and_commerce  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_industry_and_commerce  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_industry_and_commerce  where date(sys_ctime)=CURDATE() - INTERVAL 3 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_industry_and_commerce  where date(sys_ctime)=CURDATE() - INTERVAL 2 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_industry_and_commerce  where date(sys_ctime)=CURDATE() - INTERVAL 0 DAY AND entity = 1136) as bbb
    </select>
</mapper>