1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- package com.yihu.platform.api;
- import com.yihu.platform.utils.ApiUtil;
- import com.yihu.platform.utils.Pinyin4jUtil;
- import com.yihu.platform.utils.StringUtil;
- import com.yihu.wsgw.api.InterfaceMessage;
- import net.sf.json.JSONArray;
- import net.sf.json.JSONException;
- import net.sf.json.JSONObject;
- /**
- * 医院接口
- *
- * @author wengsb----yihu.com
- * 2017年8月17日下午3:00:15
- */
- public class HospitalApi {
- /**
- * 通过省市医院id等获取医院信息
- *
- * @param msg
- * @return
- */
- public String queryComplexHospitalList_v2(InterfaceMessage msg) {
- try {
- JSONObject json = JSONObject.fromObject(msg.getParam());
- String hospitalId = StringUtil.isEmpty(json.get("hospitalId")) ? "" : json.getString("hospitalId");
- String provinceId = StringUtil.isEmpty(json.get("provinceId")) ? "" : json.getString("provinceId");
- String cityId = StringUtil.isEmpty(json.get("cityId")) ? "" : json.getString("cityId");
- Integer page = json.get("page") == null ? 1 : json.getInt("page");
- Integer pageSize = json.get("pageSize") == null ? 10 : json.getInt("pageSize");
- if (StringUtil.isEmpty(hospitalId)) {
- return ApiUtil.getRespJSON(-10000, "hospitalId不能为空").toString();
- }
- String resp = IHealthApi.queryHospital(hospitalId, provinceId, cityId, page, pageSize);
- JSONObject re = JSONObject.fromObject(resp);
- if (re.getInt("code") != 0) {
- return ApiUtil.getRespJSON(-10000, "查询医院信息失败:" + re.getString("message")).toString();
- }
- JSONArray array = re.getJSONArray("result");
- JSONArray result = new JSONArray();
- for(Object o :array){
- JSONObject obj = (JSONObject) o;
- JSONObject j = new JSONObject();
- j.put("hospitalId", obj.get("code"));
- j.put("hosName", obj.get("name"));
- j.put("spells", Pinyin4jUtil.getPinyin(obj.getString("name")));
- String levelName = "";
- if(obj.get("level").equals(1))levelName = "医院";
- if(obj.get("level").equals(2))levelName = "社区医院";
- j.put("levelId", obj.get("level"));
- j.put("levelName", levelName);
- j.put("provinceId", obj.get("province"));
- j.put("provinceName", obj.get("provinceName"));
- j.put("cityId", obj.get("city"));
- j.put("cityName", obj.get("cityName"));
- j.put("address", obj.get("address"));
- j.put("contact", obj.get("phone"));
- j.put("clinicTime", obj.get(""));
- j.put("traffic", obj.get("centerSite"));
- j.put("url", obj.get(""));
- j.put("intro", obj.get("intro"));
- j.put("photoUri", obj.get("photo"));
- result.add(j);
- }
- JSONObject obj = ApiUtil.getRespJSON(10000, "成功");
- obj.put("Result", result);
- obj.put("Count", re.getInt("allNum"));
- return obj.toString();
- } catch (JSONException e) {
- return ApiUtil.getRespJSON(-10000, "非标准json:[" + msg.getParam() + "]").toString();
- } catch (Exception e) {
- e.printStackTrace();
- return ApiUtil.getRespJSON(-14444, "加载异常!" + StringUtil.getException(e)).toString();
- }
- }
- }
|