首页24小时警情统计接口

develop
Angel 10 months ago
parent eb0c2556fa
commit e9c6a237c8

@ -24,6 +24,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
/** /**
@ -107,12 +108,13 @@ public class MetaAlarmInfoController extends BaseController {
return getDataTable(list); return getDataTable(list);
} }
@GetMapping("/filterByDay") @GetMapping("/filterByDay")
@ApiOperation("七天接警信息表") @ApiOperation("七天接警信息表")
public AjaxResult filterByDay(MetaAlarmInfo metaAlarmInfo) { public AjaxResult filterByDay(MetaAlarmInfo metaAlarmInfo) {
try { try {
// 获取当前日期 // 获取当前日期
LocalDate currentDate = LocalDate.now(); LocalDate currentDate = LocalDate.now();
// 创建一个 TreeMap 用于存储每天的数据量 // 创建一个 TreeMap 用于存储每天的数据量
Map<LocalDate, Long> dailyCountsMap = new TreeMap<>(); Map<LocalDate, Long> dailyCountsMap = new TreeMap<>();
// 循环迭代前7天 // 循环迭代前7天
@ -139,6 +141,39 @@ public class MetaAlarmInfoController extends BaseController {
return AjaxResult.error("请求失败,请联系管理员"); 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<String, Long> hourlyCountsMap = new TreeMap<>();
//循环
for (int i = 0; i < currentHour; i++) {
//构造查询条件
LocalDateTime startOfHour = startOfCurrentHour.minusHours(currentHour - i);
LocalDateTime endOfHour = startOfHour.plusHours(1);
QueryWrapper<MetaAlarmInfo> 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 @PostMapping
@ApiOperation("新增接警信息表") @ApiOperation("新增接警信息表")

@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@Api(tags = "智能设备信息表") @Api(tags = "港口的信息表")
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/base/contact/person") @RequestMapping("/base/contact/person")

@ -2,6 +2,7 @@ package com.ruoyi.database.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.database.domain.MetaPortContactPersonInfo;
import com.ruoyi.database.domain.MetaPortInfo; import com.ruoyi.database.domain.MetaPortInfo;
import com.ruoyi.database.service.MetaPortInfoService; import com.ruoyi.database.service.MetaPortInfoService;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
@ -41,6 +42,7 @@ public class MetaPortInfoController extends BaseController {
return getDataTable(list); return getDataTable(list);
} }
@PostMapping @PostMapping
@ApiOperation("新增港口信息表") @ApiOperation("新增港口信息表")
@Log(title = "港口信息表", businessType = BusinessType.INSERT) @Log(title = "港口信息表", businessType = BusinessType.INSERT)

@ -46,9 +46,7 @@ public class TransitHuntersUserModelRecordController extends BaseController {
@ApiOperation("查询非法狩猎人员模型记录表") @ApiOperation("查询非法狩猎人员模型记录表")
public TableDataInfo<TransitHuntersUserModelRecord> list(TransitHuntersUserModelRecord transitHuntersUserModelRecord) { public TableDataInfo<TransitHuntersUserModelRecord> list(TransitHuntersUserModelRecord transitHuntersUserModelRecord) {
startPage(); startPage();
QueryWrapper<TransitHuntersUserModelRecord> queryWrapper = new QueryWrapper<>(transitHuntersUserModelRecord); QueryWrapper<TransitHuntersUserModelRecord> queryWrapper = new QueryWrapper<>(transitHuntersUserModelRecord);
SimpleDateFormat outputSdf = new SimpleDateFormat("yyyyMMddHHmmss"); SimpleDateFormat outputSdf = new SimpleDateFormat("yyyyMMddHHmmss");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (transitHuntersUserModelRecord.getFirstTime() != null && transitHuntersUserModelRecord.getEndTime() != null) { if (transitHuntersUserModelRecord.getFirstTime() != null && transitHuntersUserModelRecord.getEndTime() != null) {
@ -71,8 +69,6 @@ public class TransitHuntersUserModelRecordController extends BaseController {
Long firstTime = modelRecordVo.getFirstPassTime(); Long firstTime = modelRecordVo.getFirstPassTime();
Long endTime = modelRecordVo.getEndPassTime(); Long endTime = modelRecordVo.getEndPassTime();
if( !"".equals(StringKit.toString(firstTime)) && !"".equals(StringKit.toString(endTime)) ){ if( !"".equals(StringKit.toString(firstTime)) && !"".equals(StringKit.toString(endTime)) ){
// int firstTimeI = NumKit.checkInt(firstTime);
// int endTimeI = NumKit.checkInt(endTime);
Long difference = endTime - firstTime; Long difference = endTime - firstTime;
java.time.Duration duration = java.time.Duration.ofSeconds(difference); java.time.Duration duration = java.time.Duration.ofSeconds(difference);
String formattedDuration = DateUtil.formatBetween(duration.toMillis()); String formattedDuration = DateUtil.formatBetween(duration.toMillis());
@ -81,8 +77,6 @@ public class TransitHuntersUserModelRecordController extends BaseController {
return modelRecordVo; return modelRecordVo;
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
return getDataTable(listVo); return getDataTable(listVo);
} }

@ -3,6 +3,7 @@ package com.ruoyi.database.domain;
import java.util.Date; import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
@ -52,6 +53,8 @@ public class MetaPortInfo extends BaseEntity {
@Excel(name = "港口地址") @Excel(name = "港口地址")
private String portAddress; private String portAddress;
/** /**
* *
*/ */
@ -66,4 +69,6 @@ public class MetaPortInfo extends BaseEntity {
@Excel(name = "纬度") @Excel(name = "纬度")
private Double latitude; private Double latitude;
} }

Loading…
Cancel
Save