|
|
@ -25,7 +25,6 @@ import org.dromara.common.sdk.mqtt.services.TopicServicesResponse; |
|
|
|
import org.dromara.common.sdk.mqtt.state.StateSubscribe; |
|
|
|
import org.dromara.common.sdk.mqtt.status.StatusSubscribe; |
|
|
|
import org.dromara.common.websocket.dto.BizCodeEnum; |
|
|
|
import org.dromara.common.websocket.utils.WebSocketUtils; |
|
|
|
import org.dromara.sample.common.error.CommonErrorEnum; |
|
|
|
import org.dromara.sample.component.mqtt.model.EventsReceiver; |
|
|
|
import org.dromara.sample.control.model.enums.DroneAuthorityEnum; |
|
|
@ -41,6 +40,7 @@ import org.dromara.sample.manage.service.*; |
|
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.dromara.sample.websocket.service.IWebSocketMessageService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -122,6 +122,9 @@ public class DeviceServiceImpl implements IDeviceService { |
|
|
|
@Autowired |
|
|
|
private AbstractFirmwareService abstractFirmwareService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IWebSocketMessageService webSocketMessageService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void subDeviceOffline(String deviceSn) { |
|
|
|
// If no information about this device exists in the cache, the drone is considered to be offline.
|
|
|
@ -302,20 +305,20 @@ public class DeviceServiceImpl implements IDeviceService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void pushDeviceOfflineTopo(String workspaceId, String deviceSn) { |
|
|
|
WebSocketUtils.publishAll( |
|
|
|
webSocketMessageService.sendBatch(workspaceId, |
|
|
|
null,BizCodeEnum.DEVICE_OFFLINE.getCode(), |
|
|
|
new TopologyDeviceDTO().setSn(deviceSn).setOnlineStatus(false)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void pushDeviceOnlineTopo(String workspaceId, String gatewaySn, String deviceSn) { |
|
|
|
WebSocketUtils.publishAll(null,BizCodeEnum.DEVICE_ONLINE.getCode(), |
|
|
|
webSocketMessageService.sendBatch(null,BizCodeEnum.DEVICE_ONLINE.getCode(), |
|
|
|
getDeviceTopoForPilot(deviceSn).orElseGet(TopologyDeviceDTO::new).setGatewaySn(gatewaySn)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void pushOsdDataToPilot(String workspaceId, String sn, DeviceOsdHost data) { |
|
|
|
WebSocketUtils.publishAll( UserTypeEnum.PILOT.getVal(), BizCodeEnum.DEVICE_OSD.getCode(), |
|
|
|
webSocketMessageService.sendBatch(workspaceId, UserTypeEnum.PILOT.getVal(), BizCodeEnum.DEVICE_OSD.getCode(), |
|
|
|
new DeviceOsdWsResponse() |
|
|
|
.setSn(sn) |
|
|
|
.setHost(data)); |
|
|
@ -323,7 +326,7 @@ public class DeviceServiceImpl implements IDeviceService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void pushOsdDataToWeb(String workspaceId, BizCodeEnum codeEnum, String sn, Object data) { |
|
|
|
WebSocketUtils.publishAll(UserTypeEnum.WEB.getVal(), codeEnum.getCode(), TelemetryDTO.builder().sn(sn).host(data).build()); |
|
|
|
webSocketMessageService.sendBatch(workspaceId,UserTypeEnum.WEB.getVal(), codeEnum.getCode(), TelemetryDTO.builder().sn(sn).host(data).build()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -655,7 +658,7 @@ public class DeviceServiceImpl implements IDeviceService { |
|
|
|
gateway.setControlSource(controlSource); |
|
|
|
deviceRedisService.setDeviceOnline(gateway); |
|
|
|
|
|
|
|
WebSocketUtils.publishAll(UserTypeEnum.WEB.getVal(), |
|
|
|
webSocketMessageService.sendBatch(gateway.getWorkspaceId(),UserTypeEnum.WEB.getVal(), |
|
|
|
BizCodeEnum.CONTROL_SOURCE_CHANGE.getCode(), |
|
|
|
DeviceAuthorityDTO.builder() |
|
|
|
.controlSource(gateway.getControlSource()) |
|
|
|