|
@@ -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 {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|