| | |
| | | } |
| | | String timeFormat = StringUtils.isBlank(reqVO.getTimeFormat()) ? DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND : reqVO.getTimeFormat(); |
| | | PreLineTypeEnum lineType = chartParams.get(CommonConstant.LINE_TYPE) == null ? PreLineTypeEnum.TN : PreLineTypeEnum.getEumByCode(chartParams.get(CommonConstant.LINE_TYPE)); |
| | | BigDecimal rangeH = chartParams.get(CommonConstant.RANGE_H) == null ? BigDecimal.ZERO : new BigDecimal(chartParams.get(CommonConstant.RANGE_H)); |
| | | BigDecimal rangeL = chartParams.get(CommonConstant.RANGE_L) == null ? BigDecimal.ZERO : new BigDecimal(chartParams.get(CommonConstant.RANGE_L)); |
| | | BigDecimal limitH = chartParams.get(CommonConstant.LIMIT_H) == null ? BigDecimal.ZERO : new BigDecimal(chartParams.get(CommonConstant.LIMIT_H)); |
| | | BigDecimal limitL = chartParams.get(CommonConstant.LIMIT_L) == null ? BigDecimal.ZERO : new BigDecimal(chartParams.get(CommonConstant.LIMIT_L)); |
| | | BigDecimal rangeH = chartParams.get(CommonConstant.RANGE_H) == null ? null : new BigDecimal(chartParams.get(CommonConstant.RANGE_H)); |
| | | BigDecimal rangeL = chartParams.get(CommonConstant.RANGE_L) == null ? null : new BigDecimal(chartParams.get(CommonConstant.RANGE_L)); |
| | | BigDecimal limitH = chartParams.get(CommonConstant.LIMIT_H) == null ? null : new BigDecimal(chartParams.get(CommonConstant.LIMIT_H)); |
| | | BigDecimal limitL = chartParams.get(CommonConstant.LIMIT_L) == null ? null : new BigDecimal(chartParams.get(CommonConstant.LIMIT_L)); |
| | | int lengthLeft = chartParams.get(CommonConstant.LENGTH_LEFT) == null ? predictItem.getPredictLength() : new BigDecimal(chartParams.get(CommonConstant.LENGTH_LEFT)).intValue(); |
| | | int lengthRight = chartParams.get(CommonConstant.LENGTH_RIGHT) == null ? predictItem.getPredictLength() : new BigDecimal(chartParams.get(CommonConstant.LENGTH_RIGHT)).intValue(); |
| | | |
| | |
| | | dataView.setRealData(new ArrayList<>()); |
| | | } |
| | | dataView.setCurData(mmItemResultJsonService.getData(outPut.getId(), predictTime, timeFormat)); |
| | | dataView.setLineType(lineType.getCode()); |
| | | switch (lineType) { |
| | | case TN: |
| | | dataView.setPreDataN(mmItemResultService.getData(outPut.getId(), startTime, endTime, timeFormat)); |
| | |
| | | default: |
| | | break; |
| | | } |
| | | if (!CollectionUtils.isEmpty(dataView.getRealData())) { |
| | | Object[] rdo = dataView.getRealData().get(dataView.getRealData().size() - 1); |
| | | dataView.setCurrValue(new BigDecimal(rdo[1].toString())); |
| | | } |
| | | |
| | | if (!CollectionUtils.isEmpty(dataView.getCurData())) { |
| | | List<Double> curList = dataView.getCurData().stream().map(t -> { |
| | |
| | | }).collect(Collectors.toList()); |
| | | dataView.setPreMax(new BigDecimal(curList.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | dataView.setPreMin(new BigDecimal(curList.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | dataView.setPreLast(new BigDecimal(curList.get(curList.size() - 1))); |
| | | dataView.setPreCumulant(new BigDecimal(curList.stream().mapToDouble(Double::doubleValue).sum()) |
| | | .divide(new BigDecimal(HOUR_MINS), 2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | |
| | | String alarmObj = chartParams.get(CommonConstant.ALARM_OBJ); |
| | | if (StringUtils.isNotBlank(alarmObj)) { |
| | | List<AlarmMessageRespDTO> alarmList = ConvertUtils.sourceToTarget(mmPredictAlarmMessageService.getList(alarmObj, predictTime), AlarmMessageRespDTO.class); |
| | | dataView.setAlarmList(alarmList); |
| | | if (CollectionUtils.isEmpty(alarmList)) { |
| | | dataView.setAlarmMessage("暂无预警信息"); |
| | | } else { |
| | | dataView.setAlarmMessage(alarmList.get(0).getContent()); |
| | | } |
| | | } |
| | | |
| | | result.setPredictTime(predictTime); |
| | |
| | | return result; |
| | | } |
| | | |
| | | public Map<String, BigDecimal> getPredictLastValue(PredictLastValueReqVO reqVO) { |
| | | Map<String, BigDecimal> result = new HashMap<>(reqVO.getItemNos().size()); |
| | | if (CollectionUtils.isEmpty(reqVO.getItemNos())) { |
| | | return result; |
| | | } |
| | | List<String[]> itemNos = reqVO.getItemNos(); |
| | | for (String[] itemNo : itemNos) { |
| | | String key = itemNo[0] + "_" + itemNo[1] + "_" + itemNo[2]; |
| | | ItemVO predictItem = mmPredictItemService.getItemByItemNo(itemNo[0]); |
| | | if (predictItem == null || predictItem.getLastTime() == null) { |
| | | result.put(key, BigDecimal.ZERO); |
| | | } |
| | | MmItemOutputEntity outPut = mmItemOutputService.getByItemid(predictItem.getId(), itemNo[1], itemNo[2]); |
| | | |
| | | Date predictTime = predictItem.getLastTime(); |
| | | List<Object[]> curData = mmItemResultJsonService.getData(outPut.getId(), predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | if(CollectionUtils.isEmpty(curData)) { |
| | | result.put(key, BigDecimal.ZERO); |
| | | } else { |
| | | result.put(key, new BigDecimal(curData.get(curData.size() - 1)[1].toString())); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private Date[] calResultTime(ItemVO predictItem, Date startTimeReq, Date endTimeReq, int lengthLeft, int lengthRight) { |
| | | Date[] result = new Date[3]; |
| | | Date predictTime = predictItem.getLastTime(); |