Commit dffa83a1 authored by zhengjinlei's avatar zhengjinlei

保留2位小数

parent 410c43a0
......@@ -5,7 +5,7 @@ from rest_framework import viewsets
from rest_framework.decorators import action
from rest_framework.request import Request
from rest_framework.response import Response
from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, ScoreStat
from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, ScoreStat, Round
import json
from datetime import datetime, timedelta
from config.config import TABLE_PRE
......@@ -426,9 +426,9 @@ class TasksApi(viewsets.ViewSet):
task_condition['agentName'] = agent_name
# , 'total_session', 'validate_num', 'validate_session', 'validate_zero'
rules = ScoreStat.objects.filter(**task_condition).extra(select={'area': "task", 'agentName': 'agentName'})\
.values('area', 'agentName').annotate(avg_score_svc=Avg('service_score'),
avg_score_bus=Avg('business_score'),
avg_score=Avg('score'), total_session=Sum('total_session'),
.values('area', 'agentName').annotate(avg_score_svc=Round(Avg('service_score'), 2),
avg_score_bus=Round(Avg('business_score'), 2),
avg_score=Round(Avg('score'), 2), total_session=Sum('total_session'),
validate_num=Sum('validate_num'), validate_zero=Sum('validate_zero'))\
.order_by(sort)
paginator = Paginator(rules, page_size)
......@@ -550,8 +550,9 @@ class TasksApi(viewsets.ViewSet):
if task_id:
task_condition['task'] = task_id
rules = ScoreStat.objects.filter(**task_condition).extra(select={'area': "task"}) \
.values('area').annotate(avg_score_svc=Avg('service_score'), avg_score_bus=Avg('business_score'),
avg_score=Avg('score'), total_session=Sum('total_session'),
.values('area').annotate(avg_score_svc=Round(Avg('service_score'), 2),
avg_score_bus=Round(Avg('business_score'), 2),
avg_score=Round(Avg('score'), 2), total_session=Sum('total_session'),
validate_num=Sum('validate_num'), validate_zero=Sum('validate_zero')) \
.order_by(sort)
paginator = Paginator(rules, page_size)
......
......@@ -2,6 +2,9 @@ from django.db import models
# Create your models here.
from django.db.models import Func
class Tasks(models.Model):
name = models.CharField('任务名称', null=True, max_length=50, db_index=True)
type = models.IntegerField('任务分类', default=1)
......@@ -130,3 +133,7 @@ class CheckSession(models.Model):
}
return type(table_name, (Class,), attrs)
class Round(Func):
function = 'ROUND'
arity = 2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment