diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/TransitVehicleRecordController.java b/gather-app/src/main/java/com/ruoyi/database/controller/TransitVehicleRecordController.java index 0d8b0e2..2deaea2 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/TransitVehicleRecordController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/TransitVehicleRecordController.java @@ -79,23 +79,38 @@ public class TransitVehicleRecordController extends BaseController { return getDataTable(list); } + @GetMapping("/track") @ApiOperation("查询车辆轨迹") - public TableDataInfo trackList(TransitVehicleRecord transitVehicleRecord) { - List list = transitVehicleRecordService.list(new QueryWrapper<>(transitVehicleRecord)); - List collect = list.stream() - .sorted(Comparator.comparing(TransitVehicleRecord::getPassTime)) - .collect(Collectors.toList()); - TransitVehicleRecordVO transitVehicleRecordVO = new TransitVehicleRecordVO(); + public AjaxResult trackList(String plateNo) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime now = LocalDateTime.now() + .withHour(0) + .withMinute(0) + .withSecond(0) + .withNano(0); + LocalDateTime localDateTime = now.plusDays(1); + String format = now.format(formatter); + String format1 = localDateTime.format(formatter); + List list = transitVehicleRecordService + .lambdaQuery().eq(TransitVehicleRecord::getPlateNo,plateNo) + .between(TransitVehicleRecord::getPartitionField,format,format1).list(); ArrayList transitVehicleRecordVOS = new ArrayList<>(); - for (TransitVehicleRecord transitVehicleRecord1 : collect){ + for (TransitVehicleRecord transitVehicleRecord1 : list){ + TransitVehicleRecordVO transitVehicleRecordVO = new TransitVehicleRecordVO(); BeanUtils.copyProperties(transitVehicleRecord1,transitVehicleRecordVO); - DevopsDeviceInfo deviceInfo = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getGbsChannelNo, transitVehicleRecord1.getDoorwayCode()).list().get(0); - transitVehicleRecordVO.setLongitude(deviceInfo.getLongitude()); - transitVehicleRecordVO.setLatitude(deviceInfo.getLatitude()); - transitVehicleRecordVOS.add(transitVehicleRecordVO); + DevopsDeviceInfo deviceInfo = devopsDeviceInfoService.lambdaQuery() + .eq(DevopsDeviceInfo::getGbsChannelNo, transitVehicleRecord1.getDoorwayCode()).list().get(0); + if (deviceInfo != null){ + transitVehicleRecordVO.setLongitude(deviceInfo.getLongitude()); + transitVehicleRecordVO.setLatitude(deviceInfo.getLatitude()); + transitVehicleRecordVOS.add(transitVehicleRecordVO); + } } - return getDataTable(transitVehicleRecordVOS); + List collect = transitVehicleRecordVOS.stream() + .sorted(Comparator.comparing(TransitVehicleRecordVO::getPassTime)) + .collect(Collectors.toList()); + return AjaxResult.success(collect); } @PostMapping