|
@@ -19,8 +19,11 @@ from Ansjer.config import SERVER_DOMAIN_TEST, SERVER_DOMAIN_CN, SERVER_DOMAIN_US
|
|
from Model.models import Device_Info, UidSetModel, LogModel, UID_Bucket, Unused_Uid_Meal, StsCrdModel, \
|
|
from Model.models import Device_Info, UidSetModel, LogModel, UID_Bucket, Unused_Uid_Meal, StsCrdModel, \
|
|
VodHlsModel, ExperienceContextModel, DeviceTypeModel, UidUserModel, ExperienceAiModel, AiService, \
|
|
VodHlsModel, ExperienceContextModel, DeviceTypeModel, UidUserModel, ExperienceAiModel, AiService, \
|
|
AppBundle, App_Info, AppDeviceType, DeviceNameLanguage, UIDCompanySerialModel, UidPushModel, \
|
|
AppBundle, App_Info, AppDeviceType, DeviceNameLanguage, UIDCompanySerialModel, UidPushModel, \
|
|
- CustomCustomerOrderInfo, CustomCustomerDevice
|
|
|
|
|
|
+ CustomCustomerOrderInfo, CustomCustomerDevice, DeviceVersionInfo
|
|
from Object.AWS.AmazonS3Util import AmazonS3Util
|
|
from Object.AWS.AmazonS3Util import AmazonS3Util
|
|
|
|
+from Object.Enums.RedisKeyConstant import RedisKeyConstant
|
|
|
|
+from Object.RedisObject import RedisObject
|
|
|
|
+
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.TokenObject import TokenObject
|
|
from Object.TokenObject import TokenObject
|
|
from Service.CommonService import CommonService
|
|
from Service.CommonService import CommonService
|
|
@@ -102,6 +105,16 @@ class DeviceManagement(View):
|
|
return self.call_add_app_device_type(request_dict, response, request)
|
|
return self.call_add_app_device_type(request_dict, response, request)
|
|
elif operation == 'getCustomerDeviceList': # 查询扫码添加设备列表
|
|
elif operation == 'getCustomerDeviceList': # 查询扫码添加设备列表
|
|
return self.get_customer_device_list(request_dict, response)
|
|
return self.get_customer_device_list(request_dict, response)
|
|
|
|
+
|
|
|
|
+ # 设备型号版本
|
|
|
|
+ elif operation == 'getDeviceVerInfo': # 查询设备型号版本列表
|
|
|
|
+ return self.get_device_ver_info(request_dict, response)
|
|
|
|
+ elif operation == 'addDeviceVerInfo': # 添加设备型号版本
|
|
|
|
+ return self.add_device_ver_info(request_dict, response)
|
|
|
|
+ elif operation == 'editDeviceVerInfo': # 编辑设备型号版本
|
|
|
|
+ return self.edit_device_ver_info(request_dict, response)
|
|
|
|
+ elif operation == 'delDeviceVerInfo': # 删除设备型号版本
|
|
|
|
+ return self.del_device_ver_info(request_dict, response)
|
|
else:
|
|
else:
|
|
return response.json(444, 'operation')
|
|
return response.json(444, 'operation')
|
|
|
|
|
|
@@ -1388,3 +1401,243 @@ class DeviceManagement(View):
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return response.json(500, f'error_line:{e.__traceback__.tb_lineno}, error_msg:{repr(e)}')
|
|
return response.json(500, f'error_line:{e.__traceback__.tb_lineno}, error_msg:{repr(e)}')
|
|
|
|
+
|
|
|
|
+ @staticmethod
|
|
|
|
+ def get_device_ver_info(request_dict, response):
|
|
|
|
+ d_code = request_dict.get('dCode', None)
|
|
|
|
+ software_ver = request_dict.get('softwareVer', None)
|
|
|
|
+ device_type = request_dict.get('deviceType', None)
|
|
|
|
+ page = request_dict.get('pageNo', 1) # 当前页码,默认为1
|
|
|
|
+ page_size = request_dict.get('pageSize', 10) # 每页显示的记录数,默认为10
|
|
|
|
+
|
|
|
|
+ if not all([page, page_size]):
|
|
|
|
+ return response.json(444)
|
|
|
|
+ try:
|
|
|
|
+ device_ver_info_qs = DeviceVersionInfo.objects.all()
|
|
|
|
+ if d_code:
|
|
|
|
+ device_ver_info_qs = device_ver_info_qs.filter(d_code__icontains=d_code)
|
|
|
|
+ if software_ver:
|
|
|
|
+ device_ver_info_qs = device_ver_info_qs.filter(software_ver__icontains=software_ver)
|
|
|
|
+ if device_type:
|
|
|
|
+ device_ver_info_qs = device_ver_info_qs.filter(device_type=device_type)
|
|
|
|
+
|
|
|
|
+ # 对TimeAlbum结果进行分页
|
|
|
|
+ paginator = Paginator(device_ver_info_qs.order_by("-id"), page_size)
|
|
|
|
+ device_ver_infos = paginator.page(page) # 获取当前页的数据
|
|
|
|
+
|
|
|
|
+ device_ver_info_list = []
|
|
|
|
+ # 对每个TimeAlbum,查询相关的AlbumMedia
|
|
|
|
+ for device_ver_info in device_ver_infos:
|
|
|
|
+ device_ver_info_list.append(
|
|
|
|
+ {
|
|
|
|
+ 'deviceVerId': device_ver_info.id,
|
|
|
|
+ 'dCode': device_ver_info.d_code,
|
|
|
|
+ 'softwareVer': device_ver_info.software_ver,
|
|
|
|
+ 'firmwareVer': device_ver_info.firmware_ver,
|
|
|
|
+ 'videoCode': device_ver_info.video_code,
|
|
|
|
+ 'regionAlexa': device_ver_info.region_alexa,
|
|
|
|
+ 'supportsHumanTracking': device_ver_info.supports_human_tracking,
|
|
|
|
+ 'supportsCustomVoice': device_ver_info.supports_custom_voice,
|
|
|
|
+ 'supportsDualBandWifi': device_ver_info.supports_dual_band_wifi,
|
|
|
|
+ 'supportsFourPoint': device_ver_info.supports_four_point,
|
|
|
|
+ 'supports4g': device_ver_info.supports_4g,
|
|
|
|
+ 'supportsPTZ': device_ver_info.supports_ptz,
|
|
|
|
+ 'supportsAi': device_ver_info.supports_ai,
|
|
|
|
+ 'supportsCloudStorage': device_ver_info.supports_cloud_storage,
|
|
|
|
+ 'supportsAlexa': device_ver_info.supports_alexa,
|
|
|
|
+ 'deviceType': device_ver_info.device_type,
|
|
|
|
+ 'resolution': device_ver_info.resolution,
|
|
|
|
+ 'aiType': device_ver_info.ai_type,
|
|
|
|
+ 'supportsAlarm': device_ver_info.supports_alarm,
|
|
|
|
+ 'supportsNightVision': device_ver_info.supports_night_vision,
|
|
|
|
+ 'screenChannels': device_ver_info.screen_channels,
|
|
|
|
+ 'networkType': device_ver_info.network_type,
|
|
|
|
+ 'otherFeatures': device_ver_info.other_features,
|
|
|
|
+ 'createdTime': device_ver_info.created_time,
|
|
|
|
+ 'updatedTime': device_ver_info.updated_time
|
|
|
|
+ }
|
|
|
|
+ )
|
|
|
|
+ return response.json(0, {
|
|
|
|
+ 'total': paginator.count,
|
|
|
|
+ 'list': device_ver_info_list,
|
|
|
|
+ })
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(e)
|
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
+
|
|
|
|
+ @staticmethod
|
|
|
|
+ def add_device_ver_info(request_dict, response):
|
|
|
|
+ d_code = request_dict.get('dCode', None)
|
|
|
|
+ software_ver = request_dict.get('softwareVer', None)
|
|
|
|
+ firmware_ver = request_dict.get('firmwareVer', "")
|
|
|
|
+ video_code = request_dict.get('videoCode', None)
|
|
|
|
+ region_alexa = request_dict.get('regionAlexa', "")
|
|
|
|
+ supports_human_tracking = request_dict.get('supportsHumanTracking', 0)
|
|
|
|
+ supports_custom_voice = request_dict.get('supportsCustomVoice', 0)
|
|
|
|
+ supports_dual_band_wifi = request_dict.get('supportsDualBandWifi', 0)
|
|
|
|
+ supports_four_point = request_dict.get('supportsFourPoint', 0)
|
|
|
|
+ supports_4g = request_dict.get('supports4g', 0)
|
|
|
|
+ supports_ptz = request_dict.get('supportsPTZ', 0)
|
|
|
|
+ supports_ai = request_dict.get('supportsAi', 0)
|
|
|
|
+ supports_cloud_storage = request_dict.get('supportsCloudStorage', 0)
|
|
|
|
+ supports_alexa = request_dict.get('supportsAlexa', 0)
|
|
|
|
+ device_type = request_dict.get('deviceType', None)
|
|
|
|
+ resolution = request_dict.get('resolution', "")
|
|
|
|
+ ai_type = request_dict.get('aiType', 0)
|
|
|
|
+ supports_alarm = request_dict.get('supportsAlarm', None)
|
|
|
|
+ supports_night_vision = request_dict.get('supportsNightVision', 0)
|
|
|
|
+ screen_channels = request_dict.get('screenChannels', None)
|
|
|
|
+ network_type = request_dict.get('networkType', None)
|
|
|
|
+ other_features = request_dict.get('otherFeatures', None)
|
|
|
|
+ if not all([d_code, software_ver, video_code,
|
|
|
|
+ device_type, supports_alarm,
|
|
|
|
+ screen_channels, network_type]
|
|
|
|
+ ):
|
|
|
|
+ return response.json(444)
|
|
|
|
+ try:
|
|
|
|
+ now_time = int(time.time())
|
|
|
|
+ ai_type = int(ai_type)
|
|
|
|
+ if other_features:
|
|
|
|
+ other_features = json.loads(other_features)
|
|
|
|
+ else:
|
|
|
|
+ other_features = None
|
|
|
|
+ if DeviceVersionInfo.objects.filter(d_code=d_code, software_ver=software_ver).exists():
|
|
|
|
+ return response.json(174)
|
|
|
|
+
|
|
|
|
+ DeviceVersionInfo.objects.create(
|
|
|
|
+ d_code=d_code,
|
|
|
|
+ software_ver=software_ver,
|
|
|
|
+ firmware_ver=firmware_ver,
|
|
|
|
+ video_code=video_code,
|
|
|
|
+ region_alexa=region_alexa,
|
|
|
|
+ supports_human_tracking=supports_human_tracking,
|
|
|
|
+ supports_custom_voice=supports_custom_voice,
|
|
|
|
+ supports_dual_band_wifi=supports_dual_band_wifi,
|
|
|
|
+ supports_four_point=supports_four_point,
|
|
|
|
+ supports_4g=supports_4g,
|
|
|
|
+ supports_ptz=supports_ptz,
|
|
|
|
+ supports_ai=supports_ai,
|
|
|
|
+ supports_cloud_storage=supports_cloud_storage,
|
|
|
|
+ supports_alexa=supports_alexa,
|
|
|
|
+ device_type=device_type,
|
|
|
|
+ resolution=resolution,
|
|
|
|
+ ai_type=ai_type,
|
|
|
|
+ supports_alarm=supports_alarm,
|
|
|
|
+ supports_night_vision=supports_night_vision,
|
|
|
|
+ screen_channels=screen_channels,
|
|
|
|
+ network_type=network_type,
|
|
|
|
+ other_features=other_features,
|
|
|
|
+ created_time=now_time,
|
|
|
|
+ updated_time=now_time
|
|
|
|
+ )
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(e)
|
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
+ return response.json(0)
|
|
|
|
+
|
|
|
|
+ @staticmethod
|
|
|
|
+ def edit_device_ver_info(request_dict, response):
|
|
|
|
+ device_ver_id = request_dict.get('deviceVerId', None)
|
|
|
|
+ d_code = request_dict.get('dCode', None)
|
|
|
|
+ software_ver = request_dict.get('softwareVer', None)
|
|
|
|
+ firmware_ver = request_dict.get('firmwareVer', "")
|
|
|
|
+ video_code = request_dict.get('videoCode', None)
|
|
|
|
+ region_alexa = request_dict.get('regionAlexa', "")
|
|
|
|
+ supports_human_tracking = request_dict.get('supportsHumanTracking', 0)
|
|
|
|
+ supports_custom_voice = request_dict.get('supportsCustomVoice', 0)
|
|
|
|
+ supports_dual_band_wifi = request_dict.get('supportsDualBandWifi', 0)
|
|
|
|
+ supports_four_point = request_dict.get('supportsFourPoint', 0)
|
|
|
|
+ supports_4g = request_dict.get('supports4g', 0)
|
|
|
|
+ supports_ptz = request_dict.get('supportsPTZ', 0)
|
|
|
|
+ supports_ai = request_dict.get('supportsAi', 0)
|
|
|
|
+ supports_cloud_storage = request_dict.get('supportsCloudStorage', 0)
|
|
|
|
+ supports_alexa = request_dict.get('supportsAlexa', 0)
|
|
|
|
+ device_type = request_dict.get('deviceType', None)
|
|
|
|
+ resolution = request_dict.get('resolution', "")
|
|
|
|
+ ai_type = request_dict.get('aiType', 0)
|
|
|
|
+ supports_alarm = request_dict.get('supportsAlarm', None)
|
|
|
|
+ supports_night_vision = request_dict.get('supportsNightVision', 0)
|
|
|
|
+ screen_channels = request_dict.get('screenChannels', None)
|
|
|
|
+ network_type = request_dict.get('networkType', None)
|
|
|
|
+ other_features = request_dict.get('otherFeatures', None)
|
|
|
|
+
|
|
|
|
+ if not all([device_ver_id, d_code, software_ver, video_code,
|
|
|
|
+ device_type, supports_alarm, screen_channels, network_type]):
|
|
|
|
+ return response.json(444)
|
|
|
|
+ try:
|
|
|
|
+ now_time = int(time.time())
|
|
|
|
+ ai_type = int(ai_type)
|
|
|
|
+ device_version_info_qs = DeviceVersionInfo.objects.filter(id=device_ver_id).values('d_code', 'software_ver')
|
|
|
|
+ if not device_version_info_qs.exists():
|
|
|
|
+ return response.json(173)
|
|
|
|
+ if other_features:
|
|
|
|
+ other_features = json.loads(other_features)
|
|
|
|
+ else:
|
|
|
|
+ other_features = None
|
|
|
|
+
|
|
|
|
+ d_code = device_version_info_qs[0]['d_code']
|
|
|
|
+ software_ver = device_version_info_qs[0]['software_ver']
|
|
|
|
+ version_key = RedisKeyConstant.ZOSI_DEVICE_VERSION_INFO.value + software_ver + d_code
|
|
|
|
+ # 创建Redis对象
|
|
|
|
+ redis = RedisObject()
|
|
|
|
+ # 尝试从Redis中获取数据
|
|
|
|
+ version_info = redis.get_data(version_key)
|
|
|
|
+ if version_info:
|
|
|
|
+ # 如果在Redis中找到了数据,删除缓存
|
|
|
|
+ redis.del_data(version_key)
|
|
|
|
+
|
|
|
|
+ device_version_info_qs.update(
|
|
|
|
+ d_code=d_code,
|
|
|
|
+ software_ver=software_ver,
|
|
|
|
+ firmware_ver=firmware_ver,
|
|
|
|
+ video_code=video_code,
|
|
|
|
+ region_alexa=region_alexa,
|
|
|
|
+ supports_human_tracking=supports_human_tracking,
|
|
|
|
+ supports_custom_voice=supports_custom_voice,
|
|
|
|
+ supports_dual_band_wifi=supports_dual_band_wifi,
|
|
|
|
+ supports_four_point=supports_four_point,
|
|
|
|
+ supports_4g=supports_4g,
|
|
|
|
+ supports_ptz=supports_ptz,
|
|
|
|
+ supports_ai=supports_ai,
|
|
|
|
+ supports_cloud_storage=supports_cloud_storage,
|
|
|
|
+ supports_alexa=supports_alexa,
|
|
|
|
+ device_type=device_type,
|
|
|
|
+ resolution=resolution,
|
|
|
|
+ ai_type=ai_type,
|
|
|
|
+ supports_alarm=supports_alarm,
|
|
|
|
+ supports_night_vision=supports_night_vision,
|
|
|
|
+ screen_channels=screen_channels,
|
|
|
|
+ network_type=network_type,
|
|
|
|
+ other_features=other_features,
|
|
|
|
+ created_time=now_time,
|
|
|
|
+ updated_time=now_time
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ return response.json(0)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(e)
|
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
+
|
|
|
|
+ @staticmethod
|
|
|
|
+ def del_device_ver_info(request_dict, response):
|
|
|
|
+ device_ver_id = request_dict.get('deviceVerId', None)
|
|
|
|
+ if not device_ver_id:
|
|
|
|
+ return response.json(444)
|
|
|
|
+ device_version_info_qs = DeviceVersionInfo.objects.filter(id=device_ver_id)
|
|
|
|
+ if not device_version_info_qs.exists():
|
|
|
|
+ return response.json(174)
|
|
|
|
+
|
|
|
|
+ device_version_info = device_version_info_qs.first() # Get the first instance
|
|
|
|
+ d_code = device_version_info.d_code
|
|
|
|
+ software_ver = device_version_info.software_ver
|
|
|
|
+ version_key = RedisKeyConstant.ZOSI_DEVICE_VERSION_INFO.value + software_ver + d_code
|
|
|
|
+ # 创建Redis对象
|
|
|
|
+ redis = RedisObject()
|
|
|
|
+ # 尝试从Redis中获取数据
|
|
|
|
+ version_info = redis.get_data(version_key)
|
|
|
|
+ if version_info:
|
|
|
|
+ # 如果在Redis中找到了数据,删除缓存
|
|
|
|
+ redis.del_data(version_key)
|
|
|
|
+ device_version_info_qs.delete()
|
|
|
|
+ return response.json(0)
|
|
|
|
+
|