| | |
| | | |
| | | Map<String, Object> realDataMap = new HashMap<>(); |
| | | if (StringUtils.isNotBlank(outPut.getPointid())) { |
| | | dataView.setRealData(getHisData(outPut.getPointid(), startTime, endTime, timeFormat)); |
| | | dataView.setRealData(getHisData(outPut.getPointid(), startTime, endTime, timeFormat, decimalPlaces)); |
| | | dataView.getRealData().forEach(item -> { |
| | | realDataMap.put(item[0].toString(), item[1]); |
| | | }); |
| | |
| | | } |
| | | |
| | | // 调整预测值 |
| | | dataView.setAdjData(stAdjustResultService.getData(outPut.getId(),predictTime,timeFormat)); |
| | | dataView.setAdjData(stAdjustResultService.getData(outPut.getId(), predictTime, timeFormat, decimalPlaces)); |
| | | dataView.setLineType(lineType.getCode()); |
| | | switch (lineType) { |
| | | case TN: |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取真实值 |
| | | * |
| | | * @param pointId |
| | | * @param startTime |
| | | * @param endTime |
| | | * @param timeFormat |
| | | * @return |
| | | */ |
| | | private List<Object[]> getHisData(String pointId, Date startTime, Date endTime, String timeFormat, int decimalPlaces) { |
| | | List<Object[]> result = new ArrayList<>(); |
| | | ApiPointDTO pointDTO = dataPointApi.getInfoById(pointId); |
| | | ApiPointValueQueryDTO queryPointDto = new ApiPointValueQueryDTO(); |
| | | queryPointDto.setPointNo(pointDTO.getPointNo()); |
| | | queryPointDto.setStart(startTime); |
| | | queryPointDto.setEnd(endTime); |
| | | List<ApiPointValueDTO> valueDTOS = dataPointApi.queryPointHistoryValue(queryPointDto); |
| | | if (CollectionUtils.isEmpty(valueDTOS)) { |
| | | return result; |
| | | } |
| | | valueDTOS.forEach(item -> { |
| | | Object[] values = new Object[2]; |
| | | values[0] = DateUtils.format(item.getT(), timeFormat); |
| | | values[1] = new BigDecimal(item.getV()).setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); |
| | | result.add(values); |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 新增预警信息 |
| | | * |
| | | * @param dto |
| | |
| | | |
| | | List<Object[]> getData(String outputId, Date predictTime, String timeFormat); |
| | | |
| | | List<Object[]> getData(String outputId, Date predictTime, String timeFormat, int decimalPlaces); |
| | | |
| | | StAdjustResultRespVO getInfo(String id); |
| | | |
| | | PageResult<StAdjustResultRespVO> page(@Valid StAdjustResultPageReqVO pageVO); |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Object[]> getData(String outputId, Date predictTime, String timeFormat, int decimalPlaces) { |
| | | List<Object[]> result = new ArrayList<>(); |
| | | QueryWrapper<StAdjustResultEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("output_id", outputId) |
| | | .eq("adjust_time", DateUtils.format(predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | StAdjustResultEntity data = baseDao.selectOne(wrapper); |
| | | if (data == null || StringUtils.isBlank(data.getJsonValue())) { |
| | | return result; |
| | | } |
| | | List<Double> valueList = JSONArray.parseArray(data.getJsonValue(), Double.class); |
| | | if (CollectionUtils.isEmpty(valueList)) { |
| | | return result; |
| | | } |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(predictTime); |
| | | valueList.forEach(value -> { |
| | | Object[] dv = {DateUtils.format(calendar.getTime(), timeFormat), new BigDecimal(value).setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP)}; |
| | | calendar.add(Calendar.MINUTE, 1); |
| | | result.add(dv); |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public StAdjustResultRespVO getInfo(String id) { |
| | | StAdjustResultEntity entity = baseDao.selectById(id); |
| | | StAdjustResultRespVO result = ConvertUtils.sourceToTarget(entity, StAdjustResultRespVO.class); |