From ffe7447747c8873e8400a3026fbe8085370d3575 Mon Sep 17 00:00:00 2001 From: hanrenchun Date: Sat, 24 Feb 2024 11:25:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E8=BE=86=E8=BD=A8=E8=BF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TransitVehicleRecordController.java | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) 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