<?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="cn.roadm.mapper.SpDelayRatioMapper">

    <resultMap type="DelayRatio" id="delayRatioMap">
        <id column="id" property="task_id" />
        <result column="createTime" property="createTime" />
        <result column="sp_id" property="sp_id" />
        <result column="sp_name" property="sp_name" />
        <result column="allnumber" property="allnumber" />
        <result column="five_less" property="five_less" />
        <result column="ten_less" property="ten_less" />
        <result column="ten_to_twenty" property="ten_to_twenty" />
        <result column="twenty_to_thirty" property="twenty_to_thirty" />
        <result column="thirty_to_sisty" property="thirty_to_sisty" />
        <result column="sisty_more" property="sisty_more" />
        <result column="sp_saler" property="sp_saler" />
        <result column="page" property="page" />
        <result column="channel_name" property="channel_name" />
        <result column="channelid" property="channelid" />
    </resultMap>

    <!--  CONCAT(CONCAT(sum(sr.five_less), '(' ),(CONCAT(Round(sum(sr.five_less)/sum(sr.arrive_succ + sr.arrive_fail)*100,2), '%)' ))) five_less,
        CONCAT(CONCAT(sum(sr.ten_less), '(' ),(CONCAT(Round(sum(sr.ten_less)/sum(sr.arrive_succ + sr.arrive_fail)*100,2), '%)' ))) ten_less,
        CONCAT(CONCAT(sum(sr.ten_to_twenty), '(' ),(CONCAT(Round(sum(sr.ten_to_twenty)/sum(sr.arrive_succ + sr.arrive_fail)*100,2), '%)' ))) ten_to_twenty,
        CONCAT(CONCAT(sum(sr.twenty_to_thirty), '(' ),(CONCAT(Round(sum(sr.twenty_to_thirty)/sum(sr.arrive_succ + sr.arrive_fail)*100,2), '%)' ))) twenty_to_thirty,
        CONCAT(CONCAT(sum(sr.thirty_to_sisty), '(' ),(CONCAT(Round(sum(sr.thirty_to_sisty)/sum(sr.arrive_succ + sr.arrive_fail)*100,2), '%)' ))) thirty_to_sisty,
        CONCAT(CONCAT(sum(sr.sisty_more), '(' ),(CONCAT(Round(sum(sr.sisty_more)/sum(sr.arrive_succ + sr.arrive_fail)*100,2), '%)' ))) sisty_more, -->
    <select id="listPageSpDelayRatio" parameterType="DelayRatio"
            resultMap="delayRatioMap">
        select sp.id sp_id,
        sp.sp_name,
        si.channel_name,
        sr.channelid,
        sum( IFNULL(sr.all_number,0) + IFNULL(sr.submit_fail,0) ) allnumber,
        sum( IFNULL(sr.arrive_succ,0) + IFNULL(sr.arrive_fail,0) ) arriveTotal,
        sum( IFNULL(sr.five_less,0) ) fiveLess,
        sum( IFNULL(sr.ten_less,0) ) tenLess,
        sum( IFNULL(sr.ten_to_twenty,0) ) tenToTwenty,
        sum( IFNULL(sr.twenty_to_thirty,0) ) twentyToThirty,
        sum( IFNULL(sr.thirty_to_sisty,0) ) thirtyToirty,
        sum( IFNULL(sr.sisty_more,0) ) sistyMore,
        date_format(sr.createtime,'%Y-%m-%d') createtime
        from sms_sp_delay_ratio sr, sms_sp_info sp,sms_send_channel_info si
        where sr.spid = sp.id and si.id=sr.channelid

        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="channel_name!=null and channel_name!=''">
            and si.channel_name like CONCAT('%',#{channel_name},'%')
        </if>
        <if test="sp_id!=null and sp_id>0">
            and sr.spid=#{sp_id}
        </if>
        <if test="createTime!=null and createTime!=''">
            and sr.createtime&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            sr.createtime&lt;DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        group by sp.id, sp.sp_name,si.channel_name,sr.channelid,date_format( sr.createtime, '%Y-%m-%d' )
        order by date_format( sr.createtime, '%Y-%m-%d' ) desc,allnumber desc
    </select>

    <!--   sum(sr.all_number) allnumber,
        CONCAT(CONCAT(sum(sr.five_less), '(' ),(CONCAT(Round(sum(sr.five_less)/sum(sr.arrive_succ + sr.arrive_fail)*100,2), '%)' ))) five_less,
        CONCAT(CONCAT(sum(sr.ten_less), '(' ),(CONCAT(Round(sum(sr.ten_less)/sum(sr.arrive_succ + sr.arrive_fail)*100,2), '%)' ))) ten_less,
        CONCAT(CONCAT(sum(sr.ten_to_twenty), '(' ),(CONCAT(Round(sum(sr.ten_to_twenty)/sum(sr.arrive_succ + sr.arrive_fail)*100,2), '%)' ))) ten_to_twenty,
        CONCAT(CONCAT(sum(sr.twenty_to_thirty), '(' ),(CONCAT(Round(sum(sr.twenty_to_thirty)/sum(sr.arrive_succ + sr.arrive_fail)*100,2), '%)' ))) twenty_to_thirty,
        CONCAT(CONCAT(sum(sr.thirty_to_sisty), '(' ),(CONCAT(Round(sum(sr.thirty_to_sisty)/sum(sr.arrive_succ + sr.arrive_fail)*100,2), '%)' ))) thirty_to_sisty,
        CONCAT(CONCAT(sum(sr.sisty_more), '(' ),(CONCAT(Round(sum(sr.sisty_more)/sum(sr.arrive_succ + sr.arrive_fail)*100,2), '%)' ))) sisty_more, -->
    <select id="exportSpDelayRatioList" parameterType="DelayRatio" resultType="map">
        select sp.id sp_id,
        sp.sp_name,
        sr.channelid,
        si.channel_name,
        sum( IFNULL(sr.all_number,0) + IFNULL(sr.submit_fail,0) ) allnumber,
        sum( IFNULL(sr.arrive_succ,0) + IFNULL(sr.arrive_fail,0) ) arriveTotal,
        sum( IFNULL(sr.five_less,0) ) fiveLess,
        sum( IFNULL(sr.ten_less,0) ) tenLess,
        sum( IFNULL(sr.ten_to_twenty,0) ) tenToTwenty,
        sum( IFNULL(sr.twenty_to_thirty,0) ) twentyToThirty,
        sum( IFNULL(sr.thirty_to_sisty,0) ) thirtyToirty,
        sum( IFNULL(sr.sisty_more,0) ) sistyMore,
        date_format(sr.createtime,'%Y-%m-%d') createTime
        from sms_sp_delay_ratio sr, sms_sp_info sp,sms_send_channel_info si
        where sr.spid = sp.id and si.id=sr.channelid

        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="channel_name!=null and channel_name!=''">
            and si.channel_name like CONCAT('%',#{channel_name},'%')
        </if>
        <if test="sp_id!=null and sp_id>0">
            and sr.spid=#{sp_id}
        </if>
        <if test="createTime!=null and createTime!=''">
            and sr.createtime&gt;=str_to_date(#{createTime},'%Y-%m-%d')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            sr.createtime&lt;DATE_ADD(str_to_date(#{createTime1},'%Y-%m-%d'),INTERVAL 1 DAY)
        </if>
        group by sp.id, sp.sp_name,si.channel_name,sr.channelid,
		date_format( sr.createtime, '%Y-%m-%d' )
        order by sp.id,
        date_format( sr.createtime, '%Y-%m-%d' ) desc
    </select>

    <select id="listPageSpDelayMinRatio" resultType="cn.roadm.bo.DelayRatio">
        select
        <if test="typeName !=null and typeName!='' and typeName == 'sp'">
            sp_id,
            sp_name,
        </if>
        <if test="typeName !=null and typeName!='' and typeName == 'channelid'">
            channel_name,
            channelid,
        </if>
        <if test="typeName !=null and typeName!='' and typeName == 'spAndChannel'">
            sp_id,
            sp_name,
            channel_name,
            channelid,
        </if>
        all_number,
        submit_fail,
        arrive_succ,
        arrive_fail,
        five_less,
        ten_less,
        ten_to_twenty,
        twenty_to_thirty,
        thirty_to_sisty,
        five_min,
        ten_min,
        sisty_more,
        createtime
        from (
            select
            <if test="typeName !=null and typeName!='' and typeName == 'sp'">
                sp.id sp_id,
                sp.sp_name,
            </if>
            <if test="typeName !=null and typeName!='' and typeName == 'channelid'">
                si.channel_name,
                sr.channelid,
            </if>
            <if test="typeName !=null and typeName!='' and typeName == 'spAndChannel'">
                sp.id sp_id,
                sp.sp_name,
                si.channel_name,
                sr.channelid,
            </if>
            sum(IFNULL(sr.all_number,0)) all_number,
            sum(IFNULL(sr.all_number, 0))+sum(IFNULL(sr.submit_fail, 0))  number,
            sum(IFNULL(sr.submit_fail,0)) submit_fail,
            sum(IFNULL(sr.arrive_succ,0)) arrive_succ,
            sum(IFNULL(sr.arrive_fail,0)) arrive_fail,
            Round( sum( IFNULL( sr.arrive_succ, 0 ) )/ sum( IFNULL( sr.all_number, 0 ) + IFNULL( sr.submit_fail, 0 ))* 100, 2 ) sucess_rate,
            CONCAT(CONCAT(sum(sr.five_less), '(' ),(CONCAT(Round(sum(sr.five_less)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) five_less,
            CONCAT(CONCAT(sum(sr.ten_less), '(' ),(CONCAT(Round(sum(sr.ten_less)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) ten_less,
            CONCAT(CONCAT(sum(sr.ten_to_twenty), '(' ),(CONCAT(Round(sum(sr.ten_to_twenty)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) ten_to_twenty,
            CONCAT(CONCAT(sum(sr.twenty_to_thirty), '(' ),(CONCAT(Round(sum(sr.twenty_to_thirty)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) twenty_to_thirty,
            CONCAT(CONCAT(sum(sr.thirty_to_sisty), '(' ),(CONCAT(Round(sum(sr.thirty_to_sisty)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) thirty_to_sisty,
            CONCAT(CONCAT(sum(sr.five_min), '(' ),(CONCAT(Round(sum(sr.five_min)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) five_min,
            CONCAT(CONCAT(sum(sr.ten_min), '(' ),(CONCAT(Round(sum(sr.ten_min)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) ten_min,
            CONCAT(CONCAT(sum(sr.sisty_more), '(' ),(CONCAT(Round(sum(sr.sisty_more)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) sisty_more, /* 25.04.27 调整为十分钟以上数据*/
            date_format(sr.createtime,'%Y-%m-%d %H:%i') createtime
            from sms_sp_delay_ratio sr, sms_sp_info sp,sms_send_channel_info si
            where sr.spid = sp.id and si.id=sr.channelid
            <if test="sp_name!=null and sp_name!=''">
              and sp.sp_name like CONCAT('%',#{sp_name},'%')
            </if>
            <if test="salerList != null and salerList.size() > 0">
                and sp.sp_saler in
                <foreach collection="salerList" item="item" open="(" separator="," close=")">
                    '${item}'
                </foreach>
            </if>
            <if test="sp_saler!=null and sp_saler!=''">
                and sp.sp_saler =#{sp_saler}
            </if>
            <if test="channelid!=null and channelid>=0">
                and si.id = #{channelid}
            </if>
            <if test="sp_id!=null and sp_id>0">
                and sr.spid=#{sp_id}
            </if>
            <if test="createTime!=null and createTime!=''">
                and sr.createtime&gt;=str_to_date(#{createTime},'%Y-%m-%d %H:%i')
            </if>
            <if test="createTime1!=null and createTime1!=''">
                and
                sr.createtime&lt;str_to_date(#{createTime1},'%Y-%m-%d %H:%i')
            </if>
            group by
            <if test="typeName !=null and typeName!='' and typeName == 'sp'">
                sp.id,
                sp.sp_name,
            </if>
            <if test="typeName !=null and typeName!='' and typeName == 'channelid'">
                si.channel_name,
                sr.channelid,
            </if>
            <if test="typeName !=null and typeName!='' and typeName == 'spAndChannel'">
                sp.id,
                sp.sp_name,
                si.channel_name,
                sr.channelid,
            </if>
            date_format( sr.createtime, '%Y-%m-%d %H:%i' )
            order by date_format( sr.createtime, '%Y-%m-%d %H:%i' ) desc,number desc
        ) m
        <where>
            <if test="sucess_rate!= null and sucess_rate >= 0">
                m.sucess_rate >= #{sucess_rate}
            </if>
            <if test="less_sucess_rate!= null and less_sucess_rate >= 0">
                m.sucess_rate &lt; #{less_sucess_rate}
            </if>
        </where>
    </select>

    <select id="listPageSpDelayDay" resultType="cn.roadm.bo.DelayRatio">
        select
        sp_id,
        sp_name,
        all_number,
        submit_fail,
        arrive_succ,
        arrive_fail,
        five_less,
        ten_less,
        ten_to_twenty,
        twenty_to_thirty,
        thirty_to_sisty,
        five_min,
        ten_min,
        sisty_more,
        createtime
        from (
            select
            sp.id sp_id,
            sp.sp_name,
            sum(IFNULL(ss.succ,0)) all_number,
            sum(IFNULL(ss.succ, 0))+sum(IFNULL(ss.fail, 0))  number,
            sum(IFNULL(ss.fail,0)) submit_fail,
            sum(IFNULL(sdd.arrive_succ,0)) arrive_succ,
            sum(IFNULL(sdd.arrive_fail,0)) arrive_fail,
            Round( sum( IFNULL( sdd.arrive_succ, 0 ) )/ sum( IFNULL( ss.succ, 0 ) + IFNULL( ss.fail, 0 ))* 100, 2 ) sucess_rate,
            CONCAT(CONCAT(sum(sdd.five_less), '(' ),(CONCAT(Round(sum(sdd.five_less)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) five_less,
            CONCAT(CONCAT(sum(sdd.ten_less), '(' ),(CONCAT(Round(sum(sdd.ten_less)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) ten_less,
            CONCAT(CONCAT(sum(sdd.ten_to_twenty), '(' ),(CONCAT(Round(sum(sdd.ten_to_twenty)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) ten_to_twenty,
            CONCAT(CONCAT(sum(sdd.twenty_to_thirty), '(' ),(CONCAT(Round(sum(sdd.twenty_to_thirty)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) twenty_to_thirty,
            CONCAT(CONCAT(sum(sdd.thirty_to_sisty), '(' ),(CONCAT(Round(sum(sdd.thirty_to_sisty)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) thirty_to_sisty,
            CONCAT(CONCAT(sum(sdd.five_min), '(' ),(CONCAT(Round(sum(sdd.five_min)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) five_min,
            CONCAT(CONCAT(sum(sdd.ten_min), '(' ),(CONCAT(Round(sum(sdd.ten_min)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) ten_min,
            CONCAT(CONCAT(sum(sdd.sisty_more), '(' ),(CONCAT(Round(sum(sdd.sisty_more)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) sisty_more, /* 25.04.27 调整为十分钟以上数据*/
            date_format(sdd.createtime,'%Y-%m-%d') createtime
            from sms_sp_delay_day sdd
            inner join sms_sp_info sp on sdd.spid = sp.id
            inner join sms_sp_summary ss on sdd.spid = ss.spid
            and DATE(sdd.CREATETIME) = DATE(ss.stat_time)
        <where>
            <if test="sp_name!=null and sp_name!=''">
              and sp.sp_name like CONCAT('%',#{sp_name},'%')
            </if>
            <if test="salerList != null and salerList.size() > 0">
                and sp.sp_saler in
                <foreach collection="salerList" item="item" open="(" separator="," close=")">
                    '${item}'
                </foreach>
            </if>
            <if test="sp_saler!=null and sp_saler!=''">
                and sp.sp_saler =#{sp_saler}
            </if>
            <if test="sp_id!=null and sp_id>0">
                and sdd.spid=#{sp_id}
            </if>
            <if test="createTime!=null and createTime!=''">
                and DATE(sdd.createtime) &gt;= DATE(#{createTime})
            </if>
            <if test="createTime1!=null and createTime1!=''">
                and DATE(sdd.createtime) &lt;= DATE(#{createTime1})
            </if>
        </where>
            group by
                sp.id,
                sp.sp_name,
                date_format( sdd.createtime, '%Y-%m-%d' )
            order by
                date_format( sdd.createtime, '%Y-%m-%d' ) desc,
                number desc
        ) m
        <where>
            <if test="sucess_rate!= null and sucess_rate >= 0">
                and m.sucess_rate >= #{sucess_rate}
            </if>
            <if test="less_sucess_rate!= null and less_sucess_rate >= 0">
                and m.sucess_rate &lt;= #{less_sucess_rate}
            </if>
        </where>
    </select>

    <select id="getSpDelayMinRatioSum" resultType="cn.roadm.bo.DelayRatio">
        select
        sum(all_number) all_number,
        sum(submit_fail) submit_fail,
        sum(arrive_succ) arrive_succ,
        sum(arrive_fail) arrive_fail,
        sum(IFNULL(five_less,0)) five_less,
        sum(IFNULL(ten_less,0)) ten_less,
        sum(IFNULL(ten_to_twenty,0)) ten_to_twenty,
        sum(IFNULL(twenty_to_thirty,0)) twenty_to_thirty,
        sum(IFNULL(thirty_to_sisty,0)) thirty_to_sisty,
        sum(IFNULL(five_min,0)) five_min,
        sum(IFNULL(ten_min,0)) ten_min,
        sum(IFNULL(sisty_more,0)) sisty_more
        from (
            select sp.id sp_id,
            sp.sp_name,
            si.channel_name,
            sr.channelid,
            sum(IFNULL(sr.all_number,0)) all_number,
            sum(IFNULL(sr.all_number, 0))+sum(IFNULL(sr.submit_fail, 0))  number,
            sum(IFNULL(sr.submit_fail,0)) submit_fail,
            sum(IFNULL(sr.arrive_succ,0)) arrive_succ,
            sum(IFNULL(sr.arrive_fail,0)) arrive_fail,
            Round( sum( IFNULL( sr.arrive_succ, 0 ) )/ sum( IFNULL( sr.all_number, 0 ) + IFNULL( sr.submit_fail, 0 ))* 100, 2 ) sucess_rate,
            sum(sr.five_less) five_less,
            sum(sr.ten_less) ten_less,
            sum(sr.ten_to_twenty) ten_to_twenty,
            sum(sr.twenty_to_thirty) twenty_to_thirty,
            sum(sr.thirty_to_sisty) thirty_to_sisty,
            sum(sr.five_min) five_min,
            sum(sr.ten_min) ten_min,
            sum(sr.sisty_more) sisty_more  /* 25.04.27 调整为十分钟以上数据*/
            from sms_sp_delay_ratio sr, sms_sp_info sp,sms_send_channel_info si
            where sr.spid = sp.id and si.id=sr.channelid
            <if test="sp_name!=null and sp_name!=''">
                and sp.sp_name like CONCAT('%',#{sp_name},'%')
            </if>
            <if test="salerList != null and salerList.size() > 0">
                and sp.sp_saler in
                <foreach collection="salerList" item="item" open="(" separator="," close=")">
                    '${item}'
                </foreach>
            </if>
            <if test="sp_saler!=null and sp_saler!=''">
                and sp.sp_saler =#{sp_saler}
            </if>
            <if test="channelid!=null and channelid>=0">
                and si.id = #{channelid}
            </if>
            <if test="sp_id!=null and sp_id>0">
                and sr.spid=#{sp_id}
            </if>
            <if test="createTime!=null and createTime!=''">
                and sr.createtime&gt;=str_to_date(#{createTime},'%Y-%m-%d %H:%i')
            </if>
            <if test="createTime1!=null and createTime1!=''">
                and
                sr.createtime&lt;str_to_date(#{createTime1},'%Y-%m-%d %H:%i')
            </if>
            group by sp.id, sp.sp_name,si.channel_name,sr.channelid,date_format( sr.createtime, '%Y-%m-%d %H:%i' )
            order by date_format( sr.createtime, '%Y-%m-%d %H:%i' ) desc, number desc
            ) m
        <where>
            <if test="sucess_rate!= null and sucess_rate >= 0">
                m.sucess_rate >= #{sucess_rate}
            </if>
            <if test="less_sucess_rate!= null and less_sucess_rate >= 0">
                m.sucess_rate &lt; #{less_sucess_rate}
            </if>
        </where>
    </select>

    <select id="getSpDelayDaySum" resultType="cn.roadm.bo.DelayRatio">
        select
        sum(all_number) all_number,
        sum(submit_fail) submit_fail,
        sum(arrive_succ) arrive_succ,
        sum(arrive_fail) arrive_fail,
        sum(IFNULL(five_less,0)) five_less,
        sum(IFNULL(ten_less,0)) ten_less,
        sum(IFNULL(ten_to_twenty,0)) ten_to_twenty,
        sum(IFNULL(twenty_to_thirty,0)) twenty_to_thirty,
        sum(IFNULL(thirty_to_sisty,0)) thirty_to_sisty,
        sum(IFNULL(five_min,0)) five_min,
        sum(IFNULL(ten_min,0)) ten_min,
        sum(IFNULL(sisty_more,0)) sisty_more
        from (
            select sp.id sp_id,
            sp.sp_name,
            sum(IFNULL(ss.succ,0)) all_number,
            sum(IFNULL(ss.succ, 0))+sum(IFNULL(ss.fail, 0))  number,
            sum(IFNULL(ss.fail,0)) submit_fail,
            sum(IFNULL(sdd.arrive_succ,0)) arrive_succ,
            sum(IFNULL(sdd.arrive_fail,0)) arrive_fail,
            Round( sum( IFNULL( sdd.arrive_succ, 0 ) )/ sum( IFNULL( ss.succ, 0 ) + IFNULL( ss.fail, 0 ))* 100, 2 ) sucess_rate,
            sum(sdd.five_less) five_less,
            sum(sdd.ten_less) ten_less,
            sum(sdd.ten_to_twenty) ten_to_twenty,
            sum(sdd.twenty_to_thirty) twenty_to_thirty,
            sum(sdd.thirty_to_sisty) thirty_to_sisty,
            sum(sdd.five_min) five_min,
            sum(sdd.ten_min) ten_min,
            sum(sdd.sisty_more) sisty_more
            from sms_sp_delay_day sdd
            inner join sms_sp_info sp on sdd.spid = sp.id
            inner join sms_sp_summary ss on sdd.spid = ss.spid
            and DATE(sdd.CREATETIME) = DATE(ss.stat_time)
            <where>
                <if test="sp_name!=null and sp_name!=''">
                    and sp.sp_name like CONCAT('%',#{sp_name},'%')
                </if>
                <if test="salerList != null and salerList.size() > 0">
                    and sp.sp_saler in
                    <foreach collection="salerList" item="item" open="(" separator="," close=")">
                        '${item}'
                    </foreach>
                </if>
                <if test="sp_saler!=null and sp_saler!=''">
                    and sp.sp_saler =#{sp_saler}
                </if>
                <if test="sp_id!=null and sp_id>0">
                    and sdd.spid=#{sp_id}
                </if>
                <if test="createTime!=null and createTime!=''">
                    and DATE(sdd.createtime) &gt;= DATE(#{createTime})
                </if>
                <if test="createTime1!=null and createTime1!=''">
                    and DATE(sdd.createtime) &lt;= DATE(#{createTime1})
                </if>
            </where>
            group by sp.id, sp.sp_name,date_format( sdd.createtime, '%Y-%m-%d' )
            order by date_format( sdd.createtime, '%Y-%m-%d' ) desc, number desc
            ) m
        <where>
            <if test="sucess_rate!= null and sucess_rate >= 0">
                and m.sucess_rate >= #{sucess_rate}
            </if>
            <if test="less_sucess_rate!= null and less_sucess_rate >= 0">
                and m.sucess_rate &lt;= #{less_sucess_rate}
            </if>
        </where>
    </select>
    
    <select id="getInterSpDelayMinRatioSum" resultType="cn.roadm.bo.DelayRatio">
        select
        sum(all_number) all_number,
        sum(submit_fail) submit_fail,
        sum(arrive_succ) arrive_succ,
        sum(arrive_fail) arrive_fail,
        sum(IFNULL(five_less,0)) five_less,
        sum(IFNULL(ten_less,0)) ten_less,
        sum(IFNULL(ten_to_twenty,0)) ten_to_twenty,
        sum(IFNULL(twenty_to_thirty,0)) twenty_to_thirty,
        sum(IFNULL(thirty_to_sisty,0)) thirty_to_sisty,
        sum(IFNULL(sisty_more,0)) sisty_more
        from (
            select sp.id sp_id,
            sp.sp_name,
            si.channel_name,
            sr.channelid,
            sum(IFNULL(sr.all_number,0)) all_number,
            sum(IFNULL(sr.all_number, 0))+sum(IFNULL(sr.submit_fail, 0))  number,
            sum(IFNULL(sr.submit_fail,0)) submit_fail,
            sum(IFNULL(sr.arrive_succ,0)) arrive_succ,
            sum(IFNULL(sr.arrive_fail,0)) arrive_fail,
            Round( sum( IFNULL( sr.arrive_succ, 0 ) )/ sum( IFNULL( sr.all_number, 0 ) + IFNULL( sr.submit_fail, 0 ))* 100, 2 ) sucess_rate,
            sum(sr.five_less) five_less,
            sum(sr.ten_less) ten_less,
            sum(sr.ten_to_twenty) ten_to_twenty,
            sum(sr.twenty_to_thirty) twenty_to_thirty,
            sum(sr.thirty_to_sisty) thirty_to_sisty,
            sum(sr.sisty_more) sisty_more
            from inter_sms_sp_delay_ratio sr, sms_sp_info sp,sms_send_channel_info si
            where sr.spid = sp.id and si.id=sr.channelid
            <if test="sp_name!=null and sp_name!=''">
                and sp.sp_name like CONCAT('%',#{sp_name},'%')
            </if>
            <if test="salerList != null and salerList.size() > 0">
                and sp.sp_saler in
                <foreach collection="salerList" item="item" open="(" separator="," close=")">
                    '${item}'
                </foreach>
            </if>
            <if test="sp_saler!=null and sp_saler!=''">
                and sp.sp_saler =#{sp_saler}
            </if>
            <if test="channelid!=null and channelid>=0">
                and si.id = #{channelid}
            </if>
            <if test="sp_id!=null and sp_id>0">
                and sr.spid=#{sp_id}
            </if>
            <if test="createTime!=null and createTime!=''">
                and sr.createtime&gt;=str_to_date(#{createTime},'%Y-%m-%d %H:%i')
            </if>
            <if test="createTime1!=null and createTime1!=''">
                and
                sr.createtime&lt;str_to_date(#{createTime1},'%Y-%m-%d %H:%i')
            </if>
            group by sp.id, sp.sp_name,si.channel_name,sr.channelid,date_format( sr.createtime, '%Y-%m-%d %H:%i' )
            order by date_format( sr.createtime, '%Y-%m-%d %H:%i' ) desc, number desc
            ) m
        <where>
            <if test="sucess_rate!= null and sucess_rate >= 0">
                m.sucess_rate >= #{sucess_rate}
            </if>
        </where>
    </select>

    <select id="exportSpDelayMinRatioList" resultType="java.util.Map">
        select sp.id sp_id,
        sp.sp_name,
        si.channel_name,
        sr.channelid,
        sum(IFNULL(sr.all_number,0) + IFNULL(sr.submit_fail, 0)) submit_total,
        sum(IFNULL(sr.all_number,0)) submit_succ,
        sum(IFNULL(sr.submit_fail,0)) submit_fail,
        sum(IFNULL(sr.arrive_succ,0)) arrive_succ,
        sum(IFNULL(sr.arrive_fail,0)) arrive_fail,
        CONCAT(CONCAT(sum(sr.five_less), '(' ),(CONCAT(Round(sum(sr.five_less)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) five_less,
        CONCAT(CONCAT(sum(sr.ten_less), '(' ),(CONCAT(Round(sum(sr.ten_less)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) ten_less,
        CONCAT(CONCAT(sum(sr.ten_to_twenty), '(' ),(CONCAT(Round(sum(sr.ten_to_twenty)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) ten_to_twenty,
        CONCAT(CONCAT(sum(sr.twenty_to_thirty), '(' ),(CONCAT(Round(sum(sr.twenty_to_thirty)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) twenty_to_thirty,
        CONCAT(CONCAT(sum(sr.thirty_to_sisty), '(' ),(CONCAT(Round(sum(sr.thirty_to_sisty)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) thirty_to_sisty,
        CONCAT(CONCAT(sum(sr.five_min), '(' ),(CONCAT(Round(sum(sr.five_min)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) five_min,
        CONCAT(CONCAT(sum(sr.ten_min), '(' ),(CONCAT(Round(sum(sr.ten_min)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) ten_min,
        CONCAT(CONCAT(sum(sr.sisty_more), '(' ),(CONCAT(Round(sum(sr.sisty_more)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) sisty_more, /* 25.04.27 调整为十分钟以上数据*/
        date_format(sr.createtime,'%Y-%m-%d %H:%i') createTime
        from sms_sp_delay_ratio sr, sms_sp_info sp,sms_send_channel_info si
        where sr.spid = sp.id and si.id=sr.channelid

        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="channel_name!=null and channel_name!=''">
            and si.channel_name like CONCAT('%',#{channel_name},'%')
        </if>
        <if test="sp_id!=null and sp_id>0">
            and sr.spid=#{sp_id}
        </if>
        <if test="createTime!=null and createTime!=''">
            and sr.createtime&gt;=str_to_date(#{createTime},'%Y-%m-%d %H:%i')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            sr.createtime&lt;str_to_date(#{createTime1},'%Y-%m-%d %H:%i')
        </if>
        group by sp.id, sp.sp_name,si.channel_name,sr.channelid,date_format( sr.createtime, '%Y-%m-%d %H:%i' )
        order by date_format( sr.createtime, '%Y-%m-%d %H:%i' ) desc,submit_total desc
    </select>

    <select id="exportSpDelayDayList" resultType="java.util.Map">
        select sp.id sp_id,
        sp.sp_name,
        sum(IFNULL(ss.succ,0) + IFNULL(ss.fail, 0)) submit_total,
        sum(IFNULL(ss.succ,0)) submit_succ,
        sum(IFNULL(ss.fail,0)) submit_fail,
        sum(IFNULL(sdd.arrive_succ,0)) arrive_succ,
        sum(IFNULL(sdd.arrive_fail,0)) arrive_fail,
        CONCAT(CONCAT(sum(sdd.five_less), '(' ),(CONCAT(Round(sum(sdd.five_less)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) five_less,
        CONCAT(CONCAT(sum(sdd.ten_less), '(' ),(CONCAT(Round(sum(sdd.ten_less)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) ten_less,
        CONCAT(CONCAT(sum(sdd.ten_to_twenty), '(' ),(CONCAT(Round(sum(sdd.ten_to_twenty)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) ten_to_twenty,
        CONCAT(CONCAT(sum(sdd.twenty_to_thirty), '(' ),(CONCAT(Round(sum(sdd.twenty_to_thirty)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) twenty_to_thirty,
        CONCAT(CONCAT(sum(sdd.thirty_to_sisty), '(' ),(CONCAT(Round(sum(sdd.thirty_to_sisty)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) thirty_to_sisty,
        CONCAT(CONCAT(sum(sdd.five_min), '(' ),(CONCAT(Round(sum(sdd.five_min)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) five_min,
        CONCAT(CONCAT(sum(sdd.ten_min), '(' ),(CONCAT(Round(sum(sdd.ten_min)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) ten_min,
        CONCAT(CONCAT(sum(sdd.sisty_more), '(' ),(CONCAT(Round(sum(sdd.sisty_more)/sum(IFNULL( sdd.arrive_succ, 0 ) + IFNULL( sdd.arrive_fail, 0 ))*100,2), '%)' ))) sisty_more, /* 25.04.27 调整为十分钟以上数据*/
        date_format(sdd.createtime,'%Y-%m-%d') createTime
        from
            sms_sp_delay_day sdd
            inner join sms_sp_info sp on sdd.spid = sp.id
            inner join sms_sp_summary ss on sdd.spid = ss.spid
            and DATE(sdd.CREATETIME) = DATE(ss.stat_time)
        <where>
            <if test="sp_name!=null and sp_name!=''">
                and sp.sp_name like CONCAT('%',#{sp_name},'%')
            </if>
            <if test="sp_id!=null and sp_id>0">
                and sdd.spid=#{sp_id}
            </if>
            <if test="createTime!=null and createTime!=''">
                and DATE(sdd.createtime) &gt;= DATE(#{createTime})
            </if>
            <if test="createTime1!=null and createTime1!=''">
                and DATE(sdd.createtime) &lt;= DATE(#{createTime1})
            </if>
        </where>
        group by sp.id, sp.sp_name,date_format( sdd.createtime, '%Y-%m-%d' )
        order by date_format( sdd.createtime, '%Y-%m-%d' ) desc,submit_total desc
    </select>
    
    <select id="exportInterSpDelayMinRatioList" resultType="java.util.Map">
        select sp.id sp_id,
        sp.sp_name,
        si.channel_name,
        sr.channelid,
        sum(IFNULL(sr.all_number,0) + IFNULL(sr.submit_fail, 0)) submit_total,
        sum(IFNULL(sr.all_number,0)) submit_succ,
        sum(IFNULL(sr.submit_fail,0)) submit_fail,
        sum(IFNULL(sr.arrive_succ,0)) arrive_succ,
        sum(IFNULL(sr.arrive_fail,0)) arrive_fail,
        CONCAT(CONCAT(sum(sr.five_less), '(' ),(CONCAT(Round(sum(sr.five_less)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) five_less,
        CONCAT(CONCAT(sum(sr.ten_less), '(' ),(CONCAT(Round(sum(sr.ten_less)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) ten_less,
        CONCAT(CONCAT(sum(sr.ten_to_twenty), '(' ),(CONCAT(Round(sum(sr.ten_to_twenty)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) ten_to_twenty,
        CONCAT(CONCAT(sum(sr.twenty_to_thirty), '(' ),(CONCAT(Round(sum(sr.twenty_to_thirty)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) twenty_to_thirty,
        CONCAT(CONCAT(sum(sr.thirty_to_sisty), '(' ),(CONCAT(Round(sum(sr.thirty_to_sisty)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) thirty_to_sisty,
        CONCAT(CONCAT(sum(sr.sisty_more), '(' ),(CONCAT(Round(sum(sr.sisty_more)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) sisty_more,
        date_format(sr.createtime,'%Y-%m-%d %H:%i') createTime
        from inter_sms_sp_delay_ratio sr, sms_sp_info sp,sms_send_channel_info si
        where sr.spid = sp.id and si.id=sr.channelid

        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="channelid!=null and channelid>=0">
            and si.id = #{channelid}
        </if>
        <if test="channel_name!=null and channel_name!=''">
            and si.channel_name like CONCAT('%',#{channel_name},'%')
        </if>
        <if test="sp_id!=null and sp_id>0">
            and sr.spid=#{sp_id}
        </if>
        <if test="createTime!=null and createTime!=''">
            and sr.createtime&gt;=str_to_date(#{createTime},'%Y-%m-%d %H:%i')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and
            sr.createtime&lt;str_to_date(#{createTime1},'%Y-%m-%d %H:%i')
        </if>
        group by sp.id, sp.sp_name,si.channel_name,sr.channelid,date_format( sr.createtime, '%Y-%m-%d %H:%i' )
        order by date_format( sr.createtime, '%Y-%m-%d %H:%i' ) desc,submit_total desc
    </select>

    <select id="listSpDelayMinRatio" resultType="cn.roadm.bo.DelayRatio">
        select
        ${sumField} `time`,
        sum(IFNULL( sr.all_number, 0 )) + sum(IFNULL( sr.submit_fail, 0 )) sum_number,
        sum(IFNULL(sr.all_number,0)) all_number,
        sum(IFNULL(sr.submit_fail,0)) submit_fail,
        sum(IFNULL(sr.arrive_succ,0)) arrive_succ,
        sum(IFNULL(sr.arrive_fail,0)) arrive_fail,
        Round( sum( IFNULL( sr.arrive_succ, 0 ) )/ sum( IFNULL( sr.all_number, 0 ) + IFNULL( sr.submit_fail, 0 ))* 100, 2 ) sucess_rate,
        Round( sum( IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 )) / sum( IFNULL( sr.all_number, 0 ) + IFNULL( sr.submit_fail, 0 ))* 100,2) report_rate
        from sms_sp_delay_ratio sr, sms_sp_info sp,sms_send_channel_info si
        where sr.spid = sp.id and si.id=sr.channelid
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="channelid!=null and channelid>=0">
            and si.id = #{channelid}
        </if>
        <if test="sp_id!=null and sp_id>0">
            and sr.spid=#{sp_id}
        </if>
        <if test="createTime!=null and createTime!=''">
            and sr.createtime&gt;=str_to_date(#{createTime},'%Y-%m-%d %H:%i')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and sr.createtime&lt;str_to_date(#{createTime1},'%Y-%m-%d %H:%i')
        </if>
        group by `time`
        order by `time` desc

    </select>
    
    
    <select id="listInterSpDelayMinRatio" resultType="cn.roadm.bo.DelayRatio">
        select
        ${sumField} `time`,
        sum(IFNULL( sr.all_number, 0 )) + sum(IFNULL( sr.submit_fail, 0 )) sum_number,
        sum(IFNULL(sr.all_number,0)) all_number,
        sum(IFNULL(sr.submit_fail,0)) submit_fail,
        sum(IFNULL(sr.arrive_succ,0)) arrive_succ,
        sum(IFNULL(sr.arrive_fail,0)) arrive_fail,
        Round( sum( IFNULL( sr.arrive_succ, 0 ) )/ sum( IFNULL( sr.all_number, 0 ) + IFNULL( sr.submit_fail, 0 ))* 100, 2 ) sucess_rate,
        Round( sum( IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 )) / sum( IFNULL( sr.all_number, 0 ) + IFNULL( sr.submit_fail, 0 ))* 100,2) report_rate
        from inter_sms_sp_delay_ratio sr, sms_sp_info sp,sms_send_channel_info si
        where sr.spid = sp.id and si.id=sr.channelid
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="channelid!=null and channelid>=0">
            and si.id = #{channelid}
        </if>
        <if test="sp_id!=null and sp_id>0">
            and sr.spid=#{sp_id}
        </if>
        <if test="createTime!=null and createTime!=''">
            and sr.createtime&gt;=str_to_date(#{createTime},'%Y-%m-%d %H:%i')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and sr.createtime&lt;str_to_date(#{createTime1},'%Y-%m-%d %H:%i')
        </if>
        group by `time`
        order by `time` desc

    </select>

    <select id="listSpDelayMinPieRatio" resultType="cn.roadm.bo.DelayRatio">
        select
        IFNULL( sr.five_less, 0 ) fiveLess,
        IFNULL( sr.ten_less, 0 ) tenLess,
        IFNULL( sr.ten_to_twenty, 0 ) tenToTwenty,
        IFNULL( sr.twenty_to_thirty, 0 ) twentyToThirty,
        IFNULL( sr.thirty_to_sisty, 0 ) thirtyToSisty,
        IFNULL( sr.sisty_more, 0 ) sistyMore
        from sms_sp_delay_ratio sr, sms_sp_info sp,sms_send_channel_info si
        where sr.spid = sp.id and si.id=sr.channelid
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="channelid!=null and channelid>=0">
            and si.id = #{channelid}
        </if>
        <if test="sp_id!=null and sp_id>0">
            and sr.spid=#{sp_id}
        </if>
        <if test="createTime!=null and createTime!=''">
            and sr.createtime&gt;=str_to_date(#{createTime},'%Y-%m-%d %H:%i')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and sr.createtime&lt;str_to_date(#{createTime1},'%Y-%m-%d %H:%i')
        </if>
    </select>
    
    
    <select id="listInterSpDelayMinPieRatio" resultType="cn.roadm.bo.DelayRatio">
        select
        IFNULL( sr.five_less, 0 ) fiveLess,
        IFNULL( sr.ten_less, 0 ) tenLess,
        IFNULL( sr.ten_to_twenty, 0 ) tenToTwenty,
        IFNULL( sr.twenty_to_thirty, 0 ) twentyToThirty,
        IFNULL( sr.thirty_to_sisty, 0 ) thirtyToSisty,
        IFNULL( sr.sisty_more, 0 ) sistyMore
        from inter_sms_sp_delay_ratio sr, sms_sp_info sp,sms_send_channel_info si
        where sr.spid = sp.id and si.id=sr.channelid
        <if test="sp_name!=null and sp_name!=''">
            and sp.sp_name like CONCAT('%',#{sp_name},'%')
        </if>
        <if test="channelid!=null and channelid>=0">
            and si.id = #{channelid}
        </if>
        <if test="sp_id!=null and sp_id>0">
            and sr.spid=#{sp_id}
        </if>
        <if test="createTime!=null and createTime!=''">
            and sr.createtime&gt;=str_to_date(#{createTime},'%Y-%m-%d %H:%i')
        </if>
        <if test="createTime1!=null and createTime1!=''">
            and sr.createtime&lt;str_to_date(#{createTime1},'%Y-%m-%d %H:%i')
        </if>
    </select>
    
    
    
    
    <select id="listPageInterSpDelayMinRatio" resultType="cn.roadm.bo.DelayRatio">
        select
        <if test="typeName !=null and typeName!='' and typeName == 'sp'">
            sp_id,
            sp_name,
        </if>
        <if test="typeName !=null and typeName!='' and typeName == 'channelid'">
            channel_name,
            channelid,
        </if>
        <if test="typeName !=null and typeName!='' and typeName == 'spAndChannel'">
            sp_id,
            sp_name,
            channel_name,
            channelid,
        </if>
        all_number,
        submit_fail,
        arrive_succ,
        arrive_fail,
        five_less,
        ten_less,
        ten_to_twenty,
        twenty_to_thirty,
        thirty_to_sisty,
        sisty_more,
        createtime
        from (
            select
            <if test="typeName !=null and typeName!='' and typeName == 'sp'">
                sp.id sp_id,
                sp.sp_name,
            </if>
            <if test="typeName !=null and typeName!='' and typeName == 'channelid'">
                si.channel_name,
                sr.channelid,
            </if>
            <if test="typeName !=null and typeName!='' and typeName == 'spAndChannel'">
                sp.id sp_id,
                sp.sp_name,
                si.channel_name,
                sr.channelid,
            </if>
            sum(IFNULL(sr.all_number,0)) all_number,
            sum(IFNULL(sr.all_number, 0))+sum(IFNULL(sr.submit_fail, 0))  number,
            sum(IFNULL(sr.submit_fail,0)) submit_fail,
            sum(IFNULL(sr.arrive_succ,0)) arrive_succ,
            sum(IFNULL(sr.arrive_fail,0)) arrive_fail,
            Round( sum( IFNULL( sr.arrive_succ, 0 ) )/ sum( IFNULL( sr.all_number, 0 ) + IFNULL( sr.submit_fail, 0 ))* 100, 2 ) sucess_rate,
            CONCAT(CONCAT(sum(sr.five_less), '(' ),(CONCAT(Round(sum(sr.five_less)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) five_less,
            CONCAT(CONCAT(sum(sr.ten_less), '(' ),(CONCAT(Round(sum(sr.ten_less)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) ten_less,
            CONCAT(CONCAT(sum(sr.ten_to_twenty), '(' ),(CONCAT(Round(sum(sr.ten_to_twenty)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) ten_to_twenty,
            CONCAT(CONCAT(sum(sr.twenty_to_thirty), '(' ),(CONCAT(Round(sum(sr.twenty_to_thirty)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) twenty_to_thirty,
            CONCAT(CONCAT(sum(sr.thirty_to_sisty), '(' ),(CONCAT(Round(sum(sr.thirty_to_sisty)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) thirty_to_sisty,
            CONCAT(CONCAT(sum(sr.sisty_more), '(' ),(CONCAT(Round(sum(sr.sisty_more)/sum(IFNULL( sr.arrive_succ, 0 ) + IFNULL( sr.arrive_fail, 0 ))*100,2), '%)' ))) sisty_more,
            date_format(sr.createtime,'%Y-%m-%d %H:%i') createtime
            from inter_sms_sp_delay_ratio sr, sms_sp_info sp,sms_send_channel_info si
            where sr.spid = sp.id and si.id=sr.channelid
            <if test="sp_name!=null and sp_name!=''">
              and sp.sp_name like CONCAT('%',#{sp_name},'%')
            </if>
            <if test="salerList != null and salerList.size() > 0">
                and sp.sp_saler in
                <foreach collection="salerList" item="item" open="(" separator="," close=")">
                    '${item}'
                </foreach>
            </if>
            <if test="sp_saler!=null and sp_saler!=''">
                and sp.sp_saler =#{sp_saler}
            </if>
            <if test="channelid!=null and channelid>=0">
                and si.id = #{channelid}
            </if>
            <if test="channel_name!=null and channel_name!=''">
                and si.channel_name like CONCAT('%', #{channel_name}, '%')
            </if>
            <if test="sp_id!=null and sp_id>0">
                and sr.spid=#{sp_id}
            </if>
            <if test="createTime!=null and createTime!=''">
                and sr.createtime&gt;=str_to_date(#{createTime},'%Y-%m-%d %H:%i')
            </if>
            <if test="createTime1!=null and createTime1!=''">
                and
                sr.createtime&lt;str_to_date(#{createTime1},'%Y-%m-%d %H:%i')
            </if>
            group by
            <if test="typeName !=null and typeName!='' and typeName == 'sp'">
                sp.id,
                sp.sp_name,
            </if>
            <if test="typeName !=null and typeName!='' and typeName == 'channelid'">
                si.channel_name,
                sr.channelid,
            </if>
            <if test="typeName !=null and typeName!='' and typeName == 'spAndChannel'">
                sp.id,
                sp.sp_name,
                si.channel_name,
                sr.channelid,
            </if>
            date_format( sr.createtime, '%Y-%m-%d %H:%i' )
            order by date_format( sr.createtime, '%Y-%m-%d %H:%i' ) desc,number desc
        ) m
        <where>
            <if test="sucess_rate!= null and sucess_rate >= 0">
                m.sucess_rate >= #{sucess_rate}
            </if>
        </where>
    </select>
    
    
    
</mapper>