| | |
| | | package com.ruoyi.system.controller; |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.dataInterchange.api.feignClient.PlaybackMsgClient; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | 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 javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; /** |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/3/24 17:50 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/order") |
| | | public class OrderController { |
| | | |
| | | |
| | | @Resource |
| | | private IOrderService orderService; |
| | | |
| | |
| | | private PlaybackMsgClient playbackMsgClient; |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/getOrderList") |
| | | @ApiOperation(value = "获取订单列表", tags = {"车辆管理", "订单管理"}) |
| | | public R<PageInfo<Order>> getOrderList(OrderListReq req){ |
| | | public R<PageInfo<Order>> getOrderList(OrderListReq req) { |
| | | PageInfo<Order> orderList = orderService.getOrderList(req); |
| | | return R.ok(orderList); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/exportOrderList") |
| | | @ApiOperation(value = "导出订单列表", tags = {"订单管理"}) |
| | | public void exportOrderList(OrderListReq req, HttpServletResponse response) { |
| | | req.setPageSize(99999); |
| | | PageInfo<Order> orderList = orderService.getOrderList(req); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), Order.class, orderList.getRecords()); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("订单列表.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | workbook.close(); |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getOrderInfo/{id}") |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "id", required = true) |
| | | }) |
| | | public R<Order> getOrderInfo(@PathVariable("id") Integer id){ |
| | | public R<Order> getOrderInfo(@PathVariable("id") Integer id) { |
| | | Order order = orderService.getById(id); |
| | | if(null == order){ |
| | | if (null == order) { |
| | | return R.fail("失败"); |
| | | } |
| | | Driver driver = driverService.getById(order.getDriverId()); |
| | | Car car = carService.getById(order.getCarId()); |
| | | Enterprise enterprise = enterpriseService.getById(order.getEnterpriseId()); |
| | | order.setDriverName(driver.getName()); |
| | | if (null != driver) { |
| | | order.setDriverName(driver.getName()); |
| | | order.setDriverPhone(driver.getPhone()); |
| | | order.setDrivingLicenseNumber(driver.getDrivingLicenseNumber()); |
| | | } |
| | | order.setVehicleNumber(car.getVehicleNumber()); |
| | | order.setEnterpriseName(enterprise.getName()); |
| | | return R.ok(order); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/getOrderTravel") |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "id", required = true) |
| | | }) |
| | | public R<List<OrderTravelVo>> getOrderTravel(@PathVariable("id") Integer id){ |
| | | public R<List<OrderTravelVo>> getOrderTravel(Integer id) { |
| | | Order order = orderService.getById(id); |
| | | if(null == order){ |
| | | if (null == order) { |
| | | return R.fail("失败"); |
| | | } |
| | | Car car = carService.getById(order.getCarId()); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/getOrderMonitoring") |
| | | @ApiOperation(value = "获取订单监控", tags = {"订单管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "id", required = true) |
| | | }) |
| | | public R<RealVideoResp> getOrderMonitoring(@PathVariable("id") Integer id){ |
| | | public R<RealVideoResp> getOrderMonitoring(Integer id) { |
| | | Order order = orderService.getById(id); |
| | | if(null == order){ |
| | | if (null == order) { |
| | | return R.fail("失败"); |
| | | } |
| | | Car car = carService.getById(order.getCarId()); |
| | |
| | | long endTime = dateTime.plusDays(1).toEpochSecond(ZoneOffset.ofHours(8)); |
| | | R<UPPlaybackMsgStartupAckVo> startupAckVoR = playbackMsgClient.playbackMsgStartup(Integer.valueOf(enterprise.getCode()), car.getVehicleNumber(), |
| | | startTime, endTime); |
| | | if(200 == startupAckVoR.getCode()){ |
| | | if (200 == startupAckVoR.getCode()) { |
| | | UPPlaybackMsgStartupAckVo data = startupAckVoR.getData(); |
| | | RealVideoResp resp = new RealVideoResp(); |
| | | resp.setServerIp(data.getServerIP()); |