czt
2024-11-25 8fc406df592585be2a11f7334d3dcc67484e12dc
src/main/java/com/fzzy/push/shjdjw2023/Shjdjw2023HttpClientUtil.java
@@ -34,8 +34,6 @@
        String rs = "";
        ShjdjwRespDto responseDto = null;
        try {
            String md = AESUtils.encrypt(data, apiConfs.getPublicKey());
            log.info("---------接口请求地址:" +url+ "----------密文参数:" + md +"---------");
            connection = (HttpURLConnection) urls.openConnection();
            connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
            connection.setDoOutput(true);
@@ -47,10 +45,10 @@
            connection.setConnectTimeout(20000);
            connection.setReadTimeout(30000);
            connection.setRequestMethod("POST");
            StringBuffer buffer = new StringBuffer();
            buffer.append(md);
            outputStream = connection.getOutputStream();
            outputStream.write(buffer.toString().getBytes("UTF-8"));
            outputStream.write(data.getBytes("UTF-8"));
            try {
                connection.connect();
                if (connection.getResponseCode() == 200) {
@@ -70,9 +68,16 @@
                rs = null;
                return new ShjdjwRespDto(99,e.getMessage());
            }
            log.info("---------接口返回:" + rs +"---------");
            responseDto = JSON.parseObject(rs,ShjdjwRespDto.class);
            if(responseDto == null )   return new ShjdjwRespDto(99,"接口请求发生未知错误");
            if(StringUtils.isNotEmpty(rs)){
                rs = rs.replaceAll("\"", "");
                log.info("---------接口返回,秘文:" + rs +"---------");
                rs = AESUtils.decrypt(rs, apiConfs.getPublicKey());
                log.info("---------接口返回,解析后:" + rs +"---------");
                responseDto = JSON.parseObject(rs, ShjdjwRespDto.class);
            }
            if(responseDto == null )  {
                return new ShjdjwRespDto(99,"接口请求发生未知错误");
            }
            return responseDto;
        } finally {
            try {