Commit dc66fb20 authored by lvshibao's avatar lvshibao

修改定时任务时间

parent 7005f31e
...@@ -33,16 +33,22 @@ def team_seat(): ...@@ -33,16 +33,22 @@ def team_seat():
return seat_code_team_name return seat_code_team_name
@kronos.register('30 1,6,12 * * *') @kronos.register('30 6 * * *')
def rule_stat(start_date=None, end_date=None): def rule_stat(start_date=None, end_date=None):
""" """
首页概述-违规项统计 首页概述-违规项统计
按照时间逻辑,录音任务头一天晚上跑,质检任务第二天凌晨五点钟跑,报表任务六点半跑
所以start_date为utc时间减去三小时足够了,至于报表的存储时间,存储当天时间即可,毕竟是当天的质检任务统计的报表
:return: :return:
""" """
seat_code_team_name = team_seat() seat_code_team_name = team_seat()
if not start_date and not end_date: if not start_date and not end_date:
start_date = (datetime.now() + timedelta(days=-1)).strftime('%Y-%m-%d') # 数据库中为utc时间
end_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S') start_date = (datetime.utcnow() + timedelta(hours=-3)).strftime('%Y-%m-%d %H:%M:%S')
end_date = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
create_date = (datetime.strptime(end_date, '%Y-%m-%d %H:%M:%S') + timedelta(hours=8)).strftime('%Y-%m-%d')
logger.info('[rule_stat]rule stat start...') logger.info('[rule_stat]rule stat start...')
task_condition = {'hasCheck': 1, 'createdAt__gte': start_date, 'createdAt__lt': end_date} task_condition = {'hasCheck': 1, 'createdAt__gte': start_date, 'createdAt__lt': end_date}
tasks = Tasks.objects.filter(**task_condition).values('id', 'name', 'sessionCollectionId') tasks = Tasks.objects.filter(**task_condition).values('id', 'name', 'sessionCollectionId')
...@@ -63,9 +69,11 @@ def rule_stat(start_date=None, end_date=None): ...@@ -63,9 +69,11 @@ def rule_stat(start_date=None, end_date=None):
data = json.loads(result) data = json.loads(result)
for d in data: for d in data:
remain = get_remain(check) remain = get_remain(check)
if 'isViolation' in d.keys() and d['isViolation'] and 'rule' in d.keys() and 'name' in d['rule'].keys(): if 'isViolation' in d.keys() and d['isViolation'] and 'rule' in d.keys() and 'name' in d[
'rule'].keys():
name = d['rule']['name'] name = d['rule']['name']
rule_obj = {'create_date': start_date, 'sessionCollectionId': t['sessionCollectionId'],
rule_obj = {'create_date': create_date, 'sessionCollectionId': t['sessionCollectionId'],
'rule': name, 'rule_num': 1, 'rule': name, 'rule_num': 1,
'task': seat_code_team_name.get(check['agentName'], '未找到团队'), 'task': seat_code_team_name.get(check['agentName'], '未找到团队'),
'agentName': check['agentName'], 'customName': check['customName'], 'agentName': check['agentName'], 'customName': check['customName'],
...@@ -80,7 +88,7 @@ def rule_stat(start_date=None, end_date=None): ...@@ -80,7 +88,7 @@ def rule_stat(start_date=None, end_date=None):
logger.info('[rule_stat]rule stat end.') logger.info('[rule_stat]rule stat end.')
@kronos.register('30 1,6,12 * * *') @kronos.register('30 6 * * *')
def seat_stat(start_date=None, end_date=None): def seat_stat(start_date=None, end_date=None):
""" """
首页概述-违规坐席统计 首页概述-违规坐席统计
...@@ -88,8 +96,9 @@ def seat_stat(start_date=None, end_date=None): ...@@ -88,8 +96,9 @@ def seat_stat(start_date=None, end_date=None):
""" """
seat_code_team_name = team_seat() seat_code_team_name = team_seat()
if not start_date and not end_date: if not start_date and not end_date:
start_date = (datetime.now() + timedelta(days=-1)).strftime('%Y-%m-%d') start_date = (datetime.utcnow() + timedelta(hours=-3)).strftime('%Y-%m-%d %H:%M:%S')
end_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S') end_date = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
create_date = (datetime.strptime(end_date, '%Y-%m-%d %H:%M:%S') + timedelta(hours=8)).strftime('%Y-%m-%d')
logger.info('[seat_stat]violate seat stat start...') logger.info('[seat_stat]violate seat stat start...')
task_condition = {'hasCheck': 1, 'createdAt__gte': start_date, 'createdAt__lt': end_date} task_condition = {'hasCheck': 1, 'createdAt__gte': start_date, 'createdAt__lt': end_date}
tasks = Tasks.objects.filter(**task_condition).values('id', 'name', 'sessionCollectionId') tasks = Tasks.objects.filter(**task_condition).values('id', 'name', 'sessionCollectionId')
...@@ -113,7 +122,7 @@ def seat_stat(start_date=None, end_date=None): ...@@ -113,7 +122,7 @@ def seat_stat(start_date=None, end_date=None):
seat['remainTime'] += remain seat['remainTime'] += remain
seat['validate_session'] += 1 if check['violationRuleCount'] > 0 else 0 seat['validate_session'] += 1 if check['violationRuleCount'] > 0 else 0
else: else:
seat_dict[check['agentName']] = {'create_date': start_date, 'agentName': check['agentName'], seat_dict[check['agentName']] = {'create_date': create_date, 'agentName': check['agentName'],
'taskId': check['taskId'], 'taskId': check['taskId'],
'task': seat_code_team_name.get(check['agentName'], '未找到团队'), 'task': seat_code_team_name.get(check['agentName'], '未找到团队'),
'sessionCollectionId': t['sessionCollectionId'], 'total_session': 1} 'sessionCollectionId': t['sessionCollectionId'], 'total_session': 1}
...@@ -136,8 +145,9 @@ def score_stat(start_date=None, end_date=None): ...@@ -136,8 +145,9 @@ def score_stat(start_date=None, end_date=None):
""" """
seat_code_team_name = team_seat() seat_code_team_name = team_seat()
if not start_date and not end_date: if not start_date and not end_date:
start_date = (datetime.now() + timedelta(days=-1)).strftime('%Y-%m-%d') start_date = (datetime.utcnow() + timedelta(hours=-3)).strftime('%Y-%m-%d %H:%M:%S')
end_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S') end_date = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
create_date = (datetime.strptime(end_date, '%Y-%m-%d %H:%M:%S') + timedelta(hours=8)).strftime('%Y-%m-%d')
logger.info('[score_stat]seat score stat start...') logger.info('[score_stat]seat score stat start...')
task_condition = {'hasCheck': 1, 'createdAt__gte': start_date, 'createdAt__lt': end_date} task_condition = {'hasCheck': 1, 'createdAt__gte': start_date, 'createdAt__lt': end_date}
tasks = Tasks.objects.filter(**task_condition).values('id', 'name', 'sessionCollectionId') tasks = Tasks.objects.filter(**task_condition).values('id', 'name', 'sessionCollectionId')
...@@ -179,7 +189,7 @@ def score_stat(start_date=None, end_date=None): ...@@ -179,7 +189,7 @@ def score_stat(start_date=None, end_date=None):
seat['service_score'] = round((seat['service_score'] + service_score) / 2, 2) seat['service_score'] = round((seat['service_score'] + service_score) / 2, 2)
seat['business_score'] = round((seat['business_score'] + business_score) / 2, 2) seat['business_score'] = round((seat['business_score'] + business_score) / 2, 2)
else: else:
seat_dict[check['agentName']] = {'create_date': start_date, 'agentName': check['agentName'], seat_dict[check['agentName']] = {'create_date': create_date, 'agentName': check['agentName'],
'taskId': check['taskId'], 'taskId': check['taskId'],
'task': seat_code_team_name.get(check['agentName'], '未找到团队'), 'task': seat_code_team_name.get(check['agentName'], '未找到团队'),
'sessionCollectionId': t['sessionCollectionId'], 'total_session': 1, 'sessionCollectionId': t['sessionCollectionId'], 'total_session': 1,
......
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