diff --git a/src/main/java/com/genersoft/iot/vmp/service/ICommonGbChannelService.java b/src/main/java/com/genersoft/iot/vmp/service/ICommonGbChannelService.java index e8aaf7a1..771b3f11 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/ICommonGbChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/ICommonGbChannelService.java @@ -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.service.bean.*; import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup; +import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion; import com.github.pagehelper.PageInfo; import java.util.ArrayList; @@ -66,4 +67,8 @@ public interface ICommonGbChannelService { void updateChannelToGroup(UpdateCommonChannelToGroup commonGbChannel); void removeFromGroup(UpdateCommonChannelToGroup params); + + void removeFromRegion(UpdateCommonChannelToRegion params); + + void updateChannelToRegion(UpdateCommonChannelToRegion params); } 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 9021afbd..4f342c70 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 @@ -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.utils.DateUtil; 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.PageInfo; import org.apache.commons.lang3.ObjectUtils; @@ -686,4 +687,19 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService { 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); + } } 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 f7aa25fa..420ab669 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 @@ -15,6 +15,7 @@ import com.github.pagehelper.PageHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; import java.util.Collection; import java.util.Collections; @@ -42,7 +43,9 @@ public class RegionServiceImpl implements IRegionService { public void add(Region region) { assert region.getCommonRegionName() != null; assert region.getCommonRegionDeviceId() != null; - assert region.getCommonRegionParentId() != null; + if (ObjectUtils.isEmpty(region.getCommonRegionParentId().trim())) { + region.setCommonRegionParentId(null); + } region.setCommonRegionCreateTime(DateUtil.getNow()); region.setCommonRegionUpdateTime(DateUtil.getNow()); regionMapper.add(region); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonGbChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonGbChannelMapper.java index 2163a67b..3dc137c7 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonGbChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonGbChannelMapper.java @@ -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.Region; import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup; +import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; @@ -375,14 +376,14 @@ public interface CommonGbChannelMapper { void removeGroupInfo(@Param("groupList") List groupList); @Update({""}) - void updateChannelToGroup(@Param("commonGbChannel") UpdateCommonChannelToGroup commonGbChannel); + void updateChannelToGroup(@Param("param") UpdateCommonChannelToGroup param); @Update({"") void removeRegionInfo(@Param("regionList") List regionList); + + @Update({""}) + void removeRegionGroupByIds(@Param("commonGbIds") List commonGbIds); + + @Update({""}) + void removeFromRegionByRegionId(@Param("commonGbCivilCode") String commonGbCivilCode); + + @Update({""}) + void updateChannelToRegion(@Param("param") UpdateCommonChannelToRegion param); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/RegionMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/RegionMapper.java index 55379299..a02ea3c8 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/RegionMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/RegionMapper.java @@ -14,21 +14,21 @@ public interface RegionMapper { " ") List getChildren(@Param("parentDeviceId") String parentDeviceId); - @Insert("INSERT INTO wvp_common_region (" + + @Insert(" ") + int add(@Param("region") Region region); @Delete("delete from wvp_common_region where common_region_device_id = #{regionDeviceId}") int deleteByDeviceId(@Param("regionDeviceId") String regionDeviceId); @@ -84,11 +84,11 @@ public interface RegionMapper { @Update(value = {" "}) void update(@Param("region") Region region); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/UpdateCommonChannelToRegion.java b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/UpdateCommonChannelToRegion.java new file mode 100644 index 00000000..69d4d2d0 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/UpdateCommonChannelToRegion.java @@ -0,0 +1,26 @@ +package com.genersoft.iot.vmp.vmanager.bean; + +import java.util.List; + +public class UpdateCommonChannelToRegion { + + private String commonGbCivilCode; + + private List commonGbIds; + + public String getCommonGbCivilCode() { + return commonGbCivilCode; + } + + public void setCommonGbCivilCode(String commonGbCivilCode) { + this.commonGbCivilCode = commonGbCivilCode; + } + + public List getCommonGbIds() { + return commonGbIds; + } + + public void setCommonGbIds(List commonGbIds) { + this.commonGbIds = commonGbIds; + } +} 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 b1a7f761..3d503560 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 @@ -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.bean.*; import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup; +import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion; import com.github.pagehelper.PageInfo; import com.google.common.collect.Lists; import io.swagger.v3.oas.annotations.Operation; @@ -179,7 +180,22 @@ public class CommonChannelController { 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); + } } 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 96b8b0bc..e58814f5 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 @@ -60,8 +60,8 @@ public class RegionController { @Operation(summary = "删除区域") @Parameter(name = "regionDeviceId", description = "区域编码", required = true) @ResponseBody - @DeleteMapping("/delete") - public void delete(@RequestBody String regionDeviceId){ + @GetMapping("/delete") + public void delete(String regionDeviceId){ assert regionDeviceId != null; boolean result = regionService.deleteByDeviceId(regionDeviceId); if (!result) {