HosptailController.java 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. package com.yihu.wlyy.web.patient.hosptail;
  2. import com.yihu.wlyy.entity.doctor.profile.Doctor;
  3. import com.yihu.wlyy.entity.organization.Hospital;
  4. import com.yihu.wlyy.entity.address.Town;
  5. import com.yihu.wlyy.service.app.account.DoctorInfoService;
  6. import com.yihu.wlyy.service.app.hospital.HospitalService;
  7. import com.yihu.wlyy.web.BaseController;
  8. import org.json.JSONArray;
  9. import org.json.JSONObject;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.data.domain.Page;
  12. import org.springframework.stereotype.Controller;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestParam;
  15. import org.springframework.web.bind.annotation.ResponseBody;
  16. import java.util.List;
  17. /**
  18. * Created by Administrator on 2016.08.19.
  19. */
  20. @Controller
  21. @RequestMapping(value = "/patient/hosptail")
  22. public class HosptailController extends BaseController {
  23. @Autowired
  24. private HospitalService hospitalService;
  25. @Autowired
  26. private DoctorInfoService doctorInfoService;
  27. /**
  28. * 根据市得到区
  29. * @return
  30. */
  31. @RequestMapping(value = "getTownByCityCode")
  32. @ResponseBody
  33. public String getTownByCityCode(String city) {
  34. try {
  35. JSONArray array = new JSONArray();
  36. List<Town> list = hospitalService.getTownByCityCode(city);
  37. if (list != null) {
  38. for (Town temp : list) {
  39. if (temp == null) {
  40. continue;
  41. }
  42. JSONObject json = new JSONObject();
  43. json.put("code", temp.getCode());
  44. json.put("name", temp.getName());
  45. json.put("photo", temp.getPhoto());
  46. array.put(json);
  47. }
  48. }
  49. return write(200, "查询成功", "list", array);
  50. } catch (Exception e) {
  51. error(e);
  52. return error(-1, "查询失败");
  53. }
  54. }
  55. /**
  56. *
  57. * @param town
  58. * @return
  59. */
  60. @RequestMapping(value = "getHositalByTownCode")
  61. @ResponseBody
  62. public String getHositalByTownCode(String town) {
  63. try {
  64. JSONArray array = new JSONArray();
  65. List<Hospital> list = hospitalService.getHositalByTownCode(town);
  66. if (list != null) {
  67. for (Hospital temp : list) {
  68. if (temp == null) {
  69. continue;
  70. }
  71. JSONObject json = new JSONObject();
  72. json.put("code", temp.getCode());
  73. json.put("name", temp.getName());
  74. json.put("photo", temp.getPhoto());
  75. json.put("address", temp.getAddress());
  76. array.put(json);
  77. }
  78. }
  79. return write(200, "查询成功", "list", array);
  80. } catch (Exception e) {
  81. error(e);
  82. return error(-1, "查询失败");
  83. }
  84. }
  85. /**
  86. * 根据类别获取医院列表
  87. * @param type
  88. * @param query 查询条件 医院名称
  89. * @param id
  90. * @param pageSize 页数
  91. * @return
  92. */
  93. @RequestMapping(value = "/hospital_list")
  94. @ResponseBody
  95. public String getHospitalList(
  96. @RequestParam(required = true) Integer type,
  97. @RequestParam(required = false) String query,
  98. @RequestParam(required = true) long id,
  99. @RequestParam(required = true) Integer pageSize) {
  100. try {
  101. Page<Hospital> hospitalList = hospitalService.getHospitalList(query, type, id, pageSize);
  102. JSONArray array = new JSONArray();
  103. if (hospitalList != null) {
  104. for (Hospital hospital : hospitalList) {
  105. if (hospital == null) {
  106. continue;
  107. }
  108. JSONObject json = new JSONObject();
  109. json.put("id", hospital.getId());
  110. json.put("code", hospital.getCode());
  111. json.put("name", hospital.getName());
  112. json.put("province", hospital.getProvince());
  113. json.put("provinceName", hospital.getProvinceName());
  114. json.put("city", hospital.getCity());
  115. json.put("cityName", hospital.getCityName());
  116. json.put("town", hospital.getTown());
  117. json.put("townName", hospital.getTownName());
  118. json.put("level", hospital.getLevel());
  119. String levelName = "";
  120. switch (hospital.getLevel()) {
  121. case 1:
  122. levelName = "医院";
  123. break;
  124. case 2:
  125. levelName = "社区医院";
  126. break;
  127. }
  128. json.put("levelName", levelName);
  129. json.put("address", hospital.getAddress());
  130. json.put("intro", hospital.getIntro());
  131. json.put("photo", hospital.getPhoto());
  132. array.put(json);
  133. }
  134. }
  135. return write(200, "查询成功!", "list", array);
  136. } catch (Exception ex) {
  137. error(ex);
  138. return error(-1, "查询失败!");
  139. }
  140. }
  141. /**
  142. * 根据医院标识获取医生信息
  143. * @param hospital 医院标识
  144. * @param query 查询条件 :医生名称
  145. * @param id
  146. * @param pageSize 页数
  147. * @return
  148. */
  149. @RequestMapping(value = "/doctor_list")
  150. @ResponseBody
  151. public String getDoctorByHospital(
  152. @RequestParam(required = false) String hospital,
  153. @RequestParam(required = false) String query,
  154. @RequestParam(required = true) long id,
  155. @RequestParam(required = true) Integer pageSize) {
  156. try {
  157. Page<Doctor> doctorList = doctorInfoService.getDoctorListByHospital(query, hospital, id, pageSize);
  158. JSONArray array = new JSONArray();
  159. if (doctorList != null) {
  160. for (Doctor doctor : doctorList) {
  161. JSONObject json = new JSONObject();
  162. json.put("id", doctor.getId());
  163. json.put("code", doctor.getCode());
  164. json.put("name", doctor.getName());
  165. json.put("photo", doctor.getPhoto());
  166. json.put("sex", doctor.getSex());
  167. String sexName = "";
  168. switch (doctor.getSex()) {
  169. case 1:
  170. sexName = "男";
  171. break;
  172. case 2:
  173. sexName = "女";
  174. break;
  175. }
  176. json.put("sexName", sexName);
  177. json.put("job", doctor.getJob());
  178. json.put("jobName", doctor.getJobName());
  179. json.put("hospital", doctor.getHospital());
  180. json.put("hospitalName", doctor.getHosptialName());
  181. json.put("dept", doctor.getDept());
  182. json.put("deptName", doctor.getDeptName());
  183. array.put(json);
  184. }
  185. }
  186. return write(200, "查询成功!", "list", array);
  187. } catch (Exception ex) {
  188. error(ex);
  189. return error(-1, "查询失败!");
  190. }
  191. }
  192. }