| | |
| | | viewDto.setOutId(outId); |
| | | viewDto.setResultstr(output.getResultstr()); |
| | | viewDto.setResultName(output.getResultName()); |
| | | viewDto.setRealData(getHisData(output.getPointid(), startTime, endTime)); |
| | | viewDto.setRealData(getHisData(output.getPointid(), startTime, endTime, reqVO.getPrec())); |
| | | viewDto.setPreDataN(mmItemResultService.getData(output.getId(), startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | viewDto.setPreDataL(mmItemResultLastPointService.getData(output.getId(), startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | viewDto.setCurData(mmItemResultJsonService.getData(output.getId(), predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | |
| | | //处理预测累计 |
| | | if (output.getIscumulant() == 1) { |
| | | if (StringUtils.isNotBlank(output.getCumulpoint())) { |
| | | viewDto.setCumulantRealData(getHisData(output.getCumulpoint(), startTime, endTime)); |
| | | viewDto.setCumulantRealData(getHisData(output.getCumulpoint(), startTime, endTime, reqVO.getPrec())); |
| | | } |
| | | viewDto.setCumulantPreData(mmItemResultService.getData(output.getId() + CommonDict.CUMULANT_SUFFIX, startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | } |
| | |
| | | legend.add(out.getResultName()); |
| | | PreDataSampleViewRespDTO viewDto = new PreDataSampleViewRespDTO(); |
| | | if (StringUtils.isNotBlank(out.getPointid())) { |
| | | viewDto.setRealData(getHisData(out.getPointid(), startTime, endTime)); |
| | | viewDto.setRealData(getHisData(out.getPointid(), startTime, endTime, reqVO.getPrec())); |
| | | } |
| | | viewDto.setPreDataN(mmItemResultService.getData(out.getId(), startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | //处理预测累计 |
| | | if (out.getIscumulant() == 1) { |
| | | if (StringUtils.isNotBlank(out.getCumulpoint())) { |
| | | viewDto.setCumulantRealData(getHisData(out.getCumulpoint(), startTime, endTime)); |
| | | viewDto.setCumulantRealData(getHisData(out.getCumulpoint(), startTime, endTime, reqVO.getPrec())); |
| | | } |
| | | viewDto.setCumulantPreData(mmItemResultService.getData(out.getId() + CommonDict.CUMULANT_SUFFIX, startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | } |
| | |
| | | dataView.setPreDataN(mmItemResultService.getData(outPut.getId(), predictTime, endTime, timeFormat)); |
| | | dataView.setPreDataL(mmItemResultLastPointService.getData(outPut.getId(), startTime, endTime, timeFormat)); |
| | | break; |
| | | case CL: |
| | | dataView.setPreDataN(mmItemResultService.getData(outPut.getId(), predictTime, endTime, timeFormat)); |
| | | dataView.setPreDataL(mmItemResultLastPointService.getData(outPut.getId(), startTime, endTime, timeFormat)); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | //处理预测累计 |
| | | if (outPut.getIscumulant() != null && outPut.getIscumulant() == 1) { |
| | | /*if (StringUtils.isNotBlank(outPut.getCumulpoint())) { |
| | | dataView.setCumulantRealData(getHisData(outPut.getCumulpoint(), startTime, endTime)); |
| | | }*/ |
| | | List<Object[]> cumulantPreList = mmItemResultService.getData(outPut.getId() + CommonDict.CUMULANT_SUFFIX, startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | dataView.setCumulantPreData(cumulantPreList); |
| | | if (!CollectionUtils.isEmpty(cumulantPreList)) { |
| | | dataView.setCumulantPreLast(new BigDecimal(cumulantPreList.get(cumulantPreList.size() - 1)[1].toString()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | } |
| | | |
| | | if (!CollectionUtils.isEmpty(dataView.getRealData())) { |
| | | Object[] rdo = dataView.getRealData().get(dataView.getRealData().size() - 1); |
| | | dataView.setCurrValue(new BigDecimal(rdo[1].toString())); |
| | |
| | | } |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | List<MmItemOutputEntity> outs = mmItemOutputService.getByItemid(predictItem.getId()); |
| | | for (MmItemOutputEntity out : outs) { |
| | | //处理预测累计 |
| | | if (out.getIscumulant() == 1) { |
| | | dataView.setCumulantPreData(mmItemResultService.getData(out.getId() + CommonDict.CUMULANT_SUFFIX, startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | } |
| | | } |
| | | if (!CollectionUtils.isEmpty(dataView.getCumulantPreData())) { |
| | | List<Double> cumulantPreList = dataView.getCumulantPreData().stream().map(t -> { |
| | | return new Double(t[1].toString()); |
| | | }).collect(Collectors.toList()); |
| | | dataView.setCumulantPreLast(new BigDecimal(cumulantPreList.get(cumulantPreList.size() - 1)).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | |
| | | result.setPredictTime(predictTime); |
| | |
| | | * @param pointId |
| | | * @param startTime |
| | | * @param endTime |
| | | * @param prec |
| | | * @return |
| | | */ |
| | | private List<Object[]> getHisData(String pointId, Date startTime, Date endTime) { |
| | | private List<Object[]> getHisData(String pointId, Date startTime, Date endTime, Integer prec) { |
| | | List<Object[]> result = new ArrayList<>(); |
| | | if (StringUtils.isBlank(pointId)) { |
| | | return result; |
| | |
| | | if (CollectionUtils.isEmpty(valueDTOS)) { |
| | | return result; |
| | | } |
| | | int defaultPrec = 3; |
| | | valueDTOS.forEach(item -> { |
| | | Object[] values = new Object[2]; |
| | | values[0] = DateUtils.format(item.getT(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | values[1] = new BigDecimal(item.getV()).setScale(3, BigDecimal.ROUND_HALF_UP); |
| | | if (prec != null && prec < 0) { |
| | | values[1] = item.getV(); |
| | | } else if (prec != null && prec > 0) { |
| | | values[1] = new BigDecimal(item.getV()).setScale(prec, BigDecimal.ROUND_HALF_UP); |
| | | } else { |
| | | values[1] = new BigDecimal(item.getV()).setScale(defaultPrec, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | result.add(values); |
| | | }); |
| | | return result; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Object[]> getItemResult(String outputid, Date startTime, Date endTime, String timeFormat) { |
| | | return mmItemResultService.getData(outputid,startTime,endTime,timeFormat); |
| | | public List<Object[]> getItemResult(PreItemResultReqVO reqVO) { |
| | | |
| | | return mmItemResultService.getData(reqVO.getOutputid(),reqVO.getStartTime(),reqVO.getEndTime(),reqVO.getTimeFormat()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Object[]> getItemResultLastPoint(String outputid, Date startTime, Date endTime, String timeFormat) { |
| | | return mmItemResultLastPointService.getData(outputid,startTime,endTime,timeFormat); |
| | | public List<Object[]> getItemResultLastPoint(PreItemResultReqVO reqVO) { |
| | | return mmItemResultLastPointService.getData(reqVO.getOutputid(),reqVO.getStartTime(),reqVO.getEndTime(),reqVO.getTimeFormat()); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean useSuggest(StAlarmAndSuggestReqVO reqVO) { |
| | | return stScheduleSuggestService.useSuggest(reqVO); |
| | | } |
| | | |
| | | private Date[] calResultTime(ItemVO predictItem, Date startTimeReq, Date endTimeReq, int lengthLeft, int lengthRight) { |