Commit 36fda97ebba23425e859ea87ada5beb8687349c1
Committed by
Gitee
!5 优化通道更新逻辑以及添加去重保证数据存入
Merge pull request !5 from panll/temp2
Showing
7 changed files
with
131 additions
and
181 deletions
src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java
| @@ -21,7 +21,7 @@ public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoi | @@ -21,7 +21,7 @@ public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoi | ||
| 21 | 21 | ||
| 22 | @Override | 22 | @Override |
| 23 | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) { | 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 | response.setHeader("Access-Control-Allow-Origin", "*"); | 26 | response.setHeader("Access-Control-Allow-Origin", "*"); |
| 27 | // 允许自定义请求头token(允许head跨域) | 27 | // 允许自定义请求头token(允许head跨域) |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
| @@ -255,7 +255,9 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | @@ -255,7 +255,9 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | ||
| 255 | continue; | 255 | continue; |
| 256 | } | 256 | } |
| 257 | Element eventElement = itemDevice.element("Event"); | 257 | Element eventElement = itemDevice.element("Event"); |
| 258 | - DeviceChannel channel = channelContentHander(itemDevice); | 258 | + DeviceChannel channel = XmlUtil.channelContentHander(itemDevice); |
| 259 | + channel.setDeviceId(device.getDeviceId()); | ||
| 260 | + logger.debug("收到来自设备【{}】的通道: {}【{}】", device.getDeviceId(), channel.getName(), channel.getChannelId()); | ||
| 259 | switch (eventElement.getText().toUpperCase()) { | 261 | switch (eventElement.getText().toUpperCase()) { |
| 260 | case "ON" : // 上线 | 262 | case "ON" : // 上线 |
| 261 | logger.info("收到来自设备【{}】的通道【{}】上线通知", device.getDeviceId(), channel.getChannelId()); | 263 | logger.info("收到来自设备【{}】的通道【{}】上线通知", device.getDeviceId(), channel.getChannelId()); |
| @@ -316,93 +318,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | @@ -316,93 +318,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | ||
| 316 | } | 318 | } |
| 317 | } | 319 | } |
| 318 | 320 | ||
| 319 | - public DeviceChannel channelContentHander(Element itemDevice){ | ||
| 320 | - Element channdelNameElement = itemDevice.element("Name"); | ||
| 321 | - String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : ""; | ||
| 322 | - Element statusElement = itemDevice.element("Status"); | ||
| 323 | - String status = statusElement != null ? statusElement.getTextTrim().toString() : "ON"; | ||
| 324 | - DeviceChannel deviceChannel = new DeviceChannel(); | ||
| 325 | - deviceChannel.setName(channelName); | ||
| 326 | - Element channdelIdElement = itemDevice.element("DeviceID"); | ||
| 327 | - String channelId = channdelIdElement != null ? channdelIdElement.getTextTrim().toString() : ""; | ||
| 328 | - deviceChannel.setChannelId(channelId); | ||
| 329 | - // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理 | ||
| 330 | - if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) { | ||
| 331 | - deviceChannel.setStatus(1); | ||
| 332 | - } | ||
| 333 | - if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) { | ||
| 334 | - deviceChannel.setStatus(0); | ||
| 335 | - } | ||
| 336 | - | ||
| 337 | - deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer")); | ||
| 338 | - deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model")); | ||
| 339 | - deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner")); | ||
| 340 | - deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode")); | ||
| 341 | - deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); | ||
| 342 | - deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); | ||
| 343 | - if (XmlUtil.getText(itemDevice, "Parental") == null | ||
| 344 | - || XmlUtil.getText(itemDevice, "Parental") == "") { | ||
| 345 | - deviceChannel.setParental(0); | ||
| 346 | - } else { | ||
| 347 | - deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental"))); | ||
| 348 | - } | ||
| 349 | - deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID")); | ||
| 350 | - if (XmlUtil.getText(itemDevice, "SafetyWay") == null | ||
| 351 | - || XmlUtil.getText(itemDevice, "SafetyWay") == "") { | ||
| 352 | - deviceChannel.setSafetyWay(0); | ||
| 353 | - } else { | ||
| 354 | - deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay"))); | ||
| 355 | - } | ||
| 356 | - if (XmlUtil.getText(itemDevice, "RegisterWay") == null | ||
| 357 | - || XmlUtil.getText(itemDevice, "RegisterWay") == "") { | ||
| 358 | - deviceChannel.setRegisterWay(1); | ||
| 359 | - } else { | ||
| 360 | - deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay"))); | ||
| 361 | - } | ||
| 362 | - deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum")); | ||
| 363 | - if (XmlUtil.getText(itemDevice, "Certifiable") == null | ||
| 364 | - || XmlUtil.getText(itemDevice, "Certifiable") == "") { | ||
| 365 | - deviceChannel.setCertifiable(0); | ||
| 366 | - } else { | ||
| 367 | - deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable"))); | ||
| 368 | - } | ||
| 369 | - if (XmlUtil.getText(itemDevice, "ErrCode") == null | ||
| 370 | - || XmlUtil.getText(itemDevice, "ErrCode") == "") { | ||
| 371 | - deviceChannel.setErrCode(0); | ||
| 372 | - } else { | ||
| 373 | - deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode"))); | ||
| 374 | - } | ||
| 375 | - deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime")); | ||
| 376 | - deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy")); | ||
| 377 | - deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress")); | ||
| 378 | - if (XmlUtil.getText(itemDevice, "Port") == null || XmlUtil.getText(itemDevice, "Port") == "") { | ||
| 379 | - deviceChannel.setPort(0); | ||
| 380 | - } else { | ||
| 381 | - deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port"))); | ||
| 382 | - } | ||
| 383 | - deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password")); | ||
| 384 | - if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) { | ||
| 385 | - deviceChannel.setLongitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Longitude"))); | ||
| 386 | - } else { | ||
| 387 | - deviceChannel.setLongitude(0.00); | ||
| 388 | - } | ||
| 389 | - if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Latitude"))) { | ||
| 390 | - deviceChannel.setLatitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Latitude"))); | ||
| 391 | - } else { | ||
| 392 | - deviceChannel.setLatitude(0.00); | ||
| 393 | - } | ||
| 394 | - if (XmlUtil.getText(itemDevice, "PTZType") == null | ||
| 395 | - || XmlUtil.getText(itemDevice, "PTZType") == "") { | ||
| 396 | - deviceChannel.setPTZType(0); | ||
| 397 | - } else { | ||
| 398 | - deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); | ||
| 399 | - } | ||
| 400 | - deviceChannel.setHasAudio(true); // 默认含有音频,播放时再检查是否有音频及是否AAC | ||
| 401 | - return deviceChannel; | ||
| 402 | - } | ||
| 403 | - | ||
| 404 | - | ||
| 405 | - | ||
| 406 | public void setCmder(SIPCommander cmder) { | 321 | public void setCmder(SIPCommander cmder) { |
| 407 | } | 322 | } |
| 408 | 323 |
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,6 +14,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP | ||
| 14 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; | 14 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| 15 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; | 15 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; |
| 16 | import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; | 16 | import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; |
| 17 | +import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; | ||
| 17 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | 18 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 18 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | 19 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 19 | import org.dom4j.DocumentException; | 20 | import org.dom4j.DocumentException; |
| @@ -94,85 +95,9 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp | @@ -94,85 +95,9 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp | ||
| 94 | if (channelDeviceElement == null) { | 95 | if (channelDeviceElement == null) { |
| 95 | continue; | 96 | continue; |
| 96 | } | 97 | } |
| 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); | 98 | + DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice); |
| 104 | deviceChannel.setDeviceId(device.getDeviceId()); | 99 | 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 | - Element InfoNode = channelDeviceElement.element("Info"); | ||
| 170 | - if (getText(InfoNode, "PTZType") == null || getText(InfoNode, "PTZType") == "") { | ||
| 171 | - deviceChannel.setPTZType(0); | ||
| 172 | - } else { | ||
| 173 | - deviceChannel.setPTZType(Integer.parseInt(getText(InfoNode, "PTZType"))); | ||
| 174 | - } | ||
| 175 | - deviceChannel.setHasAudio(true); // 默认含有音频,播放时再检查是否有音频及是否AAC | 100 | + logger.debug("收到来自设备【{}】的通道: {}【{}】", device.getDeviceId(), deviceChannel.getName(), deviceChannel.getChannelId()); |
| 176 | channelList.add(deviceChannel); | 101 | channelList.add(deviceChannel); |
| 177 | } | 102 | } |
| 178 | 103 |
src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java
| @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.utils; | @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.utils; | ||
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSONArray; | 3 | import com.alibaba.fastjson.JSONArray; |
| 4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | ||
| 5 | import org.dom4j.Attribute; | 6 | import org.dom4j.Attribute; |
| 6 | import org.dom4j.Document; | 7 | import org.dom4j.Document; |
| 7 | import org.dom4j.DocumentException; | 8 | import org.dom4j.DocumentException; |
| @@ -178,4 +179,89 @@ public class XmlUtil { | @@ -178,4 +179,89 @@ public class XmlUtil { | ||
| 178 | Document xml = reader.read(new ByteArrayInputStream(content)); | 179 | Document xml = reader.read(new ByteArrayInputStream(content)); |
| 179 | return xml.getRootElement(); | 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
| @@ -24,10 +24,7 @@ import org.springframework.transaction.annotation.Transactional; | @@ -24,10 +24,7 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 24 | import org.springframework.util.StringUtils; | 24 | import org.springframework.util.StringUtils; |
| 25 | 25 | ||
| 26 | import java.text.SimpleDateFormat; | 26 | import java.text.SimpleDateFormat; |
| 27 | -import java.util.ArrayList; | ||
| 28 | -import java.util.HashMap; | ||
| 29 | -import java.util.List; | ||
| 30 | -import java.util.Map; | 27 | +import java.util.*; |
| 31 | 28 | ||
| 32 | /** | 29 | /** |
| 33 | * @description:视频设备数据存储-jdbc实现 | 30 | * @description:视频设备数据存储-jdbc实现 |
| @@ -227,21 +224,41 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { | @@ -227,21 +224,41 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { | ||
| 227 | @Override | 224 | @Override |
| 228 | public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) { | 225 | public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) { |
| 229 | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); | 226 | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| 227 | + // 数据去重 | ||
| 228 | + List<DeviceChannel> channels = new ArrayList<>(); | ||
| 229 | + StringBuilder stringBuilder = new StringBuilder(); | ||
| 230 | + if (deviceChannelList.size() > 1) { | ||
| 231 | + // 数据去重 | ||
| 232 | + Set<String> gbIdSet = new HashSet<>(); | ||
| 233 | + for (DeviceChannel deviceChannel : deviceChannelList) { | ||
| 234 | + if (!gbIdSet.contains(deviceChannel.getChannelId())) { | ||
| 235 | + gbIdSet.add(deviceChannel.getChannelId()); | ||
| 236 | + channels.add(deviceChannel); | ||
| 237 | + }else { | ||
| 238 | + stringBuilder.append(deviceChannel.getChannelId() + ","); | ||
| 239 | + } | ||
| 240 | + } | ||
| 241 | + }else { | ||
| 242 | + channels = deviceChannelList; | ||
| 243 | + } | ||
| 244 | + if (stringBuilder.length() > 0) { | ||
| 245 | + logger.debug("[目录查询]收到的数据存在重复: {}" , stringBuilder); | ||
| 246 | + } | ||
| 230 | try { | 247 | try { |
| 231 | int cleanChannelsResult = deviceChannelMapper.cleanChannelsByDeviceId(deviceId); | 248 | int cleanChannelsResult = deviceChannelMapper.cleanChannelsByDeviceId(deviceId); |
| 232 | int limitCount = 300; | 249 | int limitCount = 300; |
| 233 | - boolean result = cleanChannelsResult <0; | ||
| 234 | - if (!result && deviceChannelList.size() > 0) { | ||
| 235 | - if (deviceChannelList.size() > limitCount) { | ||
| 236 | - for (int i = 0; i < deviceChannelList.size(); i += limitCount) { | 250 | + boolean result = cleanChannelsResult < 0; |
| 251 | + if (!result && channels.size() > 0) { | ||
| 252 | + if (channels.size() > limitCount) { | ||
| 253 | + for (int i = 0; i < channels.size(); i += limitCount) { | ||
| 237 | int toIndex = i + limitCount; | 254 | int toIndex = i + limitCount; |
| 238 | - if (i + limitCount > deviceChannelList.size()) { | ||
| 239 | - toIndex = deviceChannelList.size(); | 255 | + if (i + limitCount > channels.size()) { |
| 256 | + toIndex = channels.size(); | ||
| 240 | } | 257 | } |
| 241 | - result = result || deviceChannelMapper.batchAdd(deviceChannelList.subList(i, toIndex)) < 0; | 258 | + result = result || deviceChannelMapper.batchAdd(channels.subList(i, toIndex)) < 0; |
| 242 | } | 259 | } |
| 243 | }else { | 260 | }else { |
| 244 | - result = result || deviceChannelMapper.batchAdd(deviceChannelList) < 0; | 261 | + result = result || deviceChannelMapper.batchAdd(channels) < 0; |
| 245 | } | 262 | } |
| 246 | } | 263 | } |
| 247 | if (result) { | 264 | if (result) { |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
| @@ -150,7 +150,8 @@ public class DeviceQuery { | @@ -150,7 +150,8 @@ public class DeviceQuery { | ||
| 150 | Device device = storager.queryVideoDevice(deviceId); | 150 | Device device = storager.queryVideoDevice(deviceId); |
| 151 | String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId; | 151 | String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId; |
| 152 | String uuid = UUID.randomUUID().toString(); | 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 | result.onTimeout(()->{ | 155 | result.onTimeout(()->{ |
| 155 | logger.warn("设备[{}]通道信息同步超时", deviceId); | 156 | logger.warn("设备[{}]通道信息同步超时", deviceId); |
| 156 | // 释放rtpserver | 157 | // 释放rtpserver |
| @@ -163,6 +164,7 @@ public class DeviceQuery { | @@ -163,6 +164,7 @@ public class DeviceQuery { | ||
| 163 | wvpResult.setMsg("更新超时"); | 164 | wvpResult.setMsg("更新超时"); |
| 164 | msg.setData(wvpResult); | 165 | msg.setData(wvpResult); |
| 165 | resultHolder.invokeAllResult(msg); | 166 | resultHolder.invokeAllResult(msg); |
| 167 | + | ||
| 166 | }); | 168 | }); |
| 167 | // 等待其他相同请求返回时一起返回 | 169 | // 等待其他相同请求返回时一起返回 |
| 168 | if (resultHolder.exist(key, null)) { | 170 | if (resultHolder.exist(key, null)) { |
web_src/src/components/DeviceList.vue
| @@ -213,8 +213,13 @@ | @@ -213,8 +213,13 @@ | ||
| 213 | that.$refs[itemData.deviceId + 'refbtn' ].loading = false; | 213 | that.$refs[itemData.deviceId + 'refbtn' ].loading = false; |
| 214 | }).catch(function(e) { | 214 | }).catch(function(e) { |
| 215 | console.error(e) | 215 | console.error(e) |
| 216 | + that.$message({ | ||
| 217 | + showClose: true, | ||
| 218 | + message: e, | ||
| 219 | + type: 'error' | ||
| 220 | + }); | ||
| 216 | that.$refs[itemData.deviceId + 'refbtn' ].loading = false; | 221 | that.$refs[itemData.deviceId + 'refbtn' ].loading = false; |
| 217 | - });; | 222 | + }); |
| 218 | }, | 223 | }, |
| 219 | //通知设备上传媒体流 | 224 | //通知设备上传媒体流 |
| 220 | sendDevicePush: function(itemData) { | 225 | sendDevicePush: function(itemData) { |