Commit f99c9cac6afc899c244aa66897cb3bf35a2da7d6
1 parent
726963ba
优化通道更新
Showing
7 changed files
with
141 additions
and
186 deletions
src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java
| ... | ... | @@ -21,7 +21,7 @@ public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoi |
| 21 | 21 | |
| 22 | 22 | @Override |
| 23 | 23 | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) { |
| 24 | - logger.debug("用户需要登录,访问[{}]失败,AuthenticationException=[{}]", request.getRequestURI(), e.getMessage()); | |
| 24 | +// logger.debug("用户需要登录,访问[{}]失败,AuthenticationException=[{}]", request.getRequestURI(), e.getMessage()); | |
| 25 | 25 | // 允许跨域 |
| 26 | 26 | response.setHeader("Access-Control-Allow-Origin", "*"); |
| 27 | 27 | // 允许自定义请求头token(允许head跨域) | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
| ... | ... | @@ -257,7 +257,9 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements |
| 257 | 257 | continue; |
| 258 | 258 | } |
| 259 | 259 | Element eventElement = itemDevice.element("Event"); |
| 260 | - DeviceChannel channel = channelContentHander(itemDevice); | |
| 260 | + DeviceChannel channel = XmlUtil.channelContentHander(itemDevice); | |
| 261 | + channel.setDeviceId(device.getDeviceId()); | |
| 262 | + logger.debug("收到来自设备【{}】的通道: {}【{}】", device.getDeviceId(), channel.getName(), channel.getChannelId()); | |
| 261 | 263 | switch (eventElement.getText().toUpperCase()) { |
| 262 | 264 | case "ON" : // 上线 |
| 263 | 265 | logger.info("收到来自设备【{}】的通道【{}】上线通知", device.getDeviceId(), channel.getChannelId()); |
| ... | ... | @@ -318,93 +320,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements |
| 318 | 320 | } |
| 319 | 321 | } |
| 320 | 322 | |
| 321 | - public DeviceChannel channelContentHander(Element itemDevice){ | |
| 322 | - Element channdelNameElement = itemDevice.element("Name"); | |
| 323 | - String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : ""; | |
| 324 | - Element statusElement = itemDevice.element("Status"); | |
| 325 | - String status = statusElement != null ? statusElement.getTextTrim().toString() : "ON"; | |
| 326 | - DeviceChannel deviceChannel = new DeviceChannel(); | |
| 327 | - deviceChannel.setName(channelName); | |
| 328 | - Element channdelIdElement = itemDevice.element("DeviceID"); | |
| 329 | - String channelId = channdelIdElement != null ? channdelIdElement.getTextTrim().toString() : ""; | |
| 330 | - deviceChannel.setChannelId(channelId); | |
| 331 | - // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理 | |
| 332 | - if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) { | |
| 333 | - deviceChannel.setStatus(1); | |
| 334 | - } | |
| 335 | - if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) { | |
| 336 | - deviceChannel.setStatus(0); | |
| 337 | - } | |
| 338 | - | |
| 339 | - deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer")); | |
| 340 | - deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model")); | |
| 341 | - deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner")); | |
| 342 | - deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode")); | |
| 343 | - deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); | |
| 344 | - deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); | |
| 345 | - if (XmlUtil.getText(itemDevice, "Parental") == null | |
| 346 | - || XmlUtil.getText(itemDevice, "Parental") == "") { | |
| 347 | - deviceChannel.setParental(0); | |
| 348 | - } else { | |
| 349 | - deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental"))); | |
| 350 | - } | |
| 351 | - deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID")); | |
| 352 | - if (XmlUtil.getText(itemDevice, "SafetyWay") == null | |
| 353 | - || XmlUtil.getText(itemDevice, "SafetyWay") == "") { | |
| 354 | - deviceChannel.setSafetyWay(0); | |
| 355 | - } else { | |
| 356 | - deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay"))); | |
| 357 | - } | |
| 358 | - if (XmlUtil.getText(itemDevice, "RegisterWay") == null | |
| 359 | - || XmlUtil.getText(itemDevice, "RegisterWay") == "") { | |
| 360 | - deviceChannel.setRegisterWay(1); | |
| 361 | - } else { | |
| 362 | - deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay"))); | |
| 363 | - } | |
| 364 | - deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum")); | |
| 365 | - if (XmlUtil.getText(itemDevice, "Certifiable") == null | |
| 366 | - || XmlUtil.getText(itemDevice, "Certifiable") == "") { | |
| 367 | - deviceChannel.setCertifiable(0); | |
| 368 | - } else { | |
| 369 | - deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable"))); | |
| 370 | - } | |
| 371 | - if (XmlUtil.getText(itemDevice, "ErrCode") == null | |
| 372 | - || XmlUtil.getText(itemDevice, "ErrCode") == "") { | |
| 373 | - deviceChannel.setErrCode(0); | |
| 374 | - } else { | |
| 375 | - deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode"))); | |
| 376 | - } | |
| 377 | - deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime")); | |
| 378 | - deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy")); | |
| 379 | - deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress")); | |
| 380 | - if (XmlUtil.getText(itemDevice, "Port") == null || XmlUtil.getText(itemDevice, "Port") == "") { | |
| 381 | - deviceChannel.setPort(0); | |
| 382 | - } else { | |
| 383 | - deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port"))); | |
| 384 | - } | |
| 385 | - deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password")); | |
| 386 | - if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) { | |
| 387 | - deviceChannel.setLongitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Longitude"))); | |
| 388 | - } else { | |
| 389 | - deviceChannel.setLongitude(0.00); | |
| 390 | - } | |
| 391 | - if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Latitude"))) { | |
| 392 | - deviceChannel.setLatitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Latitude"))); | |
| 393 | - } else { | |
| 394 | - deviceChannel.setLatitude(0.00); | |
| 395 | - } | |
| 396 | - if (XmlUtil.getText(itemDevice, "PTZType") == null | |
| 397 | - || XmlUtil.getText(itemDevice, "PTZType") == "") { | |
| 398 | - deviceChannel.setPTZType(0); | |
| 399 | - } else { | |
| 400 | - deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); | |
| 401 | - } | |
| 402 | - deviceChannel.setHasAudio(true); // 默认含有音频,播放时再检查是否有音频及是否AAC | |
| 403 | - return deviceChannel; | |
| 404 | - } | |
| 405 | - | |
| 406 | - | |
| 407 | - | |
| 408 | 323 | public void setCmder(SIPCommander cmder) { |
| 409 | 324 | } |
| 410 | 325 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java
| ... | ... | @@ -14,6 +14,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP |
| 14 | 14 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| 15 | 15 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; |
| 16 | 16 | import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; |
| 17 | +import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; | |
| 17 | 18 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 18 | 19 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 19 | 20 | import org.dom4j.DocumentException; |
| ... | ... | @@ -90,88 +91,14 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp |
| 90 | 91 | // 遍历DeviceList |
| 91 | 92 | while (deviceListIterator.hasNext()) { |
| 92 | 93 | Element itemDevice = deviceListIterator.next(); |
| 94 | + | |
| 93 | 95 | Element channelDeviceElement = itemDevice.element("DeviceID"); |
| 94 | 96 | if (channelDeviceElement == null) { |
| 95 | 97 | continue; |
| 96 | 98 | } |
| 97 | - String channelDeviceId = channelDeviceElement.getText(); | |
| 98 | - Element channdelNameElement = itemDevice.element("Name"); | |
| 99 | - String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : ""; | |
| 100 | - Element statusElement = itemDevice.element("Status"); | |
| 101 | - String status = statusElement != null ? statusElement.getText().toString() : "ON"; | |
| 102 | - DeviceChannel deviceChannel = new DeviceChannel(); | |
| 103 | - deviceChannel.setName(channelName); | |
| 99 | + DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice); | |
| 104 | 100 | deviceChannel.setDeviceId(device.getDeviceId()); |
| 105 | - String now = this.format.format(new Date(System.currentTimeMillis())); | |
| 106 | - deviceChannel.setCreateTime(now); | |
| 107 | - deviceChannel.setUpdateTime(now); | |
| 108 | - deviceChannel.setChannelId(channelDeviceId); | |
| 109 | - // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理 | |
| 110 | - if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) { | |
| 111 | - deviceChannel.setStatus(1); | |
| 112 | - } | |
| 113 | - if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) { | |
| 114 | - deviceChannel.setStatus(0); | |
| 115 | - } | |
| 116 | - | |
| 117 | - deviceChannel.setManufacture(getText(itemDevice, "Manufacturer")); | |
| 118 | - deviceChannel.setModel(getText(itemDevice, "Model")); | |
| 119 | - deviceChannel.setOwner(getText(itemDevice, "Owner")); | |
| 120 | - deviceChannel.setCivilCode(getText(itemDevice, "CivilCode")); | |
| 121 | - deviceChannel.setBlock(getText(itemDevice, "Block")); | |
| 122 | - deviceChannel.setAddress(getText(itemDevice, "Address")); | |
| 123 | - if (getText(itemDevice, "Parental") == null || getText(itemDevice, "Parental") == "") { | |
| 124 | - deviceChannel.setParental(0); | |
| 125 | - } else { | |
| 126 | - deviceChannel.setParental(Integer.parseInt(getText(itemDevice, "Parental"))); | |
| 127 | - } | |
| 128 | - deviceChannel.setParentId(getText(itemDevice, "ParentID")); | |
| 129 | - if (getText(itemDevice, "SafetyWay") == null || getText(itemDevice, "SafetyWay") == "") { | |
| 130 | - deviceChannel.setSafetyWay(0); | |
| 131 | - } else { | |
| 132 | - deviceChannel.setSafetyWay(Integer.parseInt(getText(itemDevice, "SafetyWay"))); | |
| 133 | - } | |
| 134 | - if (getText(itemDevice, "RegisterWay") == null || getText(itemDevice, "RegisterWay") == "") { | |
| 135 | - deviceChannel.setRegisterWay(1); | |
| 136 | - } else { | |
| 137 | - deviceChannel.setRegisterWay(Integer.parseInt(getText(itemDevice, "RegisterWay"))); | |
| 138 | - } | |
| 139 | - deviceChannel.setCertNum(getText(itemDevice, "CertNum")); | |
| 140 | - if (getText(itemDevice, "Certifiable") == null || getText(itemDevice, "Certifiable") == "") { | |
| 141 | - deviceChannel.setCertifiable(0); | |
| 142 | - } else { | |
| 143 | - deviceChannel.setCertifiable(Integer.parseInt(getText(itemDevice, "Certifiable"))); | |
| 144 | - } | |
| 145 | - if (getText(itemDevice, "ErrCode") == null || getText(itemDevice, "ErrCode") == "") { | |
| 146 | - deviceChannel.setErrCode(0); | |
| 147 | - } else { | |
| 148 | - deviceChannel.setErrCode(Integer.parseInt(getText(itemDevice, "ErrCode"))); | |
| 149 | - } | |
| 150 | - deviceChannel.setEndTime(getText(itemDevice, "EndTime")); | |
| 151 | - deviceChannel.setSecrecy(getText(itemDevice, "Secrecy")); | |
| 152 | - deviceChannel.setIpAddress(getText(itemDevice, "IPAddress")); | |
| 153 | - if (getText(itemDevice, "Port") == null || getText(itemDevice, "Port") == "") { | |
| 154 | - deviceChannel.setPort(0); | |
| 155 | - } else { | |
| 156 | - deviceChannel.setPort(Integer.parseInt(getText(itemDevice, "Port"))); | |
| 157 | - } | |
| 158 | - deviceChannel.setPassword(getText(itemDevice, "Password")); | |
| 159 | - if (NumericUtil.isDouble(getText(itemDevice, "Longitude"))) { | |
| 160 | - deviceChannel.setLongitude(Double.parseDouble(getText(itemDevice, "Longitude"))); | |
| 161 | - } else { | |
| 162 | - deviceChannel.setLongitude(0.00); | |
| 163 | - } | |
| 164 | - if (NumericUtil.isDouble(getText(itemDevice, "Latitude"))) { | |
| 165 | - deviceChannel.setLatitude(Double.parseDouble(getText(itemDevice, "Latitude"))); | |
| 166 | - } else { | |
| 167 | - deviceChannel.setLatitude(0.00); | |
| 168 | - } | |
| 169 | - if (getText(itemDevice, "PTZType") == null || getText(itemDevice, "PTZType") == "") { | |
| 170 | - deviceChannel.setPTZType(0); | |
| 171 | - } else { | |
| 172 | - deviceChannel.setPTZType(Integer.parseInt(getText(itemDevice, "PTZType"))); | |
| 173 | - } | |
| 174 | - deviceChannel.setHasAudio(true); // 默认含有音频,播放时再检查是否有音频及是否AAC | |
| 101 | + logger.debug("收到来自设备【{}】的通道: {}【{}】", device.getDeviceId(), deviceChannel.getName(), deviceChannel.getChannelId()); | |
| 175 | 102 | channelList.add(deviceChannel); |
| 176 | 103 | } |
| 177 | 104 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java
| ... | ... | @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.utils; |
| 2 | 2 | |
| 3 | 3 | import com.alibaba.fastjson.JSONArray; |
| 4 | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | |
| 5 | 6 | import org.dom4j.Attribute; |
| 6 | 7 | import org.dom4j.Document; |
| 7 | 8 | import org.dom4j.DocumentException; |
| ... | ... | @@ -178,4 +179,89 @@ public class XmlUtil { |
| 178 | 179 | Document xml = reader.read(new ByteArrayInputStream(content)); |
| 179 | 180 | return xml.getRootElement(); |
| 180 | 181 | } |
| 182 | + | |
| 183 | + public static DeviceChannel channelContentHander(Element itemDevice){ | |
| 184 | + Element channdelNameElement = itemDevice.element("Name"); | |
| 185 | + String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : ""; | |
| 186 | + Element statusElement = itemDevice.element("Status"); | |
| 187 | + String status = statusElement != null ? statusElement.getTextTrim().toString() : "ON"; | |
| 188 | + DeviceChannel deviceChannel = new DeviceChannel(); | |
| 189 | + deviceChannel.setName(channelName); | |
| 190 | + Element channdelIdElement = itemDevice.element("DeviceID"); | |
| 191 | + String channelId = channdelIdElement != null ? channdelIdElement.getTextTrim().toString() : ""; | |
| 192 | + deviceChannel.setChannelId(channelId); | |
| 193 | + // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理 | |
| 194 | + if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) { | |
| 195 | + deviceChannel.setStatus(1); | |
| 196 | + } | |
| 197 | + if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) { | |
| 198 | + deviceChannel.setStatus(0); | |
| 199 | + } | |
| 200 | + | |
| 201 | + deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer")); | |
| 202 | + deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model")); | |
| 203 | + deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner")); | |
| 204 | + deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode")); | |
| 205 | + deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); | |
| 206 | + deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); | |
| 207 | + if (XmlUtil.getText(itemDevice, "Parental") == null | |
| 208 | + || XmlUtil.getText(itemDevice, "Parental") == "") { | |
| 209 | + deviceChannel.setParental(0); | |
| 210 | + } else { | |
| 211 | + deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental"))); | |
| 212 | + } | |
| 213 | + deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID")); | |
| 214 | + if (XmlUtil.getText(itemDevice, "SafetyWay") == null | |
| 215 | + || XmlUtil.getText(itemDevice, "SafetyWay") == "") { | |
| 216 | + deviceChannel.setSafetyWay(0); | |
| 217 | + } else { | |
| 218 | + deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay"))); | |
| 219 | + } | |
| 220 | + if (XmlUtil.getText(itemDevice, "RegisterWay") == null | |
| 221 | + || XmlUtil.getText(itemDevice, "RegisterWay") == "") { | |
| 222 | + deviceChannel.setRegisterWay(1); | |
| 223 | + } else { | |
| 224 | + deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay"))); | |
| 225 | + } | |
| 226 | + deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum")); | |
| 227 | + if (XmlUtil.getText(itemDevice, "Certifiable") == null | |
| 228 | + || XmlUtil.getText(itemDevice, "Certifiable") == "") { | |
| 229 | + deviceChannel.setCertifiable(0); | |
| 230 | + } else { | |
| 231 | + deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable"))); | |
| 232 | + } | |
| 233 | + if (XmlUtil.getText(itemDevice, "ErrCode") == null | |
| 234 | + || XmlUtil.getText(itemDevice, "ErrCode") == "") { | |
| 235 | + deviceChannel.setErrCode(0); | |
| 236 | + } else { | |
| 237 | + deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode"))); | |
| 238 | + } | |
| 239 | + deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime")); | |
| 240 | + deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy")); | |
| 241 | + deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress")); | |
| 242 | + if (XmlUtil.getText(itemDevice, "Port") == null || XmlUtil.getText(itemDevice, "Port") == "") { | |
| 243 | + deviceChannel.setPort(0); | |
| 244 | + } else { | |
| 245 | + deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port"))); | |
| 246 | + } | |
| 247 | + deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password")); | |
| 248 | + if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) { | |
| 249 | + deviceChannel.setLongitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Longitude"))); | |
| 250 | + } else { | |
| 251 | + deviceChannel.setLongitude(0.00); | |
| 252 | + } | |
| 253 | + if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Latitude"))) { | |
| 254 | + deviceChannel.setLatitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Latitude"))); | |
| 255 | + } else { | |
| 256 | + deviceChannel.setLatitude(0.00); | |
| 257 | + } | |
| 258 | + if (XmlUtil.getText(itemDevice, "PTZType") == null | |
| 259 | + || XmlUtil.getText(itemDevice, "PTZType") == "") { | |
| 260 | + deviceChannel.setPTZType(0); | |
| 261 | + } else { | |
| 262 | + deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); | |
| 263 | + } | |
| 264 | + deviceChannel.setHasAudio(true); // 默认含有音频,播放时再检查是否有音频及是否AAC | |
| 265 | + return deviceChannel; | |
| 266 | + } | |
| 181 | 267 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
| ... | ... | @@ -23,10 +23,7 @@ import org.springframework.transaction.annotation.Transactional; |
| 23 | 23 | import org.springframework.util.StringUtils; |
| 24 | 24 | |
| 25 | 25 | import java.text.SimpleDateFormat; |
| 26 | -import java.util.ArrayList; | |
| 27 | -import java.util.HashMap; | |
| 28 | -import java.util.List; | |
| 29 | -import java.util.Map; | |
| 26 | +import java.util.*; | |
| 30 | 27 | |
| 31 | 28 | /** |
| 32 | 29 | * @description:视频设备数据存储-jdbc实现 |
| ... | ... | @@ -223,21 +220,41 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { |
| 223 | 220 | @Override |
| 224 | 221 | public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) { |
| 225 | 222 | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| 223 | + // 数据去重 | |
| 224 | + List<DeviceChannel> channels = new ArrayList<>(); | |
| 225 | + StringBuilder stringBuilder = new StringBuilder(); | |
| 226 | + if (deviceChannelList.size() > 1) { | |
| 227 | + // 数据去重 | |
| 228 | + Set<String> gbIdSet = new HashSet<>(); | |
| 229 | + for (DeviceChannel deviceChannel : deviceChannelList) { | |
| 230 | + if (!gbIdSet.contains(deviceChannel.getChannelId())) { | |
| 231 | + gbIdSet.add(deviceChannel.getChannelId()); | |
| 232 | + channels.add(deviceChannel); | |
| 233 | + }else { | |
| 234 | + stringBuilder.append(deviceChannel.getChannelId() + ","); | |
| 235 | + } | |
| 236 | + } | |
| 237 | + }else { | |
| 238 | + channels = deviceChannelList; | |
| 239 | + } | |
| 240 | + if (stringBuilder.length() > 0) { | |
| 241 | + logger.debug("[目录查询]收到的数据存在重复: {}" , stringBuilder); | |
| 242 | + } | |
| 226 | 243 | try { |
| 227 | 244 | int cleanChannelsResult = deviceChannelMapper.cleanChannelsByDeviceId(deviceId); |
| 228 | - int limitCount = 300; | |
| 229 | - boolean result = cleanChannelsResult <0; | |
| 230 | - if (!result && deviceChannelList.size() > 0) { | |
| 231 | - if (deviceChannelList.size() > limitCount) { | |
| 232 | - for (int i = 0; i < deviceChannelList.size(); i += limitCount) { | |
| 245 | + int limitCount = 1; | |
| 246 | + boolean result = cleanChannelsResult < 0; | |
| 247 | + if (!result && channels.size() > 0) { | |
| 248 | + if (channels.size() > limitCount) { | |
| 249 | + for (int i = 0; i < channels.size(); i += limitCount) { | |
| 233 | 250 | int toIndex = i + limitCount; |
| 234 | - if (i + limitCount > deviceChannelList.size()) { | |
| 235 | - toIndex = deviceChannelList.size(); | |
| 251 | + if (i + limitCount > channels.size()) { | |
| 252 | + toIndex = channels.size(); | |
| 236 | 253 | } |
| 237 | - result = result || deviceChannelMapper.batchAdd(deviceChannelList.subList(i, toIndex)) < 0; | |
| 254 | + result = result || deviceChannelMapper.batchAdd(channels.subList(i, toIndex)) < 0; | |
| 238 | 255 | } |
| 239 | 256 | }else { |
| 240 | - result = result || deviceChannelMapper.batchAdd(deviceChannelList) < 0; | |
| 257 | + result = result || deviceChannelMapper.batchAdd(channels) < 0; | |
| 241 | 258 | } |
| 242 | 259 | } |
| 243 | 260 | if (result) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
| ... | ... | @@ -150,15 +150,18 @@ public class DeviceQuery { |
| 150 | 150 | Device device = storager.queryVideoDevice(deviceId); |
| 151 | 151 | String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId; |
| 152 | 152 | String uuid = UUID.randomUUID().toString(); |
| 153 | - DeferredResult<ResponseEntity<Device>> result = new DeferredResult<ResponseEntity<Device>>(15*1000L); | |
| 153 | + // 默认超时时间为30分钟 | |
| 154 | + DeferredResult<ResponseEntity<Device>> result = new DeferredResult<ResponseEntity<Device>>(30*60*1000L); | |
| 154 | 155 | result.onTimeout(()->{ |
| 155 | 156 | logger.warn(String.format("设备通道信息同步超时")); |
| 156 | - // 释放rtpserver | |
| 157 | 157 | RequestMessage msg = new RequestMessage(); |
| 158 | 158 | msg.setKey(key); |
| 159 | - msg.setId(uuid); | |
| 160 | - msg.setData("Timeout"); | |
| 159 | + WVPResult<Object> wvpResult = new WVPResult<>(); | |
| 160 | + wvpResult.setCode(0); | |
| 161 | + wvpResult.setMsg("Timeout"); | |
| 162 | + msg.setData(wvpResult); | |
| 161 | 163 | resultHolder.invokeAllResult(msg); |
| 164 | + | |
| 162 | 165 | }); |
| 163 | 166 | // 等待其他相同请求返回时一起返回 |
| 164 | 167 | if (resultHolder.exist(key, null)) { |
| ... | ... | @@ -167,8 +170,10 @@ public class DeviceQuery { |
| 167 | 170 | cmder.catalogQuery(device, event -> { |
| 168 | 171 | RequestMessage msg = new RequestMessage(); |
| 169 | 172 | msg.setKey(key); |
| 170 | - msg.setId(uuid); | |
| 171 | - msg.setData(String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg)); | |
| 173 | + WVPResult<Object> wvpResult = new WVPResult<>(); | |
| 174 | + wvpResult.setCode(0); | |
| 175 | + wvpResult.setMsg(String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg)); | |
| 176 | + msg.setData(wvpResult); | |
| 172 | 177 | resultHolder.invokeAllResult(msg); |
| 173 | 178 | }); |
| 174 | 179 | ... | ... |
web_src/src/components/DeviceList.vue
| ... | ... | @@ -213,8 +213,13 @@ |
| 213 | 213 | that.$refs[itemData.deviceId + 'refbtn' ].loading = false; |
| 214 | 214 | }).catch(function(e) { |
| 215 | 215 | console.error(e) |
| 216 | + that.$message({ | |
| 217 | + showClose: true, | |
| 218 | + message: e, | |
| 219 | + type: 'error' | |
| 220 | + }); | |
| 216 | 221 | that.$refs[itemData.deviceId + 'refbtn' ].loading = false; |
| 217 | - });; | |
| 222 | + }); | |
| 218 | 223 | }, |
| 219 | 224 | //通知设备上传媒体流 |
| 220 | 225 | sendDevicePush: function(itemData) { | ... | ... |