aijinhui
2023-12-22 aa3706580edc249216c20db6992aaf5b249dd960
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package com.ruoyi.health.client;
 
import com.alibaba.fastjson.JSON;
import okhttp3.FormBody.Builder;
import okhttp3.*;
 
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
 
public class EquipmentsHealthClient {
    public static Map<String,Object> getToken(String url,String account,String password){//获取token
        OkHttpClient okHttpClient = new OkHttpClient();
        RequestBody formBody = new Builder()
                .add("account", account)
                .add("password", password)
                .build();
 
        Request request = new Request.Builder().url(url).post(formBody).build();
 
        Response response = null;
        try {
            response = okHttpClient.newCall(request).execute();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
 
        ResponseBody responseBody = response.body();
 
        try {
            String message = responseBody.string();
            Map<String,Object> result = (Map<String, Object>) JSON.parse(message);
            return result;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return new HashMap();
        }
    }
 
    public static Map<String,Object> getMeasureStatisticsList(String url,String token){//所有传感器统计信息
        MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
        OkHttpClient okHttpClient = new OkHttpClient();
 
        RequestBody body = RequestBody.create(mediaType, "");
        Request request = new Request.Builder().url(url).post(body).addHeader("roadflow-token",token).build();
 
        Response response = null;
        try {
            response = okHttpClient.newCall(request).execute();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
 
        ResponseBody responseBody = response.body();
 
        try {
            String message = responseBody.string();// 响应体
            Map<String,Object> map0 = (Map<String, Object>) JSON.parse(message);
            return map0;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return new HashMap();
        }
    }
 
    public static Map<String,Object> GetEquipInfo(String url,String token,Integer equipId){//获取单台油井信息和测点
        OkHttpClient okHttpClient = new OkHttpClient();
        RequestBody formBody = new Builder()
                .add("equipId", String.valueOf(equipId))
                .build();
        
        Request request = new Request.Builder().url(url).post(formBody).addHeader("roadflow-token",token).build();
       
        Response response = null;
        try {
            response = okHttpClient.newCall(request).execute();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
 
        ResponseBody responseBody = response.body();
 
        try {
            String message = responseBody.string();
            System.out.println(message);
            Map<String,Object> result = (Map<String, Object>) JSON.parse(message);
            return result;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return new HashMap();
        }
    }
 
    public static Map<String,Object> GetPartsAlertLeve(String url,String token,Integer id){
        OkHttpClient okHttpClient = new OkHttpClient();
//        MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
//        RequestBody formBody = RequestBody.create(mediaType, "");
        RequestBody formBody = new Builder()
                .add("equipId", String.valueOf(id))
                .build();
        Request request = new Request.Builder().url(url).post(formBody).addHeader("roadflow-token",token).build();
        Response response = null;
        try {
            response = okHttpClient.newCall(request).execute();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
 
        ResponseBody responseBody = response.body();
 
        try {
            String message = responseBody.string();
            System.out.println(message);
            Map<String,Object> result = (Map<String, Object>) JSON.parse(message);
            return result;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return new HashMap();
        }
    }
 
    public static Map<String,Object> GetEquipmentAlertInfo(String url,String token,Integer id){
        OkHttpClient okHttpClient = new OkHttpClient();
//        MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
//        RequestBody formBody = RequestBody.create(mediaType, "");
        RequestBody formBody = new Builder()
                .add("partid", String.valueOf(id))
                .build();
        Request request = new Request.Builder().url(url).post(formBody).addHeader("roadflow-token",token).build();
        Response response = null;
        try {
            response = okHttpClient.newCall(request).execute();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
 
        ResponseBody responseBody = response.body();
 
        try {
            String message = responseBody.string();
            System.out.println(message);
            Map<String,Object> result = (Map<String, Object>) JSON.parse(message);
            return result;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return new HashMap();
        }
    }
}