Browse Source

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

wsl 2 years ago
parent
commit
20ca8f9fe8

+ 23 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/RSAUtils.java

@ -3,6 +3,7 @@ package com.yihu.jw.util.common;
import java.security.*;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.X509EncodedKeySpec;
import javax.crypto.Cipher;
@ -128,6 +129,28 @@ public class RSAUtils {
        return ci.doFinal(data);
    }
    /**
     * 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;
    }
    public static void main(String[] args) {
        KeyPair keyPair =  initKey();

+ 16 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/admin/CommonEndpoint.java

@ -6,6 +6,7 @@ import com.yihu.jw.care.service.common.CommomService;
import com.yihu.jw.care.service.device.DevicePatientFaceService;
import com.yihu.jw.care.service.patient.CarePatientService;
import com.yihu.jw.care.util.DingdingUtil;
import com.yihu.jw.care.util.HongLingJinUtil;
import com.yihu.jw.care.util.SpeechTtsUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.label.BaseCapacityLabelDO;
@ -58,6 +59,21 @@ public class CommonEndpoint extends EnvelopRestEndpoint {
    private DevicePatientFaceService patientFaceService;
    @Autowired
    private SpeechTtsUtil speechTtsUtil;
    @Autowired
    private HongLingJinUtil hongLingJinUtil;
    @GetMapping(value = "open/getToken")
    @ApiOperation(value = "文字转语音")
    public Envelop getToken() {
        try {
            hongLingJinUtil.getToken();
            return ObjEnvelop.getSuccess("success");
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "open/wordToVoice")
    @ApiOperation(value = "文字转语音")

+ 19 - 13
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java

@ -57,22 +57,28 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
    public Envelop dingtalk_app_user(@ApiParam(name = "authCode", value = "钉钉授权code", required = true)
                                     @RequestParam(value = "authCode",required = true) String authCode){
        try {
            JSONObject jsonObject = dingdingUtil.dingtalk_app_user(authCode);
            if(jsonObject.getBoolean("success")){
                JSONObject content = jsonObject.getJSONObject("content");
                if(content.getBoolean("success")){
                    long accountId = content.getJSONObject("data").getLong("accountId");
                    BaseDoctorDO doctorDO = doctorDao.findByYktDoctorId(accountId+"");
                    if(doctorDO == null){
                        return Envelop.getError("暂无该账号,请联系云照护工作人员配置");
            //红领巾平台和这个类似直接传浙政钉id
            BaseDoctorDO doctorDO = doctorDao.findByYktDoctorId(authCode);
            if(doctorDO!=null){
                return success(doctorDO.getMobile());
            }else {
                JSONObject jsonObject = dingdingUtil.dingtalk_app_user(authCode);
                if(jsonObject.getBoolean("success")){
                    JSONObject content = jsonObject.getJSONObject("content");
                    if(content.getBoolean("success")){
                        long accountId = content.getJSONObject("data").getLong("accountId");
                        doctorDO = doctorDao.findByYktDoctorId(accountId+"");
                        if(doctorDO == null){
                            return Envelop.getError("暂无该账号,请联系云照护工作人员配置");
                        }else{
                            return success(doctorDO.getMobile());
                        }
                    }else{
                        return success(doctorDO.getMobile());
                        return Envelop.getError(content.getString("responseMessage"));
                    }
                }else{
                    return Envelop.getError(content.getString("responseMessage"));
                }else {
                    return Envelop.getError("获取失败");
                }
            }else {
                return Envelop.getError("获取失败");
            }
        }catch (Exception e){
            e.printStackTrace();

+ 69 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/HongLingJinUtil.java

@ -0,0 +1,69 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.util.common.RSAUtils;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * 拱墅区红领巾app对接
 * Created by yeshijie on 2022/7/13.
 */
@Component
public class HongLingJinUtil {
    private static final Logger logger = LoggerFactory.getLogger(HongLingJinUtil.class);
    //ras加密公钥
    private static final String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDlOKrXjxrFo4Y2nNqzVh4ZMaxg58p83uSGuSA9Kxjsja+KHvN/72NqyKER2ucPuiYsDUBjFQI9t4LMLS8zl0GlKHKHU+gr8IQ4Cg/JqQLhjpgX4/f3Xk54A/1003TWKn9hSJSlsw3uxgLVTj/pwZoL1W1NSFKSu8jZbgzToNa2GwIDAQAB";
    //第三方平台的用户名
    private static final String username = "ddsqhd";
    @Autowired
    private HttpClientUtil httpClientUtil;
    public void getToken(){
        try {
            String url = "http://10.18.40.99:7680/sso/token";
//            String url = "https://zhyzh.gongshu.gov.cn/ssotoken/sso/token";
            JSONObject json = new JSONObject();
            json.put("client_id","client_third");
            json.put("client_secret","a2o8W3nP");
            json.put("username",username);
            Map<String,Object> httpPost = new HashedMap();
            httpPost.put("Content-Type", "application/x-www-form-urlencoded");
            String code = RSAUtils.encrypt(json.toString(),publicKey);
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("code", code));
            String response = httpClientUtil.headerPost(url, params,"UTF-8",httpPost);
            logger.info("url:"+url);
            logger.info("code:"+code);
            logger.info("response:"+response);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public void zzdcommon(){
//        String url = "http://10.18.40.99:7680/sso/token";
        String url = "https://zhyzh.gongshu.gov.cn/zzdcommon/api/zzd/common";
        JSONObject json = new JSONObject();
        json.put("client_id","client_third");
        json.put("client_secret","a2o8W3nP");
        json.put("username",username);
    }
}