From 887f20524fff38e0b4fdf0e9f0a81eedff69669d Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 3 Nov 2023 17:20:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=86=E7=BB=84=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/service/IGroupService.java | 2 +- .../iot/vmp/service/IRegionService.java | 3 +- .../impl/CommonGbChannelServiceImpl.java | 51 ++++++++++--------- .../vmp/service/impl/GroupServiceImpl.java | 13 ++++- .../vmp/service/impl/RegionServiceImpl.java | 3 +- .../iot/vmp/storager/dao/GroupMapper.java | 12 ++++- .../bean/{PageInfo.java => WVPPageInfo.java} | 6 +-- .../channel/CommonChannelController.java | 2 +- .../cloudRecord/CloudRecordController.java | 8 +-- .../vmp/vmanager/group/GroupController.java | 10 ++-- .../vmp/vmanager/region/RegionController.java | 3 +- 11 files changed, 68 insertions(+), 45 deletions(-) rename src/main/java/com/genersoft/iot/vmp/vmanager/bean/{PageInfo.java => WVPPageInfo.java} (94%) diff --git a/src/main/java/com/genersoft/iot/vmp/service/IGroupService.java b/src/main/java/com/genersoft/iot/vmp/service/IGroupService.java index 895feb32..acf42e4e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IGroupService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IGroupService.java @@ -2,7 +2,7 @@ package com.genersoft.iot.vmp.service; import com.genersoft.iot.vmp.common.CommonGbChannel; import com.genersoft.iot.vmp.service.bean.Group; -import com.genersoft.iot.vmp.vmanager.bean.PageInfo; +import com.github.pagehelper.PageInfo; import java.util.List; diff --git a/src/main/java/com/genersoft/iot/vmp/service/IRegionService.java b/src/main/java/com/genersoft/iot/vmp/service/IRegionService.java index c381e348..1bd17e28 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IRegionService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IRegionService.java @@ -1,9 +1,8 @@ package com.genersoft.iot.vmp.service; import com.genersoft.iot.vmp.service.bean.Region; -import com.genersoft.iot.vmp.vmanager.bean.PageInfo; +import com.github.pagehelper.PageInfo; -import java.util.List; public interface IRegionService { diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java index 8d3696fd..0e02e816 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java @@ -164,17 +164,18 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService { commonGbChannelList.add(commonGbChannel); } }); - // 检查是否存在已存在通道与将写入通道相同的情况 - List commonGbChannelInDbList = commonGbChannelMapper.queryInList(commonGbChannelList); - if (!commonGbChannelInDbList.isEmpty()) { - // 这里可以控制新数据覆盖旧数据还是丢弃重复的新数据 - // 目前使用新数据覆盖旧数据,后续分局实际业务需求再做修改 - commonGbChannelInDbList.stream().forEach(commonGbChannel->{ - clearChannels.add(commonGbChannel.getCommonGbDeviceID()); - }); + if (!commonGbChannelList.isEmpty()) { + // 检查是否存在已存在通道与将写入通道相同的情况 + List commonGbChannelInDbList = commonGbChannelMapper.queryInList(commonGbChannelList); + if (!commonGbChannelInDbList.isEmpty()) { + // 这里可以控制新数据覆盖旧数据还是丢弃重复的新数据 + // 目前使用新数据覆盖旧数据,后续分局实际业务需求再做修改 + commonGbChannelInDbList.stream().forEach(commonGbChannel->{ + clearChannels.add(commonGbChannel.getCommonGbDeviceID()); + }); + } } - // 检测分组境况 if (businessGroupMap.isEmpty()) { virtuallyGroupMap.clear(); @@ -251,22 +252,26 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService { } // 写入通道数据 boolean result; - if (commonGbChannelList.size() <= limit) { - result = commonGbChannelMapper.addAll(commonGbChannelList) > 0; - } else { - for (int i = 0; i < commonGbChannelList.size(); i += limit) { - int toIndex = i + limit; - if (i + limit > commonGbChannelList.size()) { - toIndex = commonGbChannelList.size(); - } - List commonGbChannelListSub = commonGbChannelList.subList(i, toIndex); - int currentResult = commonGbChannelMapper.addAll(commonGbChannelListSub); - if (currentResult <= 0) { - dataSourceTransactionManager.rollback(transactionStatus); - logger.info("[同步通用通道]来自国标设备,失败, 写入数据库失败, 国标编号: {}", gbDeviceId); - return false; + if (!commonGbChannelList.isEmpty()) { + if (commonGbChannelList.size() <= limit) { + result = commonGbChannelMapper.addAll(commonGbChannelList) > 0; + } else { + for (int i = 0; i < commonGbChannelList.size(); i += limit) { + int toIndex = i + limit; + if (i + limit > commonGbChannelList.size()) { + toIndex = commonGbChannelList.size(); + } + List commonGbChannelListSub = commonGbChannelList.subList(i, toIndex); + int currentResult = commonGbChannelMapper.addAll(commonGbChannelListSub); + if (currentResult <= 0) { + dataSourceTransactionManager.rollback(transactionStatus); + logger.info("[同步通用通道]来自国标设备,失败, 写入数据库失败, 国标编号: {}", gbDeviceId); + return false; + } } + result = true; } + }else { result = true; } deviceChannelMapper.updateCommonChannelId(gbDeviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/GroupServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/GroupServiceImpl.java index 7e047c2e..85c59862 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/GroupServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/GroupServiceImpl.java @@ -2,12 +2,14 @@ package com.genersoft.iot.vmp.service.impl; import com.genersoft.iot.vmp.common.CommonGbChannel; import com.genersoft.iot.vmp.conf.exception.ControllerException; +import com.genersoft.iot.vmp.gb28181.bean.Gb28181CodeType; +import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.service.IGroupService; import com.genersoft.iot.vmp.service.bean.Group; import com.genersoft.iot.vmp.storager.dao.GroupMapper; import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.PageInfo; +import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -192,7 +194,14 @@ public class GroupServiceImpl implements IGroupService { @Override public PageInfo queryChildGroupList(String groupParentId, int page, int count) { PageHelper.startPage(page, count); - List groupList = groupMapper.queryChildGroupList(groupParentId); + Gb28181CodeType channelIdType = SipUtils.getChannelIdType(groupParentId); + List groupList; + if (groupParentId == null || channelIdType == Gb28181CodeType.BUSINESS_GROUP) { + groupList = groupMapper.queryVirtualGroupList(groupParentId); + }else { + groupList = groupMapper.queryChildGroupList(groupParentId); + } + return new PageInfo<>(groupList); } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RegionServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RegionServiceImpl.java index b3b44261..6335cfc1 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RegionServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RegionServiceImpl.java @@ -1,14 +1,13 @@ package com.genersoft.iot.vmp.service.impl; import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.service.IRegionService; import com.genersoft.iot.vmp.service.bean.Region; import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper; import com.genersoft.iot.vmp.storager.dao.RegionMapper; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.PageInfo; +import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/GroupMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/GroupMapper.java index 461a22f1..cbe2f950 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/GroupMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/GroupMapper.java @@ -109,8 +109,16 @@ public interface GroupMapper { void updateParentDeviceId(@Param("oldParentDeviceId") String oldParentDeviceId, @Param("newParentDeviceId") String newParentDeviceId); @Select("") - List queryChildGroupList(String groupParentId); + List queryChildGroupList(@Param("groupParentId") String groupParentId); + @Select("") + List queryVirtualGroupList(@Param("groupParentId") String groupParentId); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/PageInfo.java b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPPageInfo.java similarity index 94% rename from src/main/java/com/genersoft/iot/vmp/vmanager/bean/PageInfo.java rename to src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPPageInfo.java index 8894191a..ef0c9e89 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/PageInfo.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPPageInfo.java @@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.vmanager.bean; import java.util.ArrayList; import java.util.List; -public class PageInfo { +public class WVPPageInfo { //当前页 private int pageNum; //每页的数量 @@ -19,11 +19,11 @@ public class PageInfo { private List list; - public PageInfo(List resultData) { + public WVPPageInfo(List resultData) { this.resultData = resultData; } - public PageInfo() { + public WVPPageInfo() { } public void startPage(int page, int count) { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/channel/CommonChannelController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/channel/CommonChannelController.java index 8826f756..0e0475f4 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/channel/CommonChannelController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/channel/CommonChannelController.java @@ -91,7 +91,7 @@ public class CommonChannelController { @Operation(summary = "更新通道") @Parameter(name = "CommonGbChannel", description = "commonGbChannel", required = true) @ResponseBody - @GetMapping("/list") + @GetMapping("/update") public void update( @RequestParam(required = false) CommonGbChannel commonGbChannel ){ diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java index 0f37a7de..a0dfb885 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java @@ -9,7 +9,7 @@ import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.PageInfo; +import com.genersoft.iot.vmp.vmanager.bean.WVPPageInfo; import com.genersoft.iot.vmp.vmanager.bean.RecordFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -108,7 +108,7 @@ public class CloudRecordController { @Parameter(name = "startTime", description = "开始时间(yyyy-MM-dd HH:mm:ss)", required = true) @Parameter(name = "endTime", description = "结束时间(yyyy-MM-dd HH:mm:ss)", required = true) @Parameter(name = "mediaServerId", description = "流媒体ID,置空则查询全部流媒体", required = false) - public PageInfo openRtpServer( + public WVPPageInfo openRtpServer( @RequestParam String app, @RequestParam String stream, @RequestParam int page, @@ -133,10 +133,10 @@ public class CloudRecordController { mediaServerItems = mediaServerService.getAll(); } if (mediaServerItems.isEmpty()) { - return new PageInfo<>(); + return new WVPPageInfo<>(); } List records = mediaServerService.getRecords(app, stream, startTime, endTime, mediaServerItems); - PageInfo pageInfo = new PageInfo<>(records); + WVPPageInfo pageInfo = new WVPPageInfo<>(records); pageInfo.startPage(page, count); return pageInfo; } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/group/GroupController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/group/GroupController.java index 544a37db..76ec03c6 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/group/GroupController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/group/GroupController.java @@ -4,10 +4,11 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.service.IGroupService; import com.genersoft.iot.vmp.service.bean.Group; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.PageInfo; +import com.github.pagehelper.PageInfo; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import org.apache.commons.lang3.ObjectUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -73,10 +74,13 @@ public class GroupController { @ResponseBody @GetMapping("/child/list") public PageInfo queryChildGroupList( - @RequestParam(required = true) String groupParentId, + @RequestParam(required = false) String groupParentId, @RequestParam(required = true) int page, @RequestParam(required = true) int count ){ - return groupService.queryChildGroupList(groupParentId, page, count); + if (ObjectUtils.isEmpty(groupParentId)) { + groupParentId = null; + } + return groupService.queryChildGroupList(groupParentId, page, count); } } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/region/RegionController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/region/RegionController.java index 8b19bf38..4b6b63ec 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/region/RegionController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/region/RegionController.java @@ -1,9 +1,8 @@ package com.genersoft.iot.vmp.vmanager.region; import com.genersoft.iot.vmp.service.IRegionService; -import com.genersoft.iot.vmp.service.bean.Group; import com.genersoft.iot.vmp.service.bean.Region; -import com.genersoft.iot.vmp.vmanager.bean.PageInfo; +import com.github.pagehelper.PageInfo; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag;