Commit 0327d1602156510225e695a94147181d9f5db33b
1 parent
59c79c08
优化级联平台删除
Showing
3 changed files
with
12 additions
and
9 deletions
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
| @@ -118,14 +118,14 @@ public class GbStreamServiceImpl implements IGbStreamService { | @@ -118,14 +118,14 @@ public class GbStreamServiceImpl implements IGbStreamService { | ||
| 118 | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); | 118 | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| 119 | try { | 119 | try { |
| 120 | List<DeviceChannel> deviceChannelList = new ArrayList<>(); | 120 | List<DeviceChannel> deviceChannelList = new ArrayList<>(); |
| 121 | + platformGbStreamMapper.delByAppAndStreamsByPlatformId(gbStreams, platformId); | ||
| 121 | for (GbStream gbStream : gbStreams) { | 122 | for (GbStream gbStream : gbStreams) { |
| 122 | - platformGbStreamMapper.delByAppAndStreamAndPlatform(gbStream.getApp(), gbStream.getStream(), platformId); | ||
| 123 | DeviceChannel deviceChannel = new DeviceChannel(); | 123 | DeviceChannel deviceChannel = new DeviceChannel(); |
| 124 | deviceChannel.setChannelId(gbStream.getGbId()); | 124 | deviceChannel.setChannelId(gbStream.getGbId()); |
| 125 | deviceChannelList.add(deviceChannel); | 125 | deviceChannelList.add(deviceChannel); |
| 126 | - eventPublisher.catalogEventPublish(platformId, deviceChannel, CatalogEvent.DEL); | ||
| 127 | } | 126 | } |
| 128 | 127 | ||
| 128 | + eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); | ||
| 129 | dataSourceTransactionManager.commit(transactionStatus); //手动提交 | 129 | dataSourceTransactionManager.commit(transactionStatus); //手动提交 |
| 130 | result = true; | 130 | result = true; |
| 131 | }catch (Exception e) { | 131 | }catch (Exception e) { |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java
| @@ -95,6 +95,11 @@ public interface PlatformGbStreamMapper { | @@ -95,6 +95,11 @@ public interface PlatformGbStreamMapper { | ||
| 95 | "</script>") | 95 | "</script>") |
| 96 | void delByGbStreams(List<GbStream> gbStreams); | 96 | void delByGbStreams(List<GbStream> gbStreams); |
| 97 | 97 | ||
| 98 | - | ||
| 99 | - | 98 | + @Delete("<script> "+ |
| 99 | + "DELETE FROM platform_gb_stream where " + | ||
| 100 | + "<foreach collection='gbStreams' item='item' separator='or'>" + | ||
| 101 | + "(app=#{item.app} and stream=#{item.stream}) and platformId=#{platformId}" + | ||
| 102 | + "</foreach>" + | ||
| 103 | + "</script>") | ||
| 104 | + void delByAppAndStreamsByPlatformId(List<GbStream> gbStreams, String platformId); | ||
| 100 | } | 105 | } |
web_src/src/components/dialog/getCatalog.vue
| @@ -119,12 +119,10 @@ export default { | @@ -119,12 +119,10 @@ export default { | ||
| 119 | if (res.data.code === 0) { | 119 | if (res.data.code === 0) { |
| 120 | this.platformName = res.data.data.name; | 120 | this.platformName = res.data.data.name; |
| 121 | this.defaultCatalogId = res.data.data.catalogId; | 121 | this.defaultCatalogId = res.data.data.catalogId; |
| 122 | + this.defaultCatalogIdSign = res.data.data.catalogId; | ||
| 123 | + this.chooseId = res.data.data.catalogId; | ||
| 122 | resolve([ | 124 | resolve([ |
| 123 | - { | ||
| 124 | - name: "未分配", | ||
| 125 | - id: null, | ||
| 126 | - type: -1 | ||
| 127 | - },{ | 125 | + { |
| 128 | name: this.platformName, | 126 | name: this.platformName, |
| 129 | id: this.platformId, | 127 | id: this.platformId, |
| 130 | type: 0 | 128 | type: 0 |