增加接口
parent
a73508a24c
commit
e5ac02ff17
|
@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.service;
|
|||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -31,7 +32,7 @@ public interface ICommonGbChannelService {
|
|||
|
||||
CommonGbChannel getCommonChannelFromDeviceChannel(DeviceChannel deviceChannel, List<String> syncKeys);
|
||||
|
||||
List<CommonGbChannel> getChannelsInRegion(String civilCode);
|
||||
PageInfo<CommonGbChannel> getChannelsInRegion(String regionDeviceId, String query, int page, int count);
|
||||
|
||||
List<CommonGbChannel> getChannelsInBusinessGroup(String businessGroupID);
|
||||
|
||||
|
@ -44,4 +45,8 @@ public interface ICommonGbChannelService {
|
|||
void channelsOnlineFromList(List<DeviceChannel> deleteChannelList);
|
||||
|
||||
void channelsOfflineFromList(List<DeviceChannel> deleteChannelList);
|
||||
|
||||
PageInfo<CommonGbChannel> queryChannelListInGroup(String groupDeviceId, String query, int page, int count);
|
||||
|
||||
PageInfo<CommonGbChannel> queryChannelList(String query, int page, int count);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.service;
|
|||
|
||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||
import com.genersoft.iot.vmp.service.bean.Group;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -28,7 +29,7 @@ public interface IGroupService {
|
|||
/**
|
||||
* 添加业务分组
|
||||
*/
|
||||
boolean add(Group businessGroup);
|
||||
boolean add(Group group);
|
||||
|
||||
/**
|
||||
* 移除业务分组
|
||||
|
@ -43,7 +44,7 @@ public interface IGroupService {
|
|||
/**
|
||||
* 更新业务分组
|
||||
*/
|
||||
boolean update(Group businessGroup);
|
||||
boolean update(Group group);
|
||||
|
||||
/**
|
||||
* 设置国标设备到相关的分组中
|
||||
|
@ -61,4 +62,13 @@ public interface IGroupService {
|
|||
boolean removeChannelsFromGroup(List<CommonGbChannel> channels);
|
||||
|
||||
|
||||
/**
|
||||
* 查询分组
|
||||
*/
|
||||
PageInfo<Group> queryGroup(String query, int page, int count);
|
||||
|
||||
/**
|
||||
* 查询子节点
|
||||
*/
|
||||
PageInfo<Group> queryChildGroupList(String groupParentId, int page, int count);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,28 @@
|
|||
package com.genersoft.iot.vmp.service;
|
||||
|
||||
import com.genersoft.iot.vmp.service.bean.Region;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IRegionService {
|
||||
|
||||
List<Region> getChildren(String parentDeviceId);
|
||||
|
||||
void add(Region region);
|
||||
|
||||
void deleteByDeviceId(String regionDeviceId);
|
||||
|
||||
void updateRegionName(Region region);
|
||||
/**
|
||||
* 查询区划列表
|
||||
*/
|
||||
PageInfo<Region> query(String query, int page, int count);
|
||||
|
||||
/**
|
||||
* 查询子区划列表
|
||||
*/
|
||||
PageInfo<Region> queryChildGroupList(String regionParentId, int page, int count);
|
||||
|
||||
/**
|
||||
* 更新区域
|
||||
*/
|
||||
void update(Region region);
|
||||
}
|
||||
|
|
|
@ -1,45 +1,54 @@
|
|||
package com.genersoft.iot.vmp.service.bean;
|
||||
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* 分组数据
|
||||
*/
|
||||
@Schema(description = "分组数据")
|
||||
public class Group {
|
||||
|
||||
/**
|
||||
* 数据库自增ID
|
||||
*/
|
||||
@Schema(description = "数据库自增ID")
|
||||
private int commonGroupId;
|
||||
|
||||
/**
|
||||
* 分组国标编号
|
||||
*/
|
||||
@Schema(description = "分组国标编号")
|
||||
private String commonGroupDeviceId;
|
||||
|
||||
/**
|
||||
* 分组名称
|
||||
*/
|
||||
@Schema(description = "分组名称")
|
||||
private String commonGroupName;
|
||||
|
||||
/**
|
||||
* 分组父ID
|
||||
*/
|
||||
@Schema(description = "分组父ID")
|
||||
private String commonGroupParentId;
|
||||
|
||||
/**
|
||||
* 分组的顶级节点ID,对应多个虚拟组织的业务分组ID
|
||||
*/
|
||||
@Schema(description = "分组的顶级节点ID,对应多个虚拟组织的业务分组ID")
|
||||
private String commonGroupTopId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
private String commonGroupCreateTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
private String commonGroupUpdateTime;
|
||||
|
||||
public static Group getInstance(String commonGroupDeviceId, String commonGroupName, String commonGroupParentId, String commonGroupTopId) {
|
||||
|
|
|
@ -1,39 +1,47 @@
|
|||
package com.genersoft.iot.vmp.service.bean;
|
||||
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* 区域
|
||||
*/
|
||||
@Schema(description = "区域")
|
||||
public class Region {
|
||||
/**
|
||||
* 数据库自增ID
|
||||
*/
|
||||
@Schema(description = "数据库自增ID")
|
||||
private int commonRegionId;
|
||||
|
||||
/**
|
||||
* 区域国标编号
|
||||
*/
|
||||
@Schema(description = "区域国标编号")
|
||||
private String commonRegionDeviceId;
|
||||
|
||||
/**
|
||||
* 区域名称
|
||||
*/
|
||||
@Schema(description = "区域名称")
|
||||
private String commonRegionName;
|
||||
|
||||
/**
|
||||
* 父区域国标ID
|
||||
*/
|
||||
@Schema(description = "父区域国标ID")
|
||||
private String commonRegionParentId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
private String commonRegionCreateTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
private String commonRegionUpdateTime;
|
||||
|
||||
public static Region getInstance(String commonRegionDeviceId, String commonRegionName, String commonRegionParentId) {
|
||||
|
|
|
@ -16,6 +16,8 @@ import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
|
|||
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.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -84,6 +86,10 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
|
|||
|
||||
@Override
|
||||
public int update(CommonGbChannel channel) {
|
||||
assert channel.getCommonGbId() >= 0;
|
||||
assert channel.getCommonGbDeviceID() != null;
|
||||
assert channel.getCommonGbName() != null;
|
||||
// TODO 如果状态变化,需要发送消息给级联的上级
|
||||
return commonGbChannelMapper.update(channel);
|
||||
}
|
||||
|
||||
|
@ -550,11 +556,6 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
|
|||
return commonGbChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommonGbChannel> getChannelsInRegion(String civilCode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommonGbChannel> getChannelsInBusinessGroup(String businessGroupID) {
|
||||
return null;
|
||||
|
@ -592,4 +593,27 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
|
|||
public void channelsOfflineFromList(List<DeviceChannel> channelList) {
|
||||
commonGbChannelMapper.channelsOfflineFromList(channelList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<CommonGbChannel> getChannelsInRegion(String regionDeviceId, String query, int page, int count) {
|
||||
assert regionDeviceId != null;
|
||||
PageHelper.startPage(page, count);
|
||||
List<CommonGbChannel> all = commonGbChannelMapper.getChannelsInRegion(regionDeviceId, query);
|
||||
return new PageInfo<>(all);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<CommonGbChannel> queryChannelListInGroup(String groupDeviceId, String query, int page, int count) {
|
||||
assert groupDeviceId != null;
|
||||
PageHelper.startPage(page, count);
|
||||
List<CommonGbChannel> all = commonGbChannelMapper.queryChannelListInGroup(groupDeviceId, query);
|
||||
return new PageInfo<>(all);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<CommonGbChannel> queryChannelList(String query, int page, int count) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<CommonGbChannel> all = commonGbChannelMapper.query(query);
|
||||
return new PageInfo<>(all);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package com.genersoft.iot.vmp.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.service.IGroupService;
|
||||
import com.genersoft.iot.vmp.service.bean.Group;
|
||||
import com.genersoft.iot.vmp.storager.dao.GroupMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.PageInfo;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -12,6 +16,7 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -40,7 +45,7 @@ public class GroupServiceImpl implements IGroupService {
|
|||
|
||||
@Override
|
||||
public List<CommonGbChannel> getChannels(int id) {
|
||||
Group group = groupMapper.query(id);
|
||||
Group group = groupMapper.queryOne(id);
|
||||
if (group == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -58,6 +63,8 @@ public class GroupServiceImpl implements IGroupService {
|
|||
|
||||
@Override
|
||||
public boolean add(Group group) {
|
||||
assert group.getCommonGroupDeviceId() != null;
|
||||
assert group.getCommonGroupDeviceId() != null;
|
||||
return groupMapper.add(group) > 0;
|
||||
}
|
||||
|
||||
|
@ -72,10 +79,25 @@ public class GroupServiceImpl implements IGroupService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean update(Group group) {
|
||||
if (group.getCommonGroupId() == 0) {
|
||||
assert group.getCommonGroupId() >= 0;
|
||||
Group groupInDb = groupMapper.queryOne(group.getCommonGroupId());
|
||||
if (groupInDb == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未查询到待更新的分组");
|
||||
}
|
||||
if (!groupInDb.getCommonGroupDeviceId().equals(group.getCommonGroupDeviceId())) {
|
||||
// 分组编号变化
|
||||
// 修改所有子分组的父节点编号
|
||||
groupMapper.updateParentDeviceId(groupInDb.getCommonGroupDeviceId(), group.getCommonGroupDeviceId());
|
||||
// 修改所有通用通道中分组编号
|
||||
commonGbChannelDao.updateChanelGroup(groupInDb.getCommonGroupDeviceId(), group.getCommonGroupDeviceId());
|
||||
}else if (groupInDb.getCommonGroupParentId().equals(group.getCommonGroupParentId())
|
||||
&& groupInDb.getCommonGroupName().equals(group.getCommonGroupName())) {
|
||||
// 数据无变化
|
||||
return false;
|
||||
}
|
||||
|
||||
return groupMapper.update(group) > 0;
|
||||
}
|
||||
|
||||
|
@ -84,7 +106,7 @@ public class GroupServiceImpl implements IGroupService {
|
|||
if (channels.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Group group = groupMapper.query(id);
|
||||
Group group = groupMapper.queryOne(id);
|
||||
if (group == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -160,4 +182,17 @@ public class GroupServiceImpl implements IGroupService {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<Group> queryGroup(String query, int page, int count) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<Group> groupList = groupMapper.query(query);
|
||||
return new PageInfo<>(groupList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<Group> queryChildGroupList(String groupParentId, int page, int count) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<Group> groupList = groupMapper.queryChildGroupList(groupParentId);
|
||||
return new PageInfo<>(groupList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
package com.genersoft.iot.vmp.service.impl;
|
||||
|
||||
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.bean.Region;
|
||||
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.RegionMapper;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.PageInfo;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -19,13 +26,17 @@ public class RegionServiceImpl implements IRegionService {
|
|||
@Autowired
|
||||
private RegionMapper regionMapper;
|
||||
|
||||
@Override
|
||||
public List<Region> getChildren(String parentDeviceId) {
|
||||
return regionMapper.getChildren(parentDeviceId);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private CommonGbChannelMapper commonGbChannelMapper;
|
||||
|
||||
@Override
|
||||
public void add(Region region) {
|
||||
assert region.getCommonRegionName() != null;
|
||||
assert region.getCommonRegionDeviceId() != null;
|
||||
assert region.getCommonRegionParentId() != null;
|
||||
region.setCommonRegionCreateTime(DateUtil.getNow());
|
||||
region.setCommonRegionUpdateTime(DateUtil.getNow());
|
||||
regionMapper.add(region);
|
||||
}
|
||||
|
||||
|
@ -35,7 +46,45 @@ public class RegionServiceImpl implements IRegionService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateRegionName(Region region) {
|
||||
regionMapper.updateRegionName(region.getCommonRegionName(), DateUtil.getNow(), region.getCommonRegionDeviceId());
|
||||
public PageInfo<Region> query(String query, int page, int count) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<Region> regionList = regionMapper.query(query);
|
||||
return new PageInfo<>(regionList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<Region> queryChildGroupList(String regionParentId, int page, int count) {
|
||||
assert regionParentId != null;
|
||||
PageHelper.startPage(page, count);
|
||||
List<Region> all = regionMapper.getChildren(regionParentId);
|
||||
return new PageInfo<>(all);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void update(Region region) {
|
||||
assert region.getCommonRegionId() > 0;
|
||||
assert region.getCommonRegionDeviceId() != null;
|
||||
assert region.getCommonRegionName() != null;
|
||||
region.setCommonRegionUpdateTime(DateUtil.getNow());
|
||||
Region regionInDb = regionMapper.queryRegion(region.getCommonRegionId());
|
||||
if (regionInDb == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到待更新的数据");
|
||||
}
|
||||
region.setCommonRegionCreateTime(regionInDb.getCommonRegionCreateTime());
|
||||
if (!region.getCommonRegionDeviceId().equals(regionInDb.getCommonRegionDeviceId())) {
|
||||
// 节点国标编号改变,
|
||||
// 修改所有子区域的父节点编号
|
||||
regionMapper.updateChild(regionInDb.getCommonRegionDeviceId(), region.getCommonRegionDeviceId());
|
||||
// 修改所有所属的通道的编号
|
||||
commonGbChannelMapper.updateChanelRegion(regionInDb.getCommonRegionDeviceId(),
|
||||
region.getCommonRegionDeviceId());
|
||||
}else if (region.getCommonRegionName().equals(regionInDb.getCommonRegionName()) &&
|
||||
region.getCommonRegionParentId().equals(regionInDb.getCommonRegionParentId())) {
|
||||
// 数据没有变化
|
||||
return;
|
||||
}
|
||||
regionMapper.update(region);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -317,4 +317,37 @@ public interface CommonGbChannelMapper {
|
|||
"<foreach collection='commonGbChannelList' item='item' open='(' separator=',' close=')' > #{item.commonGbDeviceID}</foreach>" +
|
||||
"</script>")
|
||||
List<CommonGbChannel> queryInList(List<CommonGbChannel> commonGbChannelList);
|
||||
|
||||
@Update("<script> "+
|
||||
"UPDATE wvp_common_gb_channel SET common_gb_civilCode = #{commonRegionDeviceIdForNew} WHERE common_gb_civilCode = #{commonRegionDeviceIdForOld}" +
|
||||
"</script>")
|
||||
void updateChanelRegion(@Param("commonRegionDeviceIdForOld") String commonRegionDeviceIdForOld,
|
||||
@Param("commonRegionDeviceIdForNew") String commonRegionDeviceIdForNew);
|
||||
|
||||
@Update("<script> "+
|
||||
"UPDATE wvp_common_gb_channel SET common_gb_business_group_id = #{groupDeviceIdForNew} WHERE common_gb_business_group_id = #{groupDeviceIdForOld}" +
|
||||
"</script>")
|
||||
void updateChanelGroup(
|
||||
@Param("commonRegionDeviceIdForOld") String groupDeviceIdForOld,
|
||||
@Param("groupDeviceIdForNew") String groupDeviceIdForNew);
|
||||
|
||||
@Select("<script> "+
|
||||
"select * from wvp_common_gb_channel where common_gb_civilCode = '#{regionDeviceId}'" +
|
||||
"<if test='query != null'> and ( common_gb_device_id LIKE concat('%',#{query},'%') or common_gb_name LIKE concat('%',#{query},'%') ) </if>" +
|
||||
"</script>")
|
||||
List<CommonGbChannel> getChannelsInRegion(@Param("regionDeviceId") String regionDeviceId,
|
||||
@Param("query") String query);
|
||||
|
||||
@Select("<script> "+
|
||||
"select * from wvp_common_gb_channel where common_gb_business_group_id = '#{groupDeviceId}'" +
|
||||
"<if test='query != null'> and ( common_gb_device_id LIKE concat('%',#{query},'%') or common_gb_name LIKE concat('%',#{query},'%') ) </if>" +
|
||||
"</script>")
|
||||
List<CommonGbChannel> queryChannelListInGroup(@Param("groupDeviceId") String groupDeviceId,
|
||||
@Param("query") String query);
|
||||
|
||||
@Select("<script> "+
|
||||
"select * from wvp_common_gb_channel where 1=1 " +
|
||||
"<if test='query != null'> and ( common_gb_device_id LIKE concat('%',#{query},'%') or common_gb_name LIKE concat('%',#{query},'%') ) </if>" +
|
||||
"</script>")
|
||||
List<CommonGbChannel> query(String query);
|
||||
}
|
||||
|
|
|
@ -17,15 +17,15 @@ public interface GroupMapper {
|
|||
" <if test='parentId == null' > AND common_group_parent_id is null </if>" +
|
||||
" order by common_group_id ASC " +
|
||||
" </script>")
|
||||
List<Group> getNodes(String parentId);
|
||||
List<Group> getNodes(@Param("parentId") String parentId);
|
||||
|
||||
@Select(" select * from wvp_common_group " +
|
||||
" WHERE common_group_id = #{id} ")
|
||||
Group query(int id);
|
||||
Group queryOne(@Param("id") int id);
|
||||
|
||||
@Select(" select * from wvp_common_group " +
|
||||
" WHERE common_group_device_id = #{deviceId} ")
|
||||
Group queryByDeviceId(String deviceId);
|
||||
Group queryByDeviceId(@Param("deviceId") String deviceId);
|
||||
|
||||
@Insert("INSERT INTO wvp_common_group (" +
|
||||
"common_group_device_id, " +
|
||||
|
@ -41,14 +41,14 @@ public interface GroupMapper {
|
|||
"#{commonGroupTopId}, " +
|
||||
"#{commonGroupUpdateTime}, " +
|
||||
"#{commonGroupCreateTime})")
|
||||
int add(Group group);
|
||||
int add(@Param("group") Group group);
|
||||
|
||||
@Delete("delete from wvp_common_group where common_group_id = #{id}")
|
||||
int remove(int id);
|
||||
int remove(@Param("id") int id);
|
||||
|
||||
|
||||
@Delete("delete from wvp_common_group where common_group_device_id = #{deviceId}")
|
||||
int removeByDeviceId(String deviceId);
|
||||
int removeByDeviceId(@Param("deviceId") String deviceId);
|
||||
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
|
@ -61,7 +61,7 @@ public interface GroupMapper {
|
|||
"<if test='commonGroupUpdateTime != null'>, common_group_update_time=#{commonGroupUpdateTime}</if>" +
|
||||
"WHERE common_group_id=#{commonGroupId}" +
|
||||
" </script>"})
|
||||
int update(Group Group);
|
||||
int update(@Param("Group") Group Group);
|
||||
|
||||
|
||||
@Insert(value = "<script>" +
|
||||
|
@ -86,11 +86,31 @@ public interface GroupMapper {
|
|||
") " +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int addAll(List<Group> allGroup);
|
||||
int addAll(@Param("allGroup") List<Group> allGroup);
|
||||
|
||||
@Select("<script> "+
|
||||
"SELECT * FROM wvp_common_group WHERE common_group_device_id in" +
|
||||
"<foreach collection='allGroup' item='item' open='(' separator=',' close=')' > #{item.commonGroupDeviceId}</foreach>" +
|
||||
"</script>")
|
||||
List<Group> queryInList(List<Group> allGroup);
|
||||
List<Group> queryInList(@Param("allGroup") List<Group> allGroup);
|
||||
|
||||
@Select("<script> "+
|
||||
"select * from wvp_common_group where 1=1 " +
|
||||
"<if test='query != null'> and (common_group_device_id LIKE concat('%',#{query},'%') or common_group_name LIKE concat('%',#{query},'%') ) </if>" +
|
||||
"</script>")
|
||||
List<Group> query(@Param("query") String query);
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
" UPDATE wvp_common_group " +
|
||||
" SET" +
|
||||
" common_group_parent_id=#{newParentDeviceId}" +
|
||||
" WHERE common_group_parent_id=#{oldParentDeviceId}" +
|
||||
" </script>"})
|
||||
void updateParentDeviceId(@Param("oldParentDeviceId") String oldParentDeviceId, @Param("newParentDeviceId") String newParentDeviceId);
|
||||
|
||||
@Select("<script> "+
|
||||
"select * from wvp_common_group where common_group_parent_id = #{groupParentId} " +
|
||||
"</script>")
|
||||
List<Group> queryChildGroupList(String groupParentId);
|
||||
|
||||
}
|
||||
|
|
|
@ -11,28 +11,28 @@ public interface RegionMapper {
|
|||
List<Region> getChildren(@Param("parentDeviceId") String parentDeviceId);
|
||||
|
||||
@Insert("INSERT INTO wvp_common_region (" +
|
||||
"common_region_device_id, " +
|
||||
"common_region_name, " +
|
||||
"common_region_parent_id, " +
|
||||
"common_region_path, " +
|
||||
"common_region_create_time, " +
|
||||
"common_region_update_time ) " +
|
||||
"VALUES (" +
|
||||
"#{commonRegionDeviceId}, " +
|
||||
"#{commonRegionName}, " +
|
||||
"#{commonRegionParentId}, " +
|
||||
"#{commonRegionPath}, " +
|
||||
"#{commonRegionCreateTime}, " +
|
||||
"#{commonRegionUpdateTime})")
|
||||
" common_region_device_id, " +
|
||||
" common_region_name, " +
|
||||
" common_region_parent_id, " +
|
||||
" common_region_path, " +
|
||||
" common_region_create_time, " +
|
||||
" common_region_update_time ) " +
|
||||
" VALUES (" +
|
||||
" #{commonRegionDeviceId}, " +
|
||||
" #{commonRegionName}, " +
|
||||
" #{commonRegionParentId}, " +
|
||||
" #{commonRegionPath}, " +
|
||||
" #{commonRegionCreateTime}, " +
|
||||
" #{commonRegionUpdateTime})")
|
||||
int add(Region region);
|
||||
|
||||
@Delete("delete from wvp_common_region where common_region_device_id = #{regionDeviceId}")
|
||||
int deleteByDeviceId(@Param("regionDeviceId") String regionDeviceId);
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
"UPDATE wvp_common_region " +
|
||||
"SET common_region_update_time=#{updateTime}, common_region_name=#{name}" +
|
||||
"WHERE common_region_device_id=#{regionDeviceId}" +
|
||||
" UPDATE wvp_common_region " +
|
||||
" SET common_region_update_time=#{updateTime}, common_region_name=#{name}" +
|
||||
" HERE common_region_device_id=#{regionDeviceId}" +
|
||||
" </script>"})
|
||||
int updateRegionName(@Param("name") String name, @Param("updateTime") String updateTime, @Param("regionDeviceId") String regionDeviceId);
|
||||
|
||||
|
@ -69,8 +69,36 @@ public interface RegionMapper {
|
|||
" UPDATE" +
|
||||
" wvp_common_region" +
|
||||
" SET common_region_name=#{item.commonRegionName}" +
|
||||
"WHERE common_region_device_id=#{item.commonRegionDeviceId}"+
|
||||
" WHERE common_region_device_id=#{item.commonRegionDeviceId}"+
|
||||
"</foreach>" +
|
||||
"</script>"})
|
||||
void updateAllForName(List<Region> regionInForUpdate);
|
||||
|
||||
@Select("select * from wvp_common_region where common_region_id = #{commonRegionId}")
|
||||
Region queryRegion(@Param("commonRegionId") int commonRegionId);
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
" UPDATE wvp_common_region " +
|
||||
" SET" +
|
||||
" common_region_update_time=#{commonRegionUpdateTime}," +
|
||||
" common_region_device_id=#{commonRegionDeviceId}," +
|
||||
" common_region_name=#{commonRegionName}," +
|
||||
" common_region_parent_id=#{commonRegionParentId}" +
|
||||
" WHERE common_region_id=#{commonRegionId}" +
|
||||
" </script>"})
|
||||
void update(@Param("region") Region region);
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
" UPDATE wvp_common_region " +
|
||||
" SET" +
|
||||
" common_region_parent_id=#{commonRegionDeviceIdForNew}" +
|
||||
" WHERE common_region_parent_id=#{commonRegionDeviceIdForOld}" +
|
||||
" </script>"})
|
||||
void updateChild(@Param("commonRegionDeviceIdForOld") String commonRegionDeviceIdForOld,
|
||||
@Param("commonRegionDeviceIdForNew") String commonRegionDeviceIdForNew);
|
||||
@Select("<script> "+
|
||||
"select * from wvp_common_region where 1=1 " +
|
||||
"<if test='query != null'> and (common_region_device_id LIKE concat('%',#{query},'%') or common_region_name LIKE concat('%',#{query},'%') ) </if>" +
|
||||
"</script>")
|
||||
List<Region> query(String query);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.vmanager.channel;
|
|||
|
||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||
import com.genersoft.iot.vmp.service.ICommonGbChannelService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
|
@ -26,29 +27,35 @@ public class CommonChannelController {
|
|||
private ICommonGbChannelService commonGbChannelService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询区域下的通道
|
||||
*
|
||||
* @param civilCode 区域编号
|
||||
*/
|
||||
@GetMapping("/region/list")
|
||||
@Operation(summary = "查询区域下的通道")
|
||||
@Parameter(name = "civilCode", description = "区域编号")
|
||||
public List<CommonGbChannel> getChannelsInRegion(String civilCode) {
|
||||
return commonGbChannelService.getChannelsInRegion(civilCode);
|
||||
@Parameter(name = "regionDeviceId", description = "区域的编号", required = true)
|
||||
@Parameter(name = "query", description = "要搜索的内容", required = false)
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||
@GetMapping("/region/list")
|
||||
public PageInfo<CommonGbChannel> getChannelsInRegion(
|
||||
@RequestParam(required = true) String regionDeviceId,
|
||||
@RequestParam(required = false) String query,
|
||||
@RequestParam(required = true) int page,
|
||||
@RequestParam(required = true) int count
|
||||
) {
|
||||
return commonGbChannelService.getChannelsInRegion(regionDeviceId, query, page, count);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询分组下的通道
|
||||
*
|
||||
* @param businessGroupID 业务分组ID
|
||||
*/
|
||||
@GetMapping("/group/list")
|
||||
@Operation(summary = "查询分组下的通道")
|
||||
@Parameter(name = "businessGroupID", description = "业务分组ID")
|
||||
public List<CommonGbChannel> getChannelsInBusinessGroup(String businessGroupID) {
|
||||
return commonGbChannelService.getChannelsInBusinessGroup(businessGroupID);
|
||||
@Parameter(name = "groupDeviceId", description = "分组的编号", required = true)
|
||||
@Parameter(name = "query", description = "要搜索的内容", required = false)
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||
@ResponseBody
|
||||
@GetMapping("/group/list")
|
||||
public PageInfo<CommonGbChannel> queryChannelListInGroup(
|
||||
@RequestParam(required = true) String groupDeviceId,
|
||||
@RequestParam(required = false) String query,
|
||||
@RequestParam(required = true) int page,
|
||||
@RequestParam(required = true) int count ){
|
||||
|
||||
return commonGbChannelService.queryChannelListInGroup(groupDeviceId, query, page, count);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,10 +70,32 @@ public class CommonChannelController {
|
|||
public boolean syncFromDevice(String deviceId, String[] syncKeys,
|
||||
@RequestParam(required = false) Boolean syncGroup,
|
||||
@RequestParam(required = false) Boolean syncRegion) {
|
||||
System.out.println("deviceId===" + deviceId);
|
||||
System.out.println("syncKeys===" + Arrays.toString(syncKeys));
|
||||
System.out.println("syncGroup===" + syncGroup);
|
||||
System.out.println("syncRegion===" + syncRegion);
|
||||
return commonGbChannelService.syncChannelFromGb28181Device(deviceId, Lists.newArrayList(syncKeys), syncGroup, syncRegion);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "分页查询通道")
|
||||
@Parameter(name = "query", description = "要搜索的内容", required = false)
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
public PageInfo<CommonGbChannel> queryChannelList(
|
||||
@RequestParam(required = false) String query,
|
||||
@RequestParam(required = true) int page,
|
||||
@RequestParam(required = true) int count ){
|
||||
|
||||
return commonGbChannelService.queryChannelList(query, page, count);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新通道")
|
||||
@Parameter(name = "CommonGbChannel", description = "commonGbChannel", required = true)
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
public void update(
|
||||
@RequestParam(required = false) CommonGbChannel commonGbChannel
|
||||
){
|
||||
commonGbChannelService.update(commonGbChannel);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
package com.genersoft.iot.vmp.vmanager.group;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.service.IGroupService;
|
||||
import com.genersoft.iot.vmp.service.bean.Group;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.PageInfo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "分组管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/group")
|
||||
public class GroupController {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(GroupController.class);
|
||||
|
||||
@Autowired
|
||||
private IGroupService groupService;
|
||||
|
||||
@Operation(summary = "添加区域")
|
||||
@Parameter(name = "group", description = "Group", required = true)
|
||||
@ResponseBody
|
||||
@PostMapping("/add")
|
||||
public void add(@RequestBody Group group){
|
||||
groupService.add(group);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询区域")
|
||||
@Parameter(name = "query", description = "查询内容", required = true)
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
public PageInfo<Group> queryGroup(
|
||||
@RequestParam(required = false) String query,
|
||||
@RequestParam(required = true) int page,
|
||||
@RequestParam(required = true) int count
|
||||
){
|
||||
return groupService.queryGroup(query, page, count);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新区域")
|
||||
@Parameter(name = "group", description = "Group", required = true)
|
||||
@ResponseBody
|
||||
@PostMapping("/update")
|
||||
public void updateGroup(@RequestBody Group group){
|
||||
groupService.update(group);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除区域")
|
||||
@Parameter(name = "groupDeviceId", description = "待删除的节点编号", required = true)
|
||||
@ResponseBody
|
||||
@DeleteMapping("/delete")
|
||||
public void deleteGroup(String groupDeviceId){
|
||||
boolean result = groupService.remove(groupDeviceId);
|
||||
if (!result) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "移除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "查询区域的子节点")
|
||||
@Parameter(name = "groupParentId", description = "待查询的节点", required = true)
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||
@ResponseBody
|
||||
@GetMapping("/child/list")
|
||||
public PageInfo<Group> queryChildGroupList(
|
||||
@RequestParam(required = true) String groupParentId,
|
||||
@RequestParam(required = true) int page,
|
||||
@RequestParam(required = true) int count
|
||||
){
|
||||
return groupService.queryChildGroupList(groupParentId, page, count);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package com.genersoft.iot.vmp.vmanager.region;
|
||||
|
||||
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.vmanager.bean.PageInfo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "行政区划管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/region")
|
||||
public class RegionController {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(RegionController.class);
|
||||
|
||||
@Autowired
|
||||
private IRegionService regionService;
|
||||
|
||||
@Operation(summary = "添加区域")
|
||||
@Parameter(name = "region", description = "Region", required = true)
|
||||
@ResponseBody
|
||||
@PostMapping("/add")
|
||||
public void add(@RequestBody Region region){
|
||||
regionService.add(region);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询区域")
|
||||
@Parameter(name = "query", description = "要搜索的内容", required = true)
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
public PageInfo<Region> query(
|
||||
@RequestParam(required = false) String query,
|
||||
@RequestParam(required = true) int page,
|
||||
@RequestParam(required = true) int count
|
||||
){
|
||||
return regionService.query(query, page, count);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新区域")
|
||||
@Parameter(name = "region", description = "Region", required = true)
|
||||
@ResponseBody
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody Region region){
|
||||
regionService.update(region);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除区域")
|
||||
@Parameter(name = "regionDeviceId", description = "区域编码", required = true)
|
||||
@ResponseBody
|
||||
@DeleteMapping("/delete")
|
||||
public void delete(@RequestBody String regionDeviceId){
|
||||
regionService.deleteByDeviceId(regionDeviceId);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页区域子节点")
|
||||
@Parameter(name = "regionParentId", description = "行政区划父节点编号", required = true)
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||
@ResponseBody
|
||||
@GetMapping("/child/list")
|
||||
public PageInfo<Region> queryChildGroupList(
|
||||
@RequestParam(required = true) String regionParentId,
|
||||
@RequestParam(required = true) int page,
|
||||
@RequestParam(required = true) int count
|
||||
){
|
||||
return regionService.queryChildGroupList(regionParentId, page, count);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue