Commit c2e2e24551f4603d2ef01c170de37359cf44afce

Authored by 648540858
1 parent 40fb7947

优化通道刷新

src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
... ... @@ -44,6 +44,12 @@ public class CatalogDataCatch {
44 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 53 public void del(String key) {
48 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 23 import javax.sip.address.SipURI;
24 24 import javax.sip.header.HeaderAddress;
25 25 import javax.sip.header.ToHeader;
  26 +import javax.sip.message.Response;
26 27 import java.text.ParseException;
27 28 import java.util.Iterator;
28 29  
... ... @@ -103,6 +104,18 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
103 104 if (!StringUtils.isEmpty(getText(rootElement,"PTZCmd")) && !parentPlatform.getServerGBId().equals(targetGBId)) {
104 105 String cmdString = getText(rootElement,"PTZCmd");
105 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 119 cmder.fronEndCmd(deviceForPlatform, channelId, cmdString, eventResult -> {
107 120 // 失败的回复
108 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 115 continue;
116 116 }
117 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 121 DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice);
123 122 deviceChannel.setDeviceId(device.getDeviceId());
124   - logger.debug("收到来自设备【{}】的通道: {}【{}】", device.getDeviceId(), deviceChannel.getName(), deviceChannel.getChannelId());
  123 +
125 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 127 catalogDataCatch.put(key, sumNum, device, channelList);
129 128 if (catalogDataCatch.get(key).size() == sumNum) {
130 129 // 数据已经完整接收
... ... @@ -230,4 +229,9 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
230 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 274 channels = deviceChannelList;
275 275 }
276 276 if (stringBuilder.length() > 0) {
277   - logger.debug("[目录查询]收到的数据存在重复: {}" , stringBuilder);
  277 + logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder);
278 278 }
279 279 try {
280 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 175 });
176 176 // 等待其他相同请求返回时一起返回
177 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 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 57  
58 58 <el-table-column label="操作" width="450" align="center" fixed="right">
59 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 61 <el-button-group>
62 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 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 104 currentPage:1,
105 105 count:15,
106 106 total:0,
107   - getDeviceListLoading: false
  107 + getDeviceListLoading: false,
  108 + syncDevices:[]
108 109 };
109 110 },
110 111 computed: {
... ... @@ -117,8 +118,6 @@
117 118 });
118 119 this.currentDeviceChannelsLenth = channels.length;
119 120 }
120   -
121   - console.log("数据:" + JSON.stringify(channels));
122 121 return channels;
123 122 }
124 123 },
... ... @@ -153,13 +152,11 @@
153 152 count: that.count
154 153 }
155 154 }).then(function (res) {
156   - console.log(res);
157   - console.log(res.data.list);
158 155 that.total = res.data.total;
159 156 that.deviceList = res.data.list;
160 157 that.getDeviceListLoading = false;
161 158 }).catch(function (error) {
162   - console.log(error);
  159 + console.error(error);
163 160 that.getDeviceListLoading = false;
164 161 });
165 162  
... ... @@ -182,7 +179,7 @@
182 179 }).then((res)=>{
183 180 this.getDeviceList();
184 181 }).catch((error) =>{
185   - console.log(error);
  182 + console.error(error);
186 183 });
187 184 }).catch(() => {
188 185  
... ... @@ -191,11 +188,9 @@
191 188  
192 189 },
193 190 showChannelList: function(row) {
194   - console.log(JSON.stringify(row))
195 191 this.$router.push(`/channelList/${row.deviceId}/0/15/1`);
196 192 },
197 193 showDevicePosition: function(row) {
198   - console.log(JSON.stringify(row))
199 194 this.$router.push(`/devicePosition/${row.deviceId}/0/15/1`);
200 195 },
201 196  
... ... @@ -204,11 +199,11 @@
204 199 refDevice: function(itemData) {
205 200 console.log("刷新对应设备:" + itemData.deviceId);
206 201 var that = this;
207   - that.$set(itemData,"loading", true);
  202 + this.syncDevices.push(itemData.deviceId)
208 203 this.$axios({
209 204 method: 'post',
210 205 url: '/api/device/query/devices/' + itemData.deviceId + '/sync'
211   - }).then(function(res) {
  206 + }).then((res) => {
212 207 console.log("刷新设备结果:"+JSON.stringify(res));
213 208 if (res.data.code !==0) {
214 209 that.$message({
... ... @@ -224,15 +219,15 @@
224 219 });
225 220 }
226 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 224 console.error(e)
230 225 that.$message({
231 226 showClose: true,
232 227 message: e,
233 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 246 // });
252 247 },
253 248 transportChange: function (row) {
254   - console.log(row);
255 249 console.log(`修改传输方式为 ${row.streamMode}:${row.deviceId} `);
256 250 let that = this;
257 251 this.$axios({
... ... @@ -263,7 +257,6 @@
263 257 });
264 258 },
265 259 edit: function (row) {
266   - console.log(row);
267 260 this.$refs.deviceEdit.openDialog(row, ()=>{
268 261 this.$refs.deviceEdit.close();
269 262 this.$message({
... ...