Quellcode durchsuchen

修改CA底层POST和GET方法

DESKTOP-G6NQ3SI\dante vor 7 Jahren
Ursprung
Commit
7916470042

+ 68 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftApi.java

@ -59,6 +59,7 @@ public class ZysoftApi extends AbstractApiExecuter {
    private String licence = SystemConfig.getInstance().getGatewayLicence();
    private String basepath = SystemConfig.getInstance().getGatewayUrl();
    private String ca_url = SystemConfig.sysPropertiesSets.get("ca_url");
    private ZysoftApi(byte[] platformPublicKey, byte[] parameterPublicKey, byte[] resultPrivateKey) {
@ -199,4 +200,71 @@ public class ZysoftApi extends AbstractApiExecuter {
    {
        return cryptoParameter(key, param);
    }
    /**
     * CA底层Post统一接口
     */
    public String capost(Map<String,String> params, Map<String,String> headers, boolean openCrypto) throws Exception
    {
        List<RequestValue> paramsList = null;
        HeaderValue[] headersList = null;
        if(params!=null)
        {
            paramsList = new ArrayList<>();
            for(String key :params.keySet())
            {
                RequestValue obj = new RequestValue(key,params.get(key));
                paramsList.add(obj);
            }
        }
        if(headers!=null)
        {
            headersList = new HeaderValue[headers.size()];
            int i = 0;
            for(String key :headers.keySet())
            {
                headersList[i] = new HeaderValue(key,headers.get(key));
                i++;
            }
        }
        System.out.println("ca_url:"+ca_url);
        String response = doHttpPost(ca_url,licence,openCrypto,paramsList,headersList);
        response = response.replace("\r","").replace("\n","").replace("\t","").replace("\f","");
        //System.out.print("response:"+response+"\r\n");
        return response;
    }
    /**
     * CA底层Get统一接口
     */
    public String caget(Map<String,String> params, Map<String,String> headers, boolean openCrypto) throws Exception
    {
        List<RequestValue> paramsList = null;
        HeaderValue[] headersList = null;
        if(params!=null)
        {
            paramsList = new ArrayList<>();
            for(String key :params.keySet())
            {
                RequestValue obj = new RequestValue(key,params.get(key));
                paramsList.add(obj);
            }
        }
        if(headers!=null)
        {
            headersList = new HeaderValue[headers.size()];
            int i = 0;
            for(String key :headers.keySet())
            {
                headersList[i] = new HeaderValue(key,headers.get(key));
                i++;
            }
        }
        String response = doHttpGet(ca_url, licence, openCrypto, paramsList, headersList);
        response = response.replace("\r","").replace("\n","").replace("\t","").replace("\f","");
        System.out.print("response:"+response+"\r\n");
        return response;
    }
}

+ 4 - 2
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionCAService.java

@ -70,7 +70,7 @@ public class PrescriptionCAService extends ZysoftBaseService {
     * @throws Exception
     */
    public String postZyCaServer(String api, Map<String,String> params,String srcBusinessStreamNO,String content) throws Exception{
        String ca_url = SystemConfig.sysPropertiesSets.get("ca_url");
        String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                "<root>\n";
@ -101,7 +101,9 @@ public class PrescriptionCAService extends ZysoftBaseService {
        int times = 0;
        try {
            re = ZysoftApi.getSingleton().post(ca_url, paramsList, null,true);
//            re = ZysoftApi.getSingleton().post(ca_url, paramsList, null,true);
            re = ZysoftApi.getSingleton().capost(paramsList, null,true);
            Map<String,String> map = objectMapper.readValue(re,Map.class);
            String code = map.get("CODE");