Commit 0371f5a96e8be9067b796c7b93ecf4d3bbdb99dc

Authored by 648540858
1 parent 2b2efb59

修复国标级联全部添加与全部删除

src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java
... ... @@ -66,17 +66,17 @@ public class SIPSender {
66 66 // 添加错误订阅
67 67 if (errorEvent != null) {
68 68 sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (eventResult -> {
69   - errorEvent.response(eventResult);
70 69 sipSubscribe.removeErrorSubscribe(eventResult.callId);
71 70 sipSubscribe.removeOkSubscribe(eventResult.callId);
  71 + errorEvent.response(eventResult);
72 72 }));
73 73 }
74 74 // 添加订阅
75 75 if (okEvent != null) {
76 76 sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), eventResult -> {
77   - okEvent.response(eventResult);
78 77 sipSubscribe.removeOkSubscribe(eventResult.callId);
79 78 sipSubscribe.removeErrorSubscribe(eventResult.callId);
  79 + okEvent.response(eventResult);
80 80 });
81 81 }
82 82 if ("TCP".equals(transport)) {
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
... ... @@ -579,6 +579,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
579 579 sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> {
580 580 logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg);
581 581 }, (eventResult -> {
  582 + logger.info("[发送NOTIFY通知]类型: {},发送成功: {}", type, channels.size());
582 583 try {
583 584 sendNotifyForCatalogAddOrUpdate(type, parentPlatform, deviceChannels, subscribeInfo,
584 585 finalIndex + parentPlatform.getCatalogGroup());
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
... ... @@ -77,8 +77,6 @@ public class GbStreamServiceImpl implements IGbStreamService {
77 77 }
78 78 try {
79 79 List<DeviceChannel> deviceChannelList = new ArrayList<>();
80   -
81   -
82 80 for (int i = 0; i < gbStreams.size(); i++) {
83 81 GbStream gbStream = gbStreams.get(i);
84 82 gbStream.setCatalogId(catalogId);
... ... @@ -250,16 +248,18 @@ public class GbStreamServiceImpl implements IGbStreamService {
250 248 if (platform == null) {
251 249 return ;
252 250 }
253   - if (platformGbStreamMapper.delByPlatformAndCatalogId(platformId, catalogId) > 0) {
254   - List<GbStream> gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformId, catalogId);
255   - List<DeviceChannel> deviceChannelList = new ArrayList<>();
256   - for (GbStream gbStream : gbStreams) {
257   - DeviceChannel deviceChannel = new DeviceChannel();
258   - deviceChannel.setChannelId(gbStream.getGbId());
259   - deviceChannelList.add(deviceChannel);
260   - }
261   - eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
  251 + if (ObjectUtils.isEmpty(catalogId)) {
  252 + catalogId = null;
  253 + }
  254 + List<GbStream> gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformId, catalogId);
  255 + List<DeviceChannel> deviceChannelList = new ArrayList<>();
  256 + for (GbStream gbStream : gbStreams) {
  257 + DeviceChannel deviceChannel = new DeviceChannel();
  258 + deviceChannel.setChannelId(gbStream.getGbId());
  259 + deviceChannelList.add(deviceChannel);
262 260 }
  261 + eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
  262 + platformGbStreamMapper.delByPlatformAndCatalogId(platformId, catalogId);
263 263 }
264 264  
265 265 @Override
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java
... ... @@ -165,10 +165,9 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
165 165 catalogId = null;
166 166 }
167 167  
168   - if ((result = platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId)) > 0) {
169   - List<DeviceChannel> deviceChannels = platformChannelMapper.queryAllChannelInCatalog(platformId, catalogId);
170   - eventPublisher.catalogEventPublish(platformId, deviceChannels, CatalogEvent.DEL);
171   - }
172   - return result;
  168 + List<DeviceChannel> deviceChannels = platformChannelMapper.queryAllChannelInCatalog(platformId, catalogId);
  169 + eventPublisher.catalogEventPublish(platformId, deviceChannels, CatalogEvent.DEL);
  170 +
  171 + return platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId);
173 172 }
174 173 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
... ... @@ -58,7 +58,10 @@ public interface PlatformChannelMapper {
58 58 @Select("SELECT dc.* from wvp_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.channel_id=#{channelId} and pgc.platform_id=#{platformId}")
59 59 List<DeviceChannel> queryChannelInParentPlatform(@Param("platformId") String platformId, @Param("channelId") String channelId);
60 60  
61   - @Select("SELECT dc.* from wvp_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE pgc.platform_id=#{platformId} and pgc.catalog_id=#{catalogId}")
  61 + @Select("<script> "+
  62 + "SELECT dc.* from wvp_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE pgc.platform_id=#{platformId} " +
  63 + " <if test='catalogId != null' > and pgc.catalog_id=#{catalogId}</if>" +
  64 + "</script>")
62 65 List<DeviceChannel> queryAllChannelInCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
63 66  
64 67 @Select(" select dc.channel_id as id, dc.name as name, pgc.platform_id as platform_id, pgc.catalog_id as parent_id, 0 as children_count, 1 as type " +
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java
... ... @@ -53,11 +53,14 @@ public interface PlatformGbStreamMapper {
53 53 "WHERE gs.app=#{app} AND gs.stream=#{stream} AND pgs.platform_id=#{platformId}")
54 54 StreamProxyItem selectOne(@Param("app") String app, @Param("stream") String stream, @Param("platformId") String platformId);
55 55  
56   - @Select("select gs.* \n" +
57   - "from wvp_gb_stream gs\n" +
  56 + @Select("<script> " +
  57 + "select gs.* " +
  58 + " from wvp_gb_stream gs\n" +
58 59 " left join wvp_platform_gb_stream pgs\n" +
59 60 " on gs.gb_stream_id = pgs.gb_stream_id\n" +
60   - "where pgs.platform_id=#{platformId} and pgs.catalog_id=#{catalogId}")
  61 + " where pgs.platform_id=#{platformId} " +
  62 + " <if test='catalogId != null' > and pgs.catalog_id=#{catalogId}</if>" +
  63 + "</script>")
61 64 List<GbStream> queryChannelInParentPlatformAndCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
62 65  
63 66 @Select("select gs.gb_id as id, gs.name as name, pgs.platform_id as platform_id, pgs.catalog_id as catalog_id , 0 as children_count, 2 as type\n" +
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java
... ... @@ -84,7 +84,7 @@ public class GbStreamController {
84 84 @ResponseBody
85 85 public void del(@RequestBody GbStreamParam gbStreamParam){
86 86  
87   - if (gbStreamParam.getGbStreams() == null || gbStreamParam.getGbStreams().size() == 0) {
  87 + if (gbStreamParam.getGbStreams() == null || gbStreamParam.getGbStreams().isEmpty()) {
88 88 if (gbStreamParam.isAll()) {
89 89 gbStreamService.delAllPlatformInfo(gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId());
90 90 }
... ... @@ -103,7 +103,7 @@ public class GbStreamController {
103 103 @PostMapping(value = "/add")
104 104 @ResponseBody
105 105 public void add(@RequestBody GbStreamParam gbStreamParam){
106   - if (gbStreamParam.getGbStreams() == null || gbStreamParam.getGbStreams().size() == 0) {
  106 + if (gbStreamParam.getGbStreams() == null || gbStreamParam.getGbStreams().isEmpty()) {
107 107 if (gbStreamParam.isAll()) {
108 108 List<GbStream> allGBChannels = gbStreamService.getAllGBChannels(gbStreamParam.getPlatformId());
109 109 gbStreamService.addPlatformInfo(allGBChannels, gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId());
... ...