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,17 +66,17 @@ public class SIPSender {
66 // 添加错误订阅 66 // 添加错误订阅
67 if (errorEvent != null) { 67 if (errorEvent != null) {
68 sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (eventResult -> { 68 sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (eventResult -> {
69 - errorEvent.response(eventResult);  
70 sipSubscribe.removeErrorSubscribe(eventResult.callId); 69 sipSubscribe.removeErrorSubscribe(eventResult.callId);
71 sipSubscribe.removeOkSubscribe(eventResult.callId); 70 sipSubscribe.removeOkSubscribe(eventResult.callId);
  71 + errorEvent.response(eventResult);
72 })); 72 }));
73 } 73 }
74 // 添加订阅 74 // 添加订阅
75 if (okEvent != null) { 75 if (okEvent != null) {
76 sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), eventResult -> { 76 sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), eventResult -> {
77 - okEvent.response(eventResult);  
78 sipSubscribe.removeOkSubscribe(eventResult.callId); 77 sipSubscribe.removeOkSubscribe(eventResult.callId);
79 sipSubscribe.removeErrorSubscribe(eventResult.callId); 78 sipSubscribe.removeErrorSubscribe(eventResult.callId);
  79 + okEvent.response(eventResult);
80 }); 80 });
81 } 81 }
82 if ("TCP".equals(transport)) { 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,6 +579,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
579 sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> { 579 sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> {
580 logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg); 580 logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg);
581 }, (eventResult -> { 581 }, (eventResult -> {
  582 + logger.info("[发送NOTIFY通知]类型: {},发送成功: {}", type, channels.size());
582 try { 583 try {
583 sendNotifyForCatalogAddOrUpdate(type, parentPlatform, deviceChannels, subscribeInfo, 584 sendNotifyForCatalogAddOrUpdate(type, parentPlatform, deviceChannels, subscribeInfo,
584 finalIndex + parentPlatform.getCatalogGroup()); 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,8 +77,6 @@ public class GbStreamServiceImpl implements IGbStreamService {
77 } 77 }
78 try { 78 try {
79 List<DeviceChannel> deviceChannelList = new ArrayList<>(); 79 List<DeviceChannel> deviceChannelList = new ArrayList<>();
80 -  
81 -  
82 for (int i = 0; i < gbStreams.size(); i++) { 80 for (int i = 0; i < gbStreams.size(); i++) {
83 GbStream gbStream = gbStreams.get(i); 81 GbStream gbStream = gbStreams.get(i);
84 gbStream.setCatalogId(catalogId); 82 gbStream.setCatalogId(catalogId);
@@ -250,16 +248,18 @@ public class GbStreamServiceImpl implements IGbStreamService { @@ -250,16 +248,18 @@ public class GbStreamServiceImpl implements IGbStreamService {
250 if (platform == null) { 248 if (platform == null) {
251 return ; 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 @Override 265 @Override
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java
@@ -165,10 +165,9 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { @@ -165,10 +165,9 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
165 catalogId = null; 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,7 +58,10 @@ public interface PlatformChannelMapper {
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}") 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 List<DeviceChannel> queryChannelInParentPlatform(@Param("platformId") String platformId, @Param("channelId") String channelId); 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 List<DeviceChannel> queryAllChannelInCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId); 65 List<DeviceChannel> queryAllChannelInCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
63 66
64 @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 " + 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,11 +53,14 @@ public interface PlatformGbStreamMapper {
53 "WHERE gs.app=#{app} AND gs.stream=#{stream} AND pgs.platform_id=#{platformId}") 53 "WHERE gs.app=#{app} AND gs.stream=#{stream} AND pgs.platform_id=#{platformId}")
54 StreamProxyItem selectOne(@Param("app") String app, @Param("stream") String stream, @Param("platformId") String platformId); 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 " left join wvp_platform_gb_stream pgs\n" + 59 " left join wvp_platform_gb_stream pgs\n" +
59 " on gs.gb_stream_id = pgs.gb_stream_id\n" + 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 List<GbStream> queryChannelInParentPlatformAndCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId); 64 List<GbStream> queryChannelInParentPlatformAndCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
62 65
63 @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" + 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,7 +84,7 @@ public class GbStreamController {
84 @ResponseBody 84 @ResponseBody
85 public void del(@RequestBody GbStreamParam gbStreamParam){ 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 if (gbStreamParam.isAll()) { 88 if (gbStreamParam.isAll()) {
89 gbStreamService.delAllPlatformInfo(gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId()); 89 gbStreamService.delAllPlatformInfo(gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId());
90 } 90 }
@@ -103,7 +103,7 @@ public class GbStreamController { @@ -103,7 +103,7 @@ public class GbStreamController {
103 @PostMapping(value = "/add") 103 @PostMapping(value = "/add")
104 @ResponseBody 104 @ResponseBody
105 public void add(@RequestBody GbStreamParam gbStreamParam){ 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 if (gbStreamParam.isAll()) { 107 if (gbStreamParam.isAll()) {
108 List<GbStream> allGBChannels = gbStreamService.getAllGBChannels(gbStreamParam.getPlatformId()); 108 List<GbStream> allGBChannels = gbStreamService.getAllGBChannels(gbStreamParam.getPlatformId());
109 gbStreamService.addPlatformInfo(allGBChannels, gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId()); 109 gbStreamService.addPlatformInfo(allGBChannels, gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId());