123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- package com.yihu.platform.apiservice;
- import com.coreframework.ioc.Ioc;
- import com.coreframework.util.AppConfig;
- import com.yihu.platform.service.IUserMappingService;
- import com.yihu.platform.utils.HttpUtil;
- import com.yihu.platform.utils.StringUtil;
- import net.sf.json.JSONObject;
- import java.util.HashMap;
- import java.util.Map;
- /**
- * 厦门i健康api
- */
- public class IHealthService {
- private static final String URL = AppConfig.getValue("HealthServiceURL");
- private static final IUserMappingService userMappingService = Ioc.get(IUserMappingService.class);
- private String token;
- public IHealthService() throws Exception {
- super();
- token = getToken();
- }
- /**
- * 获取token
- *
- * @return
- * @throws Exception
- */
- public String getToken() throws Exception {
- HttpUtil httpUtil = new HttpUtil(URL + "gc/accesstoken");
- Map map = new HashMap();
- map.put("appid", AppConfig.getValue("Token.appid"));
- map.put("appSecret", AppConfig.getValue("Token.appSecret"));
- String resp = httpUtil.post(map);
- if (StringUtil.isNotEmpty(resp) && resp.indexOf("status") >= 0) {
- JSONObject json = JSONObject.fromObject(resp);
- if (json.getInt("status") != 10000) throw new Exception("获取token失败:" + json);
- return json.getJSONObject("result").getString("accesstoken");
- } else {
- throw new Exception("获取token失败:" + resp);
- }
- }
- public String queryPatient(String userId) throws Exception {
- HttpUtil httpUtil = new HttpUtil(URL + "wlyygc/patient/user/patient");
- httpUtil.setHeader("userAgent", userMappingService.getUserAgent(userId));
- Map map = new HashMap();
- map.put("code", userId);
- map.put("accesstoken", token);
- String resp = httpUtil.get(map);
- return resp;
- }
- public String queryHospital(String hospitalId, String provinceId, String cityId, Integer page, Integer pageSize) throws Exception {
- HttpUtil httpUtil = new HttpUtil(URL + "wlyygc/hospital/");
- Map map = new HashMap();
- map.put("accesstoken", token);
- map.put("hospitalId", hospitalId);
- map.put("provinceId", provinceId);
- map.put("cityId", cityId);
- map.put("page", page);
- map.put("pageSize", pageSize);
- String resp = httpUtil.get(map);
- return resp;
- }
- public String queryDoctor(String hospitalId, String userId, Integer pageIndex, Integer pageSize) throws Exception {
- HttpUtil httpUtil = new HttpUtil(URL + "wlyygc/doctor/user/doctors");
- httpUtil.setHeader("userAgent", userMappingService.getUserAgent(userId));
- Map map = new HashMap();
- map.put("accesstoken", token);
- map.put("hospitalCode", hospitalId);
- map.put("page", pageIndex);
- map.put("pageSize", pageSize);
- String resp = httpUtil.get(map);
- return resp;
- }
- public String queryDoctorByUserId(String userId) throws Exception {
- HttpUtil httpUtil = new HttpUtil(URL + "wlyygc/doctor/user/doctor");
- Map map = new HashMap();
- map.put("accesstoken", token);
- map.put("code", userId);
- String resp = httpUtil.get(map);
- return resp;
- }
- public String push(String codes, String templateId, String teampolateJson, String url, String doctorUserId) throws Exception {
- HttpUtil httpUtil = new HttpUtil(URL + "wlyygc/doctor/message/sendWXTemplate");
- httpUtil.setHeader("userAgent", userMappingService.getUserAgent(doctorUserId));
- Map map = new HashMap();
- map.put("accesstoken", token);
- map.put("Codes", codes);
- map.put("templateId", templateId);
- map.put("teampolateJson", teampolateJson);
- map.put("url", url);
- String resp = httpUtil.post(map);
- return resp;
- }
- public String send(String mobile, String content, String doctorUserId) throws Exception {
- HttpUtil httpUtil = new HttpUtil(URL + "wlyygc/doctor/message/sendMobileMessage");
- httpUtil.setHeader("userAgent", userMappingService.getUserAgent(doctorUserId));
- Map map = new HashMap();
- map.put("accesstoken", token);
- map.put("mobiles", mobile);
- map.put("content", content);
- String resp = httpUtil.post(map);
- return resp;
- }
- public String getJsapiTicket() throws Exception {
- HttpUtil httpUtil = new HttpUtil(URL + "wlyygc/wx_jsapi_ticket");
- Map map = new HashMap();
- map.put("accesstoken", token);
- String resp = httpUtil.get(map);
- return resp;
- }
- }
|