|
@@ -1,6 +1,10 @@
|
|
|
package com.zskk.control;
|
|
|
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStreamReader;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
@@ -8,6 +12,9 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import org.w3c.dom.NamedNodeMap;
|
|
|
+import org.w3c.dom.NodeList;
|
|
|
+
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.jfinal.core.Controller;
|
|
|
import com.jfinal.kit.PropKit;
|
|
@@ -16,6 +23,7 @@ import com.jfinal.plugin.activerecord.Db;
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
import com.jfinal.plugin.activerecord.dialect.SqlServerDialect;
|
|
|
import com.jfinal.plugin.druid.DruidPlugin;
|
|
|
+import com.zskk.tools.XmlHelper;
|
|
|
|
|
|
import okhttp3.FormBody;
|
|
|
import okhttp3.MediaType;
|
|
@@ -53,6 +61,54 @@ public class ViewController extends Controller {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void mysql() {
|
|
|
+ String dateString = parseStringToDate();
|
|
|
+ String fileString = dateString.replace("0", "o");
|
|
|
+ File fin_floder = new File("/home/zskk/CFIND_XML/STUDYUID_" + fileString + "1.xml");
|
|
|
+ // 创建从文件读取数据的FileInputStream流
|
|
|
+ FileInputStream fin;
|
|
|
+ try {
|
|
|
+ fin = new FileInputStream(fin_floder);
|
|
|
+ InputStreamReader isr = null;
|
|
|
+ isr = new InputStreamReader(fin);
|
|
|
+ BufferedReader raf = null;
|
|
|
+ raf = new BufferedReader(isr);
|
|
|
+ String s = null;
|
|
|
+ s = raf.readLine();
|
|
|
+ s = s.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "");
|
|
|
+ s = "<zskk>" + s + "</zskk>";
|
|
|
+ System.out.println(s);
|
|
|
+ XmlHelper xmlHelper = XmlHelper.of(s);
|
|
|
+ NodeList nodeList = xmlHelper.getNodeList("/a/NativeDicomModel/DicomAttribute");
|
|
|
+ for (int i = 0; i < nodeList.getLength(); i++) {
|
|
|
+ NamedNodeMap as = nodeList.item(i).getAttributes();
|
|
|
+ if (as != null && as.getLength() > 0) {
|
|
|
+ for (int j = 0; j < as.getLength(); j++) {
|
|
|
+ if (as.item(j).getNodeName().equals("tag")) {
|
|
|
+ if (as.item(j).getNodeValue().equals("0020000D")) {
|
|
|
+// String b = xmlHelper.getString("/zskk/NativeDicomModel[" + i + "]/DicomAttribute[" + j + "]/Value");
|
|
|
+// System.out.println(xmlHelper.getString(nodeList.item(i), "Value"));
|
|
|
+ String studyuidString = xmlHelper.getString(nodeList.item(i), "Value");
|
|
|
+ Record studyidfind = Db.use("local").findFirst("select * from study where studyuid = ?",
|
|
|
+ studyuidString);
|
|
|
+ if (studyidfind == null) {
|
|
|
+ Record studyinfo = new Record().set("studyuid", studyuidString);
|
|
|
+ Db.use("local").save("study", studyinfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ renderText(e.toString());
|
|
|
+ }
|
|
|
+ renderText("a");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public static DruidPlugin createConnectedDruidPlugin() {
|
|
|
|
|
|
return new DruidPlugin(PropKit.get("jdbcUrl_connected"), PropKit.get("user_connected"),PropKit.get("password_connected").trim());
|
|
@@ -84,5 +140,14 @@ public class ViewController extends Controller {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private String parseStringToDate() {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
+ Date date = new Date();
|
|
|
+ long dInteger = date.getTime() - 86400000;
|
|
|
+ String daString = sdf.format(new Date(dInteger));
|
|
|
+ return daString;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|