示例#1
0
def batch_search_use_case_list():
    """
    获取use_case列表,不需要获取与use_case关联的interface
    :return:
    """
    param_json = request.get_json()
    result = UseCaseAPI.get_use_case(**param_json)
    function_info_dict = MenuTreeAPI.query_line_relation()
    for use_case_info in result:
        use_case_info.update(function_info_dict[use_case_info['function_id']])
    return jsonify({'success': True, 'res': result})
示例#2
0
def query_week_report_info():
    """
    查询周报表数据,默认查询前4周数据
    :param: 时间格式:%Y-%m-%d
    :return:
    """
    param_kwarg = request.get_json()
    now_time_point = datetime.now()
    day_of_week_num = int(now_time_point.strftime('%w'))
    to_time_point = now_time_point + timedelta(days=7 - day_of_week_num)
    from_time_point = now_time_point - timedelta(weeks=4)
    if not param_kwarg.get('to_time', None):
        param_kwarg['to_time'] = to_time_point.strftime(DAY_TIME_FMT)
    else:
        to_time = datetime.strptime(param_kwarg['to_time'], '%Y-%m-%d')
        day_of_week_num = to_time.isocalendar()[2]
        to_time = to_time + timedelta(days=(7 - (day_of_week_num - 1)))
        to_time = to_time.strftime(DAY_TIME_FMT)
        param_kwarg.update({"to_time": to_time})

    if not param_kwarg.get('from_time', None):
        param_kwarg['from_time'] = from_time_point.strftime(DAY_TIME_FMT)
    else:
        from_time = datetime.strptime(param_kwarg['from_time'], '%Y-%m-%d')
        day_of_week_num = from_time.isocalendar()[2]
        from_time = from_time - timedelta(days=day_of_week_num - 1)
        from_time = from_time.strftime(DAY_TIME_FMT)
        param_kwarg.update({"from_time": from_time})
    report_info_list = ReportAPI.get_week_report_info(**param_kwarg)
    menu_tree_info = MenuTreeAPI.query_line_relation()

    for report_info in report_info_list:
        function_id = report_info.get('function_id')
        report_info.update(menu_tree_info[function_id])
    if param_kwarg.get('data_type', None):
        report_info_list = get_line_of_data(report_info_list, '%W')
        business_info_list = MenuTreeAPI.query_business_line()
        business_info_dict = {}
        for business_info in business_info_list:
            business_info_dict[business_info['id']] = business_info

        for report_info in report_info_list:
            business_line_id = report_info.get('business_line_id')
            report_info.update(business_info_dict[business_line_id])
        if report_info_list:
            chartist_data = report_data_manager(report_info_list, '%W')
        else:
            chartist_data = {}
        return jsonify({'success': True, 'res': chartist_data})
    return jsonify({'success': True, 'res': report_info_list})
示例#3
0
def get_function_line():
    """
    查询所有功能模块菜单
    :return:
    """
    param_args = request.get_json()
    id = param_args.get('id')
    system_line_id = param_args.get('system_line_id')
    param_args.pop(
        'system_line_id'
    ) if 'system_line_id' in param_args and system_line_id is None else None
    param_args.pop('id') if 'id' in param_args and id is None else None
    result = MenuTreeAPI.query_line_relation(**param_args)
    return jsonify({'success': True, 'res': result})
示例#4
0
def query_minutes_report_info():
    """
    查询分钟报表数据
    :param: 时间格式:%Y-%m-%d %H:%M:%S
    :return:
    """
    param_kwarg = request.get_json()
    now_time_point = datetime.now()
    to_time_point = now_time_point
    from_time_point = now_time_point
    if 'to_time' not in param_kwarg or not param_kwarg.get('to_time'):
        param_kwarg['to_time'] = to_time_point.strftime(MINUTE_TIME_FMT)
    else:
        to_time = param_kwarg['to_time']
        to_time = datetime.strptime(to_time, '%Y-%m-%d') + timedelta(days=1)
        to_time = to_time.strftime(MINUTE_TIME_FMT)
        param_kwarg.update({"to_time": to_time})

    if 'from_time' not in param_kwarg or not param_kwarg.get(
            'from_time', None):
        param_kwarg['from_time'] = from_time_point.strftime(DAY_TIME_FMT)
    else:
        from_time = param_kwarg['from_time']
        from_time = datetime.strptime(from_time, '%Y-%m-%d')
        from_time = from_time.strftime(DAY_TIME_FMT)
        param_kwarg.update({"from_time": from_time})
    report_info_list = ReportAPI.get_minutes_report_info(**param_kwarg)
    menu_tree_info = MenuTreeAPI.query_line_relation()
    for report_info in report_info_list:
        function_id = report_info.get('function_id')
        if menu_tree_info.get(function_id, None):
            report_info.update(menu_tree_info[function_id])
    if param_kwarg.get('data_type', None):
        report_info_list = get_line_of_data(report_info_list, '%Y-%m-%d %H:%M')
        business_info_list = MenuTreeAPI.query_business_line()
        business_info_dict = {}
        for business_info in business_info_list:
            business_info_dict[business_info['id']] = business_info

        for report_info in report_info_list:
            business_line_id = report_info.get('business_line_id')
            report_info.update(business_info_dict[business_line_id])
        if report_info_list:
            chartist_data = report_data_manager(report_info_list,
                                                '%Y-%m-%d %H:%M')
        else:
            chartist_data = {}
        return jsonify({'success': True, 'res': chartist_data})
    return jsonify({'success': True, 'res': report_info_list})
示例#5
0
def get_send_body():
    kwarg = dict()
    now_time_point = datetime.now()
    to_time_point = now_time_point
    from_time_point = now_time_point - timedelta(days=1)
    kwarg['to_time'] = to_time_point.strftime(DAY_TIME_FMT)
    kwarg['from_time'] = from_time_point.strftime(DAY_TIME_FMT)
    report_info_list = ReportAPI.get_day_report_info(**kwarg)
    menu_tree_info = MenuTreeAPI.query_line_relation()
    for report_info in report_info_list:
        function_id = report_info.get('function_id')
        report_info.update(menu_tree_info[function_id])
    report_info_list = get_line_of_data(report_info_list,
                                        filter_line_name='system_line_id')
    cur_wk_path = os.path.join(web_root, 'static', 'email_template.html')

    with open(cur_wk_path, 'r+', encoding="utf-8") as fp:
        fp_data = fp.read()
        fp_data = fp_data.format(now_time_point.strftime('%Y/%m/%d %H:%M'))
        index = fp_data.find('<tbody>')
        before_insert_data = fp_data[:index]
        after_insert_data = fp_data[index:]
        for report_data in report_info_list:
            html_tmp = '<tr>' \
                       '<td role="row">{0}</td>' \
                       '<td role="row">{1}</td>' \
                       '<td role="row">{2}</td>' \
                       '<td role="row">{3}</td>' \
                       '<td role="row">{4}</td>' \
                       '<td role="row">{5}</td>' \
                       '<td role="row">{6}</td>' \
                       '<td role="row">{7}</td>' \
                       '</tr>'
            create_time = report_data['create_time'].strftime('%Y-%m-%d')
            before_insert_data += html_tmp.format(
                report_data['business_name'], report_data['system_name'],
                report_data['run_count'], report_data['fail_count'],
                round(report_data['pass_rate'] * 100, 3),
                float('%.3f' % report_data['average_time']),
                float('%.3f' % report_data['max_time']), create_time)

    return before_insert_data + after_insert_data