From c8c780b97726264b39ceae192239c4cd46380134 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期四, 29 八月 2024 12:00:18 +0800
Subject: [PATCH] 工单取图片多线程
---
ycl-server/src/main/java/com/ycl/api/HK/HKApi.java | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/api/HK/HKApi.java b/ycl-server/src/main/java/com/ycl/api/HK/HKApi.java
index 8998fad..1b4e116 100644
--- a/ycl-server/src/main/java/com/ycl/api/HK/HKApi.java
+++ b/ycl-server/src/main/java/com/ycl/api/HK/HKApi.java
@@ -8,14 +8,22 @@
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.StringReader;
import java.net.URI;
@Slf4j
public class HKApi {
- public static void test() {
+ public static void getOsdByIP(String ip) {
DefaultHttpClient httpclient = new DefaultHttpClient();
- String hostUrl = "http://51.95.68.80";
+ String hostUrl = "http://" + ip;
// 鑾峰彇鐒﹁窛
String url = hostUrl + "/ISAPI/System/Video/inputs/channels/1/overlays";
URI serverURI = null;
@@ -36,8 +44,20 @@
HttpResponse response = httpclient.execute(httpGet);
String resultString = EntityUtils.toString(response.getEntity(), "utf-8");
-
log.info(resultString);
+ //瑙f瀽xml
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document document = builder.parse(new InputSource(new StringReader(resultString)));
+ document.getDocumentElement().normalize();
+ NodeList nodeList = document.getElementsByTagName("TextOverlay");
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element) node;
+ log.info("TEXT : " + element.getElementsByTagName("displayText").item(0).getTextContent());
+ }
+ }
} catch (Exception e) {
e.printStackTrace();
}
--
Gitblit v1.8.0