From 8fd9f6efcb6575d68d39302efe046558d8b1534c Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期二, 14 一月 2025 14:39:16 +0800
Subject: [PATCH] 预测值

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 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 d918e48..ea66d6a 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
@@ -253,20 +253,20 @@
         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();
         }
 
@@ -318,10 +318,10 @@
         }
         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();
 
@@ -346,7 +346,7 @@
         } 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));
@@ -359,12 +359,24 @@
                 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);

--
Gitblit v1.9.3