刘韬 3 gadi atpakaļ
vecāks
revīzija
ad9ed3e88b

+ 5 - 0
DataFusion/src/com/zskk/config/ZskkConfig.java

@@ -17,6 +17,7 @@ import com.jfinal.plugin.druid.DruidPlugin;
 import com.jfinal.template.Engine;
 import com.zskk.control.ViewController;
 import com.zskk.service.ServiceFactory;
+import com.zskk.task.BackTask;
 import com.zskk.task.DataTask;
 import com.zskk.task.UpdateTask;
 
@@ -90,6 +91,10 @@ public class ZskkConfig extends JFinalConfig {
 		Cron4jPlugin upData = new Cron4jPlugin();
 		upData.addTask("*/5 * * * *", new UpdateTask());
 		me.add(upData);
+		
+		Cron4jPlugin bkData = new Cron4jPlugin();
+		bkData.addTask("*/5 * * * *", new BackTask());
+		me.add(bkData);
 	}
 
 	@Override

+ 88 - 0
DataFusion/src/com/zskk/task/BackTask.java

@@ -0,0 +1,88 @@
+package com.zskk.task;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.jfinal.kit.PropKit;
+import com.jfinal.plugin.activerecord.Db;
+import com.jfinal.plugin.activerecord.Record;
+import com.jfinal.plugin.cron4j.ITask;
+import com.zskk.service.DataService;
+import com.zskk.service.ServiceFactory;
+import com.zskk.service.ThreadPoolService;
+
+public class BackTask implements ITask {
+
+	@Override
+	public void run() {
+		// TODO Auto-generated method stub
+		DataService dService = ServiceFactory.getService(DataService.class);
+		Map<String, String> params = new HashMap<>();
+		//报告状态
+		params.put("report_status", "9");
+		//医疗机构ID
+		params.put("institution_id", PropKit.get("institution_id"));
+		//时间段
+		params.put("time", parseStringToDate());
+
+		JSONArray jsonArray = dService.getReport(params);
+		for (Object object : jsonArray) {
+			JSONObject jsonObject = JSON.parseObject(object.toString());
+			Record recordfind = Db.use("local").findFirst("select * from report where studyuid=?", jsonObject.getString("studyuid"));;
+			if (recordfind != null) {
+				continue;
+			}
+			Record record = new Record();
+			record.set("name", jsonObject.getString("name"));
+			record.set("sex", jsonObject.getString("sex"));
+			record.set("phone", jsonObject.getString("phone"));
+			record.set("card_num", jsonObject.getString("card_num"));
+			record.set("hopitalized_no", jsonObject.getString("hopitalized_no"));
+			record.set("out_patient", jsonObject.getString("out_patient"));
+			record.set("accession_num", jsonObject.getString("accession_num"));
+			record.set("patient_num", jsonObject.getString("patient_num"));
+			record.set("studyuid", jsonObject.getString("studyuid"));
+			record.set("his_patient_id", jsonObject.getString("his_patient_id"));
+			record.set("impression", jsonObject.getString("impression"));
+			record.set("description", jsonObject.getString("description"));
+			record.set("report_datetime", jsonObject.getString("report_datetime"));
+			record.set("report_doctor_name", jsonObject.getString("report_doctor_name"));
+			record.set("review_doctor_name", jsonObject.getString("review_doctor_name"));
+			record.set("review_datetime", jsonObject.getString("review_datetime"));
+			record.set("report_result", jsonObject.getString("report_result"));
+			record.set("status", 1);
+			Db.use("local").save("report", record);
+		}
+		
+	
+
+	}
+
+	@Override
+	public void stop() {
+		// TODO Auto-generated method stub
+
+	}
+	
+	/**
+	 * 日期字符串格式转换
+	 * @param dateStr
+	 * @return
+	 */
+	private String parseStringToDate() {
+		SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+	    Date date = new Date();
+	    Long dateBeforeLong = date.getTime()-86400000;
+	    Date dateBefore = new Date(dateBeforeLong);
+	    String timeStringBefore = sdf.format(dateBefore);
+	    String timeString = sdf.format(date);
+		
+        return timeStringBefore + "," + timeString;
+	}
+
+}

+ 17 - 18
DataFusion/src/com/zskk/task/UpdateTask.java

@@ -32,30 +32,29 @@ public class UpdateTask implements ITask {
 
 		JSONArray jsonArray = dService.getReport(params);
 		for (Object object : jsonArray) {
-
 			JSONObject jsonObject = JSON.parseObject(object.toString());
 			Record recordfind = Db.use("local").findFirst("select * from report where studyuid=?", jsonObject.getString("studyuid"));;
 			if (recordfind != null) {
 				continue;
 			}
 			Record record = new Record();
-			record.set("name", jsonObject.getString("name"));
-			record.set("sex", jsonObject.getString("sex"));
-			record.set("phone", jsonObject.getString("phone"));
-			record.set("card_num", jsonObject.getString("card_num"));
-			record.set("hopitalized_no", jsonObject.getString("hopitalized_no"));
-			record.set("out_patient", jsonObject.getString("out_patient"));
-			record.set("accession_num", jsonObject.getString("accession_num"));
-			record.set("patient_num", jsonObject.getString("patient_num"));
-			record.set("studyuid", jsonObject.getString("studyuid"));
-			record.set("his_patient_id", jsonObject.getString("his_patient_id"));
-			record.set("impression", jsonObject.getString("impression"));
-			record.set("description", jsonObject.getString("description"));
-			record.set("report_datetime", jsonObject.getString("report_datetime"));
-			record.set("report_doctor_name", jsonObject.getString("report_doctor_name"));
-			record.set("review_doctor_name", jsonObject.getString("review_doctor_name"));
-			record.set("review_datetime", jsonObject.getString("review_datetime"));
-			record.set("report_result", jsonObject.getString("report_result"));
+			record.set("name", jsonObject.getString("name")==null?"":jsonObject.getString("name"));
+			record.set("sex", jsonObject.getString("sex")==null?"":jsonObject.getString("sex"));
+			record.set("phone", jsonObject.getString("phone")==null?"":jsonObject.getString("phone"));
+			record.set("card_num", jsonObject.getString("card_num")==null?"":jsonObject.getString("card_num"));
+			record.set("hopitalized_no", jsonObject.getString("hopitalized_no")==null?"":jsonObject.getString("hopitalized_no"));
+			record.set("out_patient", jsonObject.getString("out_patient")==null?"":jsonObject.getString("out_patient"));
+			record.set("accession_num", jsonObject.getString("accession_num")==null?"":jsonObject.getString("accession_num"));
+			record.set("patient_num", jsonObject.getString("patient_num")==null?"":jsonObject.getString("patient_num"));
+			record.set("studyuid", jsonObject.getString("studyuid")==null?"":jsonObject.getString("studyuid"));
+			record.set("his_patient_id", jsonObject.getString("his_patient_id")==null?"":jsonObject.getString("his_patient_id"));
+			record.set("impression", jsonObject.getString("impression")==null?"":jsonObject.getString("impression"));
+			record.set("description", jsonObject.getString("description")==null?"":jsonObject.getString("description"));
+			record.set("report_datetime", jsonObject.getString("report_datetime")==null?"":jsonObject.getString("report_datetime"));
+			record.set("report_doctor_name", jsonObject.getString("report_doctor_name")==null?"":jsonObject.getString("report_doctor_name"));
+			record.set("review_doctor_name", jsonObject.getString("review_doctor_name")==null?"":jsonObject.getString("review_doctor_name"));
+			record.set("review_datetime", jsonObject.getString("review_datetime")==null?"":jsonObject.getString("review_datetime"));
+			record.set("report_result", jsonObject.getString("report_result")==null?"":jsonObject.getString("report_result"));
 			record.set("status", 1);
 			Db.use("local").save("report", record);
 		}