浏览代码

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

liubing 3 年之前
父节点
当前提交
0e0ef1a4d7

+ 3 - 0
gateway/ag-basic/src/main/resources/application.yml

@ -89,6 +89,9 @@ zuul:
    svr-cloud-care:
    svr-cloud-care:
      path: /cloudCare/**
      path: /cloudCare/**
      serviceId: svr-cloud-care
      serviceId: svr-cloud-care
    svr-cloud-care-test:
      path: /cloudCareTest/**
      serviceId: svr-cloud-care-test
    svr-cloud-medicine:
    svr-cloud-medicine:
      path: /cloudMedicine/**
      path: /cloudMedicine/**
      serviceId: svr-cloud-care
      serviceId: svr-cloud-care

+ 64 - 13
server/svr-authentication/src/main/java/com/yihu/jw/security/utils/RSAUtils.java

@ -3,12 +3,11 @@ package com.yihu.jw.security.utils;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import javax.crypto.Cipher;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.SecureRandom;
import java.security.Security;
import java.security.*;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
public class RSAUtils {
public class RSAUtils {
@ -45,6 +44,53 @@ public class RSAUtils {
        return new String(decrypt(Base64.decodeBase64(string),keyPair));
        return new String(decrypt(Base64.decodeBase64(string),keyPair));
    }
    }
    /**
     * RSA公钥加密
     *
     * @param str
     *            加密字符串
     * @param publicKey
     *            公钥
     * @return 密文
     * @throws Exception
     *             加密过程中的异常信息
     */
    public static String encrypt( String str, String publicKey ) throws Exception{
        //base64编码的公钥
        byte[] decoded = Base64.decodeBase64(publicKey);
        RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
        //RSA加密
        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.ENCRYPT_MODE, pubKey);
        String outStr = Base64.encodeBase64String(cipher.doFinal(str.getBytes("UTF-8")));
        return outStr;
    }
    /**
     * RSA私钥解密
     *
     * @param str
     *            加密字符串
     * @param privateKey
     *            私钥
     * @return 铭文
     * @throws Exception
     *             解密过程中的异常信息
     */
    public static String decrypt(String str, String privateKey) throws Exception{
        //64位解码加密后的字符串
        byte[] inputByte = Base64.decodeBase64(str.getBytes("UTF-8"));
        //base64编码的私钥
        byte[] decoded = Base64.decodeBase64(privateKey);
        RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded));
        //RSA解密
        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.DECRYPT_MODE, priKey);
        String outStr = new String(cipher.doFinal(inputByte));
        return outStr;
    }
    private static byte[] decrypt(byte[] string,KeyPair keyPair) {
    private static byte[] decrypt(byte[] string,KeyPair keyPair) {
        try {
        try {
            Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
            Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
@ -60,14 +106,19 @@ public class RSAUtils {
        }
        }
    }
    }
//    public static void main(String[] args) {
//
//        KeyPair keyPair =  initKey();
//        // 生成public key
//        System.out.println(generateBase64PublicKey(keyPair));
//
//        // 解密
//        System.out.println(decryptBase64("wAfY9JkoKay9SxcPIs1FcG+t6sR+wYwAs/mh9DpfcBraxzqoZdb9LyaAigzFQ0EKck9OyHL0dhv+Uxuw5hHw6CPT0B2Z0i1gwrjDUNaL1gWvqt1pDJVGrIYPLJSjs9xktFhY1jbxQgXGjyCt06Rwid5sJknw90AUO0CyQulfipg=",keyPair));
//    }
    public static void main(String[] args) throws Exception{
        KeyPair keyPair =  getKey();
        // 生成public key
        String privateKeyString = new String(Base64.encodeBase64((keyPair.getPrivate().getEncoded())));
        String publicKeyString = new String(Base64.encodeBase64(keyPair.getPublic().getEncoded()));
        System.out.println("publicKeyString="+publicKeyString);
        System.out.println("privateKeyString="+privateKeyString);
        String str = "123ysj*#%";
        String encryptStr = encrypt(str,publicKeyString);
        // 字符串解密
        System.out.println(decrypt(encryptStr,privateKeyString));
    }
}
}

+ 16 - 39
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/OnlineContactService.java

@ -10,7 +10,6 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
@ -40,10 +39,9 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
    @Autowired
    @Autowired
    private ServicePackageService servicePackageService;
    private ServicePackageService servicePackageService;
    @Autowired
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    private BaseDoctorDao doctorDao;
    public JSONObject getOnLineObj(String patient){
    public JSONObject getOnLineObj(String patient){
        JSONObject obj = new JSONObject();
        JSONObject obj = new JSONObject();
        String zlySql = "SELECT  doc.* from base_service_package_sign_record sr,base_service_package_record r,base_team_member m,base_doctor doc \n" +
        String zlySql = "SELECT  doc.* from base_service_package_sign_record sr,base_service_package_record r,base_team_member m,base_doctor doc \n" +
@ -133,41 +131,24 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        JSONArray doctorResult = new JSONArray();
        JSONArray doctorResult = new JSONArray();
        JSONArray patientResult = new JSONArray();
        JSONArray patientResult = new JSONArray();
        String doctors = imUtil.getSessionListByType(patient,"0","1","2",null,null,"1");
        String patients = imUtil.getSessionListByType(patient,"0","100","2",null,null,"2");
        String patients = imUtil.getSessionListByType(patient,"0","100","2",null,null,"2");
        JSONArray doctorArr = JSON.parseArray(doctors);
        JSONArray patientArr = JSON.parseArray(patients);
        JSONArray patientArr = JSON.parseArray(patients);
        if (doctorArr.size()==0){//取签约医生其中一个
          List<Map<String,Object>> signDoctors =  servicePackageService.getServerDoctorAll(patient,null,null);
          if (signDoctors.size()>0){
              Map<String,Object> tmp = signDoctors.get(0);
              JSONObject tmpObj = new JSONObject();
              tmpObj.put("name",tmp.get("doctorName"));
              tmpObj.put("unread_count","0");
              tmpObj.put("avatar",tmp.get("photo"));
              tmpObj.put("userType","1");
              tmpObj.put("doctorId",tmp.get("doctor"));
              tmpObj.put("doctorLevel",tmp.get("doctorLevel"));
              tmpObj.put("relationName",null==tmp.get("doctorLevel")?"":"1".equals(tmp.get("doctorLevel").toString())?"社区医生":"助老员");
              doctorResult.add(tmpObj);
          }
        }else {
            JSONObject tmp = doctorArr.getJSONObject(0);
            JSONArray participantsTimeArray = tmp.getJSONArray("participantsTimeArray");
            for (int i=0;i<participantsTimeArray.size();i++){
                JSONObject tmpObj = participantsTimeArray.getJSONObject(i);
                String id =  tmpObj.getString("id");
                if (!id.equals(patient)){
                    tmp.put("avatar",tmp.getString("photo"));
                    tmp.put("doctorId",id);
                    BaseDoctorDO doctorDO = doctorDao.findById(id);
                    tmp.put("doctorLevel",doctorDO.getLevel());
                    tmp.put("relationName","助老员");
                    break;
                }
            }
            doctorResult.add(tmp);
        //医生默认取签约第一个
        List<Map<String,Object>> signDoctors =  servicePackageService.getServerDoctorAll(patient,null,null);
        if (signDoctors.size()>0){
            Map<String,Object> tmp = signDoctors.get(0);
            JSONObject tmpObj = new JSONObject();
            tmpObj.put("name",tmp.get("doctorName"));
            tmpObj.put("unread_count","0");
            tmpObj.put("avatar",tmp.get("photo"));
            tmpObj.put("userType","1");
            tmpObj.put("doctorId",tmp.get("doctor"));
            tmp.put("doctorLevel",tmp.get("doctorLevel"));
            tmpObj.put("relationName","助老员");
            doctorResult.add(tmpObj);
        }
        }
        JSONArray families = familyMemberService.membersWithOnLineFlag(patient);
        JSONArray families = familyMemberService.membersWithOnLineFlag(patient);
        if (families.size()>0){
        if (families.size()>0){
            List<String> familyIds = families.stream().map(item->((JSONObject)item).getString("id")).collect(Collectors.toList());
            List<String> familyIds = families.stream().map(item->((JSONObject)item).getString("id")).collect(Collectors.toList());
@ -177,10 +158,6 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
                for (int i=0;i<participantsTimeArray.size();i++){
                for (int i=0;i<participantsTimeArray.size();i++){
                    JSONObject tmpObj = participantsTimeArray.getJSONObject(i);
                    JSONObject tmpObj = participantsTimeArray.getJSONObject(i);
                    String id =  tmpObj.getString("id");
                    String id =  tmpObj.getString("id");
                    BasePatientDO patientDO = patientDao.findById(id);
                    if (patientDO.getArchiveType()==3){
                        continue;
                    }
                    if (!id.equals(patient)&&familyIds.contains(id)){
                    if (!id.equals(patient)&&familyIds.contains(id)){
                        tmp.put("avatar",tmp.getString("photo"));
                        tmp.put("avatar",tmp.getString("photo"));
                        tmp.put("patientId",id);
                        tmp.put("patientId",id);

+ 18 - 15
svr/svr-cloud-care/src/main/resources/application.yml

@ -6,21 +6,24 @@ spring:
  aop:
  aop:
    proxy-target-class: true
    proxy-target-class: true
  datasource:
  datasource:
    max-active: 200
    max-idle: 200 #最大空闲连接
    min-idle: 10 #最小空闲连接
    validation-query-timeout: 20
    log-validation-errors: true
    validation-interval: 60000 #避免过度验证,保证验证不超过这个频率——以毫秒为单位。如果一个连接应该被验证,但上次验证未达到指定间隔,将不再次验证。
    validation-query: SELECT 1 #SQL 查询, 用来验证从连接池取出的连接, 在将连接返回给调用者之前。 如果指定, 则查询必须是一个SQL SELECT 并且必须返回至少一行记录
    test-on-borrow: true #指明是否在从池中取出连接前进行检验, 如果检验失败, 则从池中去除连接并尝试取出另一个。注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
    test-on-return: true #指明是否在归还到池中前进行检验 注意: 设置为true 后如果要生效validationQuery 参数必须设置为非空字符串
    idle-timeout: 20000
    connection-test-query: SELECT 1
    num-tests-per-eviction-run: 200 #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive
    test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
    hikari:
      minimum-idle: 100                  # 最小连接数
      maximum-pool-size: 300
      max-active: 200
      max-idle: 200 #最大空闲连接
      min-idle: 10 #最小空闲连接
      validation-query-timeout: 20
      log-validation-errors: true
      validation-interval: 60000 #避免过度验证,保证验证不超过这个频率——以毫秒为单位。如果一个连接应该被验证,但上次验证未达到指定间隔,将不再次验证。
      validation-query: SELECT 1 #SQL 查询, 用来验证从连接池取出的连接, 在将连接返回给调用者之前。 如果指定, 则查询必须是一个SQL SELECT 并且必须返回至少一行记录
      test-on-borrow: true #指明是否在从池中取出连接前进行检验, 如果检验失败, 则从池中去除连接并尝试取出另一个。注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
      test-on-return: true #指明是否在归还到池中前进行检验 注意: 设置为true 后如果要生效validationQuery 参数必须设置为非空字符串
      idle-timeout: 60000
      connection-test-query: SELECT 1
      num-tests-per-eviction-run: 200 #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive
      test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
      min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
      time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
  http:
  http:
    multipart:
    multipart: