路泰机电科技体检——数据平台后端
zhaowenxuan
2024-12-30 dd45098812d61999f588bb34b483d236470a1067
src/main/java/com/example/utils/HttpClientUtils.java
@@ -186,6 +186,7 @@
        BufferedReader reader = null;
        StringBuilder response = new StringBuilder();
        try {
            log.info("请求地址 ->{}",httpUrl);
            URL url = new URL(httpUrl);
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
@@ -195,6 +196,7 @@
            }
            connection.setDoOutput(true);
            StringBuilder postData = new StringBuilder();
            log.info("入参 ->{}", JSONUtil.toJsonStr(maps));
            for (Map.Entry<String, Object> entry : maps.entrySet()) {
                if (postData.length() > 0) {
                    postData.append("&");
@@ -211,6 +213,7 @@
            while ((line = reader.readLine()) != null) {
                response.append(line);
            }
            log.info("返回 ->{}",response);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
@@ -236,6 +239,7 @@
        String boundary = "----WebKitFormBoundary" + UUID.randomUUID().toString().replaceAll("-", "");
        String CRLF = "\r\n";
        try {
            log.info("请求地址 ->{}",httpUrl);
            URL url = new URL(httpUrl);
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
@@ -244,6 +248,7 @@
                connection.setRequestProperty("Authorization", authorization);
            }
            connection.setDoOutput(true);
            log.info("入参 ->{}",maps);
            outStream = new DataOutputStream(connection.getOutputStream());
            for (Map.Entry<String, Object> entry : maps.entrySet()) {
                outStream.writeBytes("--" + boundary + CRLF);
@@ -259,6 +264,7 @@
            while ((line = reader.readLine()) != null) {
                response.append(line);
            }
            log.info("返回 ->{}",response);
        } catch (Exception e) {
            e.printStackTrace();
            return null;