From 5ceaf8ba5734dcebd26991edb0d6c2280849348d Mon Sep 17 00:00:00 2001
From: Jay <csj123456>
Date: 星期三, 05 三月 2025 15:22:15 +0800
Subject: [PATCH] 新增修改预警配置接口和修改图表参数配置接口

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java |   73 ++++++++++++++++++++++++++++++++----
 1 files changed, 64 insertions(+), 9 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 1687d46..a08edd1 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
@@ -25,8 +25,10 @@
 import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmMessageEntity;
 import com.iailab.module.model.mcs.pre.service.*;
 import com.iailab.module.model.mcs.pre.vo.MmItemOutputRespVO;
+import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmConfigSaveReqVO;
 import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessageSaveReqVO;
 import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO;
+import com.iailab.module.model.mcs.sche.entity.StAdjustConfigDetEntity;
 import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity;
 import com.iailab.module.model.mcs.sche.entity.StScheduleSuggestEntity;
 import com.iailab.module.model.mcs.sche.service.*;
@@ -78,6 +80,9 @@
     private MmItemResultJsonService mmItemResultJsonService;
 
     @Autowired
+    private StAdjustResultService stAdjustResultService;
+
+    @Autowired
     private ChartService chartService;
 
     @Autowired
@@ -113,7 +118,8 @@
     @Autowired
     private StScheduleModelSettingService stScheduleModelSettingService;
 
-
+    @Autowired
+    private StAdjustConfigService stAdjustConfigService;
     private int HOUR_MINS = 60;
 
     @Override
@@ -212,7 +218,10 @@
             viewDto.setRealData(getHisData(output.getPointid(), startTime, endTime));
             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, 3));
+            viewDto.setCurData(mmItemResultJsonService.getData(output.getId(), predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
+            // 模拟调整曲线
+            viewDto.setAdjData(stAdjustResultService.getData(output.getId(), predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
+
             List<Double> values = new ArrayList<>();
             if (!CollectionUtils.isEmpty(viewDto.getRealData())) {
                 List<Double> hisValues = new ArrayList<>();
@@ -259,6 +268,14 @@
                 viewDto.setMaxValue(new BigDecimal(values.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP));
                 viewDto.setMinValue(new BigDecimal(values.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP));
             }
+            //处理预测累计
+            if (output.getIscumulant() == 1) {
+                if (StringUtils.isNotBlank(output.getCumulpoint())) {
+                    viewDto.setCumulantRealData(getHisData(output.getCumulpoint(), startTime, endTime));
+                }
+                viewDto.setCumulantPreData(mmItemResultService.getData(output.getId() + CommonDict.CUMULANT_SUFFIX, startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
+            }
+
             dataViewList.add(viewDto);
         }
         result.setStartTime(startTime);
@@ -316,13 +333,15 @@
                 viewDto.setRealData(getHisData(out.getPointid(), startTime, endTime));
             }
             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.getPointid() + CommonDict.CUMULANT_SUFFIX, startTime, endTime));
+                    viewDto.setCumulantRealData(getHisData(out.getCumulpoint(), startTime, endTime));
                 }
                 viewDto.setCumulantPreData(mmItemResultService.getData(out.getId() + CommonDict.CUMULANT_SUFFIX, startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
             }
+            // 调整预测值
+            viewDto.setAdjData(stAdjustResultService.getData(out.getId(),predictItem.getLastTime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
 
             viewMap.put(out.getResultName(), viewDto);
         }
@@ -386,7 +405,9 @@
         } else {
             dataView.setRealData(new ArrayList<>());
         }
-        dataView.setCurData(mmItemResultJsonService.getData(outPut.getId(), predictTime, timeFormat));
+        dataView.setCurData(mmItemResultJsonService.getData(outPut.getId(), predictTime, timeFormat, 3));
+        // 调整预测值
+        dataView.setAdjData(stAdjustResultService.getData(outPut.getId(),predictTime,timeFormat));
         dataView.setLineType(lineType.getCode());
         switch (lineType) {
             case TN:
@@ -529,6 +550,9 @@
      */
     private List<Object[]> getHisData(String pointId, Date startTime, Date endTime) {
         List<Object[]> result = new ArrayList<>();
+        if (StringUtils.isBlank(pointId)) {
+            return result;
+        }
         ApiPointDTO pointDTO = dataPointApi.getInfoById(pointId);
         ApiPointValueQueryDTO queryPointDto = new ApiPointValueQueryDTO();
         queryPointDto.setPointNo(pointDTO.getPointNo());
@@ -541,7 +565,7 @@
         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(2, BigDecimal.ROUND_HALF_UP);
+            values[1] = new BigDecimal(item.getV()).setScale(3, BigDecimal.ROUND_HALF_UP);
             result.add(values);
         });
         return result;
@@ -570,7 +594,7 @@
         valueDTOS.forEach(item -> {
             Object[] values = new Object[2];
             values[0] = DateUtils.format(item.getT(), timeFormat);
-            values[1] = new BigDecimal(item.getV()).setScale(2, BigDecimal.ROUND_HALF_UP);
+            values[1] = new BigDecimal(item.getV()).setScale(3, BigDecimal.ROUND_HALF_UP);
             result.add(values);
         });
         return result;
@@ -697,9 +721,13 @@
                 result.put(key, BigDecimal.ZERO);
             }
             MmItemOutputEntity outPut = mmItemOutputService.getByItemid(predictItem.getId(), itemNo[1], itemNo[2]);
-
+            String outputId = outPut.getId();
+            // 如果第5个参数为1,则取累计值
+            if ("1".equals(itemNo[4])){
+                outputId = outPut.getId() + CommonDict.CUMULANT_SUFFIX;
+            }
             Date predictTime = predictItem.getLastTime();
-            List<Object[]> curData = mmItemResultJsonService.getData(outPut.getId(), predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND);
+            List<Object[]> curData = mmItemResultJsonService.getData(outputId, predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND);
             if(CollectionUtils.isEmpty(curData)) {
                 result.put(key, BigDecimal.ZERO);
             } else {
@@ -790,6 +818,33 @@
         return true;
     }
 
+    @Override
+    public List<StAdjustConfigDetDTO> getAdjustConfigListByModelId(String modelId) {
+        List<StAdjustConfigDetEntity> list = stAdjustConfigService.getDetByModelId(modelId);
+        return ConvertUtils.sourceToTarget(list, StAdjustConfigDetDTO.class);
+    }
+
+    @Override
+    public Boolean updateAlarmConfig(String alarmObj,String upperLimit,String lowerLimit) {
+        MmPredictAlarmConfigSaveReqVO reqVO = new MmPredictAlarmConfigSaveReqVO();
+        reqVO.setAlarmObj(alarmObj);
+        reqVO.setUpperLimit(BigDecimal.valueOf(Double.parseDouble(upperLimit)));
+        reqVO.setLowerLimit(BigDecimal.valueOf(Double.parseDouble(lowerLimit)));
+        mmPredictAlarmConfigService.updateByAlarmObj(reqVO);
+        return true;
+    }
+
+    @Override
+    public Boolean updateChartParam(ChartDTO chartDTO) {
+        ChartDTO oldChartDTO = chartService.getChartByChartCode(chartDTO.getChartCode());
+        List<ChartParamDTO> chartParams = chartDTO.getChartParams();
+        chartParams.forEach(item -> {
+            item.setChartId(oldChartDTO.getId());
+        });
+        chartParamService.updateByChartIdAndParamCode(chartParams);
+        return true;
+    }
+
     /**
      * 计算功率因数 p²/(根号:p²+Q²)
      **/

--
Gitblit v1.9.3