From 271fed395d4d3e4ab8cdb44ccf466859ba485e46 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期四, 09 一月 2025 17:45:33 +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/SampleDataConstructor.java | 36 +++++++++++++----------------------- 1 files changed, 13 insertions(+), 23 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java index a51c53f..5f5befc 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java @@ -1,8 +1,12 @@ package com.iailab.module.model.mdk.sample; +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.TimeGranularitySecEnum; +import com.iailab.module.model.mcs.pre.enums.PredGranularityEnum; import com.iailab.module.model.mdk.common.enums.ModelParamType; import com.iailab.module.model.mdk.sample.dto.SampleData; import com.iailab.module.model.mdk.sample.dto.SampleInfo; @@ -12,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; -import java.sql.Timestamp; import java.util.*; abstract class SampleDataConstructor { @@ -21,6 +24,8 @@ @Autowired private DataPointApi dataPointApi; + @Autowired + private PlanItemApi planItemApi; /** * prepareSampleData @@ -28,7 +33,7 @@ * @param sampleInfo * @return */ - public abstract List<SampleData> prepareSampleData(SampleInfo sampleInfo); + public abstract List<SampleData> prepareSampleData(SampleInfo sampleInfo) throws Exception; /** * 补全数据 @@ -39,8 +44,7 @@ * @param endTime * @return */ - public List<DataValueVO> completionData(int length, List<DataValueVO> dataEntityList, Date startTime, Date endTime, - String paramId, String paramType) { + public List<DataValueVO> completionData(int length, List<DataValueVO> dataEntityList, Date startTime, Date endTime, String paramType, Integer granularity) { if (CollectionUtils.isEmpty(dataEntityList) || length == dataEntityList.size()) { return dataEntityList; } else if (length < dataEntityList.size()) { @@ -58,29 +62,15 @@ case NORMALITEM: case MERGEITEM: // 预测值 - Calendar calendar = Calendar.getInstance(); - calendar.setTime(startTime); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.add(Calendar.DAY_OF_YEAR, 1); - startTime = calendar.getTime(); - start = startTime.getTime(); - - calendar.setTime(endTime); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - endTime = calendar.getTime(); - end = endTime.getTime(); - - oneMin = 24 * 60 * 60 * 1000; + oneMin = granularity * 1000L; + start = start - (start % oneMin); + end = end - (end % oneMin); mins = ((end - start) / oneMin); break; case DATAPOINT: + case PLAN: // 测点值 - ApiPointDTO dataPoint = dataPointApi.getInfoById(paramId); - oneMin = 1000L * DataPointFreqEnum.getEumByCode(dataPoint.getMinfreqid()).getValue(); + oneMin = 1000L * granularity; // 设置时间偏移量 start = start - (start % oneMin) + oneMin; end = end - (end % oneMin) + oneMin; -- Gitblit v1.9.3