From edb34516b4686f77fbb85ecd84dbbdcc0d242855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=B7=E6=88=90=E4=BC=9F?= Date: Tue, 26 Nov 2024 14:54:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/data/service/impl/DataServiceImpl.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java b/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java index 05227174..10a28f58 100644 --- a/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java +++ b/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java @@ -23,6 +23,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import org.springframework.util.StopWatch; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -148,7 +149,8 @@ public abstract class DataServiceImpl implements DataService { } private Map>> queryHistoryCurveValues(Long irn, Date startTime, Date endTime, String interval, String fill, List attributes) { - + StopWatch stopWatch = new StopWatch(); + stopWatch.start("prepare resources"); String iotModelCode = sysIotModelFieldMapper.queryModelCodeByDeviceId(irn); Map highSpeedFieldMap = highIotFieldMap.get(iotModelCode); Map lowSpeedFieldMap = lowIotFieldMap.get(iotModelCode); @@ -167,11 +169,15 @@ public abstract class DataServiceImpl implements DataService { calField.add(field); } } + stopWatch.stop(); + stopWatch.start("HighSpeedValues"); Map>> result = new HashMap<>(); if (!CollectionUtils.isEmpty(highSpeedField)) { Map>> highHistoryCurve = tdEngineService.fetchHighHistoryCurve(irn, startTime, endTime, interval, highSpeedField); result.putAll(highHistoryCurve); } + stopWatch.stop(); + stopWatch.start("LowSpeedValues"); if (!CollectionUtils.isEmpty(lowSpeedField)) { Map>> lowHistoryCurve = tdEngineService.fetchLowHistoryCurve(irn, startTime, endTime, interval, lowSpeedField); if (result.get(irn.toString()) == null) { @@ -180,6 +186,8 @@ public abstract class DataServiceImpl implements DataService { result.get(irn.toString()).putAll(lowHistoryCurve.get(irn.toString())); } } + stopWatch.stop(); + stopWatch.start("CalculateValues"); if (!CollectionUtils.isEmpty(calField)){ ListUtil.page(calField,COMMIT_COUNT,list -> { for (String item : list){ @@ -192,6 +200,8 @@ public abstract class DataServiceImpl implements DataService { } }); } + stopWatch.stop(); + log.debug("查询历史数据耗时: {}", stopWatch.prettyPrint()); return result; }