|
|
@@ -0,0 +1,210 @@
|
|
|
+package com.ruoyi.uniapp.controller;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.io.IOException;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import com.ruoyi.uniapp.domain.VehicleWorkAreas;
|
|
|
+import com.ruoyi.uniapp.dto.DeviceTasksDTO;
|
|
|
+import com.ruoyi.uniapp.service.IVehicleWorkAreasService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import com.ruoyi.common.log.annotation.Log;
|
|
|
+import com.ruoyi.common.log.enums.BusinessType;
|
|
|
+import com.ruoyi.common.security.annotation.RequiresPermissions;
|
|
|
+import com.ruoyi.uniapp.domain.VehicleTasks;
|
|
|
+import com.ruoyi.uniapp.service.IVehicleTasksService;
|
|
|
+import com.ruoyi.common.core.web.controller.BaseController;
|
|
|
+import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
|
+import com.ruoyi.common.core.web.page.TableDataInfo;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 车辆作业Controller
|
|
|
+ *
|
|
|
+ * @author zmj
|
|
|
+ * @date 2025-12-17
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/deviceTasks")
|
|
|
+public class VehicleTasksController extends BaseController
|
|
|
+{
|
|
|
+ @Autowired
|
|
|
+ private IVehicleTasksService vehicleTasksService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IVehicleWorkAreasService vehicleWorkAreasService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询车辆作业列表
|
|
|
+ */
|
|
|
+ @RequiresPermissions("uniapp:vehicleTasks:list")
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo list(VehicleTasks vehicleTasks)
|
|
|
+ {
|
|
|
+ startPage();
|
|
|
+ List<VehicleTasks> list = vehicleTasksService.selectVehicleTasksList(vehicleTasks);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出车辆作业列表
|
|
|
+ */
|
|
|
+ @RequiresPermissions("uniapp:vehicleTasks:export")
|
|
|
+ @Log(title = "车辆作业", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/export")
|
|
|
+ public void export(HttpServletResponse response, VehicleTasks vehicleTasks)
|
|
|
+ {
|
|
|
+ List<VehicleTasks> list = vehicleTasksService.selectVehicleTasksList(vehicleTasks);
|
|
|
+ ExcelUtil<VehicleTasks> util = new ExcelUtil<VehicleTasks>(VehicleTasks.class);
|
|
|
+ util.exportExcel(response, list, "车辆作业数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取车辆作业详细信息
|
|
|
+ */
|
|
|
+ @RequiresPermissions("uniapp:vehicleTasks:query")
|
|
|
+ @GetMapping(value = "/{id}")
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
+ {
|
|
|
+ return success(vehicleTasksService.selectVehicleTasksById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增车辆作业
|
|
|
+ */
|
|
|
+ @RequiresPermissions("uniapp:vehicleTasks:add")
|
|
|
+ @Log(title = "车辆作业", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("/add")
|
|
|
+ public AjaxResult add(@RequestBody DeviceTasksDTO deviceTasksDTO)
|
|
|
+ {
|
|
|
+ //1、新增工作区域
|
|
|
+ VehicleWorkAreas vehicleWorkAreas = new VehicleWorkAreas();
|
|
|
+ vehicleWorkAreas.setFieldId(Long.valueOf(deviceTasksDTO.getFieldId()));
|
|
|
+ vehicleWorkAreas.setAreaName(deviceTasksDTO.getTaskName());
|
|
|
+ vehicleWorkAreas.setUserId(deviceTasksDTO.getUserId());
|
|
|
+ vehicleWorkAreas.setAreaType(deviceTasksDTO.getAreaType());
|
|
|
+ vehicleWorkAreas.setPathWidth(deviceTasksDTO.getPathWidth());
|
|
|
+ vehicleWorkAreas.setWaypoints(deviceTasksDTO.getWaypoints().toString());
|
|
|
+ vehicleWorkAreas.setObstacles(deviceTasksDTO.getObstacles().toString());
|
|
|
+ vehicleWorkAreas.setReturnPoint(deviceTasksDTO.getReturnPoint().toString());
|
|
|
+ vehicleWorkAreasService.insertVehicleWorkAreas(vehicleWorkAreas);
|
|
|
+ //2、新增工作作业
|
|
|
+ VehicleTasks vehicleTasks = new VehicleTasks();
|
|
|
+ vehicleTasks.setTaskName(deviceTasksDTO.getTaskName());
|
|
|
+ vehicleTasks.setDeviceId(Long.valueOf(deviceTasksDTO.getDeviceId()));
|
|
|
+ vehicleTasks.setAreaId(vehicleWorkAreas.getId());
|
|
|
+ return toAjax(vehicleTasksService.insertVehicleTasks(vehicleTasks));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开始作业
|
|
|
+ */
|
|
|
+ @Log(title = "开始作业", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/start/{taskId}")
|
|
|
+ public AjaxResult startWork(@PathVariable("taskId") Long taskId)
|
|
|
+ {
|
|
|
+ VehicleTasks vehicleTasks = new VehicleTasks();
|
|
|
+ vehicleTasks.setId(taskId);
|
|
|
+ vehicleTasks.setTaskStatus(1L); // 设置作业状态为开始
|
|
|
+
|
|
|
+ //TODO:MQ下发开始作业命令
|
|
|
+ return toAjax(vehicleTasksService.updateVehicleTasks(vehicleTasks));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 暂停作业
|
|
|
+ */
|
|
|
+ @Log(title = "暂停作业", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/pause/{taskId}")
|
|
|
+ public AjaxResult pauseWork(@PathVariable("taskId") Long taskId)
|
|
|
+ {
|
|
|
+ VehicleTasks vehicleTasks = new VehicleTasks();
|
|
|
+ vehicleTasks.setId(taskId);
|
|
|
+ vehicleTasks.setTaskStatus(4L); // 设置作业状态为已暂停
|
|
|
+
|
|
|
+ //TODO:MQ下发暂停作业命令
|
|
|
+ return toAjax(vehicleTasksService.updateVehicleTasks(vehicleTasks));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 停止作业
|
|
|
+ */
|
|
|
+ @Log(title = "停止作业", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/stop/{taskId}")
|
|
|
+ public AjaxResult stopWork(@PathVariable("taskId") Long taskId)
|
|
|
+ {
|
|
|
+ VehicleTasks vehicleTasks = new VehicleTasks();
|
|
|
+ vehicleTasks.setId(taskId);
|
|
|
+ vehicleTasks.setTaskStatus(5L); // 设置作业状态为已停止
|
|
|
+
|
|
|
+ //TODO:MQ下发停止作业命令
|
|
|
+ return toAjax(vehicleTasksService.updateVehicleTasks(vehicleTasks));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 召回设备
|
|
|
+ */
|
|
|
+ @Log(title = "召回设备", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/recall/{taskId}")
|
|
|
+ public AjaxResult recallWork(@PathVariable("taskId") Long taskId)
|
|
|
+ {
|
|
|
+ VehicleTasks vehicleTasks = new VehicleTasks();
|
|
|
+ vehicleTasks.setId(taskId);
|
|
|
+ vehicleTasks.setTaskStatus(6L); // 设置作业状态为召回中
|
|
|
+
|
|
|
+ //TODO:MQ下发停止作业命令
|
|
|
+ return toAjax(vehicleTasksService.updateVehicleTasks(vehicleTasks));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除作业任务
|
|
|
+ */
|
|
|
+ @Log(title = "删除作业任务", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/delete/{taskId}")
|
|
|
+ public AjaxResult removeTasks(@PathVariable("taskId") Long taskId)
|
|
|
+ {
|
|
|
+ VehicleTasks vehicleTasks = vehicleTasksService.selectVehicleTasksById(taskId);
|
|
|
+ vehicleWorkAreasService.deleteVehicleWorkAreasById(vehicleTasks.getAreaId());
|
|
|
+ int i = vehicleTasksService.deleteVehicleTasksByIds(new Long[]{taskId});
|
|
|
+ return toAjax(i);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改车辆作业
|
|
|
+ */
|
|
|
+ @RequiresPermissions("uniapp:vehicleTasks:edit")
|
|
|
+ @Log(title = "车辆作业", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping
|
|
|
+ public AjaxResult edit(@RequestBody VehicleTasks vehicleTasks)
|
|
|
+ {
|
|
|
+ return toAjax(vehicleTasksService.updateVehicleTasks(vehicleTasks));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除车辆作业
|
|
|
+ */
|
|
|
+ @RequiresPermissions("uniapp:vehicleTasks:remove")
|
|
|
+ @Log(title = "车辆作业", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
+ {
|
|
|
+ return toAjax(vehicleTasksService.deleteVehicleTasksByIds(ids));
|
|
|
+ }
|
|
|
+}
|