| | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.system.domain.SysTaskVehicle; |
| | | import com.ruoyi.system.domain.VehicleInfo; |
| | | import com.ruoyi.system.service.ISysTaskService; |
| | | import com.ruoyi.system.service.IVehicleInfoService; |
| | | |
| | | /** |
| | | * 任务车辆关联Controller |
| | |
| | | |
| | | @Autowired |
| | | private ISysTaskService sysTaskService; |
| | | |
| | | @Autowired |
| | | private IVehicleInfoService vehicleInfoService; |
| | | |
| | | /** |
| | | * 查询任务关联的车辆列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('task:general:query')") |
| | | @GetMapping("/list/{taskId}") |
| | | public AjaxResult list(@PathVariable("taskId") Long taskId) { |
| | | List<SysTaskVehicle> list = sysTaskService.getTaskVehicles(taskId); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询可用车辆列表 |
| | | * 查询可用车辆列表(根据用户权限) |
| | | * 根据用户所在的分公司,通过车辆-分公司关联表查询所有可用车辆 |
| | | * |
| | | * @param deptId 部门ID(可选,如果不传则使用当前用户的deptId) |
| | | * @param taskType 任务类型(可选) |
| | | * @return 车辆列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('task:general:query')") |
| | | @GetMapping("/available") |
| | | public AjaxResult getAvailableVehicles(@RequestParam Long deptId, @RequestParam(required = false) String taskType) { |
| | | List<SysTaskVehicle> list = sysTaskService.getAvailableVehicles(deptId, taskType); |
| | | return success(list); |
| | | public AjaxResult getAvailableVehicles( |
| | | @RequestParam(required = false) Long deptId, |
| | | @RequestParam(required = false) String taskType) { |
| | | // 如果没有传deptId,使用当前用户的userId查询 |
| | | List<VehicleInfo> vehicles = vehicleInfoService.selectAvailableVehiclesByUser(getUserId()); |
| | | return success(vehicles); |
| | | } |
| | | |
| | | /** |
| | | * 分配车辆给任务 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('task:general:assign')") |
| | | @Log(title = "任务车辆分配", businessType = BusinessType.INSERT) |
| | | @PostMapping("/assign/{taskId}") |
| | | public AjaxResult assignVehicle(@PathVariable("taskId") Long taskId, @RequestBody AssignVehicleRequest request) { |
| | |
| | | /** |
| | | * 批量分配车辆给任务 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('task:general:assign')") |
| | | @Log(title = "任务车辆批量分配", businessType = BusinessType.INSERT) |
| | | @PostMapping("/assign-batch/{taskId}") |
| | | public AjaxResult assignVehicles(@PathVariable("taskId") Long taskId, @RequestBody BatchAssignVehicleRequest request) { |
| | |
| | | /** |
| | | * 取消任务车辆分配 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('task:general:assign')") |
| | | @Log(title = "取消任务车辆分配", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{taskId}/{vehicleId}") |
| | | public AjaxResult unassignVehicle(@PathVariable("taskId") Long taskId, @PathVariable("vehicleId") Long vehicleId) { |