|
@@ -1,22 +1,80 @@
|
|
|
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;
|
|
|
+import com.zskk.tools.XmlHelper;
|
|
|
|
|
|
public class UpdateTask implements ITask {
|
|
|
|
|
|
@Override
|
|
|
public void run() {
|
|
|
// TODO Auto-generated method stub
|
|
|
- List<Record> records = Db.use("connected").find("select StudyInstanceUID,PatientStudyDate from reportinfo_image where PatientStudyDate>? group by PatientStudyDate,StudyInstanceUID order by PatientStudyDate desc", parseStringToDate());
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Record> records = Db.use("connected").find(
|
|
|
+ "select StudyInstanceUID,PatientStudyDate from reportinfo_image where PatientStudyDate>? group by PatientStudyDate,StudyInstanceUID order by PatientStudyDate desc",
|
|
|
+ parseStringToDate());
|
|
|
for (Record record : records) {
|
|
|
- Record studyidfind = Db.use("local").findFirst("select * from study where studyuid = ?",record.getStr("StudyInstanceUID"));
|
|
|
+ Record studyidfind = Db.use("local").findFirst("select * from study where studyuid = ?",
|
|
|
+ record.getStr("StudyInstanceUID"));
|
|
|
if (studyidfind == null) {
|
|
|
- Record studyinfo = new Record().set("studyuid", record.getStr("StudyInstanceUID")).set("status", 1).set("createAt", record.getStr("PatientStudyDate"));
|
|
|
+ Record studyinfo = new Record().set("studyuid", record.getStr("StudyInstanceUID")).set("status", 1)
|
|
|
+ .set("createAt", record.getStr("PatientStudyDate"));
|
|
|
Db.use("local").save("study", studyinfo);
|
|
|
}
|
|
|
}
|
|
@@ -27,7 +85,8 @@ public class UpdateTask implements ITask {
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 日期字符串格式转换
|
|
|
*
|
|
@@ -35,12 +94,13 @@ public class UpdateTask implements ITask {
|
|
|
* @return
|
|
|
*/
|
|
|
private String parseStringToDate() {
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
Date date = new Date();
|
|
|
- long dInteger = date.getTime() - 600000;
|
|
|
+ long dInteger = date.getTime() - 86400000;
|
|
|
String daString = sdf.format(new Date(dInteger));
|
|
|
return daString;
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|