From ac15907b5565bb7ee11749414efead3f252d6ec3 Mon Sep 17 00:00:00 2001
From: dongyukun <1208714201@qq.com>
Date: 星期五, 21 三月 2025 16:56:33 +0800
Subject: [PATCH] point天频率采集

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java |   61 ++++++++++++++++++------------
 1 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java
index 6bd9314..7723944 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java
@@ -14,10 +14,8 @@
 import com.iailab.module.data.common.ApiDataQueryDTO;
 import com.iailab.module.data.common.ApiDataValueDTO;
 import com.iailab.module.model.common.utils.ASCIIUtil;
-import com.iailab.module.model.mcs.pre.service.MmItemOutputService;
-import com.iailab.module.model.mcs.pre.service.MmItemResultJsonService;
 import com.iailab.module.model.mcs.pre.service.MmItemResultService;
-import com.iailab.module.model.mcs.pre.service.MmItemTypeService;
+import com.iailab.module.model.mcs.sche.service.StAdjustResultService;
 import com.iailab.module.model.mdk.common.enums.ModelParamType;
 import com.iailab.module.model.mdk.sample.dto.ColumnItem;
 import com.iailab.module.model.mdk.sample.dto.ColumnItemPort;
@@ -57,13 +55,7 @@
     private MmItemResultService mmItemResultService;
 
     @Autowired
-    private MmItemResultJsonService mmItemResultJsonService;
-
-    @Autowired
-    private MmItemTypeService mmItemTypeService;
-
-    @Autowired
-    private MmItemOutputService mmItemOutputService;
+    private StAdjustResultService stAdjustResultService;
 
     /**
      * alter by zfc 2020.11.24 修改数据样本构造方案:sampleInfo中数据已按爪子进行分类,但爪内数据为无序的,
@@ -88,6 +80,15 @@
                 }
             }
         }
+
+        // 判断要调整的列
+        for (ColumnItemPort itemPort : sampleInfo.getColumnInfo()) {
+
+            for (ColumnItem columnItem : itemPort.getColumnItemList()) {
+
+            }
+        }
+
 
         int portIdx = 1;
         //对每个爪分别进行计算
@@ -134,25 +135,26 @@
                 //对每一项依次进行数据查询,然后将查询出的值赋给matrix对应的位置
                 for (int i = 0; i < entry.getColumnItemList().size(); i++) {
                     try {
-                        List<DataValueVO> dataEntityList = getData(entry.getColumnItemList().get(i), pointMap, planMap, indMap);
+                        List<DataValueVO> dataEntityList = getData(sampleInfo, entry.getColumnItemList().get(i), pointMap, planMap, indMap);
 
                         //补全数据
                         ColumnItem columnItem = entry.getColumnItemList().get(i);
                         dataEntityList = super.completionData(matrix.length, dataEntityList, columnItem.startTime, columnItem.endTime, columnItem.getParamType(), columnItem.getGranularity());
 
-
                         /** 如果数据取不满,把缺失的数据点放在后面 */
-                        if (dataEntityList != null && dataEntityList.size() != 0) {
-                            logger.info("设置matrix, i = " + i + ", size = " + dataEntityList.size());
-                            // 调整值
-                            double adjustVal = SampleInfo.getAdjustValueFromDeviation(portIdx, i + 1, sampleInfo.getDeviation());
-                            for (int k = 0; k < dataEntityList.size(); k++) {
-                                Double dataValue = dataEntityList.get(k).getDataValue();
-                                if (null != dataValue) {
-                                    // 用BigDecimal计算,解决double精度问题
-                                    matrix[k][i] = BigDecimal.valueOf(dataValue).add(BigDecimal.valueOf(adjustVal)).doubleValue();
-                                }
+                        if (CollectionUtils.isEmpty(dataEntityList)) {
+                            continue;
+                        }
+                        logger.info("设置matrix, i = " + i + ", size = " + dataEntityList.size());
+                        // 调整值
+                        double adjustVal = SampleInfo.getAdjustValueFromDeviation(portIdx, i + 1, sampleInfo.getDeviation());
+                        for (int k = 0; k < dataEntityList.size(); k++) {
+                            Double dataValue = dataEntityList.get(k).getDataValue();
+                            if (null == dataValue) {
+                                continue;
                             }
+                            // 用BigDecimal计算,解决double精度问题
+                            matrix[k][i] = BigDecimal.valueOf(dataValue).add(BigDecimal.valueOf(adjustVal)).doubleValue();
                         }
                     } catch (Exception e) {
                         e.printStackTrace();
@@ -172,6 +174,7 @@
     /**
      * getData
      *
+     * @param sampleInfo
      * @param columnItem
      * @param pointMap
      * @param planMap
@@ -179,7 +182,8 @@
      * @return
      * @throws Exception
      */
-    private List<DataValueVO> getData(ColumnItem columnItem, Map<String, ApiPointDTO> pointMap, Map<String, ApiPlanItemDTO> planMap, Map<String, ApiIndItemDTO> indMap) throws Exception {
+    private List<DataValueVO> getData(SampleInfo sampleInfo, ColumnItem columnItem, Map<String, ApiPointDTO> pointMap, Map<String, ApiPlanItemDTO> planMap,
+                                      Map<String, ApiIndItemDTO> indMap) throws Exception {
         List<DataValueVO> dataList = new ArrayList<>();
         String paramType = columnItem.getParamType();
         switch (ModelParamType.getEumByCode(paramType)) {
@@ -201,12 +205,19 @@
                 break;
             case NORMALITEM:
             case MERGEITEM:
-                List<DataValueVO> predictValue = mmItemResultService.getPredictValue(columnItem.getParamId(), columnItem.getStartTime(), columnItem.getEndTime());
-
+                List<DataValueVO> predictValue = new ArrayList<>();
+                if (sampleInfo.getIsAdjust()) {
+                    // 如果模拟调整先查调整结果
+                    predictValue = stAdjustResultService.getPredictValue(columnItem.getParamId(), sampleInfo.getPredictTime());
+                }
+                if (CollectionUtils.isEmpty(predictValue)) {
+                    predictValue = mmItemResultService.getPredictValue(columnItem.getParamId(), columnItem.getStartTime(), columnItem.getEndTime());
+                }
                 if (CollectionUtils.isEmpty(predictValue)) {
                     break;
                 }
                 dataList = predictValue;
+
                 break;
             case PLAN:
                 ApiDataQueryDTO queryPlanItemDto = new ApiDataQueryDTO();

--
Gitblit v1.9.3