Commit 7adc5df4 by 向延琳

增加日志打印

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