zhaowenyu
2025-12-06 f3de8ac216bfc05348222e2b963ef3629358ae62
ard-sample/src/main/java/com/ard/sample/manage/service/impl/DeviceServiceImpl.java
@@ -1196,23 +1196,29 @@
        return ResponseResult.success();
    }
    /**
     * 属性设置
     * */
    @Override
    public void devicePropertySet(String dockSn, DeviceSetPropertyEnum propertyEnum, JsonNode param) {
    public ResponseResult devicePropertySet(String dockSn, DeviceSetPropertyEnum propertyEnum, JsonNode param) {
        boolean dockOnline = this.checkDeviceOnline(dockSn);
        if (!dockOnline) {
            throw new RuntimeException(CommonErrorEnum.DEVICE_OFFLINE.getErrorMsg());
            return ResponseResult.error(CommonErrorEnum.DEVICE_OFFLINE.getErrorCode(),"机场" + CommonErrorEnum.DEVICE_OFFLINE.getErrorMsg());
            //throw new RuntimeException(CommonErrorEnum.DEVICE_OFFLINE.getErrorMsg());
        }
        DeviceDTO deviceDTO = (DeviceDTO) RedisOpsUtils.get(RedisConst.DEVICE_ONLINE_PREFIX + dockSn);
        boolean deviceOnline = this.checkDeviceOnline(deviceDTO.getChildDeviceSn());
        if (!deviceOnline) {
            throw new RuntimeException("Device is offline.");
            return ResponseResult.error(CommonErrorEnum.DEVICE_OFFLINE.getErrorCode(),"无人机" + CommonErrorEnum.DEVICE_OFFLINE.getErrorMsg());
            //throw new RuntimeException("Device is offline.");
        }
        // Make sure the data is valid.
        BasicDeviceProperty basicDeviceProperty = objectMapper.convertValue(param, propertyEnum.getClazz());
        boolean valid = basicDeviceProperty.valid();
        if (!valid) {
            throw new IllegalArgumentException(CommonErrorEnum.ILLEGAL_ARGUMENT.getErrorMsg());
            return ResponseResult.error(CommonErrorEnum.ILLEGAL_ARGUMENT.getErrorMsg());
            // throw new IllegalArgumentException(CommonErrorEnum.ILLEGAL_ARGUMENT.getErrorMsg());
        }
        String topic = THING_MODEL_PRE + PRODUCT + dockSn + PROPERTY_SUF + SET_SUF;
@@ -1220,12 +1226,14 @@
                (OsdSubDeviceReceiver) RedisOpsUtils.get(RedisConst.OSD_PREFIX + deviceDTO.getChildDeviceSn());
        if (!param.isObject()) {
            this.deviceOnePropertySet(topic, propertyEnum, Map.entry(propertyEnum.getProperty(), param));
            return;
            return ResponseResult.success();
//            return;
        }
        if(param.size()==1){
            this.deviceOnePropertySetSilent(topic,propertyEnum,param);
            return;
            return ResponseResult.success();
//            return;
        }
//        if(Objects.equals(param.fieldNames().next(), "silent_mode"))
//        {
@@ -1242,7 +1250,7 @@
            this.deviceOnePropertySet(topic, propertyEnum, Map.entry(propertyEnum.getProperty(), node));
        }
        return ResponseResult.success();
    }
    /**