feat: init_doorauth
This commit is contained in:
parent
b479db9f89
commit
af105384fe
|
@ -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已创建')
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue