From b270a07828a9627f1a42e254a430c9921fec4e95 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期三, 26 三月 2025 16:14:37 +0800 Subject: [PATCH] Merge branch 'master' of http://dlindusit.com:53929/r/iailab-plat --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java | 89 ++++++++++++++++++++------------------------ 1 files changed, 40 insertions(+), 49 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java index 53bed0b..430c810 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java @@ -1,24 +1,19 @@ package com.iailab.module.model.mdk.sample; -import com.iailab.module.data.api.ind.IndItemApi; import com.iailab.module.data.api.ind.dto.ApiIndItemDTO; -import com.iailab.module.data.api.plan.PlanItemApi; import com.iailab.module.data.api.plan.dto.ApiPlanItemDTO; -import com.iailab.module.data.api.point.DataPointApi; import com.iailab.module.data.api.point.dto.ApiPointDTO; import com.iailab.module.data.enums.DataPointFreqEnum; -import com.iailab.module.data.enums.TimeGranularityEnum; import com.iailab.module.data.enums.TimeGranularitySecEnum; import com.iailab.module.model.mcs.pre.service.MmPredictItemService; 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; import com.iailab.module.model.mdk.sample.dto.SampleInfo; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; import java.util.Calendar; import java.util.Date; -import java.util.List; import java.util.Map; /** @@ -27,15 +22,6 @@ * @createTime 2024年09月03日 */ abstract class SampleInfoConstructor { - - @Autowired - private DataPointApi dataPointApi; - - @Autowired - private PlanItemApi planItemApi; - - @Autowired - private IndItemApi indItemApi; @Autowired private MmPredictItemService mmPredictItemService; @@ -47,9 +33,11 @@ * @param predictTime * @return */ - protected SampleInfo prepareSampleInfo(String modelId, Date predictTime) { + protected SampleInfo prepareSampleInfo(String modelId, Date predictTime, Map<Integer, Integer> dynamicDataLength) { //样本的列信息 - return getColumnInfo(modelId, predictTime); + SampleInfo sampleInfo = getColumnInfo(modelId, predictTime, dynamicDataLength); + sampleInfo.setPredictTime(predictTime); + return sampleInfo; } /** @@ -68,7 +56,7 @@ * @param predictTime * @return */ - protected abstract SampleInfo getColumnInfo(String modelId, Date predictTime); + protected abstract SampleInfo getColumnInfo(String modelId, Date predictTime, Map<Integer, Integer> dynamicDataLength); /** * 样本的采样周期 @@ -86,31 +74,22 @@ * @return * @throws Exception */ - protected Date getStartTime(ColumnItem columnItem, Date originalTime, Map<String, ApiPointDTO> pointMap, Map<String, ApiPlanItemDTO> planMap) { + protected Date getStartTime(ColumnItem columnItem, Date originalTime) { Date dateTime = new Date(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(originalTime); switch (ModelParamType.getEumByCode(columnItem.getParamType())) { case DATAPOINT: - ApiPointDTO dataPoint = pointMap.get(columnItem.getParamId()); - if (dataPoint == null) { - return null; - } - dateTime = calculateTime(originalTime, true, columnItem.getDataLength(), DataPointFreqEnum.getEumByCode(dataPoint.getMinfreqid()).getValue()); + dateTime = calculateTime(originalTime, true, columnItem.getDataLength(), columnItem.getGranularity()); + break; + case PLAN: + dateTime = originalTime; + break; + case IND: + case IND_ASCII: + dateTime = calculateTime(originalTime, true, columnItem.getDataLength() - 1, columnItem.getGranularity()); break; case NORMALITEM: case MERGEITEM: - dateTime = calendar.getTime(); - break; - case IND: - dateTime = calculateTime(originalTime, true, columnItem.getDataLength(), 60); - break; - case PLAN: - ApiPlanItemDTO apiPlanItemDTO = planMap.get(columnItem.getParamId()); - if (apiPlanItemDTO == null) { - return null; - } - dateTime = calculateTime(originalTime, true, columnItem.getDataLength(), TimeGranularitySecEnum.getEumByCode(apiPlanItemDTO.getTimeGranularity()).getValue()); + dateTime = calculateTime(originalTime, false, 1, columnItem.getGranularity()); break; default: break; @@ -126,23 +105,24 @@ * @return * @throws Exception */ - protected Date getEndTime(ColumnItem columnItem, Date originalTime,Map<String, ApiPointDTO> pointMap, Map<String, ApiPlanItemDTO> planMap) { + protected Date getEndTime(ColumnItem columnItem, Date originalTime) { Date dateTime = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(originalTime); switch (ModelParamType.getEumByCode(columnItem.getParamType())) { case DATAPOINT: - dateTime = calendar.getTime(); + dateTime = calculateTime(originalTime, true, 1, columnItem.getGranularity()); + break; + case PLAN: + dateTime = calculateTime(originalTime, false, columnItem.getDataLength()-1, columnItem.getGranularity()); + break; + case IND: + case IND_ASCII: + dateTime = originalTime; break; case NORMALITEM: case MERGEITEM: - dateTime = calculateTime(originalTime, false, columnItem.getDataLength(), 60); - break; - case IND: - dateTime = calendar.getTime(); - break; - case PLAN: - dateTime = calendar.getTime(); + dateTime = calculateTime(originalTime, false, columnItem.getDataLength() + 1, columnItem.getGranularity()); break; default: break; @@ -157,7 +137,7 @@ * @return * @throws Exception */ - protected Integer getGranularity(ColumnItem columnItem,Map<String, ApiPointDTO> pointMap, Map<String, ApiPlanItemDTO> planMap) { + protected Integer getGranularity(ColumnItem columnItem,Map<String, ApiPointDTO> pointMap, Map<String, ApiPlanItemDTO> planMap,Map<String, ApiIndItemDTO> indMap) { // 默认60s Integer granularity = 60; switch (ModelParamType.getEumByCode(columnItem.getParamType())) { @@ -170,7 +150,8 @@ granularity = mmPredictItemService.getItemByOutPutId(columnItem.getParamId()).getGranularity(); break; case IND: - ApiIndItemDTO indItemDTO = indItemApi.getInfoById(columnItem.getParamId()); + case IND_ASCII: + ApiIndItemDTO indItemDTO = indMap.get(columnItem.getParamId()); granularity = TimeGranularitySecEnum.getEumByCode(indItemDTO.getTimeGranularity()).getValue();; break; case PLAN: @@ -197,7 +178,7 @@ if (backward) { timeLength = (-1) * dataLength; } else { - timeLength = dataLength - 1; + timeLength = dataLength; } Date desTime = originalTime; Calendar calendar = Calendar.getInstance(); @@ -207,4 +188,14 @@ calendar.add(Calendar.SECOND, timeLength * granularity); return calendar.getTime(); } + + protected int getDataLength(Map<Integer, Integer> dynamicDataLength, Integer port, Integer dataLength) { + if (CollectionUtils.isEmpty(dynamicDataLength)) { + return dataLength; + } + if (dynamicDataLength.containsKey(port)) { + return dynamicDataLength.get(port); + } + return dataLength; + } } \ No newline at end of file -- Gitblit v1.9.3