From c2e2e24551f4603d2ef01c170de37359cf44afce Mon Sep 17 00:00:00 2001 From: 648540858 <456panlinlin> Date: 星期二, 12 四月 2022 11:04:08 +0800 Subject: [PATCH] 优化通道刷新 --- web_src/src/components/DeviceList.vue | 27 +++++-------- src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java | 2 src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java | 6 +++ src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java | 13 ++++++ src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java | 29 +++++++------- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java | 16 +++++--- 6 files changed, 55 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java index 8a3bc84..199f826 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java @@ -44,6 +44,12 @@ 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); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java index 770d2f7..129f5df 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java @@ -23,6 +23,7 @@ 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 @@ 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 { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java index cc54ec9..32b645c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java @@ -115,16 +115,15 @@ 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 @@ 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); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index 439ecd8..667a619 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -274,7 +274,7 @@ channels = deviceChannelList; } if (stringBuilder.length() > 0) { - logger.debug("[鐩綍鏌ヨ]鏀跺埌鐨勬暟鎹瓨鍦ㄩ噸澶嶏細 {}" , stringBuilder); + logger.info("[鐩綍鏌ヨ]鏀跺埌鐨勬暟鎹瓨鍦ㄩ噸澶嶏細 {}" , stringBuilder); } try { int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java index 5e9cd60..6413396 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java @@ -175,22 +175,23 @@ }); // 绛夊緟鍏朵粬鐩稿悓璇锋眰杩斿洖鏃朵竴璧疯繑鍥� 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; } /** diff --git a/web_src/src/components/DeviceList.vue b/web_src/src/components/DeviceList.vue index 74e3fbc..8a156d5 100644 --- a/web_src/src/components/DeviceList.vue +++ b/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({ -- Gitblit v1.8.0