优化分组管理
parent
e5ac02ff17
commit
887f20524f
|
@ -2,7 +2,7 @@ package com.genersoft.iot.vmp.service;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||||
import com.genersoft.iot.vmp.service.bean.Group;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package com.genersoft.iot.vmp.service;
|
package com.genersoft.iot.vmp.service;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.service.bean.Region;
|
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 {
|
public interface IRegionService {
|
||||||
|
|
||||||
|
|
|
@ -164,17 +164,18 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
|
||||||
commonGbChannelList.add(commonGbChannel);
|
commonGbChannelList.add(commonGbChannel);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 检查是否存在已存在通道与将写入通道相同的情况
|
if (!commonGbChannelList.isEmpty()) {
|
||||||
List<CommonGbChannel> commonGbChannelInDbList = commonGbChannelMapper.queryInList(commonGbChannelList);
|
// 检查是否存在已存在通道与将写入通道相同的情况
|
||||||
if (!commonGbChannelInDbList.isEmpty()) {
|
List<CommonGbChannel> commonGbChannelInDbList = commonGbChannelMapper.queryInList(commonGbChannelList);
|
||||||
// 这里可以控制新数据覆盖旧数据还是丢弃重复的新数据
|
if (!commonGbChannelInDbList.isEmpty()) {
|
||||||
// 目前使用新数据覆盖旧数据,后续分局实际业务需求再做修改
|
// 这里可以控制新数据覆盖旧数据还是丢弃重复的新数据
|
||||||
commonGbChannelInDbList.stream().forEach(commonGbChannel->{
|
// 目前使用新数据覆盖旧数据,后续分局实际业务需求再做修改
|
||||||
clearChannels.add(commonGbChannel.getCommonGbDeviceID());
|
commonGbChannelInDbList.stream().forEach(commonGbChannel->{
|
||||||
});
|
clearChannels.add(commonGbChannel.getCommonGbDeviceID());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 检测分组境况
|
// 检测分组境况
|
||||||
if (businessGroupMap.isEmpty()) {
|
if (businessGroupMap.isEmpty()) {
|
||||||
virtuallyGroupMap.clear();
|
virtuallyGroupMap.clear();
|
||||||
|
@ -251,22 +252,26 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
|
||||||
}
|
}
|
||||||
// 写入通道数据
|
// 写入通道数据
|
||||||
boolean result;
|
boolean result;
|
||||||
if (commonGbChannelList.size() <= limit) {
|
if (!commonGbChannelList.isEmpty()) {
|
||||||
result = commonGbChannelMapper.addAll(commonGbChannelList) > 0;
|
if (commonGbChannelList.size() <= limit) {
|
||||||
} else {
|
result = commonGbChannelMapper.addAll(commonGbChannelList) > 0;
|
||||||
for (int i = 0; i < commonGbChannelList.size(); i += limit) {
|
} else {
|
||||||
int toIndex = i + limit;
|
for (int i = 0; i < commonGbChannelList.size(); i += limit) {
|
||||||
if (i + limit > commonGbChannelList.size()) {
|
int toIndex = i + limit;
|
||||||
toIndex = commonGbChannelList.size();
|
if (i + limit > commonGbChannelList.size()) {
|
||||||
}
|
toIndex = commonGbChannelList.size();
|
||||||
List<CommonGbChannel> commonGbChannelListSub = commonGbChannelList.subList(i, toIndex);
|
}
|
||||||
int currentResult = commonGbChannelMapper.addAll(commonGbChannelListSub);
|
List<CommonGbChannel> commonGbChannelListSub = commonGbChannelList.subList(i, toIndex);
|
||||||
if (currentResult <= 0) {
|
int currentResult = commonGbChannelMapper.addAll(commonGbChannelListSub);
|
||||||
dataSourceTransactionManager.rollback(transactionStatus);
|
if (currentResult <= 0) {
|
||||||
logger.info("[同步通用通道]来自国标设备,失败, 写入数据库失败, 国标编号: {}", gbDeviceId);
|
dataSourceTransactionManager.rollback(transactionStatus);
|
||||||
return false;
|
logger.info("[同步通用通道]来自国标设备,失败, 写入数据库失败, 国标编号: {}", gbDeviceId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
result = true;
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
deviceChannelMapper.updateCommonChannelId(gbDeviceId);
|
deviceChannelMapper.updateCommonChannelId(gbDeviceId);
|
||||||
|
|
|
@ -2,12 +2,14 @@ package com.genersoft.iot.vmp.service.impl;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
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.IGroupService;
|
||||||
import com.genersoft.iot.vmp.service.bean.Group;
|
import com.genersoft.iot.vmp.service.bean.Group;
|
||||||
import com.genersoft.iot.vmp.storager.dao.GroupMapper;
|
import com.genersoft.iot.vmp.storager.dao.GroupMapper;
|
||||||
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
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 com.github.pagehelper.PageHelper;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -192,7 +194,14 @@ public class GroupServiceImpl implements IGroupService {
|
||||||
@Override
|
@Override
|
||||||
public PageInfo<Group> queryChildGroupList(String groupParentId, int page, int count) {
|
public PageInfo<Group> queryChildGroupList(String groupParentId, int page, int count) {
|
||||||
PageHelper.startPage(page, count);
|
PageHelper.startPage(page, count);
|
||||||
List<Group> groupList = groupMapper.queryChildGroupList(groupParentId);
|
Gb28181CodeType channelIdType = SipUtils.getChannelIdType(groupParentId);
|
||||||
|
List<Group> groupList;
|
||||||
|
if (groupParentId == null || channelIdType == Gb28181CodeType.BUSINESS_GROUP) {
|
||||||
|
groupList = groupMapper.queryVirtualGroupList(groupParentId);
|
||||||
|
}else {
|
||||||
|
groupList = groupMapper.queryChildGroupList(groupParentId);
|
||||||
|
}
|
||||||
|
|
||||||
return new PageInfo<>(groupList);
|
return new PageInfo<>(groupList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package com.genersoft.iot.vmp.service.impl;
|
package com.genersoft.iot.vmp.service.impl;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
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.IRegionService;
|
||||||
import com.genersoft.iot.vmp.service.bean.Region;
|
import com.genersoft.iot.vmp.service.bean.Region;
|
||||||
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
||||||
import com.genersoft.iot.vmp.storager.dao.RegionMapper;
|
import com.genersoft.iot.vmp.storager.dao.RegionMapper;
|
||||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
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 com.github.pagehelper.PageHelper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
|
@ -109,8 +109,16 @@ public interface GroupMapper {
|
||||||
void updateParentDeviceId(@Param("oldParentDeviceId") String oldParentDeviceId, @Param("newParentDeviceId") String newParentDeviceId);
|
void updateParentDeviceId(@Param("oldParentDeviceId") String oldParentDeviceId, @Param("newParentDeviceId") String newParentDeviceId);
|
||||||
|
|
||||||
@Select("<script> "+
|
@Select("<script> "+
|
||||||
"select * from wvp_common_group where common_group_parent_id = #{groupParentId} " +
|
"select * from wvp_common_group where common_group_parent_id = #{groupParentId}" +
|
||||||
"</script>")
|
"</script>")
|
||||||
List<Group> queryChildGroupList(String groupParentId);
|
List<Group> queryChildGroupList(@Param("groupParentId") String groupParentId);
|
||||||
|
|
||||||
|
@Select("<script> "+
|
||||||
|
"select * from wvp_common_group where " +
|
||||||
|
"<if test='groupParentId != null'> " +
|
||||||
|
"common_group_top_id = #{groupParentId} and common_group_parent_id is null and common_group_device_id != common_group_top_id " +
|
||||||
|
"</if>" +
|
||||||
|
"<if test='groupParentId == null'> common_group_device_id = common_group_top_id</if>" +
|
||||||
|
"</script>")
|
||||||
|
List<Group> queryVirtualGroupList(@Param("groupParentId") String groupParentId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.vmanager.bean;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PageInfo<T> {
|
public class WVPPageInfo<T> {
|
||||||
//当前页
|
//当前页
|
||||||
private int pageNum;
|
private int pageNum;
|
||||||
//每页的数量
|
//每页的数量
|
||||||
|
@ -19,11 +19,11 @@ public class PageInfo<T> {
|
||||||
|
|
||||||
private List<T> list;
|
private List<T> list;
|
||||||
|
|
||||||
public PageInfo(List<T> resultData) {
|
public WVPPageInfo(List<T> resultData) {
|
||||||
this.resultData = resultData;
|
this.resultData = resultData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PageInfo() {
|
public WVPPageInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startPage(int page, int count) {
|
public void startPage(int page, int count) {
|
|
@ -91,7 +91,7 @@ public class CommonChannelController {
|
||||||
@Operation(summary = "更新通道")
|
@Operation(summary = "更新通道")
|
||||||
@Parameter(name = "CommonGbChannel", description = "commonGbChannel", required = true)
|
@Parameter(name = "CommonGbChannel", description = "commonGbChannel", required = true)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@GetMapping("/list")
|
@GetMapping("/update")
|
||||||
public void update(
|
public void update(
|
||||||
@RequestParam(required = false) CommonGbChannel commonGbChannel
|
@RequestParam(required = false) CommonGbChannel commonGbChannel
|
||||||
){
|
){
|
||||||
|
|
|
@ -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.media.zlm.dto.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
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 com.genersoft.iot.vmp.vmanager.bean.RecordFile;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
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 = "startTime", description = "开始时间(yyyy-MM-dd HH:mm:ss)", required = true)
|
||||||
@Parameter(name = "endTime", 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)
|
@Parameter(name = "mediaServerId", description = "流媒体ID,置空则查询全部流媒体", required = false)
|
||||||
public PageInfo<RecordFile> openRtpServer(
|
public WVPPageInfo<RecordFile> openRtpServer(
|
||||||
@RequestParam String app,
|
@RequestParam String app,
|
||||||
@RequestParam String stream,
|
@RequestParam String stream,
|
||||||
@RequestParam int page,
|
@RequestParam int page,
|
||||||
|
@ -133,10 +133,10 @@ public class CloudRecordController {
|
||||||
mediaServerItems = mediaServerService.getAll();
|
mediaServerItems = mediaServerService.getAll();
|
||||||
}
|
}
|
||||||
if (mediaServerItems.isEmpty()) {
|
if (mediaServerItems.isEmpty()) {
|
||||||
return new PageInfo<>();
|
return new WVPPageInfo<>();
|
||||||
}
|
}
|
||||||
List<RecordFile> records = mediaServerService.getRecords(app, stream, startTime, endTime, mediaServerItems);
|
List<RecordFile> records = mediaServerService.getRecords(app, stream, startTime, endTime, mediaServerItems);
|
||||||
PageInfo<RecordFile> pageInfo = new PageInfo<>(records);
|
WVPPageInfo<RecordFile> pageInfo = new WVPPageInfo<>(records);
|
||||||
pageInfo.startPage(page, count);
|
pageInfo.startPage(page, count);
|
||||||
return pageInfo;
|
return pageInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.IGroupService;
|
||||||
import com.genersoft.iot.vmp.service.bean.Group;
|
import com.genersoft.iot.vmp.service.bean.Group;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
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.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -73,10 +74,13 @@ public class GroupController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@GetMapping("/child/list")
|
@GetMapping("/child/list")
|
||||||
public PageInfo<Group> queryChildGroupList(
|
public PageInfo<Group> queryChildGroupList(
|
||||||
@RequestParam(required = true) String groupParentId,
|
@RequestParam(required = false) String groupParentId,
|
||||||
@RequestParam(required = true) int page,
|
@RequestParam(required = true) int page,
|
||||||
@RequestParam(required = true) int count
|
@RequestParam(required = true) int count
|
||||||
){
|
){
|
||||||
return groupService.queryChildGroupList(groupParentId, page, count);
|
if (ObjectUtils.isEmpty(groupParentId)) {
|
||||||
|
groupParentId = null;
|
||||||
|
}
|
||||||
|
return groupService.queryChildGroupList(groupParentId, page, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package com.genersoft.iot.vmp.vmanager.region;
|
package com.genersoft.iot.vmp.vmanager.region;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.service.IRegionService;
|
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.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.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
|
Loading…
Reference in New Issue