DataTask.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. package com.zskk.task;
  2. import java.text.ParseException;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Date;
  5. import java.util.HashMap;
  6. import java.util.Map;
  7. import com.alibaba.fastjson.JSON;
  8. import com.alibaba.fastjson.JSONArray;
  9. import com.alibaba.fastjson.JSONObject;
  10. import com.jfinal.kit.PropKit;
  11. import com.jfinal.plugin.activerecord.Db;
  12. import com.jfinal.plugin.activerecord.Record;
  13. import com.jfinal.plugin.cron4j.ITask;
  14. import com.zskk.service.DataService;
  15. import com.zskk.service.ServiceFactory;
  16. import com.zskk.service.ThreadPoolService;
  17. public class DataTask implements ITask {
  18. @Override
  19. public void run() {
  20. // TODO Auto-generated method stub
  21. DataService dService = ServiceFactory.getService(DataService.class);
  22. JSONArray jsonArray = dService.getExamList(80);
  23. for (Object object : jsonArray) {
  24. JSONObject jsonObject = JSON.parseObject(object.toString());
  25. Record record = Db.use("connected").findFirst("select * from reportinfo where accessionNumber=?",
  26. jsonObject.getString("accession_num"));
  27. if (record == null) {
  28. continue;
  29. }
  30. if (record.getStr("description") == null && record.getStr("result") == null) {
  31. continue;
  32. }
  33. Map<String, String> params = new HashMap<>();
  34. params.put("type", "1");
  35. params.put("institution_id", PropKit.get("institution_id"));
  36. params.put("code", jsonObject.getString("id"));
  37. // 报告医生姓名
  38. params.put("report_doctor_name", record.getStr("reportdoctor"));
  39. // 报告时间
  40. params.put("report_datetime", record.getStr("reportDate"));
  41. // 审核医生姓名
  42. params.put("review_doctor_name",
  43. record.getStr("reviewdoctor") == null ? "" : record.getStr("reviewdoctor"));
  44. // 审核时间
  45. params.put("review_datetime", record.getStr("reviewdate"));
  46. // 确认医生姓名
  47. params.put("confirm_doctor_name",
  48. record.getStr("reviewdoctor") == null ? "" : record.getStr("reviewdoctor"));
  49. // 确认时间
  50. params.put("confirm_datetime", record.getStr("reviewdate"));
  51. // 意见建议
  52. params.put("impression", record.getStr("result"));
  53. // 影像所见
  54. params.put("description", record.getStr("description"));
  55. // exams表
  56. // 申请科室
  57. params.put("application_department", record.getStr("department"));
  58. // 申请医生
  59. params.put("application_doctor", record.getStr("clinicaldoctor"));
  60. // 临床诊断
  61. params.put("clin_diag", record.getStr("diagnosis") == null ? "" : record.getStr("diagnosis"));
  62. // 症状
  63. params.put("clin_symp", record.getStr("symptom") == null ? "" : record.getStr("symptom"));
  64. // patient_infos表
  65. // 患者姓名
  66. params.put("name", record.getStr("patientName"));
  67. // 患者手机号
  68. params.put("phone", record.getStr("phone") == null ? "" : record.getStr("phone"));
  69. // 患者身份证号
  70. params.put("card_num", record.getStr("IDCard") == null ? "" : record.getStr("IDCard"));
  71. // 检查结果1阴2阳
  72. params.put("report_result", "0");
  73. // 门诊号住院号
  74. params.put("hopitalized_no", record.getStr("inPatientNum") == null ? "" : record.getStr("inPatientNum"));
  75. // 门诊号
  76. params.put("out_patient", record.getStr("outPatientNum") == null ? "" : record.getStr("outPatientNum"));
  77. // 病人ID
  78. params.put("his_patient_id", record.getStr("patientNum") == null ? "" : record.getStr("patientNum"));
  79. // 检查方法
  80. params.put("exam_project", record.getStr("project"));
  81. ThreadPoolService tService = ServiceFactory.getService(ThreadPoolService.class);
  82. tService.execute(() -> {
  83. dService.saveReport(params);
  84. });
  85. }
  86. }
  87. @Override
  88. public void stop() {
  89. // TODO Auto-generated method stub
  90. }
  91. /**
  92. * 日期字符串格式转换
  93. *
  94. * @param dateStr
  95. * @return
  96. */
  97. private String parseStringToDate(String dateStr) {
  98. if (dateStr == null) {
  99. SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  100. Date date = new Date();
  101. String timeString = null;
  102. timeString = sdf2.format(date);
  103. return timeString;
  104. }
  105. return dateStr;
  106. }
  107. }