|
@ -21,6 +21,7 @@ import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.jsoup.Connection;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -418,4 +419,128 @@ public class XzyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
/***
|
|
|
* 自动签名授权-请求自动签名授权接口
|
|
|
* @param openId 患者姓名
|
|
|
* @param sysTag 患者年
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject selfSignRequest(String openId,String sysTag){
|
|
|
try {
|
|
|
OauthCaConfigDO oauthCaConfigDO = oauthCaConfigDao.findOne("oauth_ca_config");
|
|
|
String url = "";
|
|
|
String clientId= "";
|
|
|
String clientSecret = "";
|
|
|
if (oauthCaConfigDO!=null){
|
|
|
url=oauthCaConfigDO.getUrl()+"/gateway/selfSign/request";
|
|
|
clientId=oauthCaConfigDO.getClientId();
|
|
|
clientSecret=oauthCaConfigDO.getClientSecret();
|
|
|
}
|
|
|
JSONObject object = new JSONObject();
|
|
|
JSONObject msg = new JSONObject();
|
|
|
JSONObject head = new JSONObject();
|
|
|
head.put("clientId",clientId);
|
|
|
head.put("clientSecret",clientSecret);
|
|
|
msg.put("head",head);
|
|
|
JSONObject body = new JSONObject();
|
|
|
body.put("sysTag",sysTag);
|
|
|
body.put("openId",openId);
|
|
|
msg.put("body",body);
|
|
|
object.put("msg",msg);
|
|
|
object.put("signType",0);
|
|
|
logger.info("请求参数:"+object);
|
|
|
String response = httpClientUtil.sendPost(url,object.toJSONString());
|
|
|
logger.info("请求自动签名授权接口 :"+response);
|
|
|
return JSONObject.parseObject(response);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
/***
|
|
|
* 自动签名授权-获取授权结果
|
|
|
* @param baseDoctorDO
|
|
|
* @param sysTag
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject selfSignGetResult(BaseDoctorDO baseDoctorDO, String sysTag){
|
|
|
try {
|
|
|
OauthCaConfigDO oauthCaConfigDO = oauthCaConfigDao.findOne("oauth_ca_config");
|
|
|
String url = "";
|
|
|
String clientId= "";
|
|
|
String clientSecret = "";
|
|
|
if (oauthCaConfigDO!=null){
|
|
|
url=oauthCaConfigDO.getUrl()+"/gateway/selfSign/getResult";
|
|
|
clientId=oauthCaConfigDO.getClientId();
|
|
|
clientSecret=oauthCaConfigDO.getClientSecret();
|
|
|
}
|
|
|
JSONObject object = new JSONObject();
|
|
|
JSONObject msg = new JSONObject();
|
|
|
JSONObject head = new JSONObject();
|
|
|
head.put("clientId",clientId);
|
|
|
head.put("clientSecret",clientSecret);
|
|
|
msg.put("head",head);
|
|
|
JSONObject body = new JSONObject();
|
|
|
body.put("sysTag",sysTag);
|
|
|
body.put("openId",baseDoctorDO.getOpenid());
|
|
|
msg.put("body",body);
|
|
|
object.put("msg",msg);
|
|
|
object.put("signType",0);
|
|
|
logger.info("请求参数:"+object);
|
|
|
String response = httpClientUtil.sendPost(url,object.toJSONString());
|
|
|
JSONObject jsonRes=JSONObject.parseObject(response);
|
|
|
JSONObject jsonObject = jsonRes.getJSONObject("data");
|
|
|
Integer grantStep = jsonObject.getInteger("grantStep");
|
|
|
if(1==grantStep){
|
|
|
baseDoctorDO.setIsSign("1");
|
|
|
baseDoctorDO.setLastSignTime(new Date());
|
|
|
baseDoctorDao.save(baseDoctorDO);
|
|
|
}
|
|
|
logger.info("获取授权结果 :"+response);
|
|
|
return JSONObject.parseObject(response);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
/***
|
|
|
* 自动签名授权-退出授权接口
|
|
|
* @param openId
|
|
|
* @param sysTag
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject selfSignQuit(String openId,String sysTag){
|
|
|
try {
|
|
|
OauthCaConfigDO oauthCaConfigDO = oauthCaConfigDao.findOne("oauth_ca_config");
|
|
|
String url = "";
|
|
|
String clientId= "";
|
|
|
String clientSecret = "";
|
|
|
if (oauthCaConfigDO!=null){
|
|
|
url=oauthCaConfigDO.getUrl()+"/gateway/selfSign/quit";
|
|
|
clientId=oauthCaConfigDO.getClientId();
|
|
|
clientSecret=oauthCaConfigDO.getClientSecret();
|
|
|
}
|
|
|
JSONObject object = new JSONObject();
|
|
|
JSONObject msg = new JSONObject();
|
|
|
JSONObject head = new JSONObject();
|
|
|
head.put("clientId",clientId);
|
|
|
head.put("clientSecret",clientSecret);
|
|
|
msg.put("head",head);
|
|
|
JSONObject body = new JSONObject();
|
|
|
body.put("sysTag",sysTag);
|
|
|
body.put("openId",openId);
|
|
|
msg.put("body",body);
|
|
|
object.put("msg",msg);
|
|
|
object.put("signType",0);
|
|
|
logger.info("请求参数:"+object);
|
|
|
String response = httpClientUtil.sendPost(url,object.toJSONString());
|
|
|
logger.info("退出授权接口 :"+response);
|
|
|
return JSONObject.parseObject(response);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
}
|