Exemple #1
0
def rate_i15(region_id, apn):
    dic = {}
    mysql = Mysql()
    mysql.query('select count(1) from wl_c_ps_rate where count_0 = 1')
    dic['count'] = mysql.result()
    mysql.query(
        'select apn,time_start,time_end,count_0 from wl_c_ps_rate where count_0 = 1 limit 10'
    )
    dic['data'] = mysql.result()
    mysql.close()
    result_json = json.dumps(dic, cls=CJsonEncoder)
    return result_json
Exemple #2
0
def city_query(dict1):
    dic = {}
    mysql = Mysql()
    if dict1['city'] == 'all':
        mysql.query('select rb_id,rb_name from sys_region_base')
    else:
        mysql.query('select rb_id,rb_name from sys_region_base where rb_name = "%s"' % dict1['city'])
    dic['data'] = mysql.result()
    mysql.close()
    dic['status'] = '0'
    dic['fields'] = 'region_id,地市'
    result_json = json.dumps(dic,cls=CJsonEncoder)
    return result_json
Exemple #3
0
def rate_sort(dict1):
    dict_tb = {'15':'wl_c_pdp_make_i15','60':'wl_c_pdp_make_h1','1440':'wl_c_pdp_make_d1'}
    dic = {}
    mysql = Mysql()
    mysql.query('select rb_name from sys_region_base where rb_id = %s' % dict1['region_id'])
    dic['city'] = mysql.result()
    dic['status'] = '0'
    dic['fields'] = '结束时间,apn,激活成功率'
    if dict1['num'] == '0':
        mysql.query('select time_end,apn,request_rate from %s \
        where gtp_cause = 128 and region_id = %s and time_end = "%s" order by request_rate %s'\
         % (dict_tb.get(dict1['type']),dict1['region_id'],dict1['time_end'],dict1['sort']))
    else:
        mysql.query('select time_end,apn,request_rate from %s \
        where gtp_cause = 128 and region_id = %s and time_end = "%s" order by request_rate %s limit %s'\
         % (dict_tb.get(dict1['type']),dict1['region_id'],dict1['time_end'],dict1['sort'],dict1['num']))
    dic['data'] = mysql.result()
    mysql.close()
    result_json = json.dumps(dic,cls=CJsonEncoder)
    return result_json
Exemple #4
0
def traffic_sort(dict1):
    dict_tb = {'15':'wl_c_traffic_make_i15','60':'wl_c_traffic_make_h1','1440':'wl_c_traffic_make_d1'}
    dic = {}
    mysql = Mysql()
    mysql.query('select rb_name from sys_region_base where rb_id = %s' % dict1['region_id'])
    dic['city'] = mysql.result()
    dic['status'] = '0'
    dic['fields'] = '结束时间,apn,上行流量,下行流量,总流量'
    if dict1['num'] == '0':
        mysql.query('select time_end,apn,sum_ul,sum_dl,sum_total from %s \
        where region_id = %s and time_end = "%s" order by active_total %s'\
         % (dict_tb.get(dict1['type']),dict1['region_id'],dict1['time_end'],dict1['sort']))
    else:
        mysql.query('select time_end,apn,sum_ul,sum_dl,sum_total from %s \
        where region_id = %s and time_end = "%s" order by sum_total %s limit %s'\
         % (dict_tb.get(dict1['type']),dict1['region_id'],dict1['time_end'],dict1['sort'],dict1['num']))
    dic['data'] = mysql.result()
    mysql.close()
    result_json = json.dumps(dic,cls=CJsonEncoder)
    return result_json
Exemple #5
0
def active_query(dict1):
    dict_tb = {'15':'wl_c_active_make_i15','60':'wl_c_active_make_h1','1440':'wl_c_active_make_d1'}
    dic = {}
    mysql = Mysql()
    mysql.query('select rb_name from sys_region_base where rb_id = %s' % dict1['region_id'])
    dic['city'] = mysql.result()
    dic['status'] = '0'
    dic['fields'] = '结束时间,活跃用户数'
    if 'time_start' in dict1.keys():
        mysql.query('select time_end,active_total from %s \
        where  region_id = %s and apn = "%s" \
        and time_end >= "%s" and time_end <= "%s"' \
        % (dict_tb.get(dict1['type']),dict1['region_id'],dict1['apn'],dict1['time_start'],dict1['time_end']))
    else:
        mysql.query('select time_end,active_total from %s \
        where region_id = %s and apn = "%s" \
        and time_end = "%s"' % (dict_tb.get(dict1['type']),dict1['region_id'],dict1['apn'],dict1['time_end']))
    dic['data'] = mysql.result()
    mysql.close()
    result_json = json.dumps(dic,cls=CJsonEncoder)
    return result_json