Commit 419ea0f7 authored by zhengjinlei's avatar zhengjinlei

查询详情

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