¶Ô±ÈÐÂÎļþ |
| | |
| | | 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("////////////"); |
| | | 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){//è·ååå°æ²¹äºä¿¡æ¯åæµç¹ |
| | | OkHttpClient okHttpClient = new OkHttpClient(); |
| | | RequestBody formBody = new FormBody.Builder() |
| | | .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("////////////"); |
| | | 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(); |
| | | } |
| | | } |
| | | } |