package com.zskk.task; 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 DataTask implements ITask { @Override public void run() { // TODO Auto-generated method stub DataService dService = ServiceFactory.getService(DataService.class); JSONArray jsonArray = dService.getExamList(120); for (Object object : jsonArray) { try { JSONObject jsonObject = JSON.parseObject(object.toString()); Record record = Db.use("connected").findFirst("select * from reportinfo where examNo=?", jsonObject.getString("patient_num")); if (record == null) { continue; } if (record.getStr("description") == null && record.getStr("impression") == null) { continue; } Map params = new HashMap<>(); //1:exam_id 2:patient_num 3:accession_num 4:study_uid params.put("type", "1"); params.put("institution_id", PropKit.get("institution_id")); params.put("code", jsonObject.getString("id")); // 报告医生姓名 params.put("report_doctor_name", record.getStr("reportdoctor")); // 报告时间 params.put("report_datetime", parseStringToDate(record.getStr("reportdate"))); // 审核医生姓名 params.put("review_doctor_name", record.getStr("reviewdoctor") == null ? "" : record.getStr("reviewdoctor")); // 审核时间 params.put("review_datetime", parseStringToDate(record.getStr("reviewdate"))); // 确认医生姓名 params.put("confirm_doctor_name", record.getStr("reviewdoctor") == null ? "" : record.getStr("reviewdoctor")); // 确认时间 params.put("confirm_datetime", parseStringToDate(record.getStr("reviewdate"))); // 意见建议 params.put("impression", record.getStr("impression")); // 影像所见 params.put("description", record.getStr("description")); // exams表 // 申请科室 params.put("application_department", record.getStr("department")); // 申请医生 params.put("application_doctor", record.getStr("clinicaldoctor")); // 临床诊断 params.put("clin_diag", record.getStr("diagnosis") == null ? "" : record.getStr("diagnosis")); // 症状 params.put("clin_symp", record.getStr("symptom") == null ? "" : record.getStr("symptom")); // patient_infos表 // 患者姓名 params.put("name", record.getStr("patientname")); // 患者手机号 params.put("phone", record.getStr("phone") == null ? "" : record.getStr("phone")); // 患者身份证号 params.put("card_num", record.getStr("idcard") == null ? "" : record.getStr("idcard")); // 检查结果1阴2阳 params.put("report_result", record.getStr("result").contains("阳") ? "2" : "1"); // 门诊号住院号 params.put("hopitalized_no", record.getStr("inPatientNum") == null ? "" : record.getStr("inPatientNum")); // 门诊号 params.put("out_patient", record.getStr("outPatientNum") == null ? "" : record.getStr("outPatientNum")); // 病人ID params.put("his_patient_id", record.getStr("patientid") == null ? "" : record.getStr("patientid")); // 检查方法 params.put("exam_project", record.getStr("project")); ThreadPoolService tService = ServiceFactory.getService(ThreadPoolService.class); tService.execute(() -> { dService.saveReport(params); }); } catch (Exception e) { // TODO: handle exception continue; } } } @Override public void stop() { // TODO Auto-generated method stub } /** * 日期字符串格式转换 * * @param dateStr * @return */ private String parseStringToDate(String dateStr) { if (dateStr == null) { SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(); String timeString = null; timeString = sdf2.format(date); return timeString; } return dateStr; } }