|
|
@ -8,9 +8,13 @@ import com.google.code.kaptcha.util.Config;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO;
|
|
|
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
|
|
|
import com.yihu.jw.entity.base.sms.SmsDO;
|
|
|
import com.yihu.jw.entity.base.wx.WxWechatDO;
|
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
|
import com.yihu.jw.entity.hospital.family.BasePatientMemberDictDO;
|
|
|
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
|
|
|
import com.yihu.jw.entity.util.AesEncryptUtils;
|
|
|
import com.yihu.jw.restmodel.ResultStatus;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
@ -18,9 +22,7 @@ import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
|
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
|
|
|
import com.yihu.jw.security.dao.OauthKeypairDao;
|
|
|
import com.yihu.jw.security.dao.doctor.BaseDoctorDao;
|
|
|
import com.yihu.jw.security.dao.patient.BasePatientDao;
|
|
|
import com.yihu.jw.security.dao.patient.WechatDao;
|
|
|
import com.yihu.jw.security.dao.patient.WlyyHospitalSysDictDao;
|
|
|
import com.yihu.jw.security.dao.patient.*;
|
|
|
import com.yihu.jw.security.exception.ImgCaptchaException;
|
|
|
import com.yihu.jw.security.exception.PwdException;
|
|
|
import com.yihu.jw.security.login.service.BaseLoginLogService;
|
|
|
@ -196,6 +198,12 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
private UserService userService;
|
|
|
@Autowired
|
|
|
private HealthCareNewService healthCareNewService;
|
|
|
@Autowired
|
|
|
private WlyyPatientFamilyMemberDao familyMemberDao;
|
|
|
@Autowired
|
|
|
private BasePatientMemberDictDao basePatientMemberDictDao;
|
|
|
@Autowired
|
|
|
private BasePatientMedicareCardDao patientMedicareCardDao;
|
|
|
|
|
|
@PostConstruct
|
|
|
private void init() {
|
|
|
@ -1265,39 +1273,62 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
|
|
|
ResultMsg result= null;
|
|
|
if(StringUtils.isEmpty(type)){
|
|
|
String res = ykyyService.getShortMessage("1",username);
|
|
|
String resltCode ="";
|
|
|
String captcha1 = "";
|
|
|
if (!StringUtils.isEmpty(res)){
|
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
if ("10000".equalsIgnoreCase(jsonObject.getString("code"))){
|
|
|
captcha1 = jsonObject.getString("value");
|
|
|
resltCode = jsonObject.getString("code");
|
|
|
}else if("199".equalsIgnoreCase(jsonObject.getString("code"))){
|
|
|
msg = jsonObject.getString("msg");
|
|
|
Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>(msg, 199);
|
|
|
return new ResponseEntity<>(oauth2Envelop, HttpStatus.OK);
|
|
|
}else {
|
|
|
msg="发送失败";
|
|
|
Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>(msg, -1);
|
|
|
return new ResponseEntity<>(oauth2Envelop, HttpStatus.OK);
|
|
|
}
|
|
|
}
|
|
|
if ("10000".equalsIgnoreCase(resltCode)) {
|
|
|
|
|
|
Captcha _captcha = new Captcha();
|
|
|
_captcha.setCode(captcha1);
|
|
|
_captcha.setExpiresIn(300);
|
|
|
wlyyRedisVerifyCodeService.store(client_id, username, captcha1, 300);
|
|
|
|
|
|
// String res = ykyyService.getShortMessage("1",username);
|
|
|
// String resltCode ="";
|
|
|
// String captcha1 = "";
|
|
|
// if (!StringUtils.isEmpty(res)){
|
|
|
// JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
// if ("10000".equalsIgnoreCase(jsonObject.getString("code"))){
|
|
|
// captcha1 = jsonObject.getString("value");
|
|
|
// resltCode = jsonObject.getString("code");
|
|
|
// }else if("199".equalsIgnoreCase(jsonObject.getString("code"))){
|
|
|
// msg = jsonObject.getString("msg");
|
|
|
// Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>(msg, 199);
|
|
|
// return new ResponseEntity<>(oauth2Envelop, HttpStatus.OK);
|
|
|
// }else {
|
|
|
// msg="发送失败";
|
|
|
// Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>(msg, -1);
|
|
|
// return new ResponseEntity<>(oauth2Envelop, HttpStatus.OK);
|
|
|
// }
|
|
|
// }
|
|
|
// if ("10000".equalsIgnoreCase(resltCode)) {
|
|
|
//
|
|
|
// Captcha _captcha = new Captcha();
|
|
|
// _captcha.setCode(captcha1);
|
|
|
// _captcha.setExpiresIn(300);
|
|
|
// wlyyRedisVerifyCodeService.store(client_id, username, captcha1, 300);
|
|
|
//
|
|
|
// Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200);
|
|
|
// HttpHeaders headers = new HttpHeaders();
|
|
|
// headers.set("Cache-Control", "no-store");
|
|
|
// headers.set("Pragma", "no-cache");
|
|
|
// return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
|
|
|
// }
|
|
|
String res = ykyyService.sendSms(username,"EXT_REGISTER");
|
|
|
if (!StringUtils.isEmpty(res)){
|
|
|
JSONObject obj = JSONObject.parseObject(res);
|
|
|
if ("200".equalsIgnoreCase(obj.getString("code"))) {
|
|
|
Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200);
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
headers.set("Cache-Control", "no-store");
|
|
|
headers.set("Pragma", "no-cache");
|
|
|
return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}else if("1".equals(type)){
|
|
|
result = ykyyINSMSService.ykyySendSMS(username,"您好,您的手机登录短信验证码是:"+captcha+",5分钟内有效。");
|
|
|
String res = ykyyService.sendSms(username,"EXT_LOGIN");
|
|
|
if (!StringUtils.isEmpty(res)){
|
|
|
JSONObject obj = JSONObject.parseObject(res);
|
|
|
if ("200".equalsIgnoreCase(obj.getString("code"))) {
|
|
|
Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200);
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
headers.set("Cache-Control", "no-store");
|
|
|
headers.set("Pragma", "no-cache");
|
|
|
return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
|
|
|
}
|
|
|
}
|
|
|
// result = ykyyINSMSService.ykyySendSMS(username,"您好,您的手机登录短信验证码是:"+captcha+",5分钟内有效。");
|
|
|
}else if("2".equals(type)) {
|
|
|
result = ykyyINSMSService.ykyySendSMS(username, "您好,您正在进行找回密码操作,您的短信验证码是:" + captcha + ",请勿将验证码告诉他人,5分钟内有效。");
|
|
|
}
|
|
|
@ -2563,12 +2594,14 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
if (StringUtils.isEmpty(client_id)) {
|
|
|
throw new InvalidRequestException("client_id is null");
|
|
|
}
|
|
|
|
|
|
if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
|
|
|
//验证码正确
|
|
|
} else {
|
|
|
return ObjEnvelop.getError("验证码错误!");
|
|
|
if (!wxId.equalsIgnoreCase("xm_ykyy_wx")){
|
|
|
if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
|
|
|
//验证码正确
|
|
|
} else {
|
|
|
return ObjEnvelop.getError("验证码错误!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*JSONObject resResult =validateGeet(geetestChallenge,geetestValidate,geetestSeccode,"1");
|
|
|
if (resResult==null||!resResult.getString("result").equalsIgnoreCase("success")){
|
|
|
return ObjEnvelop.getError("验证失败!");
|
|
|
@ -2579,30 +2612,42 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
boolean localFlag = false;
|
|
|
boolean ykFlag = false;
|
|
|
String msg = "";
|
|
|
BasePatientDO basePatientDO = new BasePatientDO();
|
|
|
if (null!=basePatientDOS&&basePatientDOS.size()>0){
|
|
|
localFlag = true;
|
|
|
basePatientDO = basePatientDOS.get(0);
|
|
|
|
|
|
}
|
|
|
BasePatientDO basePatientDO = new BasePatientDO();
|
|
|
String r =ykyyService.getRegisterUser(mobile,pw,captcha,"a01522","xmijk","xmijk");
|
|
|
// String r =ykyyService.getRegisterUser(mobile,pw,captcha,"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());
|
|
|
// basePatientDO.setUserId(jsonObject1.getString("ID"));
|
|
|
// }else if (null!=jsonObject.get("code")&&"199".equalsIgnoreCase(jsonObject.get("code").toString())){
|
|
|
// msg = jsonObject.getString("msg");
|
|
|
// ykFlag = true;
|
|
|
// }
|
|
|
// }
|
|
|
String r = ykyyService.register(mobile,captcha);
|
|
|
if (!StringUtils.isEmpty(r)){
|
|
|
JSONObject jsonObject = JSONObject.parseObject(r);
|
|
|
if (null!=jsonObject.get("code")&&"200".equalsIgnoreCase(jsonObject.get("code").toString())){
|
|
|
if (null!=jsonObject.get("code")&&"0".equalsIgnoreCase(jsonObject.get("code").toString())){
|
|
|
JSONObject jsonObject1 = JSONObject.parseObject(jsonObject.get("data").toString());
|
|
|
basePatientDO.setUserId(jsonObject1.getString("ID"));
|
|
|
}else if (null!=jsonObject.get("code")&&"199".equalsIgnoreCase(jsonObject.get("code").toString())){
|
|
|
}else{
|
|
|
msg = jsonObject.getString("msg");
|
|
|
ykFlag = true;
|
|
|
}
|
|
|
}
|
|
|
basePatientDO.setMobile(mobile);
|
|
|
String salt = UUID.randomUUID().toString().substring(0,5);
|
|
|
basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
String password=mobile.substring(mobile.length()-6,mobile.length());
|
|
|
basePatientDO.setPassword(MD5.md5Hex(password + "{" + salt + "}"));
|
|
|
basePatientDO.setSalt(salt);
|
|
|
basePatientDO.setDel("1");
|
|
|
basePatientDO.setEnabled(1);
|
|
|
basePatientDO.setLocked(0);
|
|
|
basePatientDO.setName(name);
|
|
|
basePatientDO.setName(mobile);
|
|
|
basePatientDO.setCreateTime(new Date());
|
|
|
basePatientDO.setUpdateTime(new Date());
|
|
|
|
|
|
@ -3334,201 +3379,713 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
}
|
|
|
parameters.remove("password");
|
|
|
}else if (parameters.get("mobile") != null) {
|
|
|
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(parameters.get("username"),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){
|
|
|
// KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
|
|
|
// String mobile = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("mobile"), keyPair);
|
|
|
logger.info("mobile:"+username);
|
|
|
String res = ykyyService.mobileOnly(username);
|
|
|
if (!StringUtils.isEmpty(res)){
|
|
|
JSONObject resObj = JSONObject.parseObject(res);
|
|
|
if (resObj.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject data = resObj.getJSONObject("data");
|
|
|
String accessToken = data.getString("accessToken");
|
|
|
String infoRes = ykyyService.info(accessToken);
|
|
|
if (!StringUtils.isEmpty(infoRes)){
|
|
|
JSONObject infoObj = JSONObject.parseObject(infoRes);
|
|
|
if (infoObj.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject infoData= infoObj.getJSONObject("data");
|
|
|
String mobile1 = infoData.getString("mobile");
|
|
|
List<BasePatientDO> basePatientDOS = basePatientDao.findByMobile(mobile1);
|
|
|
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);
|
|
|
if (basePatientDOS==null||basePatientDOS.size()==0){
|
|
|
basePatientDO.setDel("1");
|
|
|
basePatientDO.setName(infoData.getString("userName"));
|
|
|
basePatientDO.setCreateTime(new Date());
|
|
|
basePatientDO.setUpdateTime(new Date());
|
|
|
basePatientDO.setYktId(infoData.getString("mainAccountId"));
|
|
|
basePatientDO.setUserId(infoData.getString("mainAccountId"));
|
|
|
basePatientDO.setIdcard(infoData.getString("idNo"));
|
|
|
String idcard = infoData.getString("idNo");
|
|
|
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 = infoData.getString("birthday");
|
|
|
Date birthday = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(birthDay)){
|
|
|
birthday = DateUtil.strToDate(birthDay+" 00:00:00");;
|
|
|
}
|
|
|
basePatientDO.setAge(age);
|
|
|
basePatientDO.setBirthday(birthday);
|
|
|
basePatientDO.setSex(sexx);
|
|
|
basePatientDO.setMobile(mobile1);
|
|
|
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.setPatientStatus("1");
|
|
|
basePatientDO.setAppletsOpenId(infoData.getString("openid"));
|
|
|
basePatientDO.setVerifyCode(accessToken);
|
|
|
basePatientDO = basePatientDao.save(basePatientDO);
|
|
|
JSONArray familyList = infoData.getJSONArray("patientAccountList");
|
|
|
if (familyList!=null&&familyList.size()!=0){
|
|
|
for (int i=0;i<familyList.size();i++){
|
|
|
JSONObject family = familyList.getJSONObject(i);
|
|
|
String familyMobile = family.getString("mobile");
|
|
|
String idNo = family.getString("idNo");
|
|
|
List<BasePatientDO> patientDOS = basePatientDao.findByIdcard(idNo);
|
|
|
BasePatientDO patientDO = new BasePatientDO();
|
|
|
if (patientDOS==null||patientDOS.size()==0){
|
|
|
patientDO.setDel("1");
|
|
|
patientDO.setName(family.getString("userName"));
|
|
|
patientDO.setCreateTime(new Date());
|
|
|
patientDO.setUpdateTime(new Date());
|
|
|
patientDO.setYktId(family.getString("patientAccountId"));
|
|
|
patientDO.setUserId(family.getString("patientAccountId"));
|
|
|
patientDO.setIdcard(family.getString("idNo"));
|
|
|
String idcard1 = family.getString("idNo");
|
|
|
Integer age1 = IdCardUtil.getAgeForIdcard(idcard1);
|
|
|
String sex1 = IdCardUtil.getSexForIdcard_new(idcard1);
|
|
|
|
|
|
Integer sexx1 = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(sex1)){
|
|
|
sexx1 = 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");;
|
|
|
String birthDay1 = IdCardUtil.getBirthdayForIdcardStr(idcard1);
|
|
|
Date birthday1 = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(birthDay1)){
|
|
|
birthday1 = DateUtil.strToDate(birthDay1+" 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);
|
|
|
patientDO.setAge(age1);
|
|
|
patientDO.setBirthday(birthday1);
|
|
|
patientDO.setSex(sexx1);
|
|
|
patientDO.setMobile(familyMobile);
|
|
|
String salt1 = UUID.randomUUID().toString().substring(0,5);
|
|
|
String pw1 = idcard1.substring(idcard1.length()-6,idcard1.length());
|
|
|
patientDO.setPassword(MD5.md5Hex(pw1 + "{" + salt1 + "}"));
|
|
|
patientDO.setSalt(salt1);
|
|
|
patientDO.setLocked(0);
|
|
|
patientDO.setEnabled(1);
|
|
|
patientDO.setPatientStatus("1");
|
|
|
patientDO.setAppletsOpenId(family.getString("mainAccountOpenid"));
|
|
|
patientDO = basePatientDao.save(patientDO);
|
|
|
}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);
|
|
|
patientDO=patientDOS.get(0);
|
|
|
}
|
|
|
JSONArray cardList = family.getJSONArray("cardList");
|
|
|
if (cardList!=null&&cardList.size()!=0){
|
|
|
for (int j=0;j<cardList.size();j++){
|
|
|
JSONObject card = cardList.getJSONObject(j);
|
|
|
String cardNo = card.getString("cardNo");
|
|
|
PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByCodeAndPatientCode(cardNo,patientDO.getId()); if (patientMedicareCardDO==null){
|
|
|
patientMedicareCardDO = new PatientMedicareCardDO();
|
|
|
patientMedicareCardDO.setCode(cardNo);
|
|
|
patientMedicareCardDO.setDel("1");
|
|
|
patientMedicareCardDO.setPatientCode(patientDO.getId());
|
|
|
patientMedicareCardDO.setParentType("A");
|
|
|
if (card.getString("cardType").equalsIgnoreCase("1")){
|
|
|
patientMedicareCardDO.setType("A_01");
|
|
|
}else if (card.getString("cardType").equalsIgnoreCase("2")){
|
|
|
patientMedicareCardDO.setType("A_02");
|
|
|
}else if (card.getString("cardType").equalsIgnoreCase("3")){
|
|
|
patientMedicareCardDO.setType("A_03");
|
|
|
}else if (card.getString("cardType").equalsIgnoreCase("9")){
|
|
|
patientMedicareCardDO.setType("A_09");
|
|
|
}
|
|
|
patientMedicareCardDao.save(patientMedicareCardDO);
|
|
|
|
|
|
}
|
|
|
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);
|
|
|
WlyyPatientFamilyMemberDO familyMemberDO = familyMemberDao.findFamilyMemberByYktFamilyId(basePatientDO.getId(),family.getString("patientAccountId"));
|
|
|
BasePatientMemberDictDO basePatientMemberDictDO = basePatientMemberDictDao.findOne(family.getString("relationship"));
|
|
|
if (familyMemberDO==null){
|
|
|
familyMemberDO = new WlyyPatientFamilyMemberDO();
|
|
|
familyMemberDO.setIsDel(1);
|
|
|
familyMemberDO.setFamilyMember(patientDO.getId());
|
|
|
familyMemberDO.setPatient(basePatientDO.getId());
|
|
|
familyMemberDO.setYktFamilyId(family.getString("patientAccountId"));
|
|
|
familyMemberDO.setCreateTime(new Date());
|
|
|
familyMemberDO.setUpdateTime(new Date());
|
|
|
familyMemberDO.setCardNo(patientDO.getIdcard());
|
|
|
familyMemberDO.setMobile(familyMobile);
|
|
|
familyMemberDO.setCardType(family.getString("idType"));
|
|
|
familyMemberDO.setFamilyRelation(family.getString("relationship"));
|
|
|
if (basePatientMemberDictDO!=null){
|
|
|
familyMemberDO.setFamilyRelationName(basePatientMemberDictDO.getRelationName());
|
|
|
}
|
|
|
familyMemberDao.save(familyMemberDO);
|
|
|
}
|
|
|
}
|
|
|
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 {
|
|
|
basePatientDO = basePatientDOS.get(0);
|
|
|
basePatientDO.setVerifyCode(accessToken);
|
|
|
basePatientDO.setAppletsOpenId(infoData.getString("openid"));
|
|
|
basePatientDao.save(basePatientDO);
|
|
|
JSONArray familyList = infoData.getJSONArray("patientAccountList");
|
|
|
if (familyList!=null&&familyList.size()!=0){
|
|
|
for (int i=0;i<familyList.size();i++){
|
|
|
JSONObject family = familyList.getJSONObject(i);
|
|
|
String familyMobile = family.getString("mobile");
|
|
|
String idNo = family.getString("idNo");
|
|
|
List<BasePatientDO> patientDOS = basePatientDao.findByIdcard(idNo);
|
|
|
BasePatientDO patientDO = new BasePatientDO();
|
|
|
if (patientDOS==null||patientDOS.size()==0){
|
|
|
patientDO.setDel("1");
|
|
|
patientDO.setName(family.getString("userName"));
|
|
|
patientDO.setCreateTime(new Date());
|
|
|
patientDO.setUpdateTime(new Date());
|
|
|
patientDO.setYktId(family.getString("patientAccountId"));
|
|
|
patientDO.setUserId(family.getString("patientAccountId"));
|
|
|
patientDO.setIdcard(family.getString("idNo"));
|
|
|
String idcard1 = family.getString("idNo");
|
|
|
Integer age1 = IdCardUtil.getAgeForIdcard(idcard1);
|
|
|
String sex1 = IdCardUtil.getSexForIdcard_new(idcard1);
|
|
|
|
|
|
Integer sexx1 = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(sex1)){
|
|
|
sexx1 = Integer.parseInt(sex1);
|
|
|
}
|
|
|
String birthDay1 = IdCardUtil.getBirthdayForIdcardStr(idcard1);
|
|
|
Date birthday1 = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(birthDay1)){
|
|
|
birthday1 = DateUtil.strToDate(birthDay1+" 00:00:00");;
|
|
|
}
|
|
|
patientDO.setAge(age1);
|
|
|
patientDO.setBirthday(birthday1);
|
|
|
patientDO.setSex(sexx1);
|
|
|
patientDO.setMobile(familyMobile);
|
|
|
String salt1 = UUID.randomUUID().toString().substring(0,5);
|
|
|
String pw1 = idcard1.substring(idcard1.length()-6,idcard1.length());
|
|
|
patientDO.setPassword(MD5.md5Hex(pw1 + "{" + salt1 + "}"));
|
|
|
patientDO.setSalt(salt1);
|
|
|
patientDO.setLocked(0);
|
|
|
patientDO.setEnabled(1);
|
|
|
patientDO.setPatientStatus("1");
|
|
|
patientDO.setAppletsOpenId(family.getString("mainAccountOpenid"));
|
|
|
patientDO = basePatientDao.save(patientDO);
|
|
|
}else {
|
|
|
patientDO=patientDOS.get(0);
|
|
|
}
|
|
|
JSONArray cardList = family.getJSONArray("cardList");
|
|
|
if (cardList!=null&&cardList.size()!=0){
|
|
|
for (int j=0;j<cardList.size();j++){
|
|
|
JSONObject card = cardList.getJSONObject(j);
|
|
|
String cardNo = card.getString("cardNo");
|
|
|
PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByCodeAndPatientCode(cardNo,patientDO.getId());
|
|
|
if (patientMedicareCardDO==null){
|
|
|
patientMedicareCardDO = new PatientMedicareCardDO();
|
|
|
patientMedicareCardDO.setCode(cardNo);
|
|
|
patientMedicareCardDO.setDel("1");
|
|
|
patientMedicareCardDO.setPatientCode(patientDO.getId());
|
|
|
patientMedicareCardDO.setParentType("A");
|
|
|
if (card.getString("cardType").equalsIgnoreCase("1")){
|
|
|
patientMedicareCardDO.setType("A_01");
|
|
|
}else if (card.getString("cardType").equalsIgnoreCase("2")){
|
|
|
patientMedicareCardDO.setType("A_02");
|
|
|
}else if (card.getString("cardType").equalsIgnoreCase("3")){
|
|
|
patientMedicareCardDO.setType("A_03");
|
|
|
}else if (card.getString("cardType").equalsIgnoreCase("9")){
|
|
|
patientMedicareCardDO.setType("A_09");
|
|
|
}
|
|
|
patientMedicareCardDao.save(patientMedicareCardDO);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
WlyyPatientFamilyMemberDO familyMemberDO = familyMemberDao.findFamilyMemberByYktFamilyId(basePatientDO.getId(),family.getString("patientAccountId"));
|
|
|
BasePatientMemberDictDO basePatientMemberDictDO = basePatientMemberDictDao.findOne(family.getString("relationship"));
|
|
|
if (familyMemberDO==null){
|
|
|
familyMemberDO = new WlyyPatientFamilyMemberDO();
|
|
|
familyMemberDO.setIsDel(1);
|
|
|
familyMemberDO.setFamilyMember(patientDO.getId());
|
|
|
familyMemberDO.setPatient(basePatientDO.getId());
|
|
|
familyMemberDO.setYktFamilyId(family.getString("patientAccountId"));
|
|
|
familyMemberDO.setCreateTime(new Date());
|
|
|
familyMemberDO.setUpdateTime(new Date());
|
|
|
familyMemberDO.setCardNo(patientDO.getIdcard());
|
|
|
familyMemberDO.setMobile(familyMobile);
|
|
|
familyMemberDO.setCardType(family.getString("idType"));
|
|
|
familyMemberDO.setFamilyRelation(family.getString("relationship"));
|
|
|
if (basePatientMemberDictDO!=null){
|
|
|
familyMemberDO.setFamilyRelationName(basePatientMemberDictDO.getRelationName());
|
|
|
}
|
|
|
familyMemberDao.save(familyMemberDO);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}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());
|
|
|
}
|
|
|
|
|
|
}*/
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
throw new Exception(resObj.getString("msg"));
|
|
|
}
|
|
|
}
|
|
|
parameters.remove("password");
|
|
|
// 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(parameters.get("username"),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");
|
|
|
} else if (!StringUtils.isEmpty(loginType)&&"3".equalsIgnoreCase(loginType)){
|
|
|
if (wlyyRedisVerifyCodeService.verification(client_id, username, captcha)) {
|
|
|
//验证码正确
|
|
|
}
|
|
|
// if (wlyyRedisVerifyCodeService.verification(client_id, username, captcha)) {
|
|
|
// //验证码正确
|
|
|
// }
|
|
|
} else {
|
|
|
//第三方同步账号模式登录
|
|
|
parameters.put("grant_type", "ihealthCode");
|
|
|
}
|
|
|
} else {
|
|
|
parameters.put("grant_type", "captcha");
|
|
|
if (wxId.equalsIgnoreCase("xm_ykyy_wx")){
|
|
|
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 res = ykyyService.loginAndMessage(username,captcha);
|
|
|
if (!StringUtils.isEmpty(res)) {
|
|
|
JSONObject resObj = JSONObject.parseObject(res);
|
|
|
if (resObj.getString("code").equalsIgnoreCase("200")) {
|
|
|
JSONObject data = resObj.getJSONObject("data");
|
|
|
String accessToken = data.getString("accessToken");
|
|
|
logger.info("accessToken"+accessToken);
|
|
|
String infoRes = ykyyService.info(accessToken);
|
|
|
if (!StringUtils.isEmpty(infoRes)) {
|
|
|
JSONObject infoObj = JSONObject.parseObject(infoRes);
|
|
|
if (infoObj.getString("code").equalsIgnoreCase("200")) {
|
|
|
JSONObject infoData = infoObj.getJSONObject("data");
|
|
|
String mobile1 = infoData.getString("mobile");
|
|
|
List<BasePatientDO> basePatientDOS = basePatientDao.findByMobile(mobile1);
|
|
|
BasePatientDO basePatientDO = new BasePatientDO();
|
|
|
if (basePatientDOS == null || basePatientDOS.size() == 0) {
|
|
|
logger.info("accessToken3333333333333333"+accessToken);
|
|
|
basePatientDO.setDel("1");
|
|
|
basePatientDO.setName(infoData.getString("userName"));
|
|
|
basePatientDO.setCreateTime(new Date());
|
|
|
basePatientDO.setUpdateTime(new Date());
|
|
|
basePatientDO.setYktId(infoData.getString("mainAccountId"));
|
|
|
basePatientDO.setUserId(infoData.getString("mainAccountId"));
|
|
|
basePatientDO.setIdcard(infoData.getString("idNo"));
|
|
|
String idcard = infoData.getString("idNo");
|
|
|
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 = infoData.getString("birthday");
|
|
|
Date birthday = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(birthDay)) {
|
|
|
birthday = DateUtil.strToDate(birthDay + " 00:00:00");
|
|
|
;
|
|
|
}
|
|
|
basePatientDO.setAge(age);
|
|
|
basePatientDO.setBirthday(birthday);
|
|
|
basePatientDO.setSex(sexx);
|
|
|
basePatientDO.setMobile(mobile1);
|
|
|
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(accessToken);
|
|
|
basePatientDO.setPatientStatus("1");
|
|
|
basePatientDO.setAppletsOpenId(infoData.getString("openid"));
|
|
|
basePatientDO = basePatientDao.save(basePatientDO);
|
|
|
JSONArray familyList = infoData.getJSONArray("patientAccountList");
|
|
|
if (familyList!=null&&familyList.size()!=0){
|
|
|
for (int i = 0; i < familyList.size(); i++) {
|
|
|
JSONObject family = familyList.getJSONObject(i);
|
|
|
String familyMobile = family.getString("mobile");
|
|
|
String idNo = family.getString("idNo");
|
|
|
List<BasePatientDO> patientDOS = basePatientDao.findByIdcard(idNo);
|
|
|
BasePatientDO patientDO = new BasePatientDO();
|
|
|
if (patientDOS == null || patientDOS.size() == 0) {
|
|
|
patientDO.setDel("1");
|
|
|
patientDO.setName(family.getString("userName"));
|
|
|
patientDO.setCreateTime(new Date());
|
|
|
patientDO.setUpdateTime(new Date());
|
|
|
patientDO.setYktId(family.getString("patientAccountId"));
|
|
|
patientDO.setUserId(family.getString("patientAccountId"));
|
|
|
patientDO.setIdcard(family.getString("idNo"));
|
|
|
String idcard1 = family.getString("idNo");
|
|
|
Integer age1 = IdCardUtil.getAgeForIdcard(idcard1);
|
|
|
String sex1 = IdCardUtil.getSexForIdcard_new(idcard1);
|
|
|
|
|
|
Integer sexx1 = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(sex1)) {
|
|
|
sexx1 = Integer.parseInt(sex);
|
|
|
}
|
|
|
String birthDay1 = IdCardUtil.getBirthdayForIdcardStr(idcard1);
|
|
|
Date birthday1 = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(birthDay1)) {
|
|
|
birthday1 = DateUtil.strToDate(birthDay1 + " 00:00:00");
|
|
|
;
|
|
|
}
|
|
|
patientDO.setAge(age1);
|
|
|
patientDO.setBirthday(birthday1);
|
|
|
patientDO.setSex(sexx1);
|
|
|
patientDO.setMobile(familyMobile);
|
|
|
String salt1 = UUID.randomUUID().toString().substring(0, 5);
|
|
|
String pw1 = idcard1.substring(idcard1.length() - 6, idcard1.length());
|
|
|
patientDO.setPassword(MD5.md5Hex(pw1 + "{" + salt1 + "}"));
|
|
|
patientDO.setSalt(salt1);
|
|
|
patientDO.setLocked(0);
|
|
|
patientDO.setEnabled(1);
|
|
|
patientDO.setPatientStatus("1");
|
|
|
patientDO.setAppletsOpenId(family.getString("mainAccountOpenid"));
|
|
|
patientDO = basePatientDao.save(patientDO);
|
|
|
} else {
|
|
|
patientDO = patientDOS.get(0);
|
|
|
}
|
|
|
JSONArray cardList = family.getJSONArray("cardList");
|
|
|
if (cardList!=null&&cardList.size()!=0){
|
|
|
for (int j = 0; j < cardList.size(); j++) {
|
|
|
JSONObject card = cardList.getJSONObject(j);
|
|
|
String cardNo = card.getString("cardNo");
|
|
|
PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByCodeAndPatientCode(cardNo,patientDO.getId()); if (patientMedicareCardDO == null) {
|
|
|
patientMedicareCardDO = new PatientMedicareCardDO();
|
|
|
patientMedicareCardDO.setCode(cardNo);
|
|
|
patientMedicareCardDO.setDel("1");
|
|
|
patientMedicareCardDO.setPatientCode(patientDO.getId());
|
|
|
patientMedicareCardDO.setParentType("A");
|
|
|
if (card.getString("cardType").equalsIgnoreCase("1")) {
|
|
|
patientMedicareCardDO.setType("A_01");
|
|
|
} else if (card.getString("cardType").equalsIgnoreCase("2")) {
|
|
|
patientMedicareCardDO.setType("A_02");
|
|
|
} else if (card.getString("cardType").equalsIgnoreCase("3")) {
|
|
|
patientMedicareCardDO.setType("A_03");
|
|
|
} else if (card.getString("cardType").equalsIgnoreCase("9")) {
|
|
|
patientMedicareCardDO.setType("A_09");
|
|
|
}
|
|
|
patientMedicareCardDao.save(patientMedicareCardDO);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
WlyyPatientFamilyMemberDO familyMemberDO = familyMemberDao.findFamilyMemberByYktFamilyId(basePatientDO.getId(), family.getString("patientAccountId"));
|
|
|
BasePatientMemberDictDO basePatientMemberDictDO = basePatientMemberDictDao.findOne(family.getString("relationship"));
|
|
|
if (familyMemberDO == null) {
|
|
|
familyMemberDO = new WlyyPatientFamilyMemberDO();
|
|
|
familyMemberDO.setIsDel(1);
|
|
|
familyMemberDO.setFamilyMember(patientDO.getId());
|
|
|
familyMemberDO.setPatient(basePatientDO.getId());
|
|
|
familyMemberDO.setYktFamilyId(family.getString("patientAccountId"));
|
|
|
familyMemberDO.setCreateTime(new Date());
|
|
|
familyMemberDO.setUpdateTime(new Date());
|
|
|
familyMemberDO.setCardNo(patientDO.getIdcard());
|
|
|
familyMemberDO.setMobile(familyMobile);
|
|
|
familyMemberDO.setCardType(family.getString("idType"));
|
|
|
familyMemberDO.setFamilyRelation(family.getString("relationship"));
|
|
|
if (basePatientMemberDictDO != null) {
|
|
|
familyMemberDO.setFamilyRelationName(basePatientMemberDictDO.getRelationName());
|
|
|
}
|
|
|
familyMemberDao.save(familyMemberDO);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
basePatientDO = basePatientDOS.get(0);
|
|
|
basePatientDO.setAppletsOpenId(infoData.getString("openid"));
|
|
|
basePatientDO.setVerifyCode(accessToken);
|
|
|
logger.info("accessToken222222222222222222"+accessToken);
|
|
|
basePatientDao.save(basePatientDO);
|
|
|
JSONArray familyList = infoData.getJSONArray("patientAccountList");
|
|
|
if (familyList!=null&&familyList.size()!=0){
|
|
|
for (int i = 0; i < familyList.size(); i++) {
|
|
|
JSONObject family = familyList.getJSONObject(i);
|
|
|
String familyMobile = family.getString("mobile");
|
|
|
String idNo = family.getString("idNo");
|
|
|
List<BasePatientDO> patientDOS = basePatientDao.findByIdcard(idNo);
|
|
|
BasePatientDO patientDO = new BasePatientDO();
|
|
|
if (patientDOS == null || patientDOS.size() == 0) {
|
|
|
patientDO.setDel("1");
|
|
|
patientDO.setName(family.getString("userName"));
|
|
|
patientDO.setCreateTime(new Date());
|
|
|
patientDO.setUpdateTime(new Date());
|
|
|
patientDO.setYktId(family.getString("patientAccountId"));
|
|
|
patientDO.setUserId(family.getString("patientAccountId"));
|
|
|
patientDO.setIdcard(family.getString("idNo"));
|
|
|
String idcard1 = family.getString("idNo");
|
|
|
Integer age1 = IdCardUtil.getAgeForIdcard(idcard1);
|
|
|
String sex1 = IdCardUtil.getSexForIdcard_new(idcard1);
|
|
|
|
|
|
Integer sexx1 = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(sex1)) {
|
|
|
sexx1 = Integer.parseInt(sex1);
|
|
|
}
|
|
|
String birthDay1 = IdCardUtil.getBirthdayForIdcardStr(idcard1);
|
|
|
Date birthday1 = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(birthDay1)) {
|
|
|
birthday1 = DateUtil.strToDate(birthDay1 + " 00:00:00");
|
|
|
;
|
|
|
}
|
|
|
patientDO.setAge(age1);
|
|
|
patientDO.setBirthday(birthday1);
|
|
|
patientDO.setSex(sexx1);
|
|
|
patientDO.setMobile(familyMobile);
|
|
|
String salt1 = UUID.randomUUID().toString().substring(0, 5);
|
|
|
String pw1 = idcard1.substring(idcard1.length() - 6, idcard1.length());
|
|
|
patientDO.setPassword(MD5.md5Hex(pw1 + "{" + salt1 + "}"));
|
|
|
patientDO.setSalt(salt1);
|
|
|
patientDO.setLocked(0);
|
|
|
patientDO.setEnabled(1);
|
|
|
patientDO.setPatientStatus("1");
|
|
|
patientDO.setAppletsOpenId(family.getString("mainAccountOpenid"));
|
|
|
patientDO = basePatientDao.save(patientDO);
|
|
|
} else {
|
|
|
patientDO = patientDOS.get(0);
|
|
|
}
|
|
|
JSONArray cardList = family.getJSONArray("cardList");
|
|
|
if (cardList!=null&&cardList.size()!=0){
|
|
|
for (int j = 0; j < cardList.size(); j++) {
|
|
|
JSONObject card = cardList.getJSONObject(j);
|
|
|
String cardNo = card.getString("cardNo");
|
|
|
PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByCodeAndPatientCode(cardNo,patientDO.getId()); if (patientMedicareCardDO == null) {
|
|
|
patientMedicareCardDO = new PatientMedicareCardDO();
|
|
|
patientMedicareCardDO.setCode(cardNo);
|
|
|
patientMedicareCardDO.setDel("1");
|
|
|
patientMedicareCardDO.setPatientCode(patientDO.getId());
|
|
|
patientMedicareCardDO.setParentType("A");
|
|
|
if (card.getString("cardType").equalsIgnoreCase("1")) {
|
|
|
patientMedicareCardDO.setType("A_01");
|
|
|
} else if (card.getString("cardType").equalsIgnoreCase("2")) {
|
|
|
patientMedicareCardDO.setType("A_02");
|
|
|
} else if (card.getString("cardType").equalsIgnoreCase("3")) {
|
|
|
patientMedicareCardDO.setType("A_03");
|
|
|
} else if (card.getString("cardType").equalsIgnoreCase("9")) {
|
|
|
patientMedicareCardDO.setType("A_09");
|
|
|
}
|
|
|
patientMedicareCardDao.save(patientMedicareCardDO);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
WlyyPatientFamilyMemberDO familyMemberDO = familyMemberDao.findFamilyMemberByYktFamilyId(basePatientDO.getId(), family.getString("patientAccountId"));
|
|
|
BasePatientMemberDictDO basePatientMemberDictDO = basePatientMemberDictDao.findOne(family.getString("relationship"));
|
|
|
if (familyMemberDO == null) {
|
|
|
familyMemberDO = new WlyyPatientFamilyMemberDO();
|
|
|
familyMemberDO.setIsDel(1);
|
|
|
familyMemberDO.setFamilyMember(patientDO.getId());
|
|
|
familyMemberDO.setPatient(basePatientDO.getId());
|
|
|
familyMemberDO.setYktFamilyId(family.getString("patientAccountId"));
|
|
|
familyMemberDO.setCreateTime(new Date());
|
|
|
familyMemberDO.setUpdateTime(new Date());
|
|
|
familyMemberDO.setCardNo(patientDO.getIdcard());
|
|
|
familyMemberDO.setMobile(familyMobile);
|
|
|
familyMemberDO.setCardType(family.getString("idType"));
|
|
|
familyMemberDO.setFamilyRelation(family.getString("relationship"));
|
|
|
if (basePatientMemberDictDO != null) {
|
|
|
familyMemberDO.setFamilyRelationName(basePatientMemberDictDO.getRelationName());
|
|
|
}
|
|
|
familyMemberDao.save(familyMemberDO);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
throw new Exception(resObj.getString("msg"));
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
parameters.put("grant_type", "captcha");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
logger.info("登陆111111111111111111");
|
|
|
ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
|
|
|
@ -3586,8 +4143,11 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
if (!StringUtils.isEmpty(appletCode)){
|
|
|
Map<String,Object> objectMap = checkApplets(appletCode,wxWechatDO.getApplets(),wxWechatDO.getAppletsSecret());
|
|
|
if (objectMap!=null){
|
|
|
appletOpenid = objectMap.get("openid").toString();
|
|
|
userDetailsService.updateOpenId(appletOpenid, wlyyUserSimple.getId());
|
|
|
if (objectMap.get("openid")!=null){
|
|
|
appletOpenid = objectMap.get("openid").toString();
|
|
|
userDetailsService.updateOpenId(appletOpenid, wlyyUserSimple.getId());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
|