diff --git a/admin/src/main/java/com/multictrl/modules/business/controller/DockSetController.java b/admin/src/main/java/com/multictrl/modules/business/controller/DockSetController.java index d1b45df..cb1b26c 100644 --- a/admin/src/main/java/com/multictrl/modules/business/controller/DockSetController.java +++ b/admin/src/main/java/com/multictrl/modules/business/controller/DockSetController.java @@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.*; */ @RestController @RequestMapping("business/dock/set") -@Tag(name = "机场属性设置") +@Tag(name = "属性设置") @ApiOrder(25) @RequiredArgsConstructor public class DockSetController { @@ -32,7 +32,7 @@ public class DockSetController { public Result supplementLightClose(@PathVariable String dockSn, @Parameter(description = "空中回传开关 false:关闭,true:开启") @RequestParam Boolean enable) { - return new Result<>().ok(dockSetService.setDockProperty(dockSn, "air_transfer_enable", enable)); + return new Result<>().ok(dockSetService.setProperty(dockSn, "air_transfer_enable", null, enable)); } @Operation(summary = "机场静音模式") @@ -42,7 +42,7 @@ public class DockSetController { public Result supplementLightClose(@PathVariable String dockSn, @Parameter(description = "机场静音模式 0:非静音模式,1:静音模式") @RequestParam Integer value) { - return new Result<>().ok(dockSetService.setDockProperty(dockSn, "silent_mode", value)); + return new Result<>().ok(dockSetService.setProperty(dockSn, "silent_mode", null, value)); } @Operation(summary = "用户体验改善计划") @@ -52,6 +52,229 @@ public class DockSetController { public Result userExperienceImprovement(@PathVariable String dockSn, @Parameter(description = "用户体验改善计划 0:初始状态,1:拒绝加入用户体验改善计划,2:同意加入用户体验改善计划") @RequestParam Integer value) { - return new Result<>().ok(dockSetService.setDockProperty(dockSn, "user_experience_improvement", value)); + return new Result<>().ok(dockSetService.setProperty(dockSn, "user_experience_improvement", null, value)); + } + + @Operation(summary = "飞行器限远设置") + @PostMapping("/distanceLimitStatus/{dockSn}") + @LogOperation("飞行器限远设置") + @RequiresPermissions("bus:dockSet:distanceLimitStatus") + public Result distanceLimitStatus(@PathVariable String dockSn, + @Parameter(description = "是否开启限远 0:未设置,1:已设置") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "distance_limit_status", "state", value)); + } + + @Operation(summary = "飞行器限远距离设置") + @PostMapping("/distanceLimit/{dockSn}") + @LogOperation("飞行器限远距离设置") + @RequiresPermissions("bus:dockSet:distanceLimit") + public Result distanceLimit(@PathVariable String dockSn, + @Parameter(description = "限远距离 {max:8000,min:15}") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "distance_limit_status", "distance_limit", value)); + } + + @Operation(summary = "飞行器限高设置") + @PostMapping("/heightLimit/{dockSn}") + @LogOperation("飞行器限高设置") + @RequiresPermissions("bus:dockSet:heightLimit") + public Result heightLimit(@PathVariable String dockSn, + @Parameter(description = "限远距离 {max:1500,min:20}") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "height_limit", null, value)); + } + + @Operation(summary = "飞行器夜航灯设置") + @PostMapping("/nightLightsState/{dockSn}") + @LogOperation("飞行器夜航灯设置") + @RequiresPermissions("bus:dockSet:nightLightsState") + public Result nightLightsState(@PathVariable String dockSn, + @Parameter(description = "飞行器夜航灯状态 0:关闭,1:打开") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "night_lights_state", null, value)); + } + + @Operation(summary = "调色盘样式设置", description = "红外相机提供多种调色样式,用户可根据不同的场景选择不同的色彩,便于更加清晰地查看目标") + @PostMapping("/thermalCurrentPaletteStyle/{dockSn}") + @LogOperation("调色盘样式设置") + @RequiresPermissions("bus:dockSet:thermalCurrentPaletteStyle") + public Result thermalCurrentPaletteStyle(@PathVariable String dockSn, + @Parameter(description = "调色盘样式 {0:白热,1:黑热,2:描红,3:医疗,5:彩虹 1,6:铁红,8:北极,11:熔岩,12:热铁,13:彩虹 2}") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "type_subtype_gimbalindex", "thermal_current_palette_style", value)); + } + + @Operation(summary = "增益模式设置", description = "低增益提供更大的测温范围,高增益拥有更高的测温精度") + @PostMapping("/thermalGainMode/{dockSn}") + @LogOperation("增益模式设置") + @RequiresPermissions("bus:dockSet:thermalGainMode") + public Result thermalGainMode(@PathVariable String dockSn, + @Parameter(description = "增益模式 {0:自动,1:低增益, 测温范围0°C-500°C,2:高增益, 测温范围-20°C-150°C}") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "type_subtype_gimbalindex", "thermal_gain_mode", value)); + } + + @Operation(summary = "开启等温线设置", description = "等温线允许用户观测自己感兴趣的温度区间的内容,让兴趣温度区间的物体能更加凸显") + @PostMapping("/thermalIsothermState/{dockSn}") + @LogOperation("开启等温线设置") + @RequiresPermissions("bus:dockSet:thermalIsothermState") + public Result thermalIsothermState(@PathVariable String dockSn, + @Parameter(description = "是否开启等温线 0:关闭,1:开启") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "type_subtype_gimbalindex", "thermal_isotherm_state", value)); + } + + @Operation(summary = "测温区间上限设置", description = "仅启用等温线功能后有效") + @PostMapping("/thermalIsothermUpperLimit/{dockSn}") + @LogOperation("测温区间上限设置") + @RequiresPermissions("bus:dockSet:thermalIsothermUpperLimit") + public Result thermalIsothermUpperLimit(@PathVariable String dockSn, + @Parameter(description = "测温区间上限 {unit_name:摄氏度 / °C}") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "type_subtype_gimbalindex", "thermal_isotherm_upper_limit", value)); + } + + @Operation(summary = "测温区间下限设置", description = "仅启用等温线功能后有效") + @PostMapping("/thermalIsothermLowerLimit/{dockSn}") + @LogOperation("测温区间下限设置") + @RequiresPermissions("bus:dockSet:thermalIsothermLowerLimit") + public Result thermalIsothermLowerLimit(@PathVariable String dockSn, + @Parameter(description = "测温区间下限 {unit_name:摄氏度 / °C}") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "type_subtype_gimbalindex", "thermal_isotherm_lower_limit", value)); + } + + @Operation(summary = "指点飞行高度设置", description = "相对(机场)起飞点的高度,相对高 ALT") + @PostMapping("/commanderFlightHeight/{dockSn}") + @LogOperation("指点飞行高度设置") + @RequiresPermissions("bus:dockSet:commanderFlightHeight") + public Result commanderFlightHeight(@PathVariable String dockSn, + @Parameter(description = "指点飞行高度 {max:3000,min:2,step:0.1,unit_name:米 / m}") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "commander_flight_height", null, value)); + } + + @Operation(summary = "指点飞行模式设置", description = "指点飞行模式设置值") + @PostMapping("/commanderFlightMode/{dockSn}") + @LogOperation("指点飞行模式设置") + @RequiresPermissions("bus:dockSet:commanderFlightMode") + public Result commanderFlightMode(@PathVariable String dockSn, + @Parameter(description = "指点飞行模式设置值 {0:智能高度飞行,1:设定高度飞行}") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "commander_flight_mode", null, value)); + } + + @Operation(summary = "指点飞行失控动作设置", description = "执行指点飞行时失控了,选择继续执行完,还是执行普通失控行为") + @PostMapping("/commanderModeLostAction/{dockSn}") + @LogOperation("指点飞行失控动作设置") + @RequiresPermissions("bus:dockSet:commanderModeLostAction") + public Result commanderModeLostAction(@PathVariable String dockSn, + @Parameter(description = "指点飞行失控动作 {0:继续执行指点飞行任务,1:退出指点飞行任务,执行普通失控行为}") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "commander_mode_lost_action", null, value)); + } + + //用户对相机拍摄的照片和录像文件进行水印配置, 目前暂不支持直播画面水印 + @Operation(summary = "水印显示全局开关设置", description = "需要开启全局开关才能显示水印") + @PostMapping("/cameraWatermarkGlobalEnable/{dockSn}") + @LogOperation("水印显示全局开关设置") + @RequiresPermissions("bus:dockSet:cameraWatermarkGlobalEnable") + public Result cameraWatermarkGlobalEnable(@PathVariable String dockSn, + @Parameter(description = "水印显示全局开关 0:关闭,1:开启") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "camera_watermark_settings", "global_enable", value)); + } + + @Operation(summary = "机型显示开关设置") + @PostMapping("/cameraWatermarkDroneTypeEnable/{dockSn}") + @LogOperation("机型显示开关设置") + @RequiresPermissions("bus:dockSet:cameraWatermarkDroneTypeEnable") + public Result cameraWatermarkDroneTypeEnable(@PathVariable String dockSn, + @Parameter(description = "机型显示开关 0:关闭,1:开启") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "camera_watermark_settings", "drone_type_enable", value)); + } + + @Operation(summary = "飞行器序列号显示开关设置") + @PostMapping("/cameraWatermarkDroneSnEnable/{dockSn}") + @LogOperation("飞行器序列号显示开关设置") + @RequiresPermissions("bus:dockSet:cameraWatermarkDroneSnEnable") + public Result cameraWatermarkDroneSnEnable(@PathVariable String dockSn, + @Parameter(description = "飞行器序列号显示开关 0:关闭,1:开启") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "camera_watermark_settings", "drone_sn_enable", value)); + } + + @Operation(summary = "日期时间显示开关设置", description = "时区默认为当地时区") + @PostMapping("/cameraWatermarkDateTimeEnable/{dockSn}") + @LogOperation("日期时间显示开关设置") + @RequiresPermissions("bus:dockSet:cameraWatermarkDateTimeEnable") + public Result cameraWatermarkDateTimeEnable(@PathVariable String dockSn, + @Parameter(description = "日期时间显示开关 0:关闭,1:开启") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "camera_watermark_settings", "datetime_enable", value)); + } + + @Operation(summary = "经纬度&海拔高显示开关设置") + @PostMapping("/cameraWatermarkGpsEnable/{dockSn}") + @LogOperation("经纬度&海拔高显示开关设置") + @RequiresPermissions("bus:dockSet:cameraWatermarkGpsEnable") + public Result cameraWatermarkGpsEnable(@PathVariable String dockSn, + @Parameter(description = "经纬度&海拔高显示开关 0:关闭,1:开启") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "camera_watermark_settings", "gps_enable", value)); + } + + @Operation(summary = "自定义文案显示开关设置") + @PostMapping("/cameraWatermarkCustomStrEnable/{dockSn}") + @LogOperation("自定义文案显示开关设置") + @RequiresPermissions("bus:dockSet:cameraWatermarkCustomStrEnable") + public Result cameraWatermarkCustomStrEnable(@PathVariable String dockSn, + @Parameter(description = "自定义文案显示开关 0:关闭,1:开启") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "camera_watermark_settings", "user_custom_string_enable", value)); + } + + @Operation(summary = "自定义文案内容设置", description = "最多可显示 250 字节") + @PostMapping("/cameraWatermarkCustomStr/{dockSn}") + @LogOperation("自定义文案内容设置") + @RequiresPermissions("bus:dockSet:cameraWatermarkCustomStr") + public Result cameraWatermarkCustomStr(@PathVariable String dockSn, + @Parameter(description = "自定义文案内容 (最多可显示 250 字节)") + @RequestParam String value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "camera_watermark_settings", "user_custom_string", value)); + } + + @Operation(summary = "水印在画面中位置设置") + @PostMapping("/cameraWatermarkLayout/{dockSn}") + @LogOperation("水印在画面中位置设置") + @RequiresPermissions("bus:dockSet:cameraWatermarkLayout") + public Result cameraWatermarkLayout(@PathVariable String dockSn, + @Parameter(description = "水印在画面中位置 {0:左上,1:左下,2:右上,3:右下}") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "camera_watermark_settings", "layout", value)); + } + + + @Operation(summary = "返航高度设置") + @PostMapping("/rthAltitude/{dockSn}") + @LogOperation("返航高度设置") + @RequiresPermissions("bus:dockSet:rthAltitude") + public Result rthAltitude(@PathVariable String dockSn, + @Parameter(description = "返航高度 {max:500,min:20,unit_name:米 / m}") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "rth_altitude", null, value)); + } + + @Operation(summary = "返航预留电量设置", + description = "注意:预留返航电量设置过低可能导致飞机没有足够电量完成返航。对于 DJI Dock 3,我们建议将该值设置在 15% ~ 50% 范围内以提供更安全的返航电量预留。") + @PostMapping("/remainingPowerForReturnHome/{dockSn}") + @LogOperation("返航预留电量设置") + @RequiresPermissions("bus:dockSet:remainingPowerForReturnHome") + public Result remainingPowerForReturnHome(@PathVariable String dockSn, + @Parameter(description = "返航预留电量 {max:100,min:0}") + @RequestParam Integer value) { + return new Result<>().ok(dockSetService.setProperty(dockSn, "remaining_power_for_return_home", null, value)); } } diff --git a/admin/src/main/java/com/multictrl/modules/business/service/DockSetService.java b/admin/src/main/java/com/multictrl/modules/business/service/DockSetService.java index 7a1e000..39941d9 100644 --- a/admin/src/main/java/com/multictrl/modules/business/service/DockSetService.java +++ b/admin/src/main/java/com/multictrl/modules/business/service/DockSetService.java @@ -8,6 +8,6 @@ package com.multictrl.modules.business.service; */ public interface DockSetService { - //设置机场属性 - String setDockProperty(String dockSn, String property, Object value); + //设置属性 + String setProperty(String dockSn, String property, String subProperty, Object value); } diff --git a/admin/src/main/java/com/multictrl/modules/business/service/impl/DockSetServiceImpl.java b/admin/src/main/java/com/multictrl/modules/business/service/impl/DockSetServiceImpl.java index 33c45b9..9015921 100644 --- a/admin/src/main/java/com/multictrl/modules/business/service/impl/DockSetServiceImpl.java +++ b/admin/src/main/java/com/multictrl/modules/business/service/impl/DockSetServiceImpl.java @@ -1,6 +1,7 @@ package com.multictrl.modules.business.service.impl; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import com.multictrl.common.exception.RenException; import com.multictrl.common.utils.CacheUtils; @@ -24,12 +25,16 @@ public class DockSetServiceImpl implements DockSetService { private final MqttPushService mqttPushService; @Override - public String setDockProperty(String dockSn, String property, Object value) { + public String setProperty(String dockSn, String property, String subProperty, Object value) { JSONObject message = new JSONObject(); JSONObject data = new JSONObject(); - JSONObject state = new JSONObject(); - state.set("state", value); - data.set(property, state); + if (StrUtil.isNotBlank(subProperty)) { + JSONObject subData = new JSONObject(); + subData.set(subProperty, value); + data.set(property, subData); + } else { + data.set(property, value); + } message.set("data", data); String bid = IdUtil.randomUUID(); String tid = IdUtil.randomUUID(); @@ -45,8 +50,13 @@ public class DockSetServiceImpl implements DockSetService { CacheUtils.delete(key); JSONObject dataJson = (JSONObject) object; JSONObject propertyObject = dataJson.getJSONObject(property); - JSONObject stateObject = propertyObject.getJSONObject("state"); - Integer result = stateObject.getInt("result"); + Integer result; + if (StrUtil.isNotBlank(subProperty)) { + JSONObject subObject = propertyObject.getJSONObject(subProperty); + result = subObject.getInt("result"); + } else { + result = propertyObject.getInt("result"); + } if (result == 0) { return "执行成功"; } else if (result == 1) {