|
@@ -26,6 +26,7 @@ from Service.EquipmentInfoService import EquipmentInfoService
|
|
|
from Service.ModelService import ModelService
|
|
|
from Service.VodHlsService import SplitVodHlsObject
|
|
|
from Ansjer.config import SERVER_DOMAIN_TEST, SERVER_DOMAIN_CN, SERVER_DOMAIN_US, SERVER_DOMAIN_EUR
|
|
|
+from Ansjer.config import LOGGER
|
|
|
|
|
|
|
|
|
class DeviceManagement(View):
|
|
@@ -53,6 +54,8 @@ class DeviceManagement(View):
|
|
|
return self.add_app_device_type(request_dict, response, request)
|
|
|
elif operation == 'getUidPush': # 查询推送信息
|
|
|
return self.get_uid_push(request_dict, response)
|
|
|
+ elif operation == 'checkDeviceInfo':
|
|
|
+ return self.query_device_user(request, request_dict, response)
|
|
|
else:
|
|
|
tko = TokenObject(
|
|
|
request.META.get('HTTP_AUTHORIZATION'),
|
|
@@ -481,16 +484,16 @@ class DeviceManagement(View):
|
|
|
Device_Info.objects.filter(UID__in=uidList).update(vodPrimaryUserID='', vodPrimaryMaster='')
|
|
|
|
|
|
# 上传序列号文件且选中序列号解绑uid
|
|
|
- if serialNumberList is not None and '序列号解绑uid' in delDataOptions:
|
|
|
- # 解绑uid数据
|
|
|
- UIDModel.objects.filter(uid__in=uidList, status=2).update(status=0)
|
|
|
- UIDCompanySerialModel.objects.filter(uid__uid__in=uidList).delete()
|
|
|
- CompanySerialModel.objects.filter(serial_number__in=serial_number_list).update(status=1)
|
|
|
- UidPushModel.objects.filter(uid_set__uid__in=uidList).delete()
|
|
|
- # 序列号加入重置状态redis列表
|
|
|
- redis_obj = RedisObject()
|
|
|
- for serial in serial_number_list:
|
|
|
- redis_obj.rpush(UNUSED_SERIAL_REDIS_LIST, serial)
|
|
|
+ # if serialNumberList is not None and '序列号解绑uid' in delDataOptions:
|
|
|
+ # # 解绑uid数据
|
|
|
+ # UIDModel.objects.filter(uid__in=uidList, status=2).update(status=0)
|
|
|
+ # UIDCompanySerialModel.objects.filter(uid__uid__in=uidList).delete()
|
|
|
+ # CompanySerialModel.objects.filter(serial_number__in=serial_number_list).update(status=1)
|
|
|
+ # UidPushModel.objects.filter(uid_set__uid__in=uidList).delete()
|
|
|
+ # # 序列号加入重置状态redis列表
|
|
|
+ # redis_obj = RedisObject()
|
|
|
+ # for serial in serial_number_list:
|
|
|
+ # redis_obj.rpush(UNUSED_SERIAL_REDIS_LIST, serial)
|
|
|
|
|
|
device_list = uidList if serialNumberList is None else serial_number_list
|
|
|
log = {
|
|
@@ -1059,3 +1062,54 @@ class DeviceManagement(View):
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
return response.json(0, {"list": return_value_list})
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def query_device_user(cls, request, request_dict, response):
|
|
|
+ try:
|
|
|
+ # 从请求中检索文件
|
|
|
+ file = request.FILES.get('deviceFile')
|
|
|
+ fileType = int(request_dict.get('type', 1))
|
|
|
+ uid_list = []
|
|
|
+
|
|
|
+ if not file:
|
|
|
+ return response.json(444)
|
|
|
+
|
|
|
+ # 处理文件内容并生成UID列表
|
|
|
+ for item in file:
|
|
|
+ id_val = item.decode().strip().replace(" ", "")
|
|
|
+ if fileType == 2:
|
|
|
+ uid = CommonService.get_uid_by_serial_number(id_val[:9])
|
|
|
+ uid_list.append(uid)
|
|
|
+ else:
|
|
|
+ uid_list.append(id_val)
|
|
|
+
|
|
|
+ if not uid_list:
|
|
|
+ return response.json(0, {'userInfo': []})
|
|
|
+
|
|
|
+ user_info = []
|
|
|
+ batch_size = 50 # 为查询设置合理的批处理大小
|
|
|
+
|
|
|
+ # 批量获取设备信息
|
|
|
+ for i in range(0, len(uid_list), batch_size):
|
|
|
+ batch_uids = uid_list[i:i + batch_size]
|
|
|
+ device_info_qs = Device_Info.objects.filter(UID__in=batch_uids).values('UID', 'NickName', 'ip',
|
|
|
+ 'userID__username')
|
|
|
+ uid_to_device_info = {device_info['UID']: device_info for device_info in device_info_qs}
|
|
|
+
|
|
|
+ # 将查询到的设备信息与当前批次进行匹配
|
|
|
+ for uid in batch_uids:
|
|
|
+ if uid in uid_to_device_info:
|
|
|
+ device_info = uid_to_device_info[uid]
|
|
|
+ user_info.append({
|
|
|
+ 'uid': device_info['UID'],
|
|
|
+ 'deviceName': device_info['NickName'],
|
|
|
+ 'ip': device_info['ip'],
|
|
|
+ 'uName': device_info['userID__username']
|
|
|
+ })
|
|
|
+
|
|
|
+ # 返回带有用户信息的响应
|
|
|
+ return response.json(0, {'userInfo': user_info})
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ LOGGER.error(f'查询设备信息异常: errLine: {e.__traceback__.tb_lineno}, errMsg: {repr(e)}')
|
|
|
+ return response.json(5)
|