Commit a64c31ff by 向延琳

优化查询

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