UpdateTask.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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.List;
  7. import java.util.Map;
  8. import com.alibaba.fastjson.JSON;
  9. import com.alibaba.fastjson.JSONArray;
  10. import com.alibaba.fastjson.JSONObject;
  11. import com.jfinal.kit.PropKit;
  12. import com.jfinal.plugin.activerecord.Db;
  13. import com.jfinal.plugin.activerecord.Record;
  14. import com.jfinal.plugin.cron4j.ITask;
  15. import com.zskk.service.DataService;
  16. import com.zskk.service.ServiceFactory;
  17. import com.zskk.service.ThreadPoolService;
  18. public class UpdateTask implements ITask {
  19. @Override
  20. public void run() {
  21. // TODO Auto-generated method stub
  22. DataService dService = ServiceFactory.getService(DataService.class);
  23. // JSONArray jsonArray = dService.getExamList(180);
  24. // for (Object object : jsonArray) {
  25. // try {
  26. // JSONObject jsonObject = JSON.parseObject(object.toString());
  27. List<Record> records = Db.use("connected").find("select top 20 * from reportinfo order by UpDateTime desc");
  28. for (Record record : records) {
  29. if (record == null) {
  30. continue;
  31. }
  32. if (record.getStr("IMPRESSION").isBlank() && record.getStr("DESCRIPTION").isBlank()) {
  33. continue;
  34. }
  35. Map<String, String> params = new HashMap<>();
  36. //1:exam_id 2:patient_num 3:accession_num 4:study_uid
  37. params.put("type", "2");
  38. params.put("institution_id", PropKit.get("institution_id"));
  39. params.put("code", record.getStr("PatientId"));
  40. //报告医生姓名
  41. params.put("report_doctor_name", record.getStr("ReportDoctor"));
  42. //报告时间
  43. params.put("report_datetime",record.getStr("ReportDate"));
  44. //审核医生姓名
  45. params.put("review_doctor_name", record.getStr("ReviewDoctor")==null?"":record.getStr("ReviewDoctor"));
  46. //审核时间
  47. params.put("review_datetime", record.getStr("ReviewDate"));
  48. //确认医生姓名
  49. params.put("confirm_doctor_name", record.getStr("ReviewDoctor")==null?"":record.getStr("ReviewDoctor"));
  50. //确认时间
  51. params.put("confirm_datetime", 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("ReqDept"));
  59. //申请医生
  60. params.put("application_doctor", record.getStr("ReqDoctor"));
  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("PatName"));
  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. // params.put("report_result", "");
  75. //住院号
  76. params.put("hopitalized_no", record.getStr("InPatientNum"));
  77. //门诊号
  78. params.put("out_patient", record.getStr("OutPatientNum"));
  79. //病人ID
  80. // params.put("his_patient_id", record.getStr("InPatientNum"));
  81. //检查方法
  82. params.put("exam_project", record.getStr("ExamItem"));
  83. ThreadPoolService tService = ServiceFactory.getService(ThreadPoolService.class);
  84. tService.execute(() -> {
  85. dService.saveReport(params);
  86. });
  87. //匹配支付状态
  88. if (record.getStr("ExamItem").contains("无片")) {
  89. JSONObject jsonObject = new JSONObject();
  90. //机构ID
  91. jsonObject.put("institution_id", PropKit.get("institution_id"));
  92. jsonObject.put("patient_num", record.getStr("PatientId"));
  93. //机构类型:1:accession_num:patient_num
  94. jsonObject.put("ins_type", "2");
  95. JSONObject pJsonObject = new JSONObject();
  96. pJsonObject.put("params", jsonObject.toJSONString());
  97. tService.execute(() -> {
  98. dService.fee(pJsonObject);
  99. });
  100. }
  101. }
  102. // } catch (Exception e) {
  103. // // TODO: handle exception
  104. // continue;
  105. // }
  106. // }
  107. }
  108. @Override
  109. public void stop() {
  110. // TODO Auto-generated method stub
  111. }
  112. /**
  113. * 日期字符串格式转换
  114. * @param dateStr
  115. * @return
  116. */
  117. private String parseStringToDate(String dateStr) {
  118. if (dateStr == null) {
  119. return "";
  120. }
  121. SimpleDateFormat sdf= new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
  122. Date date = null;
  123. String timeString = null;
  124. try {
  125. date = sdf.parse(dateStr);
  126. SimpleDateFormat sdf2= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  127. timeString = sdf2.format(date);
  128. } catch (ParseException e) {
  129. // TODO Auto-generated catch block
  130. e.printStackTrace();
  131. }
  132. return timeString;
  133. }
  134. }