Forráskód Böngészése

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

wangzhinan 4 éve
szülő
commit
292984d39c

+ 17 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/ykyy/service/YkyyService.java

@ -440,6 +440,23 @@ public class YkyyService {
        logger.info("获取眼科通忘记密码信息:"+response);
        return response;
    }
    /**获取眼科通忘记密码信息
     *
     * @param tel
     * @param password
     * @param vercode
     * @return
     */
    public String  updatePatientPassword(String tel,String password,String vercode){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("loginid",tel);
        jsonObject.put("password",password);
        String url = "http://www.yanketong.com:90/api/Patient/ForgotPassword4Jkzl";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("获取眼科通忘记密码信息:"+response);
        return response;
    }
    /**
     * 同步眼科通数据

+ 20 - 1
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java

@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.util.ConstantUtils;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -14,6 +15,7 @@ import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.repository.CrudRepository;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -55,7 +57,10 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private YkyyService ykyyService;
    @Value("${wechat.id}")
    private String wxId;
    /**
     * 居民id
@ -244,6 +249,20 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
            return false;
        }*/
        //认证信息设置
        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
            String response =ykyyService.updatePatientPassword(patientDO.getMobile(),pw,"");
            if (StringUtils.isNoneBlank(response)&&response.contains("10000")){
                String salt = randomString(5);
                patientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                patientDO.setSalt(salt);
                basePatientDao.save(patientDO);
                /*//设置更新时间
                saveDoctorPwlimitDate(id);*/
                return true;
            }
        }
        String salt = randomString(5);
        patientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
        patientDO.setSalt(salt);

+ 33 - 29
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -2156,7 +2156,6 @@ public class ImService {
															   String type, Integer status,
															   int page,int pagesize,
															   String title,String start_time,String end_time) {
		String  sql = "";
		//专家咨询
		if("1".equals(type) || "15".equals(type) || type.contains(",")||"17".equals(type)){
@ -2251,10 +2250,11 @@ public class ImService {
			}
			sql += " ORDER BY a.czrq desc ";
		}else {
			if (-1 == status&&(type.equalsIgnoreCase("0")||type.equalsIgnoreCase("9"))) {
			if ((-1 == status||1==status)&&(type.equalsIgnoreCase("0")||type.equalsIgnoreCase("9")||type.equalsIgnoreCase("16"))) {
				sql = "SELECT " +
						"a.id AS \"id\"," +
						"op.type AS \"type\"," +
						"op.pay_status AS \"payStatus\"," +
						"case op.type  when 1 then 9 when 2 then 16 else op.type end type," +
						"op.description AS \"title\"," +
						"op.description AS \"symptoms\",";
				if ("xm_ykyy_wx".equals(wxId)) {
@ -2343,8 +2343,15 @@ public class ImService {
				}
				//咨询类型
				if(!StringUtils.isEmpty(type)&&type.equalsIgnoreCase("9")){
					sql +=" AND op.type in (1,2) and op.outpatient_type = 1";
				if(!StringUtils.isEmpty(type)){
					if (type.equalsIgnoreCase("9")){
						sql +=" AND op.type in (1) and op.outpatient_type = 1";
					}else if (type.equalsIgnoreCase("16")){
						sql +=" AND op.type in (2) and op.outpatient_type = 1";
					}else {
						sql +=" AND op.type in (1,2) and op.outpatient_type = 1";
					}
				}
@ -2356,6 +2363,7 @@ public class ImService {
			} else {
				sql = "SELECT " +
						"a.id AS \"id\"," +
						"op.pay_status AS \"payStatus\"," +
						"a.type AS \"type\"," +
						"a.title AS \"title\"," +
						"a.symptoms AS \"symptoms\",";
@ -2389,7 +2397,7 @@ public class ImService {
						"wlyy_consult a   " +
						"left join wlyy_outpatient op on  a.relation_code = op.id " +
						"WHERE a.id=b.consult " +
						"AND op.patient=d.id ";
						"AND b.patient=d.id ";
				if (status == 1) {
					sql += " and op.status = 0 ";
				}
@ -2446,11 +2454,7 @@ public class ImService {
				//咨询类型
				if (!StringUtils.isEmpty(type) && !type.equalsIgnoreCase("0")) {
					if("9".equalsIgnoreCase(type)){
						sql +=" AND a.type in (9,16)" ;
					}else {
						sql +=" AND a.type in ("+type+")" ;
					}
					sql +=" AND a.type in ("+type+")" ;
				}
				if (!StringUtils.isEmpty(id)) {
@ -2500,17 +2504,16 @@ public class ImService {
	/**
	 * 查询患者所有的咨询记录总数
	 * @param doctor 患者标识
	 * @param id 会话ID(等同IM表topicId)
	 * @param type 咨询会话类型
	 * @param status 咨询状态:0全部,1候诊中,2就诊中,3结束
	 * @param title 标题关键字
	 * @param start_time 开始时间
	 * @param end_time 结束时间
	 * 	 * @param doctor 患者标识
	 * 	 * @param id 会话ID(等同IM表topicId)
	 * 	 * @param type 咨询会话类型
	 * 	 * @param status 咨询状态:0全部,1候诊中,2就诊中,3结束
	 * 	 * @param title 标题关键字
	 * 	 * @param start_time 开始时间
	 * 	 * @param end_time 结束时间
	 * @return
	 */
	public Long countConsultRecordByDoctor(String doctor, String id,String type, Integer status,String title,String start_time,String end_time) {
		/*String  sql = "SELECT " +
				" COUNT(1) AS \"total\" " +
				"FROM wlyy_consult_team b," +
@ -2654,8 +2657,7 @@ public class ImService {
			}
			sql += " ORDER BY a.czrq desc ";
		}else{
			if (-1 == status&&(type.equalsIgnoreCase("0")||type.equalsIgnoreCase("9"))) {
            if ((-1 == status||1==status)&&(type.equalsIgnoreCase("0")||type.equalsIgnoreCase("9")||type.equalsIgnoreCase("16"))) {
				sql = "SELECT " +
						" COUNT(1) AS \"total\" "+
						"FROM wlyy_outpatient op LEFT JOIN wlyy_consult a  ON a.relation_code = op.id \n" +
@ -2719,8 +2721,15 @@ public class ImService {
				}
				//咨询类型
				if(!StringUtils.isEmpty(type)&&type.equalsIgnoreCase("9")){
					sql +=" AND op.type in (1,2) and op.outpatient_type = 1";
				if(!StringUtils.isEmpty(type)){
					if (type.equalsIgnoreCase("9")){
						sql +=" AND op.type in (1) and op.outpatient_type = 1";
					}else if (type.equalsIgnoreCase("16")){
						sql +=" AND op.type in (2) and op.outpatient_type = 1";
					}else {
						sql +=" AND op.type in (1,2) and op.outpatient_type = 1";
					}
				}
				if (!StringUtils.isEmpty(id)) {
@ -2793,12 +2802,7 @@ public class ImService {
				//咨询类型
				if(!StringUtils.isEmpty(type)&&!type.equalsIgnoreCase("0")){
					if("9".equalsIgnoreCase(type)){
						sql +=" AND a.type in (9,16)" ;
					}else {
						sql +=" AND a.type in ("+type+")" ;
					}
					sql +=" AND a.type in ("+type+")" ;
				}

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

@ -1437,82 +1437,138 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        } else {
            return ObjEnvelop.getError("验证码错误!");
        }
        if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            try {
                List<BasePatientDO> basePatientDOS =basePatientDao.findByMobileAndDel(mobile,"1");
                boolean localFlag = false;
                boolean ykFlag = false;
                String msg = "";
                if (null!=basePatientDOS&&basePatientDOS.size()>0){
                    localFlag = true;
        try {
            List<BasePatientDO> basePatientDOS =basePatientDao.findByMobileAndDel(mobile,"1");
            boolean localFlag = false;
            boolean ykFlag = false;
            String msg = "";
            if (null!=basePatientDOS&&basePatientDOS.size()>0){
                localFlag = true;
                }
                BasePatientDO basePatientDO = new BasePatientDO();
                String r =ykyyService.getRegisterUser(mobile,pw,captcha,"a01522","xmijk","xmijk");
                if (!StringUtils.isEmpty(r)){
                    JSONObject jsonObject = JSONObject.parseObject(r);
                    if (null!=jsonObject.get("code")&&"200".equalsIgnoreCase(jsonObject.get("code").toString())){
                        JSONObject jsonObject1 = JSONObject.parseObject(jsonObject.get("data").toString());
                        basePatientDO.setYktId(jsonObject1.getString("ID"));
                    }else if (null!=jsonObject.get("code")&&"199".equalsIgnoreCase(jsonObject.get("code").toString())){
                        msg = jsonObject.getString("msg");
                        ykFlag = true;
                    }
                }
                basePatientDO.setMobile(mobile);
                String salt = UUID.randomUUID().toString().substring(0,5);
                basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                basePatientDO.setSalt(salt);
                basePatientDO.setDel("1");
                basePatientDO.setEnabled(1);
                basePatientDO.setLocked(0);
                basePatientDO.setCreateTime(new Date());
                basePatientDO.setUpdateTime(new Date());
                BasePatientDO patientDO = basePatientDao.save(basePatientDO);
                if (localFlag&&ykFlag){
                    return ObjEnvelop.getError("该手机号已经注册过");
                }
            }
            BasePatientDO basePatientDO = new BasePatientDO();
            String r =ykyyService.getRegisterUser(mobile,pw,captcha,"a01522","xmijk","xmijk");
            if (!StringUtils.isEmpty(r)){
                JSONObject jsonObject = JSONObject.parseObject(r);
                if (null!=jsonObject.get("code")&&"200".equalsIgnoreCase(jsonObject.get("code").toString())){
                    JSONObject jsonObject1 = JSONObject.parseObject(jsonObject.get("data").toString());
                    basePatientDO.setYktId(jsonObject1.getString("ID"));
                }else if (null!=jsonObject.get("code")&&"199".equalsIgnoreCase(jsonObject.get("code").toString())){
                    msg = jsonObject.getString("msg");
                    ykFlag = true;
                ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
                Map<String, String> parameters = new HashedMap();
                parameters.put("username",patientDO.getMobile());
                parameters.put("grant_type", "ihealthCode");
                TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
                if (authenticatedClient != null) {
                    oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
                }
                OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
                if (token == null) {
                    throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
                }
            }
            basePatientDO.setMobile(mobile);
            String salt = UUID.randomUUID().toString().substring(0,5);
            basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
            basePatientDO.setSalt(salt);
            basePatientDO.setDel("1");
            basePatientDO.setEnabled(1);
            basePatientDO.setLocked(0);
            basePatientDO.setCreateTime(new Date());
            basePatientDO.setUpdateTime(new Date());
            BasePatientDO patientDO = basePatientDao.save(basePatientDO);
            if (localFlag&&ykFlag){
                return ObjEnvelop.getError("该手机号已经注册过");
            }
            ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
                WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
                wlyyUserSimple.setAccessToken(token.getValue());
                wlyyUserSimple.setTokenType(token.getTokenType());
                wlyyUserSimple.setExpiresIn(token.getExpiresIn());
                wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
                wlyyUserSimple.setUser(parameters.get("username"));
                String loginType = parameters.get("login_type");
            Map<String, String> parameters = new HashedMap();
                BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
                userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
            parameters.put("username",patientDO.getMobile());
            parameters.put("grant_type", "ihealthCode");
                baseLoginLogDO.setUserId(wlyyUserSimple.getId());
                baseLoginLogDO.setCreateTime(new Date());
                String userAgent = JSONObject.toJSONString(wlyyUserSimple);
                baseLoginLogDO.setUserAgent(userAgent);
                baseLoginLogDO.setLoginType(loginType);
                baseLoginLogService.save(baseLoginLogDO);
            TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
            if (authenticatedClient != null) {
                oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
            }
            OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
            if (token == null) {
                throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
                return ObjEnvelop.getSuccess("success",wlyyUserSimple);
            }catch (Exception e){
                e.printStackTrace();
            }
        }else {
            try {
                Map<String,Object> rs = registerService.registerPatient(name,mobile,idcard,ssc,pw,openid,wxId,captcha);
                String code = rs.get("code").toString();
                if(!"1".equals(code)){
                    ObjEnvelop objEnvelop = new ObjEnvelop();
                    objEnvelop.setObj(rs);
                    objEnvelop.setStatus(-1);
                    objEnvelop.setMessage(rs.get("mes")+"");
                    return objEnvelop;
                }
            WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
            wlyyUserSimple.setAccessToken(token.getValue());
            wlyyUserSimple.setTokenType(token.getTokenType());
            wlyyUserSimple.setExpiresIn(token.getExpiresIn());
            wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
            wlyyUserSimple.setUser(parameters.get("username"));
            String loginType = parameters.get("login_type");
                BasePatientDO patientDO = (BasePatientDO)rs.get("patient");
            BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
            userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
                ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
            baseLoginLogDO.setUserId(wlyyUserSimple.getId());
            baseLoginLogDO.setCreateTime(new Date());
            String userAgent = JSONObject.toJSONString(wlyyUserSimple);
            baseLoginLogDO.setUserAgent(userAgent);
            baseLoginLogDO.setLoginType(loginType);
            baseLoginLogService.save(baseLoginLogDO);
                Map<String, String> parameters = new HashedMap();
            return ObjEnvelop.getSuccess("success",wlyyUserSimple);
                parameters.put("username",patientDO.getIdcard());
                parameters.put("grant_type", "ihealthCode");
        }catch (Exception e){
            e.printStackTrace();
                TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
                if (authenticatedClient != null) {
                    oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
                }
                OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
                if (token == null) {
                    throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
                }
                WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
                wlyyUserSimple.setAccessToken(token.getValue());
                wlyyUserSimple.setTokenType(token.getTokenType());
                wlyyUserSimple.setExpiresIn(token.getExpiresIn());
                wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
                wlyyUserSimple.setUser(parameters.get("username"));
                String loginType = parameters.get("login_type");
                BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
                userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
                baseLoginLogDO.setUserId(wlyyUserSimple.getId());
                baseLoginLogDO.setCreateTime(new Date());
                String userAgent = JSONObject.toJSONString(wlyyUserSimple);
                baseLoginLogDO.setUserAgent(userAgent);
                baseLoginLogDO.setLoginType(loginType);
                baseLoginLogService.save(baseLoginLogDO);
                return ObjEnvelop.getSuccess("success",wlyyUserSimple);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        return ObjEnvelop.getError("登录失败!");
    }

+ 2 - 2
server/svr-authentication/src/main/java/com/yihu/jw/security/service/RegisterService.java

@ -98,9 +98,9 @@ public class RegisterService {
                wechatDo.setPatientId(temp.getId());
                basePatientWechatDao.save(wechatDo);
            }
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(wxId)&&wxId.equalsIgnoreCase("xm_ykyy_wx")){
            /*if (org.apache.commons.lang3.StringUtils.isNoneBlank(wxId)&&wxId.equalsIgnoreCase("xm_ykyy_wx")){
                ykyyService.registerYkt(temp.getId(),pw,captcha);
            }
            }*/
            rs.put("code","1");
            rs.put("mes","ok");

+ 2 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/service/YkyyService.java

@ -19,6 +19,7 @@ import com.yihu.jw.util.idcard.IdCardUtil;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
import com.yihu.utils.security.MD5;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -232,7 +233,7 @@ public class YkyyService {
     * @param vercode
     * @return
     */
    public String forgetPassword(String tel,String password,String vercode){
    public String   forgetPassword(String tel,String password,String vercode){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("loginid",tel);