<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.ibs.grid.mapper.GridCountMapper">

    <select id="selectLsCountList" resultType="com.ruoyi.ibs.grid.domain.entity.GridCmpmCountLingshou">
        SELECT dt, grid_name, grid_name2, county, town, village, dept_id,dept_name, outlets_id,outlets_name,
        user_name, cust_num, cur_bal_d, cur_bal_t, bal_loan, cur_bal_5_bad, cur_d_ave,
        cur_t_ave, loan_ave, ph_rat, sx_rat, yxht_rat, xyk_rat, fshl_rat, sd_rat,
        etc_rat, dian_rat, black_rat, bad_rat, bad_bal_rat, ph_num, sx_num, yxht_num,
        xyk_num, fshl_num, sd_num, etc_num, dian_num, black_num, bad_num, region_code, ops_dept,
        zf_365cnt, zf_180cnt, zf_90cnt, zf_30cnt, zf_365rt, zf_180rt, zf_90rt, zf_30rt
        FROM grid_cmpm_count_lingshou
        <where>
            <if test=" dt != null  and dt != ''">and dt = #{dt} </if>
            <if test=" town != null  and town != ''">and town like concat('%',concat(#{town},'%'))</if>
            <if test=" village != null  and village != ''">and village like concat('%',concat(#{village},'%'))</if>
            <if test=" isBranch == true">and dept_id like concat('%',concat(#{deptId},'%'))</if>
            <if test=" isOutlet == true">and outlets_id like concat('%',concat(#{deptId},'%'))</if>
            <if test=" isManager == true">and user_name like concat('%',concat(#{userName},'%'))</if>
        </where>
    </select>

    <select id="selectGsCountList" resultType="com.ruoyi.ibs.grid.domain.entity.GridCmpmCountGongsi">
        SELECT dt, grid_name, grid_name2, town, dept_id,dept_name, outlets_id,outlets_name, user_name,
        cust_num, hq_cur_balance, bz_cur_balance, loan_balance_cny, finance_prod_711_balance,ustr_count_per_m,ustr_bal_m,
        finance_prod_716_balance, loan_year_dailyaverage, htqy_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, htqy_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,
        zf_365cnt, zf_180cnt, zf_90cnt, zf_30cnt, zf_365rt, zf_180rt, zf_90rt, zf_30rt
        FROM grid_cmpm_count_gongsi
        <where>
            dept_type = #{userRole}
            <if test=" isBranch == true">
                and dept_id = #{deptId}
            </if>
            <if test=" isOutlet == true">
                and outlets_id = #{deptId}
            </if>
            <if test=" isManager == true">
                and user_name like concat('%',concat(#{userName},'%'))
            </if>
            <if test=" dt != null  and dt != ''">and dt = #{dt} </if>
            <if test=" town != null  and town != ''">and town like concat('%',concat(#{town},'%'))</if>
            <if test=" village != null  and village != ''">and village like concat('%',concat(#{village},'%'))</if>
        </where>
    </select>
    <select id="selectLsCustList" resultType="com.ruoyi.ibs.grid.domain.entity.GridCustCountLingshou">
        SELECT cust_name, cust_idc, cust_isn, cur_bal_d, cur_bal_t, bal_loan, cur_bal_5_bad, cur_d_ave,
        cur_t_ave, loan_ave, is_ph, is_sx, is_yxht, is_xyk, fshl, is_sd, etc, dian, is_black, is_bad,
        region_code, ops_dept, cust_type,
        is_365zf, is_180zf, is_90zf, is_30zf
        FROM grid_cust_count_lingshou
        where region_code = #{regionCode}
        <if test=" dt != null  and dt != ''">and dt = #{dt} </if>
        <if test=" custName != null  and custName != ''">and cust_name like concat('%',concat(#{custName},'%'))</if>
        <if test=" custIdc != null  and custIdc != ''">and cust_idc like concat('%',concat(#{custIdc},'%'))</if>
    </select>


    <select id="selectGsCustList" resultType="com.ruoyi.ibs.grid.domain.entity.GridCustCountGongsi">
        SELECT cust_name, social_credit_code, cust_isn, hq_cur_balance, bz_cur_balance, is_credit,
        loan_balance_cny, loan_year_dailyaverage, is_htqy, finance_prod_716_open_flag, finance_prod_716_balance,
        finance_prod_711_open_flag, finance_prod_711_balance, intl_bussiness_jcbh_open_flag, is_ustr,
        ustr_count_per_m, ustr_bal_m, eleccharge_sign_flag, watercharge_sign_flag, taxdeduction_sign_flag,
        pjb, czb, sfb, mrb, szst, is_open_sts, intl_bussiness_open_flag, intl_bussiness_325_open_flag, region_code, ops_dept, cust_type,
        is_365zf, is_180zf, is_90zf, is_30zf
        FROM grid_cust_count_gongsi
        where region_code = #{regionCode}
        <if test=" dt != null  and dt != ''">and dt = #{dt} </if>
        <if test=" isBranch == true">and dept_id like concat('%',concat(#{deptId},'%'))</if>
        <if test=" isOutlet == true">and outlets_id like concat('%',concat(#{deptId},'%'))</if>
        <if test=" isManager == true">and user_name like concat('%',concat(#{userName},'%'))</if>
        <if test=" custName != null  and custName != ''">and cust_name like concat('%',concat(#{custName},'%'))</if>
        <if test=" socialCreditCode != null  and socialCreditCode != ''">and social_credit_code like concat('%',concat(#{socialCreditCode},'%'))</if>
    </select>

</mapper>