Commit 419ea0f7 authored by zhengjinlei's avatar zhengjinlei

查询详情

parent d533fd2b
...@@ -13,6 +13,7 @@ from django.views.decorators.clickjacking import xframe_options_exempt ...@@ -13,6 +13,7 @@ from django.views.decorators.clickjacking import xframe_options_exempt
from inspect_report import permissions from inspect_report import permissions
import logging import logging
from pypinyin import Style, pinyin from pypinyin import Style, pinyin
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from functools import reduce from functools import reduce
...@@ -370,6 +371,8 @@ class TasksApi(viewsets.ViewSet): ...@@ -370,6 +371,8 @@ class TasksApi(viewsets.ViewSet):
""" """
task_id = req.data.get('task', '') task_id = req.data.get('task', '')
agent_name = req.data.get('agentName', '') agent_name = req.data.get('agentName', '')
page = req.data.get('page', '1')
page_size = req.data.get('page_size', '10')
start_date = req.data.get('start_date', (datetime.now() + timedelta(days=-1)).strftime('%Y-%m-%d')) start_date = req.data.get('start_date', (datetime.now() + timedelta(days=-1)).strftime('%Y-%m-%d'))
end_date = req.data.get('end_date', datetime.now().strftime('%Y-%m-%d')) end_date = req.data.get('end_date', datetime.now().strftime('%Y-%m-%d'))
task_condition = {'hasCheck': 1, 'createdAt__gte': start_date, 'createdAt__lt': end_date + ' 23:59:59'} task_condition = {'hasCheck': 1, 'createdAt__gte': start_date, 'createdAt__lt': end_date + ' 23:59:59'}
...@@ -385,6 +388,7 @@ class TasksApi(viewsets.ViewSet): ...@@ -385,6 +388,7 @@ class TasksApi(viewsets.ViewSet):
else: else:
task_dict[t['sessionCollectionId']] = [t['id'], ] task_dict[t['sessionCollectionId']] = [t['id'], ]
return_data = [] return_data = []
total_count = 0
for k, v in task_dict.items(): for k, v in task_dict.items():
# session_collection = t.sessionCollectionId # session_collection = t.sessionCollectionId
table_name = TABLE_PRE + k table_name = TABLE_PRE + k
...@@ -394,7 +398,16 @@ class TasksApi(viewsets.ViewSet): ...@@ -394,7 +398,16 @@ class TasksApi(viewsets.ViewSet):
session_condition['agentName'] = agent_name session_condition['agentName'] = agent_name
checks = tn.objects.filter(**session_condition).values('id', 'createdAt', 'agentName', 'extra', 'taskId', checks = tn.objects.filter(**session_condition).values('id', 'createdAt', 'agentName', 'extra', 'taskId',
'remainTime', 'scoreItemRecord', 'sessionId') 'remainTime', 'scoreItemRecord', 'sessionId')
for check in checks: paginator = Paginator(checks, page_size)
total_count += paginator.count
try:
seats = paginator.page(page)
except PageNotAnInteger:
seats = paginator.page(1)
except EmptyPage:
seats = paginator.page(paginator.num_pages)
for check in seats:
result = check['scoreItemRecord'] result = check['scoreItemRecord']
t_name = task_name_dict[check['taskId']] t_name = task_name_dict[check['taskId']]
total_score = 100 total_score = 100
...@@ -425,7 +438,7 @@ class TasksApi(viewsets.ViewSet): ...@@ -425,7 +438,7 @@ class TasksApi(viewsets.ViewSet):
detail.update(rule_detail) detail.update(rule_detail)
detail['total_score'] = total_score detail['total_score'] = total_score
return_data.append(detail) return_data.append(detail)
return Response({'code': 0, 'msg': 'success', 'data': return_data}) return Response({'code': 0, 'msg': 'success', 'count': total_count, 'data': return_data})
@action(['post'], detail=False) @action(['post'], detail=False)
def seat_area(self, req: Request): def seat_area(self, req: Request):
...@@ -505,9 +518,9 @@ class TasksApi(viewsets.ViewSet): ...@@ -505,9 +518,9 @@ class TasksApi(viewsets.ViewSet):
for check in checks: for check in checks:
call_count += 1 call_count += 1
result = check['checkResult'] result = check['checkResult']
detail = {'agentName': check['agentName'], 'customName': check['customName'], # detail = {'agentName': check['agentName'], 'customName': check['customName'],
'remainTime': check['remainTime'], 'score': check['score'], 'sessionId': check['sessionId'], # 'remainTime': check['remainTime'], 'score': check['score'], 'sessionId': check['sessionId'],
'sessionCollectionId': k, 'taskId': check['taskId']} # 'sessionCollectionId': k, 'taskId': check['taskId']}
# session_id = check['id'] # session_id = check['id']
if result: if result:
data = json.loads(result) data = json.loads(result)
...@@ -516,9 +529,11 @@ class TasksApi(viewsets.ViewSet): ...@@ -516,9 +529,11 @@ class TasksApi(viewsets.ViewSet):
name = d['rule']['name'] name = d['rule']['name']
if name in return_data.keys(): if name in return_data.keys():
return_data[name]['count'] += 1 return_data[name]['count'] += 1
return_data[name]['details'].append(detail) # return_data[name]['details'].append(detail)
else: else:
return_data[name] = {'count': 1, 'details': [detail, ]} return_data[name] = {'count': 1, 'details': [], 'tables': []}
if k not in return_data[name]['tables']:
return_data[name]['tables'].append(k)
data_sort = [] data_sort = []
for k, v in return_data.items(): for k, v in return_data.items():
v['rule'] = k v['rule'] = k
...@@ -528,6 +543,49 @@ class TasksApi(viewsets.ViewSet): ...@@ -528,6 +543,49 @@ class TasksApi(viewsets.ViewSet):
data_sort = sorted(data_sort, key=lambda x: x['count'], reverse=True) data_sort = sorted(data_sort, key=lambda x: x['count'], reverse=True)
return Response({'code': 0, 'msg': 'success', 'data': data_sort}) return Response({'code': 0, 'msg': 'success', 'data': data_sort})
@action(['post'], detail=False)
def rule_detail(self, req: Request):
"""
首页概述-违规项统计
:param req:
:return:
"""
tables = req.data.get('tables', '')
rule_name = req.data.get('rule', '')
page = req.data.get('page', '1')
page_size = req.data.get('page_size', '10')
start_date = req.data.get('start_date', (datetime.now() + timedelta(days=-1)).strftime('%Y-%m-%d'))
end_date = req.data.get('end_date', datetime.now().strftime('%Y-%m-%d'))
if not isinstance(tables, list):
table_list = json.loads(tables)
else:
table_list = tables
return_data = []
total_count = 0
for k in table_list:
table_name = TABLE_PRE + k
tn = CheckSession.set_table(table_name)
session_condition = {'checkResult__contains': rule_name, 'createdAt__gte': start_date,
'createdAt__lt': end_date + ' 23:59:59'}
checks = tn.objects.filter(**session_condition).values('id', 'agentName', 'customName',
'remainTime', 'score', 'sessionId', 'taskId')
paginator = Paginator(checks, page_size)
total_count += paginator.count
try:
seats = paginator.page(page)
except PageNotAnInteger:
seats = paginator.page(1)
except EmptyPage:
seats = paginator.page(paginator.num_pages)
for check in seats:
detail = {'agentName': check['agentName'], 'customName': check['customName'],
'remainTime': check['remainTime'], 'score': check['score'], 'sessionId': check['sessionId'],
'sessionCollectionId': k, 'taskId': check['taskId']}
return_data.append(detail)
return Response({'code': 0, 'msg': 'success', 'count': total_count, 'data': return_data})
@xframe_options_exempt @xframe_options_exempt
def rule(request): def rule(request):
......
...@@ -93,19 +93,21 @@ ...@@ -93,19 +93,21 @@
<body style='height:100%'> <body style='height:100%'>
<div class='child-title'>语音坐席</div> <div class='child-title'>语音坐席</div>
<div class='child-main' id='childApp'> <div class='child-main' id='childApp'>
{# <div style='text-align:right;' class='childTitle'>#} <!--
{# <div class='childTitleName'>违规项分析</div>#} <div style='text-align:right;' class='childTitle'>
{# <div id='OneTime'>#} <div class='childTitleName'>违规项分析</div>
{# <el-date-picker#} <div id='OneTime'>
{# v-model="dateTime"#} <el-date-picker
{# @change='changeRange'#} v-model="dateTime"
{# value-format='yyyy-MM-dd'#} @change='changeRange'
{# clearable='false'#} value-format='yyyy-MM-dd'
{# type="date"#} clearable='false'
{# >#} type="date"
{# </el-date-picker>#} >
{# </div>#} </el-date-picker>
{# </div>#} </div>
</div>
-->
<div style='text-align:right;margin-bottom:15px;' class='childTitle'> <div style='text-align:right;margin-bottom:15px;' class='childTitle'>
<div class='childTitleName'>质检绩效考核汇总</div> <div class='childTitleName'>质检绩效考核汇总</div>
<el-date-picker <el-date-picker
...@@ -274,6 +276,8 @@ ...@@ -274,6 +276,8 @@
layout="prev, pager, next" layout="prev, pager, next"
:hide-on-single-page="isHidePage" :hide-on-single-page="isHidePage"
background background
:page-size="pagesize"
:total="total"> :total="total">
</el-pagination> </el-pagination>
<el-button v-if='isscrollTop' @click='backTop' id='backTop' type="warning" icon="el-icon-upload2" circle></el-button> <el-button v-if='isscrollTop' @click='backTop' id='backTop' type="warning" icon="el-icon-upload2" circle></el-button>
......
...@@ -51,7 +51,7 @@ new Vue({ ...@@ -51,7 +51,7 @@ new Vue({
}], }],
tableData: [], tableData: [],
currentPage:1, currentPage:1,
pagesize: 10, pagesize: 15,
total: 10, total: 10,
isHidePage: true, isHidePage: true,
} }
...@@ -104,16 +104,19 @@ new Vue({ ...@@ -104,16 +104,19 @@ new Vue({
}, },
getRule(task,start_date,end_date,agentName){ getRule(task,start_date,end_date,agentName){
let that = this; let that = this;
let page = this.currentPage;
let page_size = this.pagesize;
this.$loading({text:'数据加载中...'}); this.$loading({text:'数据加载中...'});
RquestsPost('api/v1/tasks/seat_check/',{task,start_date,end_date,agentName}).then(data => { RquestsPost('api/v1/tasks/seat_check/',{task,start_date,end_date,agentName,page,page_size}).then(data => {
that.$loading().close(); that.$loading().close();
if(data.code != 0){ if(data.code != 0){
}else{ }else{
that.tableData = this.basearr.concat(data.data.slice((this.currentPage-1)*this.pagesize,this.currentPage*this.pagesize)); //that.tableData = this.basearr.concat(data.data.slice((this.currentPage-1)*this.pagesize,this.currentPage*this.pagesize));
that.tableData = this.basearr.concat(data.data);
that.allData = data.data; that.allData = data.data;
this.total = data.data.length; this.total = data.count;
this.isHidePage = !(data.data.length > 0); this.isHidePage = !(data.data.length > 0);
//that.takeList = data.data; //that.takeList = data.data;
} }
...@@ -170,8 +173,9 @@ new Vue({ ...@@ -170,8 +173,9 @@ new Vue({
} }
}, },
CurrentChange(page){ CurrentChange(page){
//this.currentPage = page; this.currentPage = page;
this.tableData = this.basearr.concat(this.allData.slice((page-1)*this.pagesize,page*this.pagesize)); //this.tableData = this.basearr.concat(this.allData.slice((page-1)*this.pagesize,page*this.pagesize));
this.getRule(this.taskvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
//that.allData = data.data; //that.allData = data.data;
}, },
......
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