|
|
@ -15,10 +15,7 @@ import org.springframework.integration.mqtt.support.MqttHeaders; |
|
|
|
import org.springframework.messaging.Message; |
|
|
|
import org.springframework.messaging.Message; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.*; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.dji.sdk.mqtt.TopicConst.*; |
|
|
|
import static com.dji.sdk.mqtt.TopicConst.*; |
|
|
|
|
|
|
|
|
|
|
@ -45,19 +42,28 @@ public class OsdRouter { |
|
|
|
} |
|
|
|
} |
|
|
|
}, null) |
|
|
|
}, null) |
|
|
|
.<TopicOsdRequest>handle((response, headers) -> { |
|
|
|
.<TopicOsdRequest>handle((response, headers) -> { |
|
|
|
GatewayManager gateway = SDKManager.getDeviceSDK(response.getGateway()); |
|
|
|
|
|
|
|
OsdDeviceTypeEnum typeEnum = OsdDeviceTypeEnum.find(gateway.getType(), response.getFrom().equals(response.getGateway())); |
|
|
|
// fix: getDeviceSDK抛出异常导致在设备未注册的情况下报osd时产生大量日志 witcom@2023.09.22
|
|
|
|
Map<String, Object> data = (Map<String, Object>) response.getData(); |
|
|
|
//GatewayManager gateway = SDKManager.getDeviceSDK(response.getGateway());
|
|
|
|
if (!typeEnum.isGateway()) { |
|
|
|
return SDKManager.findDeviceSDK(response.getGateway()) |
|
|
|
List payloadData = (List) data.getOrDefault(PayloadModelEnum.PAYLOAD_KEY, new ArrayList<>()); |
|
|
|
.map(gateway-> { |
|
|
|
PayloadModelEnum.getAllIndexWithPosition().stream().filter(data::containsKey) |
|
|
|
|
|
|
|
.map(data::get).forEach(payloadData::add); |
|
|
|
OsdDeviceTypeEnum typeEnum = OsdDeviceTypeEnum.find(gateway.getType(), response.getFrom().equals(response.getGateway())); |
|
|
|
data.put(PayloadModelEnum.PAYLOAD_KEY, payloadData); |
|
|
|
Map<String, Object> data = (Map<String, Object>) response.getData(); |
|
|
|
} |
|
|
|
if (!typeEnum.isGateway()) { |
|
|
|
return response.setData(Common.getObjectMapper().convertValue(data, typeEnum.getClassType())); |
|
|
|
List payloadData = (List) data.getOrDefault(PayloadModelEnum.PAYLOAD_KEY, new ArrayList<>()); |
|
|
|
|
|
|
|
PayloadModelEnum.getAllIndexWithPosition().stream().filter(data::containsKey) |
|
|
|
|
|
|
|
.map(data::get).forEach(payloadData::add); |
|
|
|
|
|
|
|
data.put(PayloadModelEnum.PAYLOAD_KEY, payloadData); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return response.setData(Common.getObjectMapper().convertValue(data, typeEnum.getClassType())); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.orElse(null); |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
.<TopicOsdRequest>filter(Objects::nonNull) |
|
|
|
.<TopicOsdRequest, OsdDeviceTypeEnum>route(response -> OsdDeviceTypeEnum.find(response.getData().getClass()), |
|
|
|
.<TopicOsdRequest, OsdDeviceTypeEnum>route(response -> OsdDeviceTypeEnum.find(response.getData().getClass()), |
|
|
|
mapping -> Arrays.stream(OsdDeviceTypeEnum.values()).forEach(key -> mapping.channelMapping(key, key.getChannelName()))) |
|
|
|
mapping -> Arrays.stream(OsdDeviceTypeEnum.values()) |
|
|
|
|
|
|
|
.forEach(key -> mapping.channelMapping(key, key.getChannelName()))) |
|
|
|
.get(); |
|
|
|
.get(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|