DataTask.java 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. package com.zskk.task;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.jfinal.plugin.activerecord.Db;
  5. import com.jfinal.plugin.activerecord.Record;
  6. import com.jfinal.plugin.cron4j.ITask;
  7. import com.zskk.model.Doctors;
  8. import com.zskk.model.Exams;
  9. import java.text.ParseException;
  10. import java.text.SimpleDateFormat;
  11. import java.util.*;
  12. import static com.zskk.task.SendPostUtil.sendPost;
  13. public class DataTask implements ITask {
  14. //请求路径
  15. public final static String url = "https://risserver3.pacsonline.cn/butt/getExam/butt/getExam";
  16. public final static String url_ = "https://risserver3.pacsonline.cn/butt/getExam/butt/saveReport";
  17. @Override
  18. public void run() {
  19. // TODO Auto-generated method stub
  20. try {
  21. //List<Exams> exams = Exams.dao.use("zskk").find("SELECT * FROM pacsonline.exams where exam_status=3 and institution_id=46400001 order by createdAt desc limit 50");
  22. String s=sendPost(url, "institution_id", "13000003");
  23. JSONObject jsonObject = JSONObject.parseObject(s);
  24. String data = jsonObject.getString("data");
  25. List<Exams> exams = JSONArray.parseArray(data,Exams.class);
  26. for (Exams exams2 : exams) {
  27. try {
  28. // Studies studies = Studies.dao.use("zskk").findById(exams2.getStudyId());
  29. Record record = Db.use("connected").findFirst("select * from hhris.view_reportinfo where ACCESSIONNUMBER=?",exams2.getAccessionNum());
  30. if (record == null) {
  31. continue;
  32. }
  33. Map<String, String> params = new HashMap<>();
  34. //exams表
  35. params.put("exam_id",exams2.getId());
  36. //报告医生姓名
  37. params.put("report_doctor_name",record.getStr("REPORTDOCTOR"));
  38. //报告时间
  39. params.put("report_datetime",record.getStr("REPORTDATE"));
  40. //审核医生姓名
  41. params.put("review_doctor_name",record.getStr("REVIEWDOCTOR"));
  42. //审核时间
  43. params.put("review_datetime",record.getStr("REPORTDATE"));
  44. //确认医生姓名
  45. params.put("confirm_doctor_name","");
  46. //确认时间
  47. params.put("confirm_datetime","");
  48. if (record.getStr("IMPRESSION") == null && record.getStr("DESCRIPTION") == null) {
  49. continue;
  50. }
  51. //意见建议
  52. params.put("impression",record.getStr("IMPRESSION"));
  53. //影像所见
  54. params.put("description",record.getStr("DESCRIPTION"));
  55. //exams表
  56. //申请科室
  57. params.put("application_department","");
  58. //申请医生
  59. params.put("application_doctor","");
  60. //临床诊断
  61. params.put("clin_diag","");
  62. //patient_infos表
  63. //患者姓名
  64. params.put("name",record.getStr("PATIENTNAME"));
  65. //患者手机号
  66. params.put("phone",record.getStr("PHONE"));
  67. //患者身份证号
  68. params.put("card_num",record.getStr("IDCARD"));
  69. sendPost(url_, params);
  70. /* Report report = new Report().use("zskk");
  71. report.setId(creatId());
  72. report.setReportDatetime(parseStringToDate(record.getStr("REPORTDATE")));*/
  73. /*report.setImpression(new String(record.getStr("IMPRESSION").getBytes("windows-1252"),"GBK"));
  74. report.setDescription(new String(record.getStr("DESCRIPTION").getBytes("windows-1252"),"GBK"));
  75. report.setExamId(exams2.getId());
  76. report.setCreatedAt(new Date());
  77. report.setReportDoctorId(getDoctorIdByName(new String(record.getStr("REPORTDOCTOR").getBytes("windows-1252"),"GBK")));
  78. report.setReviewDoctorId(getDoctorIdByName(new String(record.getStr("REVIEWDOCTOR").getBytes("windows-1252"),"GBK")));
  79. report.setReviewDatetime(parseStringToDate(new String(record.getStr("REPORTDATE").getBytes("windows-1252"),"GBK")));
  80. report.setConfirmDoctorId(getDoctorIdByName(new String(record.getStr("REVIEWDOCTOR").getBytes("windows-1252"),"GBK")));
  81. report.setConfirmDatetime(parseStringToDate(new String(record.getStr("REPORTDATE").getBytes("windows-1252"),"GBK")));*/
  82. //report.save();
  83. //PatientInfos patientInfos = PatientInfos.dao.use("zskk").findById(exams2.getPatientId());
  84. //patientInfos.setName(new String(record.getStr("PATIENTNAME").getBytes("windows-1252"),"GBK"));
  85. // patientInfos.setPhone(record.getStr("PHONE"));
  86. // patientInfos.setCardNum(record.getStr("IDCARD"));
  87. // patientInfos.update();
  88. /* try {
  89. exams2.setClinDoctors(new String(record.getStr("CLINICALDOCTOR").getBytes("windows-1252"),"GBK"));
  90. } catch (Exception e) {
  91. // TODO: handle exception
  92. }
  93. exams2.setExamStatus(9);
  94. exams2.update();
  95. WeixinService wService = new WeixinService();
  96. wService.requestWeixinQrcode(report.getId());*/
  97. } catch (Exception e) {
  98. // TODO: handle exception
  99. continue;
  100. }
  101. }
  102. } catch (Exception e) {
  103. // TODO: handle exception
  104. }
  105. }
  106. @Override
  107. public void stop() {
  108. // TODO Auto-generated method stub
  109. }
  110. private String creatId() {
  111. UUID id=UUID.randomUUID();
  112. String[] idd = id.toString().split("-");
  113. return idd[0]+idd[1]+idd[2];
  114. }
  115. private String getDoctorIdByName(String name) {
  116. if (name == null) {
  117. return null;
  118. }
  119. Doctors doctors = Doctors.dao.use("zskk").findFirst("SELECT * FROM doctors where instr(?,realname) and institution_id=46400001 and realname<>''",name);
  120. if (doctors == null) {
  121. return null;
  122. }
  123. return doctors.getId();
  124. }
  125. private Date parseStringToDate(String dateStr) {
  126. if (dateStr == null) {
  127. return new Date();
  128. }
  129. SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  130. Date date = null;
  131. try {
  132. date = sdf.parse(dateStr);
  133. } catch (ParseException e) {
  134. // TODO Auto-generated catch block
  135. e.printStackTrace();
  136. }
  137. return date;
  138. }
  139. }