CZT
2023-12-27 2fe99f0d876377f7d20cb922c83d31cfbf766020
src/main/java/com/fzzy/push/shjdjw2023/Shjdjw2023HttpClientUtil.java
@@ -32,10 +32,8 @@
        HttpURLConnection connection = null;
        OutputStream outputStream = null;
        String rs = "";
        ShjdjwRespDto responseDto = null;
        ShjdjwRespDto responseDto;
        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,16 +68,12 @@
                rs = null;
                return new ShjdjwRespDto(99,e.getMessage());
            }
            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);
            log.info("---------接口返回:" + rs +"---------");
            if(StringUtils.isEmpty(rs)){
                return new ShjdjwRespDto(99,"接口请求发生未知错误");
            }
            if(responseDto == null )   return new ShjdjwRespDto(99,"接口请求发生未知错误");
            return responseDto;
//            responseDto = JSON.parseObject(rs, ShjdjwRespDto.class);
            return new ShjdjwRespDto(1,"接口请求发生未知错误");
        } finally {
            try {
                outputStream.close();