aix
2024-08-20 b0dd7ca693fcd13e539316cfc8c63150182a0315
src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java
@@ -1010,6 +1010,41 @@
    }
    @Override
    public int devicePropertySet(String workspaceId, String dockSn, JsonNode value) {
        Optional<DeviceDTO> dockOpt = deviceRedisService.getDeviceOnline(dockSn);
        if (dockOpt.isEmpty()) {
            throw new RuntimeException("机场离线");
        }
        String childSn = dockOpt.get().getChildDeviceSn();
        boolean deviceOnline = deviceRedisService.checkDeviceOnline(childSn);
        Optional<OsdSubDeviceReceiver> osdOpt = deviceRedisService.getDeviceOsd(childSn, OsdSubDeviceReceiver.class);
        if (!deviceOnline || osdOpt.isEmpty()) {
            throw new RuntimeException("设备离线");
        }
        String topic = THING_MODEL_PRE + PRODUCT + dockSn + PROPERTY_SUF + SET_SUF;
        Map reply = messageSender.publishWithReply(
                Map.class, topic,
                CommonTopicResponse.builder()
                        .bid(UUID.randomUUID().toString())
                        .tid(UUID.randomUUID().toString())
                        .timestamp(System.currentTimeMillis())
                        .data(value)
                        .build());
        SetReply setReply = objectMapper.convertValue(reply, SetReply.class);
        if (SetReplyStatusResultEnum.SUCCESS.getVal() != setReply.getResult()) {
            throw new RuntimeException("设置失败" + reply + "; 错误码: " + setReply.getResult());
        }
        return ResponseResult.success().getCode();
    }
    @Override
    public void deviceOnePropertySet(String topic, DeviceSetPropertyEnum propertyEnum, Map.Entry<String, Object> value) {
        if (Objects.isNull(value) || Objects.isNull(value.getValue())) {
            throw new IllegalArgumentException(CommonErrorEnum.ILLEGAL_ARGUMENT.getErrorMsg());