|
@ -1429,7 +1429,10 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
JSONObject patient = userDetailsService.getHLWyyUser(opid);
|
|
|
rs.put("idcard",patient.getString("idcard"));
|
|
|
rs.put("mobile",patient.getString("mobile"));
|
|
|
|
|
|
}else if("xm_ykyy_wx".equals(wxid)){
|
|
|
JSONObject patient = userDetailsService.getHLWyyUser(opid);
|
|
|
rs.put("idcard",patient.getString("idcard"));
|
|
|
rs.put("mobile",patient.getString("mobile"));
|
|
|
}
|
|
|
}else {
|
|
|
rs.put("openid",openid);
|
|
@ -2579,19 +2582,21 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
if (wlyyHospitalSysDictDO!=null){
|
|
|
isNeedGeet=wlyyHospitalSysDictDO.getDictValue();
|
|
|
}
|
|
|
if (parameters.get("mobile")==null){
|
|
|
if ("1".equalsIgnoreCase(isNeedGeet)){
|
|
|
String geetestChallenge = parameters.get("geetestChallenge");
|
|
|
String geetestValidate = parameters.get("geetestValidate");
|
|
|
String geetestSeccode = parameters.get("geetestSeccode");
|
|
|
JSONObject resResult =validateGeet(geetestChallenge,geetestValidate,geetestSeccode,"1");
|
|
|
if (resResult==null||!resResult.getString("result").equalsIgnoreCase("success")){
|
|
|
throw new Exception("验证失败");
|
|
|
String wechatId = parameters.get("wechatId");
|
|
|
if (!wechatId.equalsIgnoreCase("xm_ihealth_wx")){
|
|
|
if (parameters.get("mobile")==null){
|
|
|
if ("1".equalsIgnoreCase(isNeedGeet)){
|
|
|
String geetestChallenge = parameters.get("geetestChallenge");
|
|
|
String geetestValidate = parameters.get("geetestValidate");
|
|
|
String geetestSeccode = parameters.get("geetestSeccode");
|
|
|
JSONObject resResult =validateGeet(geetestChallenge,geetestValidate,geetestSeccode,"1");
|
|
|
if (resResult==null||!resResult.getString("result").equalsIgnoreCase("success")){
|
|
|
throw new Exception("验证失败");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//图形验证码验证
|
|
|
String key = parameters.get("key");
|
|
|
String text = parameters.get("text");
|
|
@ -2608,7 +2613,214 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
if (StringUtils.isEmpty(client_id)) {
|
|
|
throw new InvalidRequestException("client_id");
|
|
|
}
|
|
|
String wechatId = parameters.get("wechatId");
|
|
|
if (wechatId.equalsIgnoreCase("xm_ihealth_wx")){
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
params.add(new BasicNameValuePair("clientId", userDetailsService.getClientId()));
|
|
|
ClientDetails clientDetails = clientDetailsService.loadClientByClientId(userDetailsService.getClientId());
|
|
|
params.add(new BasicNameValuePair("clientSecret", clientDetails.getClientSecret()));
|
|
|
params.add(new BasicNameValuePair("code", username));
|
|
|
params.add(new BasicNameValuePair("openid", userDetailsService.getOpenid()));
|
|
|
String result = null;
|
|
|
try{
|
|
|
logger.info("params"+params.toString());
|
|
|
result = httpClientUtil.post(userDetailsService.getSynPath(userDetailsService.getWechatId()), params, "UTF-8");
|
|
|
}catch (Exception e){
|
|
|
logger.error("远程请求i健康用户信息异常:" + e.getMessage());
|
|
|
}
|
|
|
if(null == result){
|
|
|
}
|
|
|
JSONObject patient = JSONObject.parseObject(result);
|
|
|
if(patient.getInteger("status") == -1){
|
|
|
logger.error("去i健康查询用户信息失败:" + patient.getString("error"));
|
|
|
}
|
|
|
String mobile = patient.getString("mobile");
|
|
|
parameters.put("grant_type", "ihealthCode");
|
|
|
/* KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
|
|
|
String mobile = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("mobile"), keyPair);*/
|
|
|
logger.info("mobile:"+mobile);
|
|
|
String msg = "";
|
|
|
String r =ykyyService.getRegisterUser(mobile,"123456","123456","a01522","xmijk","xmijk");
|
|
|
if (!StringUtils.isEmpty(r)){
|
|
|
JSONObject jsonObject = JSONObject.parseObject(r);
|
|
|
if (null!=jsonObject.get("code")&&"200".equalsIgnoreCase(jsonObject.get("code").toString())){
|
|
|
JSONObject jsonObject1 = JSONObject.parseObject(jsonObject.get("data").toString());
|
|
|
}else if (null!=jsonObject.get("code")&&"199".equalsIgnoreCase(jsonObject.get("code").toString())){
|
|
|
msg = jsonObject.getString("msg");
|
|
|
logger.info("msg"+msg);
|
|
|
}
|
|
|
}
|
|
|
String password = null;
|
|
|
String res = ykyyService.getPatientPhone(mobile);
|
|
|
if (res!=null&&res!=""){
|
|
|
JSONObject object = JSONObject.parseObject(res);
|
|
|
if (object.getString("code").equalsIgnoreCase("200")){
|
|
|
password = object.getString("data");
|
|
|
}else {
|
|
|
WlyyUserSimple userSimple = new WlyyUserSimple();
|
|
|
return getFailedResponse(object.getString("msg"),-1,userSimple);
|
|
|
}
|
|
|
}
|
|
|
String response = ykyyService.yktLogin(mobile,password);
|
|
|
if (!StringUtils.isEmpty(response)){
|
|
|
JSONObject object = JSONObject.parseObject(response);
|
|
|
if (!object.getString("code").equalsIgnoreCase("200")){
|
|
|
throw new Exception(object.getString("msg"));
|
|
|
}else {
|
|
|
JSONObject jsonObject = object.getJSONObject("data");
|
|
|
if (jsonObject!=null){
|
|
|
String userId= jsonObject.getString("ID");
|
|
|
String tel = jsonObject.getString("LOGINID");
|
|
|
List<BasePatientDO> basePatientDOS = basePatientDao.findByMobile(tel);
|
|
|
if (basePatientDOS==null||basePatientDOS.size()==0){
|
|
|
BasePatientDO basePatientDO = new BasePatientDO();
|
|
|
String familyList = ykyyService.getFamilyList(null,userId);
|
|
|
JSONObject familyJson = JSONObject.parseObject(familyList);
|
|
|
if (familyJson.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject object1 = familyJson.getJSONObject("data");
|
|
|
JSONArray list = object1.getJSONArray("list");
|
|
|
List<String> iliness = new ArrayList<>();
|
|
|
if (list!=null&&list.size()!=0){
|
|
|
for (int i=0;i<list.size();i++){
|
|
|
JSONObject family = list.getJSONObject(i);
|
|
|
iliness.add(family.getString("ILLNESS"));
|
|
|
if (family.getString("ILLNESS").equalsIgnoreCase("本人")&&tel.equalsIgnoreCase(family.getString("TEL"))){
|
|
|
basePatientDO.setDel("1");
|
|
|
basePatientDO.setName(family.getString("NAME"));
|
|
|
basePatientDO.setCreateTime(new Date());
|
|
|
basePatientDO.setUpdateTime(new Date());
|
|
|
basePatientDO.setYktId(family.getString("ID"));
|
|
|
basePatientDO.setUserId(userId);
|
|
|
basePatientDO.setIdcard(family.getString("IDCARD"));
|
|
|
String idcard = family.getString("IDCARD");
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(idcard);
|
|
|
String sex = IdCardUtil.getSexForIdcard_new(idcard);
|
|
|
Integer sexx = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(sex)){
|
|
|
sexx = Integer.parseInt(sex);
|
|
|
}
|
|
|
String birthDay = family.getString("BIRTHDAY");
|
|
|
Date birthday = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(birthDay)){
|
|
|
birthday = DateUtil.strToDate(birthDay+" 00:00:00");;
|
|
|
}
|
|
|
basePatientDO.setBirthday(birthday);
|
|
|
basePatientDO.setSex(sexx);
|
|
|
basePatientDO.setMobile(tel);
|
|
|
String salt = UUID.randomUUID().toString().substring(0,5);
|
|
|
String pw = idcard.substring(idcard.length()-6,idcard.length());
|
|
|
basePatientDO.setIdcard(idcard);
|
|
|
basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
basePatientDO.setSalt(salt);
|
|
|
basePatientDO.setLocked(0);
|
|
|
basePatientDO.setEnabled(1);
|
|
|
basePatientDO.setVerifyCode(jsonObject.getString("TOKEN"));
|
|
|
basePatientDO.setPatientStatus("1");
|
|
|
basePatientDao.save(basePatientDO);
|
|
|
}else {
|
|
|
List<BasePatientDO> basePatientDOList = basePatientDao.findByMobile(tel);
|
|
|
if(basePatientDOList==null||basePatientDOList.size()==0){
|
|
|
basePatientDO.setDel("1");
|
|
|
if (jsonObject.getString("USERNAME").length()>=2){
|
|
|
basePatientDO.setName(jsonObject.getString("USERNAME"));
|
|
|
}else {
|
|
|
basePatientDO.setName(tel);
|
|
|
}
|
|
|
basePatientDO.setCreateTime(new Date());
|
|
|
basePatientDO.setUpdateTime(new Date());
|
|
|
basePatientDO.setYktId(jsonObject.getString("ID"));
|
|
|
basePatientDO.setUserId(userId);
|
|
|
basePatientDO.setMobile(tel);
|
|
|
String salt = UUID.randomUUID().toString().substring(0,5);
|
|
|
String pw = tel.substring(tel.length()-6,tel.length());
|
|
|
basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
basePatientDO.setSalt(salt);
|
|
|
basePatientDO.setLocked(0);
|
|
|
basePatientDO.setEnabled(1);
|
|
|
basePatientDO.setPatientStatus("1");
|
|
|
basePatientDao.save(basePatientDO);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
|
|
|
if (jsonObject.getString("USERNAME").length()>=2){
|
|
|
basePatientDO.setName(jsonObject.getString("USERNAME"));
|
|
|
}else {
|
|
|
basePatientDO.setName(tel);
|
|
|
}
|
|
|
basePatientDO.setDel("1");
|
|
|
basePatientDO.setCreateTime(new Date());
|
|
|
basePatientDO.setUpdateTime(new Date());
|
|
|
basePatientDO.setUserId(userId);
|
|
|
basePatientDO.setMobile(tel);
|
|
|
String salt = UUID.randomUUID().toString().substring(0,5);
|
|
|
String pw = tel.substring(tel.length()-6,tel.length());
|
|
|
basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
basePatientDO.setSalt(salt);
|
|
|
basePatientDO.setLocked(0);
|
|
|
basePatientDO.setEnabled(1);
|
|
|
basePatientDO.setPatientStatus("1");
|
|
|
basePatientDao.save(basePatientDO);
|
|
|
}
|
|
|
/*String birdth = com.yihu.jw.util.idcard.IdCardUtil.getBirthdayForIdcardStr(basePatientDO.getIdcard());
|
|
|
Integer age = com.yihu.jw.util.idcard.IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard());
|
|
|
Integer sex = basePatientDO.getSex()!=null?basePatientDO.getSex():0;
|
|
|
if (iliness!=null&&iliness.size()!=0){
|
|
|
if (!iliness.contains("本人")){
|
|
|
ykyyService.addFamily(basePatientDO.getUserId(),basePatientDO.getIdcard(),basePatientDO.getName(),sex+"",birdth,age+"",basePatientDO.getMobile());
|
|
|
}
|
|
|
}else {
|
|
|
ykyyService.addFamily(basePatientDO.getUserId(),basePatientDO.getIdcard(),basePatientDO.getName(),sex+"",birdth,age+"",basePatientDO.getMobile());
|
|
|
}*/
|
|
|
}
|
|
|
}else {
|
|
|
logger.info("======"+jsonObject.getString("USERNAME")+"======");
|
|
|
logger.info("tel"+jsonObject.getString("USERNAME"));
|
|
|
BasePatientDO basePatientDO1 = basePatientDOS.get(0);
|
|
|
if (basePatientDO1.getName()==null||basePatientDO1.getName()==""){
|
|
|
if (jsonObject.getString("USERNAME").length()>=2){
|
|
|
basePatientDO1.setName(jsonObject.getString("USERNAME"));
|
|
|
}else {
|
|
|
basePatientDO1.setName(tel);
|
|
|
}
|
|
|
}
|
|
|
basePatientDO1.setVerifyCode(jsonObject.getString("TOKEN"));
|
|
|
basePatientDO1.setUserId(userId);
|
|
|
basePatientDao.save(basePatientDO1);
|
|
|
/*String familyList = ykyyService.getFamilyList(null,userId);
|
|
|
JSONObject familyJson = JSONObject.parseObject(familyList);
|
|
|
if (familyJson.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject object1 = familyJson.getJSONObject("data");
|
|
|
JSONArray list = object1.getJSONArray("list");
|
|
|
List<String> iliness = new ArrayList<>();
|
|
|
if (list!=null&&list.size()!=0){
|
|
|
for (int i=0;i<list.size();i++) {
|
|
|
JSONObject family = list.getJSONObject(i);
|
|
|
iliness.add(family.getString("ILLNESS"));
|
|
|
}
|
|
|
}
|
|
|
String birdth = null;
|
|
|
Integer age = 0;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(basePatientDO1.getIdcard())){
|
|
|
birdth = com.yihu.jw.util.idcard.IdCardUtil.getBirthdayForIdcardStr(basePatientDO1.getIdcard());
|
|
|
age =com.yihu.jw.util.idcard.IdCardUtil.getAgeForIdcard(basePatientDO1.getIdcard());
|
|
|
}
|
|
|
Integer sex = basePatientDO1.getSex()!=null?basePatientDO1.getSex():0;
|
|
|
if (iliness!=null&&iliness.size()!=0){
|
|
|
if (!iliness.contains("本人")){
|
|
|
ykyyService.addFamily(basePatientDO1.getUserId(),basePatientDO1.getIdcard(),basePatientDO1.getName(),sex+"",birdth,age+"",basePatientDO1.getMobile());
|
|
|
}
|
|
|
}else {
|
|
|
ykyyService.addFamily(basePatientDO1.getUserId(),basePatientDO1.getIdcard(),basePatientDO1.getName(),sex+"",birdth,age+"",basePatientDO1.getMobile());
|
|
|
}
|
|
|
|
|
|
}*/
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
parameters.remove("password");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(parameters.get("captcha"))) {
|
|
|
parameters.put("grant_type", "ihealthCode");
|
|
|
//解密密码
|