CZT
2023-12-28 05d2819f1069d24ceb96615705d40f44ab5f1f9c
src/main/java/com/fzzy/push/shjdjw2023/Shjdjw2023HttpClientUtil.java
@@ -3,7 +3,6 @@
import com.alibaba.fastjson.JSON;
import com.fzzy.api.entity.ApiConfs;
import com.fzzy.api.utils.AESUtils;
import com.fzzy.push.gd2022.dto.GD2022ResponseDto;
import com.fzzy.push.shjdjw2023.dto.ShjdjwRespDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@@ -33,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);
@@ -48,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) {
@@ -71,16 +68,15 @@
                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;
            if("dDTJ5xGqsmo32r40WKKPOLW6ORtH3mwMyv4YaJNzc4g=".equals(rs)){
                return new ShjdjwRespDto(1,"上报成功");
            }
//            responseDto = JSON.parseObject(rs, ShjdjwRespDto.class);
            return new ShjdjwRespDto(1,"上报成功");
        } finally {
            try {
                outputStream.close();