Commit eb3c8855 authored by lvshibao's avatar lvshibao

scores页面修改

parent fb937fe0
......@@ -6,7 +6,7 @@ from rest_framework.request import Request
from before_request import before_request
from inspect_report.agency import get_team_names
from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, ScoreStat, Round
from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, ScoreStat, Round, Seat
import json
from datetime import datetime, timedelta
from config.config import TABLE_PRE, name_list
......@@ -82,7 +82,8 @@ class DataApi(viewsets.ViewSet):
task_condition['task__in'] = team_names
call_count = SeatStat.objects.filter(**task_condition).aggregate(Sum("validate_session"))['validate_session__sum']
call_count = SeatStat.objects.filter(**task_condition).aggregate(Sum("validate_session"))[
'validate_session__sum']
task_condition = req.data.get('date_condition', {})
......@@ -133,7 +134,7 @@ class DataApi(viewsets.ViewSet):
task_id = req.GET.get('task', '')
agent_name = req.GET.get('agentName', '')
sort = req.GET.get('sort', 'des')
start_date = req.GET.get('start_date', (datetime.now()+timedelta(days=-1)).strftime('%Y-%m-%d'))
start_date = req.GET.get('start_date', (datetime.now() + timedelta(days=-1)).strftime('%Y-%m-%d'))
end_date = req.GET.get('end_date', datetime.now().strftime('%Y-%m-%d'))
q_start_date = datetime.strptime(start_date, '%Y-%m-%d').date()
q_end_date = (datetime.strptime(end_date, '%Y-%m-%d') + + timedelta(days=1)).date()
......@@ -155,7 +156,7 @@ class DataApi(viewsets.ViewSet):
for s in seats:
detail = {'agentName': s['agentName'], 'validate_session': s['validate_session'],
'remainTime': s['remainTime'], 'total_session': s['total_session'],
'ratio': round(s['validate_session']/s['total_session'], 2)}
'ratio': round(s['validate_session'] / s['total_session'], 2)}
return_data.append(detail)
if sort == 'asc':
data_sort = sorted(return_data, key=lambda x: x['ratio'])
......@@ -182,22 +183,23 @@ class DataApi(viewsets.ViewSet):
return response
@action(['get'], detail=False)
@before_request
def seat_area_export(self, req: Request):
"""
地市坐席成绩分析-导出
:param req:
:return:
"""
task_id = req.GET.get('task', '')
agent_name = req.GET.get('agentName', '')
city_id = req.GET.get('city', None)
country_id = req.GET.get('country', None)
agent_name = req.GET.get('seat', '')
sort = req.GET.get('sort', '-avg_score')
start_date = req.GET.get('start_date', (datetime.now() + timedelta(days=-1)).strftime('%Y-%m-%d'))
end_date = req.GET.get('end_date', datetime.now().strftime('%Y-%m-%d'))
q_start_date = datetime.strptime(start_date, '%Y-%m-%d').date()
q_end_date = (datetime.strptime(end_date, '%Y-%m-%d') + + timedelta(days=1)).date()
task_condition = {'create_date__gte': q_start_date, 'create_date__lt': q_end_date}
if task_id:
task_condition['task'] = task_id
task_condition = req.data.get('date_condition', '')
team_names = get_team_names(city_id, country_id)
task_condition['task__in'] = team_names
if agent_name:
task_condition['agentName'] = agent_name
# , 'total_session', 'validate_num', 'validate_session', 'validate_zero'
......@@ -207,6 +209,13 @@ class DataApi(viewsets.ViewSet):
avg_score=Round(Avg('score'), 2), total_session=Sum('total_session'),
validate_num=Sum('validate_num'), validate_zero=Sum('validate_zero')) \
.order_by(sort)
agent_names = [x['agentName'] for x in rules]
seats_code_name_list = Seat.objects.filter(code__in=agent_names).values('code', 'name')
seats_code_name = dict()
for seat_code_name in seats_code_name_list:
seats_code_name[seat_code_name['code']] = seat_code_name['name']
for rule_dict in rules:
rule_dict['seatName'] = seats_code_name.get(rule_dict['agentName'], rule_dict['agentName'])
response = HttpResponse(content_type='text/csv')
file_name = '坐席成绩_' + datetime.now().strftime('%Y%m%d%H%M%S') + '.csv'
response['Content-Type'] = 'application/octet-stream'
......@@ -215,11 +224,11 @@ class DataApi(viewsets.ViewSet):
response.write(codecs.BOM_UTF8)
writer = csv.writer(response)
# 设置表头
header = ['地市', '坐席工号', '全部会话数', '触发违规项次数', '服务类平均分', '业务类平均分', '平均分', '触发0分项次数']
header = ['地市', '坐席工号', '坐席名称', '全部会话数', '触发违规项次数', '服务类平均分', '业务类平均分', '平均分', '触发0分项次数']
writer.writerow(header)
# 设置表数据
for r in rules:
row = [r['area'], r['agentName'], r['total_session'], r['validate_num'], r['avg_score_svc'],
row = [r['area'], r['agentName'], r['seatName'], r['total_session'], r['validate_num'], r['avg_score_svc'],
r['avg_score_bus'], r['avg_score'], r['validate_zero']]
writer.writerow(row)
return response
......@@ -309,7 +318,8 @@ class DataApi(viewsets.ViewSet):
writer.writerow(header)
# 设置表数据
for r in return_data:
row = [r['createdAt'], r['area'], r['agentName'], r['filename'], r['remainTime'], r['fwyy'], r['kcb'], r['jsy'],
row = [r['createdAt'], r['area'], r['agentName'], r['filename'], r['remainTime'], r['fwyy'], r['kcb'],
r['jsy'],
r['fwtd'], r['yssb'], r['jysb'], r['yycl'], r['ywcc'], r['yyjlz'], r['fwjs'], r['wtgbj'],
r['cgjxxhs'], r['wgzlf'], r['mgc'], r['total_score']]
writer.writerow(row)
......
......@@ -8,7 +8,7 @@ from rest_framework.response import Response
from before_request import before_request
from inspect_report.agency import get_team_names, get_country_names
from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, ScoreStat, Round, Team, Country
from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, ScoreStat, Round, Team, Country, Seat
import json
from datetime import datetime, timedelta
from config.config import TABLE_PRE, name_list, name_code_dict
......@@ -45,19 +45,17 @@ class TasksApi(viewsets.ViewSet):
:param req:
:return:
"""
username = req.data.get('username', '')
task_id = req.GET.get('task', '')
city_id = req.GET.get('city', None)
country_id = req.GET.get('country', None)
session_condition = req.data.get('date_condition', {})
if task_id:
session_condition['task'] = task_id
if username in name_list:
session_condition['task'] = username
seats = SeatStat.objects.filter(**session_condition).values('agentName')
return_data = []
for agent in seats:
if agent not in return_data:
return_data.append(agent)
return Response({'code': 0, 'msg': 'success', 'data': return_data, 'username': username})
team_names = get_team_names(city_id, country_id)
session_condition['task__in'] = team_names
seat_ids = SeatStat.objects.filter(**session_condition).values_list('agentName', flat=True)
seat_id_names = Seat.objects.filter(code__in=seat_ids).values('code', 'name')
seat_ids_with_name = [x['code'] for x in seat_id_names]
extra = [({'code': seat_id, 'name': seat_id} for seat_id in seat_ids if seat_id not in seat_ids_with_name)]
return Response({'code': 0, 'msg': 'success', 'data': list(seat_id_names) + extra})
@action(['post'], detail=False)
def rule(self, req: Request):
......@@ -408,17 +406,18 @@ class TasksApi(viewsets.ViewSet):
:param req:
:return:
"""
username = req.data.get('username', '')
task_id = req.data.get('task', '')
agent_name = req.data.get('agentName', '')
city_id = req.data.get('city', None)
country_id = req.data.get('country', None)
agent_name = req.data.get('seat', '')
page = req.data.get('page', '1')
page_size = req.data.get('page_size', '10')
sort = req.data.get('sort', '-avg_score')
task_condition = req.data.get('date_condition', '')
if task_id:
task_condition['task'] = task_id
if username in name_list:
task_condition['task'] = username
team_names = get_team_names(city_id, country_id)
task_condition['task__in'] = team_names
if agent_name:
task_condition['agentName'] = agent_name
# , 'total_session', 'validate_num', 'validate_session', 'validate_zero'
......@@ -428,6 +427,13 @@ class TasksApi(viewsets.ViewSet):
avg_score=Round(Avg('score'), 2), total_session=Sum('total_session'),
validate_num=Sum('validate_num'), validate_zero=Sum('validate_zero')) \
.order_by(sort)
agent_names = [x['agentName'] for x in rules]
seats_code_name_list = Seat.objects.filter(code__in=agent_names).values('code', 'name')
seats_code_name = dict()
for seat_code_name in seats_code_name_list:
seats_code_name[seat_code_name['code']] = seat_code_name['name']
for rule_dict in rules:
rule_dict['seatName'] = seats_code_name.get(rule_dict['agentName'], rule_dict['agentName'])
paginator = Paginator(rules, page_size)
total_count = paginator.count
try:
......@@ -565,12 +571,9 @@ class TasksApi(viewsets.ViewSet):
page = req.data.get('page', '1')
page_size = req.data.get('page_size', '10')
session_condition = req.data.get('date_condition', {})
team = req.data.get('team', '')
if agent_name:
session_condition['agentName'] = agent_name
if team:
session_condition['task'] = team
checks = RulesStat.objects.filter(**session_condition) \
.extra(select={'sessionCollectionId': 'sessionCollectionId'}) \
......
......@@ -107,24 +107,32 @@
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']">
</el-date-picker>
<el-select v-if="sel_is_show == true" v-model="taskvalue" filterable placeholder="请选择" @change="changeTask">
<el-select v-model="cityvalue" filterable placeholder="请选择" @change="changeCity">
<el-option
v-for="item in taskList"
v-for="item in cityList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
<el-select v-model="takevalue" filterable placeholder="请选择" @change='changeTake'>
<el-select v-model="countryvalue" filterable placeholder="请选择" @change="changeCountry">
<el-option
v-for="item in countryList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
<el-select v-model="seatvalue" filterable placeholder="请选择" @change='changeSeat'>
<el-option
label="全部工号"
value="">
</el-option>
<el-option
v-for="item in takeList"
:key="item.agentName"
:label="item.agentName"
:value="item.agentName">
v-for="item in seatList"
:key="item.code"
:label="item.name"
:value="item.code">
</el-option>
</el-select>
<el-button type='primary' size='mini' style='height:30px;' @click='loadData()'>
......@@ -133,8 +141,9 @@
<form ref="loadModal" :action="`${BASEURL}api/v1/data/seat_area_export/`" method="get">
<input type="hidden" name="start_date" :value="start_date">
<input type="hidden" name="end_date" :value="end_date">
<input type="hidden" name="task" :value="taskvalue">
<input type="hidden" name="agentName" :value="takevalue">
<input type="hidden" name="city" :value="cityvalue">
<input type="hidden" name="country" :value="countryvalue">
<input type="hidden" name="seat" :value="seatvalue">
<input type="hidden" name="sort" :value="sortObj.sort">
</form>
</div>
......@@ -153,13 +162,18 @@
style="width: 100%">
<el-table-column
prop="area"
label="地市"
label="团队"
width="150">
</el-table-column>
<el-table-column
prop="agentName"
label="坐席工号"
width="">
</el-table-column>
<el-table-column
prop="seatName"
label="坐席姓名"
width="">
</el-table-column>
<el-table-column
prop="total_session"
......@@ -230,9 +244,7 @@
<el-table style='margin-top:-20px' :data="poptableData" height='300'>
<el-table-column prop="agentName" label="坐席id" width='190'></el-table-column>
<!--
<el-table-column prop="customName" label="客户" width='190'></el-table-column>
-->
<el-table-column prop="seatName" label="坐席名称" width='190'></el-table-column>
<el-table-column prop="remainTime" label="通话时间(秒)">
{# <template slot-scope='scope'>#}
{# <span>{{formatSeconds(scope.row.remainTime)}}</span>#}
......@@ -264,7 +276,6 @@
<script src="{% static "inspect/js/vue.min.js" %}"></script>
<script src="{% static "inspect/js/element.js" %}"></script>
<script src="{% static "inspect/js/http.js" %}"></script>
<script type="text/javascript" src="{% static "inspect/js/config.js" %}"></script>
<script type="text/javascript" src="{% static "inspect/js/score.js" %}"></script>
</body>
</html>
......@@ -4,15 +4,18 @@ new Vue({
return {
ss: 'sas',
dateTime: '',
taskList: [],
taskvalue: '',
cityList: [],
countryList: [],
cityvalue: null,
isscrollTop: false,
popseatName: '',
scrollTop: 0,
dateRange: [new Date(), new Date()],
start_date: '',
end_date: '',
takeList: [],
takevalue: '',
seatList: [],
seatvalue: null,
teamvalue: null,
loading: true,
tableData: [],
poploading: false,
......@@ -65,60 +68,69 @@ new Vue({
name: item.prop,
sort: order
}
this.getRule(this.taskvalue, this.start_date, this.end_date, this.takevalue, this.page, this.page_size); // 获取统计数据
this.getRule(this.cityvalue, this.countryvalue, this.start_date, this.end_date, this.seatvalue, this.page, this.page_size); // 获取统计数据
},
changeRange(dateRange) {
this.start_date = dateRange[0];
this.end_date = dateRange[1];
this.page = 1;
this.getTake();
this.getRule(this.taskvalue, this.start_date, this.end_date, this.takevalue, this.page, this.page_size); // 获取统计数据
this.getRule(this.cityvalue, this.countryvalue, this.start_date, this.end_date, this.seatvalue, this.page, this.page_size); // 获取统计数据
},
changeTask(msg) {
this.taskvalue = msg;
changeCity(msg) {
this.cityvalue = msg;
this.countryvalue = null;
this.seatvalue = null;
this.getTake();
this.page = 1;
this.getRule(this.taskvalue, this.start_date, this.end_date, this.takevalue, this.page, this.page_size); // 获取统计数据
this.getRule(this.cityvalue, this.countryvalue, this.start_date, this.end_date, this.seatvalue, this.page, this.page_size); // 获取统计数据
},
changeTake(msg) {
this.takevalue = msg;
changeCountry(msg) {
this.countryvalue = msg;
this.seatvalue = null;
this.page = 1;
this.getRule(this.taskvalue, this.start_date, this.end_date, this.takevalue, this.page, this.page_size); // 获取统计数据
this.getRule(this.cityvalue, this.countryvalue, this.start_date, this.end_date, this.seatvalue, this.page, this.page_size); // 获取统计数据
},
getTask() {
changeSeat(msg) {
this.seatvalue = msg;
this.page = 1;
this.getRule(this.cityvalue, this.countryvalue, this.start_date, this.end_date, this.seatvalue, this.page, this.page_size); // 获取统计数据
},
getCity() {
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: '安徽省营业部'},
];
var request = new XMLHttpRequest();
let uri = window_url + 'api/v1/agency/city/';
request.open('GET', uri, false);
request.send(null);
if (request.status === 200) {
data = JSON.parse(request.response);
console.log(data.code);
if (data.code != 0) {
that.$message('服务器错误');
} else {
that.cityList = data.data.city_list;
that.countryList = data.data.country_list;
that.cityvalue = data.data.city_id;
console.log(that.cityvalue);
that.init_simple = true;
}
} else {
that.$message('服务器错误');
}
},
getRule(task, start_date, end_date, agentName, page, page_size) {
getRule(city, country, start_date, end_date, seat, page, page_size) {
let that = this;
// 获取表格数据
let sort = this.sortObj.sort;
this.$loading({text: '数据加载中...'});
RquestsPost('api/v1/tasks/seat_area/', {
task,
city,
country,
start_date,
end_date,
agentName,
seat,
page,
page_size,
sort
......@@ -135,20 +147,13 @@ new Vue({
},
getTake() {
let that = this;
RquestsGet('api/v1/tasks/seat/?task=' + that.taskvalue + '&start_date=' + this.start_date + '&end_date=' + this.end_date).then(data => {
RquestsGet('api/v1/tasks/seat/?city=' + that.cityvalue + '&country=' + that.countryvalue + '&start_date=' + this.start_date + '&end_date=' + this.end_date).then(data => {
//console.log(data);
if (data.code != 0) {
//that.takeList = [{agentName:'全部坐席'}]
} else {
that.takeList = data.data;
}
if (name_list.indexOf(data.username) !== -1) {
that.sel_is_show = false;
that.taskvalue = data.username;
} else {
that.sel_is_show = true;
that.seatList = data.data;
}
})
......@@ -192,24 +197,24 @@ new Vue({
CurrentChange(page) {
this.currentPage = page;
this.page = page;
this.getRule(this.taskvalue, this.start_date, this.end_date, this.takevalue, this.page, this.page_size); // 获取统计数据
this.getRule(this.cityvalue, this.countryvalue, this.start_date, this.end_date, this.seatvalue, this.page, this.page_size); // 获取统计数据
},
rowDetail(index, tableData) {
this.agentName = tableData.agentName;
this.taskvalue = tableData.area;
this.getDetail(this.taskvalue, this.start_date, this.end_date, this.poptables, this.poprule, this.poppage, this.poppagesize, this.agentName);
this.popseatName = tableData.seatName;
this.teamvalue = tableData.area;
this.getDetail(this.start_date, this.end_date, this.poptables, this.poprule, this.poppage, this.poppagesize, this.agentName);
},
popCurrentChange(page) {
this.poppage = page;
this.getDetail(this.taskvalue, this.start_date, this.end_date, this.poptables, this.poprule, this.poppage, this.poppagesize, this.agentName);
this.getDetail(this.start_date, this.end_date, this.poptables, this.poprule, this.poppage, this.poppagesize, this.agentName);
},
getDetail(task, start_date, end_date, tables, rule, page, page_size, agentName) {
getDetail(start_date, end_date, tables, rule, page, page_size, agentName, seatName) {
let that = this;
this.$loading({text: '数据加载中...'});
this.poploading = true;
RquestsPost('api/v1/tasks/score_detail/', {
task,
end_date,
start_date,
tables,
......@@ -232,6 +237,9 @@ new Vue({
//that.titleInfo = data.data;
that.poptotal = data.count;
that.poptableData = data.data;
for(let i = 0, len = that.poptableData.length; i < len; i++){
that.poptableData[i].seatName = that.popseatName
}
//this.$loading().close();
this.poploading = false;
})
......@@ -248,9 +256,9 @@ new Vue({
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.getCity(); // 获取任务
this.getTake(); // 获取坐席
this.getRule(this.taskvalue, this.start_date, this.end_date, this.takevalue, this.page, this.page_size); // 获取统计数据
this.getRule(this.cityvalue, this.countryvalue, this.start_date, this.end_date, this.seatvalue, this.page, this.page_size); // 获取统计数据
}
......
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