Procházet zdrojové kódy

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

Shi Kejing před 4 roky
rodič
revize
e8585ef6fa

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PayInfoNoticeService.java

@ -60,7 +60,7 @@ public class PayInfoNoticeService {
            String idcard = patientDO.getIdcard();
            String phone = patientDO.getMobile();
            if (!StringUtils.isNotBlank(url)){
                url = "https://hlwyy.xmzsh.com/ims-wx/index.html#/returnVisit/prescriptionDetail?outpatientId="+id;
                url = "https://hlwyy.xmzsh.com/hlwyy/ims-wx/#/nucleicTest/detail?id="+id;
            }
            String remark = "结算方式:微信结算" +
                    "点击查看核酸预约开单信息";

+ 62 - 6
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -1,7 +1,6 @@
package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONPObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dict.dao.DictDeptDescDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
@ -81,6 +80,7 @@ import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.utils.CheckSumBuilder;
import com.yihu.jw.utils.GenerateUserSig;
import com.yihu.jw.utils.PinYinUtils;
import com.yihu.jw.utils.Pkis.PKIService_PortType;
import com.yihu.jw.utils.Pkis.PKIService_ServiceLocator;
import com.yihu.jw.utils.WebserviceUtil;
@ -93,6 +93,7 @@ import com.yihu.jw.wechat.service.BaseSensitiveFilterWordsService;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.yihu.jw.yx.dao.YxTokenMappingDao;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.pinyin.PinyinUtil;
import com.yihu.utils.security.MD5;
import com.ylzinfo.ehc.EhcHandler;
import com.ylzinfo.ehc.common.utils.DateUtils;
@ -9330,13 +9331,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    public MixEnvelop selectByUrlHsjc(Integer id,String wxId) throws Exception {
    public MixEnvelop selectByUrlHsjc(Integer id,String wxId,String channel) throws Exception {
        WxWechatDO wxWechatDO = wechatDao.findById(wxId);
        if (wxWechatDO == null) {
            throw new Exception("微信配置不存在!");
        }
        BaseNatAppointmentDO natAppointmentDO = baseNatAppointmentDao.findOne(id);
        BasePatientDO patientDO = basePatientDao.findById(natAppointmentDO.getPatientId());
        List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wxId, natAppointmentDO.getPatientId());
        if (patientWechatDos == null || patientWechatDos.size() == 0) {
            throw new Exception("openid不存在!");
@ -9350,7 +9352,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if (!StringUtils.isNoneBlank(idcard)) {
            throw new Exception("就诊卡不存在!");
        }
        String url = ylzPayService.createSicardPayUrl(wxWechatDO.getAppOriginId(), patientWechatDo.getOpenid(), idcard, "WX");
        String url = null;
        if (StringUtils.isNoneBlank(channel)&&channel.equalsIgnoreCase("ALI")){
            url = ylzPayService.createSicardPayUrl(wxWechatDO.getAppOriginId(), patientDO.getAlipayId(), idcard, "ALI");
        }else {
            url = ylzPayService.createSicardPayUrl(wxWechatDO.getAppOriginId(), patientWechatDo.getOpenid(), idcard, "WX");
        }
        com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(url);
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find, object);
    }
@ -10530,6 +10537,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                            jsondate.put("serialNo",registerDO.getRegisterNo());
                            jsondate.put("dept",map.get("deptCode").toString());
                            jsondate.put("doctor",map.get("doctorMappingCode").toString());
                            baseNatAppointmentDO.setRegisterNo(registerDO.getRegisterNo());
                            baseNatAppointmentDO.setDoctorId(map.get("doctorMappingCode").toString());
                            baseNatAppointmentDO.setDoctorName(map.get("doctorName").toString());
                        }else {
@ -10554,6 +10562,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                            jsondate.put("serialNo",serialNo);
                            jsondate.put("dept",map.get("deptCode").toString());
                            jsondate.put("doctor",map.get("doctorMappingCode").toString());
                            baseNatAppointmentDO.setRegisterNo(serialNo);
                            //存储就诊记录
                            WlyyPatientRegisterDO registerDO = new WlyyPatientRegisterDO();
                            // 存储挂号医生与挂号科室
@ -10651,13 +10660,15 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    wlyyHttpLogDao.save(log);
                    if ("0".equals(prers)) {
                        String realOrder = jsonObject.getString("@real_order");
                        String voucherNo = jsonObject.getString("@xtgzh0");
                        baseNatAppointmentDO.setRealOrder(realOrder);
                        baseNatAppointmentDO.setIsSuccess("1");
                        baseNatAppointmentDO.setVoucherNo(voucherNo);
                        baseNatAppointmentDao.save(baseNatAppointmentDO);
                        String recipeTime = DateUtil.dateToStr(new Date(), "yyyyMMddHHmmss");
                        String applyDepaName = map.get("deptName").toString();
                        String voucherNo = jsonObject.getString("@xtgzh0");
                        String applyDoctorName = map.get("doctorName").toString();
                        BasePatientDO patientDO = basePatientDao.findById(patientId);
                        String userName = null;
@ -10677,7 +10688,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        net.sf.json.JSONObject res = jsonObject1.getJSONObject("resquest");
                        logger.info("获取待结算数据 res: " + res.toString());
                        String rsCode = res.getString("@RESULT");
                        String free= "";
                        String free= 0+"";
                        if ("0".equals(rsCode)) {
                            free = res.getString("@total_charge");
                        }
@ -10703,7 +10714,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return returnMap;
    }
    public MixEnvelop getNatRecords(String patientId,Integer page ,Integer pageSize){
    public MixEnvelop getNatRecords(String patientId,String id,Integer page ,Integer pageSize){
        String sql = "select t.name as \"name\"," +
                "t.card_no as \"cardNo\"," +
                "t.card_type as \"cardType\"," +
@ -10713,12 +10724,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "t.is_success as \"isSuccess\"," +
                "t.create_time as \"createTime\"," +
                "t.pay_status as \"payStatus\"," +
                "t.medicare as \"medicare\","+
                "t.voucher_no as \"voucherNo\","+
                "t.id as \"id\"," +
                "t.appointment_time as \"appointmentTime\" " +
                " from base_nat_appointment t where 1=1 ";
        if (StringUtils.isNoneBlank(patientId)){
            sql+=" and t.patient_id ='"+patientId+"'";
        }
        if (StringUtils.isNoneBlank(id)){
            sql+=" and t.id ='"+id+"'";
        }
        List<Map<String ,Object>> list = hibenateUtils.createSQLQuery(sql,page,pageSize);
        List<Map<String ,Object>> listCount = hibenateUtils.createSQLQuery(sql);
        MixEnvelop mixnvelop = new MixEnvelop();
@ -10745,6 +10761,19 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            sql+="select  t.street_name as \"streetName\" from base_address_mapping t  where t.town_name ='"+parentName+"' and street_name <> '' and street_name is not null";
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
        list.stream().forEach(one->{
            String firstSpell = null;
            if ("1".equalsIgnoreCase(addressFlag)){
                firstSpell = PinYinUtils.getFirstSpell(one.get("provinceName").toString());
            }else if("2".equalsIgnoreCase(addressFlag)){
                firstSpell = PinYinUtils.getFirstSpell(one.get("cityName").toString());
            }else if("3".equalsIgnoreCase(addressFlag)){
                firstSpell = PinYinUtils.getFirstSpell(one.get("townName").toString());
            }else if("4".equalsIgnoreCase(addressFlag)){
                firstSpell = PinYinUtils.getFirstSpell(one.get("streetName").toString());
            }
            one.put("firstSpell",firstSpell);
        });
        return list;
    }
@ -10773,6 +10802,33 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                            baseNatAppointmentDO.setCancelTime(new Date());
                            baseNatAppointmentDO.setCancelBy(patientId);
                            baseNatAppointmentDao.save(baseNatAppointmentDO);
                            //删除处方
                            logger.info("删除处方开始");
                            net.sf.json.JSONObject jsondate = new JSONObject();
                            jsondate.put("checkPart","鼻/咽拭子");
                            jsondate.put("cardNo",baseNatAppointmentDO.getMedicare());
                            jsondate.put("chargeFlag","2");
                            jsondate.put("chargeCode","361322");
                            jsondate.put("icdCode","Z00.000");
                            jsondate.put("socialNo",baseNatAppointmentDO.getCardNo());
                            jsondate.put("tellPhone",baseNatAppointmentDO.getMobile());
                            jsondate.put("address1",baseNatAppointmentDO.getProvinceName());
                            jsondate.put("address2",baseNatAppointmentDO.getCityName());
                            jsondate.put("address3",baseNatAppointmentDO.getTownName());
                            jsondate.put("address4",baseNatAppointmentDO.getStreetName());
                            jsondate.put("address5",2);
                            jsondate.put("area",baseNatAppointmentDO.getAddress());
                            jsondate.put("winNo",6);
                            jsondate.put("target",2);
                            jsondate.put("quantity",1);
                            jsondate.put("serialNo",baseNatAppointmentDO.getRegisterNo());
                            jsondate.put("dept",baseNatAppointmentDO.getDept());
                            jsondate.put("doctor",baseNatAppointmentDO.getDoctorId());
                            jsondate.put("realOrder",baseNatAppointmentDO.getRealOrder());
                            JSONArray array = new JSONArray();
                            array.add(jsondate);
                            JSONObject object1  = entranceService.BS10112(array.toString(),demoFlag);
                            logger.info("删除处方结束");
                        }
                    }

+ 80 - 2
business/base-service/src/main/java/com/yihu/jw/utils/PinYinUtils.java

@ -5,12 +5,27 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;
/**
 * @author huangwenjie
 * @date 2020/3/13 09:32
 */
public class PinYinUtils {
	public static final Map<String, String> multiToneMap = new HashMap<>();
	static {
		multiToneMap.put("重庆", "C");
		multiToneMap.put("广东", "G");
		multiToneMap.put("广西", "G");
		multiToneMap.put("厦门", "X");
	}
	 //将中文转换为英文
	public static String getEname(String name) throws  Exception
    {
@ -55,8 +70,71 @@ public class PinYinUtils {
		
		return newstr.toString();
	}
	/**
	 * 获取汉字串拼音首字母,英文字符不变
	 *
	 * @param chinese 汉字串
	 * @return 汉语拼音首字母
	 */
	public static String getFirstSpell(String chinese) {
		StringBuffer pybf = new StringBuffer();
		char[] arr = chinese.toCharArray();
		HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
		defaultFormat.setCaseType(HanyuPinyinCaseType.UPPERCASE);
		defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
		//只取第一个汉字的拼音
		if (arr[0] > 128) {
			try {
				String[] temp = PinyinHelper.toHanyuPinyinStringArray(arr[0], defaultFormat);
				// 长度大于1,表明是多音字,往后多取一个字或两个字,取词组,取匹配多音字属性文件确定最终读音
				if (temp != null && temp.length > 1 && !temp[0].equalsIgnoreCase(temp[1])) {
					String finalLetter = getOrgNameMultiTone(chinese);
					if(StringUtils.isEmpty(finalLetter)){
						System.out.print(arr[0]);
						System.out.print(arr[1]+":[");
						for(int i=0; i< temp.length-1; i++)
							System.out.print(temp[i]+", ");
						System.out.println(temp[temp.length-1]+"]");
						pybf.append(temp[0].charAt(0));
					}else{
						pybf.append(finalLetter.charAt(0));
					}
				} else {
					pybf.append(temp[0].charAt(0));
				}
			} catch (BadHanyuPinyinOutputFormatCombination e) {
				e.printStackTrace();
			}
		} else {
			pybf.append(arr[0]);
		}
		return pybf.toString().replaceAll("\\W", "").trim();
	}
	/**
	 * 获取医院多音字的读音,取词组,最多取三个
	 *
	 * @param chinesePhrase 中文词组
	 * @return
	 */
	public static String getOrgNameMultiTone(String chinesePhrase) {
		try{
			if (multiToneMap.containsKey(chinesePhrase.substring(0, 1))) {
				return multiToneMap.get(chinesePhrase.substring(0, 1));
			} else if (multiToneMap.containsKey(chinesePhrase.substring(0, 2))) {
				return multiToneMap.get(chinesePhrase.substring(0, 2));
			} else if (multiToneMap.containsKey(chinesePhrase.substring(0, 3))) {
				return multiToneMap.get(chinesePhrase.substring(0, 3));
			}
		}catch (Exception e){
		}
		return null;
	}
	public static void main(String[] args)  throws  Exception{
		System.out.println(getUpEname("李宇春"));
		
		System.out.println(getFirstSpell("广西"));
	}
}

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -245,6 +245,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    private String openid;
    private Date openidTime;
    private String cardType;
    private String alipayId;//支付宝id
    public String getCardType() {
        return cardType;
@ -688,4 +689,13 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public void setOnline(String online) {
        this.online = online;
    }
    @Column(name = "alipay_id")
    public String getAlipayId() {
        return alipayId;
    }
    public void setAlipayId(String alipayId) {
        this.alipayId = alipayId;
    }
}

+ 18 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/BaseNatAppointmentDO.java

@ -52,6 +52,8 @@ public class BaseNatAppointmentDO extends IntegerIdentityEntity {
    private String chargeCode;
    private String icdCode;
    private String doctorName;
    private String voucherNo;
    private String registerNo;
    public String getMedicare() {
        return medicare;
@ -381,4 +383,20 @@ public class BaseNatAppointmentDO extends IntegerIdentityEntity {
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getVoucherNo() {
        return voucherNo;
    }
    public void setVoucherNo(String voucherNo) {
        this.voucherNo = voucherNo;
    }
    public String getRegisterNo() {
        return registerNo;
    }
    public void setRegisterNo(String registerNo) {
        this.registerNo = registerNo;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistPatientRelationDO.java

@ -29,7 +29,6 @@ public class SpecialistPatientRelationDO extends UuidIdentityEntity implements S
    private String doctor;//专科医生
    @Column(name = "doctor_name")
    @Convert(converter = StringFStringEncryptConverter.class)
    private String doctorName;//专科医生姓名
    @Column(name = "patient")
@ -127,6 +126,7 @@ public class SpecialistPatientRelationDO extends UuidIdentityEntity implements S
        this.doctor = doctor;
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getDoctorName() {
        return doctorName;
    }

+ 119 - 6
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -57,11 +57,13 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
    private static final String DEFAULT_PATIENT_INSERT_STATEMENT =
            "INSERT into base_patient (id,photo,idcard,password,salt,name,birthday,sex,mobile," +
                    "province_code,province_name,city_code,city_name,town_code,town_name,street_code,street_name,address," +
                    "del,locked,enabled,login_failure_count,login_date,card_type) " +
                    " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
                    "del,locked,enabled,login_failure_count,login_date,card_type,alipay_id) " +
                    " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
    private static final String PATIENT_INSERT_WEHCAT = "insert into base_patient_wechat (id,wechat_id,patient_id,openid,create_time) values(?,?,?,?,?)";
    private static final String UPDATE_PATIENT_CARD_TYPE = "update base_patient set card_type = ?,alipay_id = ? where id = ?";
    private static final String BespeakRegist = "bespeakRegist:";
@ -144,7 +146,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
     * 用户登录判读接口
     * 判断loginType查找用户信息
     * 用户类型 1或默认为user,2:医生登录,3:患者登录,4:i健康系统-患者登录(i健康患者可以不注册直接登录互联网系统,首次使用,根据i健康居民code去i健康查询居民信息,然后保存到base.base_patient)
     *
     * 用户类型 5 中山医院支付宝-患者登录(可以不注册直接登录)
     * @param username
     * @return
     */
@ -229,7 +231,9 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                                        0,
                                        1,
                                        0,
                                        new Date()
                                        new Date(),
                                        null,
                                        null
                                }
                        );
                    }catch (Exception e){
@ -331,7 +335,8 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                                            1,
                                            0,
                                            new Date(),
                                            idtype
                                            idtype,
                                            null
                                    }
                            );
                        }catch (Exception e){
@ -379,6 +384,110 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                    familyMemberDao.save(basePatientFamilyMemberDO);
                }
            }
        }else if("5".equals(loginType)){
            //中山医院支付宝-患者登录(可以不注册直接登录)
            // 姓名,电话,证件类型,证件号和⽀付宝open_id以冒号组合,如:
            //张三:13012341234:01:350000200112231234:123456
            String data[] = username.split(":");
            String name = data[0];
            username = data[1];
            String idcard = data[3];
            users = this.getJdbcTemplate().query(DEFAULT_PATIENT_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserDetails.class),username,idcard);
            if (null == users || users.size() == 0) {
                String patientId = UUID.randomUUID().toString();
                String salt = randomString(5);
                String pw = idcard.substring(idcard.length()-6);
                String password = MD5.md5Hex(pw + "{" + salt + "}");
                int sex = 0;
                try {
                    sex = Integer.parseInt(IdCardUtil.getSexForIdcard_new(idcard));
                    this.getJdbcTemplate().update(DEFAULT_PATIENT_INSERT_STATEMENT,
                            new Object[]{patientId,
                                    null,
                                    idcard,
                                    password,
                                    salt,
                                    name,
                                    IdCardUtil.getBirthdayForIdcard(idcard),
                                    sex,
                                    username,
                                    null,
                                    null,
                                    null,
                                    null,
                                    null,
                                    null,
                                    null,
                                    null,
                                    null,
                                    1,
                                    0,
                                    1,
                                    0,
                                    new Date(),
                                    data[2],
                                    data[4]
                            }
                    );
                }catch (Exception e){
                    logger.error("将中山医院支付宝登录数据同步到互联网医院居民表失败:" + e.getMessage());
                    return users;
                }
                try {
                    this.getJdbcTemplate().update(PATIENT_INSERT_WEHCAT,
                            new Object[]{
                                    UUID.randomUUID().toString(),
                                    getWechatId(),
                                    patientId,
                                    getOpenid(),
                                    new Date()
                            }
                    );
                }catch (Exception e){
                    logger.error("将中山医院支付宝登录数据同步到互联网医院居民微信关联表失败:" + e.getMessage());
                    return users;
                }
                WlyyUserDetails user = new WlyyUserDetails();
                user.setName(name);
                user.setPassword(password);
                if(sex == 1){
                    user.setGender(WlyyUserDetails.Gender.male);
                }else if(sex == 2){
                    user.setGender(WlyyUserDetails.Gender.female);
                }
                user.setId(username);
                user.setIdcard(idcard);
                user.setMobile(username);
                user.setEnabled(true);
                user.setLocked(false);
                user.setLockedDate(null);
                users.add(user);
                BasePatientDO patientDO = patientDao.findByIdcardAndDel(idcard,"1");
                WlyyPatientFamilyMemberDO basePatientFamilyMemberDO = familyMemberDao.findFamilyMemberByPatientAndRelationCode(patientDO.getId(),"7");
                if (basePatientFamilyMemberDO==null){
                    basePatientFamilyMemberDO = new WlyyPatientFamilyMemberDO();
                    basePatientFamilyMemberDO.setPatient(patientDO.getId());
                    basePatientFamilyMemberDO.setFamilyRelation("7");
                    basePatientFamilyMemberDO.setFamilyRelationName("自己");
                    basePatientFamilyMemberDO.setCardType("身份证");
                    basePatientFamilyMemberDO.setCardNo(patientDO.getIdcard());
                    basePatientFamilyMemberDO.setCreateTime(new Date());
                    basePatientFamilyMemberDO.setUpdateTime(new Date());
                    basePatientFamilyMemberDO.setIsAuthorize(1);
                    basePatientFamilyMemberDO.setIsDel(1);
                    basePatientFamilyMemberDO.setFamilyMember(patientDO.getId());
                    familyMemberDao.save(basePatientFamilyMemberDO);
                }
            }else{
                this.getJdbcTemplate().update(UPDATE_PATIENT_CARD_TYPE,
                        new Object[]{
                                data[2],
                                data[4],
                                users.get(0).getId()
                        }
                );
            }
        }
        return users;
    }
@ -533,6 +642,10 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
            //更新登录时间
            this.getJdbcTemplate().update("update base_patient p set p.login_failure_count = 0, p.login_date = ? where p.mobile = ? or p.idcard = ?", new Date(), username, getIdcard());
            users = this.getJdbcTemplate().query(DEFAULT_PATIENT_DETAILS_IDCARD_STATEMENT, new BeanPropertyRowMapper(WlyyUserSimple.class), getIdcard());
        }else if("5".equals(loginType)){
            //更新登录时间
            this.getJdbcTemplate().update("update base_patient p set p.login_failure_count = 0, p.login_date = ? where p.mobile = ? or p.idcard = ?", new Date(), username, username);
            users = this.getJdbcTemplate().query(DEFAULT_PATIENT_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserSimple.class), username,username);
        }
        logger.info("login:登录进入6");
@ -612,7 +725,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
    public boolean setRolePhth(String loginType, OAuth2AccessToken token, String id, StringRedisTemplate redisTemplate) {
        if (org.apache.commons.lang.StringUtils.isBlank(loginType) || "1".equals(loginType) || "2".equals(loginType) || "3".equals(loginType) || "4".equals(loginType)) { //1或默认查找user表,为平台管理员账号
        if (org.apache.commons.lang.StringUtils.isBlank(loginType) || "1".equals(loginType) || "2".equals(loginType) || "3".equals(loginType) || "4".equals(loginType)|| "5".equals(loginType)) { //1或默认查找user表,为平台管理员账号
            String key = "wlyy2:auth:token:" + token.getValue();
            redisTemplate.opsForValue().set(key, "/**");
            redisTemplate.expire(key, token.getExpiresIn(), TimeUnit.SECONDS);

+ 68 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java

@ -2,6 +2,7 @@ package com.yihu.jw.security.oauth2.provider;
import com.yihu.jw.security.core.userdetails.SaltUser;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import com.yihu.jw.security.utils.AES;
import org.springframework.security.authentication.*;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
@ -22,7 +23,9 @@ import org.springframework.security.oauth2.provider.token.AbstractTokenGranter;
import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;
import org.springframework.util.Assert;
import java.util.*;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
 * Token授权器。
@ -96,6 +99,14 @@ public class WlyyTokenGranter implements TokenGranter {
                        requestFactory,
                        userDetailsService
                ));
        tokenGranters.put(AlipayTokenGranter.GRANT_TYPE,
                new AlipayTokenGranter(
                        authenticationManager,
                        tokenServices,
                        clientDetailsService,
                        requestFactory,
                        userDetailsService
                ));
    }
    public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
@ -444,6 +455,62 @@ public class WlyyTokenGranter implements TokenGranter {
                throw new InvalidGrantException("User account is locked");
            }
//            parameters.put("password",userDetails.getPassword());
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username,userDetails.getPassword(),  this.authoritiesMapper.mapAuthorities(userDetails.getAuthorities()));
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
            OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest);
            return new OAuth2Authentication(storedOAuth2Request, userAuth);
        }
    }
    /**
     * 支付宝登录
     */
    public static class AlipayTokenGranter extends AbstractTokenGranter {
        private static final String GRANT_TYPE = "alipay";
        private final AuthenticationManager authenticationManager;
        private final UserDetailsService userDetailsService;
        private GrantedAuthoritiesMapper authoritiesMapper = new NullAuthoritiesMapper();
        public AlipayTokenGranter(AuthenticationManager authenticationManager,
                                                  AuthorizationServerTokenServices tokenServices,
                                                  ClientDetailsService clientDetailsService,
                                                  OAuth2RequestFactory requestFactory,
                                                  UserDetailsService userDetailsService) {
            this(authenticationManager, tokenServices, clientDetailsService, requestFactory, userDetailsService, GRANT_TYPE);
        }
        protected AlipayTokenGranter(AuthenticationManager authenticationManager,
                                                     AuthorizationServerTokenServices tokenServices,
                                                     ClientDetailsService clientDetailsService,
                                                     OAuth2RequestFactory requestFactory,
                                                     UserDetailsService userDetailsService,
                                                     String grantType) {
            super(tokenServices, clientDetailsService, requestFactory, grantType);
            this.authenticationManager = authenticationManager;
            this.userDetailsService = userDetailsService;
        }
        @Override
        protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest tokenRequest) {
            Map<String, String> parameters = new LinkedHashMap<String, String>(tokenRequest.getRequestParameters());
            String encdata = parameters.get("encdata");
            encdata = AES.decrypt(encdata);
            //姓名,电话,证件类型,证件号和⽀付宝open_id以冒号组合,如:
            //张三:13012341234:01:350000200112231234:123456
            String data[] = encdata.split(":");
            String username = data[1];
            SaltUser userDetails = (SaltUser)userDetailsService.loadUserByUsername(encdata);
            if (!userDetails.isEnabled()) {
                throw new InvalidGrantException("User is disabled");
            }
            if (!userDetails.isAccountNonLocked()) {
                throw new InvalidGrantException("User account is locked");
            }
//            parameters.put("password",userDetails.getPassword());
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username,userDetails.getPassword(),  this.authoritiesMapper.mapAuthorities(userDetails.getAuthorities()));
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);

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

@ -192,15 +192,25 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        }
        logger.info("login:登录进入2");
        String flag = parameters.get("flag");
        String username = parameters.get("username");
        if (StringUtils.isEmpty(username)) {
        if (StringUtils.isEmpty(username)&&StringUtils.isEmpty(flag)) {
            throw new InvalidRequestException("username");
        }
        String client_id = parameters.get("client_id");
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        if (StringUtils.isEmpty(parameters.get("captcha"))) {
        if("alipay".equals(flag)){
            //支付宝登录
            parameters.put("grant_type", flag);
            String encdata = parameters.get("encdata");
            encdata = AES.decrypt(encdata);
            String data[] = encdata.split(":");
            username = data[1];
            parameters.put("username", username);
        }else if (StringUtils.isEmpty(parameters.get("captcha"))) {
            parameters.put("grant_type", "password");
            //解密密码
            if (parameters.get("password") != null) {
@ -278,6 +288,14 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        return getResponse(wlyyUserSimple);
    }
    public static void main(String[] args) throws Exception{
        String encodedText = "OiF6sj1G11jLgHrvgPVUilE9IGeqgNZs2EFh%2FiCyFd9uhZqC5vl%2BwyrVXVM9jAEgRvxbi3jYK%2BmFvmRa5s1EQg%3D%3D";
        encodedText = URLDecoder.decode(encodedText,"utf-8");
        String str =  AES.decrypt("3bdc154ed1e44a9c9f44451a16d8e0aa",encodedText);
        System.out.println(str);
    }
    /**
     * 单点登陆第二步 - token验证
     *

+ 17 - 4
server/svr-authentication/src/main/java/com/yihu/jw/security/utils/AES.java

@ -1,18 +1,31 @@
package com.yihu.jw.security.utils;
import org.apache.commons.lang3.StringUtils;
import sun.misc.BASE64Decoder;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.lang3.StringUtils;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
/**
 * Created by Trick on 2020/2/24.
 */
public class AES {
    /**
     * 中山支付宝加密密钥
     */
    private static final String key = "3bdc154ed1e44a9c9f44451a16d8e0aa";
    public static String decrypt(String strIn){
        try {
            return decrypt(key,strIn);
        }catch (Exception e){
            e.printStackTrace();
        }
        return strIn;
    }
    //AES解密方法
    public static String decrypt(String strKey, String strIn) throws Exception {
        if(StringUtils.isEmpty(strKey)|| StringUtils.isEmpty(strIn)){

+ 7 - 7
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -958,14 +958,12 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                                    String name= natAppointmentDO.getName();
                                    String idcard = natAppointmentDO.getCardNo();
                                    String mobile = natAppointmentDO.getMobile();
                                    String url = "https://hlwyy.xmzsh.com";
                                    String url = "https://hlwyy.xmzsh.com/hlwyy/ims-wx/#/nucleicTest/detail?id="+natAppointmentDO.getId();
                                    String date = DateUtil.dateToStrLong(natAppointmentDO.getAppointmentTime());
                                    String first = "尊敬的用户"+name+",您已完成线上自助核酸检测开单预约";
                                    String contentMsg = "申请人:"+name+";预约时间:"+date+";发票流水号:"+voucherNo;
                                    String remark="<div style=\"color:#ff4949;\">\n" +
                                            "        <p>备注:1、请您持核酸开单预约信息和发票流水号、医保卡/就诊卡/电子健康卡,提前15分钟至我院五号楼北侧(急诊部后侧)核酸检测点?号取管窗口绑定检测。</p >\n" +
                                            "<p>2、核酸检测标本采集24小时后出具报告。请关注厦门大学附属中山医院微信公众号查询;如需打印,请至厦门大学附属中山医院核酸检测点自助机打印。</p >\n" +
                                            "    </div>";
                                    String contentMsg = "申请人:"+name+";预约时间:"+date+";发票流水号:"+waitPayDetailVO.getRecipeNo();
                                    String remark="备注:1、请您持核酸开单预约信息和发票流水号、医保卡/就诊卡/电子健康卡,提前15分钟至我院五号楼北侧(急诊部后侧)核酸检测点?号取管窗口绑定检测。" +
                                            "2、核酸检测标本采集24小时后出具报告。请关注厦门大学附属中山医院微信公众号查询;如需打印,请至厦门大学附属中山医院核酸检测点自助机打印。";
                                    String responseMsg="";
                                    if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
                                        responseMsg = entranceService.ehospitalNotice(
@ -1471,13 +1469,15 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "查询预约记录", notes = "查询预约记录")
    public MixEnvelop getNatRecords(@ApiParam(name = "patientId", value = "居民id")
                                        @RequestParam(value = "patientId", required = false)String patientId,
                                    @ApiParam(name = "id", value = "预约id")
                                    @RequestParam(value = "id", required = false)String id,
                                    @ApiParam(name = "page", value = "页数")
                                    @RequestParam(value = "page", required = false)Integer page,
                                    @ApiParam(name = "pageSize", value = "每页大小")
                                        @RequestParam(value = "pageSize", required = false)Integer pageSize) {
        return  prescriptionService.getNatRecords(patientId,page,pageSize);
        return  prescriptionService.getNatRecords(patientId,id,page,pageSize);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findBaseAddress)
    @ApiOperation(value = "查询地址", notes = "查询地址")

+ 4 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -2171,11 +2171,13 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "oupatientId", value = "oupatientId", required = false)
            @RequestParam(required = false)String oupatientId,
            @ApiParam(name = "flag", value = "flag", required = false)
            @RequestParam(required = false)String flag) throws Exception {
            @RequestParam(required = false)String flag,
            @ApiParam(name = "channel", value = "WX、ALI", required = false)
            @RequestParam(required = false)String channel) throws Exception {
        try {
            if (StringUtils.isNoneBlank(flag)){
                Integer id = Integer.parseInt(oupatientId);
                return ObjEnvelop.getSuccess("ok",prescriptionService.selectByUrlHsjc(id,wxId));
                return ObjEnvelop.getSuccess("ok",prescriptionService.selectByUrlHsjc(id,wxId,channel));
            }else {
                return ObjEnvelop.getSuccess("ok",prescriptionService.selectByUrl(oupatientId,prescriptionId,wxId));
            }

+ 81 - 46
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java

@ -51,6 +51,8 @@ public class SpecialistService{
    private JdbcTemplate jdbcTemplate;
    @Value("${basedb.name}")
    private String basedb;
    @Value("${encrypt.key}")
    private String key;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
@ -73,16 +75,16 @@ public class SpecialistService{
        String sql = "SELECT " +
                " r.id, " +
                " r.doctor, " +
                " r.doctor_name AS doctor_name, " +
                " CAST(AES_DECRYPT(from_base64(r.doctor_name), '" + key + "') AS char) AS doctor_name, " +
                " r.saas_id AS sassId, " +
                " r.patient, " +
                " r.patient_name AS patient_name, " +
                " CAST(AES_DECRYPT(from_base64(r.patient_name), '" + key + "') AS char)  AS patient_name, " +
                " r.health_doctor AS healthDoctor, " +
                " r.health_doctor_name AS healthDoctorName, " +
                " CAST(AES_DECRYPT(from_base64(r.health_doctor_name), '" + key + "') AS char) AS healthDoctorName, " +
                " r.sign_code AS signCode, " +
                " r.sign_year AS signYear, " +
                " r.sign_doctor AS sign_doctor, " +
                " r.sign_doctor_name AS signDoctorName, " +
                " CAST(AES_DECRYPT(from_base64(r.sign_doctor_name), '" + key + "') AS char) AS signDoctorName, " +
                " r.create_time AS createTime," +
                " r.status " +
                "FROM " +
@ -134,7 +136,7 @@ public class SpecialistService{
    public MixEnvelop<PatientRelationVO, PatientRelationVO> findNoLabelPatientRelation(String doctor){
        String sql ="SELECT " +
                " r.patient, " +
                " r.patient_name AS patientName, " +
                " CAST(AES_DECRYPT(from_base64(r.patient_name), '" + key + "') AS char)  AS patientName, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                " p.photo, " +
                " rd.create_time AS createTime ," +
@ -174,7 +176,7 @@ public class SpecialistService{
    public MixEnvelop<PatientRelationVO, PatientRelationVO> findPatientRelatioByAssistant(String doctor , String assistant, Integer page, Integer size){
        String sql ="SELECT " +
                " r.patient, " +
                " r.patient_name AS patientName, " +
                " CAST(AES_DECRYPT(from_base64(r.patient_name), '" + key + "') AS char)  AS patientName, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                " p.photo ," +
                " p.sex," +
@ -205,7 +207,7 @@ public class SpecialistService{
    public MixEnvelop<PatientLabelVO, PatientLabelVO> getPatientByLabel(String doctor, String labelType,String teamCode, String labelCode, Integer page, Integer size,String shareDoctor){
        String sql="SELECT " +
                " p. NAME, " +
                " CAST(AES_DECRYPT(from_base64(s.patient_name), '" + key + "') AS char)  AS name, " +
                " p. CODE, " +
                " p.sex," +
                " IFNULL( " +
@ -221,7 +223,8 @@ public class SpecialistService{
                " lb.labelName as health, " +
                " lb.label AS healthcode ," +
                " s.health_assistant AS healthAssistant," +
                " s.health_assistant_name AS healthAssistantName," +
                " CAST(AES_DECRYPT(from_base64(s.health_assistant_name), '" + key + "') AS char)  AS healthAssistantName, " +
//                " s.health_assistant_name AS healthAssistantName," +
                " s.is_manage AS isManage," +
                " s.id AS specialCode" +
                " FROM " +
@ -250,7 +253,8 @@ public class SpecialistService{
        if("7".equals(labelType)){
            sql = "SELECT " +
                    "c.CODE," +
                    "c.NAME," +
                    " CAST(AES_DECRYPT(from_base64(a.patient_name), '" + key + "') AS char)  AS name, " +
//                    "c.NAME," +
                    "c.sex," +
                    "IFNULL(YEAR (from_days(datediff(now(),c.birthday))),'未知') age," +
                    "c.photo,b.disease AS label," +
@ -258,7 +262,8 @@ public class SpecialistService{
                    "d.label_name AS health," +
                    "d.label AS healthcode," +
                    "a.health_assistant AS healthAssistant," +
                    "a.health_assistant_name AS healthAssistantName, " +
                    " CAST(AES_DECRYPT(from_base64(a.health_assistant_name), '" + key + "') AS char)  AS healthAssistantName, " +
//                    "a.health_assistant_name AS healthAssistantName, " +
                    "a.is_manage AS isManage, " +
                    "a.id AS specialCode " +
                    "FROM wlyy_specialist.wlyy_specialist_patient_relation a " +
@ -277,12 +282,14 @@ public class SpecialistService{
        if("pending".equals(labelType)){
            sql = "SELECT " +
                    "c.CODE," +
                    "c.NAME," +
                    " CAST(AES_DECRYPT(from_base64(a.patient_name), '" + key + "') AS char)  AS name, " +
//                    "c.NAME," +
                    "c.sex," +
                    "IFNULL(YEAR (from_days(datediff(now(),c.birthday))),'未知') age," +
                    "c.photo," +
                    "a.health_assistant AS healthAssistant," +
                    "a.health_assistant_name AS healthAssistantName, " +
                    " CAST(AES_DECRYPT(from_base64(a.health_assistant_name), '" + key + "') AS char)  AS healthAssistantName, " +
//                    "a.health_assistant_name AS healthAssistantName, " +
                    "a.is_manage AS isManage " +
                    "FROM wlyy_specialist.wlyy_specialist_patient_relation a " +
                    "JOIN "+basedb+".wlyy_patient c ON a.patient=c.CODE " +
@ -340,7 +347,8 @@ public class SpecialistService{
    public MixEnvelop<PatientRelationVO, PatientRelationVO> getDoctorPatientByName(String doctor, String nameKey,String teamCode, Integer page, Integer size){
        String sql ="SELECT " +
                " p.code AS patient, " +
                " p.`name` AS patientName, " +
                " CAST(AES_DECRYPT(from_base64(r.patient_name), '" + key + "') AS char)  AS patientName, " +
//                " p.`name` AS patientName, " +
                " p.photo, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                " p.sex ," +
@ -364,7 +372,7 @@ public class SpecialistService{
                " r.doctor IN ( SELECT m.doctor_code FROM wlyy.wlyy_admin_team_member m WHERE m.team_id ='" +teamCode+
                "' ) " +
                " AND r.status >=0  AND r.sign_status >0 " +
                " AND r.patient_name LIKE '%"+nameKey+"%' "+
                " AND CAST(AES_DECRYPT(from_base64 (r.patient_name),'" + key + "') AS CHAR) LIKE '%"+nameKey+"%' "+
                " LIMIT "+(page-1)*size+","+size;
        List<PatientRelationVO> patientRelationVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientRelationVO.class));
@ -376,7 +384,8 @@ public class SpecialistService{
    public MixEnvelop<PatientRelationVO, PatientRelationVO> getDoctorPatientByNameOrIdCard(String doctor, String filter,String teamCode, Integer page, Integer size){
        String sql ="SELECT " +
                " p.code AS code, " +
                " p.`name` AS name, " +
                " CAST(AES_DECRYPT(from_base64(r.patient_name), '" + key + "') AS char)  AS patientName, " +
//                " p.`name` AS name, " +
                " p.photo, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                " p.sex ," +
@ -401,7 +410,7 @@ public class SpecialistService{
                " r.doctor IN ( SELECT m.doctor_code FROM wlyy.wlyy_admin_team_member m WHERE m.team_id ='" +teamCode+
                "' ) " +
                " AND r.status >=0  AND r.sign_status >0 " +
                " AND (r.patient_name LIKE '%"+filter+"%' OR p.idcard LIKE '%"+filter+"%') "+
                " AND (CAST(AES_DECRYPT(from_base64 (r.patient_name),'" + key + "') AS CHAR) LIKE '%"+filter+"%' OR p.idcard LIKE '%"+filter+"%') "+
                " LIMIT "+(page-1)*size+","+size;
        List<PatientRelationVO> patientRelationVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientRelationVO.class));
@ -441,7 +450,8 @@ public class SpecialistService{
        String sql ="SELECT " +
                " p.code AS patient, " +
                " p.`name` AS patientName, " +
                " CAST(AES_DECRYPT(from_base64(r.patient_name), '" + key + "') AS char)  AS patientName, " +
//                " p.`name` AS patientName, " +
                " p.photo, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                " p.sex, " +
@ -478,12 +488,14 @@ public class SpecialistService{
        String checkDoctorSql = "SELECT " +
                " r.id AS relationCode," +
                " r.patient, " +
                " r.patient_name AS patientName, " +
                " CAST(AES_DECRYPT(from_base64(r.patient_name), '" + key + "') AS char)  AS patientName, " +
//                " r.patient_name AS patientName, " +
                " r.team_code AS teamCode, " +
                " t.`name`, " +
                " d.photo ," +
                " d.code AS doctor," +
                " d.name AS doctorName" +
                " CAST(AES_DECRYPT(from_base64(r.doctor_name), '" + key + "') AS char)  AS doctorName " +
//                " d.name AS doctorName" +
                " FROM " +
                " wlyy_specialist_patient_relation r " +
                " JOIN "+basedb+".wlyy_admin_team t ON t.id = r.team_code " +
@ -501,7 +513,8 @@ public class SpecialistService{
            for(SpecialistTeamVO specialistTeamVO:specialistTeamVOs){
                String menberSql = "SELECT " +
                        " m.doctor_code AS doctorCode, " +
                        " d.`name` AS doctorName " +
                        " CAST(AES_DECRYPT(from_base64(d.`name`), '" + key + "') AS char)  AS doctorName " +
//                        " d.`name` AS doctorName " +
                        " FROM " +
                        " "+basedb+".wlyy_admin_team_member m " +
                        " JOIN "+basedb+".wlyy_doctor d ON m.doctor_code = d.`code` " +
@ -518,7 +531,8 @@ public class SpecialistService{
        String checkTeamSql = "SELECT " +
                " r.id AS relationCode," +
                " r.patient, " +
                " r.patient_name AS patientName, " +
                " CAST(AES_DECRYPT(from_base64(r.patient_name), '" + key + "') AS char)  AS patientName, " +
//                " r.patient_name AS patientName, " +
                " r.team_code AS teamCode, " +
                " t.`name`, " +
                " d.photo " +
@ -538,7 +552,8 @@ public class SpecialistService{
            for(SpecialistTeamVO specialistTeamVO:teamVOs){
                String menberSql = "SELECT " +
                        " m.doctor_code AS doctorCode, " +
                        " d.`name` AS doctorName " +
                        " CAST(AES_DECRYPT(from_base64(d.`name`), '" + key + "') AS char)  AS doctorName " +
//                        " d.`name` AS doctorName " +
                        " FROM " +
                        " "+basedb+".wlyy_admin_team_member m " +
                        " JOIN "+basedb+".wlyy_doctor d ON m.doctor_code = d.`code` " +
@ -593,9 +608,11 @@ public class SpecialistService{
    public MixEnvelop<PatientSignInfoVO, PatientSignInfoVO> findPatientSigninfo(String code){
        String sql = "SELECT " +
                " r.patient, " +
                " r.patient_name AS patientName, " +
                " CAST(AES_DECRYPT(from_base64(r.patient_name), '" + key + "') AS char)  AS patientName, " +
//                " r.patient_name AS patientName, " +
                " r.doctor, " +
                " r.doctor_name AS doctorName, " +
                " CAST(AES_DECRYPT(from_base64(r.doctor_name), '" + key + "') AS char)  AS doctorName, " +
//                " r.doctor_name AS doctorName, " +
                " d.hospital, " +
                " d.hospital_name AS hospitalName, " +
                " d.photo, " +
@ -622,12 +639,15 @@ public class SpecialistService{
        String sql = "SELECT " +
                " r.id AS relationCode, " +
                " r.patient, " +
                " r.patient_name AS patientName, " +
                " CAST(AES_DECRYPT(from_base64(r.patient_name), '" + key + "') AS char)  AS patientName, " +
//                " r.patient_name AS patientName, " +
                " r.team_code,r.sign_date , " +
                " t.`name` AS name," +
                " d.photo," +
                " md.code AS doctor," +
                " md.name AS doctorName,d.hospital,d.hospital_name " +
                " CAST(AES_DECRYPT(from_base64(md.name), '" + key + "') AS char)  AS doctorName, " +
//                " md.name AS doctorName," +
                "d.hospital,d.hospital_name " +
                " FROM " +
                " wlyy_specialist_patient_relation r  " +
                " JOIN "+basedb+".wlyy_admin_team t ON t.id = r.team_code " +
@ -643,7 +663,8 @@ public class SpecialistService{
            for(SpecialistTeamVO specialistTeamVO:specialistTeamVOs){
                String menberSql = "SELECT " +
                        " m.doctor_code AS doctorCode, " +
                        " d.`name` AS doctorName " +
                        " CAST(AES_DECRYPT(from_base64(d.name), '" + key + "') AS char)  AS doctorName " +
//                        " d.`name` AS doctorName " +
                        " FROM " +
                        " "+basedb+".wlyy_admin_team_member m " +
                        " JOIN "+basedb+".wlyy_doctor d ON m.doctor_code = d.`code` " +
@ -662,8 +683,10 @@ public class SpecialistService{
                " r.id AS relationCode, " +
                " r.patient, " +
                " r.team_code AS teamCode," +
                " r.patient_name AS patientName, " +
                " d.name AS doctorName, " +
                " CAST(AES_DECRYPT(from_base64(r.patient_name), '" + key + "') AS char)  AS patientName, " +
//                " r.patient_name AS patientName, " +
//                " d.name AS doctorName, " +
                " CAST(AES_DECRYPT(from_base64(d.name), '" + key + "') AS char)  AS doctorName, " +
                " d.code AS doctor, " +
                " d.photo, " +
                " d.dept, " +
@ -692,11 +715,14 @@ public class SpecialistService{
                " r.id AS relationCode," +
                " r.patient, " +
                " r.team_code AS teamCode," +
                " r.patient_name AS patientName, " +
                " CAST(AES_DECRYPT(from_base64(r.patient_name), '" + key + "') AS char)  AS patientName, " +
//                " r.patient_name AS patientName, " +
                " r.health_assistant AS healthAssistant," +
                " r.health_assistant_name AS healthAssistantName," +
                " CAST(AES_DECRYPT(from_base64(r.health_assistant_name), '" + key + "') AS char)  AS healthAssistantName, " +
//                " r.health_assistant_name AS healthAssistantName," +
                " r.create_time AS createTime," +
                " d.name AS doctorName, " +
                " CAST(AES_DECRYPT(from_base64(d.name), '" + key + "') AS char)  AS doctorName, " +
//                " d.name AS doctorName, " +
                " d.code AS doctor, " +
                " d.photo, " +
                " d.dept, " +
@ -728,7 +754,8 @@ public class SpecialistService{
        if(StringUtils.isNotBlank(name)){
            sql = "SELECT " +
                    "doctor.CODE AS CODE," +
                    "doctor.NAME AS NAME," +
                    " CAST(AES_DECRYPT(from_base64(doctor.NAME), '" + key + "') AS char)  AS NAME, " +
//                    "doctor.NAME AS NAME," +
                    "doctor.sex AS sex," +
                    "doctor.birthday AS birthday," +
                    "doctor.photo AS photo," +
@ -751,11 +778,12 @@ public class SpecialistService{
                    "SELECT a.doctor_health AS doctorcode FROM wlyy.wlyy_sign_family a RIGHT JOIN ( " +
                    "SELECT patient FROM wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 AND doctor='"+doctor+"') b ON a.patient=b.patient WHERE a.`status`=1 AND a.expenses_status = 1 " +
                    ") " +
                    "t ON doctor.CODE=t.doctorcode and doctor.NAME like '%"+name+"%'";
                    "t ON doctor.CODE=t.doctorcode and CAST(AES_DECRYPT(from_base64(doctor.NAME), '" + key + "') AS char)  like '%"+name+"%'";
        }else{
            sql = "SELECT " +
                    "doctor.CODE AS CODE," +
                    "doctor.NAME AS NAME," +
                    " CAST(AES_DECRYPT(from_base64(doctor.NAME), '" + key + "') AS char)  AS NAME, " +
//                    "doctor.NAME AS NAME," +
                    "doctor.sex AS sex," +
                    "doctor.birthday AS birthday," +
                    "doctor.photo AS photo," +
@ -805,7 +833,8 @@ public class SpecialistService{
    public MixEnvelop<PatientRelationVO,PatientRelationVO> getSpecialistSignFamilyPatientByName(String specialdoctor, String familydoctor, String nameKey, Integer page, Integer size) {
        String sql ="SELECT " +
                "p.CODE AS patient," +
                "p.`name` AS patientName," +
                " CAST(AES_DECRYPT(from_base64(p.`name`), '" + key + "') AS char)  AS patientName, " +
//                "p.`name` AS patientName," +
                "p.photo," +
                "IFNULL(YEAR (from_days(datediff(now(),p.birthday))),'未知') age," +
                "p.sex " +
@ -816,7 +845,7 @@ public class SpecialistService{
                "  AND doctor='"+specialdoctor+"') " +
                "  AND (a.doctor='"+familydoctor+"' OR a.doctor_health='"+familydoctor+"') ";
        if(StringUtils.isNotBlank(nameKey)){
            sql= sql + "  AND a.NAME LIKE '%"+nameKey+"%' ";
            sql= sql + " AND CAST(AES_DECRYPT(from_base64(a.`name`), '" + key + "') AS char) LIKE '%"+nameKey+"%' ";
        }
        sql= sql +" AND a.`status`=1 AND a.expenses_status=1) s ON p.CODE=s.patient" +
                " LIMIT "+(page-1)*size+","+size;
@ -833,12 +862,12 @@ public class SpecialistService{
                "IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                "p.birthday, " +
                "p.photo " +
                "FROM (SELECT s.disease,s.disease_name,s.patient,s.patient_name,r.team_code from " +
                "FROM (SELECT s.disease,s.disease_name,s.patient,CAST(AES_DECRYPT(from_base64(s.patient_name), '" + key + "') AS char) as patient_name,r.team_code from " +
                "(SELECT id, team_code FROM wlyy_specialist_patient_relation WHERE doctor='" + doctor + "' and sign_status > 0 and `status` >= 0) r " +
                "JOIN "+basedb+".wlyy_patient_disease_server s on r.id = s.specialist_relation_code WHERE s.del = 1) s " +
                "JOIN "+basedb+".wlyy_patient p on s.patient = p.`code` where p.`status` >0 ";
        if(StringUtils.isNotBlank(patientInfo)){
            sql += " and p.idcard like '%"+ patientInfo +"%' or patient_name like '%" + patientInfo + "%'";
            sql += " and p.idcard like '%"+ patientInfo +"%' or patient_name  like '%" + patientInfo + "%'";
        }
        if(StringUtils.isNotBlank(disease)){
            sql = sql.replace("WHERE s.del = 1", "WHERE s.del = 1 and s.disease = '" + disease + "'");
@ -968,7 +997,7 @@ public class SpecialistService{
        jsonObject.put("doctorInfo", jdbcTemplate.queryForMap(doctorSql));
        //3、获取该医生所属团队及团队成员信息
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code, wd.NAME as doctorName  FROM " + basedb + ".wlyy_doctor wd LEFT JOIN  " + basedb + ".wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, " + basedb + ".wlyy_admin_team at " +
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code,  CAST(AES_DECRYPT(from_base64(wd.NAME), '" + key + "') AS char)  AS doctorName  FROM " + basedb + ".wlyy_doctor wd LEFT JOIN  " + basedb + ".wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, " + basedb + ".wlyy_admin_team at " +
                "WHERE tm.team_id IN ( SELECT watm.team_id teamId FROM  " + basedb + ".wlyy_admin_team_member watm WHERE watm.doctor_code ='" + doctorCode + "'" + " AND watm.available = '1' ) AND tm.available='1' AND `at`.id=tm.team_id";
        List<Map<String, Object>> teamList = jdbcTemplate.queryForList(teamSql);
        Map<Integer, List<Map<String, Object>>> m = teamList.stream().collect(Collectors.groupingBy(tem -> ((Integer) tem.get("team_id")).intValue(), Collectors.toList()));
@ -1019,7 +1048,7 @@ public class SpecialistService{
        jsonObject.put("specialistPatientRelationId", null == specialistPatientRelationDO ? null : specialistPatientRelationDO.getId());
        jsonObject.put("signCertificate", null == specialistPatientRelationDO ? null : specialistPatientRelationDO.getSignCertificate());
        //1、获取居民基础信息
        String preSql = "SELECT p.name as name, p.photo as photo,p.idcard as idcard,p.mobile as mobile,p.medicare_number as medicareNumber,p.ssc as ssc," +
        String preSql = "SELECT CAST(AES_DECRYPT(from_base64(p.name ), '" + key + "') AS char) as name, p.photo as photo,p.idcard as idcard,p.mobile as mobile,p.medicare_number as medicareNumber,p.ssc as ssc," +
                " CASE  WHEN wd.name is null THEN '无' ELSE wd.name END as doctorName,CASE  WHEN wd.hospital_name is NULL THEN '无' ELSE wd.hospital_name END as hospitalName,CASE  WHEN wd.mobile is NULL THEN '无' ELSE wd.mobile END as doctorMobole ";
        String patientSql = " from " + basedb + ".wlyy_patient p LEFT JOIN " + basedb + ".wlyy_sign_family wsf " +
                " ON p.code=wsf.patient AND wsf.type='2' AND wsf.status='1' " +
@ -1053,7 +1082,7 @@ public class SpecialistService{
        jsonObject.put("doctorInfo", result);
        //3、获取该医生所属团队及团队成员信息
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code, wd.NAME as doctorName  FROM " + basedb + ".wlyy_doctor wd LEFT JOIN  " + basedb + ".wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, " + basedb + ".wlyy_admin_team at " +
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code,  CAST(AES_DECRYPT(from_base64(wd.NAME), '" + key + "') AS char) as doctorName  FROM " + basedb + ".wlyy_doctor wd LEFT JOIN  " + basedb + ".wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, " + basedb + ".wlyy_admin_team at " +
                "WHERE tm.team_id IN ( SELECT watm.team_id teamId FROM  " + basedb + ".wlyy_admin_team_member watm WHERE watm.doctor_code ='" + doctorCode + "'" + " AND watm.available = '1' ) AND tm.available='1' AND `at`.id=tm.team_id";
        List<Map<String, Object>> teamList = jdbcTemplate.queryForList(teamSql);
        Map<Integer, List<Map<String, Object>>> m = teamList.stream().collect(Collectors.groupingBy(tem -> ((Integer) tem.get("team_id")).intValue(), Collectors.toList()));
@ -1172,7 +1201,13 @@ public class SpecialistService{
     * @return
     */
    public List<SpecialistPatientRelationDO> selectByAssistant(String patient,String doctor){
        String sql = "select * from wlyy_specialist_patient_relation r where r.health_assistant = '"+doctor+"' and r.patient = '"+patient+"' ";
        String sql = "select *,CAST(AES_DECRYPT(from_base64(r.patient_name ), '" + key + "') AS char) as patientName," +
                " CAST(AES_DECRYPT(from_base64(r.doctor_name), '" + key + "') AS char)  AS doctorName, " +
                " CAST(AES_DECRYPT(from_base64(r.health_assistant_name), '" + key + "') AS char)  AS healthAssistantName, " +
                " CAST(AES_DECRYPT(from_base64(r.health_doctor_name), '" + key + "') AS char)  AS healthDoctorName, " +
                " CAST(AES_DECRYPT(from_base64(r.sign_doctor_name), '" + key + "') AS char)  AS signDoctorName, " +
                " CAST(AES_DECRYPT(from_base64(r.create_user_name), '" + key + "') AS char)  AS createUserName " +
                " from wlyy_specialist_patient_relation r where r.health_assistant = '"+doctor+"' and r.patient = '"+patient+"' ";
        List<SpecialistPatientRelationDO> relationDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SpecialistPatientRelationDO.class));
        return relationDOS;
    }
@ -1184,7 +1219,7 @@ public class SpecialistService{
     */
    public MixEnvelop searchPatientInSpecialistNew(String doctorCode,String keywords,Integer page,Integer pageSize) throws Exception{
        String sql1 = " select count(1) as num ";
        String sql2 = " select p.name as name,p.idcard,p.code,p.photo";
        String sql2 = " select CAST(AES_DECRYPT(from_base64(p.name ), '" + key + "') AS char) as name,p.idcard,p.code,p.photo";
        String whereSql ="";
        if(!StringUtils.isEmpty(keywords)){
            whereSql+=" and  p.mobile ='"+keywords+"'";
@ -1299,9 +1334,9 @@ public class SpecialistService{
        if (!teamCode.equals(toTeamCode)){//跨团队
            flag=true;
        }
        String sql =" select name from wlyy.wlyy_doctor where code='"+toDoctorCode+"'";
        String sql =" select CAST(AES_DECRYPT(from_base64(name), '" + key + "') AS char) as name from wlyy.wlyy_doctor where code='"+toDoctorCode+"'";
        String toDoctorName = jdbcTemplate.queryForObject(sql,String.class);
        sql =" select name from wlyy.wlyy_doctor where code='"+doctorCode+"'";
        sql =" select CAST(AES_DECRYPT(from_base64(name), '" + key + "') AS char) as name from wlyy.wlyy_doctor where code='"+doctorCode+"'";
        String doctorName = jdbcTemplate.queryForObject(sql,String.class);
        JSONObject result = new JSONObject();
        JSONArray planObject = new JSONArray();