| | |
| | | if (startTime == null) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(predictItem.getLastTime()); |
| | | calendar.add(Calendar.MINUTE, -1 * predictItem.getPredictLength()); |
| | | calendar.add(Calendar.SECOND, -1 * predictItem.getPredictLength() * predictItem.getGranularity()); |
| | | startTime = calendar.getTime(); |
| | | } |
| | | Date endTime = reqVO.getEndTime(); |
| | | if (endTime == null) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(predictItem.getLastTime()); |
| | | calendar.add(Calendar.MINUTE, predictItem.getPredictLength()); |
| | | calendar.add(Calendar.SECOND, predictItem.getPredictLength() * predictItem.getGranularity()); |
| | | endTime = calendar.getTime(); |
| | | } |
| | | if (endTime.getTime() <= startTime.getTime()) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startTime); |
| | | calendar.add(Calendar.MINUTE, predictItem.getPredictLength()); |
| | | calendar.add(Calendar.SECOND, predictItem.getPredictLength() * predictItem.getGranularity()); |
| | | endTime = calendar.getTime(); |
| | | } |
| | | |
| | |
| | | } |
| | | 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(); |
| | | |
| | |
| | | } else { |
| | | dataView.setRealData(new ArrayList<>()); |
| | | } |
| | | dataView.setCurData(mmItemResultJsonService.getData(outPut.getId(), predictTime, timeFormat)); |
| | | // dataView.setCurData(mmItemResultJsonService.getData(outPut.getId(), predictTime, timeFormat)); |
| | | switch (lineType) { |
| | | case TN: |
| | | dataView.setPreDataN(mmItemResultService.getData(outPut.getId(), startTime, endTime, timeFormat)); |
| | |
| | | break; |
| | | } |
| | | |
| | | if (!CollectionUtils.isEmpty(dataView.getCurData())) { |
| | | List<Double> curList = dataView.getCurData().stream().map(t -> { |
| | | if (!CollectionUtils.isEmpty(dataView.getPreDataN())) { |
| | | List<Double> curList = dataView.getPreDataN().stream().map(t -> { |
| | | return new Double(t[1].toString()); |
| | | }).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))); |
| | | } |
| | | |
| | | 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); |