Commit 15bda856 authored by lvshibao's avatar lvshibao

代码整理

parent 7461aed9
......@@ -98,7 +98,6 @@ class AgencyApi(viewsets.ViewSet):
"""
city_id = req.GET.get('city_id', '')
country_id = req.GET.get('country_id', '')
team_list = list()
top = Country.objects.filter(id=city_id).first()
if top is not None:
if top.parent is None:
......
This diff is collapsed.
This diff is collapsed.
......@@ -16,6 +16,15 @@ score_item_service = {'服务用语': 15, '开场白': 5, '结束语': 3, '服
score_item_business = {'异议处理': 10, '业务促成': 10, '预约及流转': 10, '服务介绍': 10, '未提供报价': 2, '成功件信息核实': 20}
def get_remain(check):
remain = 0
if check['startTime'] and check['closeTime']:
start = datetime.strptime(check['startTime'], '%Y-%m-%d %H:%M:%S').timestamp()
close = datetime.strptime(check['closeTime'], '%Y-%m-%d %H:%M:%S').timestamp()
remain = int(close - start)
return remain
def team_seat():
teams = Team.objects.values_list('id', 'name')
team_id_name = {team[0]: team[1] for team in teams}
......@@ -53,13 +62,8 @@ def rule_stat(start_date=None, end_date=None):
rules_list = []
data = json.loads(result)
for d in data:
remain = 0
if check['startTime'] and check['closeTime']:
start = datetime.strptime(check['startTime'], '%Y-%m-%d %H:%M:%S').timestamp()
close = datetime.strptime(check['closeTime'], '%Y-%m-%d %H:%M:%S').timestamp()
remain = int(close - start)
if 'isViolation' in d.keys() and d['isViolation'] and 'rule' in d.keys() and 'name' in d[
'rule'].keys():
remain = get_remain(check)
if 'isViolation' in d.keys() and d['isViolation'] and 'rule' in d.keys() and 'name' in d['rule'].keys():
name = d['rule']['name']
rule_obj = {'create_date': start_date, 'sessionCollectionId': t['sessionCollectionId'],
'rule': name, 'rule_num': 1,
......@@ -102,11 +106,7 @@ def seat_stat(start_date=None, end_date=None):
seat_list = []
for check in checks:
stat_count += 1
remain = 0
if check['startTime'] and check['closeTime']:
start = datetime.strptime(check['startTime'], '%Y-%m-%d %H:%M:%S').timestamp()
close = datetime.strptime(check['closeTime'], '%Y-%m-%d %H:%M:%S').timestamp()
remain = int(close - start)
remain = get_remain(check)
if check['agentName'] in seat_dict.keys():
seat = seat_dict.get(check['agentName'])
seat['total_session'] += 1
......
This diff is collapsed.
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
from inspect_report.models import Seat
def page_with_seat_name(all_objects, page, page_size, agent=False):
paginator = Paginator(all_objects, page_size)
total_count = paginator.count
try:
objects = paginator.page(page)
except PageNotAnInteger:
objects = paginator.page(1)
except EmptyPage:
objects = paginator.page(paginator.num_pages)
if agent:
objects = set_object_seat_name(objects)
return total_count, objects
def set_object_seat_name(objects):
agent_names = [x['agentName'] for x in objects]
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 object_dict in objects:
object_dict['seatName'] = seats_code_name.get(object_dict['agentName'], object_dict['agentName'])
return objects
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