SelfManagementController.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package com.yihu.wlyy.web.wx;
  2. import java.io.IOException;
  3. import javax.servlet.http.HttpServletResponse;
  4. import io.swagger.annotations.Api;
  5. import org.apache.commons.lang3.StringUtils;
  6. import org.json.JSONException;
  7. import org.json.JSONObject;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.stereotype.Controller;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.RequestMethod;
  12. import com.yihu.wlyy.entity.patient.Patient;
  13. import com.yihu.wlyy.service.app.sign.FamilyContractService;
  14. import com.yihu.wlyy.service.common.account.PatientService;
  15. import com.yihu.wlyy.util.SystemConf;
  16. import com.yihu.wlyy.web.WeixinBaseController;
  17. @Controller
  18. @RequestMapping("/wx/self/management")
  19. @Api(description = "自我管理")
  20. public class SelfManagementController extends WeixinBaseController {
  21. @Autowired
  22. private PatientService patientService;
  23. @Autowired
  24. private FamilyContractService familyContractService;
  25. /**
  26. * 自我管理»三师签约
  27. *
  28. * @param code
  29. * @return
  30. * @throws IOException
  31. */
  32. @RequestMapping(value = "ssqy", method = RequestMethod.GET)
  33. public void ssqy(HttpServletResponse response, String code) throws IOException {
  34. String message = getOpenid(code);
  35. JSONObject json = new JSONObject(message);
  36. if (Integer.parseInt(json.get("status").toString()) == 100) {
  37. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/html/home/html/login.html?type=6&openid=" + json.get("msg").toString());
  38. } else if (Integer.parseInt(json.get("status").toString()) == 200) {
  39. // String json2 = json.get("data").toString();
  40. // String paramUrl = getParamUrl(json2, 6);
  41. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/html/ssgg/html/teachers-sign.html");
  42. } else
  43. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/health_service/404.html");
  44. }
  45. /**
  46. * 自我管理»家庭签约
  47. *
  48. * @param code
  49. * @return
  50. * @throws IOException
  51. */
  52. @RequestMapping(value = "jtqy", method = RequestMethod.GET)
  53. public void jtqy(HttpServletResponse response, String code) throws IOException {
  54. String openid = getOpenidByCode(code);
  55. if (!StringUtils.isEmpty(openid)) {
  56. String doctor = null;
  57. Patient patient = patientService.findByOpenid(openid);
  58. if (patient != null) {
  59. doctor = familyContractService.checkPatient(patient.getCode());
  60. }
  61. if (StringUtils.isEmpty(doctor)) {
  62. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/html/ssgg/html/choose-region.html?openid=" + openid);
  63. } else {
  64. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/html/ssgg/html/doctor-home-page.html?openid=" + openid + "&doctor=" + doctor);
  65. }
  66. } else
  67. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/health_service/404.html");
  68. }
  69. /**
  70. * 自我管理»健康指标
  71. *
  72. * @param code
  73. * @return
  74. * @throws IOException
  75. */
  76. @RequestMapping(value = "jkzb", method = RequestMethod.GET)
  77. public void jkzb(HttpServletResponse response, String code) throws IOException {
  78. String message = getOpenid(code);
  79. JSONObject json = new JSONObject(message);
  80. if (Integer.parseInt(json.get("status").toString()) == 100) {
  81. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/html/home/html/login.html?type=8&openid=" + json.get("msg").toString());
  82. } else if (Integer.parseInt(json.get("status").toString()) == 200) {
  83. // String json2 = json.get("data").toString();
  84. // String paramUrl = getParamUrl(json2, 8);
  85. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/html/ssgg/html/health-index.html");
  86. } else
  87. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/health_service/404.html");
  88. }
  89. /**
  90. * 自我管理»健康记录
  91. *
  92. * @param code
  93. * @return
  94. * @throws IOException
  95. */
  96. @RequestMapping(value = "jkjl", method = RequestMethod.GET)
  97. public void jkjl(HttpServletResponse response, String code) throws IOException {
  98. String message = getOpenid(code);
  99. JSONObject json = new JSONObject(message);
  100. if (Integer.parseInt(json.get("status").toString()) == 100) {
  101. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/html/home/html/login.html?type=9&openid=" + json.get("msg").toString());
  102. } else if (Integer.parseInt(json.get("status").toString()) == 200) {
  103. // String json2 = json.get("data").toString();
  104. // String paramUrl = getParamUrl(json2, 9);
  105. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/html/ssgg/html/health-record.html");
  106. } else
  107. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/health_service/404.html");
  108. }
  109. /**
  110. * 自我管理»健康知识
  111. *
  112. * @param code
  113. * @return
  114. * @throws IOException
  115. * @throws JSONException
  116. */
  117. @RequestMapping(value = "jkzs", method = RequestMethod.GET)
  118. public void jkzs(HttpServletResponse response, String code) throws JSONException, IOException {
  119. String message = getOpenid(code);
  120. JSONObject json = new JSONObject(message);
  121. if (Integer.parseInt(json.get("status").toString()) == 100) {
  122. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/html/home/html/login.html?type=10&openid=" + json.get("msg").toString());
  123. } else if (Integer.parseInt(json.get("status").toString()) == 200) {
  124. // String json2 = json.get("data").toString();
  125. // String paramUrl = getParamUrl(json2, 10);
  126. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/html/ssgg/html/health-headline.html");
  127. } else
  128. response.sendRedirect(SystemConf.getInstance().getServerUrlStr() + "wx/health_service/404.html");
  129. }
  130. }