refector: 尝试访问卡片以确保卡片生成
This commit is contained in:
parent
7128e67e92
commit
b1ec172829
|
@ -157,9 +157,15 @@ class HrmService:
|
||||||
"endDate": endDate
|
"endDate": endDate
|
||||||
}
|
}
|
||||||
_, res = dhClient.request(**dhapis['card_add'], json=json_data)
|
_, res = dhClient.request(**dhapis['card_add'], json=json_data)
|
||||||
time.sleep(6) # 等待确保生成卡片
|
|
||||||
cls.save(ep, data={'dh_face_card': cardNumber,
|
cls.save(ep, data={'dh_face_card': cardNumber,
|
||||||
'dh_face_card_start': startDate, 'dh_face_card_end': endDate})
|
'dh_face_card_start': startDate, 'dh_face_card_end': endDate})
|
||||||
|
anum = 0 # 尝试次数以确保卡片生成
|
||||||
|
while anum < 6:
|
||||||
|
time.sleep(2)
|
||||||
|
is_ok, res = dhClient.request(**dhapis['card_detail'], params={'cardNumber': cardNumber}, raise_exception=False)
|
||||||
|
if is_ok == 'success':
|
||||||
|
break
|
||||||
|
anum = anum + 1
|
||||||
return cardNumber
|
return cardNumber
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -186,14 +192,14 @@ class HrmService:
|
||||||
"timeQuantumId": 1,
|
"timeQuantumId": 1,
|
||||||
"cardPrivilegeDetails": details
|
"cardPrivilegeDetails": details
|
||||||
}
|
}
|
||||||
is_ok, res = dhClient.request(**dhapis['card_door_authority'], json=json_data, raise_exception=False)
|
dhClient.request(**dhapis['card_door_authority'], json=json_data)
|
||||||
if is_ok == 'fail' and '44999999' in res['code']:
|
# if is_ok == 'fail' and '44999999' in res['code']:
|
||||||
time.sleep(14)
|
# time.sleep(14)
|
||||||
dhClient.request(**dhapis['card_door_authority'], json=json_data)
|
# dhClient.request(**dhapis['card_door_authority'], json=json_data)
|
||||||
elif is_ok == 'fail':
|
# elif is_ok == 'fail':
|
||||||
raise ParseError(**res)
|
# raise ParseError(**res)
|
||||||
elif is_ok == 'error':
|
# elif is_ok == 'error':
|
||||||
raise APIException(**DH_REQUEST_ERROR)
|
# raise APIException(**DH_REQUEST_ERROR)
|
||||||
cls.save(ep, data={'dh_dchannels': dh_dchannels})
|
cls.save(ep, data={'dh_dchannels': dh_dchannels})
|
||||||
return dh_dchannels
|
return dh_dchannels
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue