feat: 批量清空办公室打卡门禁的相关方权限

This commit is contained in:
caoqianming 2023-10-09 17:29:28 +08:00
parent 29e94f8546
commit 9c0423d0dc
1 changed files with 21 additions and 0 deletions

View File

@ -480,6 +480,9 @@ class HrmService:
@classmethod
def init_doorauth(cls):
"""
根据third_info里的dchannels信息生成表, 后续dchannels可以不用了
"""
from apps.third.models import DoorAuth
from apps.utils.snowflake import idWorker
DoorAuth.objects.all().delete()
@ -493,3 +496,21 @@ class HrmService:
DoorAuth(id=id, employee=ep, dchannel=TDevice.objects.get(code=i)))
DoorAuth.objects.bulk_create(drs)
print(f'{ind+1}-{ep.name}-doorauth已创建')
@classmethod
def clear_bgl_r(cls):
"""
清空办公室打卡门禁的相关方权限
"""
from apps.third.models import DoorAuth
qs = DoorAuth.objects.filter(
employee__type='remployee', dchannel__code='1002222$7$0$0')
for ins in qs:
dh_face_card = ins.employee.third_info['dh_face_card']
dh_id = ins.employee.third_info['dh_id']
rdict = {"personIdsString": str(dh_id),
"cardNumberString": str(dh_face_card), "channelCode": ins.dchannel.code}
dhClient.request(
**dhapis['card_door_authority_delete'], json=rdict)
ins.delete()
print(f'{ins.employee.name}-办公室打卡权限已删除')