优化国标级联的目录创建以及推送规则,优化接收目录规则,更加规范
This commit is contained in:
@@ -45,8 +45,6 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
device = deviceMapper.getDeviceByDeviceId(deviceChannel.getDeviceId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ("WGS84".equals(device.getGeoCoordSys())) {
|
||||
deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
|
||||
deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
|
||||
@@ -252,4 +250,6 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -376,63 +376,11 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
if (device == null) {
|
||||
return null;
|
||||
}
|
||||
if (parentId == null || parentId.equals(deviceId)) {
|
||||
// 字根节点开始查询
|
||||
List<DeviceChannel> rootNodes = getRootNodes(deviceId, TreeType.CIVIL_CODE.equals(device.getTreeType()), true, !onlyCatalog);
|
||||
return transportChannelsToTree(rootNodes, "");
|
||||
if (ObjectUtils.isEmpty(parentId) || parentId.equals(deviceId)) {
|
||||
parentId = null;
|
||||
}
|
||||
|
||||
if (TreeType.CIVIL_CODE.equals(device.getTreeType())) {
|
||||
if (parentId.length()%2 != 0) {
|
||||
return null;
|
||||
}
|
||||
// 使用行政区划展示树
|
||||
// if (parentId.length() > 10) {
|
||||
// // TODO 可能是行政区划与业务分组混杂的情形
|
||||
// return null;
|
||||
// }
|
||||
|
||||
if (parentId.length() == 10 ) {
|
||||
if (onlyCatalog) {
|
||||
return null;
|
||||
}
|
||||
// parentId为行业编码, 其下不会再有行政区划
|
||||
List<DeviceChannel> channels = deviceChannelMapper.getChannelsByCivilCode(deviceId, parentId);
|
||||
List<BaseTree<DeviceChannel>> trees = transportChannelsToTree(channels, parentId);
|
||||
return trees;
|
||||
}
|
||||
// 查询其下的行政区划和摄像机
|
||||
List<DeviceChannel> channelsForCivilCode = deviceChannelMapper.getChannelsWithCivilCodeAndLength(deviceId, parentId, parentId.length() + 2);
|
||||
if (!onlyCatalog) {
|
||||
List<DeviceChannel> channels = deviceChannelMapper.getChannelsByCivilCode(deviceId, parentId);
|
||||
|
||||
for(DeviceChannel channel : channels) {
|
||||
boolean flag = false;
|
||||
for(DeviceChannel deviceChannel : channelsForCivilCode) {
|
||||
if(channel.getChannelId().equals(deviceChannel.getChannelId())) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if(!flag) {
|
||||
channelsForCivilCode.add(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<BaseTree<DeviceChannel>> trees = transportChannelsToTree(channelsForCivilCode, parentId);
|
||||
return trees;
|
||||
|
||||
}
|
||||
// 使用业务分组展示树
|
||||
if (TreeType.BUSINESS_GROUP.equals(device.getTreeType())) {
|
||||
if (parentId.length() < 14 ) {
|
||||
return null;
|
||||
}
|
||||
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null,null);
|
||||
List<BaseTree<DeviceChannel>> trees = transportChannelsToTree(deviceChannels, parentId);
|
||||
return trees;
|
||||
}
|
||||
|
||||
return null;
|
||||
List<DeviceChannel> rootNodes = deviceChannelMapper.getSubChannelsByDeviceId(deviceId, parentId, onlyCatalog);
|
||||
return transportChannelsToTree(rootNodes, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -441,42 +389,11 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
if (device == null) {
|
||||
return null;
|
||||
}
|
||||
if (parentId == null || parentId.equals(deviceId)) {
|
||||
// 字根节点开始查询
|
||||
List<DeviceChannel> rootNodes = getRootNodes(deviceId, TreeType.CIVIL_CODE.equals(device.getTreeType()), false, true);
|
||||
return rootNodes;
|
||||
if (ObjectUtils.isEmpty(parentId) || parentId.equals(deviceId)) {
|
||||
return deviceChannelMapper.getSubChannelsByDeviceId(deviceId, null, false);
|
||||
}else {
|
||||
return deviceChannelMapper.getSubChannelsByDeviceId(deviceId, parentId, false);
|
||||
}
|
||||
|
||||
if (TreeType.CIVIL_CODE.equals(device.getTreeType())) {
|
||||
if (parentId.length()%2 != 0) {
|
||||
return null;
|
||||
}
|
||||
// 使用行政区划展示树
|
||||
if (parentId.length() > 10) {
|
||||
// TODO 可能是行政区划与业务分组混杂的情形
|
||||
return null;
|
||||
}
|
||||
|
||||
if (parentId.length() == 10 ) {
|
||||
// parentId为行业编码, 其下不会再有行政区划
|
||||
List<DeviceChannel> channels = deviceChannelMapper.getChannelsByCivilCode(deviceId, parentId);
|
||||
return channels;
|
||||
}
|
||||
// 查询其下的行政区划和摄像机
|
||||
List<DeviceChannel> channels = deviceChannelMapper.getChannelsByCivilCode(deviceId, parentId);
|
||||
return channels;
|
||||
|
||||
}
|
||||
// 使用业务分组展示树
|
||||
if (TreeType.BUSINESS_GROUP.equals(device.getTreeType())) {
|
||||
if (parentId.length() < 14 ) {
|
||||
return null;
|
||||
}
|
||||
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null,null);
|
||||
return deviceChannels;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<BaseTree<DeviceChannel>> transportChannelsToTree(List<DeviceChannel> channels, String parentId) {
|
||||
@@ -496,11 +413,21 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
node.setPid(parentId);
|
||||
node.setBasicData(channel);
|
||||
node.setParent(false);
|
||||
if (channel.getChannelId().length() > 8) {
|
||||
String gbCodeType = channel.getChannelId().substring(10, 13);
|
||||
node.setParent(gbCodeType.equals(ChannelIdType.BUSINESS_GROUP) || gbCodeType.equals(ChannelIdType.VIRTUAL_ORGANIZATION) );
|
||||
}else {
|
||||
if (channel.getChannelId().length() <= 8) {
|
||||
node.setParent(true);
|
||||
}else {
|
||||
if (channel.getChannelId().length() != 20) {
|
||||
node.setParent(channel.getParental() == 1);
|
||||
}else {
|
||||
try {
|
||||
int type = Integer.parseInt(channel.getChannelId().substring(10, 13));
|
||||
if (type == 215 || type == 216 || type == 200) {
|
||||
node.setParent(true);
|
||||
}
|
||||
}catch (NumberFormatException e) {
|
||||
node.setParent(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
treeNotes.add(node);
|
||||
}
|
||||
@@ -508,53 +435,6 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
return treeNotes;
|
||||
}
|
||||
|
||||
private List<DeviceChannel> getRootNodes(String deviceId, boolean isCivilCode, boolean haveCatalog, boolean haveChannel) {
|
||||
if (!haveCatalog && !haveChannel) {
|
||||
return null;
|
||||
}
|
||||
List<DeviceChannel> result = new ArrayList<>();
|
||||
if (isCivilCode) {
|
||||
// 使用行政区划
|
||||
Integer length= deviceChannelMapper.getChannelMinLength(deviceId);
|
||||
if (length == null) {
|
||||
return null;
|
||||
}
|
||||
if (length <= 10) {
|
||||
if (haveCatalog) {
|
||||
List<DeviceChannel> provinceNode = deviceChannelMapper.getChannelsWithCivilCodeAndLength(deviceId, null, length);
|
||||
if (provinceNode != null && provinceNode.size() > 0) {
|
||||
result.addAll(provinceNode);
|
||||
}
|
||||
}
|
||||
|
||||
if (haveChannel) {
|
||||
// 查询那些civilCode不在通道中的不规范通道,放置在根目录
|
||||
List<DeviceChannel> nonstandardNode = deviceChannelMapper.getChannelWithoutCiviCode(deviceId);
|
||||
if (nonstandardNode != null && nonstandardNode.size() > 0) {
|
||||
result.addAll(nonstandardNode);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if (haveChannel) {
|
||||
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, null, null, null, null,null);
|
||||
if (deviceChannels != null && deviceChannels.size() > 0) {
|
||||
result.addAll(deviceChannels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
// 使用业务分组+虚拟组织
|
||||
|
||||
// 只获取业务分组
|
||||
List<DeviceChannel> deviceChannels = deviceChannelMapper.getBusinessGroups(deviceId, ChannelIdType.BUSINESS_GROUP);
|
||||
if (deviceChannels != null && deviceChannels.size() > 0) {
|
||||
result.addAll(deviceChannels);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExist(String deviceId) {
|
||||
return deviceMapper.getDeviceByDeviceId(deviceId) != null;
|
||||
|
||||
@@ -113,20 +113,15 @@ public class GbStreamServiceImpl implements IGbStreamService {
|
||||
deviceChannel.setStatus(gbStream.isStatus()?1:0);
|
||||
|
||||
deviceChannel.setRegisterWay(1);
|
||||
deviceChannel.setCivilCode(platform.getAdministrativeDivision());
|
||||
|
||||
if (platform.getTreeType().equals(TreeType.CIVIL_CODE)){
|
||||
deviceChannel.setCivilCode(catalogId);
|
||||
}else if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)){
|
||||
PlatformCatalog catalog = catalogMapper.select(catalogId);
|
||||
if (catalog == null) {
|
||||
deviceChannel.setParentId(platform.getDeviceGBId());
|
||||
deviceChannel.setBusinessGroupId(null);
|
||||
}else {
|
||||
deviceChannel.setParentId(catalog.getId());
|
||||
deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId());
|
||||
}
|
||||
|
||||
PlatformCatalog catalog = catalogMapper.select(catalogId);
|
||||
if (catalog != null) {
|
||||
deviceChannel.setCivilCode(catalog.getCivilCode());
|
||||
deviceChannel.setParentId(catalog.getParentId());
|
||||
deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId());
|
||||
}else {
|
||||
deviceChannel.setCivilCode(platform.getAdministrativeDivision());
|
||||
deviceChannel.setParentId(platform.getDeviceGBId());
|
||||
}
|
||||
|
||||
deviceChannel.setModel("live");
|
||||
@@ -221,20 +216,14 @@ public class GbStreamServiceImpl implements IGbStreamService {
|
||||
deviceChannel.setStatus((status != null && status )?1:0);
|
||||
|
||||
deviceChannel.setRegisterWay(1);
|
||||
deviceChannel.setCivilCode(platform.getAdministrativeDivision());
|
||||
|
||||
if (platform.getTreeType().equals(TreeType.CIVIL_CODE)){
|
||||
deviceChannel.setCivilCode(catalogId);
|
||||
}else if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)){
|
||||
PlatformCatalog catalog = catalogMapper.select(catalogId);
|
||||
if (catalog == null) {
|
||||
deviceChannel.setParentId(platform.getDeviceGBId());
|
||||
deviceChannel.setBusinessGroupId(null);
|
||||
}else {
|
||||
deviceChannel.setParentId(catalog.getId());
|
||||
deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId());
|
||||
}
|
||||
|
||||
PlatformCatalog catalog = catalogMapper.select(catalogId);
|
||||
if (catalog != null) {
|
||||
deviceChannel.setCivilCode(catalog.getCivilCode());
|
||||
deviceChannel.setParentId(catalog.getParentId());
|
||||
deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId());
|
||||
}else {
|
||||
deviceChannel.setCivilCode(platform.getAdministrativeDivision());
|
||||
deviceChannel.setParentId(platform.getDeviceGBId());
|
||||
}
|
||||
|
||||
deviceChannel.setModel("live");
|
||||
|
||||
@@ -126,22 +126,17 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
List<DeviceChannel> deviceChannelList = new ArrayList<>();
|
||||
if (channelReduces.size() > 0){
|
||||
PlatformCatalog catalog = catalogManager.select(catalogId);
|
||||
if (catalog == null && !catalogId.equals(platform.getDeviceGBId())) {
|
||||
if (catalog == null || !catalogId.equals(platform.getDeviceGBId())) {
|
||||
logger.warn("未查询到目录{}的信息", catalogId);
|
||||
return null;
|
||||
}
|
||||
for (ChannelReduce channelReduce : channelReduces) {
|
||||
DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId());
|
||||
deviceChannel.setParental(0);
|
||||
deviceChannel.setCivilCode(catalog.getCivilCode());
|
||||
deviceChannel.setParentId(catalog.getParentId());
|
||||
deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId());
|
||||
deviceChannelList.add(deviceChannel);
|
||||
if (platform.getTreeType().equals(TreeType.CIVIL_CODE)){
|
||||
deviceChannel.setCivilCode(catalogId);
|
||||
}else if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)){
|
||||
deviceChannel.setParentId(catalogId);
|
||||
if (catalog != null) {
|
||||
deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return deviceChannelList;
|
||||
|
||||
@@ -124,18 +124,12 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||
@Override
|
||||
public boolean update(ParentPlatform parentPlatform) {
|
||||
logger.info("[国标级联]更新平台 {}", parentPlatform.getDeviceGBId());
|
||||
// TODO 后续版本去除
|
||||
parentPlatform.setTreeType("");
|
||||
parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase());
|
||||
ParentPlatform parentPlatformOld = platformMapper.getParentPlatById(parentPlatform.getId());
|
||||
ParentPlatformCatch parentPlatformCatchOld = redisCatchStorage.queryPlatformCatchInfo(parentPlatformOld.getServerGBId());
|
||||
parentPlatform.setUpdateTime(DateUtil.getNow());
|
||||
if (!parentPlatformOld.getTreeType().equals(parentPlatform.getTreeType())) {
|
||||
// 目录结构发生变化,清空之前的关联关系
|
||||
logger.info("保存平台{}时发现目录结构变化,清空关联关系", parentPlatform.getDeviceGBId());
|
||||
catalogMapper.delByPlatformId(parentPlatformOld.getServerGBId());
|
||||
platformChannelMapper.delByPlatformId(parentPlatformOld.getServerGBId());
|
||||
platformGbStreamMapper.delByPlatformId(parentPlatformOld.getServerGBId());
|
||||
}
|
||||
|
||||
|
||||
// 停止心跳定时
|
||||
final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatformOld.getServerGBId();
|
||||
|
||||
Reference in New Issue
Block a user