From 5d901b5e3f033e8b04e53420d68626cbd87431c8 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期五, 06 五月 2022 10:12:34 +0800 Subject: [PATCH] 使用阿里代码规范。规范代码写法 --- src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java | 39 +++++++++++++++++++++++++++++---------- 1 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java index 35c262f..a7a5528 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; +import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.List; @@ -51,9 +52,9 @@ private EventPublisher eventPublisher; @Override - public PageInfo<GbStream> getAll(Integer page, Integer count) { + public PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId, String catalogId, String query, Boolean pushing, String mediaServerId) { PageHelper.startPage(page, count); - List<GbStream> all = gbStreamMapper.selectAll(); + List<GbStream> all = gbStreamMapper.selectAll(platFormId, catalogId, query, pushing, mediaServerId); return new PageInfo<>(all); } @@ -69,6 +70,9 @@ boolean result = false; TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); ParentPlatform parentPlatform = platformMapper.getParentPlatByServerGBId(platformId); + if (catalogId == null) { + catalogId = parentPlatform.getCatalogId(); + } try { List<DeviceChannel> deviceChannelList = new ArrayList<>(); for (GbStream gbStream : gbStreams) { @@ -76,7 +80,7 @@ gbStream.setPlatformId(platformId); // TODO 淇敼涓烘壒閲忔彁浜� platformGbStreamMapper.add(gbStream); - DeviceChannel deviceChannelListByStream = getDeviceChannelListByStream(gbStream, catalogId, parentPlatform.getDeviceGBId()); + DeviceChannel deviceChannelListByStream = getDeviceChannelListByStream(gbStream, catalogId, parentPlatform); deviceChannelList.add(deviceChannelListByStream); } dataSourceTransactionManager.commit(transactionStatus); //鎵嬪姩鎻愪氦 @@ -90,18 +94,23 @@ } @Override - public DeviceChannel getDeviceChannelListByStream(GbStream gbStream, String catalogId, String deviceGBId) { + public DeviceChannel getDeviceChannelListByStream(GbStream gbStream, String catalogId, ParentPlatform platform) { DeviceChannel deviceChannel = new DeviceChannel(); deviceChannel.setChannelId(gbStream.getGbId()); deviceChannel.setName(gbStream.getName()); deviceChannel.setLongitude(gbStream.getLongitude()); deviceChannel.setLatitude(gbStream.getLatitude()); - deviceChannel.setDeviceId(deviceGBId); + deviceChannel.setDeviceId(platform.getDeviceGBId()); deviceChannel.setManufacture("wvp-pro"); - deviceChannel.setStatus(gbStream.isStatus()?1:0); +// deviceChannel.setStatus(gbStream.isStatus()?1:0); + deviceChannel.setStatus(1); deviceChannel.setParentId(catalogId ==null?gbStream.getCatalogId():catalogId); deviceChannel.setRegisterWay(1); - deviceChannel.setCivilCode(sipConfig.getDomain()); + if (catalogId.length() <= 10) { // 鐖惰妭鐐规槸琛屾斂鍖哄垝,鍒欒缃瓹ivilCode浣跨敤姝よ鏀垮尯鍒� + deviceChannel.setCivilCode(catalogId); + }else { + deviceChannel.setCivilCode(platform.getAdministrativeDivision()); + } deviceChannel.setModel("live"); deviceChannel.setOwner("wvp-pro"); deviceChannel.setParental(0); @@ -116,14 +125,14 @@ TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); try { List<DeviceChannel> deviceChannelList = new ArrayList<>(); + platformGbStreamMapper.delByAppAndStreamsByPlatformId(gbStreams, platformId); for (GbStream gbStream : gbStreams) { - platformGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream()); DeviceChannel deviceChannel = new DeviceChannel(); deviceChannel.setChannelId(gbStream.getGbId()); deviceChannelList.add(deviceChannel); - eventPublisher.catalogEventPublish(platformId, deviceChannel, CatalogEvent.DEL); } + eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); dataSourceTransactionManager.commit(transactionStatus); //鎵嬪姩鎻愪氦 result = true; }catch (Exception e) { @@ -144,12 +153,22 @@ gbStreams.add(streamProxyItem); } } + sendCatalogMsgs(gbStreams, type); + } + + @Override + public void sendCatalogMsgs(List<GbStream> gbStreams, String type) { if (gbStreams.size() > 0) { for (GbStream gs : gbStreams) { + if (StringUtils.isEmpty(gs.getGbId())){ + continue; + } List<ParentPlatform> parentPlatforms = platformGbStreamMapper.selectByAppAndStream(gs.getApp(), gs.getStream()); if (parentPlatforms.size() > 0) { for (ParentPlatform parentPlatform : parentPlatforms) { - eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), gs, type); + if (parentPlatform != null) { + eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), gs, type); + } } } } -- Gitblit v1.8.0