优化区域树
parent
7d064b0830
commit
b96c9317e8
|
@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Gb28181CodeType;
|
import com.genersoft.iot.vmp.gb28181.bean.Gb28181CodeType;
|
||||||
import com.genersoft.iot.vmp.service.bean.*;
|
import com.genersoft.iot.vmp.service.bean.*;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup;
|
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup;
|
||||||
|
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -66,4 +67,8 @@ public interface ICommonGbChannelService {
|
||||||
void updateChannelToGroup(UpdateCommonChannelToGroup commonGbChannel);
|
void updateChannelToGroup(UpdateCommonChannelToGroup commonGbChannel);
|
||||||
|
|
||||||
void removeFromGroup(UpdateCommonChannelToGroup params);
|
void removeFromGroup(UpdateCommonChannelToGroup params);
|
||||||
|
|
||||||
|
void removeFromRegion(UpdateCommonChannelToRegion params);
|
||||||
|
|
||||||
|
void updateChannelToRegion(UpdateCommonChannelToRegion params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.storager.dao.GroupMapper;
|
||||||
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.UpdateCommonChannelToGroup;
|
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup;
|
||||||
|
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
@ -686,4 +687,19 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
|
||||||
commonGbChannelMapper.removeFromGroupByGroupId(params.getCommonGbBusinessGroupID());
|
commonGbChannelMapper.removeFromGroupByGroupId(params.getCommonGbBusinessGroupID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeFromRegion(UpdateCommonChannelToRegion params) {
|
||||||
|
if (!params.getCommonGbIds().isEmpty()) {
|
||||||
|
commonGbChannelMapper.removeRegionGroupByIds(params.getCommonGbIds());
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.isEmpty(params.getCommonGbCivilCode().trim())){
|
||||||
|
commonGbChannelMapper.removeFromRegionByRegionId(params.getCommonGbCivilCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateChannelToRegion(UpdateCommonChannelToRegion params) {
|
||||||
|
commonGbChannelMapper.updateChannelToRegion(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ 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;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -42,7 +43,9 @@ public class RegionServiceImpl implements IRegionService {
|
||||||
public void add(Region region) {
|
public void add(Region region) {
|
||||||
assert region.getCommonRegionName() != null;
|
assert region.getCommonRegionName() != null;
|
||||||
assert region.getCommonRegionDeviceId() != null;
|
assert region.getCommonRegionDeviceId() != null;
|
||||||
assert region.getCommonRegionParentId() != null;
|
if (ObjectUtils.isEmpty(region.getCommonRegionParentId().trim())) {
|
||||||
|
region.setCommonRegionParentId(null);
|
||||||
|
}
|
||||||
region.setCommonRegionCreateTime(DateUtil.getNow());
|
region.setCommonRegionCreateTime(DateUtil.getNow());
|
||||||
region.setCommonRegionUpdateTime(DateUtil.getNow());
|
region.setCommonRegionUpdateTime(DateUtil.getNow());
|
||||||
regionMapper.add(region);
|
regionMapper.add(region);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||||
import com.genersoft.iot.vmp.service.bean.Group;
|
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.UpdateCommonChannelToGroup;
|
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup;
|
||||||
|
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@ -375,14 +376,14 @@ public interface CommonGbChannelMapper {
|
||||||
void removeGroupInfo(@Param("groupList") List<Group> groupList);
|
void removeGroupInfo(@Param("groupList") List<Group> groupList);
|
||||||
|
|
||||||
@Update({"<script>" +
|
@Update({"<script>" +
|
||||||
"<foreach collection='commonGbChannel.commonGbIds' item='item' separator=';'>" +
|
"<foreach collection='param.commonGbIds' item='item' separator=';'>" +
|
||||||
" UPDATE" +
|
" UPDATE" +
|
||||||
" wvp_common_gb_channel" +
|
" wvp_common_gb_channel" +
|
||||||
" SET common_gb_business_group_id = #{commonGbChannel.commonGbBusinessGroupID}" +
|
" SET common_gb_business_group_id = #{param.commonGbBusinessGroupID}" +
|
||||||
" WHERE common_gb_id = #{item}" +
|
" WHERE common_gb_id = #{item}" +
|
||||||
"</foreach>" +
|
"</foreach>" +
|
||||||
"</script>"})
|
"</script>"})
|
||||||
void updateChannelToGroup(@Param("commonGbChannel") UpdateCommonChannelToGroup commonGbChannel);
|
void updateChannelToGroup(@Param("param") UpdateCommonChannelToGroup param);
|
||||||
|
|
||||||
@Update({"<script>" +
|
@Update({"<script>" +
|
||||||
"<foreach collection='commonGbIds' item='item' separator=';'>" +
|
"<foreach collection='commonGbIds' item='item' separator=';'>" +
|
||||||
|
@ -407,4 +408,32 @@ public interface CommonGbChannelMapper {
|
||||||
"<foreach collection='regionList' item='item' open='(' separator=',' close=')' > #{item.commonRegionDeviceId}</foreach>" +
|
"<foreach collection='regionList' item='item' open='(' separator=',' close=')' > #{item.commonRegionDeviceId}</foreach>" +
|
||||||
"</script>")
|
"</script>")
|
||||||
void removeRegionInfo(@Param("regionList") List<Region> regionList);
|
void removeRegionInfo(@Param("regionList") List<Region> regionList);
|
||||||
|
|
||||||
|
@Update({"<script>" +
|
||||||
|
"<foreach collection='commonGbIds' item='item' separator=';'>" +
|
||||||
|
" UPDATE" +
|
||||||
|
" wvp_common_gb_channel" +
|
||||||
|
" SET common_gb_civilCode = null" +
|
||||||
|
" WHERE common_gb_id = #{item}" +
|
||||||
|
"</foreach>" +
|
||||||
|
"</script>"})
|
||||||
|
void removeRegionGroupByIds(@Param("commonGbIds") List<Integer> commonGbIds);
|
||||||
|
|
||||||
|
@Update({"<script>" +
|
||||||
|
" UPDATE" +
|
||||||
|
" wvp_common_gb_channel" +
|
||||||
|
" SET common_gb_civilCode = null" +
|
||||||
|
" WHERE common_gb_civilCode = #{commonGbCivilCode}" +
|
||||||
|
"</script>"})
|
||||||
|
void removeFromRegionByRegionId(@Param("commonGbCivilCode") String commonGbCivilCode);
|
||||||
|
|
||||||
|
@Update({"<script>" +
|
||||||
|
"<foreach collection='param.commonGbIds' item='item' separator=';'>" +
|
||||||
|
" UPDATE" +
|
||||||
|
" wvp_common_gb_channel" +
|
||||||
|
" SET common_gb_civilCode = #{param.commonGbCivilCode}" +
|
||||||
|
" WHERE common_gb_id = #{item}" +
|
||||||
|
"</foreach>" +
|
||||||
|
"</script>"})
|
||||||
|
void updateChannelToRegion(@Param("param") UpdateCommonChannelToRegion param);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,21 +14,21 @@ public interface RegionMapper {
|
||||||
" </script>")
|
" </script>")
|
||||||
List<Region> getChildren(@Param("parentDeviceId") String parentDeviceId);
|
List<Region> getChildren(@Param("parentDeviceId") String parentDeviceId);
|
||||||
|
|
||||||
@Insert("INSERT INTO wvp_common_region (" +
|
@Insert(" <script>" +
|
||||||
|
"INSERT INTO wvp_common_region (" +
|
||||||
" common_region_device_id, " +
|
" common_region_device_id, " +
|
||||||
" common_region_name, " +
|
" common_region_name, " +
|
||||||
" common_region_parent_id, " +
|
"<if test='region.commonRegionParentId != null'>common_region_parent_id, </if>" +
|
||||||
" common_region_path, " +
|
|
||||||
" common_region_create_time, " +
|
" common_region_create_time, " +
|
||||||
" common_region_update_time ) " +
|
" common_region_update_time ) " +
|
||||||
" VALUES (" +
|
" VALUES (" +
|
||||||
" #{commonRegionDeviceId}, " +
|
" #{region.commonRegionDeviceId}, " +
|
||||||
" #{commonRegionName}, " +
|
" #{region.commonRegionName}, " +
|
||||||
" #{commonRegionParentId}, " +
|
"<if test='region.commonRegionParentId != null'> #{region.commonRegionParentId}, </if>" +
|
||||||
" #{commonRegionPath}, " +
|
" #{region.commonRegionCreateTime}, " +
|
||||||
" #{commonRegionCreateTime}, " +
|
" #{region.commonRegionUpdateTime})" +
|
||||||
" #{commonRegionUpdateTime})")
|
" </script>")
|
||||||
int add(Region region);
|
int add(@Param("region") Region region);
|
||||||
|
|
||||||
@Delete("delete from wvp_common_region where common_region_device_id = #{regionDeviceId}")
|
@Delete("delete from wvp_common_region where common_region_device_id = #{regionDeviceId}")
|
||||||
int deleteByDeviceId(@Param("regionDeviceId") String regionDeviceId);
|
int deleteByDeviceId(@Param("regionDeviceId") String regionDeviceId);
|
||||||
|
@ -84,11 +84,11 @@ public interface RegionMapper {
|
||||||
@Update(value = {" <script>" +
|
@Update(value = {" <script>" +
|
||||||
" UPDATE wvp_common_region " +
|
" UPDATE wvp_common_region " +
|
||||||
" SET" +
|
" SET" +
|
||||||
" common_region_update_time=#{commonRegionUpdateTime}," +
|
" common_region_update_time=#{region.commonRegionUpdateTime}," +
|
||||||
" common_region_device_id=#{commonRegionDeviceId}," +
|
" common_region_device_id=#{region.commonRegionDeviceId}," +
|
||||||
" common_region_name=#{commonRegionName}," +
|
" common_region_name=#{region.commonRegionName}," +
|
||||||
" common_region_parent_id=#{commonRegionParentId}" +
|
" common_region_parent_id=#{region.commonRegionParentId}" +
|
||||||
" WHERE common_region_id=#{commonRegionId}" +
|
" WHERE common_region_id=#{region.commonRegionId}" +
|
||||||
" </script>"})
|
" </script>"})
|
||||||
void update(@Param("region") Region region);
|
void update(@Param("region") Region region);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.genersoft.iot.vmp.vmanager.bean;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class UpdateCommonChannelToRegion {
|
||||||
|
|
||||||
|
private String commonGbCivilCode;
|
||||||
|
|
||||||
|
private List<Integer> commonGbIds;
|
||||||
|
|
||||||
|
public String getCommonGbCivilCode() {
|
||||||
|
return commonGbCivilCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommonGbCivilCode(String commonGbCivilCode) {
|
||||||
|
this.commonGbCivilCode = commonGbCivilCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getCommonGbIds() {
|
||||||
|
return commonGbIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommonGbIds(List<Integer> commonGbIds) {
|
||||||
|
this.commonGbIds = commonGbIds;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Gb28181CodeType;
|
||||||
import com.genersoft.iot.vmp.service.ICommonGbChannelService;
|
import com.genersoft.iot.vmp.service.ICommonGbChannelService;
|
||||||
import com.genersoft.iot.vmp.service.bean.*;
|
import com.genersoft.iot.vmp.service.bean.*;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup;
|
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup;
|
||||||
|
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
@ -179,7 +180,22 @@ public class CommonChannelController {
|
||||||
commonGbChannelService.removeFromGroup(params);
|
commonGbChannelService.removeFromGroup(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "从区域中移除通道")
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/region/remove")
|
||||||
|
public void removeFromRegion(@RequestBody UpdateCommonChannelToRegion params){
|
||||||
|
assert params.getCommonGbCivilCode() != null || !params.getCommonGbIds().isEmpty();
|
||||||
|
commonGbChannelService.removeFromRegion(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "为通道添加分组")
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/region/update")
|
||||||
|
public void updateChannelToRegion(@RequestBody UpdateCommonChannelToRegion params){
|
||||||
|
assert params.getCommonGbCivilCode() != null;
|
||||||
|
assert !params.getCommonGbIds().isEmpty();
|
||||||
|
commonGbChannelService.updateChannelToRegion(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,8 @@ public class RegionController {
|
||||||
@Operation(summary = "删除区域")
|
@Operation(summary = "删除区域")
|
||||||
@Parameter(name = "regionDeviceId", description = "区域编码", required = true)
|
@Parameter(name = "regionDeviceId", description = "区域编码", required = true)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@DeleteMapping("/delete")
|
@GetMapping("/delete")
|
||||||
public void delete(@RequestBody String regionDeviceId){
|
public void delete(String regionDeviceId){
|
||||||
assert regionDeviceId != null;
|
assert regionDeviceId != null;
|
||||||
boolean result = regionService.deleteByDeviceId(regionDeviceId);
|
boolean result = regionService.deleteByDeviceId(regionDeviceId);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|
Loading…
Reference in New Issue