From 80912d8a2c2e3855d112dcf1dd724d368051c7bf Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: Sat, 14 Sep 2024 17:50:05 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../vmp/gb28181/dao/DeviceChannelMapper.java | 20 +-
.../vmp/gb28181/service/IDeviceService.java | 2 +-
.../service/impl/DeviceServiceImpl.java | 2 +-
.../PushStreamStatusChangeFromRedisDto.java | 28 +-
.../redisMsg/RedisAlarmMsgListener.java | 5 +-
.../service/redisMsg/RedisGpsMsgListener.java | 2 +
.../RedisPushStreamStatusMsgListener.java | 22 +-
.../vmp/web/gb28181/ApiDeviceController.java | 2 +-
.../web/gb28181/dto/DeviceChannelExtend.java | 328 +-----------------
9 files changed, 36 insertions(+), 375 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java
index b0b52d72..9bc5db0f 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java
@@ -172,8 +172,8 @@ public interface DeviceChannelMapper {
"OR coalesce(dc.gb_name, dc.name) LIKE concat('%',#{query},'%') " +
") " +
" AND (dc.parent_id=#{parentChannelId} OR coalesce(dc.gb_civil_code, dc.civil_code) = #{parentChannelId}) " +
- " AND dc.status= true" +
- " AND dc.status= false" +
+ " AND dc.status= 'ON'" +
+ " AND dc.status= 'OFF'" +
" AND dc.sub_count > 0 " +
" AND dc.sub_count = 0 " +
" AND dc.device_id in " +
@@ -246,8 +246,8 @@ public interface DeviceChannelMapper {
" AND de.device_id = #{deviceId} " +
" AND (dc.device_id LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%') " +
" AND dc.parent_id=#{parentChannelId} " +
- " AND dc.status=1" +
- " AND dc.status=0" +
+ " AND dc.status='ON'" +
+ " AND dc.status='OFF'" +
" AND dc.sub_count > 0 " +
" AND dc.sub_count = 0 " +
" AND dc.device_id in " +
@@ -338,8 +338,8 @@ public interface DeviceChannelMapper {
"AND " +
"(COALESCE(dc.gb_device_id, dc.device_id) LIKE concat('%',#{query},'%') " +
" OR COALESCE(dc.gb_name, dc.name) LIKE concat('%',#{query},'%')) " +
- " AND dc.status=1 " +
- " AND dc.status=0 " +
+ " AND dc.status='ON' " +
+ " AND dc.status='OFF' " +
" AND dc.sub_count > 0 " +
" AND dc.sub_count = 0 " +
" AND dc.id not in (select device_channel_id from wvp_platform_channel where platform_id=#{platformId} ) " +
@@ -396,7 +396,7 @@ public interface DeviceChannelMapper {
" FROM wvp_device_channel WHERE device_id=#{channelId}")
List queryChannelByChannelId(@Param("channelId") String channelId);
- @Update(value = {"UPDATE wvp_device_channel SET status=0 WHERE id=#{id}"})
+ @Update(value = {"UPDATE wvp_device_channel SET status='OFF' WHERE id=#{id}"})
void offline(@Param("id") int id);
@Insert(""})
int batchOnline(@Param("channels") List channels);
@Update({""})
int batchOffline(List channels);
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java
index 9e7be53f..9aa46a7e 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java
@@ -89,7 +89,7 @@ public interface IDeviceService {
*/
List getAllOnlineDevice();
- List getAllByStatus(boolean status);
+ List getAllByStatus(Boolean status);
/**
* 判断是否注册已经失效
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java
index 9d110a84..488ed52b 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java
@@ -364,7 +364,7 @@ public class DeviceServiceImpl implements IDeviceService {
}
@Override
- public List getAllByStatus(boolean status) {
+ public List getAllByStatus(Boolean status) {
return deviceMapper.getDevices(status);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/PushStreamStatusChangeFromRedisDto.java b/src/main/java/com/genersoft/iot/vmp/service/bean/PushStreamStatusChangeFromRedisDto.java
index 5bb7b77f..9e9ce351 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/bean/PushStreamStatusChangeFromRedisDto.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/bean/PushStreamStatusChangeFromRedisDto.java
@@ -1,11 +1,14 @@
package com.genersoft.iot.vmp.service.bean;
+import lombok.Data;
+
import java.util.List;
/**
* 收到redis通知修改推流通道状态
* @author lin
*/
+@Data
public class PushStreamStatusChangeFromRedisDto {
private boolean setAllOffline;
@@ -13,29 +16,4 @@ public class PushStreamStatusChangeFromRedisDto {
private List onlineStreams;
private List offlineStreams;
-
-
- public boolean isSetAllOffline() {
- return setAllOffline;
- }
-
- public void setSetAllOffline(boolean setAllOffline) {
- this.setAllOffline = setAllOffline;
- }
-
- public List getOnlineStreams() {
- return onlineStreams;
- }
-
- public void setOnlineStreams(List onlineStreams) {
- this.onlineStreams = onlineStreams;
- }
-
- public List getOfflineStreams() {
- return offlineStreams;
- }
-
- public void setOfflineStreams(List offlineStreams) {
- this.offlineStreams = offlineStreams;
- }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java
index ecfe5676..315ade75 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java
@@ -29,6 +29,10 @@ import java.text.ParseException;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
+/**
+ * 监听 SUBSCRIBE alarm_receive
+ * 发布 PUBLISH alarm_receive '{ "gbId": "", "alarmSn": 1, "alarmType": "111", "alarmDescription": "222", }'
+ */
@Slf4j
@Component
public class RedisAlarmMsgListener implements MessageListener {
@@ -62,7 +66,6 @@ public class RedisAlarmMsgListener implements MessageListener {
@Override
public void onMessage(@NotNull Message message, byte[] bytes) {
- // 消息示例: PUBLISH alarm_receive '{ "gbId": "", "alarmSn": 1, "alarmType": "111", "alarmDescription": "222", }'
log.info("收到来自REDIS的ALARM通知: {}", new String(message.getBody()));
boolean isEmpty = taskQueue.isEmpty();
taskQueue.offer(message);
diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java
index 8d4e10b3..7569fb8e 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java
@@ -20,6 +20,8 @@ import java.util.concurrent.ConcurrentLinkedQueue;
/**
* 接收来自redis的GPS更新通知
* @author lin
+ * 监听: SUBSCRIBE VM_MSG_GPS
+ * 发布 PUBLISH VM_MSG_GPS ''
*/
@Slf4j
@Component
diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java
index f95bc9ff..9746d132 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java
@@ -40,9 +40,7 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic
@Autowired
private UserSetting userSetting;
-
-
- private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>();
+ private final ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>();
@Qualifier("taskExecutor")
@Autowired
@@ -59,26 +57,26 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic
while (!taskQueue.isEmpty()) {
Message msg = taskQueue.poll();
try {
- PushStreamStatusChangeFromRedisDto statusChangeFromPushStream = JSON.parseObject(msg.getBody(), PushStreamStatusChangeFromRedisDto.class);
- if (statusChangeFromPushStream == null) {
+ PushStreamStatusChangeFromRedisDto streamStatusMessage = JSON.parseObject(msg.getBody(), PushStreamStatusChangeFromRedisDto.class);
+ if (streamStatusMessage == null) {
log.warn("[REDIS消息]推流设备状态变化消息解析失败");
continue;
}
// 取消定时任务
dynamicTask.stop(VideoManagerConstants.VM_MSG_GET_ALL_ONLINE_REQUESTED);
- if (statusChangeFromPushStream.isSetAllOffline()) {
+ if (streamStatusMessage.isSetAllOffline()) {
// 所有设备离线
streamPushService.allOffline();
}
- if (statusChangeFromPushStream.getOfflineStreams() != null
- && statusChangeFromPushStream.getOfflineStreams().size() > 0) {
+ if (streamStatusMessage.getOfflineStreams() != null
+ && !streamStatusMessage.getOfflineStreams().isEmpty()) {
// 更新部分设备离线
- streamPushService.offline(statusChangeFromPushStream.getOfflineStreams());
+ streamPushService.offline(streamStatusMessage.getOfflineStreams());
}
- if (statusChangeFromPushStream.getOnlineStreams() != null &&
- statusChangeFromPushStream.getOnlineStreams().size() > 0) {
+ if (streamStatusMessage.getOnlineStreams() != null &&
+ !streamStatusMessage.getOnlineStreams().isEmpty()) {
// 更新部分设备上线
- streamPushService.online(statusChangeFromPushStream.getOnlineStreams());
+ streamPushService.online(streamStatusMessage.getOnlineStreams());
}
}catch (Exception e) {
log.warn("[REDIS消息-推流设备状态变化] 发现未处理的异常, \r\n{}", JSON.toJSONString(message));
diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java
index 06fd5f81..a2f82be8 100644
--- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java
+++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java
@@ -165,7 +165,7 @@ public class ApiDeviceController {
// 1-IETF RFC3261,
// 2-基于口令的双向认证,
// 3-基于数字证书的双向认证
- deviceJOSNChannel.put("Status", deviceChannelExtend.isStatus() ? "ON":"OFF");
+ deviceJOSNChannel.put("Status", deviceChannelExtend.getStatus());
deviceJOSNChannel.put("Longitude", deviceChannelExtend.getLongitude());
deviceJOSNChannel.put("Latitude", deviceChannelExtend.getLatitude());
deviceJOSNChannel.put("PTZType ", deviceChannelExtend.getPTZType()); // 云台类型, 0 - 未知, 1 - 球机, 2 - 半球,
diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java
index 5e76cb70..e963075e 100644
--- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java
+++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java
@@ -1,5 +1,8 @@
package com.genersoft.iot.vmp.web.gb28181.dto;
+import lombok.Data;
+
+@Data
public class DeviceChannelExtend {
@@ -146,7 +149,7 @@ public class DeviceChannelExtend {
* OFF
* 遇到过NVR下的IPC下发信令可以推流, 但是 Status 响应 OFF
*/
- private boolean status;
+ private String status;
/**
* 经度
@@ -208,21 +211,6 @@ public class DeviceChannelExtend {
*/
private String gpsTime;
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getDeviceId() {
- return deviceId;
- }
-
- public void setDeviceId(String deviceId) {
- this.deviceId = deviceId;
- }
public void setPTZType(int PTZType) {
this.PTZType = PTZType;
@@ -244,312 +232,4 @@ public class DeviceChannelExtend {
break;
}
}
-
- public String getChannelId() {
- return channelId;
- }
-
- public void setChannelId(String channelId) {
- this.channelId = channelId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getManufacture() {
- return manufacture;
- }
-
- public void setManufacture(String manufacture) {
- this.manufacture = manufacture;
- }
-
- public String getModel() {
- return model;
- }
-
- public void setModel(String model) {
- this.model = model;
- }
-
- public String getOwner() {
- return owner;
- }
-
- public void setOwner(String owner) {
- this.owner = owner;
- }
-
- public String getCivilCode() {
- return civilCode;
- }
-
- public void setCivilCode(String civilCode) {
- this.civilCode = civilCode;
- }
-
- public String getBlock() {
- return block;
- }
-
- public void setBlock(String block) {
- this.block = block;
- }
-
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
- public int getParental() {
- return parental;
- }
-
- public void setParental(int parental) {
- this.parental = parental;
- }
-
- public String getParentId() {
- return parentId;
- }
-
- public void setParentId(String parentId) {
- this.parentId = parentId;
- }
-
- public int getSafetyWay() {
- return safetyWay;
- }
-
- public void setSafetyWay(int safetyWay) {
- this.safetyWay = safetyWay;
- }
-
- public int getRegisterWay() {
- return registerWay;
- }
-
- public void setRegisterWay(int registerWay) {
- this.registerWay = registerWay;
- }
-
- public String getCertNum() {
- return certNum;
- }
-
- public void setCertNum(String certNum) {
- this.certNum = certNum;
- }
-
- public int getCertifiable() {
- return certifiable;
- }
-
- public void setCertifiable(int certifiable) {
- this.certifiable = certifiable;
- }
-
- public int getErrCode() {
- return errCode;
- }
-
- public void setErrCode(int errCode) {
- this.errCode = errCode;
- }
-
- public String getEndTime() {
- return endTime;
- }
-
- public void setEndTime(String endTime) {
- this.endTime = endTime;
- }
-
- public String getSecrecy() {
- return secrecy;
- }
-
- public void setSecrecy(String secrecy) {
- this.secrecy = secrecy;
- }
-
- public String getIpAddress() {
- return ipAddress;
- }
-
- public void setIpAddress(String ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public int getPTZType() {
- return PTZType;
- }
-
- public String getPTZTypeText() {
- return PTZTypeText;
- }
-
- public void setPTZTypeText(String PTZTypeText) {
- this.PTZTypeText = PTZTypeText;
- }
-
- public boolean isStatus() {
- return status;
- }
-
- public void setStatus(boolean status) {
- this.status = status;
- }
-
- public double getLongitude() {
- return longitude;
- }
-
- public void setLongitude(double longitude) {
- this.longitude = longitude;
- }
-
- public double getLatitude() {
- return latitude;
- }
-
- public void setLatitude(double latitude) {
- this.latitude = latitude;
- }
-
- public double getLongitudeGcj02() {
- return longitudeGcj02;
- }
-
- public void setLongitudeGcj02(double longitudeGcj02) {
- this.longitudeGcj02 = longitudeGcj02;
- }
-
- public double getLatitudeGcj02() {
- return latitudeGcj02;
- }
-
- public void setLatitudeGcj02(double latitudeGcj02) {
- this.latitudeGcj02 = latitudeGcj02;
- }
-
- public double getLongitudeWgs84() {
- return longitudeWgs84;
- }
-
- public void setLongitudeWgs84(double longitudeWgs84) {
- this.longitudeWgs84 = longitudeWgs84;
- }
-
- public double getLatitudeWgs84() {
- return latitudeWgs84;
- }
-
- public void setLatitudeWgs84(double latitudeWgs84) {
- this.latitudeWgs84 = latitudeWgs84;
- }
-
- public int getSubCount() {
- return subCount;
- }
-
- public void setSubCount(int subCount) {
- this.subCount = subCount;
- }
-
- public boolean isHasAudio() {
- return hasAudio;
- }
-
- public void setHasAudio(boolean hasAudio) {
- this.hasAudio = hasAudio;
- }
-
- public String getStreamId() {
- return streamId;
- }
-
- public void setStreamId(String streamId) {
- this.streamId = streamId;
- }
-
- public String getCreateTime() {
- return createTime;
- }
-
- public void setCreateTime(String createTime) {
- this.createTime = createTime;
- }
-
- public String getUpdateTime() {
- return updateTime;
- }
-
- public void setUpdateTime(String updateTime) {
- this.updateTime = updateTime;
- }
-
- public int getChannelType() {
- return channelType;
- }
-
- public void setChannelType(int channelType) {
- this.channelType = channelType;
- }
-
- public String getBusinessGroupId() {
- return businessGroupId;
- }
-
- public void setBusinessGroupId(String businessGroupId) {
- this.businessGroupId = businessGroupId;
- }
-
- public String getGpsTime() {
- return gpsTime;
- }
-
- public void setGpsTime(String gpsTime) {
- this.gpsTime = gpsTime;
- }
-
- public String getDeviceName() {
- return deviceName;
- }
-
- public void setDeviceName(String deviceName) {
- this.deviceName = deviceName;
- }
-
- public boolean isDeviceOnline() {
- return deviceOnline;
- }
-
- public void setDeviceOnline(boolean deviceOnline) {
- this.deviceOnline = deviceOnline;
- }
}