| | |
| | | package com.iailab.module.ansteel.api.controller.admin; |
| | | |
| | | import cn.hutool.core.util.NumberUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.framework.common.exception.enums.GlobalErrorCodeConstants; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | |
| | | for (PowerNetFactorDTO dto : result) { |
| | | boolean cosFlag = false; |
| | | try { |
| | | List<String> points = new ArrayList<>(); |
| | | if (StringUtils.isNotBlank(dto.getCurP())) { |
| | |
| | | Map<String, Object> pointsRealValue = dataPointApi.queryPointsRealValue(points); |
| | | if (pointsRealValue.get(dto.getCurP()) != null) { |
| | | dto.setCurP(pointsRealValue.get(dto.getCurP()).toString()); |
| | | } else { |
| | | dto.setCurP(""); |
| | | } |
| | | if (pointsRealValue.get(dto.getCurQ()) != null) { |
| | | dto.setCurQ(pointsRealValue.get(dto.getCurQ()).toString()); |
| | | } else { |
| | | dto.setCurQ(""); |
| | | } |
| | | if (pointsRealValue.get(dto.getCurCos()) != null) { |
| | | dto.setCurCos(pointsRealValue.get(dto.getCurCos()).toString()); |
| | | } else { |
| | | dto.setCurCos(""); |
| | | cosFlag = true; |
| | | } |
| | | } else { |
| | | dto.setCurP(""); |
| | | dto.setCurQ(""); |
| | | dto.setCurCos(""); |
| | | } |
| | | } catch (Exception e) { |
| | | log.info(dto.getNodeName() + "获取当前值异常"); |
| | | e.printStackTrace(); |
| | | } catch (Exception ex) { |
| | | log.info(dto.getNodeName() + "获取当前值异常" + ex.getMessage()); |
| | | } |
| | | |
| | | try { |
| | |
| | | } |
| | | if (!CollectionUtils.isEmpty(itemNos)) { |
| | | reqVO.setItemNos(itemNos); |
| | | log.info("reqVO=" + JSONObject.toJSONString(reqVO)); |
| | | Map<String, BigDecimal> preValues = mcsApi.getPredictValueByTime(reqVO); |
| | | if (StringUtils.isNotBlank(dto.getPreP()) && preValues.get(dto.getPreP()) != null) { |
| | | dto.setPreP(preValues.get(dto.getPreP()).toString()); |
| | |
| | | if (StringUtils.isNotBlank(dto.getPreCos()) && preValues.get(dto.getPreCos()) != null) { |
| | | dto.setPreCos(preValues.get(dto.getPreCos()).toString()); |
| | | } |
| | | } else { |
| | | dto.setPreP(""); |
| | | dto.setPreQ(""); |
| | | dto.setPreCos(""); |
| | | } |
| | | } catch (Exception ex) { |
| | | log.info(dto.getNodeName() + "获取预测值异常"); |
| | | ex.printStackTrace(); |
| | | log.info(dto.getNodeName() + "获取预测值异常," + ex.getMessage()); |
| | | } |
| | | |
| | | // 设置状态 |
| | | if (cosFlag && StringUtils.isNotBlank(dto.getCurCos()) && NumberUtil.isNumber(dto.getCurCos())) { |
| | | BigDecimal curCos = new BigDecimal(dto.getCurCos()); |
| | | if (dto.getLimitL() != null && dto.getLimitH() != null && |
| | | curCos.compareTo(dto.getLimitL()) < 0 || curCos.compareTo(dto.getLimitH()) > 0) { |
| | | dto.setStatus(1); |
| | | } else { |
| | | dto.setStatus(0); |
| | | } |
| | | } |
| | | } |
| | | return success(result); |