From 37c27edd781380879966b1d9d5518a920acb6b62 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 18 三月 2025 09:57:09 +0800 Subject: [PATCH] columnItem.getDataLength() + 1 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java | 54 +++++++++++++++++++----------------------------------- 1 files changed, 19 insertions(+), 35 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 6915322..5910cdc 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 @@ -52,8 +52,7 @@ } List<DataValueVO> completionDataEntityList = new ArrayList<>(); - long oneMin = 0L; - + long oneMin = granularity * 1000L;; long start = startTime.getTime(); long end = endTime.getTime(); long mins = 0L; @@ -61,47 +60,18 @@ switch (ModelParamType.getEumByCode(paramType)) { case NORMALITEM: case MERGEITEM: - // 预测值 - oneMin = granularity * 1000L; // 设置时间偏移量 - if (granularity >= 24*60*60) { - // 如果时间粒度大于等于一天,因为时区问题,特殊处理,否则时间为8:00,而非0:00 - start = start - ((start+8*60*60*1000) % oneMin); - end = end - ((end+8*60*60*1000) % oneMin); - } else { - start = start - (start % oneMin); - end = end - (end % oneMin); - } - mins = ((end - start) / oneMin); + mins = calMins(start, end, granularity); break; case DATAPOINT: case PLAN: - // 测点值 - oneMin = 1000L * granularity; // 设置时间偏移量 - if (granularity >= 24*60*60) { - // 如果时间粒度大于等于一天,因为时区问题,特殊处理,否则时间为8:00,而非0:00 - start = start - ((start+8*60*60*1000) % oneMin); - end = end - ((end+8*60*60*1000) % oneMin); - } else { - start = start - (start % oneMin); - end = end - (end % oneMin); - } - mins = ((end - start) / oneMin); + mins = calMins(start, end, granularity); break; case IND: - // 测点值 - oneMin = 1000L * granularity; + case IND_ASCII: // 设置时间偏移量 - if (granularity >= 24*60*60) { - // 如果时间粒度大于等于一天,因为时区问题,特殊处理,否则时间为8:00,而非0:00 - start = start - ((start+8*60*60*1000) % oneMin); - end = end - ((end+8*60*60*1000) % oneMin); - } else { - start = start - (start % oneMin); - end = end - (end % oneMin); - } - mins = ((end - start) / oneMin) + 1; + mins = calMins(start, end, granularity) + 1; break; default: break; @@ -141,6 +111,20 @@ return completionDataEntityList; } + private long calMins(long start, long end, Integer granularity) { + long oneMin = granularity * 1000L; + // 设置时间偏移量 + if (granularity >= 24 * 60 * 60) { + // 如果时间粒度大于等于一天,因为时区问题,特殊处理,否则时间为8:00,而非0:00 + start = start - ((start + 8 * 60 * 60 * 1000) % oneMin); + end = end - ((end + 8 * 60 * 60 * 1000) % oneMin); + } else { + start = start - (start % oneMin); + end = end - (end % oneMin); + } + return ((end - start) / oneMin); + } + /** * getFirstValue * -- Gitblit v1.9.3