CreditAdministrationMapper.xml 16.8 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.CreditAdministrationMapper">
    
    <resultMap type="com.credit.cy.business.domain.CreditAdministration" id="CreditAdministrationResult">
        <result property="id"    column="id"    />
        <result property="catalogId"    column="catalog_id"    />
        <result property="catalogName"    column="catalog_name"    />
        <result property="administrationType"    column="administration_type"    />
        <result property="counterpartName"    column="counterpart_name"    />
        <result property="counterpartType"    column="counterpart_type"    />
        <result property="counterpartCreditCode"    column="counterpart_credit_code"    />
        <result property="delegate"    column="delegate"    />
        <result property="delegateCardType"    column="delegate_card_type"    />
        <result property="delegateCardCode"    column="delegate_card_code"    />
        <result property="counterpartCardCode"    column="counterpart_card_code"    />
        <result property="content"    column="content"    />
        <result property="execTime"    column="exec_time"    />
        <result property="execOrg"    column="exec_org"    />
        <result property="execOrgCode"    column="exec_org_code"    />
        <result property="dataSource"    column="data_source"    />
        <result property="sourceCreditCode"    column="source_credit_code"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="reportDept" column="report_dept"/>
        <result property="reportDate" column="report_date"/>
        <result property="checkStatus" column="check_status"/>
        <result property="mdKey" column="md_key"/>
        <result property="entityId" column="entity_id"/>
        <result property="checkMsg"    column="check_msg"    />
    </resultMap>

    <resultMap id="CreditHomeAdministration" type="com.credit.cy.business.service.bo.HomeAdministrationBo">
        <result property="adminType"    column="admin_type"    />
        <result property="reportNum" column="report_num"/>
    </resultMap>

    <sql id="selectCreditAdministrationVo">
        select id, catalog_id, administration_type, counterpart_name, counterpart_type, counterpart_credit_code, delegate, delegate_card_type, delegate_card_code, counterpart_card_code, content, exec_time, exec_org, exec_org_code, data_source, source_credit_code, remark,
               create_time, update_time, create_by, update_by, report_dept,report_date,check_status,md_key,entity_id,check_msg  from credit_administration
    </sql>

    <select id="selectCreditAdministrationList" parameterType="com.credit.cy.business.domain.CreditAdministration" resultMap="CreditAdministrationResult">
        <include refid="selectCreditAdministrationVo"/>
        <where>
            <if test="counterpartCreditCode != null  and counterpartCreditCode != ''"> and counterpart_credit_code = #{counterpartCreditCode}</if>
            <if test="delegateCardCode != null  and delegateCardCode != ''"> and delegate_card_code = #{delegateCardCode}</if>
            <if test="counterpartCardCode != null  and counterpartCardCode != ''"> and counterpart_card_code = #{counterpartCardCode}</if>
            <if test="catalogId != null "> and catalog_id = #{catalogId}</if>
            <if test="createBy != null "> and create_by = #{createBy}</if>
            <if test="reportDept != null  "> and report_dept =#{reportDept}</if>
            <if test="counterpartName != null  and counterpartName != ''"> and counterpart_name like concat('%', #{counterpartName}, '%')</if>
            <if test="entityId != null  "> and entity_id =#{entityId}</if>
            <if test="counterpartType != null  and counterpartType != ''"> and counterpart_type = #{counterpartType}</if>
            <if test="delegate != null  and delegate != ''"> and delegate = #{delegate}</if>
            <if test="delegateCardType != null  and delegateCardType != ''"> and delegate_card_type = #{delegateCardType}</if>
            <if test="execTime != null "> and exec_time = #{execTime}</if>
            <if test="execOrg != null  and execOrg != ''"> and exec_org = #{execOrg}</if>
            <if test="execOrgCode != null  and execOrgCode != ''"> and exec_org_code = #{execOrgCode}</if>
            <if test="dataSource != null  and dataSource != ''"> and data_source = #{dataSource}</if>
            <if test="sourceCreditCode != null  and sourceCreditCode != ''"> and source_credit_code = #{sourceCreditCode}</if>
            <if test="administrationType != null  and administrationType != ''"> and administration_type = #{administrationType}</if>
            <if test="checkStatus != null  "> and check_status =#{checkStatus}</if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
        </where>
    </select>

    <select id="getCreditAdministrationExport" parameterType="com.credit.cy.business.domain.CreditAdministration" resultMap="CreditAdministrationResult">
        SELECT
            a.id,
            a.catalog_id,
            a.administration_type,
            a.counterpart_name,
            a.counterpart_type,
            a.counterpart_credit_code,
            a.delegate,
            a.delegate_card_type,
            a.delegate_card_code,
            a.counterpart_card_code,
            a.content,
            a.exec_time,
            a.exec_org,
            a.exec_org_code,
            a.data_source,
            a.source_credit_code,
            a.remark,
            a.create_time,
            a.update_time,
            a.create_by,
            a.update_by,
            a.report_dept,
            a.report_date,
            a.check_status,
            a.md_key,
            a.entity_id,
            a.check_msg,
            c.catalog_name
        FROM
            credit_administration a
            JOIN credit_catalog c ON a.catalog_id = c.id
        <where>
            <if test="administrationType != null  and administrationType != ''"> and a.administration_type = #{administrationType}</if>
            <if test="counterpartType != null  and counterpartType != ''"> and a.counterpart_type = #{counterpartType}</if>
            <if test="counterpartName != null  and counterpartName != ''"> and a.counterpart_name like concat('%',#{counterpartName}, '%')</if>
            <if test="reportDept != null  "> and a.report_dept =#{reportDept}</if>
        </where>
    </select>
    
    <select id="selectCreditAdministrationById" parameterType="Long" resultMap="CreditAdministrationResult">
        <include refid="selectCreditAdministrationVo"/>
        where id = #{id}
    </select>

    <select id="selectCreditAdministrationByMdKey"
            resultMap="CreditAdministrationResult">
        <include refid="selectCreditAdministrationVo"/>
        where md_key = #{mdKey}
    </select>

    <select id="selectCreditAdministrationListByIds" resultMap="CreditAdministrationResult">
        <include refid="selectCreditAdministrationVo"/>
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>

    <insert id="insertCreditAdministration" parameterType="com.credit.cy.business.domain.CreditAdministration" useGeneratedKeys="true" keyProperty="id">
        insert into credit_administration
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="catalogId != null">catalog_id,</if>
            <if test="administrationType != null">administration_type,</if>
            <if test="counterpartName != null">counterpart_name,</if>
            <if test="counterpartType != null">counterpart_type,</if>
            <if test="counterpartCreditCode != null">counterpart_credit_code,</if>
            <if test="delegate != null">delegate,</if>
            <if test="delegateCardType != null">delegate_card_type,</if>
            <if test="delegateCardCode != null">delegate_card_code,</if>
            <if test="counterpartCardCode != null">counterpart_card_code,</if>
            <if test="content != null">content,</if>
            <if test="execTime != null">exec_time,</if>
            <if test="execOrg != null">exec_org,</if>
            <if test="execOrgCode != null">exec_org_code,</if>
            <if test="dataSource != null">data_source,</if>
            <if test="sourceCreditCode != null">source_credit_code,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="reportDept != null">report_dept,</if>
            <if test="reportDate != null">report_date,</if>
            <if test="checkStatus != null">check_status,</if>
            <if test="mdKey != null">md_key,</if>
            <if test="entityId != null">entity_id,</if>
            <if test="checkMsg != null">check_msg,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="catalogId != null">#{catalogId},</if>
            <if test="administrationType != null">#{administrationType},</if>
            <if test="counterpartName != null">#{counterpartName},</if>
            <if test="counterpartType != null">#{counterpartType},</if>
            <if test="counterpartCreditCode != null">#{counterpartCreditCode},</if>
            <if test="delegate != null">#{delegate},</if>
            <if test="delegateCardType != null">#{delegateCardType},</if>
            <if test="delegateCardCode != null">#{delegateCardCode},</if>
            <if test="counterpartCardCode != null">#{counterpartCardCode},</if>
            <if test="content != null">#{content},</if>
            <if test="execTime != null">#{execTime},</if>
            <if test="execOrg != null">#{execOrg},</if>
            <if test="execOrgCode != null">#{execOrgCode},</if>
            <if test="dataSource != null">#{dataSource},</if>
            <if test="sourceCreditCode != null">#{sourceCreditCode},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="reportDept != null">#{reportDept},</if>
            <if test="reportDate != null">#{reportDate},</if>
            <if test="checkStatus != null">#{checkStatus},</if>
            <if test="mdKey != null">#{mdKey},</if>
            <if test="entityId != null">#{entityId},</if>
            <if test="checkMsg != null">#{checkMsg},</if>
         </trim>
    </insert>

    <update id="updateCreditAdministration" parameterType="com.credit.cy.business.domain.CreditAdministration">
        update credit_administration
        <trim prefix="SET" suffixOverrides=",">
            <if test="counterpartName != null">counterpart_name = #{counterpartName},</if>
            <if test="counterpartType != null">counterpart_type = #{counterpartType},</if>
            <if test="counterpartCreditCode != null">counterpart_credit_code = #{counterpartCreditCode},</if>
            <if test="delegate != null">delegate = #{delegate},</if>
            <if test="delegateCardType != null">delegate_card_type = #{delegateCardType},</if>
            <if test="delegateCardCode != null">delegate_card_code = #{delegateCardCode},</if>
            <if test="counterpartCardCode != null">counterpart_card_code = #{counterpartCardCode},</if>
            <if test="content != null">content = #{content},</if>
            exec_time = #{execTime},
            <if test="execOrg != null">exec_org = #{execOrg},</if>
            <if test="execOrgCode != null">exec_org_code = #{execOrgCode},</if>
            <if test="dataSource != null">data_source = #{dataSource},</if>
            <if test="sourceCreditCode != null">source_credit_code = #{sourceCreditCode},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="checkStatus != null">check_status=#{checkStatus},</if>
            <if test="reportDate != null">report_date=#{reportDate},</if>
            <if test="reportDept != null">report_dept=#{reportDept},</if>
            <if test="mdKey != null">md_key = #{mdKey},</if>
            <if test="entityId != null">entity_id = #{entityId},</if>
            <if test="checkMsg != null">check_msg = #{checkMsg},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCreditAdministrationById" parameterType="Long">
        delete from credit_administration where id = #{id}
    </delete>

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

    <select id="selectCount" parameterType="com.credit.cy.business.model.query.WorkCountQuery" resultType="java.lang.Long">
        select count(1) from credit_administration
        <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="selectAdministrationListByQuery" parameterType="com.credit.cy.business.model.query.CreditAdministrationQuery" resultMap="CreditAdministrationResult">
        <include refid="selectCreditAdministrationVo"/>
        <where>
            <if test="catalogId != null "> and catalog_id = #{catalogId}</if>
            <if test="createBy != null "> and create_by = #{createBy}</if>
            <if test="reportDept != null  "> and report_dept =#{reportDept}</if>
            <if test="counterpartName != null  and counterpartName != ''"> and counterpart_name like concat('%',#{counterpartName}, '%')</if>
            <if test="counterpartCardCode != null  and counterpartCardCode != ''"> and counterpart_card_code = #{counterpartCardCode}</if>
            <if test="counterpartCreditCode != null  and counterpartCreditCode != ''"> and counterpart_credit_code = #{counterpartCreditCode}</if>
            <if test="entityId != null  "> and entity_id = #{entityId}</if>
            <if test="counterpartType != null  and counterpartType != ''"> and counterpart_type = #{counterpartType}</if>
            <if test="administrationType != null  and administrationType != ''"> and administration_type = #{administrationType}</if>
            <if test="checkStatus != null  "> and check_status =#{checkStatus}</if>
            <if test="checkStatusList != null "> and check_status in
                <foreach item="checkStatus" collection="checkStatusList" open="(" separator="," close=")">
                    #{checkStatus}
                </foreach>
            </if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
        </where>
    </select>

    <select id="homeStatistics" parameterType="com.credit.cy.business.model.query.AdministrationStatisticsQuery" resultMap="CreditHomeAdministration">
        select administration_type as admin_type,  count(0) as report_num from credit_administration
        where check_status = #{checkStatus} and report_date &gt;= #{reportStartDate} and report_date &lt; #{reportEndDate}
        <if test="reportDept != null  and reportDept != ''"> and report_dept = #{reportDept}</if>
        group by admin_type
    </select>
</mapper>