|
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
|
|
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
|
|
|
import com.xydl.cac.entity.IcdConfigType;
|
|
|
|
import com.xydl.cac.entity.IcdConfigType;
|
|
|
|
import com.xydl.cac.entity.IcdFile;
|
|
|
|
import com.xydl.cac.entity.IcdFile;
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.IcdIed;
|
|
|
|
import com.xydl.cac.exception.BusinessException;
|
|
|
|
import com.xydl.cac.exception.BusinessException;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
@ -26,60 +27,61 @@ public class IcdXmlUtil {
|
|
|
|
IcdFile icdFile = IcdFile.builder()
|
|
|
|
IcdFile icdFile = IcdFile.builder()
|
|
|
|
.xml(xml)
|
|
|
|
.xml(xml)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
LinkedHashMap<String, IcdConfigType> iedMap = processTypeRoot(root);
|
|
|
|
processTypeRoot(root, icdFile);
|
|
|
|
icdFile.setConfigList(new ArrayList<>(iedMap.values()));
|
|
|
|
|
|
|
|
return icdFile;
|
|
|
|
return icdFile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static LinkedHashMap<String, IcdConfigType> processTypeRoot(JsonNode root) {
|
|
|
|
private static void processTypeRoot(JsonNode root, IcdFile icdFile) {
|
|
|
|
LinkedHashMap<String, IcdConfigType> iedMap = new LinkedHashMap<>();
|
|
|
|
LinkedHashMap<String, IcdConfigType> configMap = new LinkedHashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, JsonNode> mapLNodeType = buildLNodeTypeMap(root);
|
|
|
|
Map<String, JsonNode> mapLNodeType = buildLNodeTypeMap(root);
|
|
|
|
Map<String, JsonNode> mapDOType = buildDOTypeMap(root);
|
|
|
|
Map<String, JsonNode> mapDOType = buildDOTypeMap(root);
|
|
|
|
Map<String, JsonNode> mapDAType = buildDATypeMap(root);
|
|
|
|
Map<String, JsonNode> mapDAType = buildDATypeMap(root);
|
|
|
|
|
|
|
|
|
|
|
|
List<JsonNode> iedList = findNodes(root, "IED");
|
|
|
|
List<JsonNode> iedNodeList = findNodes(root, "IED");
|
|
|
|
for (JsonNode iedNode : iedList) {
|
|
|
|
for (JsonNode iedNode : iedNodeList) {
|
|
|
|
processIEDNode(iedMap, iedNode,
|
|
|
|
processIEDNode(configMap, iedNode,
|
|
|
|
mapLNodeType, mapDOType, mapDAType);
|
|
|
|
mapLNodeType, mapDOType, mapDAType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
icdFile.setConfigList(new ArrayList<>(configMap.values()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<IcdIed> iedList = new ArrayList<>();
|
|
|
|
List<JsonNode> apList = findNodes(root, "ConnectedAP");
|
|
|
|
List<JsonNode> apList = findNodes(root, "ConnectedAP");
|
|
|
|
for (JsonNode apNode : apList) {
|
|
|
|
for (JsonNode apNode : apList) {
|
|
|
|
String iedName = apNode.get("iedName").asText();
|
|
|
|
IcdIed ied = processAPNode(apNode);
|
|
|
|
IcdConfigType config = iedMap.get(iedName);
|
|
|
|
iedList.add(ied);
|
|
|
|
if (config != null) {
|
|
|
|
|
|
|
|
processAPNode(apNode, config);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
icdFile.setIedList(iedList);
|
|
|
|
return iedMap;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void processAPNode(JsonNode apNode, IcdConfigType config) {
|
|
|
|
private static IcdIed processAPNode(JsonNode apNode) {
|
|
|
|
|
|
|
|
IcdIed ied = new IcdIed();
|
|
|
|
|
|
|
|
String iedName = apNode.get("iedName").asText();
|
|
|
|
|
|
|
|
ied.setName(iedName);
|
|
|
|
List<JsonNode> pList = findNodes(apNode, "P");
|
|
|
|
List<JsonNode> pList = findNodes(apNode, "P");
|
|
|
|
for (JsonNode pNode : pList) {
|
|
|
|
for (JsonNode pNode : pList) {
|
|
|
|
String type = pNode.get("type").asText();
|
|
|
|
String type = pNode.get("type").asText();
|
|
|
|
if ("IP".equalsIgnoreCase(type)) {
|
|
|
|
if ("IP".equalsIgnoreCase(type)) {
|
|
|
|
config.setIp(pNode.asText());
|
|
|
|
ied.setIp(pNode.get("").asText());
|
|
|
|
} else if ("OSI-AP-Title".equalsIgnoreCase(type)) {
|
|
|
|
} else if ("OSI-AP-Title".equalsIgnoreCase(type)) {
|
|
|
|
config.setApTitle(pNode.asText());
|
|
|
|
ied.setApTitle(pNode.get("").asText());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ied;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void processIEDNode(LinkedHashMap<String, IcdConfigType> iedMap, JsonNode iedNode,
|
|
|
|
private static void processIEDNode(LinkedHashMap<String, IcdConfigType> configMap, JsonNode iedNode,
|
|
|
|
Map<String, JsonNode> mapLNodeType, Map<String, JsonNode> mapDOType, Map<String, JsonNode> mapDAType) {
|
|
|
|
Map<String, JsonNode> mapLNodeType, Map<String, JsonNode> mapDOType, Map<String, JsonNode> mapDAType) {
|
|
|
|
String iedName = iedNode.get("name").asText();
|
|
|
|
String iedName = iedNode.get("name").asText();
|
|
|
|
|
|
|
|
|
|
|
|
List<JsonNode> devList = findNodes(iedNode, "LDevice");
|
|
|
|
List<JsonNode> devList = findNodes(iedNode, "LDevice");
|
|
|
|
for (JsonNode dev : devList) {
|
|
|
|
for (JsonNode dev : devList) {
|
|
|
|
processTypeDeviceNode(iedMap, iedName, dev,
|
|
|
|
processTypeDeviceNode(configMap, iedName, dev,
|
|
|
|
mapLNodeType, mapDOType, mapDAType);
|
|
|
|
mapLNodeType, mapDOType, mapDAType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void processTypeDeviceNode(LinkedHashMap<String, IcdConfigType> iedMap, String iedName, JsonNode deviceNode,
|
|
|
|
private static void processTypeDeviceNode(LinkedHashMap<String, IcdConfigType> configMap, String iedName, JsonNode deviceNode,
|
|
|
|
Map<String, JsonNode> mapLNodeType, Map<String, JsonNode> mapDOType, Map<String, JsonNode> mapDAType) {
|
|
|
|
Map<String, JsonNode> mapLNodeType, Map<String, JsonNode> mapDOType, Map<String, JsonNode> mapDAType) {
|
|
|
|
String ldeviceInst = deviceNode.get("inst").asText();
|
|
|
|
String ldeviceInst = deviceNode.get("inst").asText();
|
|
|
|
Map<String, JsonNode> mapLN = buildLNMap(deviceNode);
|
|
|
|
Map<String, JsonNode> mapLN = buildLNMap(deviceNode);
|
|
|
@ -111,7 +113,7 @@ public class IcdXmlUtil {
|
|
|
|
|
|
|
|
|
|
|
|
String key = iedName + ldeviceInst + "/" + lnClass;
|
|
|
|
String key = iedName + ldeviceInst + "/" + lnClass;
|
|
|
|
if ("MX".equals(fc)) {
|
|
|
|
if ("MX".equals(fc)) {
|
|
|
|
IcdConfigType config = iedMap.get(key);
|
|
|
|
IcdConfigType config = configMap.get(key);
|
|
|
|
if (config == null) {
|
|
|
|
if (config == null) {
|
|
|
|
config = IcdConfigType.builder()
|
|
|
|
config = IcdConfigType.builder()
|
|
|
|
.iedName(iedName)
|
|
|
|
.iedName(iedName)
|
|
|
@ -119,20 +121,20 @@ public class IcdXmlUtil {
|
|
|
|
.lnClass(lnClass)
|
|
|
|
.lnClass(lnClass)
|
|
|
|
.lnDesc(lnDesc)
|
|
|
|
.lnDesc(lnDesc)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
iedMap.put(key, config);
|
|
|
|
configMap.put(key, config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String param = fc + "$" + doName + "$" + lastname;
|
|
|
|
String param = fc + "$" + doName + "$" + lastname;
|
|
|
|
config.addInst(lnInst);
|
|
|
|
config.addInst(lnInst);
|
|
|
|
config.addAtt(doName, doDesc, param, lnInst);
|
|
|
|
config.addAtt(doName, doDesc, param, lnInst);
|
|
|
|
} else if ("ST".equals(fc)) {
|
|
|
|
} else if ("ST".equals(fc)) {
|
|
|
|
IcdConfigType config = iedMap.get(key);
|
|
|
|
IcdConfigType config = configMap.get(key);
|
|
|
|
if (config == null) {
|
|
|
|
if (config == null) {
|
|
|
|
config = IcdConfigType.builder()
|
|
|
|
config = IcdConfigType.builder()
|
|
|
|
.iedName(iedName)
|
|
|
|
.iedName(iedName)
|
|
|
|
.ldeviceInst(ldeviceInst)
|
|
|
|
.ldeviceInst(ldeviceInst)
|
|
|
|
.lnClass(lnClass)
|
|
|
|
.lnClass(lnClass)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
iedMap.put(key, config);
|
|
|
|
configMap.put(key, config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String param = fc + "$" + doName + "$" + lastname;
|
|
|
|
String param = fc + "$" + doName + "$" + lastname;
|
|
|
|
config.addInst(lnInst);
|
|
|
|
config.addInst(lnInst);
|
|
|
|