Exemplo n.º 1
0
    def test_034_api_78dk_platform_om_bd_bdTj_date(self):
        """
        BD统计  bd_state_enabled
        :return:
        """

        res = json.loads(PlatformAction.test_api_78dk_platform_om_bd_bdTj(bdstate='bd_state_unknown',
            enddate=TimeFormat.get_day_around(30), pagecurrent=1, pagesize=10, searchwhere='',
            startdate=TimeFormat.get_day_around(-30)))
        Assertion.verity(res['code'], '10000')
        Assertion.verity(res['msg'], '成功')
Exemplo n.º 2
0
def get_data(times):
    start_time = tianxing_etl['json_data']['data']['report_time']
    start = start_time.split(' ')[0]
    if times == '1' or times == 1:
        end = TimeFormat.get_day_around(-27, start)
    elif times == '3' or times == 3:
        end = TimeFormat.get_month_ago(2, start_time)
    elif times == '6' or times == 6:
        end = TimeFormat.get_month_ago(5, start_time)
    elif times == '7' or times == 7:
        end = TimeFormat.get_day_around(-6, start)
    elif times == '12' or times == 12:
        end = TimeFormat.get_month_ago(11, start_time)
    else:
        end = TimeFormat.get_month_ago(8, start_time)
    return end
Exemplo n.º 3
0
def get_time_step2(time_day, time_step):
    # 前开后闭
    if time_step == '早晨':
        start_time, end_time = time_day + " " + "5:30:00", time_day + " " + "11:30:00"
    elif time_step == '中午':
        start_time, end_time = time_day + " " + "11:30:00", time_day + " " + "13:30:00"
    elif time_step == '下午':
        start_time, end_time = time_day + " " + "13:30:00", time_day + " " + "17:30:00"
    elif time_step == '晚上':
        start_time, end_time = time_day + " " + "17:30:00", time_day + " " + "23:30:00"
    elif time_step == '凌晨':
        start_time1, end_time1 = time_day + " " + "23:30:00", time_day + " " + "23:59:59"
        start_time2, end_time2 = time_day + " " + "00:00:00", time_day + " " + "05:30:00"
        start_time, end_time = random.choice(
            ((start_time1, end_time1), (start_time2, end_time2)))
    else:
        start_time, end_time = time_day + " " + "13:30:00", time_day + " " + "17:30:00"
    e_time = TimeFormat.random_time(start_time, end_time)
    e_day, e_hms = e_time.split(' ')
    now = TimeFormat.getnow()
    n_hms = now.split(' ')[-1]
    e_time_num = int(TimeFormat.string_toTimestamp_13(e_time))
    n_time_num = int(TimeFormat.string_toTimestamp_13(e_day + ' ' + n_hms))
    if e_time_num <= n_time_num:
        e_time = TimeFormat.get_day_around(1, e_day) + ' ' + e_hms
    return e_time
Exemplo n.º 4
0
 def test_005_device_tracklist(self):
     """
     Time       :2019-04-03
     author     : 罗林
     desc       :获取设备轨迹
     """
     deviceid = cls.get_device_id()
     rs1 = cla.test_device_tracklist(starttime=tf.string_toTimestamp_10(tf.get_day_around(-7) + " 00:00:00"),
                                     endtime=tf.get_now_time(), positiontype=-1, deviceid=deviceid)
     ass.verity(json.loads(rs1)['message'], '请求成功')
Exemplo n.º 5
0
def get_time_step07(time_day):
    # 前开后闭
    start_time, end_time = time_day + " " + "00:00:00", time_day + " " + "07:00:00"
    e_time = TimeFormat.random_time(start_time, end_time)
    e_day, e_hms = e_time.split(' ')
    now = TimeFormat.getnow()
    n_hms = now.split(' ')[-1]
    e_time_num = int(TimeFormat.string_toTimestamp_13(e_time))
    n_time_num = int(TimeFormat.string_toTimestamp_13(e_day + ' ' + n_hms))
    if e_time_num <= n_time_num:
        e_time = TimeFormat.get_day_around(1, e_day) + ' ' + e_hms
    return e_time
Exemplo n.º 6
0
def get_days(month, premise, params):
    """
    几月距离今天的天数
    :param month:  几月
    :param premise:  请求参数
    :param params:  请求参数
    :return:
    """
    calls_items = list()
    for items in params['calls']:
        calls_items.extend(items['items'])
    calls_days = list()
    if premise == 'no_dial_day':
        dial_calls_days = list(
            filter(lambda x: x['dial_type'] == 'dial', calls_items))
        calls_days = [t['time'] for t in dial_calls_days]
    elif premise == 'no_call_day':
        calls_days = [t['time'] for t in calls_items]
    elif premise in ('power_off_day', 'continue_power_off_days'):
        calls_days = [t['time'] for t in calls_items]
        smses_items = list()
        for items in params['smses']:
            smses_items.extend(items['items'])
        smses_days = [
            '-'.join(t['time'].split('-')[:3]) + ' ' + t['time'].split('-')[-1]
            for t in smses_items
        ]
        calls_days.extend(smses_days)
    on_days = list(set(calls_days))
    now, times = TimeFormat.getnow().split(' ')
    now_time = TimeFormat.get_now_time_13()
    if month == '7':
        day = TimeFormat.get_day_around(-7)
    else:
        time_day = TimeFormat.get_month_ago(int(month))
        day = time_day.split(' ')[0]
    day_time = TimeFormat.string_toTimestamp_13(day + ' ' + times)
    days_num = len(
        list(
            filter(
                lambda x: day_time < int(TimeFormat.string_toTimestamp_13(x))
                <= now_time, on_days)))
    return str(TimeFormat.time_between_day(day, now) - days_num)
Exemplo n.º 7
0
def yys_modif(yys_data, modif_key, modif_value):
    """
    运营商json 数据修改
    :param yys_data: 运营商json 数据
    :param modif_key: 需要修改的key
    :param modif_value: 修改后的值
    :return: yys_data
    #key定义
    V03_1001 : 账户余额
    V03_1002 : 开户时长 #
    V03_1003 : 手机号是否实名认证 #
    V03_1004 : 黑中介分数 #
    V03_1005 : 直接联系人人数
    V03_1006 : 直接联系人中黑名单人数
    V03_1007 : 间接联系人中黑名单人数
    V03_1008 : 直接联系人中引起间接黑名单占比
    V03_1009 : 查询过该用户的相关企业数量
    V03_1010 : 电话号码注册过的相关企业数量
    V03_1011 : 申请人姓名+身份证号码是否出现在法院黑名单 #
    V03_1012 : 申请人姓名+身份证号码是否出现在金融机构黑名单 #
    V03_1013 : 申请人姓名+手机号码是否出现在金融机构黑名单 #
    V03_1014 : 近1月关机天数
    V03_1015 : 近3月关机天数
    V03_1016 : 近6月关机天数
    V03_1017 : 近1月连续3天以上关机次数
    V03_1018 : 近3月连续3天以上关机次数
    V03_1019 : 近6月连续3天以上关机次数
    V03_1020 : 近1月无通话天数
    V03_1021 : 近3月无通话天数
    V03_1022 : 近6月无通话天数 #
    V03_1023 : 近1月互通电话的号码数目
    V03_1024 : 近3月互通电话的号码数目 #
    V03_1025 : 近6月互通电话的号码数目 #
    V03_1026 : 与贷款公司近1月通话次数
    V03_1027 : 与贷款公司近3月通话次数
    V03_1028 : 与贷款公司近6月通话次数
    V03_1029 : 与贷款公司近1月通话时长
    V03_1030 : 与贷款公司近3月通话时长
    V03_1031 : 与贷款公司近6月通话时长
    V03_1032 : 与催收公司近1月通话次数
    V03_1033 : 与催收公司近3月通话次数
    V03_1034 : 与催收公司近6月通话次数
    V03_1035 : 与催收公司近1月通话时长
    V03_1036 : 与催收公司近3月通话时长
    V03_1037 : 与催收公司近6月通话时长
    V03_1038 : 近1月消费总金额
    V03_1039 : 近3月消费总金额
    V03_1040 : 近6月消费总金额
    V03_1041 : 近3月平均消费金额
    V03_1042 : 近6月平均消费金额
    V03_1043 : 近3月朋友圈数量
    V03_1044 : 近6月朋友圈数量
    V03_1045 : 通话详单
    V03_1046 : 朋友圈联系人top3列表
    V03_1047 : 夜间活动情况
    V03_1048 : 近3月朋友圈是否在本地
    V03_1049 : 近6月朋友圈是否在本地
    """
    try:
        if modif_key == 'V03_1002':
            # 开户时长(月)
            m_value = TimeFormat.get_day_around(
                FileUtils.str_to_num(str(modif_value)))
            LOGGER.info('V03_1002 修改值为{}'.format(m_value))
            yys_data["open_time"] = m_value
        elif modif_key == 'V03_1003':
            yys_data["state"] = modif_value  # 是否实名
        else:
            raise KeyError('the modif_key {} is error'.format(modif_key))
    except Exception as e:
        LOGGER.error(e)
    return yys_data
Exemplo n.º 8
0
def modif(data, modif_key, modif_value):
    """
    修改请求数据
    :param data: 请求数据
    :param modif_key:  修改请求数据参数
    :param modif_value: 修改值
    :return:
    carrier: 运营商类型 (联通、移动、电信)
    open_time: 开户时长 (天)
    sex:男,女
    age: 年龄
    total_fee:账期内所有费用
    web_fee:网络流量消费金额(分)
    voice_fee:通话消费金额(分)
    sms_fee:短信消费金额(分)
    extra_service_fee:增值业务消费金额(分)
    extra_fee:其它消费金额(分)
    base_fee:基础消费金额
    sms_cnt:短信次数 (数字)
    sms_fees:短信费用
    location:朋友圈中心城市
    peer_number:朋友联系数量
    location_type:号码类型;国内通话
    dial_type:主叫,被叫 DAIL,DAILED
    duration: 通话时长(秒)
    fee: 通话费用
    time: 通话时段 (早晨,上午,中午,下午,傍晚,晚上,凌晨,深夜)
        早晨(5:30:00-9:00:00)
        上午(9:00:00-11:30:00)
        中午(11:30:00-13:30:00)
        下午(13:30:00-17:30:00)
        傍晚(17:30:00-19:30:00)
        晚上(19:30:00-23:30:00)
        凌晨(23:30:00-01:30:00)
        深夜(01:30:00-05:30:00)
    time2: 通话时段
        早晨(5:30-11:30)
        中午(11:30-13:30)
        下午(13:30-17:30)
        晚上(17:30-23:30)
        凌晨(23:30-5:30)
    time3: 通话时段 0-7点,不用输入参数修改值
    total_size:通话次数
    bill_month:通话月份 (7,1,3,6)
    calls: 通话信息条数 (数字)
    """
    if re.sub('\s+', '', modif_value) == '':
        modif_value = 'null'
    if modif_key == 'carrier':
        # modif_value 输入 联通、移动、电信
        if modif_value in carriers.keys():
            modif_value = carriers[modif_value]
        data["carrier"] = modif_value
    elif modif_key == 'open_time':
        # 输入数字,距离当前时间的天数
        if modif_value.isdigit():
            modif_value = TimeFormat.get_day_around(-int(modif_value))
        data["open_time"] = modif_value
    elif modif_key == 'sex':
        # 输入男、女,自动生成 idcard
        idcard = list(data["idcard"])
        if modif_value == '女':
            v = random.choice('02468')
            idcard[16] = str(v)
            data["idcard"] = ''.join(idcard)
        elif modif_value == '男':
            v = random.choice('13579')
            idcard[16] = str(v)
            data["idcard"] = ''.join(idcard)
        else:
            data["idcard"] = modif_value
    elif modif_key == 'age':
        # 输入年龄,自动生成 idcard
        if modif_value.isdigit():
            idcard = list(data["idcard"])
            time_now = TimeFormat.getnow_day()
            year, month, day = time_now.split('-')
            y = int(year) - int(modif_value)
            idcard[6:14] = ''.join([str(y), month, day])
            data["idcard"] = ''.join(idcard)
        else:
            data["idcard"] = modif_value
    elif modif_key == 'city':
        data["city"] = modif_value
    elif modif_key == 'total_fee':
        data["bills"][0]["total_fee"] = modif_value
    elif modif_key == 'web_fee':
        data["bills"][0]["web_fee"] = modif_value
    elif modif_key == 'voice_fee':
        data["bills"][0]["voice_fee"] = modif_value
    elif modif_key == 'sms_fee':
        data["bills"][0]["sms_fee"] = modif_value
    elif modif_key == 'extra_service_fee':
        data["bills"][0]["extra_service_fee"] = modif_value
    elif modif_key == 'extra_fee':
        data["bills"][0]["extra_fee"] = modif_value
    elif modif_key == 'base_fee':
        data["bills"][0]["base_fee"] = modif_value
    elif modif_key == 'sms_cnt':
        # 输入数字, 自动生成对应数字的短信条数
        if modif_value.isdigit():
            sms = data['smses'][0]
            data['smses'] = [sms for _ in range(int(modif_value))]
        else:
            data['smses'] = []
    elif modif_key == 'sms_fees':
        data['smses'][0]['items'][0]['fee'] = modif_value
    elif modif_key == 'location':
        data["calls"][0]['items'][0]['location'] = modif_value
    elif modif_key == 'peer_number':
        data["calls"][0]['items'][0]['peer_number'] = modif_value
    elif modif_key == 'location_type':
        data["calls"][0]['items'][0]['location_type'] = modif_value
    elif modif_key == 'dial_type':
        # 输入 DAIL 或者 DAILED
        calls = data["calls"][0]
        call = copy.deepcopy(calls)
        call['items'][0]['dial_type'] = modif_value
        data["calls"][0] = call
    elif modif_key == 'duration':
        if modif_value.isdigit():
            modif_value = int(modif_value)
        data["calls"][0]['items'][0]['duration'] = modif_value
    elif modif_key == 'fee':
        data["calls"][0]['items'][0]['fee'] = modif_value
    elif modif_key == 'time':
        # 输入时间段
        #         早晨(5:30:00-9:00:00)
        #         上午(9:00:00-11:30:00)
        #         中午(11:30:00-13:30:00)
        #         下午(13:30:00-17:30:00)
        #         傍晚(17:30:00-19:30:00)
        #         晚上(19:30:00-23:30:00)
        #         凌晨(23:30:00-01:30:00)
        #         深夜(01:30:00-05:30:00)
        if modif_value in ('早晨', '上午', '中午', '下午', '傍晚', '晚上', '凌晨', '深夜'):
            sev_time = data["calls"][0]['items'][0]['time']
            sev_day = sev_time.split(' ')[0]
            data["calls"][0]['items'][0]['time'] = get_time_step(
                sev_day, modif_value)
        else:
            data["calls"][0]['items'][0]['time'] = modif_value
    elif modif_key == 'time2':
        # 输入时间段
        #         早晨(5:30-11:30)
        #         中午(11:30-13:30)
        #         下午(13:30-17:30)
        #         晚上(17:30-23:30)
        #         凌晨(23:30-5:30)
        if modif_value in ('早晨', '中午', '下午', '晚上', '凌晨'):
            sev_time = data["calls"][0]['items'][0]['time']
            sev_day = sev_time.split(' ')[0]
            data["calls"][0]['items'][0]['time'] = get_time_step2(
                sev_day, modif_value)
        else:
            data["calls"][0]['items'][0]['time'] = modif_value
    elif modif_key == 'time3':
        # 输入时间段, 不用输入修改参数值, 直接获取 0-7点
        sev_time = data["calls"][0]['items'][0]['time']
        sev_day = sev_time.split(' ')[0]
        data["calls"][0]['items'][0]['time'] = get_time_step07(sev_day)
    elif modif_key == 'total_size':
        if modif_value.isdigit():
            modif_value = int(modif_value)
        data["calls"][0]['total_size'] = modif_value
    elif modif_key == 'bill_month':
        # 输入修改的月份 7,1,3,6; 7代表7天,其余的都是月份
        times = data["calls"][0]['items'][0]['time']
        time_hmc = times.split(' ')[-1]
        if modif_value == '7':
            start_day = TimeFormat.get_day_around(-7)
            bill_month = '-'.join(start_day.split('-')[:2])
            month_start_date, month_end_date = TimeFormat.get_FirstAndLastDay_month(
                bill_month)
            e_time = start_day + ' ' + time_hmc
            e_time_num = int(TimeFormat.string_toTimestamp_13(e_time))
            n_hms = TimeFormat.getnow().split(' ')[-1]
            n_time_num = int(
                TimeFormat.string_toTimestamp_13(start_day + ' ' + n_hms))
            if e_time_num <= n_time_num:
                e_time = TimeFormat.get_day_around(1,
                                                   start_day) + ' ' + time_hmc
            data["calls"][0]['bill_month'] = bill_month
            data["calls"][0]['items'][0]['time'] = e_time
            data["smses"][0]['bill_month'] = bill_month
            data["smses"][0]['items'][0]['time'] = e_time.replace(' ', '-')
            data["bills"][0]['bill_month'] = bill_month
            data["bills"][0]['bill_start_date'] = month_start_date
            data["bills"][0]['bill_end_date'] = month_end_date
        elif modif_value in ('1', '3', '6'):
            month_day = TimeFormat.get_month_day_ago(int(modif_value))
            year, month, day = month_day.split('-')
            bill_month = year + '-' + month
            month_start_date, month_end_date = TimeFormat.get_FirstAndLastDay_month(
                bill_month)
            data["calls"][0]['bill_month'] = bill_month
            e_time = month_day + ' ' + time_hmc
            e_time_num = int(TimeFormat.string_toTimestamp_13(e_time))
            n_hms = TimeFormat.getnow().split(' ')[-1]
            n_time_num = int(
                TimeFormat.string_toTimestamp_13(month_day + ' ' + n_hms))
            if e_time_num <= n_time_num:
                e_time = TimeFormat.get_day_around(1,
                                                   month_day) + ' ' + time_hmc
            data["calls"][0]['items'][0]['time'] = e_time
            data["smses"][0]['bill_month'] = bill_month
            data["smses"][0]['items'][0]['time'] = e_time.replace(' ', '-')
            data["bills"][0]['bill_month'] = bill_month
            data["bills"][0]['bill_start_date'] = month_start_date
            data["bills"][0]['bill_end_date'] = month_end_date
        else:
            data["calls"][0]['bill_month'] = modif_value
            data["smses"][0]['bill_month'] = modif_value
            data["bills"][0]['bill_month'] = modif_value
    elif modif_key == 'calls':
        # 输入数字,自动生成通话条数
        if modif_value.isdigit():
            calls = data["calls"][0]
            call = copy.deepcopy(calls)
            data["calls"] = [call for _ in range(int(modif_value))]
        else:
            data["calls"] = []