Commit c2e2e24551f4603d2ef01c170de37359cf44afce
1 parent
40fb7947
优化通道刷新
Showing
6 changed files
with
55 additions
and
38 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
| @@ -44,6 +44,12 @@ public class CatalogDataCatch { | @@ -44,6 +44,12 @@ public class CatalogDataCatch { | ||
| 44 | return catalogData.getChannelList(); | 44 | return catalogData.getChannelList(); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | + public int getTotal(String key) { | ||
| 48 | + CatalogData catalogData = data.get(key); | ||
| 49 | + if (catalogData == null) return 0; | ||
| 50 | + return catalogData.getTotal(); | ||
| 51 | + } | ||
| 52 | + | ||
| 47 | public void del(String key) { | 53 | public void del(String key) { |
| 48 | data.remove(key); | 54 | data.remove(key); |
| 49 | } | 55 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java
| @@ -23,6 +23,7 @@ import javax.sip.*; | @@ -23,6 +23,7 @@ import javax.sip.*; | ||
| 23 | import javax.sip.address.SipURI; | 23 | import javax.sip.address.SipURI; |
| 24 | import javax.sip.header.HeaderAddress; | 24 | import javax.sip.header.HeaderAddress; |
| 25 | import javax.sip.header.ToHeader; | 25 | import javax.sip.header.ToHeader; |
| 26 | +import javax.sip.message.Response; | ||
| 26 | import java.text.ParseException; | 27 | import java.text.ParseException; |
| 27 | import java.util.Iterator; | 28 | import java.util.Iterator; |
| 28 | 29 | ||
| @@ -103,6 +104,18 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent | @@ -103,6 +104,18 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent | ||
| 103 | if (!StringUtils.isEmpty(getText(rootElement,"PTZCmd")) && !parentPlatform.getServerGBId().equals(targetGBId)) { | 104 | if (!StringUtils.isEmpty(getText(rootElement,"PTZCmd")) && !parentPlatform.getServerGBId().equals(targetGBId)) { |
| 104 | String cmdString = getText(rootElement,"PTZCmd"); | 105 | String cmdString = getText(rootElement,"PTZCmd"); |
| 105 | Device deviceForPlatform = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); | 106 | Device deviceForPlatform = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); |
| 107 | + if (deviceForPlatform == null) { | ||
| 108 | + try { | ||
| 109 | + responseAck(evt, Response.NOT_FOUND); | ||
| 110 | + return; | ||
| 111 | + } catch (SipException e) { | ||
| 112 | + e.printStackTrace(); | ||
| 113 | + } catch (InvalidArgumentException e) { | ||
| 114 | + e.printStackTrace(); | ||
| 115 | + } catch (ParseException e) { | ||
| 116 | + e.printStackTrace(); | ||
| 117 | + } | ||
| 118 | + } | ||
| 106 | cmder.fronEndCmd(deviceForPlatform, channelId, cmdString, eventResult -> { | 119 | cmder.fronEndCmd(deviceForPlatform, channelId, cmdString, eventResult -> { |
| 107 | // 失败的回复 | 120 | // 失败的回复 |
| 108 | try { | 121 | try { |
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 | @@ -115,16 +115,15 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp | ||
| 115 | continue; | 115 | continue; |
| 116 | } | 116 | } |
| 117 | //by brewswang | 117 | //by brewswang |
| 118 | - if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {//如果包含位置信息,就更新一下位置 | ||
| 119 | - processNotifyMobilePosition(evt, itemDevice); | ||
| 120 | - } | ||
| 121 | - | 118 | +// if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {//如果包含位置信息,就更新一下位置 |
| 119 | +// processNotifyMobilePosition(evt, itemDevice); | ||
| 120 | +// } | ||
| 122 | DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice); | 121 | DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice); |
| 123 | deviceChannel.setDeviceId(device.getDeviceId()); | 122 | deviceChannel.setDeviceId(device.getDeviceId()); |
| 124 | - logger.debug("收到来自设备【{}】的通道: {}【{}】", device.getDeviceId(), deviceChannel.getName(), deviceChannel.getChannelId()); | 123 | + |
| 125 | channelList.add(deviceChannel); | 124 | channelList.add(deviceChannel); |
| 126 | } | 125 | } |
| 127 | - | 126 | + logger.debug("收到来自设备【{}】的通道: {}个,{}/{}", device.getDeviceId(), channelList.size(), catalogDataCatch.get(key) == null ? 0 :catalogDataCatch.get(key).size(), sumNum); |
| 128 | catalogDataCatch.put(key, sumNum, device, channelList); | 127 | catalogDataCatch.put(key, sumNum, device, channelList); |
| 129 | if (catalogDataCatch.get(key).size() == sumNum) { | 128 | if (catalogDataCatch.get(key).size() == sumNum) { |
| 130 | // 数据已经完整接收 | 129 | // 数据已经完整接收 |
| @@ -230,4 +229,9 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp | @@ -230,4 +229,9 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp | ||
| 230 | e.printStackTrace(); | 229 | e.printStackTrace(); |
| 231 | } | 230 | } |
| 232 | } | 231 | } |
| 232 | + | ||
| 233 | + public String getChannelSyncProgress(String deviceId) { | ||
| 234 | + String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId; | ||
| 235 | + return catalogDataCatch.get(key) == null ? "0/0" : catalogDataCatch.get(key).size() + "/" + catalogDataCatch.getTotal(key); | ||
| 236 | + } | ||
| 233 | } | 237 | } |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
| @@ -274,7 +274,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | @@ -274,7 +274,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | ||
| 274 | channels = deviceChannelList; | 274 | channels = deviceChannelList; |
| 275 | } | 275 | } |
| 276 | if (stringBuilder.length() > 0) { | 276 | if (stringBuilder.length() > 0) { |
| 277 | - logger.debug("[目录查询]收到的数据存在重复: {}" , stringBuilder); | 277 | + logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder); |
| 278 | } | 278 | } |
| 279 | try { | 279 | try { |
| 280 | int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels); | 280 | int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels); |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
| @@ -175,22 +175,23 @@ public class DeviceQuery { | @@ -175,22 +175,23 @@ public class DeviceQuery { | ||
| 175 | }); | 175 | }); |
| 176 | // 等待其他相同请求返回时一起返回 | 176 | // 等待其他相同请求返回时一起返回 |
| 177 | if (resultHolder.exist(key, null)) { | 177 | if (resultHolder.exist(key, null)) { |
| 178 | + resultHolder.put(key, uuid, result); | ||
| 179 | + return result; | ||
| 180 | + }else { | ||
| 181 | + cmder.catalogQuery(device, event -> { | ||
| 182 | + RequestMessage msg = new RequestMessage(); | ||
| 183 | + msg.setKey(key); | ||
| 184 | + msg.setId(uuid); | ||
| 185 | + WVPResult<Object> wvpResult = new WVPResult<>(); | ||
| 186 | + wvpResult.setCode(-1); | ||
| 187 | + wvpResult.setData(device); | ||
| 188 | + wvpResult.setMsg(String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg)); | ||
| 189 | + msg.setData(wvpResult); | ||
| 190 | + resultHolder.invokeAllResult(msg); | ||
| 191 | + }); | ||
| 192 | + resultHolder.put(key, uuid, result); | ||
| 178 | return result; | 193 | return result; |
| 179 | } | 194 | } |
| 180 | - cmder.catalogQuery(device, event -> { | ||
| 181 | - RequestMessage msg = new RequestMessage(); | ||
| 182 | - msg.setKey(key); | ||
| 183 | - msg.setId(uuid); | ||
| 184 | - WVPResult<Object> wvpResult = new WVPResult<>(); | ||
| 185 | - wvpResult.setCode(-1); | ||
| 186 | - wvpResult.setData(device); | ||
| 187 | - wvpResult.setMsg(String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg)); | ||
| 188 | - msg.setData(wvpResult); | ||
| 189 | - resultHolder.invokeAllResult(msg); | ||
| 190 | - }); | ||
| 191 | - | ||
| 192 | - resultHolder.put(key, uuid, result); | ||
| 193 | - return result; | ||
| 194 | } | 195 | } |
| 195 | 196 | ||
| 196 | /** | 197 | /** |
web_src/src/components/DeviceList.vue
| @@ -57,7 +57,7 @@ | @@ -57,7 +57,7 @@ | ||
| 57 | 57 | ||
| 58 | <el-table-column label="操作" width="450" align="center" fixed="right"> | 58 | <el-table-column label="操作" width="450" align="center" fixed="right"> |
| 59 | <template slot-scope="scope"> | 59 | <template slot-scope="scope"> |
| 60 | - <el-button size="mini" :loading="scope.row.loading" v-if="scope.row.online!=0" icon="el-icon-refresh" @click="refDevice(scope.row)">刷新</el-button> | 60 | + <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> |
| 61 | <el-button-group> | 61 | <el-button-group> |
| 62 | <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> | 62 | <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> |
| 63 | <el-button size="mini" icon="el-icon-location" v-bind:disabled="scope.row.online==0" type="primary" @click="showDevicePosition(scope.row)">定位</el-button> | 63 | <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 @@ | @@ -104,7 +104,8 @@ | ||
| 104 | currentPage:1, | 104 | currentPage:1, |
| 105 | count:15, | 105 | count:15, |
| 106 | total:0, | 106 | total:0, |
| 107 | - getDeviceListLoading: false | 107 | + getDeviceListLoading: false, |
| 108 | + syncDevices:[] | ||
| 108 | }; | 109 | }; |
| 109 | }, | 110 | }, |
| 110 | computed: { | 111 | computed: { |
| @@ -117,8 +118,6 @@ | @@ -117,8 +118,6 @@ | ||
| 117 | }); | 118 | }); |
| 118 | this.currentDeviceChannelsLenth = channels.length; | 119 | this.currentDeviceChannelsLenth = channels.length; |
| 119 | } | 120 | } |
| 120 | - | ||
| 121 | - console.log("数据:" + JSON.stringify(channels)); | ||
| 122 | return channels; | 121 | return channels; |
| 123 | } | 122 | } |
| 124 | }, | 123 | }, |
| @@ -153,13 +152,11 @@ | @@ -153,13 +152,11 @@ | ||
| 153 | count: that.count | 152 | count: that.count |
| 154 | } | 153 | } |
| 155 | }).then(function (res) { | 154 | }).then(function (res) { |
| 156 | - console.log(res); | ||
| 157 | - console.log(res.data.list); | ||
| 158 | that.total = res.data.total; | 155 | that.total = res.data.total; |
| 159 | that.deviceList = res.data.list; | 156 | that.deviceList = res.data.list; |
| 160 | that.getDeviceListLoading = false; | 157 | that.getDeviceListLoading = false; |
| 161 | }).catch(function (error) { | 158 | }).catch(function (error) { |
| 162 | - console.log(error); | 159 | + console.error(error); |
| 163 | that.getDeviceListLoading = false; | 160 | that.getDeviceListLoading = false; |
| 164 | }); | 161 | }); |
| 165 | 162 | ||
| @@ -182,7 +179,7 @@ | @@ -182,7 +179,7 @@ | ||
| 182 | }).then((res)=>{ | 179 | }).then((res)=>{ |
| 183 | this.getDeviceList(); | 180 | this.getDeviceList(); |
| 184 | }).catch((error) =>{ | 181 | }).catch((error) =>{ |
| 185 | - console.log(error); | 182 | + console.error(error); |
| 186 | }); | 183 | }); |
| 187 | }).catch(() => { | 184 | }).catch(() => { |
| 188 | 185 | ||
| @@ -191,11 +188,9 @@ | @@ -191,11 +188,9 @@ | ||
| 191 | 188 | ||
| 192 | }, | 189 | }, |
| 193 | showChannelList: function(row) { | 190 | showChannelList: function(row) { |
| 194 | - console.log(JSON.stringify(row)) | ||
| 195 | this.$router.push(`/channelList/${row.deviceId}/0/15/1`); | 191 | this.$router.push(`/channelList/${row.deviceId}/0/15/1`); |
| 196 | }, | 192 | }, |
| 197 | showDevicePosition: function(row) { | 193 | showDevicePosition: function(row) { |
| 198 | - console.log(JSON.stringify(row)) | ||
| 199 | this.$router.push(`/devicePosition/${row.deviceId}/0/15/1`); | 194 | this.$router.push(`/devicePosition/${row.deviceId}/0/15/1`); |
| 200 | }, | 195 | }, |
| 201 | 196 | ||
| @@ -204,11 +199,11 @@ | @@ -204,11 +199,11 @@ | ||
| 204 | refDevice: function(itemData) { | 199 | refDevice: function(itemData) { |
| 205 | console.log("刷新对应设备:" + itemData.deviceId); | 200 | console.log("刷新对应设备:" + itemData.deviceId); |
| 206 | var that = this; | 201 | var that = this; |
| 207 | - that.$set(itemData,"loading", true); | 202 | + this.syncDevices.push(itemData.deviceId) |
| 208 | this.$axios({ | 203 | this.$axios({ |
| 209 | method: 'post', | 204 | method: 'post', |
| 210 | url: '/api/device/query/devices/' + itemData.deviceId + '/sync' | 205 | url: '/api/device/query/devices/' + itemData.deviceId + '/sync' |
| 211 | - }).then(function(res) { | 206 | + }).then((res) => { |
| 212 | console.log("刷新设备结果:"+JSON.stringify(res)); | 207 | console.log("刷新设备结果:"+JSON.stringify(res)); |
| 213 | if (res.data.code !==0) { | 208 | if (res.data.code !==0) { |
| 214 | that.$message({ | 209 | that.$message({ |
| @@ -224,15 +219,15 @@ | @@ -224,15 +219,15 @@ | ||
| 224 | }); | 219 | }); |
| 225 | } | 220 | } |
| 226 | that.initData() | 221 | that.initData() |
| 227 | - that.$set(itemData,"loading", true); | ||
| 228 | - }).catch(function(e) { | 222 | + this.syncDevices.splice(this.syncDevices.indexOf(itemData.deviceId, 1)); |
| 223 | + }).catch((e) => { | ||
| 229 | console.error(e) | 224 | console.error(e) |
| 230 | that.$message({ | 225 | that.$message({ |
| 231 | showClose: true, | 226 | showClose: true, |
| 232 | message: e, | 227 | message: e, |
| 233 | type: 'error' | 228 | type: 'error' |
| 234 | }); | 229 | }); |
| 235 | - that.$set(itemData,"loading", true); | 230 | + this.syncDevices.splice(this.syncDevices.indexOf(itemData.deviceId, 1)); |
| 236 | }); | 231 | }); |
| 237 | }, | 232 | }, |
| 238 | //通知设备上传媒体流 | 233 | //通知设备上传媒体流 |
| @@ -251,7 +246,6 @@ | @@ -251,7 +246,6 @@ | ||
| 251 | // }); | 246 | // }); |
| 252 | }, | 247 | }, |
| 253 | transportChange: function (row) { | 248 | transportChange: function (row) { |
| 254 | - console.log(row); | ||
| 255 | console.log(`修改传输方式为 ${row.streamMode}:${row.deviceId} `); | 249 | console.log(`修改传输方式为 ${row.streamMode}:${row.deviceId} `); |
| 256 | let that = this; | 250 | let that = this; |
| 257 | this.$axios({ | 251 | this.$axios({ |
| @@ -263,7 +257,6 @@ | @@ -263,7 +257,6 @@ | ||
| 263 | }); | 257 | }); |
| 264 | }, | 258 | }, |
| 265 | edit: function (row) { | 259 | edit: function (row) { |
| 266 | - console.log(row); | ||
| 267 | this.$refs.deviceEdit.openDialog(row, ()=>{ | 260 | this.$refs.deviceEdit.openDialog(row, ()=>{ |
| 268 | this.$refs.deviceEdit.close(); | 261 | this.$refs.deviceEdit.close(); |
| 269 | this.$message({ | 262 | this.$message({ |