三方token 不过期
This commit is contained in:
parent
7aa6f5ccea
commit
e8ae55606f
|
@ -234,14 +234,14 @@ def create_remind(event: Event, params: dict):
|
||||||
def check_not_in_place(opl: Opl):
|
def check_not_in_place(opl: Opl):
|
||||||
# 检查作业人员未就位事件(直接创建事件)
|
# 检查作业人员未就位事件(直接创建事件)
|
||||||
area = opl.operation.area
|
area = opl.operation.area
|
||||||
try:
|
if 'xx_rail' in area.third_info:
|
||||||
railId = area.third_info['xx_rail']['id']
|
railId = area.third_info['xx_rail']['id']
|
||||||
json = {
|
json = {
|
||||||
"railId": railId,
|
"railId": railId,
|
||||||
"type": ""
|
"type": ""
|
||||||
}
|
}
|
||||||
is_ok, res = xxClient.request(**xxapis['rail_ibeacon_list'], json=json, raise_exception=False)
|
is_ok, res = xxClient.request(**xxapis['rail_ibeacon_list'], json=json, raise_exception=False)
|
||||||
if is_ok:
|
if is_ok == 'success':
|
||||||
blt_list = res['recordList']
|
blt_list = res['recordList']
|
||||||
macs = [] # 所有该区域在线标签
|
macs = [] # 所有该区域在线标签
|
||||||
for i in blt_list:
|
for i in blt_list:
|
||||||
|
@ -264,32 +264,26 @@ def check_not_in_place(opl: Opl):
|
||||||
})
|
})
|
||||||
notify_event(event)
|
notify_event(event)
|
||||||
break
|
break
|
||||||
except Exception:
|
|
||||||
myLogger.error('检查作业人员未就位失败', exc_info=True)
|
|
||||||
|
|
||||||
|
|
||||||
def check_miss_lcard(ep: Employee, area: Area):
|
def check_miss_lcard(ep: Employee, area: Area):
|
||||||
# 获取当前区域下的定位卡列表
|
# 获取当前区域下的定位卡列表
|
||||||
try:
|
if 'xx_rail' in area.third_info:
|
||||||
railId = area.third_info['xx_rail']['id']
|
railId = area.third_info['xx_rail']['id']
|
||||||
json = {
|
json = {
|
||||||
"railId": railId,
|
"railId": railId,
|
||||||
"type": ""
|
"type": ""
|
||||||
}
|
}
|
||||||
is_ok, res = xxClient.request(**xxapis['rail_ibeacon_list'], json=json, raise_exception=False)
|
is_ok, res = xxClient.request(**xxapis['rail_ibeacon_list'], json=json, raise_exception=False)
|
||||||
if is_ok:
|
if is_ok == 'success':
|
||||||
blt_list = res['recordList']
|
blt_list = res['recordList']
|
||||||
macs = [] # 所有该区域在线标签
|
macs = [] # 所有该区域在线标签
|
||||||
for i in blt_list:
|
for i in blt_list:
|
||||||
macs.append(i['userId'])
|
macs.append(i['userId'])
|
||||||
td = TDevice.objects.filter(type=TDevice.DEVICE_BLT, employee=ep).first()
|
td = TDevice.objects.filter(type=TDevice.DEVICE_BLT, employee=ep).first()
|
||||||
if td:
|
if td and td.code in macs:
|
||||||
if td.code not in macs:
|
return False
|
||||||
return True
|
return True
|
||||||
else:
|
|
||||||
return True
|
|
||||||
except Exception:
|
|
||||||
myLogger.error('检查未带定位卡失败', exc_info=True)
|
|
||||||
|
|
||||||
|
|
||||||
def dispatch_dahua_event(data: dict):
|
def dispatch_dahua_event(data: dict):
|
||||||
|
@ -426,7 +420,7 @@ def loc_change(data):
|
||||||
ep_loc_dict['time2'] = time2
|
ep_loc_dict['time2'] = time2
|
||||||
if area_fix and ep_loc_dict['area_fix_id'] == area_fix['id']:
|
if area_fix and ep_loc_dict['area_fix_id'] == area_fix['id']:
|
||||||
# 如果停留在该区域
|
# 如果停留在该区域
|
||||||
cache.set(key_str, ep_loc_dict)
|
cache.set(key_str, ep_loc_dict, timeout=None)
|
||||||
# 在该固定区域停留时间(分钟)
|
# 在该固定区域停留时间(分钟)
|
||||||
stay_minute = int((ep_loc_dict['time2']-ep_loc_dict['time1'])/60)
|
stay_minute = int((ep_loc_dict['time2']-ep_loc_dict['time1'])/60)
|
||||||
# 判断停留时间是否合理
|
# 判断停留时间是否合理
|
||||||
|
@ -449,7 +443,7 @@ def loc_change(data):
|
||||||
else:
|
else:
|
||||||
ep_loc_dict['time1'] = time2
|
ep_loc_dict['time1'] = time2
|
||||||
ep_loc_dict['area_fix_id'] = area_fix['id'] if area_fix else None
|
ep_loc_dict['area_fix_id'] = area_fix['id'] if area_fix else None
|
||||||
cache.set(key_str, ep_loc_dict)
|
cache.set(key_str, ep_loc_dict, timeout=None)
|
||||||
return ep_loc_dict
|
return ep_loc_dict
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class DhClient:
|
||||||
}
|
}
|
||||||
is_ok, res = self.request(**dhapis['token_login'], params=params, raise_exception=False)
|
is_ok, res = self.request(**dhapis['token_login'], params=params, raise_exception=False)
|
||||||
if is_ok == 'success':
|
if is_ok == 'success':
|
||||||
cache.set('dh_token', res['access_token'])
|
cache.set('dh_token', res['access_token'], timeout=None)
|
||||||
self.isGetingToken = False
|
self.isGetingToken = False
|
||||||
|
|
||||||
def request(self, url: str, method: str, params=dict(), json=dict(), timeout=120,
|
def request(self, url: str, method: str, params=dict(), json=dict(), timeout=120,
|
||||||
|
@ -82,8 +82,6 @@ class DhClient:
|
||||||
raise ParseError(**err_detail)
|
raise ParseError(**err_detail)
|
||||||
return 'fail', err_detail
|
return 'fail', err_detail
|
||||||
# self.handle_log(result='success', response=ret) # 成功的日志就不记录了
|
# self.handle_log(result='success', response=ret) # 成功的日志就不记录了
|
||||||
if '/evo-apigw/admin/API/EVO/invoke/DMS' in url:
|
|
||||||
self.handle_log(result='success', response=ret)
|
|
||||||
return 'success', ret['data'] if 'data' in ret else None
|
return 'success', ret['data'] if 'data' in ret else None
|
||||||
self.handle_log(result='error', response=ret)
|
self.handle_log(result='error', response=ret)
|
||||||
if raise_exception:
|
if raise_exception:
|
||||||
|
|
|
@ -46,7 +46,7 @@ class SpClient:
|
||||||
}
|
}
|
||||||
is_ok, res = self.request(**spapis['user_login'], json=json_data, raise_exception=False)
|
is_ok, res = self.request(**spapis['user_login'], json=json_data, raise_exception=False)
|
||||||
if is_ok == 'success':
|
if is_ok == 'success':
|
||||||
cache.set('sp_token', res['user']['token'])
|
cache.set('sp_token', res['user']['token'], timeout=None)
|
||||||
self.isGetingToken = False
|
self.isGetingToken = False
|
||||||
|
|
||||||
def request(self, url: str, method: str, params=dict(), json=dict(), timeout=120,
|
def request(self, url: str, method: str, params=dict(), json=dict(), timeout=120,
|
||||||
|
|
|
@ -40,7 +40,7 @@ class XxClient:
|
||||||
}
|
}
|
||||||
is_ok, res = self.request(**xxapis['token_login'], json=json, raise_exception=False)
|
is_ok, res = self.request(**xxapis['token_login'], json=json, raise_exception=False)
|
||||||
if is_ok == 'success':
|
if is_ok == 'success':
|
||||||
cache.set('xx_token', res['token'])
|
cache.set('xx_token', res['token'], timeout=None)
|
||||||
self.isGetingToken = False
|
self.isGetingToken = False
|
||||||
|
|
||||||
def request(self, url: str, method: str = 'post', params=dict(), json=dict(), timeout=20, raise_exception=True):
|
def request(self, url: str, method: str = 'post', params=dict(), json=dict(), timeout=20, raise_exception=True):
|
||||||
|
|
|
@ -33,7 +33,7 @@ def get_user_perms_map(user):
|
||||||
user_perms_map[code][dept_id] = data_range
|
user_perms_map[code][dept_id] = data_range
|
||||||
else:
|
else:
|
||||||
user_perms_map[code] = {dept_id: pr.data_range}
|
user_perms_map[code] = {dept_id: pr.data_range}
|
||||||
cache.set('perms_' + user.id, user_perms_map, 60*60)
|
cache.set('perms_' + user.id, user_perms_map, timeout=None)
|
||||||
return user_perms_map
|
return user_perms_map
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue