bind rpj bug

This commit is contained in:
曹前明 2022-10-24 09:04:36 +08:00
parent 98035be264
commit 99f84f48cd
4 changed files with 9 additions and 8 deletions

View File

@ -78,15 +78,17 @@ class EmployeeCreateUpdateSerializer(CustomModelSerializer):
# 同时去除门禁授权 # 同时去除门禁授权
if settings.DAHUA_ENABLED and dhClient: if settings.DAHUA_ENABLED and dhClient:
# 如果是正式员工或相关方且有门禁权限: # 如果是正式员工或相关方且有门禁权限:
now = datetime.now()
if instance.type in ['employee', 'remployee']: if instance.type in ['employee', 'remployee']:
start_time = None start_time = None
end_time = None end_time = None
if instance.third_info.get('dh_face_card', None) is None and instance.type == 'employee': # 如果是正式员工,给长时间期限
start_time = now
end_time = now + timedelta(days=7300)
if instance.job_state == 20 and old_job_state == 10: # 离职 if instance.job_state == 20 and old_job_state == 10: # 离职
now = datetime.now()
start_time = now start_time = now
end_time = now + timedelta(minutes=60) end_time = now + timedelta(minutes=60)
elif instance.job_state == 10 and old_job_state == 20 and instance.type == 'employee': # 正式员工重新在职 elif instance.job_state == 10 and old_job_state == 20 and instance.type == 'employee': # 正式员工重新在职
now = datetime.now()
start_time = now start_time = now
end_time = now + timedelta(days=7300) end_time = now + timedelta(days=7300)
HrmService.sync_dahua_employee(ep=instance, old_photo=old_photo, HrmService.sync_dahua_employee(ep=instance, old_photo=old_photo,

View File

@ -7,7 +7,7 @@ from apps.third.models import TDevice
from apps.third.tapis import dhapis from apps.third.tapis import dhapis
from apps.third.dahua import dhClient from apps.third.dahua import dhClient
from apps.utils.tools import rannum, ranstr from apps.utils.tools import rannum, ranstr
from datetime import datetime from datetime import datetime, timedelta
from django.utils import timezone from django.utils import timezone
myLogger = logging.getLogger('log') myLogger = logging.getLogger('log')
@ -133,10 +133,9 @@ class HrmService:
cardId = res['id'] cardId = res['id']
cardNumber = str(ep.id)[3:8] + rannum(5) cardNumber = str(ep.id)[3:8] + rannum(5)
now = datetime.now() now = datetime.now()
if start_time is None: # 如果未规定时间范围, 默认50年 if start_time is None: # 如果未规定时间范围, 默认1小时
startDate = now.strftime("%Y-%m-%d %H:%M:%S") startDate = now.strftime("%Y-%m-%d %H:%M:%S")
endDate = (datetime(year=now.year+50, endDate = (now+timedelta(minutes=60)).strftime("%Y-%m-%d %H:%M:%S")
month=now.month, day=1)).strftime("%Y-%m-%d %H:%M:%S")
else: else:
startDate = start_time.strftime("%Y-%m-%d %H:%M:%S") startDate = start_time.strftime("%Y-%m-%d %H:%M:%S")
endDate = end_time.strftime("%Y-%m-%d %H:%M:%S") endDate = end_time.strftime("%Y-%m-%d %H:%M:%S")

View File

@ -29,7 +29,7 @@ def sync_to_rep(ep: Employee):
def bind_rpj(ticket: Ticket, transition: Transition, new_ticket_data: dict): def bind_rpj(ticket: Ticket, transition: Transition, new_ticket_data: dict):
rpj = Rpj.objects.get(id=new_ticket_data['rpj']) rpj = Rpj.objects.get(id=new_ticket_data['rpj'])
ticket_data = ticket.ticket_data ticket_data = ticket.ticket_data
ticket_data.update({'belong_dept': rpj.belong_dept}) ticket_data.update({'belong_dept': rpj.belong_dept.id})
ticket.ticket_data = ticket_data ticket.ticket_data = ticket_data
rpj.ticket = ticket rpj.ticket = ticket
rpj.state = Rpj.RPJ_AUDIT rpj.state = Rpj.RPJ_AUDIT

View File

@ -424,7 +424,7 @@ class UserViewSet(CustomModelViewSet):
search_fields = ['username', 'name', 'phone', 'email'] search_fields = ['username', 'name', 'phone', 'email']
select_related_fields = ['superior', 'belong_dept', 'post'] select_related_fields = ['superior', 'belong_dept', 'post']
prefetch_related_fields = ['posts', 'roles', 'depts'] prefetch_related_fields = ['posts', 'roles', 'depts']
ordering = ['type', 'create_time'] ordering = ['create_time', 'type']
# def filter_queryset(self, queryset): # def filter_queryset(self, queryset):
# if not self.detail: # if not self.detail: