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; }