示例#1
0
def time_bill_by_echart(request):
    """展示Product的时间统计表
    """
    try:
        time_bill = TimeBill('2015-05-20', 5)
        weeklist = time_bill.get_weeklist()

        # 获取各产品线的time_bill
        all_products_time_bill = {}
        all_products_id = Product.objects.get_all_products_id()
        for product_id in all_products_id:
            product_name = Product.objects.get(id=product_id).name
            if product_name == u'学习':
                continue
            product_time_bill = time_bill.get_product_time_bill(product_id)
            product_average_time_bill = TimeBill.get_average_time_bill(product_time_bill)
            operation_total_time_list = TimeBill.get_operation_total_time_list(product_time_bill)

            all_products_time_bill[product_name] = {
                'product_time_bill' : product_time_bill,
                'product_average_time_bill' : product_average_time_bill,
                'operation_total_time_list' : operation_total_time_list,
            }

        # 获取各Operation总的time_bill 
        all_operation_time_bill = {}
        all_operations_id = Operation.objects.get_all_operations_id()
        for operation_id in all_operations_id:
            operation_time_bill = time_bill.get_operation_time_bill(operation_id)
            all_operation_time_bill[Operation.objects.get(id=operation_id).name] = operation_time_bill

        operation_average_time_bill = TimeBill.get_average_time_bill(all_operation_time_bill)
        operation_total_time_list = TimeBill.get_operation_total_time_list(all_operation_time_bill)

        all_products_time_bill['DPF组件'] = {
            'product_time_bill' : all_operation_time_bill,
            'product_average_time_bill' : operation_average_time_bill,
            'operation_total_time_list' : operation_total_time_list,
        }

        all_operations_name = json.dumps(Operation.objects.get_all_operations_name(), ensure_ascii=False)
        all_products_name = Product.objects.get_all_products_name()
        all_products_name.remove('学习')
        all_products_name.insert(0, 'DPF组件')

        # return HttpResponse(all_products_name) 
        # return HttpResponse(json.dumps(all_products_name, ensure_ascii=False))
        # return HttpResponse(all_operations_name) 
        # return HttpResponse(json.dumps(all_operations_name, ensure_ascii=False))
        # return HttpResponse(json.dumps(all_operation_time_bill)) 
        # return HttpResponse(json.dumps(all_products_time_bill))
        return render_to_response('time_bill_by_echart.html', {
            'weeklist' : weeklist, 
            'all_operations_name' : all_operations_name,
            'all_products_name' : all_products_name,
            'all_products_time_bill' : all_products_time_bill, 
        })
    except Exception as e: 
        return HttpResponse(returnJson(False, "%s in time_bill" % (e)))
示例#2
0
def time_bill(request):
    """展示Product的时间统计表
    """
    try:
        # 展示近一个月情况
        today_date = datetime.datetime.now()
        begin_date = today_date - datetime.timedelta(42)
        begin_date_s = "{year}-{month}-{day}".format(
            year=begin_date.year,
            month=begin_date.month,
            day=begin_date.day,
            )

        time_bill = TimeBill(begin_date_s, 7)
        weeklist = time_bill.get_weeklist()

        # 获取各产品线的time_bill
        all_products_time_bill = {}
        all_products_id = Product.objects.get_all_products_id()
        for product_id in all_products_id:
            product_name = Product.objects.get(id=product_id).name
            product_time_bill = time_bill.get_product_time_bill(product_id)
            product_average_time_bill = TimeBill.get_average_time_bill(product_time_bill)
            operation_total_time_list = TimeBill.get_operation_total_time_list(product_time_bill)

            all_products_time_bill[product_name] = {
                'product_time_bill' : product_time_bill,
                'product_average_time_bill' : product_average_time_bill,
                'operation_total_time_list' : operation_total_time_list,
            }

        # 获取各Operation总time_bill, 用于展示各类操作占用时间
        all_operation_time_bill = {}
        all_operations_id = Operation.objects.get_all_operations_id()
        for operation_id in all_operations_id:
            operation_time_bill = time_bill.get_operation_time_bill(operation_id)
            all_operation_time_bill[Operation.objects.get(id=operation_id).name] = operation_time_bill

        operation_average_time_bill = TimeBill.get_average_time_bill(all_operation_time_bill)
        operation_total_time_list = TimeBill.get_operation_total_time_list(all_operation_time_bill)

        all_products_time_bill['各类操作'] = {
            'product_time_bill' : all_operation_time_bill,
            'product_average_time_bill' : operation_average_time_bill,
            'operation_total_time_list' : operation_total_time_list,
        }

        all_operations_name = json.dumps(Operation.objects.get_all_operations_name(), ensure_ascii=False)
        all_products_name = Product.objects.get_all_products_name()
        all_products_name.insert(0, '各类操作')

        return render_to_response('time_bill.html', {
            'weeklist' : weeklist, 
            'all_operations_name' : all_operations_name,
            'all_products_name' : all_products_name,
            'all_products_time_bill' : all_products_time_bill, 
        })
    except Exception as e: 
        return HttpResponse(returnJson(False, "%s in time_bill" % (e)))
示例#3
0
def product_time_bill(request):
    """展示Product的时间统计表
    """
    if request.method == 'GET':
        try:
            product_id = int(request.GET['id'])
            time_bill = TimeBill('2015-05-20', 5)
            weeklist = time_bill.get_weeklist()
            product_time_bill = time_bill.get_product_time_bill(product_id)
            product_average_time_bill = TimeBill.get_average_time_bill(product_time_bill)
            operation_total_time_list = TimeBill.get_operation_total_time_list(product_time_bill)

            return render_to_response('product_time_bill.html', {
                'weeklist' : weeklist, 
                'product_time_bill' : product_time_bill,
                'product_average_time_bill' : product_average_time_bill,
                'operation_total_time_list' : operation_total_time_list,
            })
        except Exception as e: 
            return HttpResponse(returnJson(False, "%s in product_time_bill" % (e)))
    else : 
        return HttpResponse(returnJson(False, "Request's method is not GET in product_time_bill"))
示例#4
0
def time_bill(request):
    """展示Product的时间统计表
    """
    try:
        time_bill = TimeBill('2015-05-20', 5)
        weeklist = time_bill.get_weeklist()

        # 获取各产品线的time_bill
        all_products_time_bill = {}
        all_products_id = Product.objects.get_all_products_id()
        for product_id in all_products_id:
            product_name = Product.objects.get(id=product_id).name
            product_time_bill = time_bill.get_product_time_bill(product_id)
            product_average_time_bill = TimeBill.get_average_time_bill(product_time_bill)
            operation_total_time_list = TimeBill.get_operation_total_time_list(product_time_bill)

            all_products_time_bill[product_name] = {
                'product_time_bill' : product_time_bill,
                'product_average_time_bill' : product_average_time_bill,
                'operation_total_time_list' : operation_total_time_list,
            }

        # 获取各Operation总的time_bill 
        all_operation_time_bill = {}
        all_operations_id = Operation.objects.get_all_operations_id()
        for operation_id in all_operations_id:
            operation_time_bill = time_bill.get_operation_time_bill(operation_id)
            all_operation_time_bill[Operation.objects.get(id=operation_id).name] = operation_time_bill

        operation_average_time_bill = TimeBill.get_average_time_bill(all_operation_time_bill)
        operation_total_time_list = TimeBill.get_operation_total_time_list(all_operation_time_bill)

        all_products_time_bill['操作'] = {
            'product_time_bill' : all_operation_time_bill,
            'product_average_time_bill' : operation_average_time_bill,
            'operation_total_time_list' : operation_total_time_list,
        }

        # return HttpResponse(json.dumps(all_operation_time_bill)) 
        # return HttpResponse(json.dumps(all_products_time_bill))
        return render_to_response('time_bill.html', {
            'weeklist' : weeklist, 
            'all_products_time_bill' : all_products_time_bill, 
        })
    except Exception as e: 
        return HttpResponse(returnJson(False, "%s in time_bill" % (e)))