Commit 7adc5df4 by 向延琳

增加日志打印

1 parent 34d47fe1
......@@ -47,10 +47,13 @@ public class JourneyService {
*/
@Transactional(rollbackFor = Exception.class)
public void saveDeviceJourney(DeviceJourneyDTO deviceJourneyDTO) {
long t1 = System.currentTimeMillis();
if (Objects.isNull(deviceJourneyDTO)) {
return;
}
DeviceJourney journey = deviceJourneyMapper.selectBySnAndBeginTime(deviceJourneyDTO.getSn(), deviceJourneyDTO.getBeginTime());
long t2 = System.currentTimeMillis();
log.info("重复校验时间{}", t2 - t1);
if(Objects.nonNull(journey)) {
log.warn("该设备同样的开始时间行程数据已经存在" +
"sn: " + deviceJourneyDTO.getSn() + "beginTime:" + DateUtils.formatNormal(deviceJourneyDTO.getBeginTime()));
......@@ -61,8 +64,14 @@ public class JourneyService {
Vehicle vehicle = getVehicleBySn(deviceJourneyDTO.getSn());
Long createdBy = Optional.ofNullable(vehicle).map(Vehicle::getCreatedBy).orElse(null);
Long updatedBy = Optional.ofNullable(vehicle).map(Vehicle::getUpdatedBy).orElse(null);
long t3 = System.currentTimeMillis();
log.info("获取创建人时间{}", t3 - t2);
//从关联表从获取关联id
Long vdId = vehicleService.getVdId(deviceJourneyDTO.getSn());
long t4 = System.currentTimeMillis();
log.info("获取创建人时间{}", t4 - t3);
//行程信息入库
DeviceJourney deviceJourney = convertTo(deviceJourneyDTO, vdId, createdBy, updatedBy);
deviceJourneyMapper.insert(deviceJourney);
......@@ -76,15 +85,20 @@ public class JourneyService {
//更新总行程次数 总里程
DeviceJourneyOverview overviewDO = buildOverviewWitheJourney(deviceJourneyDTO, vdId, createdBy, updatedBy);
DeviceJourneyOverview overview = deviceJourneyOverviewMapper.selectBySnAndVdId(deviceJourneyDTO.getSn(), vdId);
long t5 = System.currentTimeMillis();
log.info("行程入库时间{}", t5 - t4);
if (Objects.isNull(overview)) {
//本设备的第一条里程数据
deviceJourneyOverviewMapper.insert(overviewDO);
log.info("同步里程总耗时{}", t5 - t1);
return;
}
overview.setDistance(overview.getDistance() + overviewDO.getDistance());
overview.setDistance(overview.getTotalJourneyCount() + 1);
overview.setUpdatedDate(new Date());
deviceJourneyOverviewMapper.updateByPrimaryKeySelective(overview);
long t6 = System.currentTimeMillis();
log.info("行程入库时间{}", t6 - t1);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!