<?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.ruoyi.ibs.customerselect.mapper.GridSummarCountMapper">
    
    <resultMap type="GridSummarCount" id="GridSummarCountResult">
        <result property="dt"    column="dt"    />
        <result property="gridName"    column="grid_name"    />
        <result property="gridName2"    column="grid_name2"    />
        <result property="town"    column="town"    />
        <result property="deptId"    column="dept_id"    />
        <result property="outletsId"    column="outlets_id"    />
        <result property="userName"    column="user_name"    />
        <result property="custNum"    column="cust_num"    />
        <result property="hqCurBalance"    column="hq_cur_balance"    />
        <result property="bzCurBalance"    column="bz_cur_balance"    />
        <result property="loanBalanceCny"    column="loan_balance_cny"    />
        <result property="financeProd711Balance"    column="finance_prod_711_balance"    />
        <result property="financeProd716Balance"    column="finance_prod_716_balance"    />
        <result property="loanYearDailyaverage"    column="loan_year_dailyaverage"    />
        <result property="phRat"    column="ph_rat"    />
        <result property="qfcdRat"    column="qfcd_rat"    />
        <result property="txRat"    column="tx_rat"    />
        <result property="bhRat"    column="bh_rat"    />
        <result property="yxdfgzRat"    column="yxdfgz_rat"    />
        <result property="dkdfRat"    column="dkdf_rat"    />
        <result property="dksfRat"    column="dksf_rat"    />
        <result property="dkshfRat"    column="dkshf_rat"    />
        <result property="pjbRat"    column="pjb_rat"    />
        <result property="czbRat"    column="czb_rat"    />
        <result property="sfbRat"    column="sfb_rat"    />
        <result property="mrbRat"    column="mrb_rat"    />
        <result property="szstRat"    column="szst_rat"    />
        <result property="khRat"    column="kh_rat"    />
        <result property="gjjsywRat"    column="gjjsyw_rat"    />
        <result property="yqjshRat"    column="yqjsh_rat"    />
        <result property="phNum"    column="ph_num"    />
        <result property="qfcdNum"    column="qfcd_num"    />
        <result property="txNum"    column="tx_num"    />
        <result property="bhNum"    column="bh_num"    />
        <result property="yxdfgzNum"    column="yxdfgz_num"    />
        <result property="dkdfNum"    column="dkdf_num"    />
        <result property="dksfNum"    column="dksf_num"    />
        <result property="dkshfNum"    column="dkshf_num"    />
        <result property="pjbNum"    column="pjb_num"    />
        <result property="czbNum"    column="czb_num"    />
        <result property="sfbNum"    column="sfb_num"    />
        <result property="mrbNum"    column="mrb_num"    />
        <result property="szstNum"    column="szst_num"    />
        <result property="khNum"    column="kh_num"    />
        <result property="gjjsywNum"    column="gjjsyw_num"    />
        <result property="yqjshNum"    column="yqjsh_num"    />
        <result property="regionCode"    column="region_code"    />
        <result property="opsDept"    column="ops_dept"    />
    </resultMap>

    <sql id="selectGridSummarCountVo">
        select dt, grid_name, grid_name2, town, dept_id, outlets_id, user_name, cust_num, hq_cur_balance, bz_cur_balance, loan_balance_cny, finance_prod_711_balance, finance_prod_716_balance, loan_year_dailyaverage, ph_rat, qfcd_rat, tx_rat, bh_rat, yxdfgz_rat, dkdf_rat, dksf_rat, dkshf_rat, pjb_rat, czb_rat, sfb_rat, mrb_rat, szst_rat, kh_rat, gjjsyw_rat, yqjsh_rat, ph_num, qfcd_num, tx_num, bh_num, yxdfgz_num, dkdf_num, dksf_num, dkshf_num, pjb_num, czb_num, sfb_num, mrb_num, szst_num, kh_num, gjjsyw_num, yqjsh_num, region_code, ops_dept from grid_cmpm_count_gongsi_965
    </sql>

    <select id="selectContinuousParams" parameterType="com.ruoyi.ibs.customerselect.domain.CustBaseInfo" resultType="map">
        SELECT
            dict_label AS par_key,dict_value AS par_value FROM sys_dict_data
        WHERE 1=1
        <choose>
            <when test="custPattern == 0 or custPattern == 1">
                AND dict_type = 'continuous_ds_metric'
            </when>
            <when test="custPattern == 2">
                AND dict_type = 'continuous_dg_metric'
            </when>
        </choose>
    </select>

    <select id="selectDiscreteParams" parameterType="com.ruoyi.ibs.customerselect.domain.CustBaseInfo" resultType="map">
        SELECT
        dict_label AS par_key,dict_value AS par_value FROM sys_dict_data
        WHERE 1=1
        <if test="custPattern == 0 or custPattern == 1">
            and dict_type = 'discrete_ds_metric'
        </if>
        <if test="custPattern == 2">
            and dict_type = 'discrete_dg_metric'
        </if>
    </select>

    <select id="selectDictLabelByDictValue" parameterType="String" resultType="String">
        select dict_label from sys_dict_data where dict_value = #{dictValue} limit 1
    </select>

    <select id="selectGridSummarCountList" parameterType="GridSummarCount" resultMap="GridSummarCountResult">
        <include refid="selectGridSummarCountVo"/>
        <where>  
            <if test="dt != null  and dt != ''"> and dt = #{dt}</if>
            <if test="gridName != null  and gridName != ''"> and grid_name like concat('%', #{gridName}, '%')</if>
            <if test="gridName2 != null  and gridName2 != ''"> and grid_name2 = #{gridName2}</if>
            <if test="town != null  and town != ''"> and town = #{town}</if>
            <if test="deptId != null  and deptId != ''"> and dept_id = #{deptId}</if>
            <if test="outletsId != null  and outletsId != ''"> and outlets_id = #{outletsId}</if>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="custNum != null "> and cust_num = #{custNum}</if>
            <if test="hqCurBalance != null  and hqCurBalance != ''"> and hq_cur_balance = #{hqCurBalance}</if>
            <if test="bzCurBalance != null  and bzCurBalance != ''"> and bz_cur_balance = #{bzCurBalance}</if>
            <if test="loanBalanceCny != null  and loanBalanceCny != ''"> and loan_balance_cny = #{loanBalanceCny}</if>
            <if test="financeProd711Balance != null  and financeProd711Balance != ''"> and finance_prod_711_balance = #{financeProd711Balance}</if>
            <if test="financeProd716Balance != null  and financeProd716Balance != ''"> and finance_prod_716_balance = #{financeProd716Balance}</if>
            <if test="loanYearDailyaverage != null  and loanYearDailyaverage != ''"> and loan_year_dailyaverage = #{loanYearDailyaverage}</if>
            <if test="phRat != null  and phRat != ''"> and ph_rat = #{phRat}</if>
            <if test="qfcdRat != null  and qfcdRat != ''"> and qfcd_rat = #{qfcdRat}</if>
            <if test="txRat != null  and txRat != ''"> and tx_rat = #{txRat}</if>
            <if test="bhRat != null  and bhRat != ''"> and bh_rat = #{bhRat}</if>
            <if test="yxdfgzRat != null  and yxdfgzRat != ''"> and yxdfgz_rat = #{yxdfgzRat}</if>
            <if test="dkdfRat != null  and dkdfRat != ''"> and dkdf_rat = #{dkdfRat}</if>
            <if test="dksfRat != null  and dksfRat != ''"> and dksf_rat = #{dksfRat}</if>
            <if test="dkshfRat != null  and dkshfRat != ''"> and dkshf_rat = #{dkshfRat}</if>
            <if test="pjbRat != null  and pjbRat != ''"> and pjb_rat = #{pjbRat}</if>
            <if test="czbRat != null  and czbRat != ''"> and czb_rat = #{czbRat}</if>
            <if test="sfbRat != null  and sfbRat != ''"> and sfb_rat = #{sfbRat}</if>
            <if test="mrbRat != null  and mrbRat != ''"> and mrb_rat = #{mrbRat}</if>
            <if test="szstRat != null  and szstRat != ''"> and szst_rat = #{szstRat}</if>
            <if test="khRat != null  and khRat != ''"> and kh_rat = #{khRat}</if>
            <if test="gjjsywRat != null  and gjjsywRat != ''"> and gjjsyw_rat = #{gjjsywRat}</if>
            <if test="yqjshRat != null  and yqjshRat != ''"> and yqjsh_rat = #{yqjshRat}</if>
            <if test="phNum != null "> and ph_num = #{phNum}</if>
            <if test="qfcdNum != null "> and qfcd_num = #{qfcdNum}</if>
            <if test="txNum != null "> and tx_num = #{txNum}</if>
            <if test="bhNum != null "> and bh_num = #{bhNum}</if>
            <if test="yxdfgzNum != null "> and yxdfgz_num = #{yxdfgzNum}</if>
            <if test="dkdfNum != null "> and dkdf_num = #{dkdfNum}</if>
            <if test="dksfNum != null "> and dksf_num = #{dksfNum}</if>
            <if test="dkshfNum != null "> and dkshf_num = #{dkshfNum}</if>
            <if test="pjbNum != null "> and pjb_num = #{pjbNum}</if>
            <if test="czbNum != null "> and czb_num = #{czbNum}</if>
            <if test="sfbNum != null "> and sfb_num = #{sfbNum}</if>
            <if test="mrbNum != null "> and mrb_num = #{mrbNum}</if>
            <if test="szstNum != null "> and szst_num = #{szstNum}</if>
            <if test="khNum != null "> and kh_num = #{khNum}</if>
            <if test="gjjsywNum != null "> and gjjsyw_num = #{gjjsywNum}</if>
            <if test="yqjshNum != null "> and yqjsh_num = #{yqjshNum}</if>
            <if test="regionCode != null  and regionCode != ''"> and region_code = #{regionCode}</if>
            <if test="opsDept != null  and opsDept != ''"> and ops_dept = #{opsDept}</if>
        </where>
    </select>
    
    <select id="selectGridSummarCountByDt" parameterType="String" resultMap="GridSummarCountResult">
        <include refid="selectGridSummarCountVo"/>
        where dt = #{dt}
    </select>

    <insert id="insertGridSummarCount" parameterType="GridSummarCount">
        insert into grid_cmpm_count_gongsi_965
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dt != null">dt,</if>
            <if test="gridName != null">grid_name,</if>
            <if test="gridName2 != null">grid_name2,</if>
            <if test="town != null">town,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="outletsId != null">outlets_id,</if>
            <if test="userName != null">user_name,</if>
            <if test="custNum != null">cust_num,</if>
            <if test="hqCurBalance != null">hq_cur_balance,</if>
            <if test="bzCurBalance != null">bz_cur_balance,</if>
            <if test="loanBalanceCny != null">loan_balance_cny,</if>
            <if test="financeProd711Balance != null">finance_prod_711_balance,</if>
            <if test="financeProd716Balance != null">finance_prod_716_balance,</if>
            <if test="loanYearDailyaverage != null">loan_year_dailyaverage,</if>
            <if test="phRat != null">ph_rat,</if>
            <if test="qfcdRat != null">qfcd_rat,</if>
            <if test="txRat != null">tx_rat,</if>
            <if test="bhRat != null">bh_rat,</if>
            <if test="yxdfgzRat != null">yxdfgz_rat,</if>
            <if test="dkdfRat != null">dkdf_rat,</if>
            <if test="dksfRat != null">dksf_rat,</if>
            <if test="dkshfRat != null">dkshf_rat,</if>
            <if test="pjbRat != null">pjb_rat,</if>
            <if test="czbRat != null">czb_rat,</if>
            <if test="sfbRat != null">sfb_rat,</if>
            <if test="mrbRat != null">mrb_rat,</if>
            <if test="szstRat != null">szst_rat,</if>
            <if test="khRat != null">kh_rat,</if>
            <if test="gjjsywRat != null">gjjsyw_rat,</if>
            <if test="yqjshRat != null">yqjsh_rat,</if>
            <if test="phNum != null">ph_num,</if>
            <if test="qfcdNum != null">qfcd_num,</if>
            <if test="txNum != null">tx_num,</if>
            <if test="bhNum != null">bh_num,</if>
            <if test="yxdfgzNum != null">yxdfgz_num,</if>
            <if test="dkdfNum != null">dkdf_num,</if>
            <if test="dksfNum != null">dksf_num,</if>
            <if test="dkshfNum != null">dkshf_num,</if>
            <if test="pjbNum != null">pjb_num,</if>
            <if test="czbNum != null">czb_num,</if>
            <if test="sfbNum != null">sfb_num,</if>
            <if test="mrbNum != null">mrb_num,</if>
            <if test="szstNum != null">szst_num,</if>
            <if test="khNum != null">kh_num,</if>
            <if test="gjjsywNum != null">gjjsyw_num,</if>
            <if test="yqjshNum != null">yqjsh_num,</if>
            <if test="regionCode != null">region_code,</if>
            <if test="opsDept != null">ops_dept,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dt != null">#{dt},</if>
            <if test="gridName != null">#{gridName},</if>
            <if test="gridName2 != null">#{gridName2},</if>
            <if test="town != null">#{town},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="outletsId != null">#{outletsId},</if>
            <if test="userName != null">#{userName},</if>
            <if test="custNum != null">#{custNum},</if>
            <if test="hqCurBalance != null">#{hqCurBalance},</if>
            <if test="bzCurBalance != null">#{bzCurBalance},</if>
            <if test="loanBalanceCny != null">#{loanBalanceCny},</if>
            <if test="financeProd711Balance != null">#{financeProd711Balance},</if>
            <if test="financeProd716Balance != null">#{financeProd716Balance},</if>
            <if test="loanYearDailyaverage != null">#{loanYearDailyaverage},</if>
            <if test="phRat != null">#{phRat},</if>
            <if test="qfcdRat != null">#{qfcdRat},</if>
            <if test="txRat != null">#{txRat},</if>
            <if test="bhRat != null">#{bhRat},</if>
            <if test="yxdfgzRat != null">#{yxdfgzRat},</if>
            <if test="dkdfRat != null">#{dkdfRat},</if>
            <if test="dksfRat != null">#{dksfRat},</if>
            <if test="dkshfRat != null">#{dkshfRat},</if>
            <if test="pjbRat != null">#{pjbRat},</if>
            <if test="czbRat != null">#{czbRat},</if>
            <if test="sfbRat != null">#{sfbRat},</if>
            <if test="mrbRat != null">#{mrbRat},</if>
            <if test="szstRat != null">#{szstRat},</if>
            <if test="khRat != null">#{khRat},</if>
            <if test="gjjsywRat != null">#{gjjsywRat},</if>
            <if test="yqjshRat != null">#{yqjshRat},</if>
            <if test="phNum != null">#{phNum},</if>
            <if test="qfcdNum != null">#{qfcdNum},</if>
            <if test="txNum != null">#{txNum},</if>
            <if test="bhNum != null">#{bhNum},</if>
            <if test="yxdfgzNum != null">#{yxdfgzNum},</if>
            <if test="dkdfNum != null">#{dkdfNum},</if>
            <if test="dksfNum != null">#{dksfNum},</if>
            <if test="dkshfNum != null">#{dkshfNum},</if>
            <if test="pjbNum != null">#{pjbNum},</if>
            <if test="czbNum != null">#{czbNum},</if>
            <if test="sfbNum != null">#{sfbNum},</if>
            <if test="mrbNum != null">#{mrbNum},</if>
            <if test="szstNum != null">#{szstNum},</if>
            <if test="khNum != null">#{khNum},</if>
            <if test="gjjsywNum != null">#{gjjsywNum},</if>
            <if test="yqjshNum != null">#{yqjshNum},</if>
            <if test="regionCode != null">#{regionCode},</if>
            <if test="opsDept != null">#{opsDept},</if>
         </trim>
    </insert>

    <update id="updateGridSummarCount" parameterType="GridSummarCount">
        update grid_cmpm_count_gongsi_965
        <trim prefix="SET" suffixOverrides=",">
            <if test="gridName != null">grid_name = #{gridName},</if>
            <if test="gridName2 != null">grid_name2 = #{gridName2},</if>
            <if test="town != null">town = #{town},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="outletsId != null">outlets_id = #{outletsId},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="custNum != null">cust_num = #{custNum},</if>
            <if test="hqCurBalance != null">hq_cur_balance = #{hqCurBalance},</if>
            <if test="bzCurBalance != null">bz_cur_balance = #{bzCurBalance},</if>
            <if test="loanBalanceCny != null">loan_balance_cny = #{loanBalanceCny},</if>
            <if test="financeProd711Balance != null">finance_prod_711_balance = #{financeProd711Balance},</if>
            <if test="financeProd716Balance != null">finance_prod_716_balance = #{financeProd716Balance},</if>
            <if test="loanYearDailyaverage != null">loan_year_dailyaverage = #{loanYearDailyaverage},</if>
            <if test="phRat != null">ph_rat = #{phRat},</if>
            <if test="qfcdRat != null">qfcd_rat = #{qfcdRat},</if>
            <if test="txRat != null">tx_rat = #{txRat},</if>
            <if test="bhRat != null">bh_rat = #{bhRat},</if>
            <if test="yxdfgzRat != null">yxdfgz_rat = #{yxdfgzRat},</if>
            <if test="dkdfRat != null">dkdf_rat = #{dkdfRat},</if>
            <if test="dksfRat != null">dksf_rat = #{dksfRat},</if>
            <if test="dkshfRat != null">dkshf_rat = #{dkshfRat},</if>
            <if test="pjbRat != null">pjb_rat = #{pjbRat},</if>
            <if test="czbRat != null">czb_rat = #{czbRat},</if>
            <if test="sfbRat != null">sfb_rat = #{sfbRat},</if>
            <if test="mrbRat != null">mrb_rat = #{mrbRat},</if>
            <if test="szstRat != null">szst_rat = #{szstRat},</if>
            <if test="khRat != null">kh_rat = #{khRat},</if>
            <if test="gjjsywRat != null">gjjsyw_rat = #{gjjsywRat},</if>
            <if test="yqjshRat != null">yqjsh_rat = #{yqjshRat},</if>
            <if test="phNum != null">ph_num = #{phNum},</if>
            <if test="qfcdNum != null">qfcd_num = #{qfcdNum},</if>
            <if test="txNum != null">tx_num = #{txNum},</if>
            <if test="bhNum != null">bh_num = #{bhNum},</if>
            <if test="yxdfgzNum != null">yxdfgz_num = #{yxdfgzNum},</if>
            <if test="dkdfNum != null">dkdf_num = #{dkdfNum},</if>
            <if test="dksfNum != null">dksf_num = #{dksfNum},</if>
            <if test="dkshfNum != null">dkshf_num = #{dkshfNum},</if>
            <if test="pjbNum != null">pjb_num = #{pjbNum},</if>
            <if test="czbNum != null">czb_num = #{czbNum},</if>
            <if test="sfbNum != null">sfb_num = #{sfbNum},</if>
            <if test="mrbNum != null">mrb_num = #{mrbNum},</if>
            <if test="szstNum != null">szst_num = #{szstNum},</if>
            <if test="khNum != null">kh_num = #{khNum},</if>
            <if test="gjjsywNum != null">gjjsyw_num = #{gjjsywNum},</if>
            <if test="yqjshNum != null">yqjsh_num = #{yqjshNum},</if>
            <if test="regionCode != null">region_code = #{regionCode},</if>
            <if test="opsDept != null">ops_dept = #{opsDept},</if>
        </trim>
        where dt = #{dt}
    </update>

    <delete id="deleteGridSummarCountByDt" parameterType="String">
        delete from grid_cmpm_count_gongsi_965 where dt = #{dt}
    </delete>

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