From ca7acf119175c13955281a6752c90acb7caa4587 Mon Sep 17 00:00:00 2001 From: hanrenchun Date: Wed, 3 Jan 2024 09:09:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E8=BE=86=E6=A1=A3=E6=A1=88=E4=B8=8E?= =?UTF-8?q?=E4=BA=BA,=E8=BD=A6=E6=B5=81=E9=87=8F=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PerceptionDeviceController.java | 132 +++++++++++++++++- .../TransitVehicleRecordController.java | 10 ++ .../ruoyi/database/domain/BoneVehicle.java | 34 +++++ .../database/domain/DevopsDeviceInfo.java | 8 ++ .../database/mapper/BoneVehicleMapper.java | 22 +++ .../database/service/BoneVehicleService.java | 14 ++ .../service/impl/BoneVehicleServiceImpl.java | 23 +++ 7 files changed, 237 insertions(+), 6 deletions(-) create mode 100644 gather-app/src/main/java/com/ruoyi/database/domain/BoneVehicle.java create mode 100644 gather-app/src/main/java/com/ruoyi/database/mapper/BoneVehicleMapper.java create mode 100644 gather-app/src/main/java/com/ruoyi/database/service/BoneVehicleService.java create mode 100644 gather-app/src/main/java/com/ruoyi/database/service/impl/BoneVehicleServiceImpl.java 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 3723eff..7f2d338 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 @@ -9,16 +9,23 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.StringKit; import com.ruoyi.database.domain.TransitImpUserRecord; import com.ruoyi.database.domain.TransitImpVehicleRecord; +import com.ruoyi.database.domain.TransitUserRecord; +import com.ruoyi.database.domain.TransitVehicleRecord; import com.ruoyi.database.service.TransitImpUserRecordService; import com.ruoyi.database.service.TransitImpVehicleRecordService; +import com.ruoyi.database.service.TransitUserRecordService; +import com.ruoyi.database.service.TransitVehicleRecordService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Map; import java.util.TreeMap; @@ -36,6 +43,8 @@ public class PerceptionDeviceController extends BaseController { private final TransitImpUserRecordService userRecordService; private final TransitImpVehicleRecordService vehicleRecordService; + private final TransitVehicleRecordService transitVehicleRecordService; + private final TransitUserRecordService transitUserRecordService; @PostMapping("/humanVehicleStatistics") @@ -63,9 +72,9 @@ public class PerceptionDeviceController extends BaseController { } } - @PostMapping("/humanTrafficStatistics") - @ApiOperation("人流量统计(前7天)") - public AjaxResult humanTrafficStatistics() { + @PostMapping("/allHumanTrafficStatistics") + @ApiOperation("人流量统计(前7天)(全数)") + public AjaxResult allHumanTrafficStatistics(@RequestBody TransitUserRecord transitUserRecord) { try { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -75,10 +84,10 @@ public class PerceptionDeviceController extends BaseController { for (int i = 0; i < 7; i++) { LocalDate date = currentDate.minusDays(i); // 构造查询条件 - QueryWrapper userQueryWrapper = new QueryWrapper<>(); + QueryWrapper userQueryWrapper = new QueryWrapper<>(transitUserRecord); userQueryWrapper.between("partition_field", date, date.plusDays(1)); // 查询当前日期的记录数据总数 - long userCount = userRecordService.count(userQueryWrapper); + long userCount = transitUserRecordService.count(userQueryWrapper); // 存储结果到 TreeMap 中 dailyCountsMap.put(date, userCount); } @@ -91,7 +100,7 @@ public class PerceptionDeviceController extends BaseController { } @PostMapping("/vehicleTrafficStatistics") - @ApiOperation("车流量统计(前7天)") + @ApiOperation("车流量统计(前7天)(重点人员)") public AjaxResult vehicleTrafficStatistics() { try { // 获取当前日期 @@ -117,5 +126,116 @@ public class PerceptionDeviceController extends BaseController { } } + @PostMapping("/humanTrafficStatistics") + @ApiOperation("人流量统计(前7天)(重点人员)") + public AjaxResult humanTrafficStatistics() { + try { + // 获取当前日期 + LocalDate currentDate = LocalDate.now(); + // 创建一个 TreeMap 用于存储每天的数据量 + Map dailyCountsMap = new TreeMap<>(); + // 循环迭代前7天 + for (int i = 0; i < 7; i++) { + LocalDate date = currentDate.minusDays(i); + // 构造查询条件 + QueryWrapper userQueryWrapper = new QueryWrapper<>(); + userQueryWrapper.between("partition_field", date, date.plusDays(1)); + // 查询当前日期的记录数据总数 + long userCount = userRecordService.count(userQueryWrapper); + // 存储结果到 TreeMap 中 + dailyCountsMap.put(date, userCount); + } + + return AjaxResult.success(dailyCountsMap); + } catch (Exception e) { + logger.info(StringKit.toString(e)); + return AjaxResult.error("请求失败,请联系管理员"); + } + } + + @PostMapping("/allVehicleTrafficStatistics") + @ApiOperation("车流量统计(前7天)(全数)") + public AjaxResult allVehicleTrafficStatistics(@RequestBody TransitVehicleRecord transitVehicleRecord) { + try { + // 获取当前日期 + LocalDate currentDate = LocalDate.now(); + // 创建一个 TreeMap 用于存储每天的数据量 + Map dailyCountsMap = new TreeMap<>(); + // 循环迭代前7天 + for (int i = 0; i < 7; i++) { + LocalDate date = currentDate.minusDays(i); + // 构造查询条件 + QueryWrapper vehicleQueryWrapper = new QueryWrapper<>(transitVehicleRecord); + vehicleQueryWrapper.between("partition_field", date, date.plusDays(1)); + // 查询当前日期的记录数据总数 + long vehicleCount = transitVehicleRecordService.count(vehicleQueryWrapper); + // 存储结果到 TreeMap 中 + dailyCountsMap.put(date, vehicleCount); + } + + return AjaxResult.success(dailyCountsMap); + } catch (Exception e) { + logger.info(StringKit.toString(e)); + return AjaxResult.error("请求失败,请联系管理员"); + } + } + + @PostMapping("/allHumanTrafficStatisticsHour") + @ApiOperation("人流量统计(当天)(全数)") + public AjaxResult allHumanTrafficStatisticsHour(@RequestBody TransitUserRecord transitUserRecord) { + try { + // 获取当前日期 + LocalDateTime currentDateTime = LocalDateTime.now(); + LocalDateTime startOfDay = currentDateTime.withHour(0).withMinute(0).withSecond(0).withNano(0); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); + String formattedDateTime = startOfDay.format(formatter); + // 创建一个 TreeMap 用于存储每天的数据量 + Map dailyCountsMap = new TreeMap<>(); + // 循环迭代前7天 + for (int i = 0; i < 24; i++) { + // 构造查询条件 + QueryWrapper userQueryWrapper = new QueryWrapper<>(transitUserRecord); + userQueryWrapper.between("partition_field", formattedDateTime, startOfDay.plusHours(1).format(formatter)); + // 查询当前日期的记录数据总数 + long userCount = transitUserRecordService.count(userQueryWrapper); + // 存储结果到 TreeMap 中 + dailyCountsMap.put(startOfDay.plusHours(1).format(formatter), userCount); + } + + return AjaxResult.success(dailyCountsMap); + } catch (Exception e) { + logger.info(StringKit.toString(e)); + return AjaxResult.error("请求失败,请联系管理员"); + } + } + + @PostMapping("/allVehicleTrafficStatisticsHour") + @ApiOperation("车流量统计(当天)(全数)") + public AjaxResult allVehicleTrafficStatisticsHour(@RequestBody TransitVehicleRecord transitVehicleRecord) { + try { + // 获取当前日期 + LocalDateTime currentDateTime = LocalDateTime.now(); + LocalDateTime startOfDay = currentDateTime.withHour(0).withMinute(0).withSecond(0).withNano(0); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); + String formattedDateTime = startOfDay.format(formatter); + // 创建一个 TreeMap 用于存储每天的数据量 + Map dailyCountsMap = new TreeMap<>(); + // 循环迭代前7天 + for (int i = 0; i < 24; i++) { + // 构造查询条件 + QueryWrapper vehicleQueryWrapper = new QueryWrapper<>(transitVehicleRecord); + vehicleQueryWrapper.between("partition_field", formattedDateTime, startOfDay.plusHours(1).format(formatter)); + // 查询当前日期的记录数据总数 + long vehicleCount = transitVehicleRecordService.count(vehicleQueryWrapper); + // 存储结果到 TreeMap 中 + dailyCountsMap.put(startOfDay.plusHours(1).format(formatter), vehicleCount); + } + + return AjaxResult.success(dailyCountsMap); + } catch (Exception e) { + logger.info(StringKit.toString(e)); + return AjaxResult.error("请求失败,请联系管理员"); + } + } } 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 d769c10..51c93a3 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 @@ -1,14 +1,20 @@ package com.ruoyi.database.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.database.domain.BoneVehicle; +import com.ruoyi.database.domain.TransitUserRecord; import com.ruoyi.database.domain.TransitVehicleRecord; +import com.ruoyi.database.service.BoneVehicleService; import com.ruoyi.database.service.TransitVehicleRecordService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -17,6 +23,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; import java.util.List; /** @@ -96,4 +103,7 @@ public class TransitVehicleRecordController extends BaseController { } return AjaxResult.success(result); } + + + } diff --git a/gather-app/src/main/java/com/ruoyi/database/domain/BoneVehicle.java b/gather-app/src/main/java/com/ruoyi/database/domain/BoneVehicle.java new file mode 100644 index 0000000..a05363e --- /dev/null +++ b/gather-app/src/main/java/com/ruoyi/database/domain/BoneVehicle.java @@ -0,0 +1,34 @@ +package com.ruoyi.database.domain; + + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +/** + * @TableName bone_vehicle + */ +@TableName(value ="bone_vehicle") +@Data +public class BoneVehicle implements Serializable { + private Long id; + + + @TableField(value = "no") + private String no; + + @TableField(value = "owner_person_name") + private String ownerPersonName; + + @TableField(value = "owner_person_idcard") + private String ownerPersonIdcard; + + @TableField(value = "owner_person_phone") + private String ownerPersonPhone; + + + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/gather-app/src/main/java/com/ruoyi/database/domain/DevopsDeviceInfo.java b/gather-app/src/main/java/com/ruoyi/database/domain/DevopsDeviceInfo.java index a706059..23ae86b 100644 --- a/gather-app/src/main/java/com/ruoyi/database/domain/DevopsDeviceInfo.java +++ b/gather-app/src/main/java/com/ruoyi/database/domain/DevopsDeviceInfo.java @@ -66,6 +66,14 @@ public class DevopsDeviceInfo extends BaseEntity { @TableField(condition = SqlCondition.LIKE) private String gbsChannelNo; + /** + * 监控大类 + */ + @ApiModelProperty("监控大类") + @Excel(name = "监控大类") + private Integer parentMonitoringType; + + /** * 设备类型 */ diff --git a/gather-app/src/main/java/com/ruoyi/database/mapper/BoneVehicleMapper.java b/gather-app/src/main/java/com/ruoyi/database/mapper/BoneVehicleMapper.java new file mode 100644 index 0000000..1fa6285 --- /dev/null +++ b/gather-app/src/main/java/com/ruoyi/database/mapper/BoneVehicleMapper.java @@ -0,0 +1,22 @@ +package com.ruoyi.database.mapper; + + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.database.domain.BoneVehicle; +import org.apache.ibatis.annotations.Mapper; + +/** +* @author 28758 +* @description 针对表【bone_vehicle(小区机动车表 )】的数据库操作Mapper +* @createDate 2023-12-26 21:35:05 +* @Entity generator.domain.BoneVehicle +*/ +@Mapper +public interface BoneVehicleMapper extends BaseMapper { + +} + + + + diff --git a/gather-app/src/main/java/com/ruoyi/database/service/BoneVehicleService.java b/gather-app/src/main/java/com/ruoyi/database/service/BoneVehicleService.java new file mode 100644 index 0000000..e895184 --- /dev/null +++ b/gather-app/src/main/java/com/ruoyi/database/service/BoneVehicleService.java @@ -0,0 +1,14 @@ +package com.ruoyi.database.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.database.domain.BoneVehicle; + +/** +* @author 28758 +* @description 针对表【bone_vehicle(小区机动车表 )】的数据库操作Service +* @createDate 2023-12-26 21:35:05 +*/ +public interface BoneVehicleService extends IService { + +} diff --git a/gather-app/src/main/java/com/ruoyi/database/service/impl/BoneVehicleServiceImpl.java b/gather-app/src/main/java/com/ruoyi/database/service/impl/BoneVehicleServiceImpl.java new file mode 100644 index 0000000..03ec60c --- /dev/null +++ b/gather-app/src/main/java/com/ruoyi/database/service/impl/BoneVehicleServiceImpl.java @@ -0,0 +1,23 @@ +package com.ruoyi.database.service.impl; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.database.domain.BoneVehicle; +import com.ruoyi.database.mapper.BoneVehicleMapper; +import com.ruoyi.database.service.BoneVehicleService; +import org.springframework.stereotype.Service; + +/** +* @author 28758 +* @description 针对表【bone_vehicle(小区机动车表 )】的数据库操作Service实现 +* @createDate 2023-12-26 21:35:05 +*/ +@Service +public class BoneVehicleServiceImpl extends ServiceImpl + implements BoneVehicleService { + +} + + + +