From 1ee76c252f2dbba62e0ec34cccf9eaac51de9083 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期三, 23 七月 2025 16:25:23 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/WarnController.java |   46 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/WarnController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/WarnController.java
index 550d9ad..0b85382 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/WarnController.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/WarnController.java
@@ -31,6 +31,7 @@
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -56,9 +57,15 @@
 	
 	@GetMapping("/getCarWarnList")
 	@ApiOperation(value = "获取车辆预警列表数据", tags = {"车辆管理", "预警记录", "首页"})
-	public R<PageInfo<CarWarnListResp>> getCarWarnList(CarWarnListReq carWarnListReq) {
+	public R<Map<String, Object>> getCarWarnList(CarWarnListReq carWarnListReq) {
 		PageInfo<CarWarnListResp> pageInfo = warnService.getCarWarnList(carWarnListReq);
-		return R.ok(pageInfo);
+		Map<String, Object> map = new HashMap<>();
+		map.put("page", pageInfo);
+		List<Warn> list = warnService.getAllCarWarnList(carWarnListReq);
+		map.put("total", list.size());
+		map.put("processed", list.stream().filter(s->!s.getTreatmentState().equals("处理中")).count());
+		map.put("unprocessed", list.stream().filter(s->s.getTreatmentState().equals("处理中")).count());
+		return R.ok(map);
 	}
 	
 	
@@ -99,21 +106,23 @@
 			return R.ok();
 		}
 		String time = LocalDateTime.now().minusMinutes(15).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
-		List<Warn> list = warnService.list(new LambdaQueryWrapper<Warn>().eq(Warn::getCarId, car.getId()).lt(Warn::getStartTime, time).orderByDesc(Warn::getCreateTime));
+		List<Warn> list = warnService.list(new LambdaQueryWrapper<Warn>().eq(Warn::getCarId, car.getId()).gt(Warn::getStartTime, time).orderByDesc(Warn::getStartTime));
 		CarWarnInfoResp carWarnInfoResp = new CarWarnInfoResp();
 		carWarnInfoResp.setVehicleNumber(vehicleNumber);
 		GnssDataVo gnssDataVo = upExgMsgRealLocationClient.getVehicleSpeed(vehicleNumber).getData();
-		carWarnInfoResp.setSpeed(new BigDecimal(gnssDataVo.getVec1()));
-		Map<String, String> geocode = null;
-		try {
-			String longitude = new BigDecimal(gnssDataVo.getLon()).divide(new BigDecimal(1000000)).toString();
-			String latitude = new BigDecimal(gnssDataVo.getLat()).divide(new BigDecimal(1000000)).toString();
-			geocode = GDMapGeocodingUtil.geocode(longitude, latitude);
-		} catch (Exception e) {
-			throw new RuntimeException(e);
+		if(null != gnssDataVo){
+			carWarnInfoResp.setSpeed(new BigDecimal(gnssDataVo.getVec1()));
+			Map<String, String> geocode = null;
+			try {
+				String longitude = new BigDecimal(gnssDataVo.getLon()).divide(new BigDecimal(1000000)).toString();
+				String latitude = new BigDecimal(gnssDataVo.getLat()).divide(new BigDecimal(1000000)).toString();
+				geocode = GDMapGeocodingUtil.geocode(longitude, latitude);
+			} catch (Exception e) {
+				throw new RuntimeException(e);
+			}
+			String address = geocode.get("address");
+			carWarnInfoResp.setNowAddress(address);
 		}
-		String address = geocode.get("address");
-		carWarnInfoResp.setNowAddress(address);
 		List<WarnResp> warnList = new ArrayList<>();
 		for (Warn warn : list) {
 			WarnResp warnResp = new WarnResp();
@@ -123,6 +132,7 @@
 			warnResp.setLon(new BigDecimal(warn.getLongitude()));
 			warnResp.setLat(new BigDecimal(warn.getLatitude()));
 			warnResp.setAddress(warn.getAddress());
+			warnResp.setImageUrl(warn.getPicUrl());
 			warnList.add(warnResp);
 		}
 		carWarnInfoResp.setWarnList(warnList);
@@ -142,4 +152,14 @@
 		List<Map<String, Object>> warnGroupCountTop10 = warnService.getWarnGroupCountTop10();
 		return R.ok(warnGroupCountTop10);
 	}
+
+
+
+
+	@GetMapping("/getAllWarnGroupVehicleType")
+	@ApiOperation(value = "获取根据车辆类型的报警汇总数据", tags = {"首页"})
+	public R<List<Map<String, Object>>> getAllWarnGroupVehicleType(){
+		List<Map<String, Object>> allWarnGroupVehicleType = warnService.getAllWarnGroupVehicleType();
+		return R.ok(allWarnGroupVehicleType);
+	}
 }

--
Gitblit v1.7.1