添加资源管理
parent
ca89fe85b7
commit
0701791902
|
@ -45,10 +45,10 @@ CREATE TABLE `wvp_common_business_group`
|
|||
`common_business_group_id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
||||
`common_business_group_device_id` varchar(50) NOT NULL,
|
||||
`common_business_group_name` varchar(255) NOT NULL,
|
||||
`common_business_group_civilCode` varchar(50) DEFAULT NULL,
|
||||
`common_business_group_parent_id` varchar(50) DEFAULT NULL,
|
||||
`common_business_group_path` varchar(500) DEFAULT NULL,
|
||||
`type` varchar(255) NOT NULL,
|
||||
`common_business_group_create_time` varchar(50) NOT NULL,
|
||||
`common_business_group_update_time` varchar(50) NOT NULL,
|
||||
PRIMARY KEY (`common_business_group_id`),
|
||||
UNIQUE KEY `common_business_group_device_id` (`common_business_group_device_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
@ -60,6 +60,8 @@ CREATE TABLE `wvp_common_region`
|
|||
`common_region_name` varchar(255) NOT NULL,
|
||||
`common_region_parent_id` varchar(50) DEFAULT NULL,
|
||||
`common_region_path` varchar(255) NOT NULL,
|
||||
`common_region_create_time` varchar(50) NOT NULL,
|
||||
`common_region_update_time` varchar(50) NOT NULL,
|
||||
PRIMARY KEY (`common_region_id`),
|
||||
UNIQUE KEY `common_region_device_id` (`common_region_device_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
@ -67,22 +69,26 @@ CREATE TABLE `wvp_common_region`
|
|||
CREATE TABLE `wvp_common_platform_channel`
|
||||
(
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
||||
`platform_id` varchar(50) DEFAULT NULL,
|
||||
`common_gb_channel_id` int DEFAULT NULL,
|
||||
`platform_id` varchar(50) NOT NULL,
|
||||
`common_gb_channel_id` varchar(50) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id` (`id`),
|
||||
UNIQUE KEY `uk_platform_id_common_gb_channel_id` (`platform_id`,`common_gb_channel_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_0900_ai_ci;
|
||||
|
||||
CREATE TABLE `wvp_common_platform_region`
|
||||
(
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
||||
`platform_id` varchar(50) DEFAULT NULL,
|
||||
`region_id` int DEFAULT NULL,
|
||||
`platform_id` varchar(50) NOT NULL,
|
||||
`region_id` varchar(50) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id` (`id`),
|
||||
UNIQUE KEY `uk_platform_region_id` (`platform_id`,`region_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_0900_ai_ci;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package com.genersoft.iot.vmp.service;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||
import com.genersoft.iot.vmp.service.bean.BusinessGroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务分组
|
||||
*/
|
||||
public interface IBusinessGroupService {
|
||||
|
||||
/**
|
||||
* 查询业务分组
|
||||
*/
|
||||
List<BusinessGroup> getNodes(String parentId);
|
||||
|
||||
/**
|
||||
* 查询业务分组下的通道
|
||||
*/
|
||||
List<CommonGbChannel> getChannels(int id);
|
||||
|
||||
/**
|
||||
* 查询业务分组下的通道
|
||||
*/
|
||||
List<CommonGbChannel> getChannels(String deviceId);
|
||||
|
||||
/**
|
||||
* 添加业务分组
|
||||
*/
|
||||
boolean add(BusinessGroup businessGroup);
|
||||
|
||||
/**
|
||||
* 移除业务分组
|
||||
*/
|
||||
boolean remove(int id);
|
||||
|
||||
/**
|
||||
* 移除业务分组
|
||||
*/
|
||||
boolean remove(String deviceId);
|
||||
|
||||
/**
|
||||
* 更新业务分组
|
||||
*/
|
||||
boolean update(BusinessGroup businessGroup);
|
||||
|
||||
/**
|
||||
* 设置国标设备到相关的分组中
|
||||
*/
|
||||
boolean updateChannelsToBusinessGroup(int id, List<CommonGbChannel> channels);
|
||||
|
||||
/**
|
||||
* 设置国标设备到相关的分组中
|
||||
*/
|
||||
boolean updateChannelsToBusinessGroup(String deviceId, List<CommonGbChannel> channels);
|
||||
|
||||
/**
|
||||
* 移除分组分组中的通道
|
||||
*/
|
||||
boolean removeChannelsFromBusinessGroup(List<CommonGbChannel> channels);
|
||||
|
||||
|
||||
}
|
|
@ -13,4 +13,14 @@ public interface ICommonGbChannelService {
|
|||
int update(CommonGbChannel channel);
|
||||
|
||||
boolean checkChannelInPlatform(String channelId, String platformServerId);
|
||||
|
||||
/**
|
||||
* 从国标设备中同步通道
|
||||
*
|
||||
* @param gbDeviceId 国标设备编号
|
||||
* @param syncCoordinate 是否同步位置信息,TRUE 则使用国标设备里的位置信息, 第一次同步按照TRUE执行,此参数无效
|
||||
* @param syncBusinessGroup 是否同步业务分组,TRUE则使用国标设备的业务分组
|
||||
* @param syncRegion 是否同步行政区划,TRUE则使用国标设备的行政区划
|
||||
*/
|
||||
boolean SyncChannelFromGb28181Device(String gbDeviceId, boolean syncCoordinate, boolean syncBusinessGroup, boolean syncRegion);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
package com.genersoft.iot.vmp.service.bean;
|
||||
|
||||
/**
|
||||
* 业务分组数据
|
||||
*/
|
||||
public class BusinessGroup {
|
||||
|
||||
/**
|
||||
* 数据库自增ID
|
||||
*/
|
||||
private int commonBusinessGroupId;
|
||||
|
||||
/**
|
||||
* 分组国标编号
|
||||
*/
|
||||
private String commonBusinessGroupDeviceId;
|
||||
|
||||
/**
|
||||
* 分组名称
|
||||
*/
|
||||
private String commonBusinessGroupName;
|
||||
|
||||
/**
|
||||
* 分组名称
|
||||
*/
|
||||
private String commonBusinessGroupParentId;
|
||||
|
||||
/**
|
||||
* 分组树的路径
|
||||
*/
|
||||
private String commonBusinessGroupPath;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String commonBusinessGroupCreateTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private String commonBusinessGroupUpdateTime;
|
||||
|
||||
public int getCommonBusinessGroupId() {
|
||||
return commonBusinessGroupId;
|
||||
}
|
||||
|
||||
public void setCommonBusinessGroupId(int commonBusinessGroupId) {
|
||||
this.commonBusinessGroupId = commonBusinessGroupId;
|
||||
}
|
||||
|
||||
public String getCommonBusinessGroupDeviceId() {
|
||||
return commonBusinessGroupDeviceId;
|
||||
}
|
||||
|
||||
public void setCommonBusinessGroupDeviceId(String commonBusinessGroupDeviceId) {
|
||||
this.commonBusinessGroupDeviceId = commonBusinessGroupDeviceId;
|
||||
}
|
||||
|
||||
public String getCommonBusinessGroupName() {
|
||||
return commonBusinessGroupName;
|
||||
}
|
||||
|
||||
public void setCommonBusinessGroupName(String commonBusinessGroupName) {
|
||||
this.commonBusinessGroupName = commonBusinessGroupName;
|
||||
}
|
||||
|
||||
public String getCommonBusinessGroupPath() {
|
||||
return commonBusinessGroupPath;
|
||||
}
|
||||
|
||||
public void setCommonBusinessGroupPath(String commonBusinessGroupPath) {
|
||||
this.commonBusinessGroupPath = commonBusinessGroupPath;
|
||||
}
|
||||
|
||||
public String getCommonBusinessGroupParentId() {
|
||||
return commonBusinessGroupParentId;
|
||||
}
|
||||
|
||||
public void setCommonBusinessGroupParentId(String commonBusinessGroupParentId) {
|
||||
this.commonBusinessGroupParentId = commonBusinessGroupParentId;
|
||||
}
|
||||
|
||||
public String getCommonBusinessGroupCreateTime() {
|
||||
return commonBusinessGroupCreateTime;
|
||||
}
|
||||
|
||||
public void setCommonBusinessGroupCreateTime(String commonBusinessGroupCreateTime) {
|
||||
this.commonBusinessGroupCreateTime = commonBusinessGroupCreateTime;
|
||||
}
|
||||
|
||||
public String getCommonBusinessGroupUpdateTime() {
|
||||
return commonBusinessGroupUpdateTime;
|
||||
}
|
||||
|
||||
public void setCommonBusinessGroupUpdateTime(String commonBusinessGroupUpdateTime) {
|
||||
this.commonBusinessGroupUpdateTime = commonBusinessGroupUpdateTime;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
package com.genersoft.iot.vmp.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||
import com.genersoft.iot.vmp.service.IBusinessGroupService;
|
||||
import com.genersoft.iot.vmp.service.bean.BusinessGroup;
|
||||
import com.genersoft.iot.vmp.storager.dao.BusinessGroupMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class BusinessGroupServiceImpl implements IBusinessGroupService {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(BusinessGroupServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private CommonGbChannelMapper commonGbChannelDao;
|
||||
|
||||
@Autowired
|
||||
private BusinessGroupMapper businessGroupDao;
|
||||
|
||||
@Autowired
|
||||
DataSourceTransactionManager dataSourceTransactionManager;
|
||||
|
||||
@Autowired
|
||||
TransactionDefinition transactionDefinition;
|
||||
|
||||
|
||||
@Override
|
||||
public List<BusinessGroup> getNodes(String parentId) {
|
||||
return businessGroupDao.getNodes(parentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommonGbChannel> getChannels(int id) {
|
||||
BusinessGroup businessGroup = businessGroupDao.query(id);
|
||||
if (businessGroup == null) {
|
||||
return null;
|
||||
}
|
||||
return commonGbChannelDao.getChannels(businessGroup.getCommonBusinessGroupPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommonGbChannel> getChannels(String deviceId) {
|
||||
BusinessGroup businessGroup = businessGroupDao.queryByDeviceId(deviceId);
|
||||
if (businessGroup == null) {
|
||||
return null;
|
||||
}
|
||||
return commonGbChannelDao.getChannels(businessGroup.getCommonBusinessGroupPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(BusinessGroup businessGroup) {
|
||||
return businessGroupDao.add(businessGroup) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(int id) {
|
||||
return businessGroupDao.remove(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(String deviceId) {
|
||||
return businessGroupDao.removeByDeviceId(deviceId) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(BusinessGroup businessGroup) {
|
||||
if (businessGroup.getCommonBusinessGroupId() == 0) {
|
||||
return false;
|
||||
}
|
||||
BusinessGroup businessGroupInDb = businessGroupDao.query(businessGroup.getCommonBusinessGroupId());
|
||||
if (businessGroupInDb == null) {
|
||||
return false;
|
||||
}
|
||||
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
|
||||
boolean result = false;
|
||||
if (!businessGroupInDb.getCommonBusinessGroupPath().equals(businessGroup.getCommonBusinessGroupPath())) {
|
||||
// 需要更新通道信息
|
||||
int updateCount = commonGbChannelDao.updateBusinessGroupPath(businessGroup.getCommonBusinessGroupPath());
|
||||
if (updateCount > 0) {
|
||||
dataSourceTransactionManager.rollback(transactionStatus);
|
||||
return false;
|
||||
} else {
|
||||
result = businessGroupDao.update(businessGroup) > 0;
|
||||
}
|
||||
} else {
|
||||
result = businessGroupDao.update(businessGroup) > 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateChannelsToBusinessGroup(int id, List<CommonGbChannel> channels) {
|
||||
if (channels.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
BusinessGroup businessGroup = businessGroupDao.query(id);
|
||||
if (businessGroup == null) {
|
||||
return false;
|
||||
}
|
||||
for (CommonGbChannel channel : channels) {
|
||||
channel.setCommonGbBusinessGroupID(businessGroup.getCommonBusinessGroupPath());
|
||||
}
|
||||
// TODO 增加对数量的判断,分批处理
|
||||
return commonGbChannelDao.updateChanelForBusinessGroup(channels) > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateChannelsToBusinessGroup(String deviceId, List<CommonGbChannel> channels) {
|
||||
if (channels.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
BusinessGroup businessGroup = businessGroupDao.queryByDeviceId(deviceId);
|
||||
if (businessGroup == null) {
|
||||
return false;
|
||||
}
|
||||
for (CommonGbChannel channel : channels) {
|
||||
channel.setCommonGbBusinessGroupID(businessGroup.getCommonBusinessGroupPath());
|
||||
}
|
||||
// TODO 增加对数量的判断,分批处理
|
||||
return commonGbChannelDao.updateChanelForBusinessGroup(channels) > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeChannelsFromBusinessGroup(List<CommonGbChannel> channels) {
|
||||
// TODO 增加对数量的判断,分批处理
|
||||
return commonGbChannelDao.removeChannelsForBusinessGroup(channels) > 1;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,33 +1,57 @@
|
|||
package com.genersoft.iot.vmp.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.service.ICommonGbChannelService;
|
||||
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
|
||||
|
||||
@Autowired
|
||||
private CommonGbChannelMapper commonGbChannelMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceChannelMapper deviceChannelMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public CommonGbChannel getChannel(String channelId) {
|
||||
return null;
|
||||
return commonGbChannelMapper.queryByDeviceID(channelId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int add(CommonGbChannel channel) {
|
||||
return 0;
|
||||
return commonGbChannelMapper.add(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(String channelId) {
|
||||
return 0;
|
||||
return commonGbChannelMapper.deleteByDeviceID(channelId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(CommonGbChannel channel) {
|
||||
return 0;
|
||||
return commonGbChannelMapper.update(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkChannelInPlatform(String channelId, String platformServerId) {
|
||||
return commonGbChannelMapper.checkChannelInPlatform(channelId, platformServerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean SyncChannelFromGb28181Device(String gbDeviceId, boolean syncCoordinate, boolean syncBusinessGroup, boolean syncRegion) {
|
||||
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryAllChannels(gbDeviceId);
|
||||
if (deviceChannels.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.service.bean.BusinessGroup;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface BusinessGroupMapper {
|
||||
|
||||
@Select(value = {" <script>" +
|
||||
" select * from wvp_common_business_group " +
|
||||
" WHERE 1=1 " +
|
||||
" <if test='parentId != null' > AND common_business_group_parent_id = #{parentId}</if>" +
|
||||
" <if test='parentId == null' > AND common_business_group_parent_id is null </if>" +
|
||||
" order by common_business_group_id ASC " +
|
||||
" </script>"})
|
||||
List<BusinessGroup> getNodes(String parentId);
|
||||
|
||||
@Select(" select * from wvp_common_business_group " +
|
||||
" WHERE common_business_group_id = #{id} ")
|
||||
BusinessGroup query(int id);
|
||||
|
||||
@Select(" select * from wvp_common_business_group " +
|
||||
" WHERE common_business_group_device_id = #{deviceId} ")
|
||||
BusinessGroup queryByDeviceId(String deviceId);
|
||||
|
||||
@Insert("INSERT INTO wvp_common_business_group (" +
|
||||
"common_business_group_device_id, " +
|
||||
"common_business_group_name, " +
|
||||
"common_business_group_parent_id, " +
|
||||
"common_business_group_path, " +
|
||||
"common_business_group_update_time, " +
|
||||
"common_business_group_create_time ) " +
|
||||
"VALUES (" +
|
||||
"#{commonBusinessGroupDeviceId}, " +
|
||||
"#{commonBusinessGroupName}, " +
|
||||
"#{commonBusinessGroupParentId}, " +
|
||||
"#{commonBusinessGroupPath}, " +
|
||||
"#{commonBusinessGroupUpdateTime}, " +
|
||||
"#{commonBusinessGroupCreateTime})")
|
||||
int add(BusinessGroup businessGroup);
|
||||
|
||||
@Delete("delete from wvp_common_business_group where common_business_group_id = #{id}")
|
||||
int remove(int id);
|
||||
|
||||
|
||||
@Delete("delete from wvp_common_business_group where common_business_group_device_id = #{deviceId}")
|
||||
int removeByDeviceId(String deviceId);
|
||||
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
"UPDATE wvp_common_business_group " +
|
||||
"SET common_business_group_update_time=#{commonBusinessGroupUpdateTime}" +
|
||||
"<if test='commonBusinessGroupName != null'>, common_business_group_name=#{commonBusinessGroupName}</if>" +
|
||||
"<if test='commonBusinessGroupDeviceId != null'>, common_business_group_device_id=#{commonBusinessGroupDeviceId}</if>" +
|
||||
"<if test='commonBusinessGroupParentId != null'>, common_business_group_parent_id=#{commonBusinessGroupParentId}</if>" +
|
||||
"<if test='commonBusinessGroupPath != null'>, common_business_group_path=#{commonBusinessGroupPath}</if>" +
|
||||
"<if test='commonBusinessGroupUpdateTime != null'>, common_business_group_update_time=#{commonBusinessGroupUpdateTime}</if>" +
|
||||
"WHERE common_business_group_id=#{commonBusinessGroupId}" +
|
||||
" </script>"})
|
||||
int update(BusinessGroup businessGroup);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface CommonGbChannelMapper {
|
||||
List<CommonGbChannel> getChannels(String commonBusinessGroupPath);
|
||||
|
||||
int updateChanelForBusinessGroup(List<CommonGbChannel> channels);
|
||||
|
||||
int removeChannelsForBusinessGroup(List<CommonGbChannel> channels);
|
||||
|
||||
int updateBusinessGroupPath(String commonBusinessGroupPath);
|
||||
|
||||
CommonGbChannel queryByDeviceID(String channelId);
|
||||
|
||||
int add(CommonGbChannel channel);
|
||||
|
||||
int deleteByDeviceID(String channelId);
|
||||
|
||||
int update(CommonGbChannel channel);
|
||||
|
||||
boolean checkChannelInPlatform(String channelId, String platformServerId);
|
||||
}
|
Loading…
Reference in New Issue