路泰机电科技体检——数据平台后端
zjh
2025-06-16 dd0ab3867cb4092c222ecf156fc71c6c4777ddf3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.example;
 
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.junit.jupiter.api.Test;;
import org.springframework.boot.test.context.SpringBootTest;
 
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Map;
 
@SpringBootTest
class ImgCheckApplicationTests {
 
    @Test
    void contextLoads() {
    }
 
    public static void main(String[] args) {
        URL url = null;
        HttpURLConnection connection = null;
        OutputStreamWriter writer = null;
        BufferedReader reader = null;
        StringBuilder response = new StringBuilder();
        try {
            url = new URL("http://oapi.xamjyy.com/OAPI/zhuShuJu/getShouFeiXm");
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            connection.setRequestProperty("Authorization", "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyI2MjY0MTYyNTk2MTY5OTczNzYiXSwiZXhwIjoxNzM0NzkyMzk2LCJqdGkiOiJhYjg0YWNjZi0xMDYyLTRjNDUtYjdhNy04OGVkYmQ4ZTdmYmMiLCJjbGllbnRfaWQiOiJYRlpaUUVmWFRaN2V4aGhpIn0.CothzTpZoz08Kvb8z3FIl0CtZQhc5p12H0oHmmdp1gQ");
            connection.setDoOutput(true);
            StringBuilder postData = new StringBuilder();
            JSONObject jsonObject = JSONUtil.parseObj("{\"pageIndex\":1,\"pageSize\":10}");
            for (String key : jsonObject.keySet()) {
                if (postData.length() > 0) {
                    postData.append("&");
                }
                String encode = URLEncoder.encode(key, "UTF-8");
                String encode1 = URLEncoder.encode(String.valueOf(jsonObject.get(key)), "UTF-8");
                postData.append(encode).append("=").append(encode1);
            }
            writer = new OutputStreamWriter(connection.getOutputStream());
            System.out.println("postData = " + postData);
            writer.write(postData.toString());
            writer.flush();
            reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String line;
            while ((line = reader.readLine()) != null) {
                response.append(line);
            }
            System.out.println("response = " + response);
        }catch (Exception e){
 
        }
    }
}