From ead00557209f14e506ff4115ac25cadfa08d3280 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期四, 14 十一月 2024 15:35:41 +0800 Subject: [PATCH] 预测结果展示 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java index 5351dcd..0236bb7 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java @@ -11,6 +11,7 @@ import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; import com.iailab.module.model.mcs.pre.service.*; import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; +import com.iailab.module.model.mdk.vo.ItemVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; @@ -185,6 +186,53 @@ return result; } + @Override + public PreDataItemChartRespVO getPreDataItemChart(PreDataItemChartReqVO reqVO) { + PreDataItemChartRespVO result = new PreDataItemChartRespVO(); + ItemVO predictItem = mmPredictItemService.getItemById(reqVO.getItemId()); + if (predictItem == null) { + return result; + } + if (predictItem.getLastTime() == null) { + return result; + } + result.setLastTime(predictItem.getLastTime()); + Date startTime = reqVO.getStartTime(); + if (startTime == null) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(predictItem.getLastTime()); + calendar.add(Calendar.HOUR_OF_DAY, -1); + startTime = calendar.getTime(); + } + Date endTime = reqVO.getEndTime(); + if (endTime == null) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(predictItem.getLastTime()); + calendar.add(Calendar.HOUR_OF_DAY, 1); + endTime = calendar.getTime(); + } + List<String> categories = DateUtils.getTimeScale(startTime, endTime, predictItem.getGranularity()); + List<String> legend = new ArrayList<>(); + LinkedHashMap<String, PreDataSampleViewRespDTO> viewMap = new LinkedHashMap<>(); + List<MmItemOutputEntity> outs = mmItemOutputService.getByItemid(reqVO.getItemId()); + if (CollectionUtils.isEmpty(outs)) { + return result; + } + for (MmItemOutputEntity out : outs) { + legend.add(out.getResultstr()); + PreDataSampleViewRespDTO viewDto = new PreDataSampleViewRespDTO(); + viewDto.setRealData(getHisData(out.getPointid(), startTime, endTime)); + viewDto.setPreDataN(mmItemResultService.getData(out.getId(), startTime, endTime)); + viewMap.put(out.getResultstr(), viewDto); + } + result.setStartTime(startTime); + result.setEndTime(endTime); + result.setCategories(categories); + result.setLegend(legend); + result.setViewMap(viewMap); + return result; + } + /** * 获取真实值 * -- Gitblit v1.9.3