|
@@ -124,6 +124,8 @@ class DeviceManagement(View):
|
|
|
return self.edit_device_ver_info(request_dict, response)
|
|
|
elif operation == 'delDeviceVerInfo': # 删除设备型号版本
|
|
|
return self.del_device_ver_info(request_dict, response)
|
|
|
+ elif operation == 'syncDeviceVersion': # 删除设备型号版本
|
|
|
+ return self.sync_device_version(request_dict, response)
|
|
|
|
|
|
# 设备语音设置
|
|
|
elif operation == 'getDeviceVoice': # 获取设备音频
|
|
@@ -1721,6 +1723,70 @@ class DeviceManagement(View):
|
|
|
device_version_info_qs.delete()
|
|
|
return response.json(0)
|
|
|
|
|
|
+ @classmethod
|
|
|
+ def sync_device_version(cls, request_dict, response):
|
|
|
+ """
|
|
|
+ 同步设备版本信息
|
|
|
+ @param user_id: 用户ID
|
|
|
+ @param request: 请求对象
|
|
|
+ @param request_dict: 请求参数
|
|
|
+ @param response: 响应对象
|
|
|
+ @return: 响应结果
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ # 从请求字典中获取设备码和版本号
|
|
|
+ version = request_dict.get('version')
|
|
|
+ d_code = request_dict.get('dCode')
|
|
|
+
|
|
|
+ # 查询设备版本配置
|
|
|
+ version_config_qs = DeviceVersionInfo.objects.filter(
|
|
|
+ d_code=d_code,
|
|
|
+ software_ver=version
|
|
|
+ )
|
|
|
+
|
|
|
+ # 检查是否存在匹配的配置
|
|
|
+ if not version_config_qs.exists():
|
|
|
+ return response.json(173) # 设备版本配置不存在
|
|
|
+
|
|
|
+ # 获取第一条匹配的记录(通常应该只有一条)
|
|
|
+ version_config = version_config_qs.first()
|
|
|
+
|
|
|
+ # 将数据库字段映射为驼峰命名的响应数据
|
|
|
+ response_data = {
|
|
|
+ 'dCode': version_config.d_code,
|
|
|
+ 'softwareVer': version_config.software_ver,
|
|
|
+ 'firmwareVer': version_config.firmware_ver,
|
|
|
+ 'videoCode': version_config.video_code,
|
|
|
+ 'regionAlexa': version_config.region_alexa,
|
|
|
+ 'supportsHumanTracking': version_config.supports_human_tracking,
|
|
|
+ 'supportsCustomVoice': version_config.supports_custom_voice,
|
|
|
+ 'supportsDualBandWifi': version_config.supports_dual_band_wifi,
|
|
|
+ 'supportsFourPoint': version_config.supports_four_point,
|
|
|
+ 'supports4g': version_config.supports_4g,
|
|
|
+ 'supportsPTZ': version_config.supports_ptz,
|
|
|
+ 'supportsAi': version_config.supports_ai,
|
|
|
+ 'supportsCloudStorage': version_config.supports_cloud_storage,
|
|
|
+ 'supportsAlexa': version_config.supports_alexa,
|
|
|
+ 'deviceType': version_config.device_type,
|
|
|
+ 'resolution': version_config.resolution,
|
|
|
+ 'aiType': version_config.ai_type,
|
|
|
+ 'supportsAlarm': version_config.supports_alarm,
|
|
|
+ 'supportsNightVision': version_config.supports_night_vision,
|
|
|
+ 'screenChannels': version_config.screen_channels,
|
|
|
+ 'networkType': version_config.network_type,
|
|
|
+ 'otherFeatures': version_config.other_features,
|
|
|
+ 'electricityStatistics': version_config.electricity_statistics,
|
|
|
+ 'supportsPetTracking': version_config.supports_pet_tracking
|
|
|
+ }
|
|
|
+
|
|
|
+ # 返回成功响应,包含设备版本配置信息
|
|
|
+ return response.json(0)
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ # 通用异常处理(建议替换为具体异常类型)
|
|
|
+ LOGGER.exception("同步设备配置失败")
|
|
|
+ return response.json(500, f'Server error: {str(e)}')
|
|
|
+
|
|
|
@staticmethod
|
|
|
def get_device_voice(request_dict, response):
|
|
|
"""
|