|
@@ -26,6 +26,9 @@ from Service.CommonService import CommonService
|
|
|
from Service.EquipmentInfoService import EquipmentInfoService
|
|
|
from Service.ModelService import ModelService
|
|
|
from Service.UserDeviceService import UserDeviceService
|
|
|
+from django.utils.timezone import utc
|
|
|
+from Object.RedisObject import RedisObject
|
|
|
+import datetime
|
|
|
|
|
|
LOGGER = logging.getLogger('info')
|
|
|
|
|
@@ -816,6 +819,8 @@ class EquipmentManagerV3(View):
|
|
|
if uid_set_qs['mobile_4g'] == 1:
|
|
|
p['isCameraOpenCloud'] = 0
|
|
|
data.append(p)
|
|
|
+ # 刷新最后登录时间
|
|
|
+ self.update_user_status(userID)
|
|
|
result = data
|
|
|
return response.json(0, result)
|
|
|
|
|
@@ -1227,3 +1232,19 @@ class EquipmentManagerV3(View):
|
|
|
return response.json(0, res)
|
|
|
except Exception as e:
|
|
|
return response.json(500, repr(e))
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def update_user_status(user_id):
|
|
|
+ try:
|
|
|
+ redisObj = RedisObject()
|
|
|
+ key = f'BASIC:LOGIN:STATUS:{user_id}'
|
|
|
+ login_data = redisObj.get_data(key)
|
|
|
+ if login_data:
|
|
|
+ return True
|
|
|
+ now_time = datetime.datetime.utcnow().replace(tzinfo=utc).astimezone(utc)
|
|
|
+ Device_User.objects.filter(userID=user_id).update(last_login=now_time)
|
|
|
+ redisObj.set_data(key, '1', 86400)
|
|
|
+ return True
|
|
|
+ except Exception as e:
|
|
|
+ LOGGER.info('更新用户最后登录时间异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ return False
|