From 34ba735bfa0d272e063054c7ba0ef6fde65880f4 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期三, 08 一月 2025 17:37:10 +0800
Subject: [PATCH] point历史值查询增加默认时间

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/point/DataPointApiImpl.java |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/point/DataPointApiImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/point/DataPointApiImpl.java
index a576a68..a8d9f0c 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/point/DataPointApiImpl.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/point/DataPointApiImpl.java
@@ -63,12 +63,16 @@
     @Override
     public Map<String, List<Map<String, Object>>> queryPointsHistoryValue(ApiPointsValueQueryDTO queryDto) {
         Map<String, List<Map<String, Object>>> data = new HashMap<>();
-        if (queryDto.getStart() == null) {
-            queryDto.setStart(new Date());
-        }
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.MILLISECOND, 0);
         if (queryDto.getEnd() == null) {
-            queryDto.setEnd(new Date());
+            queryDto.setEnd(calendar.getTime());
         }
+        if (queryDto.getStart() == null) {
+            calendar.add(Calendar.HOUR_OF_DAY, -1);
+            queryDto.setStart(calendar.getTime());
+        }
+
         Map<String, Object> params = new HashMap<>(1);
         params.put("pointNos", queryDto.getPointNos());
         List<DaPointDTO> pointList = daPointService.list(params);
@@ -93,6 +97,15 @@
         pojo.setType(daPointDTO.getDataType());
         Date startTime = queryDto.getStart();
         Date endTime = queryDto.getEnd();
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.MILLISECOND, 0);
+        if (endTime == null) {
+            endTime = calendar.getTime();
+        }
+        if (startTime == null) {
+            calendar.add(Calendar.HOUR_OF_DAY, -1);
+            startTime = calendar.getTime();
+        }
         List<Map<String, Object>> list = influxDBService.queryPointValues(pojo, startTime, endTime);
         List<ApiPointValueDTO> pointValueList = new ArrayList<>();
         for (int i = 0; list.size() - i >= 1; i++) {

--
Gitblit v1.9.3