123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- package com.yihu.platform.api;
- import com.yihu.platform.apiservice.IHealthService;
- import com.yihu.platform.cache.DBCache;
- 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.isNotEmpty(provinceId))provinceId = DBCache.provinceGBCodeMap.get(provinceId);
- if(StringUtil.isNotEmpty(cityId))cityId = DBCache.cityGBCodeMap.get(cityId);
- IHealthService api = new IHealthService();
- String resp = api.queryHospital(hospitalId, provinceId, cityId, page, pageSize);
- JSONObject objRet = ApiUtil.getRespJSON(10000, "成功");
- JSONArray result = new JSONArray();
- if(StringUtil.isNotEmpty(resp)){
- JSONObject re = JSONObject.fromObject(resp);
- if (re.getInt("status") != 10000) {
- return ApiUtil.getRespJSON(-10000, "查询医院信息失败:" + re).toString();
- }
- JSONArray array = re.getJSONArray("result");
-
- 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);
- }
- objRet.put("Count", re.getInt("allNum"));
- }else{
- objRet.put("Count", 0);
- }
- objRet.put("Result", result);
- return objRet.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();
- }
- }
- }
|