Преглед изворни кода

Merge branch '2.0' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into 2.0

LAPTOP-KB9HII50\70708 пре 1 година
родитељ
комит
8a6e016c06

+ 27 - 10
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -7333,7 +7333,7 @@ public class StatisticsEsService {
        //今天的
        //今天的
        String sql = "SELECT SUM(q.total)'todayFree' FROM(\n" +
        String sql = "SELECT SUM(q.total)'todayFree' FROM(\n" +
                "	SELECT\n" +
                "	SELECT\n" +
                "	 IF(SUM(p.drug_fee) IS NULL,0,SUM(p.drug_fee))	 AS total \n" +
                "	 IF(SUM(p.drug_fee) IS NULL,'0',SUM(p.drug_fee))	 AS total \n" +
                "	FROM\n" +
                "	FROM\n" +
                "		wlyy_prescription p\n" +
                "		wlyy_prescription p\n" +
                "		INNER JOIN wlyy_outpatient o ON p.outpatient_id = o.id \n" +
                "		INNER JOIN wlyy_outpatient o ON p.outpatient_id = o.id \n" +
@ -7343,7 +7343,7 @@ public class StatisticsEsService {
                "		AND p.create_time  >='" + qvo.getEndDate() + "'  AND p.create_time <='" + qvo.getEndDate() + " 23:59:59' \n" +
                "		AND p.create_time  >='" + qvo.getEndDate() + "'  AND p.create_time <='" + qvo.getEndDate() + " 23:59:59' \n" +
                "	UNION ALL\n" +
                "	UNION ALL\n" +
                "	SELECT\n" +
                "	SELECT\n" +
                "		COALESCE(ROUND(SUM(bop.pay_price),2), 0) AS total\n" +
                "		COALESCE(ROUND(SUM(bop.pay_price),2), '0.00') AS total\n" +
                "	FROM\n" +
                "	FROM\n" +
                "		wlyy_outpatient o\n" +
                "		wlyy_outpatient o\n" +
                "		LEFT JOIN base_business_order_pay bop ON o.id = bop.relation_code \n" +
                "		LEFT JOIN base_business_order_pay bop ON o.id = bop.relation_code \n" +
@ -7403,20 +7403,37 @@ public class StatisticsEsService {
        }
        }
        allCount = prescriptionFee + checkFree;
        allCount = prescriptionFee + checkFree;
        resultMap.put("checkFree", checkFree);//检查费
        resultMap.put("prescriptionFee", prescriptionFee);//处方费
        resultMap.put("allCount", allCount);//总费用
        if (checkFree == 0) {
            resultMap.put("checkFree", "0.00");//检查费
        } else {
            resultMap.put("checkFree", checkFree);//检查费
        }
        if (prescriptionFee == 0) {
            resultMap.put("prescriptionFee", "0.00");//处方费
        } else {
            resultMap.put("prescriptionFee", prescriptionFee);//处方费
        }
        if (allCount == 0) {
        if (allCount == 0) {
            resultMap.put("avgFree", 0);
            resultMap.put("allCount", "0.00");//总费用
        } else {
            resultMap.put("allCount", allCount);//总费用
        }
        if (allCount == 0) {
            resultMap.put("avgFree", "0.00");
        } else {
        } else {
            resultMap.put("avgFree", allCount / 2.0);//平均费用
            resultMap.put("avgFree", allCount / 2.0);//平均费用
        }
        }
        if (monthModel != null) {
        if (monthModel != null && monthModel.getResult2().longValue() != 0) {
            resultMap.put("monthFree", monthModel.getResult2().longValue());//本月新增
            resultMap.put("monthFree", monthModel.getResult2().longValue());//本月新增
        } else {
        } else {
            resultMap.put("monthFree", 0);
            resultMap.put("monthFree", "0.00");
        }
        if ("0".equals(todayFree)) {
            resultMap.put("todayFree", "0.00");
        } else {
            resultMap.put("todayFree", todayFree);//今日新增
        }
        }
        resultMap.put("todayFree", todayFree);//今日新增
        System.out.println("结果===>"+JSON.toJSONString(resultMap));
        return resultMap;
        return resultMap;
    }
    }
@ -7791,7 +7808,7 @@ public class StatisticsEsService {
     * 获取i健康的患者的健康指标数据
     * 获取i健康的患者的健康指标数据
     */
     */
    public JSONObject getHealthChart(ScreenQvo qvo) {
    public JSONObject getHealthChart(ScreenQvo qvo) {
        String param = "?idcard=" + qvo.getIdcard() + "&type=" + qvo.getType() + "&gi_type="+qvo.getIndex() + "&time=" + qvo.getTime() + "&begin=" + qvo.getStartDate() + "&end=" + qvo.getEndDate();
        String param = "?idcard=" + qvo.getIdcard() + "&type=" + qvo.getType() + "&gi_type=" + qvo.getIndex() + "&time=" + qvo.getTime() + "&begin=" + qvo.getStartDate() + "&end=" + qvo.getEndDate();
        JSONObject re = wlyyHttpService.sendWlyyMesGet("chart", param);
        JSONObject re = wlyyHttpService.sendWlyyMesGet("chart", param);
        return re;
        return re;
    }
    }

+ 1 - 0
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/PostFilter.java

@ -137,6 +137,7 @@ public class PostFilter extends ZuulFilter {
                url.contains("/excelControl")||
                url.contains("/excelControl")||
                url.contains("/prescription/searchRecordWrite")||
                url.contains("/prescription/searchRecordWrite")||
                url.contains("/Funds/reconciliationExcel")||
                url.contains("/Funds/reconciliationExcel")||
//                url.contains("/open/statistics")||
                url.contains("/servicePackageSubItem/exportSubItemExcel")|| //导出
                url.contains("/servicePackageSubItem/exportSubItemExcel")|| //导出

+ 795 - 770
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -1,5 +1,6 @@
package com.yihu.jw.security.oauth2.provider.endpoint;
package com.yihu.jw.security.oauth2.provider.endpoint;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.impl.DefaultKaptcha;
@ -97,11 +98,9 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit;
/**
/**
 *
 * Endpoint for default login verify and sso login token verify
 * Endpoint for default login verify and sso login token verify
 * will return the user's basic information and token certificate
 * will return the user's basic information and token certificate
 *
 *
 *
 * @author Progr1mmer
 * @author Progr1mmer
 * @created on 2018/8/29
 * @created on 2018/8/29
 */
 */
@ -192,71 +191,72 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private void init() {
    private void init() {
        super.setTokenGranter(tokenGranter);
        super.setTokenGranter(tokenGranter);
    }
    }
    @RequestMapping(value = "/oauth/getGeetConfig", method = RequestMethod.GET)
    @RequestMapping(value = "/oauth/getGeetConfig", method = RequestMethod.GET)
    public  JSONObject getGeetConfig(String isPaitent){
    public JSONObject getGeetConfig(String isPaitent) {
        //患者端id
        //患者端id
        String gt="d99d7ba0ce0ad944d02c11e2e00b184f";
        String gt = "d99d7ba0ce0ad944d02c11e2e00b184f";
        //医生端id
        //医生端id
        String gtDoctor="65234b3ce5a6fed467ef64bcc4330605";
        String gtDoctor = "65234b3ce5a6fed467ef64bcc4330605";
        String url = "http://bypass.geetest.com/v1/bypass_status.php";
        String url = "http://bypass.geetest.com/v1/bypass_status.php";
        String register="http://localhost:8088/register";
        String register = "http://localhost:8088/register";
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        JSONObject returnResult = new JSONObject();
        JSONObject returnResult = new JSONObject();
        List<WlyyHospitalSysDictDO> list = wlyyhospitalSysdictDao.findByDictName("geetConfig");
        List<WlyyHospitalSysDictDO> list = wlyyhospitalSysdictDao.findByDictName("geetConfig");
        for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:list){
            if ("type".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                result.put("type",wlyyHospitalSysDictDO.getDictValue());
        for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO : list) {
            if ("type".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())) {
                result.put("type", wlyyHospitalSysDictDO.getDictValue());
            }
            }
            if ("register".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
            if ("register".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())) {
                register = wlyyHospitalSysDictDO.getDictValue();
                register = wlyyHospitalSysDictDO.getDictValue();
            }
            }
            if ("bypass".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
            if ("bypass".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())) {
                url = wlyyHospitalSysDictDO.getDictValue();
                url = wlyyHospitalSysDictDO.getDictValue();
            }
            }
        }
        }
        if (!"1".equalsIgnoreCase(isPaitent)){
            gt=gtDoctor;
        if (!"1".equalsIgnoreCase(isPaitent)) {
            gt = gtDoctor;
        }
        }
        List<NameValuePair> params = new ArrayList<>();
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("gt",gt));
        params.add(new BasicNameValuePair("gt", gt));
        String res = httpClientUtil.post(url, params, "UTF-8");
        String res = httpClientUtil.post(url, params, "UTF-8");
        JSONObject statusObject = JSONObject.parseObject(res);
        JSONObject statusObject = JSONObject.parseObject(res);
        if (statusObject!=null){
            result.put("offline",statusObject.getString("status"));
        if (statusObject != null) {
            result.put("offline", statusObject.getString("status"));
        }
        }
        System.out.println(res);
        System.out.println(res);
        Long t= new Date().getTime();
        String registerRes= httpClientUtil.get(register+"?t="+t+"&isPatient="+isPaitent,"UTF-8");
        Long t = new Date().getTime();
        String registerRes = httpClientUtil.get(register + "?t=" + t + "&isPatient=" + isPaitent, "UTF-8");
        System.out.println(registerRes);
        System.out.println(registerRes);
        JSONObject registerObject= JSONObject.parseObject(registerRes);
        if (registerObject!=null){
            result.put("challenge",registerObject.getString("challenge"));
            result.put("newCaptcha",registerObject.getString("new_captcha"));
        JSONObject registerObject = JSONObject.parseObject(registerRes);
        if (registerObject != null) {
            result.put("challenge", registerObject.getString("challenge"));
            result.put("newCaptcha", registerObject.getString("new_captcha"));
        }
        }
        result.put("gt",gt);
        result.put("gt", gt);
        System.out.println(result.toJSONString());
        System.out.println(result.toJSONString());
        returnResult.put("status",200);
        returnResult.put("message","success");
        returnResult.put("obj",result);
        returnResult.put("status", 200);
        returnResult.put("message", "success");
        returnResult.put("obj", result);
        return returnResult;
        return returnResult;
    }
    }
    public  JSONObject validateGeet( String geetestChallenge,String geetestValidate,String geetestSeccode,String isPatient){
    public JSONObject validateGeet(String geetestChallenge, String geetestValidate, String geetestSeccode, String isPatient) {
        String validateUrl = "http://localhost:8088/validate";
        String validateUrl = "http://localhost:8088/validate";
        List<WlyyHospitalSysDictDO> list = wlyyhospitalSysdictDao.findByDictName("geetConfig");
        List<WlyyHospitalSysDictDO> list = wlyyhospitalSysdictDao.findByDictName("geetConfig");
        for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:list){
            if ("validateUrl".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                validateUrl=wlyyHospitalSysDictDO.getDictValue();
        for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO : list) {
            if ("validateUrl".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())) {
                validateUrl = wlyyHospitalSysDictDO.getDictValue();
            }
            }
        }
        }
        List<NameValuePair> params = new ArrayList<>();
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("geetest_challenge",geetestChallenge));
        params.add(new BasicNameValuePair("geetest_validate",geetestValidate));
        params.add(new BasicNameValuePair("geetest_seccode",geetestSeccode));
        params.add(new BasicNameValuePair("isPatient",isPatient));
        params.add(new BasicNameValuePair("geetest_challenge", geetestChallenge));
        params.add(new BasicNameValuePair("geetest_validate", geetestValidate));
        params.add(new BasicNameValuePair("geetest_seccode", geetestSeccode));
        params.add(new BasicNameValuePair("isPatient", isPatient));
        String res = httpClientUtil.post(validateUrl, params, "UTF-8");
        String res = httpClientUtil.post(validateUrl, params, "UTF-8");
        JSONObject statusObject = JSONObject.parseObject(res);
        JSONObject statusObject = JSONObject.parseObject(res);
        System.out.println(statusObject.toJSONString());
        System.out.println(statusObject.toJSONString());
@ -265,38 +265,38 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    @PostMapping(value = "/oauth/doctor/logOff")
    @PostMapping(value = "/oauth/doctor/logOff")
    public JSONObject doctorLogOff(HttpServletRequest request){
    public JSONObject doctorLogOff(HttpServletRequest request) {
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject = new JSONObject();
        try {
        try {
            BaseLoginLogDO loginLogDO = getLoginLog();
            BaseLoginLogDO loginLogDO = getLoginLog();
            if(loginLogDO == null){
                jsonObject.put("msg","该操作没有权限");
                jsonObject.put("status",200);
            if (loginLogDO == null) {
                jsonObject.put("msg", "该操作没有权限");
                jsonObject.put("status", 200);
                return jsonObject;
                return jsonObject;
            }
            }
            userDetailsService.logOff(loginLogDO.getUserId());
            userDetailsService.logOff(loginLogDO.getUserId());
            jsonObject.put("msg","注销成功");
            jsonObject.put("status",200);
            jsonObject.put("msg", "注销成功");
            jsonObject.put("status", 200);
            return jsonObject;
            return jsonObject;
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            jsonObject.put("msg","注销失败!");
            jsonObject.put("status",500);
            jsonObject.put("msg", "注销失败!");
            jsonObject.put("status", 500);
            return jsonObject;
            return jsonObject;
        }
        }
    }
    }
    public HttpServletRequest getRequest(){
    public HttpServletRequest getRequest() {
        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    }
    }
    private BaseLoginLogDO getLoginLog(){
    private BaseLoginLogDO getLoginLog() {
        String accessToken = this.extractToken(getRequest());
        String accessToken = this.extractToken(getRequest());
        String sql  = "SELECT a.* from base_login_log a WHERE a.token='"+accessToken+"' ORDER BY a.create_time desc LIMIT 1";
        String sql = "SELECT a.* from base_login_log a WHERE a.token='" + accessToken + "' ORDER BY a.create_time desc LIMIT 1";
        List<BaseLoginLogDO> baseLoginLogDOList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BaseLoginLogDO.class));
        List<BaseLoginLogDO> baseLoginLogDOList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BaseLoginLogDO.class));
        //BaseLoginLogDO loginLogDO = baseLoginLogDao.findByToken(accessToken);
        //BaseLoginLogDO loginLogDO = baseLoginLogDao.findByToken(accessToken);
        return baseLoginLogDOList.size()>0?baseLoginLogDOList.get(0):null;
        return baseLoginLogDOList.size() > 0 ? baseLoginLogDOList.get(0) : null;
    }
    }
    private String extractToken(HttpServletRequest request) {
    private String extractToken(HttpServletRequest request) {
@ -326,190 +326,199 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
     */
     */
    @RequestMapping(value = "/oauth/login", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/login", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> login(@RequestParam Map<String, String> parameters, HttpSession httpSession) throws Exception {
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> login(@RequestParam Map<String, String> parameters, HttpSession httpSession) throws Exception {
            logger.info("login:登录进入1");
            //图形验证码验证
            String key = parameters.get("key");
            String text = parameters.get("text");
            if(org.apache.commons.lang3.StringUtils.isNotBlank(key)&& org.apache.commons.lang3.StringUtils.isNotBlank(text)){
                if(!verifyCaptcha(key,text)){
                    throw new ImgCaptchaException("验证码错误!");
                }
        System.out.println("参数内容 parameters==>" + JSON.toJSONString(parameters));
        System.out.println("httpSession.getId()==>" + httpSession.getId());
        logger.info("login:登录进入1");
        //图形验证码验证
        String key = parameters.get("key");
        String text = parameters.get("text");
        System.out.println("key==>" + key);
        System.out.println("text==>" + text);
        if (org.apache.commons.lang3.StringUtils.isNotBlank(key) && org.apache.commons.lang3.StringUtils.isNotBlank(text)) {
            if (!verifyCaptcha(key, text)) {
                System.out.println("");
                throw new ImgCaptchaException("验证码错误!");
            }
            }
            logger.info("login:登录进入2");
        }
        logger.info("login:登录进入2");
            String flag = parameters.get("flag");
        String flag = parameters.get("flag");
            String username = parameters.get("username");
            logger.info(username);
        String username = parameters.get("username");
        logger.info(username);
            if (StringUtils.isEmpty(username)&&StringUtils.isEmpty(flag)) {
                throw new InvalidRequestException("username");
        if (StringUtils.isEmpty(username) && StringUtils.isEmpty(flag)) {
            System.out.println("flag==>" + flag);
            System.out.println("username==>" + username);
            System.out.println("flag或者username为空");
            throw new InvalidRequestException("username");
        }
        String client_id = parameters.get("client_id");
        System.out.println("client_id==>" + client_id);
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        if ("alipay".equals(flag) || "family".equals(flag)) {
            //支付宝登录||家人登录
            parameters.put("grant_type", flag);
            String encdata = parameters.get("encdata");
            if ("alipay".equals(flag)) {
                encdata = AES.decrypt(encdata);
            } else {
                encdata = AesEncryptUtils.agDecrypt(encdata);
            }
            String data[] = encdata.split(":");
            username = data[1];
            parameters.put("username", username);
        } else if ("dingTalk".equals(flag)) {
            //钉钉免登录
            parameters.put("grant_type", "dingTalk");
            String authCode = parameters.get("authCode");
            if (org.apache.commons.lang3.StringUtils.isBlank(authCode)) {
                throw new InvalidRequestException("请求参数错误");
            }
            String registerRes = httpClientUtil.get("http://127.0.0.1:10301/doctor/dingtalk_app_user?authCode=" + authCode, "UTF-8");
            JSONObject jsonObject = JSONObject.parseObject(registerRes);
            if (jsonObject.getInteger("status") == 200) {
                parameters.put("username", jsonObject.getString("message"));
            } else {
                HttpHeaders headers = new HttpHeaders();
                headers.set("Cache-Control", "no-store");
                headers.set("Pragma", "no-cache");
                Oauth2Envelop<WlyyUserSimple> oauth2Envelop = new Oauth2Envelop<>(jsonObject.getString("message"), -1, null);
                return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            }
            }
            String client_id = parameters.get("client_id");
            if (StringUtils.isEmpty(client_id)) {
                throw new InvalidRequestException("client_id");
            }
            if("alipay".equals(flag)||"family".equals(flag)){
                //支付宝登录||家人登录
                parameters.put("grant_type", flag);
                String encdata = parameters.get("encdata");
                if("alipay".equals(flag)){
                    encdata = AES.decrypt(encdata);
                }else{
                    encdata = AesEncryptUtils.agDecrypt(encdata);
                }
                String data[] = encdata.split(":");
                username = data[1];
                parameters.put("username", username);
            }else if("dingTalk".equals(flag)){
                //钉钉免登录
                parameters.put("grant_type", "dingTalk");
                String authCode = parameters.get("authCode");
                if(org.apache.commons.lang3.StringUtils.isBlank(authCode)){
                    throw new InvalidRequestException("请求参数错误");
                }
                String registerRes= httpClientUtil.get("http://127.0.0.1:10301/doctor/dingtalk_app_user?authCode="+authCode,"UTF-8");
                JSONObject jsonObject= JSONObject.parseObject(registerRes);
                if (jsonObject.getInteger("status") == 200){
                    parameters.put("username", jsonObject.getString("message"));
                }else{
                    HttpHeaders headers = new HttpHeaders();
                    headers.set("Cache-Control", "no-store");
                    headers.set("Pragma", "no-cache");
                    Oauth2Envelop<WlyyUserSimple> oauth2Envelop = new Oauth2Envelop<>(jsonObject.getString("message"), -1, null);
                    return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
                }
            }else if("wxApplets".equals(flag)){
                //微信小程序登录
                parameters.put("grant_type", "dingTalk");
                String authCode = parameters.get("authCode");
                if(org.apache.commons.lang3.StringUtils.isBlank(authCode)){
                    throw new InvalidRequestException("请求参数错误");
                }
                String userPhone = wechatService.getUserPhoneByApplets(authCode);
                if (!StringUtils.isEmpty(userPhone)){
                    parameters.put("username", userPhone);
                }else{
                    HttpHeaders headers = new HttpHeaders();
                    headers.set("Cache-Control", "no-store");
                    headers.set("Pragma", "no-cache");
                    Oauth2Envelop<WlyyUserSimple> oauth2Envelop = new Oauth2Envelop<>("获取用户手机号失败", -1, null);
                    return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
                }
            }else if (StringUtils.isEmpty(parameters.get("captcha"))) {
                parameters.put("grant_type", "password");
                //解密密码
                if (parameters.get("password") != null) {
                    KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                    String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
                    parameters.put("password", password);
                } else {
                    //第三方同步账号模式登录
                    parameters.put("grant_type", "ihealthCode");
                }
        } else if ("wxApplets".equals(flag)) {
            //微信小程序登录
            parameters.put("grant_type", "dingTalk");
            String authCode = parameters.get("authCode");
            if (org.apache.commons.lang3.StringUtils.isBlank(authCode)) {
                throw new InvalidRequestException("请求参数错误");
            }
            String userPhone = wechatService.getUserPhoneByApplets(authCode);
            if (!StringUtils.isEmpty(userPhone)) {
                parameters.put("username", userPhone);
            } else {
            } else {
                parameters.put("grant_type", "captcha");
                HttpHeaders headers = new HttpHeaders();
                headers.set("Cache-Control", "no-store");
                headers.set("Pragma", "no-cache");
                Oauth2Envelop<WlyyUserSimple> oauth2Envelop = new Oauth2Envelop<>("获取用户手机号失败", -1, null);
                return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            }
            }
            logger.info("login:登录进入3");
            ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
            if (null == authenticatedClient) {
                throw new InvalidRequestException("client_id");
        } else if (StringUtils.isEmpty(parameters.get("captcha"))) {
            parameters.put("grant_type", "password");
            //解密密码
            if (parameters.get("password") != null) {
                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                System.out.println("keyPair==>" + JSON.toJSONString(keyPair));
                String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
                System.out.println("password==>" + password);
                parameters.put("password", password);
            } else {
                //第三方同步账号模式登录
                parameters.put("grant_type", "ihealthCode");
            }
            }
            logger.info("login:登录进入4"+authenticatedClient.getClientId());
        } else {
            parameters.put("grant_type", "captcha");
        }
        logger.info("login:登录进入3");
            TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
            oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
            OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
            if (token == null) {
                throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
            }
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        if (null == authenticatedClient) {
            throw new InvalidRequestException("client_id");
        }
        logger.info("login:登录进入4" + authenticatedClient.getClientId());
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
        OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        }
        /*如果是移动端登陆则移除之前的token,
        /*如果是移动端登陆则移除之前的token,
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        实现同一账号只能在一处登陆*/
        实现同一账号只能在一处登陆*/
            if("1".equals(kickEachOther)){
                HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
                if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
                    if (tokenStore.readAccessToken(token.getValue())!=null){
                        tokenStore.removeAccessToken(token.getValue());
                        tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
                        token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
                    }
                }
                if (token == null) {
                    throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        if ("1".equals(kickEachOther)) {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile") || request.getHeader("login-device").equalsIgnoreCase("pc"))) {
                if (tokenStore.readAccessToken(token.getValue()) != null) {
                    tokenStore.removeAccessToken(token.getValue());
                    tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
                    token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
                }
                }
            }
            WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
            if ("pad".equals(parameters.get("clientType"))&&!("1".equals(wlyyUserSimple.getArchiveType())) ){//医养平板端登录限制
                throw new InvalidGrantException("不允许登录该平台");
            }
            }
            logger.info("wlyyUserSimple::"+wlyyUserSimple);
            wlyyUserSimple.setAccessToken(token.getValue());
            wlyyUserSimple.setTokenType(token.getTokenType());
            wlyyUserSimple.setExpiresIn(token.getExpiresIn());
            wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
            wlyyUserSimple.setUser(parameters.get("username"));
            wlyyUserSimple.setState(parameters.get("state"));
            String loginType = parameters.get("login_type");
            String openid = parameters.get("openid");
            String wechatId = parameters.get("wechatId");
            logger.info("login:登录进入7");
            //更新患者openId
            BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
            logger.info("gengxin开始");
            if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("3".equals(loginType)||"4".equalsIgnoreCase(loginType))) {
                baseLoginLogDO.setOpenid(openid);
                logger.info("gengxin进入"+openid);
                userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());
                if (!StringUtils.isEmpty(wechatId)&& !"undefined".equalsIgnoreCase(wechatId)){
                    logger.info("gengxin进入"+wechatId);
                    userDetailsService.updateOpenIdAndWechatId(openid,wlyyUserSimple.getId(),wechatId);
                }
                if (wxId.equalsIgnoreCase("xm_zsyy_wx")&&wechatId.equalsIgnoreCase("xm_ihealth_wx")){
                    userDetailsService.updateOpenIdAndWechatId(userDetailsService.getZsyyOpenid(wlyyUserSimple.getIdcard()),wlyyUserSimple.getId(),wxId);
                }
            }else if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("2".equals(loginType))) {
                if (wechatId.equalsIgnoreCase("xm_mlwyy_wx")){
                    logger.info("gengxin进入"+openid);
                    userDetailsService.updateDoctorOpenId(openid, wlyyUserSimple.getId());
                }
            if (token == null) {
                throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
            }
            }
        }
            if (parameters.get("password") != null) {
                //使用密码登录成功后, 更新失败次数为 0
                userDetailsService.addFailureCount(username, 0);
        WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
        if ("pad".equals(parameters.get("clientType")) && !("1".equals(wlyyUserSimple.getArchiveType()))) {//医养平板端登录限制
            throw new InvalidGrantException("不允许登录该平台");
        }
        logger.info("wlyyUserSimple::" + wlyyUserSimple);
        wlyyUserSimple.setAccessToken(token.getValue());
        wlyyUserSimple.setTokenType(token.getTokenType());
        wlyyUserSimple.setExpiresIn(token.getExpiresIn());
        wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
        wlyyUserSimple.setUser(parameters.get("username"));
        wlyyUserSimple.setState(parameters.get("state"));
        String loginType = parameters.get("login_type");
        String openid = parameters.get("openid");
        String wechatId = parameters.get("wechatId");
        logger.info("login:登录进入7");
        //更新患者openId
        BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
        logger.info("gengxin开始");
        if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("3".equals(loginType) || "4".equalsIgnoreCase(loginType))) {
            baseLoginLogDO.setOpenid(openid);
            logger.info("gengxin进入" + openid);
            userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());
            if (!StringUtils.isEmpty(wechatId) && !"undefined".equalsIgnoreCase(wechatId)) {
                logger.info("gengxin进入" + wechatId);
                userDetailsService.updateOpenIdAndWechatId(openid, wlyyUserSimple.getId(), wechatId);
            }
            }
            logger.info("login:登录进入8");
            wlyyUserSimple.setOpenid(openid);
            userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
            if (wxId.equalsIgnoreCase("xm_zsyy_wx") && wechatId.equalsIgnoreCase("xm_ihealth_wx")) {
                userDetailsService.updateOpenIdAndWechatId(userDetailsService.getZsyyOpenid(wlyyUserSimple.getIdcard()), wlyyUserSimple.getId(), wxId);
            }
        } else if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("2".equals(loginType))) {
            if (wechatId.equalsIgnoreCase("xm_mlwyy_wx")) {
                logger.info("gengxin进入" + openid);
                userDetailsService.updateDoctorOpenId(openid, wlyyUserSimple.getId());
            }
        }
            logger.info("login:登录进入9");
            String clientType = parameters.get("clientType");
            baseLoginLogDO.setUserId(wlyyUserSimple.getId());
            baseLoginLogDO.setCreateTime(new Date());
            String userAgent = JSONObject.toJSONString(wlyyUserSimple);
            baseLoginLogDO.setUserAgent(userAgent);
            baseLoginLogDO.setLoginType(loginType);
            baseLoginLogDO.setName(wlyyUserSimple.getName());
            baseLoginLogDO.setClientType(clientType);
            baseLoginLogDO.setToken(token.getValue());
            baseLoginLogService.save(baseLoginLogDO);
            logger.info("login:登录进入10");
            //个推 clientId
            String clientId = parameters.get("getuiClientId");
            String getuiClientType = parameters.get("getuiClientType");
            String padImei = parameters.get("padImei");
            //客户端类型 app,wx,pad,pc
            userDetailsService.updateInfo(clientId,getuiClientType,padImei,loginType,wlyyUserSimple.getId(),baseLoginLogDO);
            return getResponse(wlyyUserSimple);
    }
        if (parameters.get("password") != null) {
            //使用密码登录成功后, 更新失败次数为 0
            userDetailsService.addFailureCount(username, 0);
        }
        logger.info("login:登录进入8");
        wlyyUserSimple.setOpenid(openid);
        userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
        logger.info("login:登录进入9");
        String clientType = parameters.get("clientType");
        baseLoginLogDO.setUserId(wlyyUserSimple.getId());
        baseLoginLogDO.setCreateTime(new Date());
        String userAgent = JSONObject.toJSONString(wlyyUserSimple);
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setLoginType(loginType);
        baseLoginLogDO.setName(wlyyUserSimple.getName());
        baseLoginLogDO.setClientType(clientType);
        baseLoginLogDO.setToken(token.getValue());
        baseLoginLogService.save(baseLoginLogDO);
        logger.info("login:登录进入10");
        //个推 clientId
        String clientId = parameters.get("getuiClientId");
        String getuiClientType = parameters.get("getuiClientType");
        String padImei = parameters.get("padImei");
        //客户端类型 app,wx,pad,pc
        userDetailsService.updateInfo(clientId, getuiClientType, padImei, loginType, wlyyUserSimple.getId(), baseLoginLogDO);
        return getResponse(wlyyUserSimple);
    }
    /**
    /**
@ -594,9 +603,9 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        }
        }
        //删除个推cid
        //删除个推cid
        if(!StringUtils.isEmpty(token)){
        if (!StringUtils.isEmpty(token)) {
            BaseLoginLogDO loginLogDO = baseLoginLogService.findByToken(token);
            BaseLoginLogDO loginLogDO = baseLoginLogService.findByToken(token);
            if(loginLogDO!=null){
            if (loginLogDO != null) {
                userDetailsService.deleteCidByUser(loginLogDO.getUserId());
                userDetailsService.deleteCidByUser(loginLogDO.getUserId());
            }
            }
        }
        }
@ -650,6 +659,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    @RequestMapping(value = "/oauth/getPublicKey", method = RequestMethod.GET)
    @RequestMapping(value = "/oauth/getPublicKey", method = RequestMethod.GET)
    public ObjEnvelop<PublickeyVO> getPublicKey(HttpSession httpSession, HttpServletResponse httpServletResponse) {
    public ObjEnvelop<PublickeyVO> getPublicKey(HttpSession httpSession, HttpServletResponse httpServletResponse) {
        KeyPair keyPair = com.yihu.jw.security.utils.RSAUtils.getKey();
        KeyPair keyPair = com.yihu.jw.security.utils.RSAUtils.getKey();
        System.out.println("httpSession.getId()==>" + httpSession.getId());
        httpSession.setAttribute("privateKey", keyPair);
        httpSession.setAttribute("privateKey", keyPair);
        PublickeyVO pk = new PublickeyVO();
        PublickeyVO pk = new PublickeyVO();
        pk.setPublicKey(com.yihu.jw.security.utils.RSAUtils.generateBase64PublicKey(keyPair));
        pk.setPublicKey(com.yihu.jw.security.utils.RSAUtils.generateBase64PublicKey(keyPair));
@ -726,6 +736,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    /**
    /**
     * 中山医院短信接口
     * 中山医院短信接口
     *
     * @param parameters
     * @param parameters
     * @return
     * @return
     * @throws Exception
     * @throws Exception
@ -740,7 +751,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(username)) {
        if (StringUtils.isEmpty(username)) {
            throw new InvalidRequestException("username");
            throw new InvalidRequestException("username");
        }
        }
        if (username.length()>12){
        if (username.length() > 12) {
            throw new InvalidRequestException("请输入正确的手机号!");
            throw new InvalidRequestException("请输入正确的手机号!");
        }
        }
        //验证请求间隔超时,防止频繁获取验证码
        //验证请求间隔超时,防止频繁获取验证码
@ -748,7 +759,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            throw new IllegalAccessException("SMS request frequency is too fast");
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
        if (wlyyHospitalSysDictDO != null && !StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())) {
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            Captcha _captcha = new Captcha();
            Captcha _captcha = new Captcha();
            _captcha.setCode(captcha);
            _captcha.setCode(captcha);
@ -760,10 +771,10 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            headers.set("Cache-Control", "no-store");
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }else {
        } else {
            //发送短信获取验证码
            //发送短信获取验证码
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            int result =  zhongShanSMSService.ZhongShangSendSMS(username,"您好,你的手机登录短信验证码是:"+captcha+",5分钟内有效。");
            int result = zhongShanSMSService.ZhongShangSendSMS(username, "您好,你的手机登录短信验证码是:" + captcha + ",5分钟内有效。");
            if (0 == result) {
            if (0 == result) {
@ -784,6 +795,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    /**
    /**
     * 心脏医院短信接口
     * 心脏医院短信接口
     *
     * @param parameters
     * @param parameters
     * @return
     * @return
     * @throws Exception
     * @throws Exception
@ -798,7 +810,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(username)) {
        if (StringUtils.isEmpty(username)) {
            throw new InvalidRequestException("username");
            throw new InvalidRequestException("username");
        }
        }
        if (username.length()>12){
        if (username.length() > 12) {
            throw new InvalidRequestException("请输入正确的手机号!");
            throw new InvalidRequestException("请输入正确的手机号!");
        }
        }
        //验证请求间隔超时,防止频繁获取验证码
        //验证请求间隔超时,防止频繁获取验证码
@ -806,7 +818,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            throw new IllegalAccessException("SMS request frequency is too fast");
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
        if (wlyyHospitalSysDictDO != null && !StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())) {
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            Captcha _captcha = new Captcha();
            Captcha _captcha = new Captcha();
            _captcha.setCode(captcha);
            _captcha.setCode(captcha);
@ -818,23 +830,23 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            headers.set("Cache-Control", "no-store");
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }else {
        } else {
            //发送短信获取验证码
            //发送短信获取验证码
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            JSONObject object = new JSONObject();
            JSONObject object = new JSONObject();
            object.put("operatetel","18788888888");
            object.put("interfaceid","jcpt");
            object.put("interfacepwd","jcpt");
            object.put("operator","xxgwxgzh");
            object.put("operateid","xxgwxgzh");
            object.put("operatetel", "18788888888");
            object.put("interfaceid", "jcpt");
            object.put("interfacepwd", "jcpt");
            object.put("operator", "xxgwxgzh");
            object.put("operateid", "xxgwxgzh");
            JSONArray array = new JSONArray();
            JSONArray array = new JSONArray();
            JSONObject jsonObject = new JSONObject();
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("content","您好,你的手机登录短信验证码是:"+captcha+",5分钟内有效。");
            jsonObject.put("sendtel",username);
            jsonObject.put("sendtime",DateUtil.dateToStrLong(new Date()));
            jsonObject.put("content", "您好,你的手机登录短信验证码是:" + captcha + ",5分钟内有效。");
            jsonObject.put("sendtel", username);
            jsonObject.put("sendtime", DateUtil.dateToStrLong(new Date()));
            array.add(jsonObject);
            array.add(jsonObject);
            object.put("messageinfo",array);
            int result =  xzzxService.SendSms(object.toJSONString());
            object.put("messageinfo", array);
            int result = xzzxService.SendSms(object.toJSONString());
            if (0 == result) {
            if (0 == result) {
@ -855,6 +867,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    /**
    /**
     * 第三医院短信接口
     * 第三医院短信接口
     *
     * @param parameters
     * @param parameters
     * @return
     * @return
     * @throws Exception
     * @throws Exception
@ -869,7 +882,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(username)) {
        if (StringUtils.isEmpty(username)) {
            throw new InvalidRequestException("username");
            throw new InvalidRequestException("username");
        }
        }
        if (username.length()>12){
        if (username.length() > 12) {
            throw new InvalidRequestException("请输入正确的手机号!");
            throw new InvalidRequestException("请输入正确的手机号!");
        }
        }
        //验证请求间隔超时,防止频繁获取验证码
        //验证请求间隔超时,防止频繁获取验证码
@ -877,7 +890,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            throw new IllegalAccessException("SMS request frequency is too fast");
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
        if (wlyyHospitalSysDictDO != null && !StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())) {
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            Captcha _captcha = new Captcha();
            Captcha _captcha = new Captcha();
            _captcha.setCode(captcha);
            _captcha.setCode(captcha);
@ -889,11 +902,11 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            headers.set("Cache-Control", "no-store");
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }else {
        } else {
            //发送短信获取验证码
            //发送短信获取验证码
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            String content = "您好,你的手机登录短信验证码是:"+captcha+",5分钟内有效。";
            int result =  dsyyService.SendSms(username,content);
            String content = "您好,你的手机登录短信验证码是:" + captcha + ",5分钟内有效。";
            int result = dsyyService.SendSms(username, content);
            if (0 == result) {
            if (0 == result) {
@ -914,6 +927,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    /**
    /**
     * 福州健康之路短信接口
     * 福州健康之路短信接口
     *
     * @param parameters
     * @param parameters
     * @return
     * @return
     * @throws Exception
     * @throws Exception
@ -928,7 +942,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(username)) {
        if (StringUtils.isEmpty(username)) {
            throw new InvalidRequestException("username");
            throw new InvalidRequestException("username");
        }
        }
        if (username.length()>12){
        if (username.length() > 12) {
            throw new InvalidRequestException("请输入正确的手机号!");
            throw new InvalidRequestException("请输入正确的手机号!");
        }
        }
        //验证请求间隔超时,防止频繁获取验证码
        //验证请求间隔超时,防止频繁获取验证码
@ -936,7 +950,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            throw new IllegalAccessException("SMS request frequency is too fast");
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
        if (wlyyHospitalSysDictDO != null && !StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())) {
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            Captcha _captcha = new Captcha();
            Captcha _captcha = new Captcha();
            _captcha.setCode(captcha);
            _captcha.setCode(captcha);
@ -948,10 +962,10 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            headers.set("Cache-Control", "no-store");
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }else {
        } else {
            //发送短信获取验证码
            //发送短信获取验证码
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            int result =  zbSmsService.sendMessage(username,captcha);
            int result = zbSmsService.sendMessage(username, captcha);
            if (0 == result) {
            if (0 == result) {
                Captcha _captcha = new Captcha();
                Captcha _captcha = new Captcha();
                _captcha.setCode(captcha);
                _captcha.setCode(captcha);
@ -971,6 +985,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    /**
    /**
     * 腾讯云短信接口
     * 腾讯云短信接口
     *
     * @param parameters
     * @param parameters
     * @return
     * @return
     * @throws Exception
     * @throws Exception
@ -985,7 +1000,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(username)) {
        if (StringUtils.isEmpty(username)) {
            throw new InvalidRequestException("username");
            throw new InvalidRequestException("username");
        }
        }
        if (username.length()>12){
        if (username.length() > 12) {
            throw new InvalidRequestException("请输入正确的手机号!");
            throw new InvalidRequestException("请输入正确的手机号!");
        }
        }
        //验证请求间隔超时,防止频繁获取验证码
        //验证请求间隔超时,防止频繁获取验证码
@ -993,7 +1008,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            throw new IllegalAccessException("SMS request frequency is too fast");
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
        if (wlyyHospitalSysDictDO != null && !StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())) {
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            Captcha _captcha = new Captcha();
            Captcha _captcha = new Captcha();
            _captcha.setCode(captcha);
            _captcha.setCode(captcha);
@ -1005,21 +1020,21 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            headers.set("Cache-Control", "no-store");
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }else {
        } else {
            //发送短信获取验证码
            //发送短信获取验证码
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            SmsDO smsDO = new SmsDO();
            SmsDO smsDO = new SmsDO();
            smsDO.setCaptcha(captcha);
            smsDO.setCaptcha(captcha);
            smsDO.setClientId(client_id);
            smsDO.setClientId(client_id);
            smsDO.setContent("您好,你的手机登录短信验证码是:"+captcha+",5分钟内有效。");
            smsDO.setContent("您好,你的手机登录短信验证码是:" + captcha + ",5分钟内有效。");
            smsDO.setMobile(username);
            smsDO.setMobile(username);
            smsDO.setDeadline(DateUtil.getNextMin(new Date(),5));
            smsDO.setDeadline(DateUtil.getNextMin(new Date(), 5));
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            smsDO.setRequestIp(NetworkUtil.getIpAddress(request));
            smsDO.setRequestIp(NetworkUtil.getIpAddress(request));
            smsDO.setCreateTime(new Date());
            smsDO.setCreateTime(new Date());
            baseSmsDao.save(smsDO);
            baseSmsDao.save(smsDO);
            //
            //
            String result =  txySmsService.sendMessage(username,captcha);
            String result = txySmsService.sendMessage(username, captcha);
            if ("Ok".equals(result)) {
            if ("Ok".equals(result)) {
                Captcha _captcha = new Captcha();
                Captcha _captcha = new Captcha();
                _captcha.setCode(captcha);
                _captcha.setCode(captcha);
@ -1046,7 +1061,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(username)) {
        if (StringUtils.isEmpty(username)) {
            throw new InvalidRequestException("username");
            throw new InvalidRequestException("username");
        }
        }
        if (username.length()>12){
        if (username.length() > 12) {
            throw new InvalidRequestException("请输入正确的手机号!");
            throw new InvalidRequestException("请输入正确的手机号!");
        }
        }
        //验证请求间隔超时,防止频繁获取验证码
        //验证请求间隔超时,防止频繁获取验证码
@ -1054,7 +1069,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            throw new IllegalAccessException("SMS request frequency is too fast");
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
        if (wlyyHospitalSysDictDO != null && !StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())) {
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            Captcha _captcha = new Captcha();
            Captcha _captcha = new Captcha();
            _captcha.setCode(captcha);
            _captcha.setCode(captcha);
@ -1066,21 +1081,21 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            headers.set("Cache-Control", "no-store");
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }else {
        } else {
            //发送短信获取验证码
            //发送短信获取验证码
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            SmsDO smsDO = new SmsDO();
            SmsDO smsDO = new SmsDO();
            smsDO.setCaptcha(captcha);
            smsDO.setCaptcha(captcha);
            smsDO.setClientId(client_id);
            smsDO.setClientId(client_id);
            smsDO.setContent("您好,你的手机登录短信验证码是:"+captcha+",5分钟内有效。");
            smsDO.setContent("您好,你的手机登录短信验证码是:" + captcha + ",5分钟内有效。");
            smsDO.setMobile(username);
            smsDO.setMobile(username);
            smsDO.setDeadline(DateUtil.getNextMin(new Date(),5));
            smsDO.setDeadline(DateUtil.getNextMin(new Date(), 5));
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            smsDO.setRequestIp(NetworkUtil.getIpAddress(request));
            smsDO.setRequestIp(NetworkUtil.getIpAddress(request));
            smsDO.setCreateTime(new Date());
            smsDO.setCreateTime(new Date());
            baseSmsDao.save(smsDO);
            baseSmsDao.save(smsDO);
            //
            //
            String result =  txySmsService.sendMessage(username,captcha);
            String result = txySmsService.sendMessage(username, captcha);
            if ("Ok".equals(result)) {
            if ("Ok".equals(result)) {
                Captcha _captcha = new Captcha();
                Captcha _captcha = new Captcha();
                _captcha.setCode(captcha);
                _captcha.setCode(captcha);
@ -1102,24 +1117,24 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        String wxId = parameters.get("wxId");
        String wxId = parameters.get("wxId");
        String key = parameters.get("key");
        String key = parameters.get("key");
        String text = parameters.get("text");
        String text = parameters.get("text");
        if(org.apache.commons.lang3.StringUtils.isNotBlank(key)&& org.apache.commons.lang3.StringUtils.isNotBlank(text)){
            if(!verifyCaptcha(key,text)){
        if (org.apache.commons.lang3.StringUtils.isNotBlank(key) && org.apache.commons.lang3.StringUtils.isNotBlank(text)) {
            if (!verifyCaptcha(key, text)) {
                throw new ImgCaptchaException("img_captcha error");
                throw new ImgCaptchaException("img_captcha error");
            }
            }
        }
        }
        if("xm_ykyy_wx".equals(wxId)){
           return sendYKCaptcha(parameters);
        }else if("xm_zsyy_wx".equals(wxId)){
           return sendZSCaptcha(parameters);
        }else if ("xm_xzzx_wx".equals(wxId)){
        if ("xm_ykyy_wx".equals(wxId)) {
            return sendYKCaptcha(parameters);
        } else if ("xm_zsyy_wx".equals(wxId)) {
            return sendZSCaptcha(parameters);
        } else if ("xm_xzzx_wx".equals(wxId)) {
            return sendXZCaptcha(parameters);
            return sendXZCaptcha(parameters);
        }else if ("sd_tnzyy_wx".equals(wxId)){
        } else if ("sd_tnzyy_wx".equals(wxId)) {
            return sendZBCaptcha(parameters);
            return sendZBCaptcha(parameters);
        }else if ("xm_dsyy_wx".equals(wxId)){
        } else if ("xm_dsyy_wx".equals(wxId)) {
            return sendDsyyCaptcha(parameters);
            return sendDsyyCaptcha(parameters);
        }else if("hz_yyyzh_wx".equals(wxId)){
        } else if ("hz_yyyzh_wx".equals(wxId)) {
            return sendTXYCaptcha(parameters);
            return sendTXYCaptcha(parameters);
        }else if("xm_mlwyy_wx".equals(wxId)){
        } else if ("xm_mlwyy_wx".equals(wxId)) {
            return sendMlwCaptcha(parameters);
            return sendMlwCaptcha(parameters);
        }
        }
        throw new IllegalStateException("验证码发送失败");
        throw new IllegalStateException("验证码发送失败");
@ -1132,20 +1147,20 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        String username = parameters.get("username");
        String username = parameters.get("username");
        String type = parameters.get("type");
        String type = parameters.get("type");
        String isDoctor = parameters.get("isDoctor");
        String isDoctor = parameters.get("isDoctor");
        String msg="";
        String msg = "";
        if (StringUtils.isEmpty(client_id)) {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
            throw new InvalidRequestException("client_id");
        }
        }
        if (StringUtils.isEmpty(username)) {
        if (StringUtils.isEmpty(username)) {
            throw new InvalidRequestException("username");
            throw new InvalidRequestException("username");
        }
        }
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
            String geetestChallenge = parameters.get("geetestChallenge");
            String geetestChallenge = parameters.get("geetestChallenge");
            String geetestValidate = parameters.get("geetestValidate");
            String geetestValidate = parameters.get("geetestValidate");
            String geetestSeccode = parameters.get("geetestSeccode");
            String geetestSeccode = parameters.get("geetestSeccode");
            JSONObject resResult =validateGeet(geetestChallenge,geetestValidate,geetestSeccode,"1".equalsIgnoreCase(isDoctor)?"2":"1");
            if (resResult==null||!resResult.getString("result").equalsIgnoreCase("success")){
                throw new  Exception("验证失败");
            JSONObject resResult = validateGeet(geetestChallenge, geetestValidate, geetestSeccode, "1".equalsIgnoreCase(isDoctor) ? "2" : "1");
            if (resResult == null || !resResult.getString("result").equalsIgnoreCase("success")) {
                throw new Exception("验证失败");
            }
            }
        }
        }
        //验证请求间隔超时,防止频繁获取验证码
        //验证请求间隔超时,防止频繁获取验证码
@ -1153,7 +1168,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            throw new IllegalAccessException("SMS request frequency is too fast");
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
        if (wlyyHospitalSysDictDO != null && !StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())) {
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            Captcha _captcha = new Captcha();
            Captcha _captcha = new Captcha();
            _captcha.setCode(captcha);
            _captcha.setCode(captcha);
@ -1165,14 +1180,14 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            headers.set("Cache-Control", "no-store");
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }else {
            if ("1".equalsIgnoreCase(isDoctor)){
                String res = ykyyService.getResetCode("4",username);
                String resltCode ="";
        } else {
            if ("1".equalsIgnoreCase(isDoctor)) {
                String res = ykyyService.getResetCode("4", username);
                String resltCode = "";
                String captcha = "";
                String captcha = "";
                if (!StringUtils.isEmpty(res)){
                if (!StringUtils.isEmpty(res)) {
                    JSONObject jsonObject = JSONObject.parseObject(res);
                    JSONObject jsonObject = JSONObject.parseObject(res);
                    if ("10000".equalsIgnoreCase(jsonObject.getString("code"))){
                    if ("10000".equalsIgnoreCase(jsonObject.getString("code"))) {
                        captcha = jsonObject.getString("value");
                        captcha = jsonObject.getString("value");
                        resltCode = jsonObject.getString("code");
                        resltCode = jsonObject.getString("code");
                        msg = "发送成功";
                        msg = "发送成功";
@ -1193,25 +1208,25 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                }
                }
                throw new IllegalStateException("验证码发送失败!");
                throw new IllegalStateException("验证码发送失败!");
            }else {
            } else {
                //发送短信获取验证码
                //发送短信获取验证码
                String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
                String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
                ResultMsg result= null;
                if(StringUtils.isEmpty(type)){
                    String  res = ykyyService.getShortMessage("1",username);
                    String resltCode ="";
                ResultMsg result = null;
                if (StringUtils.isEmpty(type)) {
                    String res = ykyyService.getShortMessage("1", username);
                    String resltCode = "";
                    String captcha1 = "";
                    String captcha1 = "";
                    if (!StringUtils.isEmpty(res)){
                    if (!StringUtils.isEmpty(res)) {
                        JSONObject jsonObject = JSONObject.parseObject(res);
                        JSONObject jsonObject = JSONObject.parseObject(res);
                        if ("10000".equalsIgnoreCase(jsonObject.getString("code"))){
                        if ("10000".equalsIgnoreCase(jsonObject.getString("code"))) {
                            captcha1 = jsonObject.getString("value");
                            captcha1 = jsonObject.getString("value");
                            resltCode = jsonObject.getString("code");
                            resltCode = jsonObject.getString("code");
                        }else if("199".equalsIgnoreCase(jsonObject.getString("code"))){
                        } else if ("199".equalsIgnoreCase(jsonObject.getString("code"))) {
                            msg = jsonObject.getString("msg");
                            msg = jsonObject.getString("msg");
                            Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>(msg, 199);
                            Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>(msg, 199);
                            return new ResponseEntity<>(oauth2Envelop, HttpStatus.OK);
                            return new ResponseEntity<>(oauth2Envelop, HttpStatus.OK);
                        }else {
                            msg="发送失败";
                        } else {
                            msg = "发送失败";
                            Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>(msg, -1);
                            Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>(msg, -1);
                            return new ResponseEntity<>(oauth2Envelop, HttpStatus.OK);
                            return new ResponseEntity<>(oauth2Envelop, HttpStatus.OK);
                        }
                        }
@ -1229,9 +1244,9 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                        headers.set("Pragma", "no-cache");
                        headers.set("Pragma", "no-cache");
                        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
                        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
                    }
                    }
                }else if("1".equals(type)){
                    result = ykyyINSMSService.ykyySendSMS(username,"您好,您的手机登录短信验证码是:"+captcha+",5分钟内有效。");
                }else if("2".equals(type)) {
                } else if ("1".equals(type)) {
                    result = ykyyINSMSService.ykyySendSMS(username, "您好,您的手机登录短信验证码是:" + captcha + ",5分钟内有效。");
                } else if ("2".equals(type)) {
                    result = ykyyINSMSService.ykyySendSMS(username, "您好,您正在进行找回密码操作,您的短信验证码是:" + captcha + ",请勿将验证码告诉他人,5分钟内有效。");
                    result = ykyyINSMSService.ykyySendSMS(username, "您好,您正在进行找回密码操作,您的短信验证码是:" + captcha + ",请勿将验证码告诉他人,5分钟内有效。");
                }
                }
                if (result.isSuccess()) {
                if (result.isSuccess()) {
@ -1351,7 +1366,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            在网关处通过HTTP状态码告知前端是过期 还是账号在别处登陆
            在网关处通过HTTP状态码告知前端是过期 还是账号在别处登陆
            实现同一账号只能在一处登陆*/
            实现同一账号只能在一处登陆*/
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
            if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile") || request.getHeader("login-device").equalsIgnoreCase("pc"))) {
                tokenStore.removeAccessToken(token.getValue());
                tokenStore.removeAccessToken(token.getValue());
                tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
                tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
                token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
                token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
@ -1437,7 +1452,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            return handleOAuth2Exception(new Oauth2Envelop("短信请求频率过快,请稍后再试!", -1), e);
            return handleOAuth2Exception(new Oauth2Envelop("短信请求频率过快,请稍后再试!", -1), e);
        } else if (e instanceof IllegalStateException) {
        } else if (e instanceof IllegalStateException) {
            return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), -1), e);
            return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), -1), e);
        }else if (e instanceof ImgCaptchaException) {
        } else if (e instanceof ImgCaptchaException) {
            return handleOAuth2Exception(new Oauth2Envelop("图片验证码错误", ResultStatus.IMG_CAPTCHA), e);
            return handleOAuth2Exception(new Oauth2Envelop("图片验证码错误", ResultStatus.IMG_CAPTCHA), e);
        }
        }
        return handleOAuth2Exception(new Oauth2Envelop("请求失败", -1), e);
        return handleOAuth2Exception(new Oauth2Envelop("请求失败", -1), e);
@ -1466,10 +1481,10 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    }
    }
    @RequestMapping(value = "/oauth/getHwlyyPublicKey", method = RequestMethod.GET)
    @RequestMapping(value = "/oauth/getHwlyyPublicKey", method = RequestMethod.GET)
    public ObjEnvelop getHwlyyPublicKey(){
    public ObjEnvelop getHwlyyPublicKey() {
        OauthKeypairDO keypairDO = oauthKeypairDao.findByCode("hwlyyKey");
        OauthKeypairDO keypairDO = oauthKeypairDao.findByCode("hwlyyKey");
        if(keypairDO==null){
        if (keypairDO == null) {
            KeyPair keyPair = com.yihu.jw.security.utils.RSAUtils.getKey();
            KeyPair keyPair = com.yihu.jw.security.utils.RSAUtils.getKey();
            byte[] bytekey = SerializeUtil.ObjTOSerialize(keyPair);
            byte[] bytekey = SerializeUtil.ObjTOSerialize(keyPair);
            OauthKeypairDO kpDO = new OauthKeypairDO();
            OauthKeypairDO kpDO = new OauthKeypairDO();
@ -1477,60 +1492,60 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            kpDO.setKeyPair(bytekey);
            kpDO.setKeyPair(bytekey);
            keypairDO = oauthKeypairDao.save(kpDO);
            keypairDO = oauthKeypairDao.save(kpDO);
        }
        }
        KeyPair key = (KeyPair)SerializeUtil.unSerialize(keypairDO.getKeyPair());
        KeyPair key = (KeyPair) SerializeUtil.unSerialize(keypairDO.getKeyPair());
        PublickeyVO pk = new PublickeyVO();
        PublickeyVO pk = new PublickeyVO();
        pk.setPublicKey(com.yihu.jw.security.utils.RSAUtils.generateBase64PublicKey(key));
        pk.setPublicKey(com.yihu.jw.security.utils.RSAUtils.generateBase64PublicKey(key));
        return ObjEnvelop.getSuccess("success", pk);
        return ObjEnvelop.getSuccess("success", pk);
    }
    }
    @RequestMapping(value = "/oauth/getHwlyyDecrypt", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/getHwlyyDecrypt", method = RequestMethod.POST)
    public ObjEnvelop getHwlyyDecrypt(String openid,String idcard,String wechatId,String code){
        Map<String,Object> rs = new HashedMap();
        try{
    public ObjEnvelop getHwlyyDecrypt(String openid, String idcard, String wechatId, String code) {
        Map<String, Object> rs = new HashedMap();
        try {
            OauthKeypairDO keypairDO = oauthKeypairDao.findByCode("hwlyyKey");
            OauthKeypairDO keypairDO = oauthKeypairDao.findByCode("hwlyyKey");
            KeyPair keyPair = (KeyPair)SerializeUtil.unSerialize(keypairDO.getKeyPair());
            logger.info("keyPair : "+keyPair.getPublic().toString());
            KeyPair keyPair = (KeyPair) SerializeUtil.unSerialize(keypairDO.getKeyPair());
            logger.info("keyPair : " + keyPair.getPublic().toString());
            //解密idcard,中山医院id通过openid获取,i健康通过直接加密传输
            //解密idcard,中山医院id通过openid获取,i健康通过直接加密传输
            if(org.apache.commons.lang3.StringUtils.isNotBlank(idcard)){
                rs.put("idcard",com.yihu.jw.security.utils.RSAUtils.decryptBase64(idcard, keyPair));
            }else {
                rs.put("idcard",idcard);
            if (org.apache.commons.lang3.StringUtils.isNotBlank(idcard)) {
                rs.put("idcard", com.yihu.jw.security.utils.RSAUtils.decryptBase64(idcard, keyPair));
            } else {
                rs.put("idcard", idcard);
            }
            }
            logger.info("参数 code : "+code);
            logger.info("参数 code : " + code);
            //解析code
            //解析code
            if(org.apache.commons.lang3.StringUtils.isNotBlank(code)){
                logger.info("解析前code : "+code);
            if (org.apache.commons.lang3.StringUtils.isNotBlank(code)) {
                logger.info("解析前code : " + code);
                String c = com.yihu.jw.security.utils.RSAUtils.decryptBase64(code, keyPair);
                String c = com.yihu.jw.security.utils.RSAUtils.decryptBase64(code, keyPair);
                logger.info("解析前code : "+c);
                rs.put("code",c);
            }else {
                rs.put("code",code);
                logger.info("解析前code : " + c);
                rs.put("code", c);
            } else {
                rs.put("code", code);
            }
            }
            //解密wechatId
            //解密wechatId
            if(org.apache.commons.lang3.StringUtils.isNotBlank(wechatId)){
                String wxid =com.yihu.jw.security.utils.RSAUtils.decryptBase64(wechatId, keyPair);
                rs.put("wechatId",wxid);
            if (org.apache.commons.lang3.StringUtils.isNotBlank(wechatId)) {
                String wxid = com.yihu.jw.security.utils.RSAUtils.decryptBase64(wechatId, keyPair);
                rs.put("wechatId", wxid);
                //解密openid
                //解密openid
                if(org.apache.commons.lang3.StringUtils.isNotBlank(openid)){
                if (org.apache.commons.lang3.StringUtils.isNotBlank(openid)) {
                    String opid = com.yihu.jw.security.utils.RSAUtils.decryptBase64(openid, keyPair);
                    String opid = com.yihu.jw.security.utils.RSAUtils.decryptBase64(openid, keyPair);
                    rs.put("openid",opid);
                    if("xm_zsyy_wx".equals(wxid)){
                        JSONObject patient =  userDetailsService.getHLWyyUser(opid);
                        rs.put("idcard",patient.getString("idcard"));
                        rs.put("mobile",patient.getString("mobile"));
                    rs.put("openid", opid);
                    if ("xm_zsyy_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);
                } else {
                    rs.put("openid", openid);
                }
                }
            }else {
                rs.put("wechatId",wechatId);
            } else {
                rs.put("wechatId", wechatId);
            }
            }
        }catch (Exception e){
        } catch (Exception e) {
            logger.error(e);
            logger.error(e);
        }
        }
        return ObjEnvelop.getSuccess("success", rs);
        return ObjEnvelop.getSuccess("success", rs);
@ -1538,34 +1553,35 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    /**
    /**
     * 卫健委授权登录
     * 卫健委授权登录
     *
     * @param authCode
     * @param authCode
     * @param client_id
     * @param client_id
     * @return
     * @return
     */
     */
    @RequestMapping(value = "/oauth/wjwLogin", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/wjwLogin", method = RequestMethod.POST)
    public ObjEnvelop getWjwDecrypt(String authCode,String client_id) {
    public ObjEnvelop getWjwDecrypt(String authCode, String client_id) {
        if (StringUtils.isEmpty(client_id)) {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
            throw new InvalidRequestException("client_id is null");
        }
        }
        try {
        try {
            logger.info("authCode :"+authCode);
            logger.info("authCode :" + authCode);
            String str = URLDecoder.decode(authCode,"UTF-8");
            logger.info("base64 :"+str);
            String str = URLDecoder.decode(authCode, "UTF-8");
            logger.info("base64 :" + str);
            String data = new String(Base64Utils.decode((str.getBytes())));
            String data = new String(Base64Utils.decode((str.getBytes())));
            //固定秘钥解密
            //固定秘钥解密
            String key = "FEA5049E4CCD16A9";
            String key = "FEA5049E4CCD16A9";
            String result = AesEncryptUtils.decrypt(data,key);
          /*  String result = AES.decrypt(key,data);*/
            logger.info("wjwLogin :"+result);
            String result = AesEncryptUtils.decrypt(data, key);
            /*  String result = AES.decrypt(key,data);*/
            logger.info("wjwLogin :" + result);
            BasePatientDO patientDO = oauthWjwConfigService.savePatient(result);
            BasePatientDO patientDO = oauthWjwConfigService.savePatient(result);
            logger.info("授权进来1");
            logger.info("授权进来1");
            if(patientDO == null){
            if (patientDO == null) {
                return ObjEnvelop.getError("授权登录失败!");
                return ObjEnvelop.getError("授权登录失败!");
            }
            }
@ -1575,7 +1591,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            logger.info("授权进来3");
            logger.info("授权进来3");
            Map<String, String> parameters = new HashedMap();
            Map<String, String> parameters = new HashedMap();
            parameters.put("username",patientDO.getIdcard());
            parameters.put("username", patientDO.getIdcard());
            parameters.put("grant_type", "ihealthCode");
            parameters.put("grant_type", "ihealthCode");
            TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
            TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
@ -1605,9 +1621,9 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            baseLoginLogDO.setLoginType(loginType);
            baseLoginLogDO.setLoginType(loginType);
            baseLoginLogService.save(baseLoginLogDO);
            baseLoginLogService.save(baseLoginLogDO);
            return ObjEnvelop.getSuccess("success",wlyyUserSimple);
            return ObjEnvelop.getSuccess("success", wlyyUserSimple);
        }catch (Exception e){
        } catch (Exception e) {
            logger.error(e);
            logger.error(e);
        }
        }
        return ObjEnvelop.getError("登录失败!");
        return ObjEnvelop.getError("登录失败!");
@ -1616,28 +1632,29 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    /**
    /**
     * 医联康护授权登录
     * 医联康护授权登录
     *
     * @param authCode
     * @param authCode
     * @param client_id
     * @param client_id
     * @return
     * @return
     */
     */
    @RequestMapping(value = "/oauth/ylkhLogin", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/ylkhLogin", method = RequestMethod.POST)
    public ObjEnvelop getYlkhDecrypt(String authCode,String client_id) {
    public ObjEnvelop getYlkhDecrypt(String authCode, String client_id) {
        if (StringUtils.isEmpty(client_id)) {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
            throw new InvalidRequestException("client_id is null");
        }
        }
        try {
        try {
            logger.info("authCode :"+authCode);
            logger.info("authCode :" + authCode);
            //固定秘钥解密
            //固定秘钥解密
            String key = "46A61629A19AE04C";
            String key = "46A61629A19AE04C";
            String result = AesEncryptUtils.decrypt(authCode,key);
            logger.info("wjwLogin :"+result);
            String result = AesEncryptUtils.decrypt(authCode, key);
            logger.info("wjwLogin :" + result);
            BasePatientDO patientDO = oauthWjwConfigService.savePatient(result);
            BasePatientDO patientDO = oauthWjwConfigService.savePatient(result);
            if(patientDO == null){
            if (patientDO == null) {
                return ObjEnvelop.getError("授权登录失败!");
                return ObjEnvelop.getError("授权登录失败!");
            }
            }
@ -1645,9 +1662,9 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            Map<String, String> parameters = new HashedMap();
            Map<String, String> parameters = new HashedMap();
            parameters.put("username",patientDO.getIdcard());
            parameters.put("username", patientDO.getIdcard());
            parameters.put("grant_type", "ihealthCode");
            parameters.put("grant_type", "ihealthCode");
            parameters.put("login_type","4");
            parameters.put("login_type", "4");
            TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
            TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
            if (authenticatedClient != null) {
            if (authenticatedClient != null) {
@ -1676,9 +1693,9 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            baseLoginLogDO.setLoginType(loginType);
            baseLoginLogDO.setLoginType(loginType);
            baseLoginLogService.save(baseLoginLogDO);
            baseLoginLogService.save(baseLoginLogDO);
            return ObjEnvelop.getSuccess("success",wlyyUserSimple);
            return ObjEnvelop.getSuccess("success", wlyyUserSimple);
        }catch (Exception e){
        } catch (Exception e) {
            logger.error(e);
            logger.error(e);
        }
        }
        return ObjEnvelop.getError("登录失败!");
        return ObjEnvelop.getError("登录失败!");
@ -1695,20 +1712,20 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
//    }
//    }
    @RequestMapping(value = "/oauth/getCaQRCode", method = RequestMethod.GET)
    @RequestMapping(value = "/oauth/getCaQRCode", method = RequestMethod.GET)
    public ObjEnvelop getCaQRCode(HttpServletRequest request){
    public ObjEnvelop getCaQRCode(HttpServletRequest request) {
        logger.info("/oauth/getCaQRCode");
        logger.info("/oauth/getCaQRCode");
        if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
            String sys ="JKZLHLWYLJKGLPT";
        if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
            String sys = "JKZLHLWYLJKGLPT";
            return ObjEnvelop.getSuccess("success", oauthCaConfigSerivce.getQRCode(sys));
            return ObjEnvelop.getSuccess("success", oauthCaConfigSerivce.getQRCode(sys));
        }else if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
        } else if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
            return ObjEnvelop.getSuccess("success", xzzxService.getQRCode());
            return ObjEnvelop.getSuccess("success", xzzxService.getQRCode());
        }else if (wechatId.equalsIgnoreCase("xm_ykyy_wx")){
        } else if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
            return ObjEnvelop.getSuccess("success", ykyyService.getQRCode());
            return ObjEnvelop.getSuccess("success", ykyyService.getQRCode());
        }else if (wechatId.equalsIgnoreCase("xm_hcyy_wx")){
        } else if (wechatId.equalsIgnoreCase("xm_hcyy_wx")) {
            return ObjEnvelop.getSuccess("success", hcyyService.getQRCode(getIpAddress(request)));
            return ObjEnvelop.getSuccess("success", hcyyService.getQRCode(getIpAddress(request)));
        }else if (wechatId.equalsIgnoreCase("xm_dsyy_wx")){
        } else if (wechatId.equalsIgnoreCase("xm_dsyy_wx")) {
            return ObjEnvelop.getSuccess("success", dsyyService.getQRCode());
            return ObjEnvelop.getSuccess("success", dsyyService.getQRCode());
        }else {
        } else {
            return ObjEnvelop.getSuccess("success", null);
            return ObjEnvelop.getSuccess("success", null);
        }
        }
@ -1716,88 +1733,89 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    /**
    /**
     * 医生二维码登录
     * 医生二维码登录
     *
     * @param qrcode
     * @param qrcode
     * @param client_id
     * @param client_id
     * @param login_type 2
     * @param login_type 2
     * @return
     * @return
     */
     */
    @RequestMapping(value = "/oauth/checkCaQRCodeLogin", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/checkCaQRCodeLogin", method = RequestMethod.POST)
    public ObjEnvelop checkCaQRCodeLogin(String qrcode,String client_id,String login_type,HttpServletRequest request){
    public ObjEnvelop checkCaQRCodeLogin(String qrcode, String client_id, String login_type, HttpServletRequest request) {
        if (StringUtils.isEmpty(client_id)) {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
            throw new InvalidRequestException("client_id is null");
        }
        }
        String username = null;
        String username = null;
        String openId= null;
        String openId = null;
        JSONObject rs = new JSONObject();
        JSONObject rs = new JSONObject();
        if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
        if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
            rs = oauthCaConfigSerivce.getQueryQRCode(qrcode);
            rs = oauthCaConfigSerivce.getQueryQRCode(qrcode);
            JSONObject data = rs.getJSONObject("data");
            JSONObject data = rs.getJSONObject("data");
            String qrCodeStatus = data.getString("qrCodeStatus");
            String qrCodeStatus = data.getString("qrCodeStatus");
            if(!"LoginQrCodeBeenScan".equals(qrCodeStatus)){
                return ObjEnvelop.getSuccess("error",rs);
            if (!"LoginQrCodeBeenScan".equals(qrCodeStatus)) {
                return ObjEnvelop.getSuccess("error", rs);
            }
            }
            username = data.getString("userIdCardNum");
            username = data.getString("userIdCardNum");
        }else if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
        } else if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
            rs = xzzxService.getTokeninfo(qrcode);
            rs = xzzxService.getTokeninfo(qrcode);
            JSONObject jsonObject = rs.getJSONObject("data");
            JSONObject jsonObject = rs.getJSONObject("data");
            logger.info("查询登录信息"+rs);
            logger.info("查询登录信息" + rs);
            String qrCodeStatus = rs.getString("status");
            String qrCodeStatus = rs.getString("status");
            if(!"0".equals(qrCodeStatus)){
                return ObjEnvelop.getSuccess("error",rs);
            if (!"0".equals(qrCodeStatus)) {
                return ObjEnvelop.getSuccess("error", rs);
            }
            }
            username = jsonObject.getString("userIdcardNum");
            username = jsonObject.getString("userIdcardNum");
            openId = jsonObject.getString("uniqueid");
            openId = jsonObject.getString("uniqueid");
            jsonObject.put("qrCodeStatus","LoginQrCodeBeenScan");
            rs.put("code",1000);
        }else if (wechatId.equalsIgnoreCase("xm_dsyy_wx")){
            jsonObject.put("qrCodeStatus", "LoginQrCodeBeenScan");
            rs.put("code", 1000);
        } else if (wechatId.equalsIgnoreCase("xm_dsyy_wx")) {
            rs = dsyyService.getTokeninfo(qrcode);
            rs = dsyyService.getTokeninfo(qrcode);
            JSONObject jsonObject = rs.getJSONObject("data");
            JSONObject jsonObject = rs.getJSONObject("data");
            logger.info("查询登录信息"+rs);
            logger.info("查询登录信息" + rs);
            String qrCodeStatus = rs.getString("status");
            String qrCodeStatus = rs.getString("status");
            if(!"0".equals(qrCodeStatus)){
                return ObjEnvelop.getSuccess("error",rs);
            if (!"0".equals(qrCodeStatus)) {
                return ObjEnvelop.getSuccess("error", rs);
            }
            }
            username = jsonObject.getString("userIdcardNum");
            username = jsonObject.getString("userIdcardNum");
            openId = jsonObject.getString("openId");
            openId = jsonObject.getString("openId");
            jsonObject.put("qrCodeStatus","LoginQrCodeBeenScan");
            rs.put("code",1000);
        }else if (wechatId.equalsIgnoreCase("xm_ykyy_wx")){
            jsonObject.put("qrCodeStatus", "LoginQrCodeBeenScan");
            rs.put("code", 1000);
        } else if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
            rs = ykyyService.getTokeninfo(qrcode);
            rs = ykyyService.getTokeninfo(qrcode);
            JSONObject jsonObject = rs.getJSONObject("data");
            JSONObject jsonObject = rs.getJSONObject("data");
            logger.info("查询登录信息"+rs);
            logger.info("查询登录信息" + rs);
            String qrCodeStatus = rs.getString("code");
            String qrCodeStatus = rs.getString("code");
            if(!"200".equalsIgnoreCase(qrCodeStatus)){
                return ObjEnvelop.getSuccess("error",rs);
            if (!"200".equalsIgnoreCase(qrCodeStatus)) {
                return ObjEnvelop.getSuccess("error", rs);
            }
            }
            if(!"LoginQrCodeBeenScan".equalsIgnoreCase(jsonObject.getString("qrCodeStatus"))){
                return ObjEnvelop.getSuccess("error",rs);
            if (!"LoginQrCodeBeenScan".equalsIgnoreCase(jsonObject.getString("qrCodeStatus"))) {
                return ObjEnvelop.getSuccess("error", rs);
            }
            }
            username = jsonObject.getString("userIdCardNum");
            username = jsonObject.getString("userIdCardNum");
            openId = jsonObject.getString("userJobNum");
            openId = jsonObject.getString("userJobNum");
            jsonObject.put("qrCodeStatus",jsonObject.getString("qrCodeStatus"));
            rs.put("code",1000);
        }else if (wechatId.equalsIgnoreCase("xm_hcyy_wx")){
            jsonObject.put("qrCodeStatus", jsonObject.getString("qrCodeStatus"));
            rs.put("code", 1000);
        } else if (wechatId.equalsIgnoreCase("xm_hcyy_wx")) {
            String ip = getIpAddress(request);
            String ip = getIpAddress(request);
            rs = hcyyService.getTokeninfo(qrcode,ip);
            if (rs.getString("data")==null||rs.getString("data")==""){
                return ObjEnvelop.getSuccess("error",rs);
            rs = hcyyService.getTokeninfo(qrcode, ip);
            if (rs.getString("data") == null || rs.getString("data") == "") {
                return ObjEnvelop.getSuccess("error", rs);
            }
            }
            JSONObject jsonObject = rs.getJSONObject("data");
            JSONObject jsonObject = rs.getJSONObject("data");
            logger.info("查询登录信息"+rs);
            logger.info("查询登录信息" + rs);
            String qrCodeStatus = rs.getString("code");
            String qrCodeStatus = rs.getString("code");
            if(!"10000".equalsIgnoreCase(qrCodeStatus)){
                return ObjEnvelop.getSuccess("error",rs);
            if (!"10000".equalsIgnoreCase(qrCodeStatus)) {
                return ObjEnvelop.getSuccess("error", rs);
            }
            }
            if (jsonObject==null){
                return ObjEnvelop.getSuccess("error",rs);
            if (jsonObject == null) {
                return ObjEnvelop.getSuccess("error", rs);
            }
            }
            username = jsonObject.getString("idcard");
            username = jsonObject.getString("idcard");
            jsonObject.put("qrCodeStatus","LoginQrCodeBeenScan");
            rs.put("code",1000);
            jsonObject.put("qrCodeStatus", "LoginQrCodeBeenScan");
            rs.put("code", 1000);
        }
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(username)){
        if (org.apache.commons.lang.StringUtils.isNotBlank(username)) {
            BaseDoctorDO doctorDO = doctorDao.findByIdcard(username);
            BaseDoctorDO doctorDO = doctorDao.findByIdcard(username);
            doctorDO.setOpenid(openId);
            doctorDO.setOpenid(openId);
            doctorDO.setCaFlag(1);
            doctorDO.setCaFlag(1);
@ -1807,8 +1825,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        Map<String, String> parameters = new HashedMap();
        Map<String, String> parameters = new HashedMap();
        parameters.put("username",username);
        parameters.put("login_type","2");
        parameters.put("username", username);
        parameters.put("login_type", "2");
        parameters.put("grant_type", "ihealthDcotor");
        parameters.put("grant_type", "ihealthDcotor");
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
@ -1836,14 +1854,15 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setLoginType(login_type);
        baseLoginLogDO.setLoginType(login_type);
        baseLoginLogService.save(baseLoginLogDO);
        baseLoginLogService.save(baseLoginLogDO);
        rs.put("WlyyUserSimple",wlyyUserSimple);
        return ObjEnvelop.getSuccess("success",rs);
        rs.put("WlyyUserSimple", wlyyUserSimple);
        return ObjEnvelop.getSuccess("success", rs);
    }
    }
    /**
    /**
     * 获取用户真实IP地址,不使用request.getRemoteAddr();的原因是有可能用户使用了代理软件方式避免真实IP地址。
     * 获取用户真实IP地址,不使用request.getRemoteAddr();的原因是有可能用户使用了代理软件方式避免真实IP地址。
     * 可是,如果通过了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP值,究竟哪个才是真正的用户端的真实IP呢?
     * 可是,如果通过了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP值,究竟哪个才是真正的用户端的真实IP呢?
     * 答案是取X-Forwarded-For中第一个非unknown的有效IP字符串
     * 答案是取X-Forwarded-For中第一个非unknown的有效IP字符串
     *
     * @param request
     * @param request
     * @return
     * @return
     */
     */
@ -1863,29 +1882,29 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        }
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getRemoteAddr();
            ip = request.getRemoteAddr();
            logger.info("ip="+ip);
            if("127.0.0.1".equals(ip)||"0:0:0:0:0:0:0:1".equals(ip)){
            logger.info("ip=" + ip);
            if ("127.0.0.1".equals(ip) || "0:0:0:0:0:0:0:1".equals(ip)) {
                //根据网卡取本机配置的IP
                //根据网卡取本机配置的IP
                InetAddress inet=null;
                InetAddress inet = null;
                try {
                try {
                    inet = InetAddress.getLocalHost();
                    inet = InetAddress.getLocalHost();
                } catch (UnknownHostException e) {
                } catch (UnknownHostException e) {
                    e.printStackTrace();
                    e.printStackTrace();
                }
                }
                ip= inet.getHostAddress();
                ip = inet.getHostAddress();
            }
            }
        }
        }
        return ip;
        return ip;
    }
    }
    @RequestMapping(value = "/oauth/getOauthQRCodeImg", method = RequestMethod.GET)
    @RequestMapping(value = "/oauth/getOauthQRCodeImg", method = RequestMethod.GET)
    public ObjEnvelop getOauthQRCodeImg(){
        try{
            logger.info("/oauth/getOauthQRCodeImg1:"+" startTime:"+ DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss:SSS"));
            Map<String,Object> rs = oauthYlzConfigService.getOauthQRCodeImg();
            logger.info("/oauth/getOauthQRCodeImg2:"+" endTime:"+ DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss:SSS") );
    public ObjEnvelop getOauthQRCodeImg() {
        try {
            logger.info("/oauth/getOauthQRCodeImg1:" + " startTime:" + DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss:SSS"));
            Map<String, Object> rs = oauthYlzConfigService.getOauthQRCodeImg();
            logger.info("/oauth/getOauthQRCodeImg2:" + " endTime:" + DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss:SSS"));
            return ObjEnvelop.getSuccess("success", rs);
            return ObjEnvelop.getSuccess("success", rs);
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return ObjEnvelop.getError("getOauthQRCodeImg error");
            return ObjEnvelop.getError("getOauthQRCodeImg error");
        }
        }
@ -1895,22 +1914,22 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
     * 居民二维码登录
     * 居民二维码登录
     */
     */
    @RequestMapping(value = "/oauth/checkQRCodeLogin", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/checkQRCodeLogin", method = RequestMethod.POST)
    public ObjEnvelop checkQRCodeLogin(String no,String client_id,String login_type){
    public ObjEnvelop checkQRCodeLogin(String no, String client_id, String login_type) {
        if (StringUtils.isEmpty(client_id)) {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
            throw new InvalidRequestException("client_id is null");
        }
        }
        Map<String,Object> map = oauthYlzConfigService.checkOauthQRCode(no);
        String sCode = (String)map.get("sCode");
        if(!"succ".equals(sCode)){
            return ObjEnvelop.getSuccess("error",map);
        Map<String, Object> map = oauthYlzConfigService.checkOauthQRCode(no);
        String sCode = (String) map.get("sCode");
        if (!"succ".equals(sCode)) {
            return ObjEnvelop.getSuccess("error", map);
        }
        }
        BasePatientDO patient = (BasePatientDO)map.get("patient");
        BasePatientDO patient = (BasePatientDO) map.get("patient");
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        Map<String, String> parameters = new HashedMap();
        Map<String, String> parameters = new HashedMap();
        parameters.put("username",patient.getIdcard());
        parameters.put("username", patient.getIdcard());
        parameters.put("grant_type", "ihealthCode");
        parameters.put("grant_type", "ihealthCode");
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
@ -1939,21 +1958,22 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setLoginType(loginType);
        baseLoginLogDO.setLoginType(loginType);
        baseLoginLogService.save(baseLoginLogDO);
        baseLoginLogService.save(baseLoginLogDO);
        map.put("WlyyUserSimple",wlyyUserSimple);
        map.put("WlyyUserSimple", wlyyUserSimple);
        map.remove("patient");
        map.remove("patient");
        return ObjEnvelop.getSuccess("success",map);
        return ObjEnvelop.getSuccess("success", map);
    }
    }
    /**
    /**
     * I健康医生端授权登录
     * I健康医生端授权登录
     * @param code 医生code
     *
     * @param code        医生code
     * @param client_id
     * @param client_id
     * @param login_type 3
     * @param login_type  3
     * @param httpSession
     * @param httpSession
     * @return
     * @return
     */
     */
    @RequestMapping(value = "/oauth/checkWlyyLogin", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/checkWlyyLogin", method = RequestMethod.POST)
    public ObjEnvelop checkQRCodeLogin(String code,String client_id,String login_type,HttpSession httpSession){
    public ObjEnvelop checkQRCodeLogin(String code, String client_id, String login_type, HttpSession httpSession) {
        if (StringUtils.isEmpty(client_id)) {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
            throw new InvalidRequestException("client_id is null");
@ -1961,19 +1981,19 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(code)) {
        if (StringUtils.isEmpty(code)) {
            throw new InvalidRequestException("doctor is null");
            throw new InvalidRequestException("doctor is null");
        }
        }
        logger.info("origin doctorCode :"+code);
        logger.info("origin doctorCode :" + code);
        KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
        KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
        String doctorCode = com.yihu.jw.security.utils.RSAUtils.decryptBase64(code, keyPair);
        String doctorCode = com.yihu.jw.security.utils.RSAUtils.decryptBase64(code, keyPair);
        logger.info("after doctorCode :"+doctorCode);
        logger.info("after doctorCode :" + doctorCode);
        JSONObject map = null;
        JSONObject map = null;
        try{
            map= oauthWlyyConfigService.checkWlyyDoctor(doctorCode);
        }catch (Exception e){
        try {
            map = oauthWlyyConfigService.checkWlyyDoctor(doctorCode);
        } catch (Exception e) {
            logger.error(e);
            logger.error(e);
            return ObjEnvelop.getError("授权失败");
            return ObjEnvelop.getError("授权失败");
        }
        }
        String authCode = map.getString("authCode");
        String authCode = map.getString("authCode");
        if(!"1".equals(authCode)){
        if (!"1".equals(authCode)) {
            map.remove("doctor");
            map.remove("doctor");
            return ObjEnvelop.getError("授权失败");
            return ObjEnvelop.getError("授权失败");
        }
        }
@ -1982,8 +2002,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        JSONObject doctor = map.getJSONObject("doctor");
        JSONObject doctor = map.getJSONObject("doctor");
        Map<String, String> parameters = new HashedMap();
        Map<String, String> parameters = new HashedMap();
        parameters.put("login_type","2");
        parameters.put("username",doctor.getString("idcard"));
        parameters.put("login_type", "2");
        parameters.put("username", doctor.getString("idcard"));
        parameters.put("grant_type", "ihealthDcotor");
        parameters.put("grant_type", "ihealthDcotor");
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
@ -2012,22 +2032,23 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setLoginType(loginType);
        baseLoginLogDO.setLoginType(loginType);
        baseLoginLogService.save(baseLoginLogDO);
        baseLoginLogService.save(baseLoginLogDO);
        map.put("WlyyUserSimple",wlyyUserSimple);
        map.put("WlyyUserSimple", wlyyUserSimple);
        map.remove("doctor");
        map.remove("doctor");
        return ObjEnvelop.getSuccess("success",map);
        return ObjEnvelop.getSuccess("success", map);
    }
    }
    /**
    /**
     * I健康医生端授权登录
     * I健康医生端授权登录
     * @param code 医生code
     *
     * @param code        医生code
     * @param client_id
     * @param client_id
     * @param login_type 3
     * @param login_type  3
     * @param httpSession
     * @param httpSession
     * @return
     * @return
     */
     */
    @RequestMapping(value = "/oauth/checkWlyyUserLogin", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/checkWlyyUserLogin", method = RequestMethod.POST)
    public ObjEnvelop checkQRUserCodeLogin(String code,String client_id,String login_type,HttpSession httpSession){
    public ObjEnvelop checkQRUserCodeLogin(String code, String client_id, String login_type, HttpSession httpSession) {
        if (StringUtils.isEmpty(client_id)) {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
            throw new InvalidRequestException("client_id is null");
@ -2035,19 +2056,19 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(code)) {
        if (StringUtils.isEmpty(code)) {
            throw new InvalidRequestException("doctor is null");
            throw new InvalidRequestException("doctor is null");
        }
        }
        logger.info("origin doctorCode :"+code);
        logger.info("origin doctorCode :" + code);
        KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
        KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
        String doctorCode = com.yihu.jw.security.utils.RSAUtils.decryptBase64(code, keyPair);
        String doctorCode = com.yihu.jw.security.utils.RSAUtils.decryptBase64(code, keyPair);
        logger.info("after doctorCode :"+doctorCode);
        logger.info("after doctorCode :" + doctorCode);
        JSONObject map = null;
        JSONObject map = null;
        try{
            map= oauthWlyyConfigService.checkWlyyUserDoctor(doctorCode);
        }catch (Exception e){
        try {
            map = oauthWlyyConfigService.checkWlyyUserDoctor(doctorCode);
        } catch (Exception e) {
            logger.error(e);
            logger.error(e);
            return ObjEnvelop.getError("授权失败");
            return ObjEnvelop.getError("授权失败");
        }
        }
        String authCode = map.getString("authCode");
        String authCode = map.getString("authCode");
        if(!"1".equals(authCode)){
        if (!"1".equals(authCode)) {
            map.remove("doctor");
            map.remove("doctor");
            return ObjEnvelop.getError("授权失败");
            return ObjEnvelop.getError("授权失败");
        }
        }
@ -2056,8 +2077,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        JSONObject doctor = map.getJSONObject("doctor");
        JSONObject doctor = map.getJSONObject("doctor");
        Map<String, String> parameters = new HashedMap();
        Map<String, String> parameters = new HashedMap();
        parameters.put("login_type","2");
        parameters.put("username",doctor.getString("idcard"));
        parameters.put("login_type", "2");
        parameters.put("username", doctor.getString("idcard"));
        parameters.put("grant_type", "ihealthCode");
        parameters.put("grant_type", "ihealthCode");
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
@ -2086,16 +2107,16 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setLoginType(loginType);
        baseLoginLogDO.setLoginType(loginType);
        baseLoginLogService.save(baseLoginLogDO);
        baseLoginLogService.save(baseLoginLogDO);
        map.put("WlyyUserSimple",wlyyUserSimple);
        map.put("WlyyUserSimple", wlyyUserSimple);
        map.remove("doctor");
        map.remove("doctor");
        return ObjEnvelop.getSuccess("success",map);
        return ObjEnvelop.getSuccess("success", map);
    }
    }
    @RequestMapping(value = "/oauth/imgCaptcha", method = RequestMethod.GET)
    @RequestMapping(value = "/oauth/imgCaptcha", method = RequestMethod.GET)
    @ApiOperation("生成验证码")
    @ApiOperation("生成验证码")
    public ObjEnvelop createCaptcha()throws Exception{
        return ObjEnvelop.getSuccess("success",generateCaptcha());
    public ObjEnvelop createCaptcha() throws Exception {
        return ObjEnvelop.getSuccess("success", generateCaptcha());
    }
    }
    private Map<String, String> generateCaptcha() throws IOException {
    private Map<String, String> generateCaptcha() throws IOException {
@ -2106,7 +2127,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        properties.put("kaptcha.textproducer.font.size", "45");
        properties.put("kaptcha.textproducer.font.size", "45");
        properties.put("kaptcha.textproducer.char.length", "4");
        properties.put("kaptcha.textproducer.char.length", "4");
        properties.put("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
        properties.put("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
        properties.put("kaptcha.textproducer.char.string","0123456789");
        properties.put("kaptcha.textproducer.char.string", "0123456789");
        Config config = new Config(properties);
        Config config = new Config(properties);
        captchaProducer.setConfig(config);
        captchaProducer.setConfig(config);
        String captchaText = captchaProducer.createText();
        String captchaText = captchaProducer.createText();
@ -2114,7 +2135,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ImageIO.write(image, "png", outputStream);
        ImageIO.write(image, "png", outputStream);
        String base64Img = new BASE64Encoder().encode(outputStream.toByteArray());
        String base64Img = new BASE64Encoder().encode(outputStream.toByteArray());
        base64Img = "data:image/jpeg;base64,"+base64Img.replaceAll("\n", "").replaceAll("\r", "");//格式化处理
        base64Img = "data:image/jpeg;base64," + base64Img.replaceAll("\n", "").replaceAll("\r", "");//格式化处理
        String key = "hwlyy:captcha:" + UUID.randomUUID().toString();
        String key = "hwlyy:captcha:" + UUID.randomUUID().toString();
@ -2123,16 +2144,16 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        data.put("image", base64Img);
        data.put("image", base64Img);
        data.put("format", "png");
        data.put("format", "png");
        redisTemplate.opsForValue().set(key,captchaText.toLowerCase(),5, TimeUnit.MINUTES);
        redisTemplate.opsForValue().set(key, captchaText.toLowerCase(), 5, TimeUnit.MINUTES);
        return data;
        return data;
    }
    }
    @RequestMapping(value = "/oauth/verifyCaptcha", method = RequestMethod.GET)
    @RequestMapping(value = "/oauth/verifyCaptcha", method = RequestMethod.GET)
    @ApiOperation("验证图形验证码")
    @ApiOperation("验证图形验证码")
    public boolean verifyCaptcha(String key,String text){
    public boolean verifyCaptcha(String key, String text) {
        boolean pass = false;
        boolean pass = false;
        String captcha = redisTemplate.opsForValue().get(key);
        String captcha = redisTemplate.opsForValue().get(key);
        if (org.apache.commons.lang3.StringUtils.isNotBlank(captcha)&& captcha.equals(text.toLowerCase())){
        if (org.apache.commons.lang3.StringUtils.isNotBlank(captcha) && captcha.equals(text.toLowerCase())) {
            pass = true;
            pass = true;
            redisTemplate.delete(key);
            redisTemplate.delete(key);
        }
        }
@ -2142,20 +2163,20 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    @RequestMapping(value = "/oauth/getSsoPublicKey", method = RequestMethod.GET)
    @RequestMapping(value = "/oauth/getSsoPublicKey", method = RequestMethod.GET)
    @ApiOperation("获取通用公钥")
    @ApiOperation("获取通用公钥")
    public ObjEnvelop getSsoPublicKey(String code,String appId)throws Exception{
        return ObjEnvelop.getSuccess("success",oauthSsoService.getSsoPublic(code,appId));
    public ObjEnvelop getSsoPublicKey(String code, String appId) throws Exception {
        return ObjEnvelop.getSuccess("success", oauthSsoService.getSsoPublic(code, appId));
    }
    }
    @RequestMapping(value = "/oauth/test", method = RequestMethod.GET)
    @RequestMapping(value = "/oauth/test", method = RequestMethod.GET)
    @ApiOperation("test dd")
    @ApiOperation("test dd")
    public ObjEnvelop test()throws Exception{
        return ObjEnvelop.getSuccess("success",oauthSsoService.getAuthCode());
    public ObjEnvelop test() throws Exception {
        return ObjEnvelop.getSuccess("success", oauthSsoService.getAuthCode());
    }
    }
    @RequestMapping(value = "/oauth/ssoPatientLogin", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/ssoPatientLogin", method = RequestMethod.POST)
    public ObjEnvelop ssoPatientLogin(String authCode,String client_id,String code,String appId,String login_type,String openId,String memberId){
    public ObjEnvelop ssoPatientLogin(String authCode, String client_id, String code, String appId, String login_type, String openId, String memberId) {
        if (!wechatId.equalsIgnoreCase("xm_hcyy_wx")){
        if (!wechatId.equalsIgnoreCase("xm_hcyy_wx")) {
            if (StringUtils.isEmpty(client_id)) {
            if (StringUtils.isEmpty(client_id)) {
                throw new InvalidRequestException("client_id is null");
                throw new InvalidRequestException("client_id is null");
            }
            }
@ -2173,26 +2194,26 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        try {
        try {
            Map<String, String> parameters = new HashedMap();
            Map<String, String> parameters = new HashedMap();
            if (!wechatId.equalsIgnoreCase("xm_hcyy_wx")) {
            if (!wechatId.equalsIgnoreCase("xm_hcyy_wx")) {
                logger.info("authCode :"+authCode);
                logger.info("authCode :" + authCode);
                Map<String,Object> rs = oauthSsoService.savePatient(code,appId,authCode,wechatId);
                Map<String, Object> rs = oauthSsoService.savePatient(code, appId, authCode, wechatId);
                Integer c = (Integer) rs.get("code");
                Integer c = (Integer) rs.get("code");
                if(c != 1){
                    return ObjEnvelop.getError(rs.get("mes")+"");
                if (c != 1) {
                    return ObjEnvelop.getError(rs.get("mes") + "");
                }
                }
                BasePatientDO patientDO = (BasePatientDO)rs.get("patient");
                if(patientDO==null){
                BasePatientDO patientDO = (BasePatientDO) rs.get("patient");
                if (patientDO == null) {
                    return ObjEnvelop.getError("获取居民信息失败");
                    return ObjEnvelop.getError("获取居民信息失败");
                }
                }
                parameters.put("username",patientDO.getIdcard());
                parameters.put("username", patientDO.getIdcard());
                parameters.put("grant_type", "ihealthCode");
                parameters.put("grant_type", "ihealthCode");
            }else {
                JSONObject patient = userDetailsService.getHcHLWyyUser(openId,memberId);
                if (patient==null){
            } else {
                JSONObject patient = userDetailsService.getHcHLWyyUser(openId, memberId);
                if (patient == null) {
                    return ObjEnvelop.getError("获取居民信息失败");
                    return ObjEnvelop.getError("获取居民信息失败");
                }
                }
                parameters.put("username",patient.getString("IdCardNo"));
                parameters.put("username", patient.getString("IdCardNo"));
                parameters.put("grant_type", "ihealthCode");
                parameters.put("grant_type", "ihealthCode");
            }
            }
            ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
            ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
@ -2224,9 +2245,9 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            baseLoginLogDO.setLoginType(loginType);
            baseLoginLogDO.setLoginType(loginType);
            baseLoginLogService.save(baseLoginLogDO);
            baseLoginLogService.save(baseLoginLogDO);
            return ObjEnvelop.getSuccess("success",wlyyUserSimple);
            return ObjEnvelop.getSuccess("success", wlyyUserSimple);
        }catch (Exception e){
        } catch (Exception e) {
            logger.error(e);
            logger.error(e);
        }
        }
        return ObjEnvelop.getError("登录失败!");
        return ObjEnvelop.getError("登录失败!");
@ -2303,8 +2324,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    }*/
    }*/
    @RequestMapping(value = "/oauth/registerPatientAndLogin", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/registerPatientAndLogin", method = RequestMethod.POST)
    public ObjEnvelop registerPatientAndLogin(String name, String mobile, String idcard, String ssc, String pw,
    public ObjEnvelop registerPatientAndLogin(String name, String mobile, String idcard, String ssc, String pw,
                                              String client_id,String login_type,String captcha,String openid,String wxId
    ,String geetestChallenge,String geetestValidate,String geetestSeccode )throws Exception{
                                              String client_id, String login_type, String captcha, String openid, String wxId
            , String geetestChallenge, String geetestValidate, String geetestSeccode) throws Exception {
        if (StringUtils.isEmpty(client_id)) {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
            throw new InvalidRequestException("client_id is null");
@ -2319,30 +2340,30 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (resResult==null||!resResult.getString("result").equalsIgnoreCase("success")){
        if (resResult==null||!resResult.getString("result").equalsIgnoreCase("success")){
            return ObjEnvelop.getError("验证失败!");
            return ObjEnvelop.getError("验证失败!");
        }*/
        }*/
        if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
            try {
            try {
                List<BasePatientDO> basePatientDOS =basePatientDao.findByMobileAndDel(mobile,"1");
                List<BasePatientDO> basePatientDOS = basePatientDao.findByMobileAndDel(mobile, "1");
                boolean localFlag = false;
                boolean localFlag = false;
                boolean ykFlag = false;
                boolean ykFlag = false;
                String msg = "";
                String msg = "";
                if (null!=basePatientDOS&&basePatientDOS.size()>0){
                if (null != basePatientDOS && basePatientDOS.size() > 0) {
                    localFlag = true;
                    localFlag = true;
                }
                }
                BasePatientDO basePatientDO = new BasePatientDO();
                BasePatientDO basePatientDO = new BasePatientDO();
                String r =ykyyService.getRegisterUser(mobile,pw,captcha,"a01522","xmijk","xmijk");
                if (!StringUtils.isEmpty(r)){
                String r = ykyyService.getRegisterUser(mobile, pw, captcha, "a01522", "xmijk", "xmijk");
                if (!StringUtils.isEmpty(r)) {
                    JSONObject jsonObject = JSONObject.parseObject(r);
                    JSONObject jsonObject = JSONObject.parseObject(r);
                    if (null!=jsonObject.get("code")&&"200".equalsIgnoreCase(jsonObject.get("code").toString())){
                    if (null != jsonObject.get("code") && "200".equalsIgnoreCase(jsonObject.get("code").toString())) {
                        JSONObject jsonObject1 = JSONObject.parseObject(jsonObject.get("data").toString());
                        JSONObject jsonObject1 = JSONObject.parseObject(jsonObject.get("data").toString());
                        basePatientDO.setUserId(jsonObject1.getString("ID"));
                        basePatientDO.setUserId(jsonObject1.getString("ID"));
                    }else if (null!=jsonObject.get("code")&&"199".equalsIgnoreCase(jsonObject.get("code").toString())){
                    } else if (null != jsonObject.get("code") && "199".equalsIgnoreCase(jsonObject.get("code").toString())) {
                        msg = jsonObject.getString("msg");
                        msg = jsonObject.getString("msg");
                        ykFlag = true;
                        ykFlag = true;
                    }
                    }
                }
                }
                basePatientDO.setMobile(mobile);
                basePatientDO.setMobile(mobile);
                String salt = UUID.randomUUID().toString().substring(0,5);
                String salt = UUID.randomUUID().toString().substring(0, 5);
                basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                basePatientDO.setSalt(salt);
                basePatientDO.setSalt(salt);
                basePatientDO.setDel("1");
                basePatientDO.setDel("1");
@ -2353,7 +2374,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                basePatientDO.setUpdateTime(new Date());
                basePatientDO.setUpdateTime(new Date());
                BasePatientDO patientDO = basePatientDao.save(basePatientDO);
                BasePatientDO patientDO = basePatientDao.save(basePatientDO);
                if (localFlag&&ykFlag){
                if (localFlag && ykFlag) {
                    return ObjEnvelop.getError("该手机号已经注册过");
                    return ObjEnvelop.getError("该手机号已经注册过");
                }
                }
@ -2361,7 +2382,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                Map<String, String> parameters = new HashedMap();
                Map<String, String> parameters = new HashedMap();
                parameters.put("username",patientDO.getMobile());
                parameters.put("username", patientDO.getMobile());
                parameters.put("grant_type", "ihealthCode");
                parameters.put("grant_type", "ihealthCode");
                TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
                TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
@ -2391,31 +2412,31 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                baseLoginLogDO.setLoginType(loginType);
                baseLoginLogDO.setLoginType(loginType);
                baseLoginLogService.save(baseLoginLogDO);
                baseLoginLogService.save(baseLoginLogDO);
                return ObjEnvelop.getSuccess("success",wlyyUserSimple);
                return ObjEnvelop.getSuccess("success", wlyyUserSimple);
            }catch (Exception e){
            } catch (Exception e) {
                e.printStackTrace();
                e.printStackTrace();
            }
            }
        }else {
        } else {
            try {
            try {
                Map<String,Object> rs = registerService.registerPatient(mobile,pw,name,idcard,ssc,openid);
                Map<String, Object> rs = registerService.registerPatient(mobile, pw, name, idcard, ssc, openid);
                String code = rs.get("code").toString();
                String code = rs.get("code").toString();
                if(!"1".equals(code)){
                if (!"1".equals(code)) {
                    ObjEnvelop objEnvelop = new ObjEnvelop();
                    ObjEnvelop objEnvelop = new ObjEnvelop();
                    objEnvelop.setObj(rs);
                    objEnvelop.setObj(rs);
                    objEnvelop.setStatus(-1);
                    objEnvelop.setStatus(-1);
                    objEnvelop.setMessage(rs.get("mes")+"");
                    objEnvelop.setMessage(rs.get("mes") + "");
                    return objEnvelop;
                    return objEnvelop;
                }
                }
                BasePatientDO patientDO = (BasePatientDO)rs.get("patient");
                BasePatientDO patientDO = (BasePatientDO) rs.get("patient");
                ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
                ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
                Map<String, String> parameters = new HashedMap();
                Map<String, String> parameters = new HashedMap();
                parameters.put("username",patientDO.getMobile());
                parameters.put("username", patientDO.getMobile());
                parameters.put("grant_type", "ihealthCode");
                parameters.put("grant_type", "ihealthCode");
                TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
                TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
@ -2445,9 +2466,9 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                baseLoginLogDO.setLoginType(loginType);
                baseLoginLogDO.setLoginType(loginType);
                baseLoginLogService.save(baseLoginLogDO);
                baseLoginLogService.save(baseLoginLogDO);
                return ObjEnvelop.getSuccess("success",wlyyUserSimple);
                return ObjEnvelop.getSuccess("success", wlyyUserSimple);
            }catch (Exception e){
            } catch (Exception e) {
                e.printStackTrace();
                e.printStackTrace();
            }
            }
        }
        }
@ -2456,37 +2477,37 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    }
    }
    @RequestMapping(value = "/oauth/findPatientPw", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/findPatientPw", method = RequestMethod.POST)
    public Envelop findPatientPw(String mobile,String client_id,String login_type,String captcha
            ,String pw,String key,String idcard,String text){
    public Envelop findPatientPw(String mobile, String client_id, String login_type, String captcha
            , String pw, String key, String idcard, String text) {
        try {
        try {
            if(StringUtils.isEmpty(idcard)){
            if (StringUtils.isEmpty(idcard)) {
                return ObjEnvelop.getError("手机号码不能为空!");
                return ObjEnvelop.getError("手机号码不能为空!");
            }
            }
            if(StringUtils.isEmpty(mobile)){
            if (StringUtils.isEmpty(mobile)) {
                return ObjEnvelop.getError("手机号码不能为空!");
                return ObjEnvelop.getError("手机号码不能为空!");
            }
            }
            if(StringUtils.isEmpty(key)||StringUtils.isEmpty(text)){
            if (StringUtils.isEmpty(key) || StringUtils.isEmpty(text)) {
                return ObjEnvelop.getError("图形验证码不能为空!");
                return ObjEnvelop.getError("图形验证码不能为空!");
            }
            }
            if(!verifyCaptcha(key,text)){
            if (!verifyCaptcha(key, text)) {
                throw new ImgCaptchaException("图形验证码错误!");
                throw new ImgCaptchaException("图形验证码错误!");
            }
            }
            Integer re = registerService.checkeMobileAndIdcard(mobile,idcard);
            if(re == -1){
            Integer re = registerService.checkeMobileAndIdcard(mobile, idcard);
            if (re == -1) {
                return ObjEnvelop.getError("居民不存在!");
                return ObjEnvelop.getError("居民不存在!");
            }else if(re == -2){
            } else if (re == -2) {
                return ObjEnvelop.getError("身份证和手机号码不匹配!");
                return ObjEnvelop.getError("身份证和手机号码不匹配!");
            }
            }
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
            if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
                if (captcha.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())){
            if (wlyyHospitalSysDictDO != null && !StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())) {
                if (captcha.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())) {
                }else {
                } else {
                    return ObjEnvelop.getError("短信验证码错误!");
                    return ObjEnvelop.getError("短信验证码错误!");
                }
                }
            }else {
            } else {
                if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
                if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
                    //验证码正确
                    //验证码正确
                } else {
                } else {
@ -2495,129 +2516,131 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            }
            }
            String rs = registerService.updatePatientPw(pw,mobile);
            if("ok".equals(rs)){
            String rs = registerService.updatePatientPw(pw, mobile);
            if ("ok".equals(rs)) {
                return ObjEnvelop.getSuccess("修改成功!");
                return ObjEnvelop.getSuccess("修改成功!");
            }
            }
            return ObjEnvelop.getError("手机号未注册!");
            return ObjEnvelop.getError("手机号未注册!");
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
        }
        }
        return Envelop.getError("系统繁忙,请稍后在试");
        return Envelop.getError("系统繁忙,请稍后在试");
    }
    }
    @RequestMapping(value = "/oauth/findDoctorPw", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/findDoctorPw", method = RequestMethod.POST)
    public Envelop findDoctorPw(String mobile,String client_id,String captcha,String pw) throws Exception{
        if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
           String response =  ykyyService.ResetPwd(mobile,pw,captcha);
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(response)){
    public Envelop findDoctorPw(String mobile, String client_id, String captcha, String pw) throws Exception {
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
            String response = ykyyService.ResetPwd(mobile, pw, captcha);
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(response)) {
                JSONObject object = JSONObject.parseObject(response);
                JSONObject object = JSONObject.parseObject(response);
                if (object.getString("code").equalsIgnoreCase("10000")){
                if (object.getString("code").equalsIgnoreCase("10000")) {
                    return ObjEnvelop.getSuccess("修改成功!");
                    return ObjEnvelop.getSuccess("修改成功!");
                }else {
                } else {
                    return ObjEnvelop.getError("修改失败!");
                    return ObjEnvelop.getError("修改失败!");
                }
                }
            }else {
            } else {
                return ObjEnvelop.getError("修改失败!");
                return ObjEnvelop.getError("修改失败!");
            }
            }
        }else if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
        } else if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)) {
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
            if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
                if (captcha.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())){
            if (wlyyHospitalSysDictDO != null && !StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())) {
                if (captcha.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())) {
                }else {
                } else {
                    return ObjEnvelop.getError("验证码错误!");
                    return ObjEnvelop.getError("验证码错误!");
                }
                }
            }else {
            } else {
                if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
                if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
                    //验证码正确
                    //验证码正确
                } else {
                } else {
                    return ObjEnvelop.getError("验证码错误!");
                    return ObjEnvelop.getError("验证码错误!");
                }
                }
            }
            }
            String rs = registerService.updateDoctorPw(mobile,pw,wechatId);
            if("ok".equals(rs)){
            String rs = registerService.updateDoctorPw(mobile, pw, wechatId);
            if ("ok".equals(rs)) {
                return ObjEnvelop.getSuccess("修改成功!");
                return ObjEnvelop.getSuccess("修改成功!");
            }
            }
            return ObjEnvelop.getError("手机号未注册!");
            return ObjEnvelop.getError("手机号未注册!");
        }else if ("sd_tnzyy_wx".equalsIgnoreCase(wechatId)){
        } else if ("sd_tnzyy_wx".equalsIgnoreCase(wechatId)) {
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
            if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
                if (captcha.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())){
            if (wlyyHospitalSysDictDO != null && !StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())) {
                if (captcha.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())) {
                }else {
                } else {
                    return ObjEnvelop.getError("验证码错误!");
                    return ObjEnvelop.getError("验证码错误!");
                }
                }
            }else {
            } else {
                if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
                if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
                    //验证码正确
                    //验证码正确
                } else {
                } else {
                    return ObjEnvelop.getError("验证码错误!");
                    return ObjEnvelop.getError("验证码错误!");
                }
                }
            }
            }
            String rs = registerService.updateDoctorPw(mobile,pw,wechatId);
            if("ok".equals(rs)){
            String rs = registerService.updateDoctorPw(mobile, pw, wechatId);
            if ("ok".equals(rs)) {
                return ObjEnvelop.getSuccess("修改成功!");
                return ObjEnvelop.getSuccess("修改成功!");
            }
            }
            return ObjEnvelop.getError("手机号未注册!");
            return ObjEnvelop.getError("手机号未注册!");
        }else if ("xm_xzzx_wx".equalsIgnoreCase(wechatId)){
        } else if ("xm_xzzx_wx".equalsIgnoreCase(wechatId)) {
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
            if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
                if (captcha.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())){
            if (wlyyHospitalSysDictDO != null && !StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())) {
                if (captcha.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())) {
                }else {
                } else {
                    return ObjEnvelop.getError("验证码错误!");
                    return ObjEnvelop.getError("验证码错误!");
                }
                }
            }else {
            } else {
                if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
                if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
                    //验证码正确
                    //验证码正确
                } else {
                } else {
                    return ObjEnvelop.getError("验证码错误!");
                    return ObjEnvelop.getError("验证码错误!");
                }
                }
            }
            }
            String rs = registerService.updateDoctorPw(mobile,pw,wechatId);
            if("ok".equals(rs)){
            String rs = registerService.updateDoctorPw(mobile, pw, wechatId);
            if ("ok".equals(rs)) {
                return ObjEnvelop.getSuccess("修改成功!");
                return ObjEnvelop.getSuccess("修改成功!");
            }
            }
            return ObjEnvelop.getError("手机号未注册!");
            return ObjEnvelop.getError("手机号未注册!");
        }else if ("hz_yyyzh_wx".equalsIgnoreCase(wechatId)){
        } else if ("hz_yyyzh_wx".equalsIgnoreCase(wechatId)) {
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
            if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
                if (captcha.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())){
            if (wlyyHospitalSysDictDO != null && !StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())) {
                if (captcha.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())) {
                }else {
                } else {
                    return ObjEnvelop.getError("验证码错误!");
                    return ObjEnvelop.getError("验证码错误!");
                }
                }
            }else {
            } else {
                if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
                if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
                    //验证码正确
                    //验证码正确
                } else {
                } else {
                    return ObjEnvelop.getError("验证码错误!");
                    return ObjEnvelop.getError("验证码错误!");
                }
                }
            }
            }
            String rs = registerService.updateDoctorPw(mobile,pw,wechatId);
            if("ok".equals(rs)){
            String rs = registerService.updateDoctorPw(mobile, pw, wechatId);
            if ("ok".equals(rs)) {
                return ObjEnvelop.getSuccess("修改成功!");
                return ObjEnvelop.getSuccess("修改成功!");
            }
            }
            return ObjEnvelop.getError("手机号未注册!");
            return ObjEnvelop.getError("手机号未注册!");
        }else {
        } else {
            return ObjEnvelop.getError("暂未开放");
            return ObjEnvelop.getError("暂未开放");
        }
        }
    }
    }
    @RequestMapping(value = "/oauth/updateDoctorMoble", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/updateDoctorMoble", method = RequestMethod.POST)
    public Envelop updateDoctorMoble(String id,String mobile,String client_id,String captcha){
    public Envelop updateDoctorMoble(String id, String mobile, String client_id, String captcha) {
        if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
        if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
            //验证码正确
            //验证码正确
        } else {
        } else {
            return ObjEnvelop.getError("验证码错误!");
            return ObjEnvelop.getError("验证码错误!");
        }
        }
        String rs = registerService.updateDoctorMoble(id,mobile);
        if("ok".equals(rs)){
        String rs = registerService.updateDoctorMoble(id, mobile);
        if ("ok".equals(rs)) {
            return ObjEnvelop.getSuccess("修改成功!");
            return ObjEnvelop.getSuccess("修改成功!");
        }
        }
@ -2626,7 +2649,6 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    }
    }
    /**
    /**
     * 眼科通登陆
     * 眼科通登陆
     *
     *
@ -2651,19 +2673,19 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        String captcha = parameters.get("captcha");
        String captcha = parameters.get("captcha");
        String loginType = parameters.get("login_type");
        String loginType = parameters.get("login_type");
        String appletCode = parameters.get("appletCode");
        String appletCode = parameters.get("appletCode");
        String isNeedGeet= "0";//1需要 0不需要
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO= wlyyhospitalSysdictDao.findDictById("isNeedGeet");
        if (wlyyHospitalSysDictDO!=null){
            isNeedGeet=wlyyHospitalSysDictDO.getDictValue();
        String isNeedGeet = "0";//1需要 0不需要
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedGeet");
        if (wlyyHospitalSysDictDO != null) {
            isNeedGeet = wlyyHospitalSysDictDO.getDictValue();
        }
        }
        if (parameters.get("mobile")==null){
            if ("1".equalsIgnoreCase(isNeedGeet)){
        if (parameters.get("mobile") == null) {
            if ("1".equalsIgnoreCase(isNeedGeet)) {
                String geetestChallenge = parameters.get("geetestChallenge");
                String geetestChallenge = parameters.get("geetestChallenge");
                String geetestValidate = parameters.get("geetestValidate");
                String geetestValidate = parameters.get("geetestValidate");
                String geetestSeccode = parameters.get("geetestSeccode");
                String geetestSeccode = parameters.get("geetestSeccode");
                JSONObject resResult =validateGeet(geetestChallenge,geetestValidate,geetestSeccode,"1");
                if (resResult==null||!resResult.getString("result").equalsIgnoreCase("success")){
                    throw new  Exception("验证失败");
                JSONObject resResult = validateGeet(geetestChallenge, geetestValidate, geetestSeccode, "1");
                if (resResult == null || !resResult.getString("result").equalsIgnoreCase("success")) {
                    throw new Exception("验证失败");
                }
                }
            }
            }
        }
        }
@ -2672,8 +2694,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        //图形验证码验证
        //图形验证码验证
        String key = parameters.get("key");
        String key = parameters.get("key");
        String text = parameters.get("text");
        String text = parameters.get("text");
        if(org.apache.commons.lang3.StringUtils.isNotBlank(key)&& org.apache.commons.lang3.StringUtils.isNotBlank(text)){
            if(!verifyCaptcha(key,text)){
        if (org.apache.commons.lang3.StringUtils.isNotBlank(key) && org.apache.commons.lang3.StringUtils.isNotBlank(text)) {
            if (!verifyCaptcha(key, text)) {
                throw new ImgCaptchaException("img_captcha error");
                throw new ImgCaptchaException("img_captcha error");
            }
            }
        }
        }
@ -2692,31 +2714,31 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            if (parameters.get("password") != null) {
            if (parameters.get("password") != null) {
                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
                String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
                String response = ykyyService.yktLogin(parameters.get("username"),password);
                if (!StringUtils.isEmpty(response)){
                String response = ykyyService.yktLogin(parameters.get("username"), password);
                if (!StringUtils.isEmpty(response)) {
                    JSONObject object = JSONObject.parseObject(response);
                    JSONObject object = JSONObject.parseObject(response);
                    if (!object.getString("code").equalsIgnoreCase("200")){
                    if (!object.getString("code").equalsIgnoreCase("200")) {
                        WlyyUserSimple userSimple = new WlyyUserSimple();
                        WlyyUserSimple userSimple = new WlyyUserSimple();
                        return getFailedResponse(object.getString("msg"),-1,userSimple);
                    }else {
                        return getFailedResponse(object.getString("msg"), -1, userSimple);
                    } else {
                        JSONObject jsonObject = object.getJSONObject("data");
                        JSONObject jsonObject = object.getJSONObject("data");
                        if (jsonObject!=null){
                            String userId= jsonObject.getString("ID");
                        if (jsonObject != null) {
                            String userId = jsonObject.getString("ID");
                            String tel = jsonObject.getString("LOGINID");
                            String tel = jsonObject.getString("LOGINID");
                            List<BasePatientDO> basePatientDOS = basePatientDao.findByMobile(tel);
                            List<BasePatientDO> basePatientDOS = basePatientDao.findByMobile(tel);
                            if (basePatientDOS==null||basePatientDOS.size()==0){
                            if (basePatientDOS == null || basePatientDOS.size() == 0) {
                                BasePatientDO basePatientDO = new BasePatientDO();
                                BasePatientDO basePatientDO = new BasePatientDO();
                                String familyList = ykyyService.getFamilyList(null,userId);
                                String familyList = ykyyService.getFamilyList(null, userId);
                                JSONObject familyJson = JSONObject.parseObject(familyList);
                                JSONObject familyJson = JSONObject.parseObject(familyList);
                                if (familyJson.getString("code").equalsIgnoreCase("200")){
                                if (familyJson.getString("code").equalsIgnoreCase("200")) {
                                    JSONObject object1 = familyJson.getJSONObject("data");
                                    JSONObject object1 = familyJson.getJSONObject("data");
                                    JSONArray list = object1.getJSONArray("list");
                                    JSONArray list = object1.getJSONArray("list");
                                    List<String> iliness = new ArrayList<>();
                                    List<String> iliness = new ArrayList<>();
                                    if (list!=null&&list.size()!=0){
                                        for (int i=0;i<list.size();i++){
                                    if (list != null && list.size() != 0) {
                                        for (int i = 0; i < list.size(); i++) {
                                            JSONObject family = list.getJSONObject(i);
                                            JSONObject family = list.getJSONObject(i);
                                            iliness.add(family.getString("ILLNESS"));
                                            iliness.add(family.getString("ILLNESS"));
                                            if (family.getString("ILLNESS").equalsIgnoreCase("本人")&&tel.equalsIgnoreCase(family.getString("TEL"))){
                                            if (family.getString("ILLNESS").equalsIgnoreCase("本人") && tel.equalsIgnoreCase(family.getString("TEL"))) {
                                                basePatientDO.setDel("1");
                                                basePatientDO.setDel("1");
                                                basePatientDO.setName(family.getString("NAME"));
                                                basePatientDO.setName(family.getString("NAME"));
                                                basePatientDO.setCreateTime(new Date());
                                                basePatientDO.setCreateTime(new Date());
@ -2728,19 +2750,20 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                                                Integer age = IdCardUtil.getAgeForIdcard(idcard);
                                                Integer age = IdCardUtil.getAgeForIdcard(idcard);
                                                String sex = IdCardUtil.getSexForIdcard_new(idcard);
                                                String sex = IdCardUtil.getSexForIdcard_new(idcard);
                                                Integer sexx = null;
                                                Integer sexx = null;
                                                if (org.apache.commons.lang3.StringUtils.isNoneBlank(sex)){
                                                if (org.apache.commons.lang3.StringUtils.isNoneBlank(sex)) {
                                                    sexx = Integer.parseInt(sex);
                                                    sexx = Integer.parseInt(sex);
                                                }
                                                }
                                                String birthDay = family.getString("BIRTHDAY");
                                                String birthDay = family.getString("BIRTHDAY");
                                                Date birthday = null;
                                                Date birthday = null;
                                                if (org.apache.commons.lang3.StringUtils.isNoneBlank(birthDay)){
                                                    birthday = DateUtil.strToDate(birthDay+" 00:00:00");;
                                                if (org.apache.commons.lang3.StringUtils.isNoneBlank(birthDay)) {
                                                    birthday = DateUtil.strToDate(birthDay + " 00:00:00");
                                                    ;
                                                }
                                                }
                                                basePatientDO.setBirthday(birthday);
                                                basePatientDO.setBirthday(birthday);
                                                basePatientDO.setSex(sexx);
                                                basePatientDO.setSex(sexx);
                                                basePatientDO.setMobile(tel);
                                                basePatientDO.setMobile(tel);
                                                String salt = UUID.randomUUID().toString().substring(0,5);
                                                String pw = idcard.substring(idcard.length()-6,idcard.length());
                                                String salt = UUID.randomUUID().toString().substring(0, 5);
                                                String pw = idcard.substring(idcard.length() - 6, idcard.length());
                                                basePatientDO.setIdcard(idcard);
                                                basePatientDO.setIdcard(idcard);
                                                basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                                                basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                                                basePatientDO.setSalt(salt);
                                                basePatientDO.setSalt(salt);
@ -2749,13 +2772,13 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                                                basePatientDO.setVerifyCode(jsonObject.getString("TOKEN"));
                                                basePatientDO.setVerifyCode(jsonObject.getString("TOKEN"));
                                                basePatientDO.setPatientStatus("1");
                                                basePatientDO.setPatientStatus("1");
                                                basePatientDao.save(basePatientDO);
                                                basePatientDao.save(basePatientDO);
                                            }else {
                                            } else {
                                                List<BasePatientDO> basePatientDOList = basePatientDao.findByMobile(tel);
                                                List<BasePatientDO> basePatientDOList = basePatientDao.findByMobile(tel);
                                                if(basePatientDOList==null||basePatientDOList.size()==0){
                                                if (basePatientDOList == null || basePatientDOList.size() == 0) {
                                                    basePatientDO.setDel("1");
                                                    basePatientDO.setDel("1");
                                                    if (jsonObject.getString("USERNAME").length()>=2){
                                                    if (jsonObject.getString("USERNAME").length() >= 2) {
                                                        basePatientDO.setName(jsonObject.getString("USERNAME"));
                                                        basePatientDO.setName(jsonObject.getString("USERNAME"));
                                                    }else {
                                                    } else {
                                                        basePatientDO.setName(tel);
                                                        basePatientDO.setName(tel);
                                                    }
                                                    }
                                                    basePatientDO.setCreateTime(new Date());
                                                    basePatientDO.setCreateTime(new Date());
@ -2763,8 +2786,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                                                    basePatientDO.setYktId(jsonObject.getString("ID"));
                                                    basePatientDO.setYktId(jsonObject.getString("ID"));
                                                    basePatientDO.setUserId(userId);
                                                    basePatientDO.setUserId(userId);
                                                    basePatientDO.setMobile(tel);
                                                    basePatientDO.setMobile(tel);
                                                    String salt = UUID.randomUUID().toString().substring(0,5);
                                                    String pw = tel.substring(tel.length()-6,tel.length());
                                                    String salt = UUID.randomUUID().toString().substring(0, 5);
                                                    String pw = tel.substring(tel.length() - 6, tel.length());
                                                    basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                                                    basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                                                    basePatientDO.setSalt(salt);
                                                    basePatientDO.setSalt(salt);
                                                    basePatientDO.setLocked(0);
                                                    basePatientDO.setLocked(0);
@ -2774,11 +2797,11 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                                                }
                                                }
                                            }
                                            }
                                        }
                                        }
                                    }else {
                                    } else {
                                        if (jsonObject.getString("USERNAME").length()>=2){
                                        if (jsonObject.getString("USERNAME").length() >= 2) {
                                            basePatientDO.setName(jsonObject.getString("USERNAME"));
                                            basePatientDO.setName(jsonObject.getString("USERNAME"));
                                        }else {
                                        } else {
                                            basePatientDO.setName(tel);
                                            basePatientDO.setName(tel);
                                        }
                                        }
                                        basePatientDO.setDel("1");
                                        basePatientDO.setDel("1");
@ -2786,8 +2809,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                                        basePatientDO.setUpdateTime(new Date());
                                        basePatientDO.setUpdateTime(new Date());
                                        basePatientDO.setUserId(userId);
                                        basePatientDO.setUserId(userId);
                                        basePatientDO.setMobile(tel);
                                        basePatientDO.setMobile(tel);
                                        String salt = UUID.randomUUID().toString().substring(0,5);
                                        String pw = tel.substring(tel.length()-6,tel.length());
                                        String salt = UUID.randomUUID().toString().substring(0, 5);
                                        String pw = tel.substring(tel.length() - 6, tel.length());
                                        basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                                        basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                                        basePatientDO.setSalt(salt);
                                        basePatientDO.setSalt(salt);
                                        basePatientDO.setLocked(0);
                                        basePatientDO.setLocked(0);
@ -2806,14 +2829,14 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                                        ykyyService.addFamily(basePatientDO.getUserId(),basePatientDO.getIdcard(),basePatientDO.getName(),sex+"",birdth,age+"",basePatientDO.getMobile());
                                        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"));
                            } else {
                                logger.info("======" + jsonObject.getString("USERNAME") + "======");
                                logger.info("tel" + jsonObject.getString("USERNAME"));
                                BasePatientDO basePatientDO1 = basePatientDOS.get(0);
                                BasePatientDO basePatientDO1 = basePatientDOS.get(0);
                                if (basePatientDO1.getName()==null||basePatientDO1.getName()==""){
                                    if (jsonObject.getString("USERNAME").length()>=2){
                                if (basePatientDO1.getName() == null || basePatientDO1.getName() == "") {
                                    if (jsonObject.getString("USERNAME").length() >= 2) {
                                        basePatientDO1.setName(jsonObject.getString("USERNAME"));
                                        basePatientDO1.setName(jsonObject.getString("USERNAME"));
                                    }else {
                                    } else {
                                        basePatientDO1.setName(tel);
                                        basePatientDO1.setName(tel);
                                    }
                                    }
                                }
                                }
@ -2853,123 +2876,124 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                    }
                    }
                }
                }
                parameters.remove("password");
                parameters.remove("password");
            }else if (parameters.get("mobile") != null) {
            } else if (parameters.get("mobile") != null) {
                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                String mobile = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("mobile"), keyPair);
                String mobile = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("mobile"), keyPair);
                logger.info("mobile:"+mobile);
                logger.info("mobile:" + mobile);
                String password = null;
                String password = null;
                String res = ykyyService.getPatientPhone(mobile);
                String res = ykyyService.getPatientPhone(mobile);
                if (res!=null&&res!=""){
                if (res != null && res != "") {
                    JSONObject object = JSONObject.parseObject(res);
                    JSONObject object = JSONObject.parseObject(res);
                    if (object.getString("code").equalsIgnoreCase("200")){
                    if (object.getString("code").equalsIgnoreCase("200")) {
                        password = object.getString("data");
                        password = object.getString("data");
                    }else {
                    } else {
                        WlyyUserSimple userSimple = new WlyyUserSimple();
                        WlyyUserSimple userSimple = new WlyyUserSimple();
                        return getFailedResponse(object.getString("msg"),-1,userSimple);
                        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"))){
                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");
                                                    basePatientDO.setDel("1");
                                                    basePatientDO.setName(family.getString("NAME"));
                                                    if (jsonObject.getString("USERNAME").length() >= 2) {
                                                        basePatientDO.setName(jsonObject.getString("USERNAME"));
                                                    } else {
                                                        basePatientDO.setName(tel);
                                                    }
                                                    basePatientDO.setCreateTime(new Date());
                                                    basePatientDO.setCreateTime(new Date());
                                                    basePatientDO.setUpdateTime(new Date());
                                                    basePatientDO.setUpdateTime(new Date());
                                                    basePatientDO.setYktId(family.getString("ID"));
                                                    basePatientDO.setYktId(jsonObject.getString("ID"));
                                                    basePatientDO.setUserId(userId);
                                                    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);
                                                    basePatientDO.setMobile(tel);
                                                    String salt = UUID.randomUUID().toString().substring(0,5);
                                                    String pw = idcard.substring(idcard.length()-6,idcard.length());
                                                    basePatientDO.setIdcard(idcard);
                                                    String salt = UUID.randomUUID().toString().substring(0, 5);
                                                    String pw = tel.substring(tel.length() - 6, tel.length());
                                                    basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                                                    basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                                                    basePatientDO.setSalt(salt);
                                                    basePatientDO.setSalt(salt);
                                                    basePatientDO.setLocked(0);
                                                    basePatientDO.setLocked(0);
                                                    basePatientDO.setEnabled(1);
                                                    basePatientDO.setEnabled(1);
                                                    basePatientDO.setVerifyCode(jsonObject.getString("TOKEN"));
                                                    basePatientDO.setPatientStatus("1");
                                                    basePatientDO.setPatientStatus("1");
                                                    basePatientDao.save(basePatientDO);
                                                    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 {
                                        }
                                    } 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);
                                        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());
                                    /*String birdth = com.yihu.jw.util.idcard.IdCardUtil.getBirthdayForIdcardStr(basePatientDO.getIdcard());
                                    Integer age = com.yihu.jw.util.idcard.IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard());
                                    Integer age = com.yihu.jw.util.idcard.IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard());
                                    Integer sex = basePatientDO.getSex()!=null?basePatientDO.getSex():0;
                                    Integer sex = basePatientDO.getSex()!=null?basePatientDO.getSex():0;
@ -2980,21 +3004,21 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                                    }else {
                                    }else {
                                        ykyyService.addFamily(basePatientDO.getUserId(),basePatientDO.getIdcard(),basePatientDO.getName(),sex+"",birdth,age+"",basePatientDO.getMobile());
                                        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);
                                    }
                                    }
                                }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);
                                }
                                basePatientDO1.setVerifyCode(jsonObject.getString("TOKEN"));
                                basePatientDO1.setUserId(userId);
                                basePatientDao.save(basePatientDO1);
                                /*String familyList = ykyyService.getFamilyList(null,userId);
                                /*String familyList = ykyyService.getFamilyList(null,userId);
                                JSONObject familyJson = JSONObject.parseObject(familyList);
                                JSONObject familyJson = JSONObject.parseObject(familyList);
                                if (familyJson.getString("code").equalsIgnoreCase("200")){
                                if (familyJson.getString("code").equalsIgnoreCase("200")){
@ -3023,12 +3047,12 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                                    }
                                    }
                                }*/
                                }*/
                                }
                            }
                            }
                        }
                        }
                    }
                    }
                    parameters.remove("password");
                } else if (!StringUtils.isEmpty(loginType)&&"3".equalsIgnoreCase(loginType)){
                }
                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)) {
                    //验证码正确
                    //验证码正确
                }
                }
@ -3057,7 +3081,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        实现同一账号只能在一处登陆*/
        实现同一账号只能在一处登陆*/
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
        if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile") || request.getHeader("login-device").equalsIgnoreCase("pc"))) {
            tokenStore.removeAccessToken(token.getValue());
            tokenStore.removeAccessToken(token.getValue());
            tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
            tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
            token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
            token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
@ -3081,8 +3105,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && "3".equals(loginType)) {
        if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && "3".equals(loginType)) {
            baseLoginLogDO.setOpenid(openid);
            baseLoginLogDO.setOpenid(openid);
            /*userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());*/
            /*userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());*/
            if (!StringUtils.isEmpty(wechatId)&& !"undefined".equalsIgnoreCase(wechatId)){
                userDetailsService.updateOpenIdAndWechatId(openid,wlyyUserSimple.getId(),wechatId);
            if (!StringUtils.isEmpty(wechatId) && !"undefined".equalsIgnoreCase(wechatId)) {
                userDetailsService.updateOpenIdAndWechatId(openid, wlyyUserSimple.getId(), wechatId);
            }
            }
        }
        }
        if (parameters.get("password") != null) {
        if (parameters.get("password") != null) {
@ -3092,9 +3116,9 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        WxWechatDO wxWechatDO = wechatDao.findByIdAndStatus(wechatId);
        WxWechatDO wxWechatDO = wechatDao.findByIdAndStatus(wechatId);
        String appletOpenid = null;
        String appletOpenid = null;
        if (!StringUtils.isEmpty(appletCode)){
            Map<String,Object> objectMap = checkApplets(appletCode,wxWechatDO.getApplets(),wxWechatDO.getAppletsSecret());
            if (objectMap!=null){
        if (!StringUtils.isEmpty(appletCode)) {
            Map<String, Object> objectMap = checkApplets(appletCode, wxWechatDO.getApplets(), wxWechatDO.getAppletsSecret());
            if (objectMap != null) {
                appletOpenid = objectMap.get("openid").toString();
                appletOpenid = objectMap.get("openid").toString();
                userDetailsService.updateOpenId(appletOpenid, wlyyUserSimple.getId());
                userDetailsService.updateOpenId(appletOpenid, wlyyUserSimple.getId());
            }
            }
@ -3112,7 +3136,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    }
    }
    public Map<String, Object> checkApplets(String code,String appid,String appSecret) throws Exception {
    public Map<String, Object> checkApplets(String code, String appid, String appSecret) throws Exception {
        HttpUtils httpUtils = new HttpUtils();
        HttpUtils httpUtils = new HttpUtils();
        Map<String, Object> param = new HashedMap();
        Map<String, Object> param = new HashedMap();
        param.put("appid", appid);
        param.put("appid", appid);
@ -3123,8 +3147,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        HttpResponse response = httpUtils.doGet("https://api.weixin.qq.com/sns/jscode2session", param);
        HttpResponse response = httpUtils.doGet("https://api.weixin.qq.com/sns/jscode2session", param);
        JSONObject rs = JSONObject.parseObject(response.getContent());
        JSONObject rs = JSONObject.parseObject(response.getContent());
        Map<String, Object> res = new HashedMap();
        Map<String, Object> res = new HashedMap();
        logger.info("checkApplets:"+response.getContent());
        if (rs.containsKey("openid")){
        logger.info("checkApplets:" + response.getContent());
        if (rs.containsKey("openid")) {
            res.put("openid", rs.getString("openid"));
            res.put("openid", rs.getString("openid"));
            res.put("sessionKey", rs.getString("session_key"));
            res.put("sessionKey", rs.getString("session_key"));
        }
        }
@ -3133,37 +3157,38 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    @RequestMapping(value = "/oauth/findYktPatientPw", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/findYktPatientPw", method = RequestMethod.POST)
    public Envelop findYktPatientPw(String mobile,String client_id,String login_type,String captcha,String pw)throws Exception {
    public Envelop findYktPatientPw(String mobile, String client_id, String login_type, String captcha, String pw) throws Exception {
        if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
        if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
            //验证码正确
            //验证码正确
        } else {
        } else {
            return ObjEnvelop.getError("验证码错误!");
            return ObjEnvelop.getError("验证码错误!");
        }
        }
        String response = ykyyService.forgetPassword(mobile,pw,captcha);
        if (org.apache.commons.lang3.StringUtils.isNoneBlank(response)){
        String response = ykyyService.forgetPassword(mobile, pw, captcha);
        if (org.apache.commons.lang3.StringUtils.isNoneBlank(response)) {
            JSONObject object = JSONObject.parseObject(response);
            JSONObject object = JSONObject.parseObject(response);
            if (object.getString("code").equalsIgnoreCase("10000")){
            if (object.getString("code").equalsIgnoreCase("10000")) {
                return ObjEnvelop.getSuccess("修改成功!");
                return ObjEnvelop.getSuccess("修改成功!");
            }else {
            } else {
                return ObjEnvelop.getSuccess("修改失败!");
                return ObjEnvelop.getSuccess("修改失败!");
            }
            }
        }
        }
        String rs = registerService.updatePatientPw(pw,mobile);
        if("ok".equals(rs)){
        String rs = registerService.updatePatientPw(pw, mobile);
        if ("ok".equals(rs)) {
            return ObjEnvelop.getSuccess("修改成功!");
            return ObjEnvelop.getSuccess("修改成功!");
        }
        }
        return ObjEnvelop.getError("手机号未注册!");
        return ObjEnvelop.getError("手机号未注册!");
    }
    }
    /*
    /*
     *眼科通修改密码发送的验证码
     *眼科通修改密码发送的验证码
     */
     */
    @RequestMapping(value = "/oauth/yktGetResetCode", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/yktGetResetCode", method = RequestMethod.POST)
    public ObjEnvelop yktGetResetCode(@ApiParam(name = "loginid", value = "注册的电话号码", required = true)
    public ObjEnvelop yktGetResetCode(@ApiParam(name = "loginid", value = "注册的电话号码", required = true)
                                      @RequestParam(value = "loginid",required = true)String loginid,
                                      @RequestParam(value = "loginid", required = true) String loginid,
                                      @ApiParam(name = "type", value = "验证码类型 1、患者注册 2、患者找回密码 3、医生注册 4、医生找回密码", required = true)
                                      @ApiParam(name = "type", value = "验证码类型 1、患者注册 2、患者找回密码 3、医生注册 4、医生找回密码", required = true)
                                      @RequestParam(value = "type",required = false)String type){
                                      @RequestParam(value = "type", required = false) String type) {
        try {
        try {
            return ObjEnvelop.getSuccess("ok",ykyyService.getResetCode(type,loginid));
            return ObjEnvelop.getSuccess("ok", ykyyService.getResetCode(type, loginid));
        } catch (Exception e) {
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
        }
        }
@ -3191,34 +3216,34 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        /*//图形验证码验证
        /*//图形验证码验证
        String key = parameters.get("key");
        String key = parameters.get("key");
        String text = parameters.get("text");*/
        String text = parameters.get("text");*/
        String isNeedGeet= "0";//1需要 0不需要
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO1= wlyyhospitalSysdictDao.findDictById("isNeedGeet");
        if (wlyyHospitalSysDictDO1!=null){
            isNeedGeet=wlyyHospitalSysDictDO1.getDictValue();
        String isNeedGeet = "0";//1需要 0不需要
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO1 = wlyyhospitalSysdictDao.findDictById("isNeedGeet");
        if (wlyyHospitalSysDictDO1 != null) {
            isNeedGeet = wlyyHospitalSysDictDO1.getDictValue();
        }
        }
        if (parameters.get("mobile")==null){
            if("1".equalsIgnoreCase(isNeedGeet)){
        if (parameters.get("mobile") == null) {
            if ("1".equalsIgnoreCase(isNeedGeet)) {
                String geetestChallenge = parameters.get("geetestChallenge");
                String geetestChallenge = parameters.get("geetestChallenge");
                String geetestValidate = parameters.get("geetestValidate");
                String geetestValidate = parameters.get("geetestValidate");
                String geetestSeccode = parameters.get("geetestSeccode");
                String geetestSeccode = parameters.get("geetestSeccode");
                JSONObject resResult =validateGeet(geetestChallenge,geetestValidate,geetestSeccode,"2");
                if (resResult==null||!resResult.getString("result").equalsIgnoreCase("success")){
                    throw new  Exception("验证失败");
                JSONObject resResult = validateGeet(geetestChallenge, geetestValidate, geetestSeccode, "2");
                if (resResult == null || !resResult.getString("result").equalsIgnoreCase("success")) {
                    throw new Exception("验证失败");
                }
                }
            }
            }
        }
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedPictureCode");
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedPictureCode");
        String isNeedPictureCode = "1";
        String isNeedPictureCode = "1";
        if (wlyyHospitalSysDictDO!=null){
        if (wlyyHospitalSysDictDO != null) {
            isNeedPictureCode = wlyyHospitalSysDictDO.getDictValue();
            isNeedPictureCode = wlyyHospitalSysDictDO.getDictValue();
        }
        }
        logger.info("isNeedPictureCode:"+isNeedPictureCode);
        if ("1".equalsIgnoreCase(isNeedPictureCode)){
        logger.info("isNeedPictureCode:" + isNeedPictureCode);
        if ("1".equalsIgnoreCase(isNeedPictureCode)) {
            //图形验证码验证
            //图形验证码验证
            String key = parameters.get("key");
            String key = parameters.get("key");
            String text = parameters.get("text");
            String text = parameters.get("text");
            if(org.apache.commons.lang3.StringUtils.isNotBlank(key)&& org.apache.commons.lang3.StringUtils.isNotBlank(text)){
                if(!verifyCaptcha(key,text)){
            if (org.apache.commons.lang3.StringUtils.isNotBlank(key) && org.apache.commons.lang3.StringUtils.isNotBlank(text)) {
                if (!verifyCaptcha(key, text)) {
                    throw new ImgCaptchaException("img_captcha error");
                    throw new ImgCaptchaException("img_captcha error");
                }
                }
            }
            }
@ -3239,34 +3264,34 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            if (parameters.get("password") != null) {
            if (parameters.get("password") != null) {
                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
                String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
                logger.info("password:"+password);
                String response = ykyyService.DoctorLogin(parameters.get("username"),password);
                if (!StringUtils.isEmpty(response)){
                logger.info("password:" + password);
                String response = ykyyService.DoctorLogin(parameters.get("username"), password);
                if (!StringUtils.isEmpty(response)) {
                    JSONObject object = JSONObject.parseObject(response);
                    JSONObject object = JSONObject.parseObject(response);
                    logger.info("眼科通登陆返回参数:"+object);
                    if (!object.getString("code").equalsIgnoreCase("10000")){
                    logger.info("眼科通登陆返回参数:" + object);
                    if (!object.getString("code").equalsIgnoreCase("10000")) {
                        WlyyUserSimple userSimple = new WlyyUserSimple();
                        WlyyUserSimple userSimple = new WlyyUserSimple();
                        return getFailedResponse(object.getString("msg"),-1,userSimple);
                    }else {
                        return getFailedResponse(object.getString("msg"), -1, userSimple);
                    } else {
                        JSONObject jsonObject = object.getJSONObject("value");
                        JSONObject jsonObject = object.getJSONObject("value");
                        if (jsonObject!=null) {
                        if (jsonObject != null) {
                            String idCard = jsonObject.getString("idCard");
                            String idCard = jsonObject.getString("idCard");
                            String verifyCode = jsonObject.getString("verifyCode");
                            String verifyCode = jsonObject.getString("verifyCode");
                            String yktDoctorId= jsonObject.getString("id");
                            String yktDoctorId = jsonObject.getString("id");
                            BaseDoctorDO doctorDOs = doctorDao.findByIdcard(idCard);
                            BaseDoctorDO doctorDOs = doctorDao.findByIdcard(idCard);
                            if (doctorDOs!=null){
                            if (doctorDOs != null) {
                                doctorDOs.setVerifyCode(verifyCode);
                                doctorDOs.setVerifyCode(verifyCode);
                                doctorDOs.setYktDoctorId(yktDoctorId);
                                doctorDOs.setYktDoctorId(yktDoctorId);
                                /*doctorDOs.setYktCode();*/
                                /*doctorDOs.setYktCode();*/
                                doctorDao.save(doctorDOs);
                                doctorDao.save(doctorDOs);
                            }else {
                            } else {
                                WlyyUserSimple userSimple = new WlyyUserSimple();
                                WlyyUserSimple userSimple = new WlyyUserSimple();
                                return getFailedResponse("您的账号未认证,请联系互联网医院工作人员,联系电话0592-2108763。",-1,userSimple);
                                return getFailedResponse("您的账号未认证,请联系互联网医院工作人员,联系电话0592-2108763。", -1, userSimple);
                            }
                            }
                            if (idCard==null||idCard==""){
                            if (idCard == null || idCard == "") {
                                logger.info("身份证为空");
                                logger.info("身份证为空");
                            }else {
                                ykyyService.updateYkyyDoctor(idCard,verifyCode,yktDoctorId);
                            } else {
                                ykyyService.updateYkyyDoctor(idCard, verifyCode, yktDoctorId);
                            }
                            }
                        }
                        }
                    }
                    }
@ -3275,51 +3300,51 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            } else if (parameters.get("mobile") != null) {
            } else if (parameters.get("mobile") != null) {
                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                String mobile = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("mobile"), keyPair);
                String mobile = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("mobile"), keyPair);
                logger.info("mobile:"+mobile);
                logger.info("mobile:" + mobile);
                String password = null;
                String password = null;
                String res = ykyyService.getDoctorPhone(mobile);
                String res = ykyyService.getDoctorPhone(mobile);
                if (res!=null&&res!=""){
                if (res != null && res != "") {
                    JSONObject object = JSONObject.parseObject(res);
                    JSONObject object = JSONObject.parseObject(res);
                    if (object.getString("code").equalsIgnoreCase("200")){
                    if (object.getString("code").equalsIgnoreCase("200")) {
                        password = object.getString("data");
                        password = object.getString("data");
                    }else {
                    } else {
                        WlyyUserSimple userSimple = new WlyyUserSimple();
                        WlyyUserSimple userSimple = new WlyyUserSimple();
                        return getFailedResponse(object.getString("msg"),-1,userSimple);
                        return getFailedResponse(object.getString("msg"), -1, userSimple);
                    }
                    }
                }
                }
                String response = ykyyService.DoctorLogin(parameters.get("username"),password);
                if (!StringUtils.isEmpty(response)){
                String response = ykyyService.DoctorLogin(parameters.get("username"), password);
                if (!StringUtils.isEmpty(response)) {
                    JSONObject object = JSONObject.parseObject(response);
                    JSONObject object = JSONObject.parseObject(response);
                    logger.info("眼科通登陆返回参数:"+object);
                    if (!object.getString("code").equalsIgnoreCase("10000")){
                    logger.info("眼科通登陆返回参数:" + object);
                    if (!object.getString("code").equalsIgnoreCase("10000")) {
                        WlyyUserSimple userSimple = new WlyyUserSimple();
                        WlyyUserSimple userSimple = new WlyyUserSimple();
                        return getFailedResponse(object.getString("message"),-1,userSimple);
                    }else {
                        return getFailedResponse(object.getString("message"), -1, userSimple);
                    } else {
                        JSONObject jsonObject = object.getJSONObject("value");
                        JSONObject jsonObject = object.getJSONObject("value");
                        if (jsonObject!=null) {
                        if (jsonObject != null) {
                            String idCard = jsonObject.getString("idCard");
                            String idCard = jsonObject.getString("idCard");
                            String verifyCode = jsonObject.getString("verifyCode");
                            String verifyCode = jsonObject.getString("verifyCode");
                            String yktDoctorId= jsonObject.getString("id");
                            String yktDoctorId = jsonObject.getString("id");
                            BaseDoctorDO doctorDOs = doctorDao.findByIdcard(idCard);
                            BaseDoctorDO doctorDOs = doctorDao.findByIdcard(idCard);
                            if (doctorDOs!=null){
                            if (doctorDOs != null) {
                                doctorDOs.setVerifyCode(verifyCode);
                                doctorDOs.setVerifyCode(verifyCode);
                                doctorDOs.setYktDoctorId(yktDoctorId);
                                doctorDOs.setYktDoctorId(yktDoctorId);
                                /*doctorDOs.setYktCode();*/
                                /*doctorDOs.setYktCode();*/
                                doctorDao.save(doctorDOs);
                                doctorDao.save(doctorDOs);
                            }else {
                            } else {
                                WlyyUserSimple userSimple = new WlyyUserSimple();
                                WlyyUserSimple userSimple = new WlyyUserSimple();
                                return getFailedResponse("您的账号未认证,请联系互联网医院工作人员,联系电话0592-2108763。",-1,userSimple);
                                return getFailedResponse("您的账号未认证,请联系互联网医院工作人员,联系电话0592-2108763。", -1, userSimple);
                            }
                            }
                            if (idCard==null||idCard==""){
                            if (idCard == null || idCard == "") {
                                logger.info("身份证为空");
                                logger.info("身份证为空");
                            }else {
                                ykyyService.updateYkyyDoctor(idCard,verifyCode,yktDoctorId);
                            } else {
                                ykyyService.updateYkyyDoctor(idCard, verifyCode, yktDoctorId);
                            }
                            }
                        }
                        }
                    }
                    }
                }
                }
                parameters.remove("password");
                parameters.remove("password");
            }else {
            } else {
                //第三方同步账号模式登录
                //第三方同步账号模式登录
                parameters.put("grant_type", "ihealthDcotor");
                parameters.put("grant_type", "ihealthDcotor");
            }
            }
@ -3332,7 +3357,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (null == authenticatedClient) {
        if (null == authenticatedClient) {
            throw new InvalidRequestException("client_id");
            throw new InvalidRequestException("client_id");
        }
        }
        logger.info("login:登录进入4"+authenticatedClient.getClientId());
        logger.info("login:登录进入4" + authenticatedClient.getClientId());
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
        oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
@ -3344,7 +3369,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        实现同一账号只能在一处登陆*/
        实现同一账号只能在一处登陆*/
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
        if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile") || request.getHeader("login-device").equalsIgnoreCase("pc"))) {
            tokenStore.removeAccessToken(token.getValue());
            tokenStore.removeAccessToken(token.getValue());
            tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
            tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
            token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
            token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
@ -3366,13 +3391,13 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        //更新患者openId
        //更新患者openId
        BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
        BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
        logger.info("gengxin开始");
        logger.info("gengxin开始");
        if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("3".equals(loginType)||"4".equalsIgnoreCase(loginType))) {
        if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("3".equals(loginType) || "4".equalsIgnoreCase(loginType))) {
            baseLoginLogDO.setOpenid(openid);
            baseLoginLogDO.setOpenid(openid);
            logger.info("gengxin进入"+openid);
            logger.info("gengxin进入" + openid);
            userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());
            userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());
            if (!StringUtils.isEmpty(wechatId)&& !"undefined".equalsIgnoreCase(wechatId)){
                logger.info("gengxin进入"+wechatId);
                userDetailsService.updateOpenIdAndWechatId(openid,wlyyUserSimple.getId(),wechatId);
            if (!StringUtils.isEmpty(wechatId) && !"undefined".equalsIgnoreCase(wechatId)) {
                logger.info("gengxin进入" + wechatId);
                userDetailsService.updateOpenIdAndWechatId(openid, wlyyUserSimple.getId(), wechatId);
            }
            }
        }
        }
        if (parameters.get("password") != null) {
        if (parameters.get("password") != null) {

+ 2 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java

@ -29,7 +29,8 @@ import java.util.Map;
 * Created by wangzhinan on 2019/12/3.
 * Created by wangzhinan on 2019/12/3.
 */
 */
@RestController
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.Statistics.PREFIX)
//@RequestMapping(value = BaseHospitalRequestMapping.Statistics.PREFIX)
@RequestMapping("/open/statistics")
@Api(value = "统计分析", description = "统计分析", tags = {"统计分析"})
@Api(value = "统计分析", description = "统计分析", tags = {"统计分析"})
public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
public class EsStatisticsEndpoint extends EnvelopRestEndpoint {