DataService.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package com.zskk.service;
  2. import java.io.IOException;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Date;
  5. import java.util.HashMap;
  6. import java.util.Map;
  7. import javax.xml.parsers.ParserConfigurationException;
  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 okhttp3.FormBody;
  13. import okhttp3.OkHttpClient;
  14. import okhttp3.Request;
  15. import okhttp3.RequestBody;
  16. import okhttp3.Response;
  17. public class DataService {
  18. private static String GET_EXAM_URL = "https://risserver3.pacsonline.cn/butt/getExam";
  19. private static String SAVE_REPORT_URL = "https://risserver3.pacsonline.cn/butt/saveReport";
  20. private static String UPDATE_PATIENT_URL = "https://risserver3.pacsonline.cn/butt/saveExam";
  21. private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
  22. /**
  23. * 获取未出报告的检查列表
  24. * @param instutionId
  25. * @param number
  26. */
  27. public JSONArray getExamList(Integer number) {
  28. Map <String,String> map = new HashMap<String,String>();
  29. map.put("institution_id", PropKit.get("institution_id"));
  30. map.put("num", number.toString());
  31. String content = postWithParameters(GET_EXAM_URL, map);
  32. JSONObject jsonObject = JSON.parseObject(content);
  33. if (!jsonObject.getString("msg").equals("success")) {
  34. return null;
  35. }
  36. JSONArray jsonArray = JSON.parseArray(jsonObject.getString("data"));
  37. return jsonArray;
  38. }
  39. /**
  40. * 写入报告
  41. * @param instutionId
  42. * @param number
  43. */
  44. public void saveReport(Map <String,String> map) {
  45. postWithParameters(SAVE_REPORT_URL, map);
  46. }
  47. /**
  48. * 更新患者信息
  49. * @param instutionId
  50. * @param number
  51. */
  52. public void updatePatientInfo(Map<String, String> map) {
  53. postWithParameters(UPDATE_PATIENT_URL, map);
  54. }
  55. public static String postWithParameters(String url, Map<String, String> map) {
  56. FormBody.Builder formbody = new FormBody.Builder();
  57. for (Map.Entry<String, String> entry : map.entrySet()) {
  58. formbody.add(entry.getKey(), entry.getValue());
  59. }
  60. RequestBody requestBody = formbody.build();
  61. Request request = new Request.Builder()
  62. .url(url)
  63. .post(requestBody)
  64. .build();
  65. try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
  66. if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
  67. String content = response.body().string();
  68. return content;
  69. } catch (IOException e) {
  70. // TODO Auto-generated catch block
  71. e.printStackTrace();
  72. return null;
  73. }
  74. }
  75. public static void main(String[] args) throws IOException, ParserConfigurationException {
  76. SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
  77. Date date = new Date();
  78. long dInteger = date.getTime() - 86400000;
  79. String daString = sdf.format(new Date(dInteger));
  80. System.out.println(daString.replace("0", "o"));
  81. Date ddDate =new Date();
  82. System.out.println(ddDate.toString());
  83. }
  84. }