8258214f547da1b60925ce4d96059b84f82e951f.svn-base 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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("userId", obj.get("code"));
  55. j.put("doctorName", obj.get("name"));
  56. j.put("doctorSex", obj.get("sex"));
  57. j.put("lczc", obj.get("job"));
  58. j.put("lczcName", obj.get("jobName"));
  59. j.put("spells", Pinyin4jUtil.getPinyin(obj.getString("name")));
  60. j.put("skill", obj.get("expertise"));
  61. j.put("intro", obj.get("introduce"));
  62. j.put("photoUri", obj.get("photo"));
  63. j.put("provinceId", obj.get("province"));
  64. j.put("provinceName", obj.get("provinceName"));
  65. j.put("cityId", obj.get("city"));
  66. j.put("cityName", obj.get("cityName"));
  67. j.put("hospitalId", obj.get("hospital"));
  68. j.put("hosName", obj.get("hospitalName"));
  69. j.put("deptName", obj.get("deptName"));
  70. result.add(j);
  71. }
  72. JSONObject obj = ApiUtil.getRespJSON(10000, "成功");
  73. obj.put("Result", result);
  74. obj.put("Count", 10);
  75. return obj.toString();
  76. } catch (JSONException e) {
  77. return ApiUtil.getRespJSON(-10000, "非标准json:[" + msg.getParam() + "]").toString();
  78. } catch (Exception e) {
  79. e.printStackTrace();
  80. return ApiUtil.getRespJSON(-14444, "加载异常!" + StringUtil.getException(e)).toString();
  81. }
  82. }
  83. /**
  84. * 根据医生id查询医生信息
  85. * @param msg
  86. * @return
  87. */
  88. public String queryDoctorInfoByUid(InterfaceMessage msg) {
  89. try {
  90. JSONObject json = JSONObject.fromObject(msg.getParam());
  91. String userId = StringUtil.isEmpty(json.get("userId")) ? "" : json.getString("userId");
  92. if(StringUtil.isEmpty(userId)){
  93. return ApiUtil.getRespJSON(-10000, "userId不能为空:").toString();
  94. }
  95. IHealthService api = new IHealthService();
  96. String resp = api.queryDoctorByUserId(userId);
  97. JSONObject re = JSONObject.fromObject(resp);
  98. if (re.getInt("status") != 10000) {
  99. return ApiUtil.getRespJSON(-10000, "查询医生信息失败:" + re).toString();
  100. }
  101. JSONObject obj = re.getJSONObject("result");
  102. JSONObject retJSON = new JSONObject();
  103. if(obj!=null && obj.size()>0 && StringUtil.isNotEmpty(obj.get("code")))
  104. {
  105. retJSON.put("userId", obj.get("code"));
  106. retJSON.put("doctorName", obj.get("name"));
  107. retJSON.put("doctorSex", obj.get("name"));
  108. retJSON.put("doctorSex", obj.get("sex"));
  109. retJSON.put("lczc", obj.get("job"));
  110. retJSON.put("lczcName", obj.get("jobName"));
  111. if(StringUtil.isNotEmpty(obj.get("name"))){
  112. retJSON.put("spells", Pinyin4jUtil.getPinyin(obj.getString("name")));
  113. }else{
  114. retJSON.put("spells", "");
  115. }
  116. retJSON.put("skill", obj.get("expertise"));
  117. retJSON.put("intro", obj.get("introduce"));
  118. retJSON.put("photoUri", obj.get("photo"));
  119. retJSON.put("provinceId", obj.get("province"));
  120. retJSON.put("provinceName", obj.get("provinceName"));
  121. retJSON.put("cityId", obj.get("city"));
  122. retJSON.put("cityName", obj.get("cityName"));
  123. retJSON.put("hospitalId", obj.get("hospital"));
  124. retJSON.put("hosName", obj.get("hospitalName"));
  125. retJSON.put("deptName", obj.get("deptName"));
  126. Integer userType = userMappingService.getUserType4UserMapping(obj.get("code").toString());
  127. if(userType == null || userType<=0){
  128. return ApiUtil.getRespJSON(-10000, "查询医生信息失败").toString();
  129. }
  130. retJSON.put("userType",userType);
  131. }
  132. retJSON.put("Code", 10000);
  133. retJSON.put("Message", "成功");
  134. return retJSON.toString();
  135. } catch (JSONException e) {
  136. return ApiUtil.getRespJSON(-10000, "非标准json:[" + msg.getParam() + "]").toString();
  137. } catch (Exception e) {
  138. e.printStackTrace();
  139. return ApiUtil.getRespJSON(-14444, "加载异常!" + StringUtil.getException(e)).toString();
  140. }
  141. }
  142. }