DataTask.java 4.2 KB

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