行政区划作为级联数据的处理,修复设备树的显示

This commit is contained in:
648540858
2022-04-26 17:24:41 +08:00
parent 6c719556f5
commit 9ce22eba3c
7 changed files with 57 additions and 25 deletions

View File

@@ -204,6 +204,7 @@ public class XmlUtil {
deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode"));
deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block"));
deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address"));
String businessGroupID = XmlUtil.getText(itemDevice, "BusinessGroupID");
if (XmlUtil.getText(itemDevice, "Parental") == null
|| XmlUtil.getText(itemDevice, "Parental") == "") {
deviceChannel.setParental(0);
@@ -212,11 +213,27 @@ public class XmlUtil {
}
deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID"));
String parentId = XmlUtil.getText(itemDevice, "ParentID");
if (parentId != null && parentId.contains("/")) {
String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1);
deviceChannel.setParentId(lastParentId);
if (parentId != null) {
if (parentId.contains("/")) {
String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1);
deviceChannel.setParentId(lastParentId);
}else {
deviceChannel.setParentId(parentId);
}
}else {
deviceChannel.setParentId(parentId);
if (deviceChannel.getChannelId().length() <= 10) { // 此时为行政区划, 上下级行政区划使用DeviceId关联
deviceChannel.setParentId(deviceChannel.getChannelId().substring(0, deviceChannel.getChannelId().length() - 2));
}else if (deviceChannel.getChannelId().length() == 20) {
if (Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织
deviceChannel.setParentId(businessGroupID);
}else if (deviceChannel.getCivilCode() != null) {
// 设备, 无parentId的20位是使用CivilCode表示上级的设备
// 注215 业务分组是需要有parentId的
deviceChannel.setParentId(deviceChannel.getCivilCode());
}
}else {
deviceChannel.setParentId(deviceChannel.getDeviceId());
}
}
if (XmlUtil.getText(itemDevice, "SafetyWay") == null
@@ -277,4 +294,4 @@ public class XmlUtil {
deviceChannel.setHasAudio(true); // 默认含有音频播放时再检查是否有音频及是否AAC
return deviceChannel;
}
}
}