Commit b86acc71 by 向延琳

增加日志打印

1 parent 0137b204
......@@ -36,6 +36,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
......@@ -162,20 +163,37 @@ public class DashboardService extends AbstractCommonService {
public StatisticalInfoVO getStatisticalInfo() {
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());
stopWatch.start();
//车辆总数
List<Integer> listVehicle = vehicleMapper.countDeviceWithAuth(activeSearch);
int totalVehicle = listVehicle.stream().reduce(0, Integer::sum);
stopWatch.stop();
log.info("{} 耗时:{} ms", "车辆总数查询", stopWatch.getLastTaskTimeMillis());
stopWatch.start();
//今日激活
RangeTimeDTO today = new RangeTimeDTO(DateUtil.getTodayFirstDateTimeStr(), DateUtil.getTodayLastDateTimeStr());
List<Integer> listTodayActiveDevice = vehicleDeviceMapper.countDeviceWithAuth(today, activeSearch);
int todayActiveDevice = listTodayActiveDevice.stream().reduce(0, Integer::sum);
stopWatch.stop();
log.info("{} 耗时:{} ms", "今日激活查询", stopWatch.getLastTaskTimeMillis());
stopWatch.start();
//在线率
String onLineRate = getOnLineRate(totalActiveDevice);
stopWatch.stop();
log.info("{} 耗时:{} ms", "在线率查询", stopWatch.getLastTaskTimeMillis());
stopWatch.start();
//断电报警
List<String> sns = vehicleMapper.getAllDeviceSnByAuth();
AlarmTrackRecQueryDTO query = new AlarmTrackRecQueryDTO();
......@@ -184,14 +202,22 @@ public class DashboardService extends AbstractCommonService {
query.setStartTime(DateUtil.getTodayLastDateTimeStr());
query.setAlarmType(Constants.ALARM_TYPE_POWER_OFF);
Integer powerOffCount = remoteAlarmService.getAlarmCount(query);
stopWatch.stop();
log.info("{} 耗时:{} ms", "今日断电报警", stopWatch.getLastTaskTimeMillis());
stopWatch.start();
//光感报警
query.setAlarmType(Constants.ALARM_TYPE_LIGHT);
Integer lightCount = remoteAlarmService.getAlarmCount(query);
stopWatch.stop();
log.info("{} 耗时:{} ms", "今日光感报警查询", stopWatch.getLastTaskTimeMillis());
stopWatch.start();
//围栏报警
List<Integer> fenceList = alarmElectricFenceMapper.countActiveDeviceFenceAlarm(today);
int fenceCount = fenceList.stream().reduce(0, Integer::sum);
stopWatch.stop();
log.info("{} 耗时:{} ms", "今日围栏报警查询", stopWatch.getLastTaskTimeMillis());
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!