256d2a13e3a12b11e1b9d2c8debf9e5d30627bfe.svn-base 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package com.yihu.platform.api;
  2. import java.io.IOException;
  3. import com.coreframework.db.DB;
  4. import com.coreframework.ioc.Ioc;
  5. import com.coreframework.util.AppConfig;
  6. import com.yihu.platform.apiservice.IHealthService;
  7. import com.yihu.platform.service.IUserMappingService;
  8. import com.yihu.platform.utils.ApiUtil;
  9. import com.yihu.platform.utils.DesUtil;
  10. import com.yihu.platform.utils.Pinyin4jUtil;
  11. import com.yihu.platform.utils.StringUtil;
  12. import com.yihu.wsgw.api.InterfaceMessage;
  13. import net.sf.json.JSONArray;
  14. import net.sf.json.JSONException;
  15. import net.sf.json.JSONObject;
  16. /**
  17. * 医生接口
  18. * @author wengsb----yihu.com
  19. * 2017年8月17日下午3:00:15
  20. */
  21. public class DoctorApi {
  22. private static final IUserMappingService userMappingService = Ioc.get(IUserMappingService.class);
  23. /**
  24. * 通过医院id,医生id获取医生列表
  25. * @param msg
  26. * @return
  27. */
  28. public String queryComplexDoctorList_v2(InterfaceMessage msg) {
  29. try {
  30. JSONObject json = JSONObject.fromObject(msg.getParam());
  31. Integer pageIndex = StringUtil.isEmpty(json.get("pageIndex")) ? 1 : json.getInt("pageIndex");
  32. Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? 10 : json.getInt("pageSize");
  33. String hosDeptId = StringUtil.isEmpty(json.get("hosDeptId")) ? "" : json.getString("hosDeptId");
  34. String doctorUid = StringUtil.isEmpty(json.get("doctorUid")) ? "" : json.getString("doctorUid");
  35. String doctorUids = StringUtil.isEmpty(json.get("doctorUids")) ? "" : json.getString("doctorUids");
  36. String hospitalId = StringUtil.isEmpty(json.get("hospitalId")) ? "" : json.getString("hospitalId");
  37. String userId = StringUtil.isEmpty(json.get("userId")) ? "" : json.getString("userId");
  38. if(StringUtil.isEmpty(userId)){
  39. return ApiUtil.getRespJSON(-10000, "userId不能为空:").toString();
  40. }
  41. IHealthService api = new IHealthService();
  42. String resp = api.queryDoctor(hospitalId,userId,pageIndex,pageSize);
  43. JSONObject re = JSONObject.fromObject(resp);
  44. if (re.getInt("status") != 10000) {
  45. return ApiUtil.getRespJSON(-10000, "查询医生信息失败:" + re).toString();
  46. }
  47. JSONArray array = re.getJSONArray("result");
  48. JSONArray result = new JSONArray();
  49. for(Object o :array){
  50. JSONObject obj = (JSONObject) o;
  51. JSONObject j = new JSONObject();
  52. j.put("hosDeptId", obj.get("dept"));
  53. j.put("doctorUid", obj.get("code"));
  54. j.put("doctorName", obj.get("name"));
  55. j.put("doctorSex", obj.get("sex"));
  56. j.put("lczc", obj.get("job"));
  57. j.put("lczcName", obj.get("jobName"));
  58. j.put("spells", Pinyin4jUtil.getPinyin(obj.getString("name")));
  59. j.put("skill", obj.get("expertise"));
  60. j.put("intro", obj.get("introduce"));
  61. j.put("photoUri", obj.get("photo"));
  62. j.put("provinceId", obj.get("province"));
  63. j.put("provinceName", obj.get("provinceName"));
  64. j.put("cityId", obj.get("city"));
  65. j.put("cityName", obj.get("cityName"));
  66. j.put("hospitalId", obj.get("hospital"));
  67. j.put("hosName", obj.get("hospitalName"));
  68. j.put("deptName", obj.get("deptName"));
  69. result.add(j);
  70. }
  71. JSONObject obj = ApiUtil.getRespJSON(10000, "成功");
  72. obj.put("Result", result);
  73. obj.put("Count", 10);
  74. return obj.toString();
  75. } catch (JSONException e) {
  76. return ApiUtil.getRespJSON(-10000, "非标准json:[" + msg.getParam() + "]").toString();
  77. } catch (Exception e) {
  78. e.printStackTrace();
  79. return ApiUtil.getRespJSON(-14444, "加载异常!" + StringUtil.getException(e)).toString();
  80. }
  81. }
  82. /**
  83. * 根据医生id查询医生信息
  84. * @param msg
  85. * @return
  86. */
  87. public String queryDoctorInfoByUid(InterfaceMessage msg) {
  88. try {
  89. JSONObject json = JSONObject.fromObject(msg.getParam());
  90. String userId = StringUtil.isEmpty(json.get("userId")) ? "" : json.getString("userId");
  91. if(StringUtil.isEmpty(userId)){
  92. return ApiUtil.getRespJSON(-10000, "userId不能为空:").toString();
  93. }
  94. IHealthService api = new IHealthService();
  95. String resp = api.queryDoctorByUserId(userId);
  96. JSONObject re = JSONObject.fromObject(resp);
  97. if (re.getInt("status") != 10000) {
  98. return ApiUtil.getRespJSON(-10000, "查询医生信息失败:" + re).toString();
  99. }
  100. JSONObject obj = re.getJSONObject("result");
  101. JSONObject retJSON = new JSONObject();
  102. if(obj!=null && obj.size()>0 && StringUtil.isNotEmpty(obj.get("code")))
  103. {
  104. retJSON.put("userId", obj.get("code"));
  105. retJSON.put("doctorName", obj.get("name"));
  106. retJSON.put("doctorSex", obj.get("name"));
  107. retJSON.put("doctorSex", obj.get("sex"));
  108. retJSON.put("lczc", obj.get("job"));
  109. retJSON.put("lczcName", obj.get("jobName"));
  110. if(StringUtil.isNotEmpty(obj.get("name"))){
  111. retJSON.put("spells", Pinyin4jUtil.getPinyin(obj.getString("name")));
  112. }else{
  113. retJSON.put("spells", "");
  114. }
  115. retJSON.put("skill", obj.get("expertise"));
  116. retJSON.put("intro", obj.get("introduce"));
  117. retJSON.put("photoUri", obj.get("photo"));
  118. retJSON.put("provinceId", obj.get("province"));
  119. retJSON.put("provinceName", obj.get("provinceName"));
  120. retJSON.put("cityId", obj.get("city"));
  121. retJSON.put("cityName", obj.get("cityName"));
  122. retJSON.put("hospitalId", obj.get("hospital"));
  123. retJSON.put("hosName", obj.get("hospitalName"));
  124. retJSON.put("deptName", obj.get("deptName"));
  125. Integer userType = userMappingService.getUserType4UserMapping(obj.get("code").toString());
  126. if(userType == null || userType<=0){
  127. return ApiUtil.getRespJSON(-10000, "查询医生信息失败").toString();
  128. }
  129. retJSON.put("userType",userType);
  130. }
  131. retJSON.put("Code", 10000);
  132. retJSON.put("Message", "成功");
  133. return retJSON.toString();
  134. } catch (JSONException e) {
  135. return ApiUtil.getRespJSON(-10000, "非标准json:[" + msg.getParam() + "]").toString();
  136. } catch (Exception e) {
  137. e.printStackTrace();
  138. return ApiUtil.getRespJSON(-14444, "加载异常!" + StringUtil.getException(e)).toString();
  139. }
  140. }
  141. }