Pu Zhibing
2025-03-21 e102aefb00170246d40995d8d7e53cad2385e4d4
guns-admin/src/main/java/com/stylefeng/guns/modular/api/PatrolTaskController.java
@@ -1,23 +1,28 @@
package com.stylefeng.guns.modular.api;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.common.constant.JwtConstants;
import com.stylefeng.guns.core.page.PageInfoBT;
import com.stylefeng.guns.core.util.JwtTokenUtil;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.system.model.Vehicles;
import com.stylefeng.guns.modular.system.model.enums.ImageModelEnum;
import com.stylefeng.guns.modular.system.model.enums.VideoChannelEnum;
import com.stylefeng.guns.modular.system.model.vo.*;
import com.stylefeng.guns.modular.system.service.IPatrolTaskService;
import com.stylefeng.guns.modular.system.service.ITaskDetailService;
import com.stylefeng.guns.modular.system.service.IVehicleService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.util.videoGateway.VideoGateway;
import com.stylefeng.guns.modular.system.util.videoGateway.model.Ship;
import com.stylefeng.guns.modular.system.util.videoGateway.model.Vehicle;
import com.stylefeng.guns.modular.system.warpper.VehicleSpeed;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -29,6 +34,7 @@
 * @author zhibing.pu
 * @Date 2024/12/17 20:18
 */
@Slf4j
@RestController
@RequestMapping("")
public class PatrolTaskController extends BaseController {
@@ -38,6 +44,9 @@
   
   @Resource
   private ITaskDetailService taskDetailService;
   @Resource
   private IVehicleService vehicleService;
   
   
   
@@ -115,17 +124,15 @@
   @GetMapping("/api/patrolTask/getVehicleList")
   @ApiOperation(value = "获取车辆列表", tags = {"任务管理"})
   public ResultUtil<List<Vehicle>> getVehicleList(Integer year){
      List<Vehicle> vehicleList = VideoGateway.getVehicleList(null, null, null, 0);
      List<Vehicles> vehicles = vehicleService.selectList(null);
      List<Vehicle> list = new ArrayList<>();
      if(null != year){
         for (Vehicle vehicle : vehicleList) {
            String vehicleGpsProtocol = vehicle.getVehicleGpsProtocol();
            if(2023 == year && null != vehicleGpsProtocol && vehicleGpsProtocol.equals("2")){
               list.add(vehicle);
            }
         }
      }else{
         list = vehicleList;
      for (Vehicles vehicle : vehicles) {
         Vehicle vehicle1 = new Vehicle();
         vehicle1.setId(vehicle.getId());
         vehicle1.setVehicleNum(vehicle.getVehicleCode());
         vehicle1.setCompanyName(vehicle.getCompanyName());
         vehicle1.setCompanyId(vehicle.getCompanyId().toString());
         list.add(vehicle1);
      }
      return ResultUtil.success(list);
   }
@@ -226,7 +233,7 @@
   }
   
   
   @PutMapping("/base/patrolTask/vehicleSpeed")
   @PostMapping("/base/patrolTask/vehicleSpeed")
   @ApiOperation(value = "变更车辆状态", tags = {"互联互通接口"})
   @ApiImplicitParams({
         @ApiImplicitParam(value = "车牌号", name = "vehicleNum", dataType = "String", required = true),
@@ -237,8 +244,10 @@
         @ApiImplicitParam(value = "纬度", name = "latitude", dataType = "double", required = true),
         @ApiImplicitParam(value = "经度", name = "longitude", dataType = "double", required = true),
   })
   public ResultUtil vehicleSpeed(String vehicleNum, Integer vehicleStatus, Integer vehicleType, String communicationNum, String vehicleGpsProtocol, Double latitude, Double longitude){
      patrolTaskService.vehicleSpeed(vehicleNum, vehicleStatus, vehicleType, communicationNum, vehicleGpsProtocol, latitude, longitude);
   public ResultUtil vehicleSpeed(@RequestBody VehicleSpeed vehicleSpeed){
      log.info("推送车辆状态:{}", JSON.toJSONString(vehicleSpeed));
      patrolTaskService.vehicleSpeed(vehicleSpeed.getVehicleNum(), vehicleSpeed.getVehicleStatus(), vehicleSpeed.getVehicleType(),
            vehicleSpeed.getCommunicationNum(), vehicleSpeed.getVehicleGpsProtocol(), vehicleSpeed.getLatitude(), vehicleSpeed.getLongitude());
      return ResultUtil.success();
   }
}