Commit a1872f7b authored by lvshibao's avatar lvshibao

rule_detail 根据用户名筛选

parent 028fe762
...@@ -20,4 +20,25 @@ TABLE_PRE = '' ...@@ -20,4 +20,25 @@ TABLE_PRE = ''
name_list = ['合肥', '芜湖', '淮北', '安庆', '黄山', '滁州', '阜阳', '亳州', '宿州', '六安', '宣城', '巢湖', '池州', '淮南', '安徽省营业部', '蚌埠', '马鞍山', name_list = ['合肥', '芜湖', '淮北', '安庆', '黄山', '滁州', '阜阳', '亳州', '宿州', '六安', '宣城', '巢湖', '池州', '淮南', '安徽省营业部', '蚌埠', '马鞍山',
'铜陵'] '铜陵']
name_code_dict = {
'合肥': '3401',
'芜湖': '3402',
'淮北': '3406',
'安庆': '3408',
'黄山': '3410',
'滁州': '3411',
'阜阳': '3412',
'亳州': '3416',
'宿州': '3422',
'六安': '3424',
'宣城': '3425',
'巢湖': '3426',
'池州': '3429',
'淮南': '3404',
'安徽省营业部': '3431',
'蚌埠': '3403',
'马鞍山': '3405',
'铜陵': '3407',
}
USER_INFO_URL = 'http://172.17.1.74:8248/getUserInfo' USER_INFO_URL = 'http://172.17.1.74:8248/getUserInfo'
...@@ -8,7 +8,7 @@ from rest_framework.response import Response ...@@ -8,7 +8,7 @@ from rest_framework.response import Response
from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, ScoreStat, Round from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, ScoreStat, Round
import json import json
from datetime import datetime, timedelta from datetime import datetime, timedelta
from config.config import TABLE_PRE, name_list from config.config import TABLE_PRE, name_list, name_code_dict
from django.views.decorators.clickjacking import xframe_options_exempt from django.views.decorators.clickjacking import xframe_options_exempt
import logging import logging
from pypinyin import Style, pinyin from pypinyin import Style, pinyin
...@@ -516,12 +516,14 @@ class TasksApi(viewsets.ViewSet): ...@@ -516,12 +516,14 @@ class TasksApi(viewsets.ViewSet):
return Response({'code': 0, 'msg': 'success', 'data': data_sort, 'username': username}) return Response({'code': 0, 'msg': 'success', 'data': data_sort, 'username': username})
@action(['post'], detail=False) @action(['post'], detail=False)
@get_account_info
def rule_detail(self, req: Request): def rule_detail(self, req: Request):
""" """
首页概述-违规项统计 首页概述-违规项统计
:param req: :param req:
:return: :return:
""" """
username = req.data.get('username', '')
tables = req.data.get('tables', '') tables = req.data.get('tables', '')
rule_name = req.data.get('rule', '') rule_name = req.data.get('rule', '')
page = req.data.get('page', '1') page = req.data.get('page', '1')
...@@ -536,6 +538,8 @@ class TasksApi(viewsets.ViewSet): ...@@ -536,6 +538,8 @@ class TasksApi(viewsets.ViewSet):
table_list = tables table_list = tables
session_condition = {'create_date__gte': q_start_date, 'create_date__lt': q_end_date, 'rule': rule_name, session_condition = {'create_date__gte': q_start_date, 'create_date__lt': q_end_date, 'rule': rule_name,
'sessionCollectionId__in': table_list} 'sessionCollectionId__in': table_list}
if username in name_list:
session_condition['agentName__iregex'] = '*' + name_code_dict[username] + '*'
checks = RulesStat.objects.filter(**session_condition).values('agentName', 'customName', 'remainTime', 'score', checks = RulesStat.objects.filter(**session_condition).values('agentName', 'customName', 'remainTime', 'score',
'sessionCollectionId', 'sessionId', 'taskId') 'sessionCollectionId', 'sessionId', 'taskId')
paginator = Paginator(checks, page_size) paginator = Paginator(checks, 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