From 4561698ebcbbf4fa72a2d1410fdf830e868d4f37 Mon Sep 17 00:00:00 2001 From: hanrenchun Date: Fri, 26 Jan 2024 17:26:04 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E7=82=B9=E4=BA=BA=E8=BD=A6=E6=8A=93?= =?UTF-8?q?=E6=8B=8D,=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PerceptionDeviceController.java | 17 +++++++++-- .../TransitImpUserRecordController.java | 19 ++++++++++-- .../TransitImpVehicleRecordController.java | 29 ++++++++++++++----- .../TransitUserRecordController.java | 22 +++++++------- .../TransitVehicleRecordController.java | 15 +++++----- 5 files changed, 72 insertions(+), 30 deletions(-) diff --git a/gather-app/src/main/java/com/ruoyi/business/controller/PerceptionDeviceController.java b/gather-app/src/main/java/com/ruoyi/business/controller/PerceptionDeviceController.java index 294c4fa..c8e4e9a 100644 --- a/gather-app/src/main/java/com/ruoyi/business/controller/PerceptionDeviceController.java +++ b/gather-app/src/main/java/com/ruoyi/business/controller/PerceptionDeviceController.java @@ -19,6 +19,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.stream.Collectors; /** * 大屏感知设备查询接口 @@ -43,8 +44,14 @@ public class PerceptionDeviceController extends BaseController { @ApiOperation("人车统计") public AjaxResult overviewResources() { try { - Integer userCount = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getDeviceType, 1).count(); - Integer vehicleCount = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getDeviceType, 2).count(); + Integer userCount = devopsDeviceInfoService.lambdaQuery() + .eq(DevopsDeviceInfo::getDeviceType, 1) + .eq(DevopsDeviceInfo::getParentMonitoringType,1) + .count(); + Integer vehicleCount = devopsDeviceInfoService.lambdaQuery() + .eq(DevopsDeviceInfo::getDeviceType, 2) + .eq(DevopsDeviceInfo::getParentMonitoringType,1) + .count(); Map map = new HashMap<>(); map.put("userCount", userCount); map.put("vehicleCount", vehicleCount); @@ -177,6 +184,8 @@ public class PerceptionDeviceController extends BaseController { @ApiOperation("车流量统计(前7天)(重点人员)") public AjaxResult vehicleTrafficStatistics() { try { + List deviceInfos = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getParentMonitoringType, 1).list(); + List collect = deviceInfos.stream().map(devopsDeviceInfo -> devopsDeviceInfo.getGbsChannelNo()).collect(Collectors.toList()); // 获取当前日期 LocalDate currentDate = LocalDate.now(); // 创建一个 TreeMap 用于存储每天的数据量 @@ -186,6 +195,7 @@ public class PerceptionDeviceController extends BaseController { LocalDate date = currentDate.minusDays(i); // 构造查询条件 QueryWrapper vehicleQueryWrapper = new QueryWrapper<>(); + vehicleQueryWrapper.in("device_code",collect); vehicleQueryWrapper.between("partition_field", date, date.plusDays(1)); // 查询当前日期的记录数据总数 long vehicleCount = vehicleRecordService.count(vehicleQueryWrapper); @@ -204,6 +214,8 @@ public class PerceptionDeviceController extends BaseController { @ApiOperation("人流量统计(前7天)(重点人员)") public AjaxResult humanTrafficStatistics() { try { + List deviceInfos = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getParentMonitoringType, 1).list(); + List collect = deviceInfos.stream().map(devopsDeviceInfo -> devopsDeviceInfo.getGbsChannelNo()).collect(Collectors.toList()); // 获取当前日期 LocalDate currentDate = LocalDate.now(); // 创建一个 TreeMap 用于存储每天的数据量 @@ -213,6 +225,7 @@ public class PerceptionDeviceController extends BaseController { LocalDate date = currentDate.minusDays(i); // 构造查询条件 QueryWrapper userQueryWrapper = new QueryWrapper<>(); + userQueryWrapper.in("device_code",collect); userQueryWrapper.between("partition_field", date, date.plusDays(1)); // 查询当前日期的记录数据总数 long userCount = userRecordService.count(userQueryWrapper); diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/TransitImpUserRecordController.java b/gather-app/src/main/java/com/ruoyi/database/controller/TransitImpUserRecordController.java index 1eb6b9c..eb8e46f 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/TransitImpUserRecordController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/TransitImpUserRecordController.java @@ -9,7 +9,9 @@ import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.PageUtils; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.database.domain.DevopsDeviceInfo; import com.ruoyi.database.domain.TransitImpUserRecord; +import com.ruoyi.database.service.DevopsDeviceInfoService; import com.ruoyi.database.service.TransitImpUserRecordService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -20,10 +22,13 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; /** * 涉稳列管人员人脸抓拍记录表(TransitImpUserRecord)Controller @@ -38,21 +43,29 @@ import java.util.List; public class TransitImpUserRecordController extends BaseController { private final TransitImpUserRecordService transitImpUserRecordService; + private final DevopsDeviceInfoService devopsDeviceInfoService; @GetMapping @ApiOperation("查询涉稳列管人员人脸抓拍记录表") public TableDataInfo list(TransitImpUserRecord transitImpUserRecord) throws Exception{ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + List deviceInfos = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getParentMonitoringType, 1).list(); + List collect = deviceInfos.stream().map(devopsDeviceInfo -> devopsDeviceInfo.getGbsChannelNo()).collect(Collectors.toList()); QueryWrapper queryWrapper = new QueryWrapper<>(transitImpUserRecord); - if (transitImpUserRecord.getFirstTime() != null && transitImpUserRecord.getEndTime() != null) { - queryWrapper.between("partition_field", transitImpUserRecord.getFirstTime(), transitImpUserRecord.getEndTime()); - } + queryWrapper.in("device_code",collect); if (transitImpUserRecord.getFirstTime() != null){ Calendar calendar = Calendar.getInstance(); calendar.setTime(simpleDateFormat.parse(transitImpUserRecord.getFirstTime())); calendar.add(Calendar.DAY_OF_MONTH, 1); queryWrapper.between("partition_field", transitImpUserRecord.getFirstTime(),simpleDateFormat.format(calendar.getTime())); + queryWrapper.orderByDesc("partition_field"); + }else { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime now = LocalDateTime.now(); + LocalDateTime minusDay = now.minusDays(1); + queryWrapper.between("partition_field",formatter.format(minusDay),formatter.format(now)); + queryWrapper.orderByDesc("partition_field"); } int count = transitImpUserRecordService.count(queryWrapper); PageUtils.startPage(); diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/TransitImpVehicleRecordController.java b/gather-app/src/main/java/com/ruoyi/database/controller/TransitImpVehicleRecordController.java index d3a98f4..aaf2606 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/TransitImpVehicleRecordController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/TransitImpVehicleRecordController.java @@ -9,8 +9,10 @@ import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.PageUtils; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.database.domain.DevopsDeviceInfo; import com.ruoyi.database.domain.TransitImpUserRecord; import com.ruoyi.database.domain.TransitImpVehicleRecord; +import com.ruoyi.database.service.DevopsDeviceInfoService; import com.ruoyi.database.service.TransitImpVehicleRecordService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -20,10 +22,13 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; /** * 重点人车辆记录表(TransitImpVehicleRecord)Controller @@ -38,31 +43,41 @@ import java.util.List; public class TransitImpVehicleRecordController extends BaseController { private final TransitImpVehicleRecordService transitImpVehicleRecordService; + private final DevopsDeviceInfoService devopsDeviceInfoService; @GetMapping @ApiOperation("查询重点人车辆记录表") public TableDataInfo list(TransitImpVehicleRecord transitImpVehicleRecord) throws Exception{ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + List deviceInfos = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getParentMonitoringType, 1).list(); + List collect = deviceInfos.stream().map(devopsDeviceInfo -> devopsDeviceInfo.getGbsChannelNo()).collect(Collectors.toList()); QueryWrapper queryWrapper = new QueryWrapper<>(transitImpVehicleRecord); - if (transitImpVehicleRecord.getFirstTime() != null && transitImpVehicleRecord.getEndTime() != null) { - queryWrapper.between("partition_field", transitImpVehicleRecord.getFirstTime(), transitImpVehicleRecord.getEndTime()); - } + queryWrapper.in("device_code",collect); if (transitImpVehicleRecord.getFirstTime() != null){ Calendar calendar = Calendar.getInstance(); calendar.setTime(simpleDateFormat.parse(transitImpVehicleRecord.getFirstTime())); calendar.add(Calendar.DAY_OF_MONTH, 1); queryWrapper.between("partition_field", transitImpVehicleRecord.getFirstTime(),simpleDateFormat.format(calendar.getTime())); + queryWrapper.orderByDesc("partition_field"); + }else { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime now = LocalDateTime.now(); + LocalDateTime minusDay = now.minusDays(1); + queryWrapper.between("partition_field",formatter.format(minusDay),formatter.format(now)); + queryWrapper.orderByDesc("partition_field"); } int count = transitImpVehicleRecordService.count(queryWrapper); PageUtils.startPage(); List list = transitImpVehicleRecordService.list(queryWrapper); List impVehicleRecords = new ArrayList<>(); for (TransitImpVehicleRecord transitImpVehicleRecord1 : list){ - Date partitionField = transitImpVehicleRecord1.getPartitionField(); - String format = dateFormat.format(partitionField); - transitImpVehicleRecord1.setElapsedTime(format); - impVehicleRecords.add(transitImpVehicleRecord1); + if (!"unknown".equals(transitImpVehicleRecord1.getPlateNo())) { + Date partitionField = transitImpVehicleRecord1.getPartitionField(); + String format = dateFormat.format(partitionField); + transitImpVehicleRecord1.setElapsedTime(format); + impVehicleRecords.add(transitImpVehicleRecord1); + } } TableDataInfo dataTable = getDataTable(impVehicleRecords); dataTable.setTotal(count); diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/TransitUserRecordController.java b/gather-app/src/main/java/com/ruoyi/database/controller/TransitUserRecordController.java index f67f1d0..a4d15da 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/TransitUserRecordController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/TransitUserRecordController.java @@ -1,6 +1,7 @@ package com.ruoyi.database.controller; +import cn.hutool.core.date.DateTime; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; @@ -15,11 +16,16 @@ import com.ruoyi.database.service.TransitImpUserRecordService; import com.ruoyi.database.service.TransitUserRecordService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.Data; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.List; @@ -42,21 +48,17 @@ public class TransitUserRecordController extends BaseController { @ApiOperation("查询人脸记录表") public TableDataInfo list(TransitUserRecord transitUserRecord) { startPage(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime now = LocalDateTime.now(); + LocalDateTime minusDay = now.minusDays(1); QueryWrapper queryWrapper = new QueryWrapper<>(transitUserRecord); -// List impUserRecords = transitImpUserRecordService.lambdaQuery().eq(TransitImpUserRecord::getDeviceCode, transitUserRecord.getDeviceCode()).list(); - if (transitUserRecord.getFirstTime() != null && transitUserRecord.getEndTime() != null) { - queryWrapper.between("partition_field", transitUserRecord.getFirstTime(), transitUserRecord.getEndTime()); - } -// if (impUserRecords != null && !impUserRecords.isEmpty()){ -// for (TransitImpUserRecord transitImpUserRecord : impUserRecords){ -// Date partitionField = transitImpUserRecord.getPartitionField(); -// } -// return getDataTable(impUserRecords); -// } + queryWrapper.between("partition_field",formatter.format(minusDay),formatter.format(now)); + queryWrapper.orderByDesc("partition_field"); List list = transitUserRecordService.list(queryWrapper); return getDataTable(list); } + @PostMapping @ApiOperation("新增人脸记录表") @Log(title = "人脸记录表", businessType = BusinessType.INSERT) 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 71bd050..0da7de3 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 @@ -26,6 +26,8 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -49,15 +51,12 @@ public class TransitVehicleRecordController extends BaseController { @ApiOperation("查询车辆记录表") public TableDataInfo list(TransitVehicleRecord transitVehicleRecord) { startPage(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime now = LocalDateTime.now(); + LocalDateTime minusDay = now.minusDays(1); QueryWrapper queryWrapper = new QueryWrapper<>(transitVehicleRecord); - List vehicleRecords = transitImpVehicleRecordService.lambdaQuery().eq(TransitImpVehicleRecord::getDeviceCode, transitVehicleRecord.getDoorwayCode()).list(); - if (transitVehicleRecord.getFirstTime() != null && transitVehicleRecord.getEndTime() != null) { - queryWrapper.between("partition_field", transitVehicleRecord.getFirstTime(), transitVehicleRecord.getEndTime()); - } - if (vehicleRecords != null && !vehicleRecords.isEmpty()){ - return getDataTable(vehicleRecords); - } - PageUtils.startPage(); + queryWrapper.between("partition_field",formatter.format(minusDay),formatter.format(now)); + queryWrapper.orderByDesc("partition_field"); List list = transitVehicleRecordService.list(queryWrapper); return getDataTable(list); }