diff --git a/apps/hrm/services.py b/apps/hrm/services.py index 432302b9..2b753d30 100755 --- a/apps/hrm/services.py +++ b/apps/hrm/services.py @@ -475,3 +475,19 @@ class HrmService: return embedding_objs[0]["embedding"], '' except Exception as e: return None, '人脸数据获取失败请重新上传图片' + + @classmethod + def init_doorauth(cls): + from apps.third.models import DoorAuth + from apps.utils.snowflake import idWorker + DoorAuth.objects.all().delete() + for ind, ep in enumerate(Employee.objects.all().order_by('create_time')): + third_info = ep.third_info + if third_info.get('dh_dchannels', None): + drs = [] + for i in third_info['dh_dchannels']: + id = idWorker.get_id() + drs.append( + DoorAuth(id=id, employee=ep, dchannel=TDevice.objects.get(code=i))) + DoorAuth.objects.bulk_create(drs) + print(f'{ind+1}-{ep.name}-doorauth已创建') diff --git a/apps/third/views_d.py b/apps/third/views_d.py index a83e1ea4..8f9bf9c8 100644 --- a/apps/third/views_d.py +++ b/apps/third/views_d.py @@ -552,6 +552,7 @@ class DoorAuthViewSet(ListModelMixin, DestroyModelMixin, CustomGenericViewSet): filterset_fields = ['dchannel', 'employee'] select_related_fields = ['dchannel', 'employee'] search_fields = ['employee__name'] + ordering = '-create_time' @transaction.atomic def perform_destroy(self, instance):