2025-12-09 zwy 增加机场飞行器摄像头切换状态通道,增加LiveStatusTwoReceiver路由
6 files modified
39 ■■■■■ changed files
ard-admin/src/main/java/com/ard/web/controller/sample/LiveStreamController.java 10 ●●●●● patch | view | raw | blame | history
ard-sample/src/main/java/com/ard/sample/component/mqtt/config/MqttMessageChannel.java 3 ●●●●● patch | view | raw | blame | history
ard-sample/src/main/java/com/ard/sample/component/mqtt/handler/StateLiveCapacityHandler.java 2 ●●●●● patch | view | raw | blame | history
ard-sample/src/main/java/com/ard/sample/component/mqtt/handler/StateLiveStatusHandler.java 17 ●●●●● patch | view | raw | blame | history
ard-sample/src/main/java/com/ard/sample/component/mqtt/handler/StateRouter.java 5 ●●●●● patch | view | raw | blame | history
ard-sample/src/main/java/com/ard/sample/component/mqtt/model/ChannelName.java 2 ●●●●● patch | view | raw | blame | history
ard-admin/src/main/java/com/ard/web/controller/sample/LiveStreamController.java
@@ -9,6 +9,7 @@
import com.ard.sample.manage.model.dto.LiveTypeDTO;
import com.ard.sample.manage.model.param.RemoteDebugParam;
import com.ard.sample.manage.model.receiver.LiveCapacityReceiver;
import com.ard.sample.manage.model.receiver.LiveStatusTwoReceiver;
import com.ard.sample.manage.service.IDeviceService;
import com.ard.sample.manage.service.ILiveStreamService;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -56,6 +57,15 @@
        liveStreamService.saveLiveCapacity(liveCapacity, headers.getTimestamp());
    }
    /**
     * 处理摄像头返回状态
     * */
    @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_STATUS)
    public void LiveStateStatus(LiveStatusTwoReceiver liveReceiver, MessageHeaders headers) {
        log.info("摄像头返回状态通道INBOUND_STATE_STATUS:{}", liveReceiver);
    }
    /**
     * Get live capability data of all drones in the current user's workspace from the database.
     *
ard-sample/src/main/java/com/ard/sample/component/mqtt/config/MqttMessageChannel.java
@@ -66,6 +66,9 @@
    public MessageChannel stateCapacityChannel() {
        return new DirectChannel();
    }
    // 机场与飞行器视频切换状态通道
    @Bean(name = ChannelName.INBOUND_STATE_STATUS)
    public MessageChannel stateStatusChannel() { return new DirectChannel(); }
    @Bean(name = ChannelName.INBOUND_STATE_PAYLOAD_UPDATE)
    public MessageChannel statePayloadUpdateChannel() {
ard-sample/src/main/java/com/ard/sample/component/mqtt/handler/StateLiveCapacityHandler.java
@@ -28,7 +28,7 @@
    public CommonTopicReceiver handleState(Map<String, Object> dataNode, CommonTopicReceiver stateReceiver, String sn) throws JsonProcessingException {
        // Determine if it is live capacity data based on name.
        if (dataNode.containsKey(StateDataEnum.LIVE_CAPACITY.getDesc())) {
            Object data = dataNode.get(StateDataEnum.LIVE_CAPACITY.getDesc());
            //Object data = dataNode.get(StateDataEnum.LIVE_CAPACITY.getDesc());
            stateReceiver.setData(mapper.convertValue(
                    dataNode.get(StateDataEnum.LIVE_CAPACITY.getDesc()),
                    LiveCapacityReceiver.class));
ard-sample/src/main/java/com/ard/sample/component/mqtt/handler/StateLiveStatusHandler.java
@@ -1,5 +1,7 @@
package com.ard.sample.component.mqtt.handler;
import com.ard.common.core.redis.RedisConst;
import com.ard.common.core.redis.RedisOpsUtils;
import com.ard.sample.component.mqtt.model.CommonTopicReceiver;
import com.ard.sample.component.mqtt.model.StateDataEnum;
import com.ard.sample.component.websocket.enums.MessageType;
@@ -24,8 +26,6 @@
public class StateLiveStatusHandler extends AbstractStateTopicHandler{
    @Autowired
    private DockWebSocketHandler _dockWebSocketHandler;
    @Autowired
    private IDeviceService _deviceService;
    protected StateLiveStatusHandler(@Autowired @Qualifier("stateFirmwareVersionHandler")AbstractStateTopicHandler handler) {
@@ -36,15 +36,14 @@
    public CommonTopicReceiver handleState(Map<String, Object> dataNode, CommonTopicReceiver stateReceiver, String sn) throws JsonProcessingException {
        if (dataNode.containsKey(StateDataEnum.LIVESTATUS.getDesc())) {
            stateReceiver.setType(MessageType.LIVESTATUS.getType());
            String deviceSn= stateReceiver.getGateway();
            DeviceQueryParam param = DeviceQueryParam.builder().deviceSn(deviceSn).build();
            List<DeviceDTO> deviceDTOS = _deviceService.getDevicesByParams(param);
            if(deviceDTOS!=null && deviceDTOS.size()>0)
            DeviceDTO device = (DeviceDTO) RedisOpsUtils.get(RedisConst.DEVICE_ONLINE_PREFIX + sn);
            if(device != null)
            {
                String childSn = deviceDTOS.get(0).getChildDeviceSn();
                List<LiveStatusTwoReceiver> list = mapper.convertValue(dataNode.get(StateDataEnum.LIVESTATUS.getDesc()), new TypeReference<List<LiveStatusTwoReceiver>>() {});
                String childSn = device.getChildDeviceSn();
                List<LiveStatusTwoReceiver> list = mapper.convertValue(dataNode.get(StateDataEnum.LIVESTATUS.getDesc()),
                        new TypeReference<List<LiveStatusTwoReceiver>>() {});
                for (LiveStatusTwoReceiver receiver : list) {
                    if(receiver.getVideoId().contains(childSn)){
                    if(receiver.getVideoId()!=null && receiver.getVideoId().contains(childSn)){
                        stateReceiver.setData(receiver);
                        continue;
                    }
ard-sample/src/main/java/com/ard/sample/component/mqtt/handler/StateRouter.java
@@ -5,6 +5,7 @@
import com.ard.sample.manage.model.receiver.DeviceBasicReceiver;
import com.ard.sample.manage.model.receiver.FirmwareVersionReceiver;
import com.ard.sample.manage.model.receiver.LiveCapacityReceiver;
import com.ard.sample.manage.model.receiver.LiveStatusTwoReceiver;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
import lombok.extern.slf4j.Slf4j;
@@ -94,10 +95,14 @@
        // Channel mapping for live streaming capabilities.
        router.setChannelMapping(LiveCapacityReceiver.class.getName(),
                ChannelName.INBOUND_STATE_CAPACITY);
        router.setChannelMapping(LiveStatusTwoReceiver.class.getName(),
                ChannelName.INBOUND_STATE_STATUS);
        router.setChannelMapping(FirmwareVersionReceiver.class.getName(),
                ChannelName.INBOUND_STATE_FIRMWARE_VERSION);
        router.setChannelMapping(Map.class.getName(),
                ChannelName.DEFAULT);
        // 配置默认输出通道(兜底)
        router.setDefaultOutputChannelName(ChannelName.DEFAULT);
        return router;
    }
ard-sample/src/main/java/com/ard/sample/component/mqtt/model/ChannelName.java
@@ -33,6 +33,8 @@
    public static final String INBOUND_STATE_CAPACITY = "inboundStateCapacity";
    public static final String INBOUND_STATE_STATUS = "inboundStateStatus";
    public static final String INBOUND_STATE_LIST = "inboundStateList";
    public static final String INBOUND_SERVICE_REPLY = "inboundStateServiceReply";