刘韬 3 years ago
parent
commit
73663050a5

+ 1 - 1
DataFusion/src/com/zskk/config/ZskkConfig.java

@@ -92,7 +92,7 @@ public class ZskkConfig extends JFinalConfig {
 //		me.add(cpData);
 //		
 		Cron4jPlugin inData = new Cron4jPlugin();
-		inData.addTask("14 18 * * *", new UpdateTask());
+		inData.addTask("35 19 * * *", new UpdateTask());
 		me.add(inData);
 //		
 		Cron4jPlugin cgData = new Cron4jPlugin();

+ 28 - 12
DataFusion/src/com/zskk/service/DataService.java

@@ -97,7 +97,7 @@ public class DataService {
 	}
     
     public static void main(String[] args) throws IOException, ParserConfigurationException {
-    	File fin_floder = new File("/Users/liutao/Desktop/test/test81.xml");
+    	File fin_floder = new File("/Users/liutao/Desktop/test/test111.xml");
 
 		//创建从文件读取数据的FileInputStream流
 		FileInputStream fin;
@@ -124,19 +124,35 @@ public class DataService {
 			System.out.println(s);
 		    XmlHelper xmlHelper = XmlHelper.of(s);
 
-		    NodeList nodeList = xmlHelper.getNodeList("/a/NativeDicomModel/DicomAttribute");
+		    NodeList nodeList = xmlHelper.getNodeList("/a/NativeDicomModel");
 		    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("/a/NativeDicomModel["+i+"]/DicomAttribute["+j+"]/Value");
-							System.out.println(xmlHelper.getString(nodeList.item(i), "Value"));
+		    	String qString="";
+		    	NodeList nodeList2 =xmlHelper.getNodeList(nodeList.item(i),"DicomAttribute");
+		    	for (int k = 0; k < nodeList2.getLength(); k++) {
+//					System.out.println(k);
+					NamedNodeMap as = nodeList2.item(k).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("/a/NativeDicomModel["+i+"]/DicomAttribute["+j+"]/Value");
+//								System.out.println(xmlHelper.getString(nodeList2.item(k), "Value"));
+								qString =qString+"*"+xmlHelper.getString(nodeList2.item(k), "Value")+"**";
+							}
 						}
-					}
-			      }
-			    }
+				    	  if (as.item(j).getNodeName().equals("tag")) {
+								if (as.item(j).getNodeValue().equals("00080061")) {
+									String b =xmlHelper.getString("/a/NativeDicomModel["+i+"]/DicomAttribute["+j+"]/Value");
+//									System.out.println(xmlHelper.getString(nodeList2.item(k), "Value"));
+									qString =qString+"*"+xmlHelper.getString(nodeList2.item(k), "Value")+"**";
+
+								}
+							}
+				      }
+				    }
+		    	
+		    	}
+				System.out.println(qString);
 			}
 		    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
 			Date date = new Date();

+ 33 - 27
DataFusion/src/com/zskk/task/UpdateTask.java

@@ -3,16 +3,12 @@ package com.zskk.task;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.List;
-
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.NodeList;
-
 import com.jfinal.plugin.activerecord.Db;
 import com.jfinal.plugin.activerecord.Record;
 import com.jfinal.plugin.cron4j.ITask;
@@ -34,32 +30,44 @@ public class UpdateTask implements ITask {
 			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("/zskk/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);
+			String xmlContent = null;
+			xmlContent = raf.readLine();
+			xmlContent = xmlContent.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "");
+			xmlContent = "<zskk>" + xmlContent + "</zskk>";
+			XmlHelper xmlHelper = XmlHelper.of(xmlContent);
+			// NativeDicomModel节点列表
+			NodeList nativeDicomModelList = xmlHelper.getNodeList("/zskk/NativeDicomModel");
+			for (int i = 0; i < nativeDicomModelList.getLength(); i++) {
+				String qString = "";
+				String studyuidString = "";
+				String modalitiesString = "";
+				// DicomAttribute节点列表
+				NodeList dicomAttributeList = xmlHelper.getNodeList(nativeDicomModelList.item(i), "DicomAttribute");
+				for (int j = 0; j < dicomAttributeList.getLength(); j++) {
+					// DicomAttribute节点属性列表
+					NamedNodeMap attributeMap = dicomAttributeList.item(j).getAttributes();
+					if (attributeMap != null && attributeMap.getLength() > 0) {
+						for (int k = 0; k < attributeMap.getLength(); k++) {
+							if (attributeMap.item(k).getNodeName().equals("tag")) {
+								// 获取studyuid
+								if (attributeMap.item(k).getNodeValue().equals("0020000D")) {
+									studyuidString = xmlHelper.getString(dicomAttributeList.item(j), "Value");
+								}
+								// 获取检查类型
+								if (attributeMap.item(j).getNodeValue().equals("00080061")) {
+									modalitiesString = xmlHelper.getString(dicomAttributeList.item(j), "Value");
 								}
 							}
 						}
 					}
 				}
+				Record studyidfind = Db.use("local").findFirst("select * from study where studyuid = ?",
+						studyuidString);
+				if (studyidfind == null) {
+					Record studyinfo = new Record().set("studyuid", studyuidString).set("modalities", modalitiesString)
+							.set("status", 1).set("createAt", new Date()).set("updateAt", new Date());
+					Db.use("local").save("study", studyinfo);
+				}
 			}
 		} catch (IOException e) {
 			// TODO Auto-generated catch block
@@ -73,7 +81,6 @@ public class UpdateTask implements ITask {
 
 	}
 
-
 	/**
 	 * 日期字符串格式转换
 	 * 
@@ -89,5 +96,4 @@ public class UpdateTask implements ITask {
 
 	}
 
-
 }