rengb 5 лет назад
Родитель
Сommit
ddb84bbbbc

+ 5 - 0
public/pom.xml

@@ -33,6 +33,11 @@
             <artifactId>guava</artifactId>
             <version>18.0</version>
         </dependency>
+        <dependency>
+            <groupId>dom4j</groupId>
+            <artifactId>dom4j</artifactId>
+            <version>1.6.1</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 13 - 0
public/src/main/java/com/lantone/qc/pub/util/StringUtil.java

@@ -67,6 +67,19 @@ public class StringUtil {
         return str.replaceAll("\r|\n|\r\n|/r/n", "").trim();
     }
 
+    /**
+     * 清除字符串中的空白
+     *
+     * @param str
+     * @return
+     */
+    public static String removeBlank(String str) {
+        if (isBlank(str)) {
+            return str;
+        }
+        return str.replaceAll("[\\s\\p{Zs}]", "");
+    }
+
     /**
      * 比较两个列表的内容
      */

+ 0 - 19
public/src/main/java/com/lantone/qc/pub/util/XmlUtil.java

@@ -1,19 +0,0 @@
-package com.lantone.qc.pub.util;
-
-import com.google.common.collect.Maps;
-
-import java.util.Map;
-
-/**
- * @Description: xml解析工具
- * @author: rengb
- * @time: 2020/3/28 14:23
- */
-public class XmlUtil {
-
-    public static Map<String, String> getXmlToMap(String xml) {
-        Map<String, String> retMap = Maps.newHashMap();
-        return retMap;
-    }
-
-}

+ 35 - 0
trans/src/main/java/com/lantone/qc/trans/taizhou/util/TzXmlUtil.java

@@ -0,0 +1,35 @@
+package com.lantone.qc.trans.taizhou.util;
+
+import com.google.common.collect.Maps;
+import com.lantone.qc.pub.util.StringUtil;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: xml解析工具
+ * @author: rengb
+ * @time: 2020/3/28 14:23
+ */
+public class TzXmlUtil {
+
+    public static Map<String, String> getXmlToMapForTZ(String xml) {
+        Map<String, String> retMap = Maps.newHashMap();
+        try {
+            Document doc = DocumentHelper.parseText(xml);
+            List<Element> emrTermElements = doc.getRootElement().element("BLHLNR").element("emr_xml_root").element("TermList").elements("EMR-TERM");
+            emrTermElements.forEach(emrTermElement -> {
+                retMap.put(
+                        StringUtil.removeBlank(emrTermElement.attributeValue("ename")),
+                        emrTermElement.getStringValue().trim()
+                );
+            });
+        } catch (Exception e) {
+        }
+        return retMap;
+    }
+
+}