Trick 4 lat temu
rodzic
commit
bd00d9cddf

+ 1 - 0
business/base-service/pom.xml

@ -139,6 +139,7 @@
            <artifactId>ehcsdk</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>

+ 27 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java

@ -21,6 +21,7 @@ import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.prescription.service.entrance.util.AES;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
@ -555,6 +556,32 @@ public class XzzxEntranceService {
        }
    }
    /**
     * 获取中山医院token
     * @return
     * @throws Exception
     */
    public String getXzToken() throws Exception{
        JSONObject params = new JSONObject();
        params.put("appId","1BQ08T2R60006501A8C00000BE73319D");
        params.put("encryptType","DES");
        params.put("sign","58E40DCEA527333B9E7C3CCD1A08979F");
        params.put("signType","MD5");
        params.put("timestamp",new Date().getTime());
        params.put("version","v.1.0.0");
        params.put("serviceId","ext.user.getTokenByMerchId");
        JSONObject p = new JSONObject();
        p.put("medicalId","3501000014");
        params.put("param",p);
        String rs = HttpUtil.sendPost("http://xzbh.xmheart.com:8090/hospitalPortal-ext-app/ext/app/unifyapi",params.toJSONString());
        logger.info("rs :"+rs);
        JSONObject rsJson = JSON.parseObject(rs);
        String tokenAES = rsJson.getJSONObject("param").getString("token");
        String token = AES.decrypt("xm_xxg_zxzx", tokenAES);
        return token;
    }
//=====================微信模板消息推送接口================================
}

+ 168 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/util/AES.java

@ -0,0 +1,168 @@
package com.yihu.jw.hospital.prescription.service.entrance.util;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import com.yihu.jw.utils.encode.Base64;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class AES {
	public static String encrypt(String strKey, String strIn) {
		try {
			SecretKeySpec skeySpec = getKey(strKey);
			Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
			IvParameterSpec iv = new IvParameterSpec(
					"0102030405060708".getBytes());
			cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
			byte[] encrypted = cipher.doFinal(strIn.getBytes("UTF-8"));
			return Base64.encode(encrypted);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	public static String decrypt(String strKey, String strIn) throws Exception {
		try {
			SecretKeySpec skeySpec = getKey(strKey);
			Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
			IvParameterSpec iv = new IvParameterSpec(
					"0102030405060708".getBytes());
			cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
			byte[] encrypted1 = Base64.decode(strIn);
			byte[] original = cipher.doFinal(encrypted1);
			String originalString = new String(original, "UTF-8");
			return originalString;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	private static SecretKeySpec getKey(String strKey) throws Exception {
		byte[] arrBTmp = strKey.getBytes();
		byte[] arrB = new byte[16]; // 创建一个空的16位字节数组(默认值为0)
		for (int i = 0; i < arrBTmp.length && i < arrB.length; i++) {
			arrB[i] = arrBTmp[i];
		}
		SecretKeySpec skeySpec = new SecretKeySpec(arrB, "AES");
		return skeySpec;
	}
	
	/** 
	 * 随机生成秘钥 
	 */  
	public static void generateKey(){    
	    try {    
	        KeyGenerator kg = KeyGenerator.getInstance("AES");    
	        kg.init(128);//要生成多少位,只需要修改这里即可128, 192或256    
	        SecretKey sk = kg.generateKey();    
	        byte[] b = sk.getEncoded();    
	        String s = byteToHexString(b);    
	        System.out.println(s);    
	        System.out.println("十六进制密钥长度为"+s.length());    
	        System.out.println("二进制密钥的长度为"+s.length()*4);    
	    } catch (NoSuchAlgorithmException e) {    
	        e.printStackTrace();    
	        System.out.println("没有此算法。");    
	    }    
	} 
	
	/** 
	 * byte数组转化为16进制字符串 
	 * @param bytes 
	 * @return 
	 */  
	public static String byteToHexString(byte[] bytes){       
	    StringBuffer sb = new StringBuffer();       
	    for (int i = 0; i < bytes.length; i++) {       
	         String strHex=Integer.toHexString(bytes[i]);   
	         if(strHex.length() > 3){       
	                sb.append(strHex.substring(6));       
	         } else {    
	              if(strHex.length() < 2){    
	                 sb.append("0" + strHex);    
	              } else {    
	                 sb.append(strHex);       
	              }       
	         }    
	    }    
	   return  sb.toString();       
	}
	public static String signConvertToPara(String region) {
		String target = "";
		if (region != null) {
			target = region.replaceAll("\\+", "%2B").replaceAll("\\ ", "%20")
					.replaceAll("\\/", "%2F").replaceAll("\\?", "%3F")
					.replaceAll("\\#", "%23").replaceAll("\\&", "%26")
					.replaceAll("\\=", "%3D");
		}
		return target;
	}
	public static String paraConvertsign(String region) {
		String target = "";
		if (region != null) {
			target = region.replaceAll("%2B", "+").replaceAll("%20", " ")
					.replaceAll("%2F", "/").replaceAll("%3F", "?")
					.replaceAll("%25", "%").replaceAll("%23", "#")
					.replaceAll("%26", "&").replaceAll("%3D", "=");
		}
		return target;
	}
	//用于和c#互通的加解密
	//https://www.jianshu.com/p/9483c9ea3a04
	 /**
     * AES的加密函数
     * @param str 传入需要加密的字符
     * @param key 传入一个16位长度的密钥。否则报错
     * @return 执行成功返回加密结果,否则报错
     * @throws Exception 抛出一个加密异常
     */
    public static String aesEncrypt(String str, String key) throws Exception {
        if (str == null || key == null) return null;
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key.getBytes("utf-8"), "AES"));
        byte[] bytes = cipher.doFinal(str.getBytes("utf-8"));
        return new BASE64Encoder().encode(bytes);
    }
    /**
     * AES的解密函数
     * @param str 传入需要解密的字符
     * @param key 传入一个16位长度的密钥。否则报错
     * @return 执行成功返回加密结果,否则报错
     * @throws Exception 抛出一个解密异常
     */
    public static String aesDecrypt(String str, String key) throws Exception {
        if (str == null || key == null) return null;
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key.getBytes("utf-8"), "AES"));
        byte[] bytes = new BASE64Decoder().decodeBuffer(str);
        bytes = cipher.doFinal(bytes);
        return new String(bytes, "utf-8");
    }
    
	public static void main(String[] args) throws Exception {
		generateKey();
		String testKey = "xmxzzxtj";
		String testEn = AES.encrypt(testKey, "{'function':'healthExam','yyid00':'220006','userId':'','name':'','phone':'','identityCard':'','icCard':''}");
		System.out.println(testEn);
		String testDe = AES.decrypt(testKey, testEn);
		System.out.println(testDe);
		
	}
}

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

@ -133,7 +133,7 @@ public class OauthYlzConfigService {
    public Map<String,Object> getOauthQRCodeImg(){
        try {
            logger.info("getOauthQRCodeImg dao1:"+DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss:SSS"));
            OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findOne("ylz_config1");
            OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findOne("ylz_config");
            logger.info("getOauthQRCodeImg dao2:"+DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss:SSS"));
            TransRequest e = new TransRequest();
            e.setMethod("ehc.ehealthcard.authurl");

+ 52 - 11
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/common/FileUploadController.java

@ -1,5 +1,8 @@
package com.yihu.jw.base.endpoint.common;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.base.util.ErrorCodeUtil;
@ -13,6 +16,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
@ -22,6 +27,7 @@ import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URLDecoder;
import java.util.Base64;
import java.util.Map;
/**
 * 文件上传不在微服务中处理
@ -32,11 +38,22 @@ import java.util.Base64;
@Api(tags = "文件上传相关操作", description = "文件上传相关操作")
public class FileUploadController extends EnvelopRestEndpoint {
    private static final Logger logger = LoggerFactory.getLogger(EnvelopRestEndpoint.class);
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Autowired
    FileUploadService fileUploadService;
    @Value("${testPattern.sign}")
    private String isClose;
    @Value("${testPattern.remote_inner_url}")
    private String remote_inner_url;
    @Autowired
    private ObjectMapper objectMapper;
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_IMG)
    @ApiOperation(value = "文件流上传图片", notes = "文件流上传图片")
    public ObjEnvelop<UploadVO> uploadImg(@ApiParam(value = "文件", required = true)
@ -59,17 +76,17 @@ public class FileUploadController extends EnvelopRestEndpoint {
        return success("上传成功", uploadVO);
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM)
    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
    public ObjEnvelop<UploadVO> uploadStream(@ApiParam(value = "文件", required = true)
                                                 @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        // 得到文件的完整名称  xxx.txt
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
        return success("上传成功", uploadVO);
    }
//    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM)
//    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
//    public ObjEnvelop<UploadVO> uploadStream(@ApiParam(value = "文件", required = true)
//                                                 @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
//
//        // 得到文件的完整名称  xxx.txt
//        String originalFilename = file.getOriginalFilename();
//        InputStream inputStream = file.getInputStream();
//        UploadVO uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
//        return success("上传成功", uploadVO);
//    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STRING)
    @ApiOperation(value = "base64上传图片",notes = "base64上传图片")
@ -79,4 +96,28 @@ public class FileUploadController extends EnvelopRestEndpoint {
        return success("上传成功", uploadVO);
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM)
    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
    public ObjEnvelop<UploadVO> uploadStream(@ApiParam(value = "文件", required = true)
                                             @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        UploadVO uploadVO = new UploadVO();
        if (isClose.equalsIgnoreCase("1")){
            Map<String, Object> map = fileUploadService.uploadImg(file);
            uploadVO.setFullUri(map.get("accessory").toString());
        }else if(isClose.equals("2")){
            //内网上传
            String rs = fileUploadService.request(remote_inner_url,file,null);
            logger.info(rs);
            JSONObject json = JSON.parseObject(rs);
            uploadVO = objectMapper.readValue(json.getJSONObject("obj").toJSONString(),UploadVO.class);
        }else {
            // 得到文件的完整名称  xxx.txt
            String originalFilename = file.getOriginalFilename();
            InputStream inputStream = file.getInputStream();
            uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
        }
        return success("上传成功", uploadVO);
    }
}

+ 13 - 1
svr/svr-base/src/main/resources/application.yml

@ -115,6 +115,10 @@ wlyy:
  url: http://ehr.yihu.com/wlyy/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
---
spring:
  profiles: jwtest
@ -154,6 +158,10 @@ wlyy:
  url: http://ehr.yihu.com/wlyy/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
---
spring:
  profiles: jwprod
@ -190,4 +198,8 @@ hospital:
wlyy:
  url: http://ehr.yihu.com/wlyy/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040
  id: d24d1367-7f4f-43af-910e-a0a43799e040
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream

+ 7 - 1
svr/svr-base/src/main/resources/bootstrap.yml

@ -30,7 +30,13 @@ spring:
    config:
      uri: ${wlyy.spring.config.uri:http://192.0.33.26:1221}
      label: ${wlyy.spring.config.label:master}
---
spring:
  profiles: xzprod
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://172.16.100.63:1221}
      label: ${wlyy.spring.config.label:master}
---
spring:
  profiles: local