支持自动同步国标通道到通用通道,分组信息以及行政区划自动同步

结构优化
648540858 2023-10-04 00:59:16 +08:00
parent 8f7673a083
commit 6255e6f89f
19 changed files with 840 additions and 261 deletions

View File

@ -42,18 +42,16 @@ CREATE TABLE `wvp_common_gb_channel`
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `wvp_common_business_group`
CREATE TABLE `wvp_common_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_parent_id` varchar(50) DEFAULT NULL,
`common_business_group_path` varchar(500) DEFAULT NULL,
`common_business_group_gb_parent_id` varchar(500) DEFAULT 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`)
`common_group_id` bigint unsigned NOT NULL AUTO_INCREMENT,
`common_group_device_id` varchar(50) NOT NULL,
`common_group_name` varchar(255) NOT NULL,
`common_group_parent_id` varchar(50) DEFAULT NULL,
`common_group_create_time` varchar(50) NOT NULL,
`common_group_update_time` varchar(50) NOT NULL,
PRIMARY KEY (`common_group_id`),
UNIQUE KEY `common_group_device_id` (`common_group_device_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `wvp_common_region`
@ -62,7 +60,6 @@ CREATE TABLE `wvp_common_region`
`common_region_device_id` varchar(50) NOT NULL,
`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`),
@ -83,7 +80,7 @@ CREATE TABLE `wvp_common_platform_channel`
CREATE TABLE `wvp_common_platform_region`
(
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`platform_id` varchar(50) NOT NULL,
`region_id` varchar(50) NOT NULL,
PRIMARY KEY (`id`),

View File

@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.conf;
import com.genersoft.iot.vmp.common.CivilCodePo;
import com.genersoft.iot.vmp.service.bean.Region;
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -101,4 +102,24 @@ public class CivilCodeFileConf implements CommandLineRunner {
}
public Region createRegion(String code) {
if (code.length() > 8) {
return null;
}
if (code.length() == 8) {
String parentCode = code.substring(0, 6);
return Region.getInstance(code, "未知地区_" + code, parentCode);
}else {
CivilCodePo civilCodePo = civilCodeMap.get(code);
if (civilCodePo == null){
return null;
}
String parentCode = civilCodePo.getParentCode();
if (parentCode == null) {
return null;
}
return Region.getInstance(code, civilCodePo.getName(), parentCode);
}
}
}

View File

@ -1,23 +0,0 @@
package com.genersoft.iot.vmp.gb28181.bean;
/**
* ,11-13
* D A
* @author lin
*/
public class ChannelIdType {
/**
*
*/
public final static String CENTRAL_SIGNALING_CONTROL_SERVER = "200";
/**
*
*/
public final static String BUSINESS_GROUP = "215";
/**
*
*/
public final static String VIRTUAL_ORGANIZATION = "216";
}

View File

@ -0,0 +1,43 @@
package com.genersoft.iot.vmp.gb28181.bean;
import com.genersoft.iot.vmp.common.enums.DeviceControlType;
import org.dom4j.Element;
import org.springframework.util.ObjectUtils;
public enum Gb28181CodeType {
CIVIL_CODE_PROVINCE("CIVIL_CODE_PROVINCE","省级编号"),
CIVIL_CODE_CITY("CIVIL_CODE_CITY","市级编号"),
CIVIL_CODE_COUNTY("CIVIL_CODE_GRASS_ROOTS","区级编号"),
CIVIL_CODE_GRASS_ROOTS("CIVIL_CODE_GRASS_ROOTS","基层接入单位编号"),
BUSINESS_GROUP("BUSINESS_GROUP","业务分组"),
VIRTUAL_ORGANIZATION("VIRTUAL_ORGANIZATION","虚拟组织")
;
private final String val;
private final String desc;
Gb28181CodeType(String val, String desc) {
this.val = val;
this.desc = desc;
}
public String getVal() {
return val;
}
public String getDesc() {
return desc;
}
public static DeviceControlType typeOf(Element rootElement) {
for (DeviceControlType item : DeviceControlType.values()) {
if (!ObjectUtils.isEmpty(rootElement.element(item.getVal())) || !ObjectUtils.isEmpty(rootElement.elements(item.getVal()))) {
return item;
}
}
return null;
}
}

View File

@ -141,12 +141,11 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
// 数据已经完整接收, 此时可能存在某个设备离线变上线的情况,但是考虑到性能,此处不做处理,
// 目前支持设备通道上线通知时和设备上线时向上级通知
boolean resetChannelsResult = deviceChannelService.resetChannels(take.getDevice(), catalogDataCatch.get(take.getDevice().getDeviceId()));
String errorMsg = null;
if (!resetChannelsResult) {
String errorMsg = "接收成功,写入失败,共" + sumNum + "条,已接收" + catalogDataCatch.get(take.getDevice().getDeviceId()).size() + "条";
catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), errorMsg);
} else {
catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), null);
errorMsg = "接收成功,写入失败,共" + sumNum + "条,已接收" + catalogDataCatch.get(take.getDevice().getDeviceId()).size() + "条";
}
catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), errorMsg);
}
}

View File

@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.gb28181.utils;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.Gb28181CodeType;
import com.genersoft.iot.vmp.gb28181.bean.Gb28181Sdp;
import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo;
import com.genersoft.iot.vmp.utils.DateUtil;
@ -263,4 +264,46 @@ public class SipUtils {
}
return localDateTime.format(DateUtil.formatter);
}
public static Gb28181CodeType getChannelIdType(String channelId) {
int length = channelId.length();
if (length <= 8) {
// 行政区划
switch (length){
case 2:
return Gb28181CodeType.CIVIL_CODE_PROVINCE;
case 4:
return Gb28181CodeType.CIVIL_CODE_CITY;
case 6:
return Gb28181CodeType.CIVIL_CODE_COUNTY;
case 8:
return Gb28181CodeType.CIVIL_CODE_GRASS_ROOTS;
default:
logger.warn("[不规范编号] 编号: {} 长度: {}, 类型判定失败", channelId, length);
return null;
}
}else {
if (length != 20) {
logger.warn("[不规范编号] 编号: {} 长度: {}, 尝试类型判定", channelId, length);
}
if (length < 13) {
logger.warn("[不规范编号] 编号: {} 长度: {}, 无法获取类型编码11、12、13类型判定失败", channelId, length);
return null;
}
String codeTypeStr = channelId.substring(10, 13);
if (!NumericUtil.isInteger(codeTypeStr)) {
logger.warn("[不规范编号] 编号: {} 长度: {}, 类型编码11、12、13存在非数字类型判定失败", channelId, length);
return null;
}
int codeType = Integer.parseInt(codeTypeStr);
switch (codeType){
case 215:
return Gb28181CodeType.BUSINESS_GROUP;
case 216:
return Gb28181CodeType.VIRTUAL_ORGANIZATION;
default:
return null;
}
}
}
}

View File

@ -1,19 +1,19 @@
package com.genersoft.iot.vmp.service;
import com.genersoft.iot.vmp.common.CommonGbChannel;
import com.genersoft.iot.vmp.service.bean.BusinessGroup;
import com.genersoft.iot.vmp.service.bean.Group;
import java.util.List;
/**
*
*/
public interface IBusinessGroupService {
public interface IGroupService {
/**
*
*/
List<BusinessGroup> getNodes(String parentId);
List<Group> getNodes(String parentId);
/**
*
@ -28,7 +28,7 @@ public interface IBusinessGroupService {
/**
*
*/
boolean add(BusinessGroup businessGroup);
boolean add(Group businessGroup);
/**
*
@ -43,7 +43,7 @@ public interface IBusinessGroupService {
/**
*
*/
boolean update(BusinessGroup businessGroup);
boolean update(Group businessGroup);
/**
*

View File

@ -0,0 +1,16 @@
package com.genersoft.iot.vmp.service;
import com.genersoft.iot.vmp.service.bean.Region;
import java.util.List;
public interface IRegionService {
List<Region> getChildren(String parentDeviceId);
void add(Region region);
void deleteByDeviceId(String regionDeviceId);
void updateRegionName(Region region);
}

View File

@ -1,98 +0,0 @@
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;
}
}

View File

@ -0,0 +1,111 @@
package com.genersoft.iot.vmp.service.bean;
import com.genersoft.iot.vmp.utils.DateUtil;
/**
*
*/
public class Group {
/**
* ID
*/
private int commonGroupId;
/**
*
*/
private String commonGroupDeviceId;
/**
*
*/
private String commonGroupName;
/**
* ID
*/
private String commonGroupParentId;
/**
* IDID
*/
private String commonGroupTopId;
/**
*
*/
private String commonGroupCreateTime;
/**
*
*/
private String commonGroupUpdateTime;
public static Group getInstance(String commonGroupDeviceId, String commonGroupName, String commonGroupParentId, String commonGroupTopId) {
Group group = new Group();
group.setCommonGroupDeviceId(commonGroupDeviceId);
group.setCommonGroupName(commonGroupName);
group.setCommonGroupParentId(commonGroupParentId);
group.setCommonGroupTopId(commonGroupTopId);
group.setCommonGroupCreateTime(DateUtil.getNow());
group.setCommonGroupUpdateTime(DateUtil.getNow());
return group;
}
public int getCommonGroupId() {
return commonGroupId;
}
public void setCommonGroupId(int commonGroupId) {
this.commonGroupId = commonGroupId;
}
public String getCommonGroupDeviceId() {
return commonGroupDeviceId;
}
public void setCommonGroupDeviceId(String commonGroupDeviceId) {
this.commonGroupDeviceId = commonGroupDeviceId;
}
public String getCommonGroupName() {
return commonGroupName;
}
public void setCommonGroupName(String commonGroupName) {
this.commonGroupName = commonGroupName;
}
public String getCommonGroupParentId() {
return commonGroupParentId;
}
public void setCommonGroupParentId(String commonGroupParentId) {
this.commonGroupParentId = commonGroupParentId;
}
public String getCommonGroupCreateTime() {
return commonGroupCreateTime;
}
public void setCommonGroupCreateTime(String commonGroupCreateTime) {
this.commonGroupCreateTime = commonGroupCreateTime;
}
public String getCommonGroupUpdateTime() {
return commonGroupUpdateTime;
}
public void setCommonGroupUpdateTime(String commonGroupUpdateTime) {
this.commonGroupUpdateTime = commonGroupUpdateTime;
}
public String getCommonGroupTopId() {
return commonGroupTopId;
}
public void setCommonGroupTopId(String commonGroupTopId) {
this.commonGroupTopId = commonGroupTopId;
}
}

View File

@ -0,0 +1,96 @@
package com.genersoft.iot.vmp.service.bean;
import com.genersoft.iot.vmp.utils.DateUtil;
/**
*
*/
public class Region {
/**
* ID
*/
private int commonRegionId;
/**
*
*/
private String commonRegionDeviceId;
/**
*
*/
private String commonRegionName;
/**
* ID
*/
private String commonRegionParentId;
/**
*
*/
private String commonRegionCreateTime;
/**
*
*/
private String commonRegionUpdateTime;
public static Region getInstance(String commonRegionDeviceId, String commonRegionName, String commonRegionParentId) {
Region region = new Region();
region.setCommonRegionDeviceId(commonRegionDeviceId);
region.setCommonRegionName(commonRegionName);
region.setCommonRegionParentId(commonRegionParentId);
region.setCommonRegionCreateTime(DateUtil.getNow());
region.setCommonRegionUpdateTime(DateUtil.getNow());
return region;
}
public int getCommonRegionId() {
return commonRegionId;
}
public void setCommonRegionId(int commonRegionId) {
this.commonRegionId = commonRegionId;
}
public String getCommonRegionDeviceId() {
return commonRegionDeviceId;
}
public void setCommonRegionDeviceId(String commonRegionDeviceId) {
this.commonRegionDeviceId = commonRegionDeviceId;
}
public String getCommonRegionName() {
return commonRegionName;
}
public void setCommonRegionName(String commonRegionName) {
this.commonRegionName = commonRegionName;
}
public String getCommonRegionParentId() {
return commonRegionParentId;
}
public void setCommonRegionParentId(String commonRegionParentId) {
this.commonRegionParentId = commonRegionParentId;
}
public String getCommonRegionCreateTime() {
return commonRegionCreateTime;
}
public void setCommonRegionCreateTime(String commonRegionCreateTime) {
this.commonRegionCreateTime = commonRegionCreateTime;
}
public String getCommonRegionUpdateTime() {
return commonRegionUpdateTime;
}
public void setCommonRegionUpdateTime(String commonRegionUpdateTime) {
this.commonRegionUpdateTime = commonRegionUpdateTime;
}
}

View File

@ -1,13 +1,22 @@
package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.common.CommonGbChannel;
import com.genersoft.iot.vmp.conf.CivilCodeFileConf;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.Gb28181CodeType;
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.jt1078.proc.request.Re;
import com.genersoft.iot.vmp.service.ICommonGbChannelService;
import com.genersoft.iot.vmp.service.bean.Group;
import com.genersoft.iot.vmp.service.bean.CommonGbChannelType;
import com.genersoft.iot.vmp.service.bean.Region;
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
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 org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -17,8 +26,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@Service
public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
@ -32,10 +40,19 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
private DeviceChannelMapper deviceChannelMapper;
@Autowired
DataSourceTransactionManager dataSourceTransactionManager;
private GroupMapper groupMapper;
@Autowired
TransactionDefinition transactionDefinition;
private RegionMapper regionMapper;
@Autowired
private DataSourceTransactionManager dataSourceTransactionManager;
@Autowired
private TransactionDefinition transactionDefinition;
@Autowired
private CivilCodeFileConf civilCodeFileConf;
@Override
@ -77,20 +94,67 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
@Override
public boolean syncChannelFromGb28181Device(String gbDeviceId, List<String> syncKeys, Boolean syncGroup, Boolean syncRegion) {
logger.info("同步通用通道]来自国标设备,国标编号: {}", gbDeviceId);
logger.info("[同步通用通道]来自国标设备,国标编号: {}", gbDeviceId);
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryAllChannels(gbDeviceId);
if (deviceChannels.isEmpty()) {
logger.info("[同步通用通道]来自国标设备,结束, 通道数为0, 国标编号: {}", gbDeviceId);
return false;
}
List<CommonGbChannel> commonGbChannelList = new ArrayList<>(deviceChannels.size());
List<CommonGbChannel> commonGbChannelList = new ArrayList<>();
// 存储得到的10到13位为215的业务分组数据
Map<String, Group> businessGroupMap = new HashMap<>();
// 存储得到的10到13位为216的虚拟组织 数据
Map<String, Group> virtuallyGroupMap = new HashMap<>();
// 存储得到的行政区划数据
Map<String, Region> regionMap = new HashMap<>();
// 存储得到的所有parentId, 后续检验parentId是否已传输对应的分组/行政区划数据,从而确定是否需要自动创建节点。
Set<String> parentIdSet = new HashSet<>();
// 存储得到的所有行政区划, 后续检验civilCode是否已传输对应的行政区划数据从而确定是否需要自动创建节点。
Set<String> civilCodeSet = new HashSet<>();
List<DeviceChannel> clearChannels = new ArrayList<>();
for (DeviceChannel deviceChannel : deviceChannels) {
deviceChannels.stream().forEach(deviceChannel -> {
if (deviceChannel.getCommonGbChannelId() > 0) {
clearChannels.add(deviceChannel);
}
CommonGbChannel commonGbChannel = getCommonChannelFromDeviceChannel(deviceChannel, syncKeys);
commonGbChannelList.add(commonGbChannel);
}
Gb28181CodeType channelIdType = SipUtils.getChannelIdType(deviceChannel.getChannelId());
if (channelIdType != null) {
if (
(
channelIdType == Gb28181CodeType.CIVIL_CODE_PROVINCE
|| channelIdType == Gb28181CodeType.CIVIL_CODE_CITY
|| channelIdType == Gb28181CodeType.CIVIL_CODE_COUNTY
|| channelIdType == Gb28181CodeType.CIVIL_CODE_GRASS_ROOTS
)
&&
!regionMap.containsKey(deviceChannel.getChannelId())
) {
// 行政区划条目
Region region = Region.getInstance(deviceChannel.getChannelId(), deviceChannel.getName(),
civilCodeFileConf.getParentCode(deviceChannel.getChannelId()).getCode());
regionMap.put(deviceChannel.getChannelId(), region);
}
if (channelIdType == Gb28181CodeType.BUSINESS_GROUP
&& !businessGroupMap.containsKey(deviceChannel.getChannelId())) {
Group group = Group.getInstance(deviceChannel.getChannelId(), deviceChannel.getName(),
null, deviceChannel.getChannelId());
businessGroupMap.put(deviceChannel.getChannelId(), group);
}
if (channelIdType == Gb28181CodeType.VIRTUAL_ORGANIZATION
&& !virtuallyGroupMap.containsKey(deviceChannel.getChannelId())) {
Group group = Group.getInstance(deviceChannel.getChannelId(), deviceChannel.getName(), deviceChannel.getParentId(), null);
virtuallyGroupMap.put(deviceChannel.getChannelId(), group);
}
}else {
if (!StringUtils.isEmpty(deviceChannel.getParentId())) {
parentIdSet.add(deviceChannel.getParentId());
}
if (!StringUtils.isEmpty(deviceChannel.getCivilCode())) {
civilCodeSet.add(deviceChannel.getCivilCode());
}
CommonGbChannel commonGbChannel = getCommonChannelFromDeviceChannel(deviceChannel, syncKeys);
commonGbChannelList.add(commonGbChannel);
}
});
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
int limit = 50;
if (!clearChannels.isEmpty()) {
@ -124,16 +188,170 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
int currentResult = commonGbChannelMapper.addAll(commonGbChannelListSub);
if (currentResult <= 0) {
dataSourceTransactionManager.rollback(transactionStatus);
logger.info("[同步通用通道]来自国标设备,失败, 写入数据库失败, 国标编号: {}", gbDeviceId);
return false;
}
}
result = true;
}
deviceChannelMapper.updateCommonChannelId(gbDeviceId);
// 为虚拟组织数据补充业务分组ID
if (!virtuallyGroupMap.isEmpty()) {
for (Group virtuallyGroup : virtuallyGroupMap.values()) {
String topGroupId = getTopGroupId(businessGroupMap, virtuallyGroupMap,
virtuallyGroup.getCommonGroupDeviceId(), 0);
if (topGroupId == null) {
virtuallyGroupMap.remove(virtuallyGroup.getCommonGroupDeviceId());
}else {
virtuallyGroup.setCommonGroupTopId(topGroupId);
}
}
}
List<String> errorParentIdList = new ArrayList<>();
// 检测ParentId字段数据是否不完整
for (String parentId : parentIdSet) {
Gb28181CodeType channelIdType = SipUtils.getChannelIdType(parentId);
if (channelIdType == null) {
logger.warn("[不规范的ParentId设置]parentId不是虚拟组织编号无法自动添加分组信息。 " +
"国标编号: {} parentId {}", gbDeviceId, parentId );
continue;
}
if (channelIdType == Gb28181CodeType.CIVIL_CODE_PROVINCE
|| channelIdType == Gb28181CodeType.CIVIL_CODE_CITY
|| channelIdType == Gb28181CodeType.CIVIL_CODE_COUNTY
|| channelIdType == Gb28181CodeType.CIVIL_CODE_GRASS_ROOTS
){
logger.warn("[不规范的ParentId设置]错误的将行政区划编号写入ParentId字段中尝试纠正。 " +
"国标编号: {} parentId {}", gbDeviceId, parentId );
if (!regionMap.containsKey(parentId)) {
Region region = civilCodeFileConf.createRegion(parentId);
regionMap.put(region.getCommonRegionDeviceId(), region);
}
}else if (channelIdType == Gb28181CodeType.BUSINESS_GROUP) {
logger.warn("[不规范的ParentId设置]错误的将通道的ParentId设置为业务分组应该放在虚拟组织下尝试纠正。 " +
"国标编号: {} parentId {}", gbDeviceId, parentId );
// 注纠正的方式为将parentId置空这样可以在分组列表的<未分组>中找到这些通道,然后进行手动处理,
// 代码在getCommonChannelFromDeviceChannel中体现这里只是做个日志提示下
}else if (channelIdType == Gb28181CodeType.VIRTUAL_ORGANIZATION){
Group virtuallyGroup = virtuallyGroupMap.get(parentId);
if (virtuallyGroup == null) {
// 如果下级同步的通道不包括这个虚拟组织的信息
errorParentIdList.add(parentId);
}else {
String commonGroupTopId = virtuallyGroup.getCommonGroupTopId();
// 如果下级同步的通道包括这个虚拟组织的信息, 但是没有对应的业务分组的信息
if (!businessGroupMap.containsKey(commonGroupTopId)) {
errorParentIdList.add(parentId);
}
}
}
}
// 处理存在错误的parentId
if (!errorParentIdList.isEmpty()) {
if (errorParentIdList.size() <= limit) {
if (commonGbChannelMapper.clearParentIds(errorParentIdList) <= 0) {
dataSourceTransactionManager.rollback(transactionStatus);
logger.info("[同步通用通道]来自国标设备,失败, 处理错误的ParentId失败, 国标编号: {}", gbDeviceId);
return false;
}
} else {
for (int i = 0; i < errorParentIdList.size(); i += limit) {
int toIndex = i + limit;
if (i + limit > errorParentIdList.size()) {
toIndex = errorParentIdList.size();
}
List<String> errorParentIdListSub = errorParentIdList.subList(i, toIndex);
if (commonGbChannelMapper.clearParentIds(errorParentIdListSub) <= 0) {
dataSourceTransactionManager.rollback(transactionStatus);
logger.info("[同步通用通道]来自国标设备,失败, 处理错误的ParentId失败, 国标编号: {}", gbDeviceId);
return false;
}
}
}
}
// 分组信息写入数据库
List<Group> allGroup = new ArrayList<>(businessGroupMap.values());
allGroup.addAll(virtuallyGroupMap.values());
if (allGroup.size() <= limit) {
if (groupMapper.addAll(allGroup) <= 0) {
dataSourceTransactionManager.rollback(transactionStatus);
logger.info("[同步通用通道]来自国标设备,失败,添加分组信息失败, 国标编号: {}", gbDeviceId);
return false;
}
} else {
for (int i = 0; i < allGroup.size(); i += limit) {
int toIndex = i + limit;
if (i + limit > allGroup.size()) {
toIndex = allGroup.size();
}
List<Group> allGroupSub = allGroup.subList(i, toIndex);
if (groupMapper.addAll(allGroupSub) <= 0) {
dataSourceTransactionManager.rollback(transactionStatus);
logger.info("[同步通用通道]来自国标设备,失败,添加分组信息失败, 国标编号: {}", gbDeviceId);
return false;
}
}
}
// 检测行政区划信息是否完整
for (String civilCode : civilCodeSet) {
if (!regionMap.containsKey(civilCode)) {
logger.warn("[通道信息中缺少地区信息]补充地区信息 国标编号: {} civilCode {}", gbDeviceId, civilCode );
Region region = civilCodeFileConf.createRegion(civilCode);
regionMap.put(region.getCommonRegionDeviceId(), region);
}
}
// 行政区划信息写入数据库
List<Region> allRegion = new ArrayList<>(regionMap.values());
if (!allRegion.isEmpty()) {
if (allRegion.size() <= limit) {
if (regionMapper.addAll(allRegion) <= 0) {
dataSourceTransactionManager.rollback(transactionStatus);
logger.info("[同步通用通道]来自国标设备,失败,添加行政区划信息失败, 国标编号: {}", gbDeviceId);
return false;
}
} else {
for (int i = 0; i < allRegion.size(); i += limit) {
int toIndex = i + limit;
if (i + limit > allRegion.size()) {
toIndex = allRegion.size();
}
List<Region> allRegionSub = allRegion.subList(i, toIndex);
if (regionMapper.addAll(allRegionSub) <= 0) {
dataSourceTransactionManager.rollback(transactionStatus);
logger.info("[同步通用通道]来自国标设备,失败,添加行政区划信息失败, 国标编号: {}", gbDeviceId);
return false;
}
}
}
}
dataSourceTransactionManager.commit(transactionStatus);
return result;
}
private String getTopGroupId(Map<String, Group> businessGroupMap, Map<String, Group> virtuallyGroupMap, String commonGroupId, int depth) {
if (depth >= 16) {
return null;
}
Group group = virtuallyGroupMap.get(commonGroupId);
if (group == null) {
return null;
}
Gb28181CodeType channelIdType = SipUtils.getChannelIdType(group.getCommonGroupParentId());
if (channelIdType == Gb28181CodeType.BUSINESS_GROUP) {
if (businessGroupMap.containsKey(group.getCommonGroupParentId())) {
return group.getCommonGroupParentId();
}else {
return null;
}
}
depth ++;
return getTopGroupId(businessGroupMap, virtuallyGroupMap, group.getCommonGroupParentId(), depth);
}
@Override
public CommonGbChannel getCommonChannelFromDeviceChannel(DeviceChannel deviceChannel, List<String> syncKeys) {
if (deviceChannel == null) {
@ -150,11 +368,30 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
commonGbChannel.setCommonGbManufacturer(deviceChannel.getManufacture());
commonGbChannel.setCommonGbModel(deviceChannel.getModel());
commonGbChannel.setCommonGbOwner(deviceChannel.getOwner());
Gb28181CodeType channelIdType = SipUtils.getChannelIdType(deviceChannel.getCivilCode());
if (channelIdType == Gb28181CodeType.CIVIL_CODE_PROVINCE
|| channelIdType == Gb28181CodeType.CIVIL_CODE_CITY
|| channelIdType == Gb28181CodeType.CIVIL_CODE_COUNTY
|| channelIdType == Gb28181CodeType.CIVIL_CODE_GRASS_ROOTS
){
commonGbChannel.setCommonGbCivilCode(deviceChannel.getCivilCode());
}else {
logger.warn("[不规范的CivilCode]deviceId: {}, channel: {}, civilCode: {}",
deviceChannel.getDeviceId(),
deviceChannel.getChannelId(),
deviceChannel.getCivilCode());
}
commonGbChannel.setCommonGbCivilCode(deviceChannel.getCivilCode());
commonGbChannel.setCommonGbBlock(deviceChannel.getBlock());
commonGbChannel.setCommonGbAddress(deviceChannel.getAddress());
commonGbChannel.setCommonGbParental(deviceChannel.getParental());
commonGbChannel.setCommonGbParentID(deviceChannel.getParentId());
commonGbChannel.setCommonGbParental(0);
// 不符合国标的parentId可以在未分组中找到并重新设置分组信息
Gb28181CodeType parentIdIdType = SipUtils.getChannelIdType(deviceChannel.getParentId());
if (parentIdIdType == Gb28181CodeType.VIRTUAL_ORGANIZATION) {
commonGbChannel.setCommonGbParentID(deviceChannel.getParentId());
}
commonGbChannel.setCommonGbSafetyWay(deviceChannel.getSafetyWay());
commonGbChannel.setCommonGbRegisterWay(deviceChannel.getRegisterWay());
commonGbChannel.setCommonGbCertNum(deviceChannel.getCertNum());
@ -188,6 +425,19 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
commonGbChannel.setCommonGbOwner(deviceChannel.getOwner());
break;
case "commonGbCivilCode":
Gb28181CodeType channelIdType = SipUtils.getChannelIdType(deviceChannel.getCivilCode());
if (channelIdType == Gb28181CodeType.CIVIL_CODE_PROVINCE
|| channelIdType == Gb28181CodeType.CIVIL_CODE_CITY
|| channelIdType == Gb28181CodeType.CIVIL_CODE_COUNTY
|| channelIdType == Gb28181CodeType.CIVIL_CODE_GRASS_ROOTS
){
commonGbChannel.setCommonGbCivilCode(deviceChannel.getCivilCode());
}else {
logger.warn("[不规范的CivilCode]deviceId: {}, channel: {}, civilCode: {}",
deviceChannel.getDeviceId(),
deviceChannel.getChannelId(),
deviceChannel.getCivilCode());
}
commonGbChannel.setCommonGbCivilCode(deviceChannel.getCivilCode());
break;
case "commonGbBlock":

View File

@ -285,10 +285,10 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
}
List<DeviceChannel> allChannels = channelMapper.queryAllChannels(device.getDeviceId());
Map<String,DeviceChannel> allChannelMap = new ConcurrentHashMap<>();
if (allChannels.size() > 0) {
for (DeviceChannel deviceChannel : allChannels) {
if (!allChannels.isEmpty()) {
allChannels.stream().forEach(deviceChannel -> {
allChannelMap.put(deviceChannel.getChannelId(), deviceChannel);
}
});
}
// 数据去重
List<DeviceChannel> channels = new ArrayList<>();
@ -337,7 +337,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
}
}
}
if (channels.size() > 0) {
if (!channels.isEmpty()) {
for (DeviceChannel channel : channels) {
if (subContMap.get(channel.getChannelId()) != null){
Integer count = subContMap.get(channel.getChannelId());
@ -371,33 +371,34 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
cleanChannelsResult = channelMapper.cleanChannelsNotInList(device.getDeviceId(), channels);
}
boolean result = cleanChannelsResult < 0;
if (!result && addChannels.size() > 0) {
if (addChannels.size() > limitCount) {
for (int i = 0; i < addChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > addChannels.size()) {
toIndex = addChannels.size();
if (!result) {
if (!addChannels.isEmpty()) {
if (addChannels.size() > limitCount) {
for (int i = 0; i < addChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > addChannels.size()) {
toIndex = addChannels.size();
}
result = result || channelMapper.batchAdd(addChannels.subList(i, toIndex)) < 0;
}
result = result || channelMapper.batchAdd(addChannels.subList(i, toIndex)) < 0;
}else {
result = channelMapper.batchAdd(addChannels) < 0;
}
}
if (!updateChannels.isEmpty()) {
if (updateChannels.size() > limitCount) {
for (int i = 0; i < updateChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > updateChannels.size()) {
toIndex = updateChannels.size();
}
result = result || channelMapper.batchUpdate(updateChannels.subList(i, toIndex)) < 0;
}
}else {
result = result || channelMapper.batchUpdate(updateChannels) < 0;
}
}else {
result = result || channelMapper.batchAdd(addChannels) < 0;
}
}
if (!result && updateChannels.size() > 0) {
if (updateChannels.size() > limitCount) {
for (int i = 0; i < updateChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > updateChannels.size()) {
toIndex = updateChannels.size();
}
result = result || channelMapper.batchUpdate(updateChannels.subList(i, toIndex)) < 0;
}
}else {
result = result || channelMapper.batchUpdate(updateChannels) < 0;
}
}
if (result) {
//事务回滚
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

View File

@ -1,9 +1,9 @@
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.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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -16,15 +16,15 @@ import org.springframework.transaction.TransactionStatus;
import java.util.List;
@Service
public class BusinessGroupServiceImpl implements IBusinessGroupService {
public class GroupServiceImpl implements IGroupService {
private final static Logger logger = LoggerFactory.getLogger(BusinessGroupServiceImpl.class);
private final static Logger logger = LoggerFactory.getLogger(GroupServiceImpl.class);
@Autowired
private CommonGbChannelMapper commonGbChannelDao;
@Autowired
private BusinessGroupMapper businessGroupDao;
private GroupMapper businessGroupDao;
@Autowired
DataSourceTransactionManager dataSourceTransactionManager;
@ -34,13 +34,13 @@ public class BusinessGroupServiceImpl implements IBusinessGroupService {
@Override
public List<BusinessGroup> getNodes(String parentId) {
public List<Group> getNodes(String parentId) {
return businessGroupDao.getNodes(parentId);
}
@Override
public List<CommonGbChannel> getChannels(int id) {
BusinessGroup businessGroup = businessGroupDao.query(id);
Group businessGroup = businessGroupDao.query(id);
if (businessGroup == null) {
return null;
}
@ -49,7 +49,7 @@ public class BusinessGroupServiceImpl implements IBusinessGroupService {
@Override
public List<CommonGbChannel> getChannels(String deviceId) {
BusinessGroup businessGroup = businessGroupDao.queryByDeviceId(deviceId);
Group businessGroup = businessGroupDao.queryByDeviceId(deviceId);
if (businessGroup == null) {
return null;
}
@ -57,7 +57,7 @@ public class BusinessGroupServiceImpl implements IBusinessGroupService {
}
@Override
public boolean add(BusinessGroup businessGroup) {
public boolean add(Group businessGroup) {
return businessGroupDao.add(businessGroup) > 0;
}
@ -72,11 +72,11 @@ public class BusinessGroupServiceImpl implements IBusinessGroupService {
}
@Override
public boolean update(BusinessGroup businessGroup) {
public boolean update(Group businessGroup) {
if (businessGroup.getCommonBusinessGroupId() == 0) {
return false;
}
BusinessGroup businessGroupInDb = businessGroupDao.query(businessGroup.getCommonBusinessGroupId());
Group businessGroupInDb = businessGroupDao.query(businessGroup.getCommonBusinessGroupId());
if (businessGroupInDb == null) {
return false;
}
@ -103,7 +103,7 @@ public class BusinessGroupServiceImpl implements IBusinessGroupService {
if (channels.isEmpty()) {
return false;
}
BusinessGroup businessGroup = businessGroupDao.query(id);
Group businessGroup = businessGroupDao.query(id);
if (businessGroup == null) {
return false;
}
@ -119,7 +119,7 @@ public class BusinessGroupServiceImpl implements IBusinessGroupService {
if (channels.isEmpty()) {
return false;
}
BusinessGroup businessGroup = businessGroupDao.queryByDeviceId(deviceId);
Group businessGroup = businessGroupDao.queryByDeviceId(deviceId);
if (businessGroup == null) {
return false;
}

View File

@ -0,0 +1,41 @@
package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.service.IRegionService;
import com.genersoft.iot.vmp.service.bean.Region;
import com.genersoft.iot.vmp.storager.dao.RegionMapper;
import com.genersoft.iot.vmp.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*
*/
@Service
public class RegionServiceImpl implements IRegionService {
@Autowired
private RegionMapper regionMapper;
@Override
public List<Region> getChildren(String parentDeviceId) {
return regionMapper.getChildren(parentDeviceId);
}
@Override
public void add(Region region) {
regionMapper.add(region);
}
@Override
public void deleteByDeviceId(String regionDeviceId) {
regionMapper.deleteByDeviceId(regionDeviceId);
}
@Override
public void updateRegionName(Region region) {
regionMapper.updateRegionName(region.getCommonRegionName(), DateUtil.getNow(), region.getCommonRegionDeviceId());
}
}

View File

@ -1,65 +0,0 @@
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);
}

View File

@ -301,4 +301,10 @@ public interface CommonGbChannelMapper {
"<foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.commonGbChannelId}</foreach>" +
"</script>")
void channelsOfflineFromList(List<DeviceChannel> channelList);
@Update("<script> "+
"UPDATE wvp_common_gb_channel SET common_gb_parent_id = null WHERE common_gb_id in" +
"<foreach collection='errorParentIdList' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
"</script>")
int clearParentIds(List<String> errorParentIdList);
}

View File

@ -0,0 +1,83 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.service.bean.Group;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface GroupMapper {
@Select(value = " <script>" +
" select * from wvp_common_group " +
" WHERE 1=1 " +
" <if test='parentId != null' > AND common_group_parent_id = #{parentId}</if>" +
" <if test='parentId == null' > AND common_group_parent_id is null </if>" +
" order by common_group_id ASC " +
" </script>")
List<Group> getNodes(String parentId);
@Select(" select * from wvp_common_group " +
" WHERE common_group_id = #{id} ")
Group query(int id);
@Select(" select * from wvp_common_group " +
" WHERE common_group_device_id = #{deviceId} ")
Group queryByDeviceId(String deviceId);
@Insert("INSERT INTO wvp_common_group (" +
"common_group_device_id, " +
"common_group_name, " +
"common_group_parent_id, " +
"common_group_update_time, " +
"common_group_create_time ) " +
"VALUES (" +
"#{commonGroupDeviceId}, " +
"#{commonGroupName}, " +
"#{commonGroupParentId}, " +
"#{commonGroupUpdateTime}, " +
"#{commonGroupCreateTime})")
int add(Group group);
@Delete("delete from wvp_common_group where common_group_id = #{id}")
int remove(int id);
@Delete("delete from wvp_common_group where common_group_device_id = #{deviceId}")
int removeByDeviceId(String deviceId);
@Update(value = {" <script>" +
"UPDATE wvp_common_group " +
"SET common_group_update_time=#{commonGroupUpdateTime}" +
"<if test='commonGroupName != null'>, common_group_name=#{commonGroupName}</if>" +
"<if test='commonGroupDeviceId != null'>, common_group_device_id=#{commonGroupDeviceId}</if>" +
"<if test='commonGroupParentId != null'>, common_group_parent_id=#{commonGroupParentId}</if>" +
"<if test='commonGroupUpdateTime != null'>, common_group_update_time=#{commonGroupUpdateTime}</if>" +
"WHERE common_group_id=#{commonGroupId}" +
" </script>"})
int update(Group Group);
@Insert(value = "<script>" +
"insert into wvp_common_group ( " +
"common_group_device_id, " +
"common_group_name, " +
"common_group_parent_id, " +
"common_group_create_time, " +
"common_group_update_time " +
") values " +
"<foreach collection='allGroup' index='index' item='item' separator=','> " +
"( " +
"#{item.commonGroupDeviceId}, " +
"#{item.commonGroupName}, " +
"#{item.commonGroupParentId}, " +
"#{item.commonGroupCreateTime}, " +
"#{item.commonGroupUpdateTime} " +
")" +
"</foreach>" +
"</script>")
int addAll(List<Group> allGroup);
}

View File

@ -0,0 +1,58 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.service.bean.Region;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface RegionMapper {
@Select("select * from wvp_common_region where common_region_parent_id = #{parentDeviceId}")
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})")
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}" +
" </script>"})
int updateRegionName(@Param("name") String name, @Param("updateTime") String updateTime, @Param("regionDeviceId") String regionDeviceId);
@Insert(value = "<script>" +
"insert into wvp_common_group ( " +
"common_region_device_id, " +
"common_region_name, " +
"common_region_parent_id, " +
"common_region_create_time, " +
"common_region_update_time " +
") values " +
"<foreach collection='allRegion' index='index' item='item' separator=','> " +
"( " +
"#{item.commonRegionDeviceId}, " +
"#{item.commonRegionName}, " +
"#{item.commonRegionParentId}, " +
"#{item.commonRegionCreateTime}, " +
"#{item.commonRegionUpdateTime} " +
")" +
"</foreach>" +
"</script>")
int addAll(List<Region> allRegion);
}