fix: while 循环做card_door_authority的补偿机制
This commit is contained in:
parent
f59426b426
commit
8d3d1934b7
|
@ -156,16 +156,16 @@ class HrmService:
|
||||||
"startDate": startDate,
|
"startDate": startDate,
|
||||||
"endDate": endDate
|
"endDate": endDate
|
||||||
}
|
}
|
||||||
_, res = dhClient.request(**dhapis['card_add'], json=json_data)
|
dhClient.request(**dhapis['card_add'], json=json_data)
|
||||||
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 # 尝试次数以确保卡片生成
|
# anum = 0 # 尝试次数以确保卡片生成
|
||||||
while anum < 6:
|
# while anum < 10:
|
||||||
time.sleep(2)
|
# time.sleep(2)
|
||||||
is_ok, res = dhClient.request(**dhapis['card_detail'], params={'cardNumber': cardNumber}, raise_exception=False)
|
# is_ok, res = dhClient.request(**dhapis['card_detail'], params={'cardNumber': cardNumber}, raise_exception=False)
|
||||||
if is_ok == 'success':
|
# if is_ok == 'success':
|
||||||
break
|
# break
|
||||||
anum = anum + 1
|
# anum = anum + 1
|
||||||
return cardNumber
|
return cardNumber
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -192,14 +192,19 @@ class HrmService:
|
||||||
"timeQuantumId": 1,
|
"timeQuantumId": 1,
|
||||||
"cardPrivilegeDetails": details
|
"cardPrivilegeDetails": details
|
||||||
}
|
}
|
||||||
dhClient.request(**dhapis['card_door_authority'], json=json_data)
|
ind = 0
|
||||||
# if is_ok == 'fail' and '44999999' in res['code']:
|
while ind < 6:
|
||||||
# time.sleep(14)
|
time.sleep(5)
|
||||||
# dhClient.request(**dhapis['card_door_authority'], json=json_data)
|
is_ok, res = dhClient.request(**dhapis['card_door_authority'], json=json_data, raise_exception=False)
|
||||||
# elif is_ok == 'fail':
|
if is_ok == 'success':
|
||||||
# raise ParseError(**res)
|
break
|
||||||
# elif is_ok == 'error':
|
elif is_ok == 'fail' and '44999999' in res['code']:
|
||||||
# raise APIException(**DH_REQUEST_ERROR)
|
ind = ind + 1
|
||||||
|
continue
|
||||||
|
elif is_ok == 'fail':
|
||||||
|
raise ParseError(**res)
|
||||||
|
elif is_ok == '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