|
@@ -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;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|