From 063a25c9cf4e38496cf5395569856b67c80cdc53 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期一, 28 四月 2025 19:11:08 +0800 Subject: [PATCH] 查询最大值 --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/utils/GenInfluxPointValueUtils.java | 30 +++++++++++++++++++++++++++++- 1 files changed, 29 insertions(+), 1 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/utils/GenInfluxPointValueUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/utils/GenInfluxPointValueUtils.java index 36d6dd1..e3388f8 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/utils/GenInfluxPointValueUtils.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/utils/GenInfluxPointValueUtils.java @@ -1,8 +1,14 @@ package com.iailab.module.data.point.collection.utils; import com.iailab.module.data.common.enums.DataTypeEnum; +import com.iailab.module.data.enums.DataPointFreqEnum; import com.iailab.module.data.point.dto.DaPointDTO; import com.iailab.module.data.influxdb.pojo.*; + +import java.math.BigDecimal; +import java.time.Instant; +import java.util.Calendar; +import java.util.Date; /** * @author PanZhibao @@ -51,7 +57,7 @@ ((InfluxPointValueDigPOJO) pojo).setValue(dto.getDefaultValue().intValue()); } if (value != null) { - ((InfluxPointValueDigPOJO) pojo).setValue(Integer.parseInt(value.toString())); + ((InfluxPointValueDigPOJO) pojo).setValue(new BigDecimal(value.toString()).intValue()); } return pojo; } else if (DataTypeEnum.BOOLEAN.getCode().equals(dto.getDataType().trim())) { @@ -69,4 +75,26 @@ return new InfluxPointValueStrPOJO(); } } + + public static Instant getByMin(Date collectTime, DataPointFreqEnum freqEnum) { + Calendar cal = Calendar.getInstance(); + cal.setTime(collectTime); + switch (freqEnum) { + case NET_1MIN: + cal.set(Calendar.SECOND, 0); + break; + case NET_1H: + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MINUTE, 0); + break; + case NET_Day: + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.HOUR_OF_DAY, 0); + break; + default: + break; + } + return cal.getTime().toInstant(); + } } -- Gitblit v1.9.3