From 3d4eeb82dd61f8951616dece2425e870116bc23d Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 04 四月 2025 15:56:37 +0800
Subject: [PATCH] 提交最终版本和配置线上环境

---
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CarController.java |  208 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 208 insertions(+), 0 deletions(-)

diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CarController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CarController.java
index cc99532..3255d47 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CarController.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CarController.java
@@ -1,7 +1,38 @@
 package com.ruoyi.system.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.dataInterchange.api.feignClient.PlaybackMsgClient;
+import com.ruoyi.dataInterchange.api.feignClient.RealVideoMsgClient;
+import com.ruoyi.dataInterchange.api.feignClient.UPExgMsgRealLocationClient;
+import com.ruoyi.dataInterchange.api.vo.GnssDataVo;
+import com.ruoyi.dataInterchange.api.vo.OrderTravelVo;
+import com.ruoyi.dataInterchange.api.vo.UPPlaybackMsgStartupAckVo;
+import com.ruoyi.dataInterchange.api.vo.UPRealvideoMsgStartupAckVo;
+import com.ruoyi.system.api.model.Car;
+import com.ruoyi.system.api.model.CarType;
+import com.ruoyi.system.api.model.Driver;
+import com.ruoyi.system.api.model.Enterprise;
+import com.ruoyi.system.query.*;
+import com.ruoyi.system.service.ICarService;
+import com.ruoyi.system.service.ICarTypeService;
+import com.ruoyi.system.service.IDriverService;
+import com.ruoyi.system.service.IEnterpriseService;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.util.List;
 
 /**
  * @author zhibing.pu
@@ -10,4 +41,181 @@
 @RestController
 @RequestMapping("/car")
 public class CarController {
+	
+	@Resource
+	private ICarService carService;
+	
+	@Resource
+	private IDriverService driverService;
+	
+	@Resource
+	private IEnterpriseService enterpriseService;
+	
+	@Resource
+	private RealVideoMsgClient realVideoMsgClient;
+	
+	@Resource
+	private PlaybackMsgClient playbackMsgClient;
+	
+	@Resource
+	private UPExgMsgRealLocationClient upExgMsgRealLocationClient;
+	
+	@Resource
+	private ICarTypeService carTypeService;
+	
+	@Resource
+	private RedisTemplate redisTemplate;
+	
+	
+	@GetMapping("/getCarList")
+	@ApiOperation(value = "获取车辆列表", tags = {"车辆管理"})
+	public R<PageInfo<CarListResp>> getCarList(CarListReq carListReq) {
+		PageInfo<CarListResp> carList = carService.getCarList(carListReq);
+		return R.ok(carList);
+	}
+	
+	
+	@GetMapping("/getCarInfo/{id}")
+	@ApiOperation(value = "获取车辆详情", tags = {"车辆管理"})
+	@ApiImplicitParams({
+			@ApiImplicitParam(value = "车辆id", name = "id", required = true)
+	})
+	public R<Car> getCarInfo(@PathVariable("id") Integer id) {
+		Car car = carService.getById(id);
+		if (null == car) {
+			return R.fail("失败");
+		}
+		Driver driver = driverService.getOne(new LambdaQueryWrapper<Driver>().eq(Driver::getVehicleNumber, car.getVehicleNumber()).eq(Driver::getStatus, 1));
+		Enterprise enterprise = enterpriseService.getById(car.getEnterpriseId());
+		car.setEnterpriseName(enterprise.getName());
+		car.setDriverName(driver.getName());
+		return R.ok(car);
+	}
+	
+	
+	@GetMapping("/getRealVideo/{id}")
+	@ApiOperation(value = "获取实时音视频", tags = {"车辆管理"})
+	@ApiImplicitParams({
+			@ApiImplicitParam(value = "车辆id", name = "id", required = true)
+	})
+	public R<RealVideoResp> getRealVideo(@PathVariable("id") Integer id) {
+		Car car = carService.getById(id);
+		if (null == car) {
+			return R.fail("失败");
+		}
+		Enterprise enterprise = enterpriseService.getById(car.getEnterpriseId());
+		R<UPRealvideoMsgStartupAckVo> msgStartupAckVoR = realVideoMsgClient.startupRealVideo(Integer.valueOf(enterprise.getCode()), car.getVehicleNumber());
+		if (200 == msgStartupAckVoR.getCode()) {
+			UPRealvideoMsgStartupAckVo data = msgStartupAckVoR.getData();
+			RealVideoResp resp = new RealVideoResp();
+			resp.setServerIp(data.getServerIP());
+			resp.setServerPort(data.getServerPort());
+			return R.ok(resp);
+		}
+		return R.fail(msgStartupAckVoR.getMsg());
+	}
+	
+	
+	@GetMapping("/getPlaybackVideo")
+	@ApiOperation(value = "获取音视频回放", tags = {"车辆管理"})
+	public R<RealVideoResp> getPlaybackVideo(PlaybackVideoReq req) {
+		Car car = carService.getById(req.getId());
+		if (null == car) {
+			return R.fail("失败");
+		}
+		Enterprise enterprise = enterpriseService.getById(car.getEnterpriseId());
+		R<UPPlaybackMsgStartupAckVo> startupAckVoR = playbackMsgClient.playbackMsgStartup(Integer.valueOf(enterprise.getCode()), car.getVehicleNumber(),
+				req.getStartTime(), req.getEndTime());
+		if (200 == startupAckVoR.getCode()) {
+			UPPlaybackMsgStartupAckVo data = startupAckVoR.getData();
+			RealVideoResp resp = new RealVideoResp();
+			resp.setServerIp(data.getServerIP());
+			resp.setServerPort(data.getServerPort());
+			return R.ok(resp);
+		}
+		return R.fail(startupAckVoR.getMsg());
+	}
+	
+	
+	@GetMapping("/playbackMsgControl")
+	@ApiOperation(value = "音视频回放远程控制", tags = {"车辆管理"})
+	public R playbackMsgControl(PlaybackMsgControlReq req) {
+		Car car = carService.getById(req.getId());
+		if (null == car) {
+			return R.fail("失败");
+		}
+		Enterprise enterprise = enterpriseService.getById(car.getEnterpriseId());
+		return playbackMsgClient.playbackMsgControl(Integer.valueOf(enterprise.getCode()), car.getVehicleNumber(),
+				req.getControlType(), req.getFastTime());
+	}
+	
+	
+	@GetMapping("/getCarTravel")
+	@ApiOperation(value = "获取车辆行程轨迹", tags = {"车辆管理"})
+	public R<List<OrderTravelVo>> getCarTravel(CarTravelReq req) {
+		Car car = carService.getOne(new LambdaQueryWrapper<Car>().eq(Car::getVehicleNumber, req.getVehicleNumber()));
+		Long startTime;
+		Long endTime;
+		if (null != req.getStartTime() && null != req.getEndTime()) {
+			startTime = req.getStartTime();
+			endTime = req.getEndTime();
+		} else {
+			LocalDateTime now = LocalDateTime.now();
+			startTime = now.minusMinutes(1).toEpochSecond(ZoneOffset.ofHours(8));
+			endTime = now.toEpochSecond(ZoneOffset.ofHours(8));
+		}
+		R<List<OrderTravelVo>> orderTravel = upExgMsgRealLocationClient.getOrderTravel(car.getVehicleNumber(), startTime, endTime);
+		return orderTravel;
+	}
+	
+	
+	@GetMapping("/getCarTypeList")
+	@ApiOperation(value = "获取车辆类型列表数据", tags = {"车辆类型"})
+	public R<List<CarType>> getCarTypeList(String name) {
+		List<CarType> list = carTypeService.list(new LambdaQueryWrapper<CarType>().like(StringUtils.isNotEmpty(name), CarType::getName, name));
+		return R.ok(list);
+	}
+	
+	
+	@GetMapping("/getCarCount")
+	@ApiOperation(value = "获取各种车辆类型车辆总数", tags = {"首页"})
+	public R<List<CarType>> getCarCount() {
+		List<CarType> list = carTypeService.list();
+		return R.ok(list);
+	}
+	
+	
+	@GetMapping("/getCarStatusCount")
+	@ApiOperation(value = "获取车辆状态汇总数据和公司总数等", tags = {"首页"})
+	public R<CarStatusCount> getCarStatusCount() {
+		List<Car> list = carService.list();
+		long online = list.stream().filter(s -> s.getStatus() == 1).count();
+		long offline = list.stream().filter(s -> s.getStatus() == 3).count();
+		long breakdown = list.stream().filter(s -> s.getStatus() == 4).count();
+		long abnormal = list.stream().filter(s -> s.getStatus() == 2).count();
+		CarStatusCount carStatusCount = new CarStatusCount();
+		carStatusCount.setOffline(offline);
+		carStatusCount.setOnline(online);
+		carStatusCount.setBreakdown(breakdown);
+		carStatusCount.setAbnormal(abnormal);
+		long enterprise = enterpriseService.count();
+		carStatusCount.setEnterprise(enterprise);
+		carStatusCount.setCar(list.size());
+		long driver = driverService.count();
+		carStatusCount.setDriver(driver);
+		return R.ok(carStatusCount);
+	}
+	
+	
+	@GetMapping("/getMapCarList")
+	@ApiOperation(value = "获取地图司机数据", tags = {"首页"})
+	public R<List<Car>> getMapCarList() {
+		List<Car> list = carService.list();
+		for (Car car : list) {
+			GnssDataVo gnssDataVo = (GnssDataVo) redisTemplate.opsForValue().get("location:" + car.getVehicleNumber());
+			car.setLongitude(Double.valueOf(gnssDataVo.getLon() / 1000000).toString());
+			car.setLatitude(Double.valueOf(gnssDataVo.getLat() / 1000000).toString());
+		}
+		return R.ok(list);
+	}
 }

--
Gitblit v1.7.1