Browse Source

优化通道刷新

pull/437/head
648540858 2 years ago
parent
commit
c2e2e24551
  1. 6
      src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
  2. 13
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java
  3. 16
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java
  4. 2
      src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
  5. 29
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
  6. 27
      web_src/src/components/DeviceList.vue

6
src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java

@ -44,6 +44,12 @@ public class CatalogDataCatch {
return catalogData.getChannelList();
}
public int getTotal(String key) {
CatalogData catalogData = data.get(key);
if (catalogData == null) return 0;
return catalogData.getTotal();
}
public void del(String key) {
data.remove(key);
}

13
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java

@ -23,6 +23,7 @@ import javax.sip.*;
import javax.sip.address.SipURI;
import javax.sip.header.HeaderAddress;
import javax.sip.header.ToHeader;
import javax.sip.message.Response;
import java.text.ParseException;
import java.util.Iterator;
@ -103,6 +104,18 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
if (!StringUtils.isEmpty(getText(rootElement,"PTZCmd")) && !parentPlatform.getServerGBId().equals(targetGBId)) {
String cmdString = getText(rootElement,"PTZCmd");
Device deviceForPlatform = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId);
if (deviceForPlatform == null) {
try {
responseAck(evt, Response.NOT_FOUND);
return;
} catch (SipException e) {
e.printStackTrace();
} catch (InvalidArgumentException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
}
cmder.fronEndCmd(deviceForPlatform, channelId, cmdString, eventResult -> {
// 失败的回复
try {

16
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java

@ -115,16 +115,15 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
continue;
}
//by brewswang
if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {//如果包含位置信息,就更新一下位置
processNotifyMobilePosition(evt, itemDevice);
}
// if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {//如果包含位置信息,就更新一下位置
// processNotifyMobilePosition(evt, itemDevice);
// }
DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice);
deviceChannel.setDeviceId(device.getDeviceId());
logger.debug("收到来自设备【{}】的通道: {}【{}】", device.getDeviceId(), deviceChannel.getName(), deviceChannel.getChannelId());
channelList.add(deviceChannel);
}
logger.debug("收到来自设备【{}】的通道: {}个,{}/{}", device.getDeviceId(), channelList.size(), catalogDataCatch.get(key) == null ? 0 :catalogDataCatch.get(key).size(), sumNum);
catalogDataCatch.put(key, sumNum, device, channelList);
if (catalogDataCatch.get(key).size() == sumNum) {
// 数据已经完整接收
@ -230,4 +229,9 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
e.printStackTrace();
}
}
public String getChannelSyncProgress(String deviceId) {
String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId;
return catalogDataCatch.get(key) == null ? "0/0" : catalogDataCatch.get(key).size() + "/" + catalogDataCatch.getTotal(key);
}
}

2
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java

@ -274,7 +274,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
channels = deviceChannelList;
}
if (stringBuilder.length() > 0) {
logger.debug("[目录查询]收到的数据存在重复: {}" , stringBuilder);
logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder);
}
try {
int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels);

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

@ -175,22 +175,23 @@ public class DeviceQuery {
});
// 等待其他相同请求返回时一起返回
if (resultHolder.exist(key, null)) {
resultHolder.put(key, uuid, result);
return result;
}else {
cmder.catalogQuery(device, event -> {
RequestMessage msg = new RequestMessage();
msg.setKey(key);
msg.setId(uuid);
WVPResult<Object> wvpResult = new WVPResult<>();
wvpResult.setCode(-1);
wvpResult.setData(device);
wvpResult.setMsg(String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg));
msg.setData(wvpResult);
resultHolder.invokeAllResult(msg);
});
resultHolder.put(key, uuid, result);
return result;
}
cmder.catalogQuery(device, event -> {
RequestMessage msg = new RequestMessage();
msg.setKey(key);
msg.setId(uuid);
WVPResult<Object> wvpResult = new WVPResult<>();
wvpResult.setCode(-1);
wvpResult.setData(device);
wvpResult.setMsg(String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg));
msg.setData(wvpResult);
resultHolder.invokeAllResult(msg);
});
resultHolder.put(key, uuid, result);
return result;
}
/**

27
web_src/src/components/DeviceList.vue

@ -57,7 +57,7 @@
<el-table-column label="操作" width="450" align="center" fixed="right">
<template slot-scope="scope">
<el-button size="mini" :loading="scope.row.loading" v-if="scope.row.online!=0" icon="el-icon-refresh" @click="refDevice(scope.row)">刷新</el-button>
<el-button size="mini" :loading="syncDevices.includes(scope.row.deviceId)" v-if="scope.row.online!=0" icon="el-icon-refresh" @click="refDevice(scope.row)">刷新</el-button>
<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-location" v-bind:disabled="scope.row.online==0" type="primary" @click="showDevicePosition(scope.row)">定位</el-button>
@ -104,7 +104,8 @@
currentPage:1,
count:15,
total:0,
getDeviceListLoading: false
getDeviceListLoading: false,
syncDevices:[]
};
},
computed: {
@ -117,8 +118,6 @@
});
this.currentDeviceChannelsLenth = channels.length;
}
console.log("数据:" + JSON.stringify(channels));
return channels;
}
},
@ -153,13 +152,11 @@
count: that.count
}
}).then(function (res) {
console.log(res);
console.log(res.data.list);
that.total = res.data.total;
that.deviceList = res.data.list;
that.getDeviceListLoading = false;
}).catch(function (error) {
console.log(error);
console.error(error);
that.getDeviceListLoading = false;
});
@ -182,7 +179,7 @@
}).then((res)=>{
this.getDeviceList();
}).catch((error) =>{
console.log(error);
console.error(error);
});
}).catch(() => {
@ -191,11 +188,9 @@
},
showChannelList: function(row) {
console.log(JSON.stringify(row))
this.$router.push(`/channelList/${row.deviceId}/0/15/1`);
},
showDevicePosition: function(row) {
console.log(JSON.stringify(row))
this.$router.push(`/devicePosition/${row.deviceId}/0/15/1`);
},
@ -204,11 +199,11 @@
refDevice: function(itemData) {
console.log("刷新对应设备:" + itemData.deviceId);
var that = this;
that.$set(itemData,"loading", true);
this.syncDevices.push(itemData.deviceId)
this.$axios({
method: 'post',
url: '/api/device/query/devices/' + itemData.deviceId + '/sync'
}).then(function(res) {
}).then((res) => {
console.log("刷新设备结果:"+JSON.stringify(res));
if (res.data.code !==0) {
that.$message({
@ -224,15 +219,15 @@
});
}
that.initData()
that.$set(itemData,"loading", true);
}).catch(function(e) {
this.syncDevices.splice(this.syncDevices.indexOf(itemData.deviceId, 1));
}).catch((e) => {
console.error(e)
that.$message({
showClose: true,
message: e,
type: 'error'
});
that.$set(itemData,"loading", true);
this.syncDevices.splice(this.syncDevices.indexOf(itemData.deviceId, 1));
});
},
//
@ -251,7 +246,6 @@
// });
},
transportChange: function (row) {
console.log(row);
console.log(`修改传输方式为 ${row.streamMode}${row.deviceId} `);
let that = this;
this.$axios({
@ -263,7 +257,6 @@
});
},
edit: function (row) {
console.log(row);
this.$refs.deviceEdit.openDialog(row, ()=>{
this.$refs.deviceEdit.close();
this.$message({

Loading…
Cancel
Save