From 0dd2826b9ea55fbb8cb433fd14d88136b6d3d209 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: Mon, 30 Dec 2024 15:59:15 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=BE=E5=A4=87=E8=AE=A2?=
=?UTF-8?q?=E9=98=85=E7=9A=84=E6=93=8D=E4=BD=9C=E6=96=B9=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../vmp/gb28181/controller/DeviceQuery.java | 17 ++
.../iot/vmp/gb28181/dao/DeviceMapper.java | 18 ++-
.../service/IDeviceChannelService.java | 1 +
.../vmp/gb28181/service/IDeviceService.java | 5 +
.../service/impl/DeviceServiceImpl.java | 146 +++++++++++-------
web_src/src/components/DeviceList.vue | 114 +++++++++++---
web_src/src/components/GBRecordDetail.vue | 2 +-
web_src/src/components/channelList.vue | 2 +-
web_src/src/components/dialog/deviceEdit.vue | 21 ---
.../src/components/dialog/devicePlayer.vue | 2 +-
10 files changed, 225 insertions(+), 103 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java
index 226e51d8..30720b36 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java
@@ -489,4 +489,21 @@ public class DeviceQuery {
public DeviceChannel getRawChannel(int id) {
return deviceChannelService.getRawChannel(id);
}
+
+ @GetMapping("/subscribe/catalog")
+ @Operation(summary = "开启/关闭目录订阅")
+ @Parameter(name = "id", description = "通道的Id", required = true)
+ @Parameter(name = "cycle", description = "订阅周期", required = true)
+ public void subscribeCatalog(int id, int cycle) {
+ deviceService.subscribeCatalog(id, cycle);
+ }
+
+ @GetMapping("/subscribe/mobile-position")
+ @Operation(summary = "开启/关闭移动位置订阅")
+ @Parameter(name = "id", description = "通道的Id", required = true)
+ @Parameter(name = "cycle", description = "订阅周期", required = true)
+ @Parameter(name = "interval", description = "报送间隔", required = true)
+ public void subscribeMobilePosition(int id, int cycle, int interval) {
+ deviceService.subscribeMobilePosition(id, cycle, interval);
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java
index 9eec2a9a..3f50e435 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java
@@ -247,9 +247,8 @@ public interface DeviceMapper {
@Update(value = {" "})
@@ -351,4 +350,17 @@ public interface DeviceMapper {
@Select("select wd.* from wvp_device wd left join wvp_device_channel wdc on wdc.data_type = #{dataType} and wd.id = wdc.data_device_id where wdc.device_id = #{channelDeviceId}")
Device getDeviceBySourceChannelDeviceId(@Param("dataType") Integer dataType, @Param("channelDeviceId") String channelDeviceId);
+ @Update(value = {" "})
+ void updateSubscribeCatalog(Device device);
+
+ @Update(value = {" "})
+ void updateSubscribeMobilePosition(Device device);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java
index bb21e321..c4a0200e 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java
@@ -125,4 +125,5 @@ public interface IDeviceChannelService {
List queryChaneListByDeviceDbId(Integer deviceDbId);
List queryChaneIdListByDeviceDbIds(List deviceDbId);
+
}
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 0812f8cf..09a86179 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
@@ -161,4 +161,9 @@ public interface IDeviceService {
Device getDeviceByChannelId(Integer channelId);
Device getDeviceBySourceChannelDeviceId(String requesterId);
+
+ void subscribeCatalog(int id, int cycle);
+
+ void subscribeMobilePosition(int id, int cycle, int interval);
+
}
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 9747cf88..0f9bd4b2 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
@@ -12,7 +12,6 @@ import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper;
import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
-import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
@@ -35,6 +34,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.Assert;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
@@ -263,6 +263,9 @@ public class DeviceServiceImpl implements IDeviceService {
@Override
public boolean removeCatalogSubscribe(Device device, CommonCallback callback) {
if (device == null || device.getSubscribeCycleForCatalog() < 0) {
+ if (callback != null) {
+ callback.run(false);
+ }
return false;
}
log.info("[移除目录订阅]: {}", device.getDeviceId());
@@ -272,6 +275,16 @@ public class DeviceServiceImpl implements IDeviceService {
if (runnable instanceof ISubscribeTask) {
ISubscribeTask subscribeTask = (ISubscribeTask) runnable;
subscribeTask.stop(callback);
+ }else {
+ log.info("[移除目录订阅]失败,未找到订阅任务 : {}", device.getDeviceId());
+ if (callback != null) {
+ callback.run(false);
+ }
+ }
+ }else {
+ log.info("[移除移动位置订阅]失败,设备已经离线 : {}", device.getDeviceId());
+ if (callback != null) {
+ callback.run(false);
}
}
dynamicTask.stop(taskKey);
@@ -297,6 +310,9 @@ public class DeviceServiceImpl implements IDeviceService {
@Override
public boolean removeMobilePositionSubscribe(Device device, CommonCallback callback) {
if (device == null || device.getSubscribeCycleForCatalog() < 0) {
+ if (callback != null) {
+ callback.run(false);
+ }
return false;
}
log.info("[移除移动位置订阅]: {}", device.getDeviceId());
@@ -306,6 +322,16 @@ public class DeviceServiceImpl implements IDeviceService {
if (runnable instanceof ISubscribeTask) {
ISubscribeTask subscribeTask = (ISubscribeTask) runnable;
subscribeTask.stop(callback);
+ }else {
+ log.info("[移除移动位置订阅]失败,未找到订阅任务 : {}", device.getDeviceId());
+ if (callback != null) {
+ callback.run(false);
+ }
+ }
+ }else {
+ log.info("[移除移动位置订阅]失败,设备已经离线 : {}", device.getDeviceId());
+ if (callback != null) {
+ callback.run(false);
}
}
dynamicTask.stop(taskKey);
@@ -421,64 +447,12 @@ public class DeviceServiceImpl implements IDeviceService {
@Override
public void updateCustomDevice(Device device) {
+ // 订阅状态的修改使用一个单独方法控制,此处不再进行状态修改
Device deviceInStore = deviceMapper.query(device.getId());
if (deviceInStore == null) {
log.warn("更新设备时未找到设备信息");
return;
}
- // 目录订阅相关的信息
- if (deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) {
- if (device.getSubscribeCycleForCatalog() > 0) {
- // 若已开启订阅,但订阅周期不同,则先取消
- if (deviceInStore.getSubscribeCycleForCatalog() != 0) {
- removeCatalogSubscribe(deviceInStore, result->{
- // 开启订阅
- deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
- addCatalogSubscribe(deviceInStore);
- // 因为是异步执行,需要在这里更新下数据
- deviceMapper.updateCustom(deviceInStore);
- redisCatchStorage.updateDevice(deviceInStore);
- });
- }else {
- // 开启订阅
- deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
- addCatalogSubscribe(deviceInStore);
- }
-
- }else if (device.getSubscribeCycleForCatalog() == 0) {
- // 取消订阅
- deviceInStore.setSubscribeCycleForCatalog(0);
- removeCatalogSubscribe(deviceInStore, null);
- }
- }
- // 移动位置订阅相关的信息
- if (deviceInStore.getSubscribeCycleForMobilePosition() != device.getSubscribeCycleForMobilePosition()) {
- if (device.getSubscribeCycleForMobilePosition() > 0) {
- // 若已开启订阅,但订阅周期不同,则先取消
- if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) {
- removeMobilePositionSubscribe(deviceInStore, result->{
- // 开启订阅
- deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition());
- deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval());
- addMobilePositionSubscribe(deviceInStore);
- // 因为是异步执行,需要在这里更新下数据
- deviceMapper.updateCustom(deviceInStore);
- redisCatchStorage.updateDevice(deviceInStore);
- });
- }else {
- // 开启订阅
- deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition());
- deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval());
- addMobilePositionSubscribe(deviceInStore);
- }
-
- }else if (device.getSubscribeCycleForMobilePosition() == 0) {
- // 取消订阅
- deviceInStore.setSubscribeCycleForMobilePosition(0);
- deviceInStore.setMobilePositionSubmissionInterval(0);
- removeMobilePositionSubscribe(deviceInStore, null);
- }
- }
if (deviceInStore.getGeoCoordSys() != null) {
// 坐标系变化,需要重新计算GCJ02坐标和WGS84坐标
if (!deviceInStore.getGeoCoordSys().equals(device.getGeoCoordSys())) {
@@ -547,4 +521,68 @@ public class DeviceServiceImpl implements IDeviceService {
public Device getDeviceBySourceChannelDeviceId(String channelId) {
return deviceMapper.getDeviceBySourceChannelDeviceId(ChannelDataType.GB28181.value,channelId);
}
+
+ @Override
+ public void subscribeCatalog(int id, int cycle) {
+ Device device = deviceMapper.query(id);
+ Assert.notNull(device, "未找到设备");
+ if (device.getSubscribeCycleForCatalog() == cycle) {
+ return;
+ }
+
+ // 目录订阅相关的信息
+ if (device.getSubscribeCycleForCatalog() > 0) {
+ // 订阅周期不同,则先取消
+ removeCatalogSubscribe(device, result->{
+ device.setSubscribeCycleForCatalog(cycle);
+ if (cycle > 0) {
+ // 开启订阅
+ addCatalogSubscribe(device);
+ }
+ // 因为是异步执行,需要在这里更新下数据
+ deviceMapper.updateSubscribeCatalog(device);
+ redisCatchStorage.updateDevice(device);
+ });
+ }else {
+ // 开启订阅
+ device.setSubscribeCycleForCatalog(cycle);
+ addCatalogSubscribe(device);
+ deviceMapper.updateSubscribeCatalog(device);
+ redisCatchStorage.updateDevice(device);
+ }
+ }
+
+ @Override
+ public void subscribeMobilePosition(int id, int cycle, int interval) {
+ Device device = deviceMapper.query(id);
+ Assert.notNull(device, "未找到设备");
+ if (device.getSubscribeCycleForMobilePosition() == cycle) {
+ return;
+ }
+
+ // 目录订阅相关的信息
+ if (device.getSubscribeCycleForMobilePosition() > 0) {
+ // 订阅周期已经开启,则先取消
+ removeMobilePositionSubscribe(device, result->{
+ // 开启订阅
+ device.setSubscribeCycleForMobilePosition(cycle);
+ device.setMobilePositionSubmissionInterval(interval);
+ if (cycle > 0) {
+ addMobilePositionSubscribe(device);
+ }
+ // 因为是异步执行,需要在这里更新下数据
+ deviceMapper.updateSubscribeMobilePosition(device);
+ redisCatchStorage.updateDevice(device);
+ });
+ }else {
+ // 订阅未开启
+ device.setSubscribeCycleForMobilePosition(cycle);
+ device.setMobilePositionSubmissionInterval(interval);
+ // 开启订阅
+ addMobilePositionSubscribe(device);
+ // 因为是异步执行,需要在这里更新下数据
+ deviceMapper.updateSubscribeMobilePosition(device);
+ redisCatchStorage.updateDevice(device);
+ }
+ }
}
diff --git a/web_src/src/components/DeviceList.vue b/web_src/src/components/DeviceList.vue
index 7525def5..f538b1ea 100755
--- a/web_src/src/components/DeviceList.vue
+++ b/web_src/src/components/DeviceList.vue
@@ -4,10 +4,10 @@
设备列表
-
+
-
+
@@ -35,9 +35,9 @@
-
+
-
+
@@ -48,9 +48,12 @@
-
+
+
+ {{scope.row.channelCount}}
+
-
+
在线
@@ -58,18 +61,20 @@
-
-
-
-
-
-
-
-
-
-
+
- subscribeForCatalog(scope.row.id, e)">
+ subscribeForMobilePosition(scope.row.id, e)">
+
+
+
+
+
+
+
+
+
+ 刷新
@@ -79,13 +84,13 @@
编辑
- 删除
-
{moreClick(command, scope.row)}">
操作
-
+
+
+ 删除
布防
@@ -164,6 +169,8 @@ export default {
},
methods: {
initData: function () {
+ this.currentPage = 1;
+ this.total= 0;
this.getDeviceList();
},
currentChange: function (val) {
@@ -346,6 +353,8 @@ export default {
this.setGuard(itemData)
}else if (command === "resetGuard") {
this.resetGuard(itemData)
+ }else if (command === "delete") {
+ this.deleteDevice(itemData)
}
},
setGuard: function (itemData) {
@@ -394,6 +403,67 @@ export default {
})
});
},
+ subscribeForCatalog: function (data, value) {
+ console.log(data)
+ console.log(value)
+ this.$axios({
+ method: 'get',
+ url: `/api/device/query/subscribe/catalog`,
+ params: {
+ id: data,
+ cycle: value?60:0
+ }
+ }).then( (res)=> {
+ if (res.data.code === 0) {
+ this.$message.success({
+ showClose: true,
+ message: value?"订阅成功":"取消订阅成功"
+ })
+ }else {
+ this.$message.error({
+ showClose: true,
+ message: res.data.msg
+ })
+ }
+ }).catch( (error)=> {
+ this.$message.error({
+ showClose: true,
+ message: error.message
+ })
+ });
+
+ },
+ subscribeForMobilePosition: function (data, value) {
+ console.log(data)
+ console.log(value)
+ this.$axios({
+ method: 'get',
+ url: `/api/device/query/subscribe/mobile-position`,
+ params: {
+ id: data,
+ cycle: value?60:0,
+ interval: value?5:0
+ }
+ }).then( (res)=> {
+ if (res.data.code === 0) {
+ this.$message.success({
+ showClose: true,
+ message: value?"订阅成功":"取消订阅成功"
+ })
+ }else {
+ this.$message.error({
+ showClose: true,
+ message: res.data.msg
+ })
+ }
+ }).catch( (error)=> {
+ this.$message.error({
+ showClose: true,
+ message: error.message
+ })
+ });
+
+ },
}
};
diff --git a/web_src/src/components/GBRecordDetail.vue b/web_src/src/components/GBRecordDetail.vue
index 288bfe19..9cc853ae 100755
--- a/web_src/src/components/GBRecordDetail.vue
+++ b/web_src/src/components/GBRecordDetail.vue
@@ -64,7 +64,7 @@
倍速
-
+
0.25倍速
0.5倍速
1倍速
diff --git a/web_src/src/components/channelList.vue b/web_src/src/components/channelList.vue
index 0f4a4c67..db2ab937 100755
--- a/web_src/src/components/channelList.vue
+++ b/web_src/src/components/channelList.vue
@@ -141,7 +141,7 @@
更多
-
+
设备录像
diff --git a/web_src/src/components/dialog/deviceEdit.vue b/web_src/src/components/dialog/deviceEdit.vue
index a4cee372..860d9b73 100755
--- a/web_src/src/components/dialog/deviceEdit.vue
+++ b/web_src/src/components/dialog/deviceEdit.vue
@@ -43,21 +43,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -122,12 +107,6 @@ export default {
onSubmit: function () {
console.log("onSubmit");
console.log(this.form);
- this.form.subscribeCycleForCatalog = this.form.subscribeCycleForCatalog||0
- this.form.subscribeCycleForMobilePosition = this.form.subscribeCycleForMobilePosition||0
- this.form.mobilePositionSubmissionInterval = this.form.mobilePositionSubmissionInterval||0
- if (this.form.mobilePositionSubmissionInterval === 0) {
- this.form.mobilePositionSubmissionInterval = 5
- }
this.$axios({
method: 'post',
url:`/api/device/query/device/${this.isEdit?'update':'add'}/`,
diff --git a/web_src/src/components/dialog/devicePlayer.vue b/web_src/src/components/dialog/devicePlayer.vue
index 9644d1c8..22f2da6d 100755
--- a/web_src/src/components/dialog/devicePlayer.vue
+++ b/web_src/src/components/dialog/devicePlayer.vue
@@ -57,7 +57,7 @@
更多地址
-
+
FLV:
{{ streamInfo.flv }}