| | |
| | | |
| | | 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.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; |
| | |
| | | @Resource |
| | | private UPExgMsgRealLocationClient upExgMsgRealLocationClient; |
| | | |
| | | @Resource |
| | | private ICarTypeService carTypeService; |
| | | |
| | | |
| | | @GetMapping("/getCarList") |
| | | @ApiOperation(value = "获取车辆列表", tags = {"车辆管理"}) |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "车辆id", name = "id", required = true) |
| | | }) |
| | | public R<Car> getCarInfo(@PathVariable("id") Integer id){ |
| | | public R<Car> getCarInfo(@PathVariable("id") Integer id) { |
| | | Car car = carService.getById(id); |
| | | if(null == car){ |
| | | if (null == car) { |
| | | return R.fail("失败"); |
| | | } |
| | | Driver driver = driverService.getOne(new LambdaQueryWrapper<Driver>().eq(Driver::getVehicleNumber, car.getVehicleNumber()).eq(Driver::getStatus, 1)); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/getRealVideo/{id}") |
| | | @ApiOperation(value = "获取实时音视频", tags = {"车辆管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "车辆id", name = "id", required = true) |
| | | }) |
| | | public R<RealVideoResp> getRealVideo(@PathVariable("id") Integer id){ |
| | | public R<RealVideoResp> getRealVideo(@PathVariable("id") Integer id) { |
| | | Car car = carService.getById(id); |
| | | if(null == car){ |
| | | 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()){ |
| | | if (200 == msgStartupAckVoR.getCode()) { |
| | | UPRealvideoMsgStartupAckVo data = msgStartupAckVoR.getData(); |
| | | RealVideoResp resp = new RealVideoResp(); |
| | | resp.setServerIp(data.getServerIP()); |
| | |
| | | |
| | | @GetMapping("/getPlaybackVideo") |
| | | @ApiOperation(value = "获取音视频回放", tags = {"车辆管理"}) |
| | | public R<RealVideoResp> getPlaybackVideo(PlaybackVideoReq req){ |
| | | public R<RealVideoResp> getPlaybackVideo(PlaybackVideoReq req) { |
| | | Car car = carService.getById(req.getId()); |
| | | if(null == car){ |
| | | 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()){ |
| | | if (200 == startupAckVoR.getCode()) { |
| | | UPPlaybackMsgStartupAckVo data = startupAckVoR.getData(); |
| | | RealVideoResp resp = new RealVideoResp(); |
| | | resp.setServerIp(data.getServerIP()); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/playbackMsgControl") |
| | | @ApiOperation(value = "音视频回放远程控制", tags = {"车辆管理"}) |
| | | public R playbackMsgControl(PlaybackMsgControlReq req){ |
| | | public R playbackMsgControl(PlaybackMsgControlReq req) { |
| | | Car car = carService.getById(req.getId()); |
| | | if(null == car){ |
| | | if (null == car) { |
| | | return R.fail("失败"); |
| | | } |
| | | Enterprise enterprise = enterpriseService.getById(car.getEnterpriseId()); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/getCarTravel") |
| | | @ApiOperation(value = "获取车辆行程轨迹", tags = {"车辆管理"}) |
| | | public R<List<OrderTravelVo>> getCarTravel(CarTravelReq req){ |
| | | 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()){ |
| | | if (null != req.getStartTime() && null != req.getEndTime()) { |
| | | startTime = req.getStartTime(); |
| | | endTime = req.getEndTime(); |
| | | }else{ |
| | | } 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); |
| | | } |
| | | |
| | | } |