优化通道管理/行政区划页面逻辑

This commit is contained in:
648540858
2024-11-05 18:23:58 +08:00
parent d5eb13192e
commit 9a29f44c86
23 changed files with 237 additions and 244 deletions

View File

@@ -103,17 +103,18 @@ public class CommonChannelController {
@Parameter(name = "count", description = "每页查询数量", required = true)
@Parameter(name = "query", description = "查询内容")
@Parameter(name = "online", description = "是否在线")
@Parameter(name = "hasCivilCode", description = "是否分配行政区划")
@Parameter(name = "civilCode", description = "行政区划")
@Parameter(name = "groupDeviceId", description = "业务分组下的父节点ID")
@GetMapping("/list")
public PageInfo<CommonGBChannel> queryList(int page, int count,
@RequestParam(required = false) String query,
@RequestParam(required = false) Boolean online,
@RequestParam(required = false) Boolean hasCivilCode,
@RequestParam(required = false) Boolean hasGroup){
@RequestParam(required = false) String civilCode,
@RequestParam(required = false) String groupDeviceId){
if (ObjectUtils.isEmpty(query)){
query = null;
}
return channelService.queryList(page, count, query, online, hasCivilCode, hasGroup);
return channelService.queryList(page, count, query, online, civilCode, groupDeviceId);
}
@Operation(summary = "通道设置行政区划", security = @SecurityRequirement(name = JwtUtils.HEADER))

View File

@@ -57,12 +57,13 @@ public class RegionController {
@GetMapping("/tree/list")
public List<RegionTree> 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 regionService.queryForTree(query, parent);
return regionService.queryForTree(query, parent, hasChannel);
}
@Operation(summary = "更新区域")
@@ -109,6 +110,14 @@ public class RegionController {
return regionService.getAllChild(parent);
}
@Operation(summary = "获取所属的行政区划下的行政区划")
@Parameter(name = "deviceId", description = "当前的行政区划", required = false)
@ResponseBody
@GetMapping("/path")
public List<Region> getPath(String deviceId){
return regionService.getPath(deviceId);
}
@Operation(summary = "从通道中同步行政区划")
@ResponseBody
@GetMapping("/sync")

View File

@@ -257,8 +257,7 @@ public interface CommonGBChannelMapper {
@SelectProvider(type = ChannelProvider.class, method = "queryList")
List<CommonGBChannel> queryList(@Param("query") String query, @Param("online") Boolean online,
@Param("hasCivilCode") Boolean hasCivilCode,
@Param("hasGroup") Boolean hasGroup);
@Param("civilCode") String civilCode, @Param("groupDeviceId") String groupDeviceId);
@Select("<script>" +
" select " +

View File

@@ -1,7 +1,6 @@
package com.genersoft.iot.vmp.gb28181.dao;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Group;
import com.genersoft.iot.vmp.gb28181.bean.Region;
import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
import org.apache.ibatis.annotations.*;

View File

@@ -132,17 +132,11 @@ public class ChannelProvider {
if (params.get("online") != null && !(Boolean)params.get("online")) {
sqlBuild.append(" AND coalesce(gb_status, status) = 'OFF'");
}
if (params.get("hasCivilCode") != null && (Boolean)params.get("hasCivilCode")) {
sqlBuild.append(" AND coalesce(gb_civil_code, civil_code) is not null");
if (params.get("civilCode") != null) {
sqlBuild.append(" AND coalesce(gb_civil_code, civil_code) = #{civilCode}");
}
if (params.get("hasCivilCode") != null && !(Boolean)params.get("hasCivilCode")) {
sqlBuild.append(" AND coalesce(gb_civil_code, civil_code) is null");
}
if (params.get("hasGroup") != null && (Boolean)params.get("hasGroup")) {
sqlBuild.append(" AND coalesce(gb_parent_id, parent_id) is not null");
}
if (params.get("hasGroup") != null && !(Boolean)params.get("hasGroup")) {
sqlBuild.append(" AND coalesce(gb_parent_id, parent_id) is null");
if (params.get("groupDeviceId") != null) {
sqlBuild.append(" AND coalesce(gb_parent_id, parent_id) = #{groupDeviceId}");
}
return sqlBuild.toString();
}

View File

@@ -41,7 +41,7 @@ public interface IGbChannelService {
void reset(int id);
PageInfo<CommonGBChannel> queryList(int page, int count, String query, Boolean online, Boolean hasCivilCode, Boolean hasGroup);
PageInfo<CommonGBChannel> queryList(int page, int count, String query, Boolean online, String civilCode, String groupDeviceId);
void removeCivilCode(List<Region> allChildren);

View File

@@ -27,11 +27,13 @@ public interface IRegionService {
Region queryRegionByDeviceId(String regionDeviceId);
List<RegionTree> queryForTree(String query, Integer parent);
List<RegionTree> queryForTree(String query, Integer parent, Boolean hasChannel);
void syncFromChannel();
boolean delete(int id);
boolean batchAdd(List<Region> regionList);
List<Region> getPath(String deviceId);
}

View File

@@ -388,10 +388,9 @@ public class GbChannelServiceImpl implements IGbChannelService {
}
@Override
public PageInfo<CommonGBChannel> queryList(int page, int count, String query, Boolean online, Boolean hasCivilCode,
Boolean hasGroup) {
public PageInfo<CommonGBChannel> queryList(int page, int count, String query, Boolean online, String civilCode, String groupDeviceId) {
PageHelper.startPage(page, count);
List<CommonGBChannel> all = commonGBChannelMapper.queryList(query, online, hasCivilCode, hasGroup);
List<CommonGBChannel> all = commonGBChannelMapper.queryList(query, online, civilCode, groupDeviceId);
return new PageInfo<>(all);
}

View File

@@ -139,9 +139,9 @@ public class RegionServiceImpl implements IRegionService {
}
@Override
public List<RegionTree> queryForTree(String query, Integer parent) {
public List<RegionTree> queryForTree(String query, Integer parent, Boolean hasChannel) {
List<RegionTree> regionList = regionMapper.queryForTree(query, parent);
if (parent != null) {
if (parent != null && hasChannel != null && hasChannel) {
Region parentRegion = regionMapper.queryOne(parent);
if (parentRegion != null) {
List<RegionTree> channelList = commonGBChannelMapper.queryForRegionTreeByCivilCode(query, parentRegion.getDeviceId());
@@ -224,4 +224,31 @@ public class RegionServiceImpl implements IRegionService {
return true;
}
@Override
public List<Region> getPath(String deviceId) {
Region region = regionMapper.queryByDeviceId(deviceId);
if (region == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "行政区划不存在");
}
List<Region> allParent = getAllParent(region);
allParent.add(region);
return allParent;
}
private List<Region> getAllParent(Region region) {
if (region.getParentId() == null) {
return new ArrayList<>();
}
List<Region> regionList = new ArrayList<>();
Region parent = regionMapper.queryByDeviceId(region.getParentDeviceId());
if (parent == null) {
return regionList;
}
List<Region> allParent = getAllParent(parent);
allParent.add(parent);
return allParent;
}
}