| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | |
| | | 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); |
| | | } |
| | | } |