刘韬 před 3 roky
rodič
revize
081b7bbe76

+ 58 - 5
DataFusion/src/com/zskk/control/ViewController.java

@@ -65,14 +65,67 @@ public class ViewController extends Controller {
 		 List<String> files = new ArrayList<String>();
 	        File file = new File("/home/zskk/CFIND_XML");
 	        File[] tempList = file.listFiles();
-	        for (int j = 0; j < tempList.length; j++) {
-	            if (tempList[j].isFile()) {
-	                files.add(tempList[j].toString());
+	        for (int m = 0; m < tempList.length; m++) {
+	            if (tempList[m].isFile()) {
+	                files.add(tempList[m].toString());
 	                //文件名,不包含路径
-	                String fileName = tempList[j].getName();
+	                String fileName = tempList[m].getName();
 	               fileName2String = fileName2String+fileName+"**";
+	               File fin_floder = new File("/home/zskk/CFIND_XML/" + fileName);
+	       		// 创建从文件读取数据的FileInputStream流
+	       		FileInputStream fin;
+	       		try {
+	       			fin = new FileInputStream(fin_floder);
+	       			InputStreamReader isr = null;
+	       			isr = new InputStreamReader(fin);
+	       			BufferedReader raf = null;
+	       			raf = new BufferedReader(isr);
+	       			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");
+	       									continue;
+	       								}
+	       								// 获取检查类型
+	       								if (attributeMap.item(k).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", parseStringToDateTime()).set("updateAt", parseStringToDateTime());
+	       					Db.use("local").save("study", studyinfo);
+	       				}
+	       			}
+	       		} catch (IOException e) {
+	       			// TODO Auto-generated catch block
+	       			e.printStackTrace();
+	       		}
 	            }
-	            if (tempList[j].isDirectory()) {
+	            if (tempList[m].isDirectory()) {
 	                //这里就不递归了,
 	            }