|
@ -1,9 +1,18 @@
|
|
|
package com.yihu.jw.security.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.security.dao.doctor.BaseDoctorDao;
|
|
|
import com.yihu.jw.security.dao.patient.BasePatientDao;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import com.yihu.jw.util.idcard.IdCardUtil;
|
|
|
import com.yihu.utils.security.MD5;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@ -16,10 +25,17 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class YkyyService {
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(YkyyService.class);
|
|
|
|
|
|
@Autowired
|
|
|
private HttpClientUtil httpClientUtil;
|
|
|
|
|
|
private static String yktUrl = "http://www.yanketong.com:90/";
|
|
|
private static String yktUrl1 = "http://www.yanketong.com:90/";
|
|
|
|
|
|
@Autowired
|
|
|
private BasePatientDao patientDao;
|
|
|
|
|
|
private static String yktUrl = "http://www.yanketong.com:133/api/";
|
|
|
|
|
|
/**
|
|
|
* 眼科医院单点登录接口
|
|
@ -27,7 +43,239 @@ public class YkyyService {
|
|
|
*/
|
|
|
public String getDoctorInfoByVerifycode(String verifyCode){
|
|
|
String url = "api/Doctor/GetDoctorInfoByverifycode";
|
|
|
return httpClientUtil.get(yktUrl+url+"?verifyCode="+verifyCode,"GBK");
|
|
|
return httpClientUtil.get(yktUrl1+url+"?verifyCode="+verifyCode,"GBK");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*获取家庭成员信息
|
|
|
*
|
|
|
* @param tel
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
public String getFamilyList(String tel,String userId){
|
|
|
String response="";
|
|
|
String url = yktUrl+"doc_jkzl/get_family_list?";
|
|
|
if (StringUtils.isNoneBlank(tel)&&StringUtils.isNoneBlank(userId)){
|
|
|
url+="tel="+tel;
|
|
|
url+="&user_id="+userId;
|
|
|
}else if (StringUtils.isNoneBlank(tel)&&!StringUtils.isNoneBlank(userId)){
|
|
|
url+="tel="+tel;
|
|
|
}else if (!StringUtils.isNoneBlank(tel)&&StringUtils.isNoneBlank(userId)){
|
|
|
url+="user_id="+userId;
|
|
|
}
|
|
|
response = httpClientUtil.get(url,"GBK");
|
|
|
logger.info("获取家庭成员信息:"+response);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 眼科通登录接口
|
|
|
* @param tel
|
|
|
* @param password
|
|
|
* @return
|
|
|
*/
|
|
|
public String yktLogin(String tel,String password){
|
|
|
String response="";
|
|
|
String url = yktUrl+"user_center/patient_login?patient_account="+tel+"&patient_pwd="+password;
|
|
|
response = httpClientUtil.get(url,"GBK");
|
|
|
logger.info("获取眼科通登录信息:"+response);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 眼科通验证码
|
|
|
* @param type
|
|
|
* @param phone
|
|
|
* @return
|
|
|
*/
|
|
|
public String getShortMessage(String type,String phone){
|
|
|
String response="";
|
|
|
String url = yktUrl+"verification_code/short_message?type="+type+"&telephone="+phone;
|
|
|
response = httpClientUtil.get(url,"GBK");
|
|
|
logger.info("眼科通验证码:"+response);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 增加家庭成员
|
|
|
* @param userId
|
|
|
* @param idcard
|
|
|
* @param name
|
|
|
* @param sex
|
|
|
* @param birth
|
|
|
* @param age
|
|
|
* @param tel
|
|
|
* @return
|
|
|
*/
|
|
|
public String addFamily(String userId,String idcard,String name,String sex,String birth,String age,String tel){
|
|
|
String response="";
|
|
|
String url = yktUrl+"doc_jkzl/add_family?ass_user_id="+userId+"&id_card="+idcard+"&name="+name+"&sex="+sex
|
|
|
+"&birth="+birth+"&age="+age+"&tel="+tel+"&medical_card=&illness=本人&clinic_id=";
|
|
|
response = httpClientUtil.get(url,"GBK");
|
|
|
logger.info("增加家庭成员:"+response);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**获取眼科通忘记密码信息
|
|
|
*
|
|
|
* @param tel
|
|
|
* @param password
|
|
|
* @param vercode
|
|
|
* @return
|
|
|
*/
|
|
|
public String forgetPassword(String tel,String password,String vercode){
|
|
|
String response="";
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("loginid",tel);
|
|
|
jsonObject.put("password",password);
|
|
|
String url = "http://www.yanketong.com:90/api/Patient/ForgotPassword4Jkzl";
|
|
|
response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
|
|
|
logger.info("获取眼科通忘记密码信息:"+response);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* telephone=15578008051&patient_pwd=123456&code=513970&invite_code=a01522&equipment_type=ios&equipment_guid=12312321
|
|
|
* 眼科通用户注册
|
|
|
*
|
|
|
* @param telephone
|
|
|
* @param patientPwd
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
public String getRegisterUser(String telephone,String patientPwd,String code,String inviteCode,String equipmentType,String equipmentGuid){
|
|
|
String response="";
|
|
|
String url = yktUrl+"user_center/patient_register01?telephone="+telephone+"&patient_pwd="+patientPwd+"&code="+code+"&invite_code="+inviteCode+"&equipment_type="+equipmentType+
|
|
|
"&equipment_guid="+equipmentGuid;
|
|
|
response = httpClientUtil.get(url,"GBK");
|
|
|
logger.info("眼科通用户注册:"+response);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 同步眼科通数据
|
|
|
* @param patient
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void registerYkt(String patient,String pw,String code) throws Exception {
|
|
|
BasePatientDO basePatientDO = patientDao.findById(patient);
|
|
|
if (basePatientDO!=null){
|
|
|
String userId = basePatientDO.getUserId();
|
|
|
if (StringUtils.isNoneBlank(userId)){
|
|
|
String familyList =getFamilyList(null,userId);
|
|
|
JSONObject object = JSONObject.parseObject(familyList);
|
|
|
if (object.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject object1 = object.getJSONObject("data");
|
|
|
JSONArray array = object1.getJSONArray("list");
|
|
|
if (array!=null&&array.size()!=0){
|
|
|
JSONObject jsonObject = array.getJSONObject(0);
|
|
|
if (jsonObject!=null){
|
|
|
String yktId = jsonObject.getString("ID");
|
|
|
basePatientDO.setYktId(yktId);
|
|
|
patientDao.save(basePatientDO);
|
|
|
}
|
|
|
}else {
|
|
|
String birdth = IdCardUtil.getBirthdayForIdcardStr(basePatientDO.getIdcard());
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard());
|
|
|
Integer sex = basePatientDO.getSex()!=null?basePatientDO.getSex():0;
|
|
|
String family = addFamily(userId,basePatientDO.getIdcard(),basePatientDO.getName(),sex.toString(),birdth,age.toString(),basePatientDO.getMobile());
|
|
|
JSONObject object2 = JSONObject.parseObject(family);
|
|
|
if (object2.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject object3 = object2.getJSONObject("data");
|
|
|
String yktId = object3.getString("ID");
|
|
|
basePatientDO.setYktId(yktId);
|
|
|
patientDao.save(basePatientDO);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
throw new Exception("查询家庭成员失败!");
|
|
|
}
|
|
|
}else {
|
|
|
String r =getRegisterUser(basePatientDO.getMobile(),pw,code,"a01522","xmijk","xmijk");
|
|
|
JSONObject object4 = JSONObject.parseObject(r);
|
|
|
if (object4.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject object5 = object4.getJSONObject("data");
|
|
|
if (object5!=null){
|
|
|
userId = object5.getString("ID");
|
|
|
basePatientDO.setUserId(userId);
|
|
|
patientDao.save(basePatientDO);
|
|
|
String familyList =getFamilyList(null,userId);
|
|
|
JSONObject object = JSONObject.parseObject(familyList);
|
|
|
if (object.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject object1 = object.getJSONObject("data");
|
|
|
JSONArray array = object1.getJSONArray("list");
|
|
|
if (array!=null&&array.size()!=0){
|
|
|
JSONObject jsonObject1 = array.getJSONObject(0);
|
|
|
if (jsonObject1!=null){
|
|
|
String yktId = jsonObject1.getString("ID");
|
|
|
userId = jsonObject1.getString("ASSUSERID");
|
|
|
basePatientDO.setYktId(yktId);
|
|
|
basePatientDO.setUserId(userId);
|
|
|
patientDao.save(basePatientDO);
|
|
|
}
|
|
|
}else {
|
|
|
String birdth = IdCardUtil.getBirthdayForIdcardStr(basePatientDO.getIdcard());
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard());
|
|
|
Integer sex = basePatientDO.getSex()!=null?basePatientDO.getSex():0;
|
|
|
String family = addFamily(userId,basePatientDO.getIdcard(),basePatientDO.getName(),sex.toString(),birdth,age.toString(),basePatientDO.getMobile());
|
|
|
JSONObject object2 = JSONObject.parseObject(family);
|
|
|
if (object2.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject object3 = object2.getJSONObject("data");
|
|
|
String yktId = object3.getString("ID");
|
|
|
basePatientDO.setYktId(yktId);
|
|
|
userId = object3.getString("ASSUSERID");
|
|
|
basePatientDO.setUserId(userId);
|
|
|
patientDao.save(basePatientDO);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
throw new Exception("查询家庭成员失败!");
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
String familyList =getFamilyList(basePatientDO.getMobile(),null);
|
|
|
JSONObject object = JSONObject.parseObject(familyList);
|
|
|
if (object.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject object1 = object.getJSONObject("data");
|
|
|
JSONArray array = object1.getJSONArray("list");
|
|
|
if (array!=null&&array.size()!=0){
|
|
|
JSONObject jsonObject1 = array.getJSONObject(0);
|
|
|
if (jsonObject1!=null){
|
|
|
String yktId = jsonObject1.getString("ID");
|
|
|
userId = jsonObject1.getString("ASSUSERID");
|
|
|
basePatientDO.setYktId(yktId);
|
|
|
basePatientDO.setUserId(userId);
|
|
|
patientDao.save(basePatientDO);
|
|
|
}
|
|
|
}else {
|
|
|
userId=object1.getString("user_id");
|
|
|
String birdth = DateUtil.dateToStrShort(IdCardUtil.getBirthdayForIdcard(basePatientDO.getIdcard()));
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard());
|
|
|
Integer sex = basePatientDO.getSex()!=null?basePatientDO.getSex():0;
|
|
|
String family = addFamily(userId,basePatientDO.getIdcard(),basePatientDO.getName(),sex.toString(),birdth,age.toString(),basePatientDO.getMobile());
|
|
|
JSONObject object2 = JSONObject.parseObject(family);
|
|
|
if (object2.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject object3 = object2.getJSONObject("data");
|
|
|
String yktId = object3.getString("ID");
|
|
|
basePatientDO.setYktId(yktId);
|
|
|
userId = object3.getString("ASSUSERID");
|
|
|
basePatientDO.setUserId(userId);
|
|
|
patientDao.save(basePatientDO);
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
throw new Exception("查询家庭成员失败!");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|