Commit a64c31ff by 向延琳

优化查询

1 parent 13b8732d
...@@ -187,17 +187,17 @@ public class DashboardService extends AbstractCommonService { ...@@ -187,17 +187,17 @@ public class DashboardService extends AbstractCommonService {
} }
public StatisticalInfoVO getStatisticalInfo() { public StatisticalInfoVO getStatisticalInfo() {
long t1 = System.currentTimeMillis();
StatSearch activeSearch = new StatSearch().setStatPattern("%Y-%m-%d"); StatSearch activeSearch = new StatSearch().setStatPattern("%Y-%m-%d");
injectSettled(activeSearch); injectSettled(activeSearch);
StopWatch stopWatch = new StopWatch(); StopWatch stopWatch = new StopWatch();
//激活设备总数 //激活设备总数 TODO 警情迁移后需要单独查询激活数量
stopWatch.start(); // stopWatch.start();
List<Integer> listActiveDevice = vehicleDeviceMapper.countDeviceWithAuth(new RangeTimeDTO(), activeSearch); // List<Integer> listActiveDevice = vehicleDeviceMapper.countDeviceWithAuth(new RangeTimeDTO(), activeSearch);
int totalActiveDevice = listActiveDevice.stream().reduce(0, Integer::sum); // int totalActiveDevice = listActiveDevice.stream().reduce(0, Integer::sum);
stopWatch.stop(); // stopWatch.stop();
log.info("{} 耗时:{} ms", "看板统计信息 - 激活设备总数查询", stopWatch.getLastTaskTimeMillis()); // log.info("{} 耗时:{} ms", "看板统计信息 - 激活设备总数查询", stopWatch.getLastTaskTimeMillis());
//车辆总数 //车辆总数
stopWatch.start(); stopWatch.start();
...@@ -214,9 +214,10 @@ public class DashboardService extends AbstractCommonService { ...@@ -214,9 +214,10 @@ public class DashboardService extends AbstractCommonService {
stopWatch.stop(); stopWatch.stop();
log.info("{} 耗时:{} ms", "看板统计信息 - 今日激活查询", stopWatch.getLastTaskTimeMillis()); log.info("{} 耗时:{} ms", "看板统计信息 - 今日激活查询", stopWatch.getLastTaskTimeMillis());
//断电报警 //查询新E盾sn
stopWatch.start(); stopWatch.start();
List<String> sns = vehicleMapper.getAllDeviceSnByAuth(); List<String> sns = vehicleMapper.getAllDeviceSnByAuth();
int totalActiveDevice = sns.size();
stopWatch.stop(); stopWatch.stop();
log.info("{} 耗时:{} ms", "看板统计信息 - sn查询", stopWatch.getLastTaskTimeMillis()); log.info("{} 耗时:{} ms", "看板统计信息 - sn查询", stopWatch.getLastTaskTimeMillis());
...@@ -242,7 +243,6 @@ public class DashboardService extends AbstractCommonService { ...@@ -242,7 +243,6 @@ public class DashboardService extends AbstractCommonService {
//在线率 //在线率
String onlineRate =getOnLineRate(totalActiveDevice); String onlineRate =getOnLineRate(totalActiveDevice);
int powerOffCount; int powerOffCount;
int lightCount; int lightCount;
try { try {
...@@ -251,6 +251,8 @@ public class DashboardService extends AbstractCommonService { ...@@ -251,6 +251,8 @@ public class DashboardService extends AbstractCommonService {
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
long t2 = System.currentTimeMillis();
log.info("{} 总耗时:{} ms", "看板统计信息", t2 - t1);
return new StatisticalInfoVO(totalActiveDevice, totalVehicle, todayActiveDevice, powerOffCount, fenceCount, lightCount, onlineRate); return new StatisticalInfoVO(totalActiveDevice, totalVehicle, todayActiveDevice, powerOffCount, fenceCount, lightCount, onlineRate);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!