优化通道管理/业务分组页面逻辑
This commit is contained in:
@@ -98,23 +98,40 @@ public class CommonChannelController {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Operation(summary = "获取通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Operation(summary = "获取关联行政区划通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||
@Parameter(name = "query", description = "查询内容")
|
||||
@Parameter(name = "online", description = "是否在线")
|
||||
@Parameter(name = "civilCode", description = "行政区划")
|
||||
@Parameter(name = "groupDeviceId", description = "业务分组下的父节点ID")
|
||||
@GetMapping("/list")
|
||||
public PageInfo<CommonGBChannel> queryList(int page, int count,
|
||||
@GetMapping("/civilcode/list")
|
||||
public PageInfo<CommonGBChannel> queryListByCivilCode(int page, int count,
|
||||
@RequestParam(required = false) String query,
|
||||
@RequestParam(required = false) Boolean online,
|
||||
@RequestParam(required = false) String civilCode,
|
||||
@RequestParam(required = false) Integer channelType,
|
||||
@RequestParam(required = false) String civilCode){
|
||||
if (ObjectUtils.isEmpty(query)){
|
||||
query = null;
|
||||
}
|
||||
return channelService.queryListByCivilCode(page, count, query, online, channelType, civilCode);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取关联业务分组通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||
@Parameter(name = "query", description = "查询内容")
|
||||
@Parameter(name = "online", description = "是否在线")
|
||||
@Parameter(name = "groupDeviceId", description = "业务分组下的父节点ID")
|
||||
@GetMapping("/parent/list")
|
||||
public PageInfo<CommonGBChannel> queryListByParentId(int page, int count,
|
||||
@RequestParam(required = false) String query,
|
||||
@RequestParam(required = false) Boolean online,
|
||||
@RequestParam(required = false) Integer channelType,
|
||||
@RequestParam(required = false) String groupDeviceId){
|
||||
if (ObjectUtils.isEmpty(query)){
|
||||
query = null;
|
||||
}
|
||||
return channelService.queryList(page, count, query, online, civilCode, groupDeviceId);
|
||||
return channelService.queryListByParentId(page, count, query, online, channelType, groupDeviceId);
|
||||
}
|
||||
|
||||
@Operation(summary = "通道设置行政区划", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
|
||||
@@ -40,12 +40,13 @@ public class GroupController {
|
||||
@GetMapping("/tree/list")
|
||||
public List<GroupTree> queryForTree(
|
||||
@RequestParam(required = false) String query,
|
||||
@RequestParam(required = false) Integer parent
|
||||
@RequestParam(required = false) Integer parent,
|
||||
@RequestParam(required = false) Boolean hasChannel
|
||||
){
|
||||
if (ObjectUtils.isEmpty(query)) {
|
||||
query = null;
|
||||
}
|
||||
return groupService.queryForTree(query, parent);
|
||||
return groupService.queryForTree(query, parent, hasChannel);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新分组")
|
||||
@@ -68,6 +69,14 @@ public class GroupController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所属的行政区划下的行政区划")
|
||||
@Parameter(name = "deviceId", description = "当前的行政区划", required = false)
|
||||
@ResponseBody
|
||||
@GetMapping("/path")
|
||||
public List<Group> getPath(String deviceId, String businessGroup){
|
||||
return groupService.getPath(deviceId, businessGroup);
|
||||
}
|
||||
|
||||
// @Operation(summary = "根据分组Id查询分组")
|
||||
// @Parameter(name = "groupDeviceId", description = "分组节点编号", required = true)
|
||||
// @ResponseBody
|
||||
|
||||
@@ -255,9 +255,17 @@ public interface CommonGBChannelMapper {
|
||||
@SelectProvider(type = ChannelProvider.class, method = "queryByStreamProxyId")
|
||||
CommonGBChannel queryByStreamProxyId(@Param("streamProxyId") Integer streamProxyId);
|
||||
|
||||
@SelectProvider(type = ChannelProvider.class, method = "queryList")
|
||||
List<CommonGBChannel> queryList(@Param("query") String query, @Param("online") Boolean online,
|
||||
@Param("civilCode") String civilCode, @Param("groupDeviceId") String groupDeviceId);
|
||||
@SelectProvider(type = ChannelProvider.class, method = "queryListByCivilCode")
|
||||
List<CommonGBChannel> queryListByCivilCode(@Param("query") String query, @Param("online") Boolean online,
|
||||
@Param("channelType") Integer channelType, @Param("civilCode") String civilCode);
|
||||
|
||||
|
||||
|
||||
@SelectProvider(type = ChannelProvider.class, method = "queryListByParentId")
|
||||
List<CommonGBChannel> queryListByParentId(@Param("query") String query, @Param("online") Boolean online,
|
||||
@Param("channelType") Integer channelType, @Param("groupDeviceId") String groupDeviceId);
|
||||
|
||||
|
||||
|
||||
@Select("<script>" +
|
||||
" select " +
|
||||
|
||||
@@ -117,7 +117,7 @@ public class ChannelProvider {
|
||||
}
|
||||
|
||||
|
||||
public String queryList(Map<String, Object> params ){
|
||||
public String queryListByCivilCode(Map<String, Object> params ){
|
||||
StringBuilder sqlBuild = new StringBuilder();
|
||||
sqlBuild.append(BASE_SQL);
|
||||
sqlBuild.append(" where channel_type = 0 ");
|
||||
@@ -134,9 +134,50 @@ public class ChannelProvider {
|
||||
}
|
||||
if (params.get("civilCode") != null) {
|
||||
sqlBuild.append(" AND coalesce(gb_civil_code, civil_code) = #{civilCode}");
|
||||
}else {
|
||||
sqlBuild.append(" AND coalesce(gb_civil_code, civil_code) is null");
|
||||
}
|
||||
if (params.get("channelType") != null) {
|
||||
if ((Integer)params.get("channelType") == 0) {
|
||||
sqlBuild.append(" AND device_db_id is not null");
|
||||
}else if ((Integer)params.get("channelType") == 1) {
|
||||
sqlBuild.append(" AND stream_push_id is not null");
|
||||
}else if ((Integer)params.get("channelType") == 2) {
|
||||
sqlBuild.append(" AND stream_proxy_id is not null");
|
||||
}
|
||||
}
|
||||
return sqlBuild.toString();
|
||||
}
|
||||
|
||||
public String queryListByParentId(Map<String, Object> params ){
|
||||
StringBuilder sqlBuild = new StringBuilder();
|
||||
sqlBuild.append(BASE_SQL);
|
||||
sqlBuild.append(" where channel_type = 0 ");
|
||||
if (params.get("query") != null) {
|
||||
sqlBuild.append(" AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%')" +
|
||||
" OR coalesce(gb_name, name) LIKE concat('%',#{query},'%') )")
|
||||
;
|
||||
}
|
||||
if (params.get("online") != null && (Boolean)params.get("online")) {
|
||||
sqlBuild.append(" AND coalesce(gb_status, status) = 'ON'");
|
||||
}
|
||||
if (params.get("online") != null && !(Boolean)params.get("online")) {
|
||||
sqlBuild.append(" AND coalesce(gb_status, status) = 'OFF'");
|
||||
}
|
||||
if (params.get("groupDeviceId") != null) {
|
||||
sqlBuild.append(" AND coalesce(gb_parent_id, parent_id) = #{groupDeviceId}");
|
||||
}else {
|
||||
sqlBuild.append(" AND coalesce(gb_parent_id, parent_id) is null");
|
||||
}
|
||||
|
||||
if (params.get("channelType") != null) {
|
||||
if ((Integer)params.get("channelType") == 0) {
|
||||
sqlBuild.append(" AND device_db_id is not null");
|
||||
}else if ((Integer)params.get("channelType") == 1) {
|
||||
sqlBuild.append(" AND stream_push_id is not null");
|
||||
}else if ((Integer)params.get("channelType") == 2) {
|
||||
sqlBuild.append(" AND stream_proxy_id is not null");
|
||||
}
|
||||
}
|
||||
return sqlBuild.toString();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,9 @@ public interface IGbChannelService {
|
||||
|
||||
void reset(int id);
|
||||
|
||||
PageInfo<CommonGBChannel> queryList(int page, int count, String query, Boolean online, String civilCode, String groupDeviceId);
|
||||
PageInfo<CommonGBChannel> queryListByCivilCode(int page, int count, String query, Boolean online, Integer channelType, String civilCode);
|
||||
|
||||
PageInfo<CommonGBChannel> queryListByParentId(int page, int count, String query, Boolean online, Integer channelType, String groupDeviceId);
|
||||
|
||||
void removeCivilCode(List<Region> allChildren);
|
||||
|
||||
|
||||
@@ -14,11 +14,13 @@ public interface IGroupService {
|
||||
|
||||
Group queryGroupByDeviceId(String regionDeviceId);
|
||||
|
||||
List<GroupTree> queryForTree(String query, Integer parent);
|
||||
List<GroupTree> queryForTree(String query, Integer parent, Boolean hasChannel);
|
||||
|
||||
void syncFromChannel();
|
||||
|
||||
boolean delete(int id);
|
||||
|
||||
boolean batchAdd(List<Group> groupList);
|
||||
|
||||
List<Group> getPath(String deviceId, String businessGroup);
|
||||
}
|
||||
|
||||
@@ -388,9 +388,16 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<CommonGBChannel> queryList(int page, int count, String query, Boolean online, String civilCode, String groupDeviceId) {
|
||||
public PageInfo<CommonGBChannel> queryListByCivilCode(int page, int count, String query, Boolean online, Integer channelType, String civilCode) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<CommonGBChannel> all = commonGBChannelMapper.queryList(query, online, civilCode, groupDeviceId);
|
||||
List<CommonGBChannel> all = commonGBChannelMapper.queryListByCivilCode(query, online, channelType, civilCode);
|
||||
return new PageInfo<>(all);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<CommonGBChannel> queryListByParentId(int page, int count, String query, Boolean online, Integer channelType, String groupDeviceId) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<CommonGBChannel> all = commonGBChannelMapper.queryListByParentId(query, online, channelType, groupDeviceId);
|
||||
return new PageInfo<>(all);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.GroupMapper;
|
||||
@@ -8,6 +9,7 @@ import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IGroupService;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -15,10 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 区域管理类
|
||||
@@ -154,7 +153,7 @@ public class GroupServiceImpl implements IGroupService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GroupTree> queryForTree(String query, Integer parentId) {
|
||||
public List<GroupTree> queryForTree(String query, Integer parentId, Boolean hasChannel) {
|
||||
|
||||
List<GroupTree> groupTrees = groupManager.queryForTree(query, parentId);
|
||||
if (parentId == null) {
|
||||
@@ -162,7 +161,7 @@ public class GroupServiceImpl implements IGroupService {
|
||||
}
|
||||
// 查询含有的通道
|
||||
Group parentGroup = groupManager.queryOne(parentId);
|
||||
if (parentGroup != null ) {
|
||||
if (parentGroup != null && hasChannel != null && hasChannel) {
|
||||
List<GroupTree> groupTreesForChannel = commonGBChannelMapper.queryForGroupTreeByParentId(query, parentGroup.getDeviceId());
|
||||
if (!ObjectUtils.isEmpty(groupTreesForChannel)) {
|
||||
groupTrees.addAll(groupTreesForChannel);
|
||||
@@ -247,4 +246,37 @@ public class GroupServiceImpl implements IGroupService {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Group> getPath(String deviceId, String businessGroup) {
|
||||
Group businessGroupInDb = groupManager.queryBusinessGroup(businessGroup);
|
||||
if (businessGroupInDb == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "业务分组不存在");
|
||||
}
|
||||
List<Group> groupList = new LinkedList<>();
|
||||
groupList.add(businessGroupInDb);
|
||||
Group group = groupManager.queryOneByDeviceId(deviceId, businessGroup);
|
||||
if (group == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "虚拟组织不存在");
|
||||
}
|
||||
groupList.add(group);
|
||||
List<Group> allParent = getAllParent(group);
|
||||
groupList.addAll(allParent);
|
||||
return groupList;
|
||||
}
|
||||
|
||||
private List<Group> getAllParent(Group group) {
|
||||
if (group.getParentId() == null || group.getBusinessGroup() == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<Group> groupList = new ArrayList<>();
|
||||
Group parent = groupManager.queryOneByDeviceId(group.getParentDeviceId(), group.getBusinessGroup());
|
||||
if (parent == null) {
|
||||
return groupList;
|
||||
}
|
||||
List<Group> allParent = getAllParent(parent);
|
||||
allParent.add(parent);
|
||||
return allParent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,13 +242,14 @@ public class RegionServiceImpl implements IRegionService {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<Region> regionList = new ArrayList<>();
|
||||
List<Region> regionList = new LinkedList<>();
|
||||
Region parent = regionMapper.queryByDeviceId(region.getParentDeviceId());
|
||||
if (parent == null) {
|
||||
return regionList;
|
||||
}
|
||||
regionList.add(parent);
|
||||
List<Region> allParent = getAllParent(parent);
|
||||
allParent.add(parent);
|
||||
return allParent;
|
||||
regionList.addAll(allParent);
|
||||
return regionList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user