Browse Source

增加移除离线设备的功能

pull/87/head
panlinlin 4 years ago
parent
commit
f1fae7aac6
  1. 2
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
  2. 5
      src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
  3. 5
      src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
  4. 18
      src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
  5. 21
      src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
  6. 6
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
  7. 21
      web_src/src/components/DeviceList.vue

2
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java

@ -340,7 +340,7 @@ public class ZLMHttpHookListener {
String app = json.getString("app"); String app = json.getString("app");
String streamId = json.getString("stream"); String streamId = json.getString("stream");
StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId); StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
if ("rtp".equals(app) && streamId.indexOf("gb_play") > -1 && streamInfo == null) { if ("rtp".equals(app) && streamId.contains("gb_play") && streamInfo == null) {
String[] s = streamId.split("_"); String[] s = streamId.split("_");
if (s.length == 4) { if (s.length == 4) {
String deviceId = s[2]; String deviceId = s[2];

5
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java

@ -104,4 +104,9 @@ public interface IRedisCatchStorage {
*/ */
boolean isChannelSendingRTP(String channelId); boolean isChannelSendingRTP(String channelId);
/**
* 清空某个设备的所有缓存
* @param deviceId 设备ID
*/
void clearCatchByDeviceId(String deviceId);
} }

5
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java

@ -37,6 +37,11 @@ public interface PlatformChannelMapper {
"</script>") "</script>")
int delChannelForGB(String platformId, List<ChannelReduce> channelReducesToDel); int delChannelForGB(String platformId, List<ChannelReduce> channelReducesToDel);
@Delete("<script> "+
"DELETE FROM platform_gb_channel WHERE deviceId='${deviceId}' " +
"</script>")
int delChannelForDeviceId(String deviceId);
@Delete("<script> "+ @Delete("<script> "+
"DELETE FROM platform_gb_channel WHERE platformId='${platformId}'" + "DELETE FROM platform_gb_channel WHERE platformId='${platformId}'" +
"</script>") "</script>")

18
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java

@ -259,4 +259,22 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
} }
} }
@Override
public void clearCatchByDeviceId(String deviceId) {
List<Object> playLeys = redis.scan(String.format("%S_*_%s_*", VideoManagerConstants.PLAYER_PREFIX,
deviceId));
if (playLeys.size() > 0) {
for (Object key : playLeys) {
redis.del(key.toString());
}
}
List<Object> playBackers = redis.scan(String.format("%S_*_%s_*", VideoManagerConstants.PLAY_BLACK_PREFIX,
deviceId));
if (playBackers.size() > 0) {
for (Object key : playBackers) {
redis.del(key.toString());
}
}
}
} }

21
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java

@ -195,9 +195,22 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
*/ */
@Override @Override
public boolean delete(String deviceId) { public boolean delete(String deviceId) {
int result = deviceMapper.del(deviceId); TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
boolean result = false;
return result > 0; try {
if (platformChannelMapper.delChannelForDeviceId(deviceId) <0 // 删除与国标平台的关联
|| deviceChannelMapper.cleanChannelsByDeviceId(deviceId) < 0 // 删除他的通道
|| deviceMapper.del(deviceId) < 0 // 移除设备信息
) {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
}
result = true;
dataSourceTransactionManager.commit(transactionStatus); //手动提交
}catch (Exception e) {
dataSourceTransactionManager.rollback(transactionStatus);
}
return result;
} }
/** /**
@ -550,4 +563,6 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
public void mediaOutline(String app, String streamId) { public void mediaOutline(String app, String streamId) {
gbStreamMapper.setStatus(app, streamId, false); gbStreamMapper.setStatus(app, streamId, false);
} }
} }

6
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java

@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.vmanager.gb28181.device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -33,6 +34,9 @@ public class DeviceQuery {
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorager storager;
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Autowired @Autowired
private SIPCommander cmder; private SIPCommander cmder;
@ -177,8 +181,10 @@ public class DeviceQuery {
if (offLineDetector.isOnline(deviceId)) { if (offLineDetector.isOnline(deviceId)) {
return new ResponseEntity<String>("不允许删除在线设备!", HttpStatus.NOT_ACCEPTABLE); return new ResponseEntity<String>("不允许删除在线设备!", HttpStatus.NOT_ACCEPTABLE);
} }
// 清除redis记录
boolean isSuccess = storager.delete(deviceId); boolean isSuccess = storager.delete(deviceId);
if (isSuccess) { if (isSuccess) {
redisCatchStorage.clearCatchByDeviceId(deviceId);
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("deviceId", deviceId); json.put("deviceId", deviceId);
return new ResponseEntity<>(json.toString(),HttpStatus.OK); return new ResponseEntity<>(json.toString(),HttpStatus.OK);

21
web_src/src/components/DeviceList.vue

@ -51,11 +51,12 @@
<el-table-column label="操作" width="360" align="center" fixed="right"> <el-table-column label="操作" width="360" align="center" fixed="right">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" :ref="scope.row.deviceId + 'refbtn' " icon="el-icon-refresh" @click="refDevice(scope.row)">刷新</el-button> <el-button size="mini" :ref="scope.row.deviceId + 'refbtn' " v-if="scope.row.online!=0" icon="el-icon-refresh" @click="refDevice(scope.row)">刷新</el-button>
<el-button-group> <el-button-group>
<el-button size="mini" icon="el-icon-video-camera-solid" v-bind:disabled="scope.row.online==0" type="primary" @click="showChannelList(scope.row)">通道</el-button> <el-button size="mini" icon="el-icon-video-camera-solid" v-bind:disabled="scope.row.online==0" type="primary" @click="showChannelList(scope.row)">通道</el-button>
<el-button size="mini" icon="el-icon-location" v-bind:disabled="scope.row.online==0" type="primary" @click="showDevicePosition(scope.row)">定位</el-button> <el-button size="mini" icon="el-icon-location" v-bind:disabled="scope.row.online==0" type="primary" @click="showDevicePosition(scope.row)">定位</el-button>
<el-button size="mini" icon="el-icon-s-tools" v-bind:disabled="scope.row.online==0" type="primary">控制</el-button> <el-button size="mini" icon="el-icon-s-tools" v-bind:disabled="scope.row.online==0" type="primary">控制</el-button>
<el-button size="mini" icon="el-icon-delete" type="danger" v-if="scope.row.online==0" @click="deleteDevice(scope.row)">删除</el-button>
</el-button-group> </el-button-group>
</template> </template>
</el-table-column> </el-table-column>
@ -155,6 +156,18 @@
}); });
}, },
deleteDevice: function(row) {
let that = this;
this.$axios({
method: 'delete',
url:`/api/device/query/devices/${row.deviceId}/delete`
}).then((res)=>{
this.getDeviceList();
}).catch((error) =>{
console.log(error);
});
},
showChannelList: function(row) { showChannelList: function(row) {
console.log(JSON.stringify(row)) console.log(JSON.stringify(row))
this.$router.push(`/channelList/${row.deviceId}/0/15/1`); this.$router.push(`/channelList/${row.deviceId}/0/15/1`);

Loading…
Cancel
Save