From 2e50c813f2d089e0265b13a7f9c5a9b23829130c Mon Sep 17 00:00:00 2001 From: liriming <1343021927@qq.com> Date: 星期四, 20 三月 2025 18:11:57 +0800 Subject: [PATCH] sdk修改 --- iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/client/IailabClient.java | 70 ++++++----------------------------- 1 files changed, 12 insertions(+), 58 deletions(-) diff --git a/iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/client/IailabClient.java b/iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/client/IailabClient.java index 667a51a..96b3342 100644 --- a/iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/client/IailabClient.java +++ b/iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/client/IailabClient.java @@ -6,7 +6,10 @@ import com.iailab.sdk.auth.client.common.exception.enums.GlobalErrorCodeConstants; import com.iailab.sdk.auth.client.common.pojo.CommonResult; import com.iailab.sdk.auth.client.common.pojo.PageResult; -import com.iailab.sdk.auth.client.dto.*; +import com.iailab.sdk.auth.client.dto.ApiPointsValueQueryDTO; +import com.iailab.sdk.auth.client.dto.StAlarmAndSuggestPageReqDTO; +import com.iailab.sdk.auth.client.dto.StAlarmAndSuggestRespDTO; +import com.iailab.sdk.auth.client.dto.TokenDTO; import com.iailab.sdk.auth.config.SdkAutoConfiguration; import com.iailab.sdk.auth.constants.SdkErrorCodeConstants; import com.iailab.sdk.util.http.IailabHttpUtils; @@ -16,11 +19,12 @@ import org.springframework.util.Base64Utils; import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.client.RestTemplate; import java.nio.charset.StandardCharsets; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -196,16 +200,16 @@ return authTokenDTO; } - public CommonResult<JSONObject> handleHttp(String method, String url, Map<String, Object> params) { - JSONObject data = new JSONObject(); + public CommonResult<Object> handleHttp(String method, String url, Map<String, Object> params) { + Object data = new Object(); String resp = null; try { String upperMethod = method.toUpperCase(); if ("GET".equals(upperMethod)) { - resp = IailabHttpUtils.doGet(url, params, CHARSET); + resp = IailabHttpUtils.doGet(BASE_URL +url, params, CHARSET); } else if ("POST".equals(upperMethod)) { ObjectMapper objectMapper = new ObjectMapper(); - resp = IailabHttpUtils.doPost(url, objectMapper.writeValueAsString(params), CHARSET); + resp = IailabHttpUtils.doPost(BASE_URL +url, objectMapper.writeValueAsString(params), CHARSET); } if (StringUtils.isEmpty(resp)) { return CommonResult.error(GlobalErrorCodeConstants.EMPTY_RESP); @@ -215,7 +219,7 @@ if (!GlobalErrorCodeConstants.SUCCESS.getCode().equals(respCode)) { CommonResult.error(respCode, jsonObject.getString(RESP_MSG)); } - data = jsonObject.getJSONObject(RESP_DATA); + data = jsonObject.get(RESP_DATA); } catch (Exception ex) { ex.printStackTrace(); return CommonResult.error(GlobalErrorCodeConstants.UNKNOWN.getCode(), ex.getMessage()); @@ -301,55 +305,5 @@ return CommonResult.error(GlobalErrorCodeConstants.UNKNOWN.getCode(), ex.getMessage()); } return CommonResult.success(data); - } - - /** - * 发电厂机组运行情况 - * @return - */ - public CommonResult<List<PowerRunStateDTO>> getPowerRunState() { - List<PowerRunStateDTO> list = new ArrayList<>(); - try { - String url = BASE_URL + "/ansteel/api/mcs/power-run-state/list"; - String resp = IailabHttpUtils.doGet(url, new HashMap<>(), "UTF-8"); - if (StringUtils.isEmpty(resp)) { - return CommonResult.error(GlobalErrorCodeConstants.EMPTY_RESP); - } - JSONObject jsonObject = JSON.parseObject(resp); - Integer respCode = jsonObject.getInteger(RESP_CODE); - if (!GlobalErrorCodeConstants.SUCCESS.getCode().equals(respCode)) { - CommonResult.error(respCode, jsonObject.getString(RESP_MSG)); - } - Long total = Long.parseLong(jsonObject.getJSONObject(RESP_DATA).get("total").toString()); - list = jsonObject.getJSONObject(RESP_DATA).getJSONArray("list").toJavaList(PowerRunStateDTO.class); - } catch (Exception ex) { - return CommonResult.error(GlobalErrorCodeConstants.UNKNOWN.getCode(), ex.getMessage()); - } - return CommonResult.success(list); - } - - /** - * 预测数据图表 - * @param reqVO - * @return - */ - public CommonResult<PreDataChartRespVO> getPreDataChart(PreDataSingleChartReqVO reqVO) { - PreDataChartRespVO respVO = new PreDataChartRespVO(); - try { - String url = BASE_URL + "/ansteel/api/mcs/predict-data/charts"; - String resp = IailabHttpUtils.doPost(url, JSON.toJSONString(reqVO), "UTF-8"); - if (StringUtils.isEmpty(resp)) { - return CommonResult.error(GlobalErrorCodeConstants.EMPTY_RESP); - } - JSONObject jsonObject = JSON.parseObject(resp); - Integer respCode = jsonObject.getInteger(RESP_CODE); - if (!GlobalErrorCodeConstants.SUCCESS.getCode().equals(respCode)) { - CommonResult.error(respCode, jsonObject.getString(RESP_MSG)); - } - respVO = jsonObject.getJSONObject(RESP_DATA).toJavaObject(PreDataChartRespVO.class); - } catch (Exception ex) { - return CommonResult.error(GlobalErrorCodeConstants.UNKNOWN.getCode(), ex.getMessage()); - } - return CommonResult.success(respVO); } } \ No newline at end of file -- Gitblit v1.9.3