From e9c6a237c82823fd1010ff19bb11092bf5e9a1ea Mon Sep 17 00:00:00 2001 From: Angel <1050374295@qq.com> Date: Fri, 26 Jan 2024 17:28:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B524=E5=B0=8F=E6=97=B6=E8=AD=A6?= =?UTF-8?q?=E6=83=85=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MetaAlarmInfoController.java | 37 ++++++++++++++++++- .../MetaPortContactPersonInfoController.java | 2 +- .../controller/MetaPortInfoController.java | 2 + ...ansitHuntersUserModelRecordController.java | 6 --- .../ruoyi/database/domain/MetaPortInfo.java | 5 +++ 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/MetaAlarmInfoController.java b/gather-app/src/main/java/com/ruoyi/database/controller/MetaAlarmInfoController.java index 4e7034e..1b35e89 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/MetaAlarmInfoController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/MetaAlarmInfoController.java @@ -24,6 +24,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.*; /** @@ -107,12 +108,13 @@ public class MetaAlarmInfoController extends BaseController { return getDataTable(list); } - @GetMapping("/filterByDay") + @GetMapping("/filterByDay") @ApiOperation("七天接警信息表") public AjaxResult filterByDay(MetaAlarmInfo metaAlarmInfo) { try { // 获取当前日期 LocalDate currentDate = LocalDate.now(); + // 创建一个 TreeMap 用于存储每天的数据量 Map dailyCountsMap = new TreeMap<>(); // 循环迭代前7天 @@ -139,6 +141,39 @@ public class MetaAlarmInfoController extends BaseController { return AjaxResult.error("请求失败,请联系管理员"); } } + @GetMapping("/filterByHour") + @ApiOperation("当天接警信息表") + public AjaxResult filterByHour(MetaAlarmInfo metaAlarmInfo) { + try { + // 获取当前日期和时间 + LocalDateTime currentDateTime = LocalDateTime.now(); + + //获取当前小时数 + int currentHour = currentDateTime.getHour(); + //将分钟和秒数置为零,表示当前时间点的小时的开始 + LocalDateTime startOfCurrentHour = currentDateTime.withMinute(0).withSecond(0); + //创建一个TreeMap 用于存储每天的数据量 + Map hourlyCountsMap = new TreeMap<>(); + //循环 + for (int i = 0; i < currentHour; i++) { + //构造查询条件 + LocalDateTime startOfHour = startOfCurrentHour.minusHours(currentHour - i); + LocalDateTime endOfHour = startOfHour.plusHours(1); + QueryWrapper queryWrapper = new QueryWrapper<>(metaAlarmInfo); + queryWrapper.between("alarm_response_time",startOfHour.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")), + endOfHour.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); + //查询当前小时的记录数据总数 + long HourCount = metaAlarmInfoService.count(queryWrapper); + //存 + hourlyCountsMap.put(endOfHour.format(DateTimeFormatter.ofPattern("HH:mm")),HourCount); + } + + return AjaxResult.success(hourlyCountsMap); + } catch (Exception e) { + logger.info(StringKit.toString(e)); + return AjaxResult.error("请求失败,请联系管理员"); + } + } @PostMapping @ApiOperation("新增接警信息表") diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/MetaPortContactPersonInfoController.java b/gather-app/src/main/java/com/ruoyi/database/controller/MetaPortContactPersonInfoController.java index e7e351b..1811ba3 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/MetaPortContactPersonInfoController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/MetaPortContactPersonInfoController.java @@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; -@Api(tags = "智能设备信息表") +@Api(tags = "港口的信息表") @RestController @RequiredArgsConstructor @RequestMapping("/base/contact/person") diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/MetaPortInfoController.java b/gather-app/src/main/java/com/ruoyi/database/controller/MetaPortInfoController.java index 3719e20..1a9f3b5 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/MetaPortInfoController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/MetaPortInfoController.java @@ -2,6 +2,7 @@ package com.ruoyi.database.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.database.domain.MetaPortContactPersonInfo; import com.ruoyi.database.domain.MetaPortInfo; import com.ruoyi.database.service.MetaPortInfoService; import com.ruoyi.common.annotation.Log; @@ -41,6 +42,7 @@ public class MetaPortInfoController extends BaseController { return getDataTable(list); } + @PostMapping @ApiOperation("新增港口信息表") @Log(title = "港口信息表", businessType = BusinessType.INSERT) diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/TransitHuntersUserModelRecordController.java b/gather-app/src/main/java/com/ruoyi/database/controller/TransitHuntersUserModelRecordController.java index c91e365..db70bff 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/TransitHuntersUserModelRecordController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/TransitHuntersUserModelRecordController.java @@ -46,9 +46,7 @@ public class TransitHuntersUserModelRecordController extends BaseController { @ApiOperation("查询非法狩猎人员模型记录表") public TableDataInfo list(TransitHuntersUserModelRecord transitHuntersUserModelRecord) { startPage(); - QueryWrapper queryWrapper = new QueryWrapper<>(transitHuntersUserModelRecord); - SimpleDateFormat outputSdf = new SimpleDateFormat("yyyyMMddHHmmss"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); if (transitHuntersUserModelRecord.getFirstTime() != null && transitHuntersUserModelRecord.getEndTime() != null) { @@ -71,8 +69,6 @@ public class TransitHuntersUserModelRecordController extends BaseController { Long firstTime = modelRecordVo.getFirstPassTime(); Long endTime = modelRecordVo.getEndPassTime(); if( !"".equals(StringKit.toString(firstTime)) && !"".equals(StringKit.toString(endTime)) ){ -// int firstTimeI = NumKit.checkInt(firstTime); -// int endTimeI = NumKit.checkInt(endTime); Long difference = endTime - firstTime; java.time.Duration duration = java.time.Duration.ofSeconds(difference); String formattedDuration = DateUtil.formatBetween(duration.toMillis()); @@ -81,8 +77,6 @@ public class TransitHuntersUserModelRecordController extends BaseController { return modelRecordVo; }) .collect(Collectors.toList()); - - return getDataTable(listVo); } diff --git a/gather-app/src/main/java/com/ruoyi/database/domain/MetaPortInfo.java b/gather-app/src/main/java/com/ruoyi/database/domain/MetaPortInfo.java index 6837b30..78835a0 100644 --- a/gather-app/src/main/java/com/ruoyi/database/domain/MetaPortInfo.java +++ b/gather-app/src/main/java/com/ruoyi/database/domain/MetaPortInfo.java @@ -3,6 +3,7 @@ package com.ruoyi.database.domain; import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.ruoyi.common.annotation.Excel; @@ -52,6 +53,8 @@ public class MetaPortInfo extends BaseEntity { @Excel(name = "港口地址") private String portAddress; + + /** * 经度 */ @@ -66,4 +69,6 @@ public class MetaPortInfo extends BaseEntity { @Excel(name = "纬度") private Double latitude; + + }