大屏看板控制类
This commit is contained in:
parent
cfcde9db80
commit
a880c0c944
|
|
@ -0,0 +1,85 @@
|
||||||
|
package com.nflg.mobilebroken.admin.controller;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.nflg.mobilebroken.admin.service.ITranslate;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.request.TranslateWordRequest;
|
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import org.apache.http.message.BasicHeader;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大屏看板
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/kanban")
|
||||||
|
public class KanbanController extends ControllerBase{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化数据
|
||||||
|
* @param
|
||||||
|
* @return 翻译结果
|
||||||
|
*/
|
||||||
|
@PostMapping("initialize")
|
||||||
|
public ApiResult<String> initialize(){
|
||||||
|
|
||||||
|
JSONArray array=new JSONArray();
|
||||||
|
String initdata1=httpOfGet("http://47.94.198.125:5555/zhonglv/initdata1","type","initworktime");
|
||||||
|
JSONObject jsonObject = JSONUtil.parseObj(initdata1);
|
||||||
|
array.add(jsonObject);
|
||||||
|
String initdata2=httpOfGet("http://47.94.198.125:5555/zhonglv/initdata1","type","initstandard");
|
||||||
|
JSONObject jsonObject2 = JSONUtil.parseObj(initdata2);
|
||||||
|
array.add(jsonObject2);
|
||||||
|
String getdata1=httpOfGet("http://47.94.198.125:5555/zhonglv/getdata1","type","alarm");
|
||||||
|
JSONObject jsonObject3 = JSONUtil.parseObj(getdata1);
|
||||||
|
array.add(jsonObject3);
|
||||||
|
String getdata2=httpOfGet("http://47.94.198.125:5555/zhonglv/getdata1","type","device");
|
||||||
|
JSONObject jsonObject4 = JSONUtil.parseObj(getdata2);
|
||||||
|
array.add(jsonObject4);
|
||||||
|
String getdata3=httpOfGet("http://47.94.198.125:5555/zhonglv/getdata1","type","chart");
|
||||||
|
JSONObject jsonObject5 = JSONUtil.parseObj(getdata3);
|
||||||
|
array.add(jsonObject5);
|
||||||
|
String getdata4=httpOfGet("http://47.94.198.125:5555/zhonglv/getdata1","type","other");
|
||||||
|
JSONObject jsonObject6 = JSONUtil.parseObj(getdata4);
|
||||||
|
array.add(jsonObject6);
|
||||||
|
return ApiResult.success(jsonObject6.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String httpOfGet(String url, String paramName, String paramValue){
|
||||||
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
|
try {
|
||||||
|
HttpGet request = new HttpGet(url);
|
||||||
|
// 设置请求头
|
||||||
|
request.addHeader(new BasicHeader("Authorization", "Bearer your_token_here"));
|
||||||
|
request.addHeader(new BasicHeader("Content-Type", "application/json"));
|
||||||
|
request.addHeader(new BasicHeader(paramName, paramValue));
|
||||||
|
CloseableHttpResponse response = httpClient.execute(request);
|
||||||
|
try {
|
||||||
|
//int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
// 获取响应体内容
|
||||||
|
String responseBody = EntityUtils.toString(response.getEntity());
|
||||||
|
return responseBody;
|
||||||
|
} finally {
|
||||||
|
response.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
httpClient.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue