809777c7c69e757f1a02b4c1b75012fe40437a15.svn-base 5.5 KB

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