648540858
2022-04-26 363606d8453c027429ea66a6036c62b01ff8e06c
src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java
@@ -204,6 +204,7 @@
        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 @@
        }
        deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID"));
        String parentId = XmlUtil.getText(itemDevice, "ParentID");
        if (parentId.contains("/")) {
            String lastParentId = parentId.substring(parentId.lastIndexOf("/"));
            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 @@
        deviceChannel.setHasAudio(true); // 默认含有音频,播放时再检查是否有音频及是否AAC
        return deviceChannel;
    }
}
}