Commit b5fb82934e01f78921e465ba0ac88b4daa97327d
1 parent
bd5b9ca1
修复发送目录信息是状态错误
Showing
5 changed files
with
57 additions
and
7 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
| ... | ... | @@ -132,7 +132,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { |
| 132 | 132 | if (event.getGbStreams() != null && event.getGbStreams().size() > 0){ |
| 133 | 133 | for (GbStream gbStream : event.getGbStreams()) { |
| 134 | 134 | deviceChannelList.add( |
| 135 | - gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform)); | |
| 135 | + gbStreamService.getDeviceChannelListByStreamWithStatus(gbStream, gbStream.getCatalogId(), parentPlatform)); | |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | if (deviceChannelList.size() > 0) { |
| ... | ... | @@ -154,7 +154,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { |
| 154 | 154 | deviceChannelList.add(deviceChannel); |
| 155 | 155 | GbStream gbStream = storager.queryStreamInParentPlatform(platform.getServerGBId(), gbId); |
| 156 | 156 | if(gbStream != null){ |
| 157 | - DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), platform); | |
| 157 | + DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStreamWithStatus(gbStream, gbStream.getCatalogId(), platform); | |
| 158 | 158 | deviceChannelList.add(deviceChannelByStream); |
| 159 | 159 | } |
| 160 | 160 | sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), platform, deviceChannelList, subscribeInfo, null); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| ... | ... | @@ -1219,9 +1219,9 @@ public class SIPCommander implements ISIPCommander { |
| 1219 | 1219 | String charset = device.getCharset(); |
| 1220 | 1220 | catalogXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n"); |
| 1221 | 1221 | catalogXml.append("<Query>\r\n"); |
| 1222 | - catalogXml.append("<CmdType>Catalog</CmdType>\r\n"); | |
| 1223 | - catalogXml.append("<SN>" + sn + "</SN>\r\n"); | |
| 1224 | - catalogXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); | |
| 1222 | + catalogXml.append(" <CmdType>Catalog</CmdType>\r\n"); | |
| 1223 | + catalogXml.append(" <SN>" + sn + "</SN>\r\n"); | |
| 1224 | + catalogXml.append(" <DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); | |
| 1225 | 1225 | catalogXml.append("</Query>\r\n"); |
| 1226 | 1226 | |
| 1227 | 1227 | String tm = Long.toString(System.currentTimeMillis()); |
| ... | ... | @@ -1229,7 +1229,7 @@ public class SIPCommander implements ISIPCommander { |
| 1229 | 1229 | CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() |
| 1230 | 1230 | : udpSipProvider.getNewCallId(); |
| 1231 | 1231 | |
| 1232 | - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), "z9hG4bK-ViaCatalog-" + tm, "FromCat" + tm, null, callIdHeader); | |
| 1232 | + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), "z9hG4bK" + tm, tm, null, callIdHeader); | |
| 1233 | 1233 | |
| 1234 | 1234 | transmitRequest(device, request, errorEvent); |
| 1235 | 1235 | } catch (SipException | ParseException | InvalidArgumentException e) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java
| ... | ... | @@ -53,4 +53,6 @@ public interface IGbStreamService { |
| 53 | 53 | * @return |
| 54 | 54 | */ |
| 55 | 55 | int updateGbIdOrName(List<StreamPushItem> streamPushItemForUpdate); |
| 56 | + | |
| 57 | + DeviceChannel getDeviceChannelListByStreamWithStatus(GbStream gbStream, String catalogId, ParentPlatform platform); | |
| 56 | 58 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
| ... | ... | @@ -79,7 +79,7 @@ public class GbStreamServiceImpl implements IGbStreamService { |
| 79 | 79 | gbStream.setPlatformId(platformId); |
| 80 | 80 | // TODO 修改为批量提交 |
| 81 | 81 | platformGbStreamMapper.add(gbStream); |
| 82 | - DeviceChannel deviceChannelListByStream = getDeviceChannelListByStream(gbStream, catalogId, parentPlatform); | |
| 82 | + DeviceChannel deviceChannelListByStream = getDeviceChannelListByStreamWithStatus(gbStream, catalogId, parentPlatform); | |
| 83 | 83 | deviceChannelList.add(deviceChannelListByStream); |
| 84 | 84 | } |
| 85 | 85 | dataSourceTransactionManager.commit(transactionStatus); //手动提交 |
| ... | ... | @@ -188,4 +188,46 @@ public class GbStreamServiceImpl implements IGbStreamService { |
| 188 | 188 | public int updateGbIdOrName(List<StreamPushItem> streamPushItemForUpdate) { |
| 189 | 189 | return gbStreamMapper.updateGbIdOrName(streamPushItemForUpdate); |
| 190 | 190 | } |
| 191 | + | |
| 192 | + @Override | |
| 193 | + public DeviceChannel getDeviceChannelListByStreamWithStatus(GbStream gbStream, String catalogId, ParentPlatform platform) { | |
| 194 | + DeviceChannel deviceChannel = new DeviceChannel(); | |
| 195 | + deviceChannel.setChannelId(gbStream.getGbId()); | |
| 196 | + deviceChannel.setName(gbStream.getName()); | |
| 197 | + deviceChannel.setLongitude(gbStream.getLongitude()); | |
| 198 | + deviceChannel.setLatitude(gbStream.getLatitude()); | |
| 199 | + deviceChannel.setDeviceId(platform.getDeviceGBId()); | |
| 200 | + deviceChannel.setManufacture("wvp-pro"); | |
| 201 | + // todo 目前是每一条查询一次,需要优化 | |
| 202 | + Boolean status = null; | |
| 203 | + if ("proxy".equals(gbStream.getStreamType())) { | |
| 204 | + status = gbStreamMapper.selectStatusForProxy(gbStream.getApp(), gbStream.getStream()); | |
| 205 | + }else { | |
| 206 | + status = gbStreamMapper.selectStatusForPush(gbStream.getApp(), gbStream.getStream()); | |
| 207 | + } | |
| 208 | + deviceChannel.setStatus((status != null && status )?1:0); | |
| 209 | + | |
| 210 | + deviceChannel.setRegisterWay(1); | |
| 211 | + deviceChannel.setCivilCode(platform.getAdministrativeDivision()); | |
| 212 | + | |
| 213 | + if (platform.getTreeType().equals(TreeType.CIVIL_CODE)){ | |
| 214 | + deviceChannel.setCivilCode(catalogId); | |
| 215 | + }else if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)){ | |
| 216 | + PlatformCatalog catalog = catalogMapper.select(catalogId); | |
| 217 | + if (catalog == null) { | |
| 218 | + deviceChannel.setParentId(platform.getDeviceGBId()); | |
| 219 | + deviceChannel.setBusinessGroupId(null); | |
| 220 | + }else { | |
| 221 | + deviceChannel.setParentId(catalog.getId()); | |
| 222 | + deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId()); | |
| 223 | + } | |
| 224 | + | |
| 225 | + } | |
| 226 | + | |
| 227 | + deviceChannel.setModel("live"); | |
| 228 | + deviceChannel.setOwner("wvp-pro"); | |
| 229 | + deviceChannel.setParental(0); | |
| 230 | + deviceChannel.setSecrecy("0"); | |
| 231 | + return deviceChannel; | |
| 232 | + } | |
| 191 | 233 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
| ... | ... | @@ -158,4 +158,10 @@ public interface GbStreamMapper { |
| 158 | 158 | "</foreach>"+ |
| 159 | 159 | "</script>") |
| 160 | 160 | int updateGbIdOrName(List<StreamPushItem> streamPushItemForUpdate); |
| 161 | + | |
| 162 | + @Select("SELECT status FROM stream_proxy WHERE app=#{app} AND stream=#{stream}") | |
| 163 | + Boolean selectStatusForProxy(String app, String stream); | |
| 164 | + | |
| 165 | + @Select("SELECT status FROM stream_push WHERE app=#{app} AND stream=#{stream}") | |
| 166 | + Boolean selectStatusForPush(String app, String stream); | |
| 161 | 167 | } | ... | ... |