Commit 5577c600 authored by zhengjinlei's avatar zhengjinlei

质检数据统计第二版

parent f5d45e3d
......@@ -42,26 +42,34 @@ class TasksApi(viewsets.ViewSet):
:return:
"""
task_id = req.GET.get('task', '')
task_condition = {}
task_condition = {'hasCheck': 1}
session_condition = {}
if task_id:
task_condition['pk'] = task_id
session_condition['taskId'] = task_id
tasks = Tasks.objects.filter(**task_condition).values('sessionCollectionId').annotate(Count=Count('sessionCollectionId'))
task_condition['name__startswith'] = task_id
tasks = Tasks.objects.filter(**task_condition).values('id', 'sessionCollectionId')
task_dict = {}
for t in tasks:
if t['sessionCollectionId'] in task_dict.keys():
task_dict[t['sessionCollectionId']].append(t['id'])
else:
task_dict[t['sessionCollectionId']] = [t['id'], ]
return_data = []
for t in tasks:
session_collection = t['sessionCollectionId']
table_name = TABLE_PRE + session_collection
for k, v in task_dict.items():
# session_collection = t['sessionCollectionId']
table_name = TABLE_PRE + k
tn = CheckSession.set_table(table_name)
agents = tn.objects.filter(**session_condition).values('agentName').annotate(Count=Count('agentName')).values('agentName')
return_data.append(agents)
# for agent in agents:
# if agent not in return_data:
# return_data.append(agent)
data_reduce = lambda x, y: x if y in x else x + [y]
return_data = reduce(data_reduce, [[], ] + return_data)
return Response({'code': 0, 'msg': 'success', 'data': return_data[0]})
session_condition['taskId__in'] = v
agents = tn.objects.filter(**session_condition).values('agentName')
# .annotate(Count=Count('agentName')).values('agentName')
# if agents:
# return_data.append(agents)
for agent in agents:
if agent not in return_data:
return_data.append(agent)
# data_reduce = lambda x, y: x if y in x else x + [y]
# return_data = reduce(data_reduce, [[], ] + return_data)
return Response({'code': 0, 'msg': 'success', 'data': return_data})
@action(['post'], detail=False)
def rule(self, req: Request):
......@@ -72,36 +80,47 @@ class TasksApi(viewsets.ViewSet):
"""
task_id = req.data.get('task', '')
agent_name = req.data.get('agentName', '')
start_date = req.data.get('start_date', (datetime.now()+timedelta(days=-30)).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'))
task_condition = {'createdAt__gte': start_date, 'createdAt__lt': end_date + ' 23:59:59'}
tasks = []
task_condition = {'hasCheck': 1, 'createdAt__gte': start_date, 'createdAt__lt': end_date + ' 23:59:59'}
if task_id:
tk = Tasks.objects.get(pk=task_id)
tasks.append(tk)
task_condition['name__startswith'] = task_id
tasks = Tasks.objects.filter(**task_condition).values('id', 'sessionCollectionId')
task_dict = {}
for t in tasks:
if t['sessionCollectionId'] in task_dict.keys():
task_dict[t['sessionCollectionId']].append(t['id'])
else:
tasks = Tasks.objects.filter(**task_condition)
task_dict[t['sessionCollectionId']] = [t['id'], ]
return_data = {}
for t in tasks:
session_collection = t.sessionCollectionId
table_name = TABLE_PRE + session_collection
for k, v in task_dict.items():
# session_collection = t.sessionCollectionId
table_name = TABLE_PRE + k
tn = CheckSession.set_table(table_name)
session_condition = {'taskId': t.id}
session_condition = {'taskId__in': v}
if agent_name:
session_condition['agentName'] = agent_name
checks = tn.objects.filter(**session_condition)
checks = tn.objects.filter(**session_condition).values('id', 'checkResult')
# checks = tn.objects.filter(**session_condition).values('id', 'checkResult')
for check in checks:
result = check.checkResult
result = check['checkResult']
# session_id = check['id']
if result:
data = json.loads(result)
for d in data:
if 'isViolation' in d.keys() and d['isViolation'] and 'rule' in d.keys() and 'name' in d['rule'].keys():
name = d['rule']['name']
if name in return_data.keys():
return_data[name] += 1
return_data[name]['count'] += 1
# return_data[name]['ids'].append(session_id)
else:
return_data[name] = 1
data_sort = sorted(return_data.items(), key=lambda item: item[1], reverse=False)
return_data[name] = {'count': 1}
# return_data[name] = {'count': 1, 'ids': [session_id, ]}
data_sort = []
for k, v in return_data.items():
v['rule'] = k
data_sort.append(v)
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)
......@@ -113,24 +132,26 @@ class TasksApi(viewsets.ViewSet):
"""
task_id = req.data.get('task', '')
num = req.data.get('num', '10')
start_date = req.data.get('start_date', (datetime.now()+timedelta(days=-30)).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'))
task_condition = {'createdAt__gte': start_date, 'createdAt__lt': end_date + ' 23:59:59'}
tasks = []
task_condition = {'hasCheck': 1, 'createdAt__gte': start_date, 'createdAt__lt': end_date + ' 23:59:59'}
if task_id:
tk = Tasks.objects.get(pk=task_id)
tasks.append(tk)
task_condition['name__startswith'] = task_id
tasks = Tasks.objects.filter(**task_condition).values('id', 'sessionCollectionId')
task_dict = {}
for t in tasks:
if t['sessionCollectionId'] in task_dict.keys():
task_dict[t['sessionCollectionId']].append(t['id'])
else:
tasks = Tasks.objects.filter(**task_condition)
task_dict[t['sessionCollectionId']] = [t['id'], ]
return_data = {}
for t in tasks:
session_collection = t.sessionCollectionId
table_name = TABLE_PRE + session_collection
for k, v in task_dict.items():
table_name = TABLE_PRE + k
tn = CheckSession.set_table(table_name)
session_condition = {'taskId': t.id}
checks = tn.objects.filter(**session_condition)
session_condition = {'taskId__in': v}
checks = tn.objects.filter(**session_condition).values('agentName')
for check in checks:
agent_name = check.agentName
agent_name = check['agentName']
if agent_name:
if agent_name in return_data.keys():
return_data[agent_name] += 1
......@@ -152,29 +173,31 @@ class TasksApi(viewsets.ViewSet):
"""
task_id = req.data.get('task', '')
num = req.data.get('num', '10')
start_date = req.data.get('start_date', (datetime.now()+timedelta(days=-30)).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'))
task_condition = {'createdAt__gte': start_date, 'createdAt__lt': end_date + ' 23:59:59'}
tasks = []
task_condition = {'hasCheck': 1, 'createdAt__gte': start_date, 'createdAt__lt': end_date + ' 23:59:59'}
if task_id:
tk = Tasks.objects.get(pk=task_id)
tasks.append(tk)
task_condition['name__startswith'] = task_id
tasks = Tasks.objects.filter(**task_condition).values('id', 'sessionCollectionId')
task_dict = {}
for t in tasks:
if t['sessionCollectionId'] in task_dict.keys():
task_dict[t['sessionCollectionId']].append(t['id'])
else:
tasks = Tasks.objects.filter(**task_condition)
task_dict[t['sessionCollectionId']] = [t['id'], ]
return_data = {}
for t in tasks:
session_collection = t.sessionCollectionId
table_name = TABLE_PRE + session_collection
for k, v in task_dict.items():
table_name = TABLE_PRE + k
tn = CheckSession.set_table(table_name)
session_condition = {'taskId': t.id}
checks = tn.objects.filter(**session_condition)
session_condition = {'taskId__in': v}
checks = tn.objects.filter(**session_condition).values('agentName', 'score')
for check in checks:
agent_name = check.agentName
agent_name = check['agentName']
if agent_name:
if agent_name in return_data.keys():
return_data[agent_name] += check.score
return_data[agent_name] += check['score']
else:
return_data[agent_name] = check.score
return_data[agent_name] = check['score']
data_max = sorted(return_data.items(), key=lambda item: item[1], reverse=False)
data_max = data_max[:int(num)]
data_max_return = {}
......@@ -182,6 +205,152 @@ class TasksApi(viewsets.ViewSet):
data_max_return[dm[0]] = dm[1]
return Response({'code': 0, 'msg': 'success', 'data': data_max_return})
@action(['post'], detail=False)
def seat_rule(self, req: Request):
"""
坐席违规分析-按照得分
:param req:
:return:
"""
task_id = req.data.get('task', '')
num = req.data.get('num', '10')
a_name = req.data.get('agentName', '')
sort = req.data.get('sort', 'des')
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'}
if task_id:
task_condition['name__startswith'] = task_id
tasks = Tasks.objects.filter(**task_condition).values('id', 'sessionCollectionId')
task_dict = {}
for t in tasks:
if t['sessionCollectionId'] in task_dict.keys():
task_dict[t['sessionCollectionId']].append(t['id'])
else:
task_dict[t['sessionCollectionId']] = [t['id'], ]
return_data = {}
for k, v in task_dict.items():
table_name = TABLE_PRE + k
tn = CheckSession.set_table(table_name)
session_condition = {'taskId__in': v}
if a_name:
session_condition['agentName'] = a_name
checks = tn.objects.filter(**session_condition).values('agentName', 'violationRuleCount')
for check in checks:
agent_name = check['agentName']
if agent_name:
if agent_name in return_data.keys():
return_data[agent_name]['total_session'] += 1
if check['violationRuleCount'] > 0:
return_data[agent_name]['validate_session'] += 1
else:
if check['violationRuleCount'] > 0:
return_data[agent_name] = {'total_session': 1, 'validate_session': 1}
else:
return_data[agent_name] = {'total_session': 1, 'validate_session': 0}
# data_max = sorted(return_data.items(), key=lambda item: item[1], reverse=False)
pre_data_sort = []
for k, v in return_data.items():
ratio = round(v['validate_session']/v['total_session'], 2)
v['ratio'] = ratio
v['agentName'] = k
pre_data_sort.append(v)
if sort == 'asc':
data_sort = sorted(pre_data_sort, key=lambda x: x['ratio'])
for i in range(len(data_sort)):
data_sort[i]['ranking'] = len(data_sort) - i
else:
data_sort = sorted(pre_data_sort, key=lambda x: x['ratio'], reverse=True)
for i in range(len(data_sort)):
data_sort[i]['ranking'] = i + 1
data_sort[i]['ratio'] = '{0}%'.format(int(data_sort[i]['ratio'] * 100))
return Response({'code': 0, 'msg': 'success', 'data': data_sort})
@action(['post'], detail=False)
def static(self, req: Request):
"""
获取违规项分析
:param req:
:return:
"""
task_id = req.data.get('task', '')
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'}
if task_id:
task_condition['name__startswith'] = task_id
tasks = Tasks.objects.filter(**task_condition).values('id', 'sessionCollectionId')
task_dict = {}
for t in tasks:
if t['sessionCollectionId'] in task_dict.keys():
task_dict[t['sessionCollectionId']].append(t['id'])
else:
task_dict[t['sessionCollectionId']] = [t['id'], ]
return_data = {'total_session': 0, 'validate_session': 0}
for k, v in task_dict.items():
table_name = TABLE_PRE + k
tn = CheckSession.set_table(table_name)
session_condition = {'taskId__in': v}
checks = tn.objects.filter(**session_condition).values('violationRuleCount')
for check in checks:
return_data['total_session'] += 1
if check['violationRuleCount'] > 0:
return_data['validate_session'] += 1
if return_data['total_session']:
return_data['ratio'] = round(return_data['validate_session']/return_data['total_session'], 2)
else:
return_data['ratio'] = 0.0
return Response({'code': 0, 'msg': 'success', 'data': return_data})
@action(['post'], detail=False)
def static_date(self, req: Request):
"""
获取违规项分析
:param req:
:return:
"""
task_id = req.data.get('task', '')
start_date = req.data.get('start_date', (datetime.now() + timedelta(days=-6)).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'}
if task_id:
task_condition['name__startswith'] = task_id
tasks = Tasks.objects.filter(**task_condition).values('id', 'sessionCollectionId')
task_dict = {}
for t in tasks:
if t['sessionCollectionId'] in task_dict.keys():
task_dict[t['sessionCollectionId']].append(t['id'])
else:
task_dict[t['sessionCollectionId']] = [t['id'], ]
return_data = {}
for k, v in task_dict.items():
table_name = TABLE_PRE + k
tn = CheckSession.set_table(table_name)
session_condition = {'taskId__in': v}
checks = tn.objects.filter(**session_condition).values('violationRuleCount', 'createdAt')
for check in checks:
date = check['createdAt'].strftime('%Y-%m-%d')
if date in return_data.keys():
return_data[date]['total_session'] += 1
if check['violationRuleCount'] > 0:
return_data[date]['validate_session'] += 1
else:
if check['violationRuleCount'] > 0:
return_data[date] = {'total_session': 1, 'validate_session': 1}
else:
return_data[date] = {'total_session': 1, 'validate_session': 0}
data_sort = []
for k, v in return_data.items():
# return_data[k]['ratio'] = round(v['validate_session']/v['total_session'], 2)
if v['total_session']:
v['ratio'] = round(v['validate_session']/v['total_session'], 2)
else:
v['ratio'] = 0
v['date'] = k
data_sort.append(v)
data_sort = sorted(data_sort, key=lambda x: x['date'], reverse=True)
return Response({'code': 0, 'msg': 'success', 'data': data_sort})
@xframe_options_exempt
def rule(request):
......@@ -191,3 +360,8 @@ def rule(request):
@xframe_options_exempt
def seat(request):
return render(request, 'inspect/seat.html')
@xframe_options_exempt
def group(request):
return render(request, 'inspect/group.html')
<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
<meta charset='utf-8' />
<title>组长概览</title>
<!-- 引入样式 -->
<link rel="stylesheet" href="{% static "inspect/css/element.css" %}">
<!-- 引入组件库 -->
<link rel='stylesheet' type='text/css' href="{% static "inspect/css/all.css" %}">
<style>
#OneTime{
display: inline-block;
}
#OneTime .el-input__icon {
line-height: 32px;
}
#OneTime .el-input .el-input__inner {
padding-left: 30px;
}
.groutTitle span{
display:inline-block;
margin-right: 20px;
color:#565656;
font-size:15px;
}
</style>
</head>
<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>
<!--
<el-select v-model="taskvalue" filterable placeholder="请选择" @change="changeTask">
<el-option
v-for="item in taskList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
<el-select v-model="takevalue" filterable placeholder="请选择" @change='changeTake'>
<el-option
label="全部坐席"
value="">
</el-option>
<el-option
v-for="item in takeList"
:key="item.agentName"
:label="item.agentName"
:value="item.agentName">
</el-option>
</el-select>
-->
</div>
<div style='margin-top:10px;padding-left:30px;' class='groutTitle'>
<span>质检完成会话数: <span v-html='titleInfo.total_session'></span></span>
<span>违规会话数: <span v-html='titleInfo.validate_session'></span></span>
<span>占比:<span v-html='titleInfo.ratio * 100 + "%"'></span></span>
</div>
<div id='main' style='width:80%;height:600px' v-loading='true'></div>
</div>
<script type="text/javascript">
window.onload = function(){
};
</script>
<script src="{% static "inspect/js/vue.min.js" %}"></script>
<script src="{% static "inspect/js/element.js" %}"></script>
<script src="{% static "inspect/js/echarts.js" %}"></script>
<script src="{% static "inspect/js/http.js" %}"></script>
<script type="text/javascript" src="{% static "inspect/js/groupOverview.js" %}"></script>
</body>
</html>
......@@ -9,11 +9,11 @@
<!-- 引入组件库 -->
<link rel='stylesheet' type='text/css' href="{% static "inspect/css/all.css" %}">
</head>
<body style='height:100%;min-width:1000px'>
<body style='height:100%'>
<div class='child-title'>语音坐席</div>
<div class='child-main' id='childApp'>
<div style='text-align:right;margin-bottom:30px;' class='childTitle'>
<div class='childTitleName'>违规坐席分析</div>
<div style='text-align:right;' class='childTitle'>
<div class='childTitleName'>违规分析</div>
<el-date-picker
v-model="dateRange"
@change='changeRange'
......@@ -24,7 +24,7 @@
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']">
</el-date-picker>
<el-select filterable v-model="taskvalue" placeholder="请选择" @change="changeTask">
<el-select v-model="taskvalue" filterable placeholder="请选择" @change="changeTask">
<el-option
v-for="item in taskList"
:key="item.id"
......@@ -32,23 +32,66 @@
:value="item.id">
</el-option>
</el-select>
<el-select v-model="takevalue" filterable placeholder="请选择" @change='changeTake'>
<el-option
label="全部坐席"
value="">
</el-option>
<el-option
v-for="item in takeList"
:key="item.agentName"
:label="item.agentName"
:value="item.agentName">
</el-option>
</el-select>
</div>
<div class='childStatistics'>
<div>
<div id='main' v-loading='true' style='height:600px;display:inline-block;'></div>
</div>
<div>
<div id='mainTwo' v-loading='true' style='height:600px;display:inline-block;'></div>
</div>
<div id='main' style='margin-top:20px'>
<el-table
:data="tableData"
border
height="600"
style="width: 100%">
<el-table-column
prop="agentName"
label="坐席"
width="180"
>
</el-table-column>
<el-table-column
prop="total_session"
label="全部会话数"
width="180"
>
</el-table-column>
<el-table-column
prop="validate_session"
label="违规会话数">
</el-table-column>
<el-table-column
prop="ratio"
label="违规占比">
{# <template slot-scope="scope">#}
{# {{scope}}%#}
{# </template>#}
</el-table-column>
<el-table-column
prop="ranking"
sortable
label="排名">
</el-table-column>
</el-table>
</div>
</div>
<script type="text/javascript">
window.onload = function(){
};
</script>
<script src="{% static "inspect/js/vue.min.js" %}"></script>
<script src="{% static "inspect/js/element.js" %}"></script>
<script src="{% static "inspect/js/echarts.js" %}"></script>
<script type="text/javascript" src="{% static "inspect/js/http.js" %}"></script>
<script type="text/javascript" src="{% static "inspect/js/violator.js" %}"></script>
<script type="text/javascript">
</script>
</body>
</html>
......@@ -15,10 +15,11 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path
from .api.tasksapi import rule, seat
from .api.tasksapi import rule, seat, group
urlpatterns = [
# path('admin/', admin.site.urls),
path('inspect/rule/', rule),
path('inspect/seat/', seat),
path('inspect/group/', group),
]
......@@ -33,15 +33,36 @@ new Vue({
},
getTask(){
let that = this;
RquestsGet('api/v1/tasks/obtain/').then(data => {
//console.log(data);
if(data.code != 0){
that.taskList = [{id:'',name:'全部任务'}];
}else{
that.taskList = [{id:'',name:'全部任务'}].concat(data.data);
that.getTake()
}
})
that.taskList = [
{id:'',name:'全省'},
{id:'合肥',name:'合肥'},
{id:'芜湖',name:'芜湖'},
{id:'蚌埠',name:'蚌埠'},
{id:'淮南',name:'淮南'},
{id:'马鞍山',name:'马鞍山'},
{id:'淮北',name:'淮北'},
{id:'铜陵',name:'铜陵'},
{id:'安庆',name:'安庆'},
{id:'黄山',name:'黄山'},
{id:'滁州',name:'滁州'},
{id:'阜阳',name:'阜阳'},
{id:'毫州',name:'毫州'},
{id:'宿州',name:'宿州'},
{id:'六安',name:'六安'},
{id:'宣城',name:'宣城'},
{id:'巢湖',name:'巢湖'},
{id:'池州',name:'池州'},
{id:'安徽省营业部',name:'安徽省营业部'},
];
//RquestsGet('api/v1/tasks/obtain/').then(data => {
// //console.log(data);
// if(data.code != 0){
// that.taskList = [{id:'',name:'全部任务'}];
// }else{
// that.taskList = [{id:'',name:'全部任务'}].concat(data.data);
// that.getTake()
// }
//})
},
getTake(){
let that = this;
......@@ -57,9 +78,15 @@ new Vue({
},
Charts(msg){
let msgLen = msg.length;
let msgArr = [];
for(let key in msg){
console.log(key) ;
console.log(msg[key]) ;
msgArr.unshift([msg[key].rule, msg[key].count])
}
let sourceArr = [
[ 'product', 'amount'],
].concat(msg);
].concat(msgArr);
var option = {
dataZoom : [
{
......@@ -184,8 +211,8 @@ new Vue({
return date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate();
},
init(){
this.dateRange = [new Date(new Date()-24*60*60*1000*30), new Date()];
this.start_date = this.dateFormat(new Date(new Date()-24*60*60*1000*30));
this.dateRange = [new Date(new Date()-24*60*60*1000), new Date()];
this.start_date = this.dateFormat(new Date(new Date()-24*60*60*1000));
this.end_date = this.dateFormat(new Date());
this.getTask(); // 获取任务
//this.getTake(); // 获取坐席
......
new Vue({
el: '#childApp',
data:function(){
return {
ss:'sas',
dateTime: '',
taskList:[],
taskvalue: '',
start_date: '',
end_date:'',
takeList:[],
takevalue: '',
titleInfo: {
"total_session": 0,
"validate_session": 0,
"ratio": 0,
},
loading: true,
}
},
methods: {
changeRange(dateTime){
console.log(dateTime);
this.start_date = dateTime;
this.getRule(this.taskvalue,this.start_date,this.takevalue); // 获取统计数据
},
changeTask(msg){
console.log(msg);
this.taskvalue = msg;
this.getTake()
this.getRule(this.taskvalue,this.start_date,this.takevalue); // 获取统计数据
},
changeTake(msg){
this.takevalue = msg;
this.getRule(this.taskvalue,this.start_date,this.takevalue); // 获取统计数据
console.log(msg);
},
getTask(){
let that = this;
that.taskList = [
{id:'',name:'全省'},
{id:'合肥',name:'合肥'},
{id:'芜湖',name:'芜湖'},
{id:'蚌埠',name:'蚌埠'},
{id:'淮南',name:'淮南'},
{id:'马鞍山',name:'马鞍山'},
{id:'淮北',name:'淮北'},
{id:'铜陵',name:'铜陵'},
{id:'安庆',name:'安庆'},
{id:'黄山',name:'黄山'},
{id:'滁州',name:'滁州'},
{id:'阜阳',name:'阜阳'},
{id:'毫州',name:'毫州'},
{id:'宿州',name:'宿州'},
{id:'六安',name:'六安'},
{id:'宣城',name:'宣城'},
{id:'巢湖',name:'巢湖'},
{id:'池州',name:'池州'},
{id:'安徽省营业部',name:'安徽省营业部'},
];
//RquestsGet('api/v1/tasks/obtain/').then(data => {
// //console.log(data);
// if(data.code != 0){
// that.taskList = [{id:'',name:'全部任务'}];
// }else{
// that.taskList = [{id:'',name:'全部任务'}].concat(data.data);
// that.getTake()
// }
//})
},
getTake(){
let that = this;
RquestsGet('api/v1/tasks/seat/?task=' + that.taskvalue).then(data => {
//console.log(data);
if(data.code != 0){
//that.takeList = [{agentName:'全部坐席'}]
}else{
that.takeList = data.data;
}
})
},
Charts(msg){
console.log(msg);
let msgLen = msg.length;
let xAxisArr = [];
let seriesArr = [];
for(let key in msg){
console.log(key);
xAxisArr.unshift(msg[key].date);
seriesArr.unshift(msg[key].ratio * 100);
}
let option = {
tooltip: {
trigger: 'axis',
//formatter: '违规率:<br />{c}%'
formatter: '违规率:{c}%'
},
xAxis: {
type: 'category',
//data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
data: xAxisArr
},
yAxis: {
//name: 'amount',
max:'100',
type: 'value',
axisLabel:{
formatter: '{value}%'
}
},
series: [{
//data: [820, 932, 901, 934, 1290, 1330, 1320],
name:'违规率',
data: seriesArr,
type: 'line',
smooth: true,
itemStyle:{
normal:{
color: '#fccb04'
},
emphasis:{
color: '#f7d139'
}
},
}]
};
var myChart = echarts.init(document.getElementById('main'));
myChart.setOption(option)
if(msg.length == 0){
myChart.showLoading({
text: '暂无数据',
color: '#ffffff',
textColor: '#8a8e91',
maskColor: 'rgba(255, 255, 255, 0.8)',
});
}else{
myChart.hideLoading();
}
window.onresize = function(){
myChart.resize();
}
},
getRule(task,end_date,agentName){
let that = this;
let start_date = this.dateFormat(new Date(new Date(end_date).getTime() - 6*24*60*60*1000));
console.log(start_date,end_date);
let arr = [];
this.$loading({text:'数据加载中...'});
RquestsPost('api/v1/tasks/static_date/',{task,end_date,start_date,agentName}).then(data => {
console.log(data.data);
if(data.code != 0){
that.$message(data.msg);
if(data.msg){
that.$message(data.msg);
}else{
that.$message('服务器错误')
}
}
if(!data.data){
this.$loading().close();
return false;
}
//for(let key in data.data){
// arr.unshift([data.data[key],key])
//}
that.Charts(data.data);
this.$loading().close();
})
RquestsPost('api/v1/tasks/static/',{task,end_date,start_date,agentName}).then(data => {
console.log(data.data);
if(data.code != 0){
that.$message(data.msg);
if(data.msg){
that.$message(data.msg);
}else{
that.$message('服务器错误')
}
}
if(!data.data){
this.$loading().close();
return false;
}
that.titleInfo = data.data;
this.$loading().close();
})
},
dateFormat(date){
return date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate();
},
init(){
this.dateTime = new Date(new Date()-24*60*60*1000);
this.start_date = this.dateFormat(new Date(new Date()-24*60*60*1000));
this.getTask(); // 获取任务
//this.getTake(); // 获取坐席
this.getRule(this.taskvalue,this.start_date,this.takevalue); // 获取统计数据
}
},
created(){
this.init()
},
})
let window_url = "http://127.0.0.1:8099/";
// let window_url = "http://127.0.0.1:8099/";
let window_url = window.location.protocol + "//" + window.location.host + "/";
function RquestsGet(url){
let uri = window_url + url;
......
......@@ -8,33 +8,10 @@ new Vue({
taskvalue: '',
start_date: '',
end_date:'',
takeList:[],
takevalue: '',
loading: true,
Series:[
{
type: 'bar',
barWidth: 20,
barCategoryGap: "20%",
label:{
normal: {
position: 'right',
show: true,
color: '#000'
}
},
itemStyle:{
normal:{
color: '#fccb04'
},
emphasis:{
color: '#f7d139'
}
},
encode: {
x: 'amount',
y: 'product'
}
}
]
tableData: []
}
},
methods: {
......@@ -42,154 +19,103 @@ new Vue({
console.log(dateRange);
this.start_date = dateRange[0];
this.end_date = dateRange[1];
this.getStatistics(this.taskvalue,this.start_date,this.end_date); // 获取统计数据
this.getRule(this.taskvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
},
changeTask(msg){
console.log(msg);
this.taskvalue = msg;
this.getStatistics(this.taskvalue,this.start_date,this.end_date); // 获取统计数据
this.getTake()
this.getRule(this.taskvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
},
changeTake(msg){
this.takevalue = msg;
this.getRule(this.taskvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
console.log(msg);
},
getTask(){
let that = this;
RquestsGet('api/v1/tasks/obtain/').then(data => {
that.taskList = [
{id:'',name:'全省'},
{id:'合肥',name:'合肥'},
{id:'芜湖',name:'芜湖'},
{id:'蚌埠',name:'蚌埠'},
{id:'淮南',name:'淮南'},
{id:'马鞍山',name:'马鞍山'},
{id:'淮北',name:'淮北'},
{id:'铜陵',name:'铜陵'},
{id:'安庆',name:'安庆'},
{id:'黄山',name:'黄山'},
{id:'滁州',name:'滁州'},
{id:'阜阳',name:'阜阳'},
{id:'毫州',name:'毫州'},
{id:'宿州',name:'宿州'},
{id:'六安',name:'六安'},
{id:'宣城',name:'宣城'},
{id:'巢湖',name:'巢湖'},
{id:'池州',name:'池州'},
{id:'安徽省营业部',name:'安徽省营业部'},
];
//RquestsGet('api/v1/tasks/obtain/').then(data => {
// //console.log(data);
// if(data.code != 0){
// that.taskList = [{id:'',name:'全部任务'}];
// }else{
// that.taskList = [{id:'',name:'全部任务'}].concat(data.data);
// that.getTake()
// }
//})
},
getTake(){
let that = this;
RquestsGet('api/v1/tasks/seat/?task=' + that.taskvalue).then(data => {
//console.log(data);
if(data.code != 0){
that.taskList = [{id:'',name:'全部任务'}];
//that.takeList = [{agentName:'全部坐席'}]
}else{
that.taskList = [{id:'',name:'全部任务'}].concat(data.data);
that.takeList = data.data;
}
})
},
ChartsOne(msg){
let sourceArr = [
[ 'amount', 'product'],
].concat(msg);
let option = {
title:{
text:'坐席得分统计',
x: '50%',
textAlign: 'center'
},
dataset: {
source: sourceArr
},
grid: {containLabel: true},
xAxis: {name: 'amount',max:'100'},
yAxis: {type: 'category',boundaryGap:'20%'},
series: this.Series
};
var myChart = echarts.init(document.getElementById('main'));
myChart.setOption(option)
if(msg.length == 0){
myChart.showLoading({
text: '暂无数据',
color: '#ffffff',
textColor: '#8a8e91',
maskColor: 'rgba(255, 255, 255, 0.8)',
}
);
}else{
myChart.hideLoading();
}
window.onresize = function(){
myChart.resize();
}
},
ChartsTwo(msg){
let sourceArr = [
[ 'amount', 'product'],
].concat(msg);
var optionTwo = {
title:{
text:'违规话数统计',
x: '50%',
textAlign: 'center'
},
dataset: {
source: sourceArr
},
grid: {containLabel: true},
xAxis: {name: 'amount'},
yAxis: {type: 'category',boundaryGap:'20%'},
series: this.Series
};
var myChartTwo = echarts.init(document.getElementById('mainTwo'));
myChartTwo.setOption(optionTwo);
if(msg.length == 0){
myChartTwo.showLoading({
text: '暂无数据',
color: '#ffffff',
textColor: '#8a8e91',
maskColor: 'rgba(255, 255, 255, 0.8)',
}
);
}else{
myChartTwo.hideLoading();
}
window.onresize = function(){
myChartTwo.resize();
}
},
getStatistics(task,start_date,end_date){
getRule(task,start_date,end_date,agentName){
let that = this;
this.$loading({text:'数据加载中...'});
RquestsPost('api/v1/tasks/seat_score/',{task,start_date,end_date}).then(data => {
console.log(data.data);
let arr = [];
if(data.code != 0){
if(data.msg){
that.$message(data.msg);
}else{
that.$message('服务器错误')
}
}
if(!data.data){
this.$loading().close();
return false;
}
for(let key in data.data){
arr.push([data.data[key],key])
}
console.log(arr);
that.ChartsOne(arr);
});
RquestsPost('api/v1/tasks/seat_session/',{task,start_date,end_date}).then(data => {
//this.$loading({text:'数据加载中...'});
RquestsPost('api/v1/tasks/seat_rule/',{task,start_date,end_date,agentName}).then(data => {
console.log(data.data);
let arr = [];
if(data.code != 0){
that.$message(data.msg);
if(data.msg){
that.$message(data.msg);
}else{
that.$message('服务器错误')
}
}
this.tableData = data.data;
if(!data.data){
this.$loading().close();
return false;
}
for(let key in data.data){
arr.push([data.data[key],key])
};
console.log(arr);
that.ChartsTwo(arr);
this.$loading().close();
});
//for(let key in data.data){
// arr.unshift([data.data[key],key])
//}
this.$loading().close();
})
},
dateFormat(date){
return date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate();
},
init(){
this.dateRange = [new Date(new Date()-24*60*60*1000*30), new Date()];
this.start_date = this.dateFormat(new Date(new Date()-24*60*60*1000*30));
this.dateRange = [new Date(new Date()-24*60*60*1000), new Date()];
this.start_date = this.dateFormat(new Date(new Date()-24*60*60*1000));
this.end_date = this.dateFormat(new Date());
this.getTask(); // 获取任务
let that = this;
//this.getTake(); // 获取坐席
console.log(this.dateRange);
this.getStatistics(this.taskvalue,this.start_date,this.end_date); // 获取统计数据
this.getRule(this.taskvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
}
},
......
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