CreditBlackListMapper.xml 9.71 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.credit.cy.business.mapper.CreditBlackListMapper">
    
    <resultMap type="CreditBlackList" id="CreditBlackListResult">
        <result property="id"    column="id"    />
        <result property="nameType"    column="name_type"    />
        <result property="enterpriseName"    column="enterprise_name"    />
        <result property="creditCode"    column="credit_code"    />
        <result property="provideUnit"    column="provide_unit"    />
        <result property="provideDate"    column="provide_date"    />
        <result property="reportDate"    column="report_date"    />
        <result property="reportDept"    column="report_dept"    />
        <result property="checkStatus"    column="check_status"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectCreditBlackListVo">
        select id, name_type, enterprise_name, credit_code, provide_unit, provide_date, report_date, report_dept, check_status, del_flag, create_by, create_time, update_time from credit_black_list
    </sql>

    <select id="selectCreditBlackListList" parameterType="CreditBlackList" resultMap="CreditBlackListResult">
        <include refid="selectCreditBlackListVo"/>
        <where>  
            <if test="nameType != null  and nameType != ''"> and name_type = #{nameType}</if>
            <if test="enterpriseName != null  and enterpriseName != ''"> and enterprise_name like concat('%',#{enterpriseName}, '%')</if>
            <if test="creditCode != null  and creditCode != ''"> and credit_code = #{creditCode}</if>
            <if test="provideUnit != null  and provideUnit != ''"> and provide_unit = #{provideUnit}</if>
            <if test="provideDate != null "> and provide_date = #{provideDate}</if>
            <if test="reportDate != null "> and report_date = #{reportDate}</if>
            <if test="reportDept != null  and reportDept != ''"> and report_dept = #{reportDept}</if>
            <if test="checkStatus != null "> and check_status = #{checkStatus}</if>
        </where>
    </select>
    
    <select id="selectCreditBlackListById" parameterType="Long" resultMap="CreditBlackListResult">
        <include refid="selectCreditBlackListVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCreditBlackList" parameterType="CreditBlackList" useGeneratedKeys="true" keyProperty="id">
        insert into credit_black_list
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="nameType != null and nameType != ''">name_type,</if>
            <if test="enterpriseName != null and enterpriseName != ''">enterprise_name,</if>
            <if test="creditCode != null">credit_code,</if>
            <if test="provideUnit != null and provideUnit != ''">provide_unit,</if>
            <if test="provideDate != null">provide_date,</if>
            <if test="reportDate != null">report_date,</if>
            <if test="reportDept != null">report_dept,</if>
            <if test="checkStatus != null">check_status,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="nameType != null and nameType != ''">#{nameType},</if>
            <if test="enterpriseName != null and enterpriseName != ''">#{enterpriseName},</if>
            <if test="creditCode != null">#{creditCode},</if>
            <if test="provideUnit != null and provideUnit != ''">#{provideUnit},</if>
            <if test="provideDate != null">#{provideDate},</if>
            <if test="reportDate != null">#{reportDate},</if>
            <if test="reportDept != null">#{reportDept},</if>
            <if test="checkStatus != null">#{checkStatus},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateCreditBlackList" parameterType="CreditBlackList">
        update credit_black_list
        <trim prefix="SET" suffixOverrides=",">
            <if test="nameType != null and nameType != ''">name_type = #{nameType},</if>
            <if test="enterpriseName != null and enterpriseName != ''">enterprise_name = #{enterpriseName},</if>
            <if test="creditCode != null">credit_code = #{creditCode},</if>
            <if test="provideUnit != null and provideUnit != ''">provide_unit = #{provideUnit},</if>
            <if test="provideDate != null">provide_date = #{provideDate},</if>
            <if test="reportDate != null">report_date = #{reportDate},</if>
            <if test="reportDept != null">report_dept = #{reportDept},</if>
            <if test="checkStatus != null">check_status = #{checkStatus},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCreditBlackListById" parameterType="Long">
        delete from credit_black_list where id = #{id}
    </delete>

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

    <select id="selectDataByIdList" parameterType="Long" resultMap="CreditBlackListResult">
        <include refid="selectCreditBlackListVo"/> where id in
        <foreach item="id" collection="list" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>

    <update id="checkReport" parameterType="Long">
        update credit_black_list set check_status = 2, report_date = now()
        where id in
        <foreach item="id" collection="list" open="(" separator="," close=")">
            #{id}
        </foreach>
        and check_status = 1
    </update>

    <select id="searchRedListInfoList" parameterType="CreditBlackList" resultMap="CreditBlackListResult">
        <include refid="selectCreditBlackListVo"/>
        <where>
            <if test="nameType != null  and nameType != ''"> and name_type = #{nameType}</if>
            <if test="enterpriseName != null  and enterpriseName != ''"> and enterprise_name = #{enterpriseName}</if>
            <if test="creditCode != null  and creditCode != ''"> and credit_code = #{creditCode}</if>
            <if test="provideUnit != null  and provideUnit != ''"> and provide_unit = #{provideUnit}</if>
            <if test="provideDate != null "> and provide_date = #{provideDate}</if>
            <if test="reportDate != null "> and report_date = #{reportDate}</if>
            <if test="reportDept != null  and reportDept != ''"> and report_dept = #{reportDept}</if>
            <if test="checkStatus != null "> and check_status = #{checkStatus}</if>
        </where>
    </select>

    <select id="selectCount" parameterType="com.credit.cy.business.model.query.WorkCountQuery" resultType="java.lang.Long">
        select count(1) from credit_black_list
        <where>
            <if test="reportDept != null  and reportDept != ''"> and report_dept = #{reportDept}</if>
            <if test="null!=reportStartDate"> and report_date >= #{reportStartDate}</if>
            <if test="null!=reportEndDate"> AND report_date <![CDATA[<=]]> #{reportEndDate}</if>
        </where>
    </select>


    <insert id="batchSave" parameterType="java.util.List">
        insert into credit_black_list (id, name_type, enterprise_name, credit_code, provide_unit, provide_date, report_date, report_dept, check_status, create_by)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.id},#{item.nameType},#{item.enterpriseName},#{item.creditCode},#{item.provideUnit},#{item.provideDate},#{item.reportDate},#{item.reportDept},#{item.checkStatus},#{item.createBy})
        </foreach>
    </insert>

    <select id="selectDeptCount" parameterType="com.credit.cy.business.model.query.WorkCountQuery" resultType="java.lang.Long">
        select count(distinct report_dept) from credit_black_list
        <where>
            <if test="reportDept != null  and reportDept != ''"> and report_dept = #{reportDept}</if>
            <if test="null!=reportStartDate"> and report_date >= #{reportStartDate}</if>
            <if test="null!=reportEndDate"> AND report_date <![CDATA[<=]]> #{reportEndDate}</if>
        </where>
    </select>

    <select id="selectGroupCount" parameterType="com.credit.cy.business.model.query.WorkCountQuery" resultType="com.credit.cy.business.model.GroupNumResult">
        select report_dept as dept,count(1) as total from credit_black_list
        <where>
            <if test="reportDept != null  and reportDept != ''"> and report_dept = #{reportDept}</if>
            <if test="null!=reportStartDate"> and report_date >= #{reportStartDate}</if>
            <if test="null!=reportEndDate"> AND report_date <![CDATA[<=]]> #{reportEndDate}</if>
        </where>
        group by report_dept
    </select>
    <select id="selectCountByCode" parameterType="com.credit.cy.business.model.query.WorkCountQuery" resultType="java.lang.Integer">
        select count(1) from credit_black_list where credit_code=#{code}
    </select>

</mapper>