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 | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 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 d57f185..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 @@ -42,7 +42,7 @@ } @Override - public List<ApiPointDTO> getInfoByIds(List<String> pointIds) { + public List<ApiPointDTO> getInfoByIds(Set<String> pointIds) { List<ApiPointDTO> result = new ArrayList<>(pointIds.size()); for (String pointId : pointIds) { result.add(daPointService.getSimpleInfoById(pointId)); @@ -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++) { @@ -113,6 +126,7 @@ pointCollector.setValue(wr); return true; } catch (Exception ex) { + ex.printStackTrace(); return false; } } -- Gitblit v1.9.3