From ffb4f5dce1f4d7275b0945e435068b2a86316fb0 Mon Sep 17 00:00:00 2001
From: zhaowenyu <35589726@qq.com>
Date: Mon, 01 Dec 2025 14:33:44 +0800
Subject: [PATCH] 2025-12-01 zwy 机场设备列表增加对nickname的筛选
---
ard-sample/src/main/java/com/ard/sample/manage/service/impl/DeviceServiceImpl.java | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 150 insertions(+), 10 deletions(-)
diff --git a/ard-sample/src/main/java/com/ard/sample/manage/service/impl/DeviceServiceImpl.java b/ard-sample/src/main/java/com/ard/sample/manage/service/impl/DeviceServiceImpl.java
index b9c7713..e6d3777 100644
--- a/ard-sample/src/main/java/com/ard/sample/manage/service/impl/DeviceServiceImpl.java
+++ b/ard-sample/src/main/java/com/ard/sample/manage/service/impl/DeviceServiceImpl.java
@@ -1,10 +1,11 @@
package com.ard.sample.manage.service.impl;
import com.alibaba.fastjson2.JSONObject;
-import com.ard.common.annotation.DataScope;
-import com.ard.common.annotation.DataScopePlus;
+import com.ard.device.camera.domain.ArdCamera;
+import com.ard.device.camera.service.IArdCameraService;
+import com.ard.device.channel.domain.ArdChannel;
+import com.ard.sample.component.websocket.handler.LiveStreamHandler;
import com.ard.system.authorize.service.AuthorizeService;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -36,7 +37,6 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -69,6 +69,12 @@
@Slf4j
@Transactional
public class DeviceServiceImpl implements IDeviceService {
+
+ @Autowired
+ private LiveStreamHandler _liveStreamHandler;
+
+ @Autowired
+ private IArdCameraService _cameraService;
@Autowired
private IMessageSenderService messageSender;
@@ -354,11 +360,28 @@
//region 单独写一个方法做权限验证,由于有好多定时任务也在实时获取设备列表,原方法不适用再添加权限注解
@Override
- public List<DeviceDTO> getDockList() {
+ public List<DeviceDTO> getDockList(String nickname) {
List<DeviceDTO> devicesList = this.getDockListByParams(
DeviceQueryParam.builder()
.domains(List.of(DeviceDomainEnum.GATEWAY.getVal(), DeviceDomainEnum.DOCK.getVal()))
+ .nickname(nickname)
.build());
+ // 在獲取设备列表时,顺便获取直播地址
+ for(DeviceDTO devices : devicesList){
+ _liveStreamHandler.StartLiveStreaming(devices.getDeviceSn());
+ _liveStreamHandler.StartLiveStreaming(devices.getChildDeviceSn());
+ ArdCamera ardCamera = new ArdCamera();
+ ardCamera.setDockId(devices.getId());
+ List<ArdCamera> ardCameraList = _cameraService.selectArdCameraList(ardCamera);
+ for(ArdCamera ardCamera1 : ardCameraList){
+ for(ArdChannel ardChannel : ardCamera1.getChannelList()) {
+ if(ardChannel.getChanNo() == 1) {
+ // 修改列表中外接相机地址
+ updateCameraWebrtcUrl(devices.getDeviceSn(), ardChannel.getArdVtdu().getWebrtcUrl());
+ }
+ }
+ }
+ }
devicesList.stream()
.filter(gateway -> DeviceDomainEnum.DOCK.getVal() == gateway.getDomain() ||
@@ -402,6 +425,7 @@
})
.eq(param.getBoundStatus() != null, DeviceEntity::getBoundStatus,
param.getBoundStatus())
+ .like(param.getNickname()!=null, DeviceEntity::getNickname, "%" + param.getNickname() + "%")
.orderBy(param.isOrderBy(),
param.isAsc(), DeviceEntity::getId))
.stream()
@@ -409,6 +433,90 @@
.collect(Collectors.toList());
}
//endregion
+
+ // region 多路直播列表,按nickname筛选
+// /**
+// * 多路直播列表,按nickname筛选
+// * */
+// @Override
+// public List<DeviceDTO> getDockCameraList(String nickname) {
+//
+// List<DeviceDTO> devicesList = this.getDockListByParams(
+// DeviceQueryParam.builder()
+// .domains(List.of(DeviceDomainEnum.GATEWAY.getVal(), DeviceDomainEnum.DOCK.getVal()))
+// .nickname(nickname)
+// .build());
+//
+// // 在獲取设备列表时,顺便获取直播地址
+// for(DeviceDTO devices : devicesList){
+// _liveStreamHandler.StartLiveStreaming(devices.getDeviceSn());
+// _liveStreamHandler.StartLiveStreaming(devices.getChildDeviceSn());
+// ArdCamera ardCamera = new ArdCamera();
+// ardCamera.setDockId(devices.getId());
+// List<ArdCamera> ardCameraList = _cameraService.selectArdCameraList(ardCamera);
+// for(ArdCamera ardCamera1 : ardCameraList){
+// for(ArdChannel ardChannel : ardCamera1.getChannelList()) {
+// if(ardChannel.getChanNo() == 1) {
+// // 修改列表中外接相机地址
+// updateCameraWebrtcUrl(devices.getDeviceSn(), ardChannel.getArdVtdu().getWebrtcUrl());
+// }
+// }
+// }
+// }
+//
+// devicesList.stream()
+// .filter(gateway -> DeviceDomainEnum.DOCK.getVal() == gateway.getDomain() ||
+// RedisOpsUtils.checkExist(RedisConst.DEVICE_ONLINE_PREFIX + gateway.getDeviceSn()))
+// .forEach(this::spliceDeviceTopoPer);
+//
+// return devicesList;
+// }
+
+// @Override
+// public void spliceDeviceTopoCamera(DeviceDTO gateway) {
+// gateway.setStatus(RedisOpsUtils.checkExist(RedisConst.DEVICE_ONLINE_PREFIX + gateway.getDeviceSn()));
+// // sub device
+// if (!StringUtils.hasText(gateway.getChildDeviceSn())) {
+// return;
+// }
+// DeviceDTO subDevice =
+// getDevicesByParams(DeviceQueryParam.builder().deviceSn(gateway.getChildDeviceSn()).build()).get(0);
+// subDevice.setStatus(RedisOpsUtils.checkExist(RedisConst.DEVICE_ONLINE_PREFIX + subDevice.getDeviceSn()));
+// gateway.setChildren(subDevice);
+// }
+
+// /**
+// * 按nickname筛选列表
+// * */
+// @Override
+// public List<DeviceDTO> getDockCameraListByParams(DeviceQueryParam param) {
+// return mapper.selectListPer(
+// new LambdaQueryWrapper<DeviceEntity>()
+// .eq(StringUtils.hasText(param.getDeviceSn()),
+// DeviceEntity::getDeviceSn, param.getDeviceSn())
+// .eq(param.getDeviceType() != null,
+// DeviceEntity::getDeviceType, param.getDeviceType())
+// .eq(param.getSubType() != null,
+// DeviceEntity::getSubType, param.getSubType())
+// .eq(StringUtils.hasText(param.getChildSn()),
+// DeviceEntity::getChildSn, param.getChildSn())
+// .and(!CollectionUtils.isEmpty(param.getDomains()), wrapper -> {
+// for (Integer domain : param.getDomains()) {
+// wrapper.eq(DeviceEntity::getDomain, domain).or();
+// }
+// })
+// .eq(param.getBoundStatus() != null, DeviceEntity::getBoundStatus,
+// param.getBoundStatus())
+// .like(param.getNickname()!=null, DeviceEntity::getNickname, "%" + param.getNickname() + "%")
+// .orderBy(param.isOrderBy(),
+// param.isAsc(), DeviceEntity::getId))
+// .stream()
+// .map(this::deviceEntityConvertToDTO)
+// .collect(Collectors.toList());
+// }
+
+
+ // endregion
@Override
public Optional<TopologyDeviceDTO> getDeviceTopoForPilot(String sn) {
@@ -503,10 +611,10 @@
@Override
@ServiceActivator(inputChannel = ChannelName.INBOUND_OSD)
public void handleOSD(Message<?> message) {
- String topic = message.getHeaders().get(MqttHeaders.RECEIVED_TOPIC).toString();
- byte[] payload = (byte[]) message.getPayload();
- CommonTopicReceiver receiver;
try {
+ String topic = message.getHeaders().get(MqttHeaders.RECEIVED_TOPIC).toString();
+ byte[] payload = (byte[]) message.getPayload();
+ CommonTopicReceiver receiver;
String from = topic.substring((THING_MODEL_PRE + PRODUCT).length(),
topic.indexOf(OSD_SUF));
@@ -544,7 +652,12 @@
tsaService.handleOSD(receiver, device, webSessions, wsMessage);
- } catch (IOException e) {
+ } catch (NullPointerException e) {
+ log.error("处理OSD消息NPE,headers={}, payload={}",
+ message.getHeaders(), message.getPayload(), e); // 打印完整栈
+ }
+ catch (IOException e) {
+ log.error("处理OSD消息的IO异常:{}",e.getMessage(), e);
e.printStackTrace();
}
}
@@ -616,6 +729,7 @@
// 验证授权数量
validateAuthorization(devicesList.size(), 1);
} catch (Exception e) {
+ log.error("保存设备时验证授权异常,请联系管理员!错误信息:" + e.getMessage());
return Optional.empty();
}
// 调用验证方法
@@ -751,6 +865,8 @@
.firmwareVersion(entity.getFirmwareVersion())
.deptId(entity.getDeptId())
.workType(entity.getWorkType())
+ .webrtcUrl(entity.getWebrtcUrl())
+ .cameraWebrtcUrl(entity.getCameraWebrtcUrl())
.workspaceName(entity.getDeptId() != null
? Optional.ofNullable(sysDeptService.selectDeptById(entity.getDeptId()))
.map(SysDept::getDeptName)
@@ -801,6 +917,25 @@
int update = mapper.update(null, lambdaUpdateWrapper);
return update > 0;
}
+
+ @Override
+ public Boolean updateWebrtcUrl(String sn, String webrtcUrl){
+ LambdaUpdateWrapper<DeviceEntity> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+ lambdaUpdateWrapper.eq(DeviceEntity::getDeviceSn, sn)
+ .set(DeviceEntity::getWebrtcUrl, webrtcUrl);
+ int update = mapper.update(null, lambdaUpdateWrapper);
+ return update > 0;
+ }
+
+ public Boolean updateCameraWebrtcUrl(String sn, String CameraWebrtcUrl){
+ LambdaUpdateWrapper<DeviceEntity> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+ lambdaUpdateWrapper.eq(DeviceEntity::getDeviceSn, sn)
+ .set(DeviceEntity::getCameraWebrtcUrl, CameraWebrtcUrl);
+ int update = mapper.update(null, lambdaUpdateWrapper);
+ return update > 0;
+ }
+
+
@Override
public Boolean bindDevice(DeviceDTO device) {
@@ -877,6 +1012,9 @@
BindDeviceReceiver dock = null;
BindDeviceReceiver drone = null;
for (BindDeviceReceiver device : devices) {
+ if(device.getDeviceModelKey().isEmpty()){
+ continue;
+ }
int val = Integer.parseInt(device.getDeviceModelKey().split("-")[0]);
if (val == DeviceDomainEnum.DOCK.getVal()) {
dock = device;
@@ -1188,6 +1326,8 @@
.domain(dto.getDomain())
.firmwareVersion(dto.getFirmwareVersion())
.workType(dto.getWorkType())
+ .webrtcUrl(dto.getWebrtcUrl())
+ .cameraWebrtcUrl(dto.getCameraWebrtcUrl())
.compatibleStatus(dto.getFirmwareStatus() == null ? null :
DeviceFirmwareStatusEnum.CONSISTENT_UPGRADE != DeviceFirmwareStatusEnum.find(dto.getFirmwareStatus()))
.build();
@@ -1247,7 +1387,7 @@
.sn(device.getDeviceSn())
.deviceCallsign(device.getNickname())
.isDeviceBindOrganization(device.getBoundStatus())
- .organizationId(device.getDeptId().toString())
+ .organizationId(String.valueOf(device.getDeptId()))
.organizationName(device.getWorkspaceName())
.build();
}
--
Gitblit v1.9.3