Browse Source

机器人控制

shiwn 4 months ago
parent
commit
be48487954

+ 66 - 0
src/main/java/com/sw/patroleditor/controller/RobotCtrlController.java

@@ -0,0 +1,66 @@
+package com.sw.patroleditor.controller;
+
+import com.sw.patroleditor.common.ResultData;
+import com.sw.patroleditor.controller.api.RobotCtrlApi;
+import com.sw.patroleditor.domain.vo.RobotModelVO;
+import com.sw.patroleditor.domain.vo.RobotMoveCtrlVO;
+import com.sw.patroleditor.domain.vo.RobotSpecialCtrlVO;
+import com.sw.patroleditor.domain.vo.RobotToolCtrlVO;
+import com.sw.patroleditor.exception.ErrorCode;
+import com.sw.patroleditor.service.RobotCtrlService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+/**
+ * 机器人控制 controller
+ * Created by shiwn on 2021/5/12 10:28
+ */
+@RestController
+@RequestMapping("robotCtrl")
+public class RobotCtrlController implements RobotCtrlApi {
+    @Autowired
+    RobotCtrlService robotCtrlService;
+
+    @Override
+    @PostMapping("/specialCtrl")
+    public ResultData specialCtrl(@RequestBody RobotSpecialCtrlVO vo) {
+        boolean flag = robotCtrlService.specialCtrl(vo);
+        if (flag) {
+            return ResultData.success();
+        }
+        return ResultData.fail(ErrorCode.OPERATION_FAILED);
+    }
+
+
+    @Override
+    @PostMapping("/robotMoveCtrl")
+    public ResultData robotMoveCtrl(@RequestBody RobotMoveCtrlVO vo) {
+        boolean flag = robotCtrlService.robotMoveCtrl(vo);
+        if (flag) {
+            return ResultData.success();
+        }
+        return ResultData.fail(ErrorCode.OPERATION_FAILED);
+    }
+
+    @Override
+    @PostMapping("/toolCtrl")
+    public ResultData toolCtrl(@RequestBody RobotToolCtrlVO vo) {
+        boolean flag = robotCtrlService.toolCtrl(vo);
+        if (flag) {
+            return ResultData.success();
+        }
+        return ResultData.fail(ErrorCode.OPERATION_FAILED);
+    }
+
+    @Override
+    @PostMapping("/modelChange")
+    public ResultData modelChange(@RequestBody RobotModelVO vo) {
+        boolean flag = robotCtrlService.modelChange(vo);
+        if (flag) {
+            return ResultData.success();
+        }
+        return ResultData.fail(ErrorCode.OPERATION_FAILED);
+    }
+}

+ 46 - 0
src/main/java/com/sw/patroleditor/controller/api/RobotCtrlApi.java

@@ -0,0 +1,46 @@
+package com.sw.patroleditor.controller.api;
+
+import com.sw.patroleditor.common.ResultData;
+import com.sw.patroleditor.domain.vo.RobotModelVO;
+import com.sw.patroleditor.domain.vo.RobotMoveCtrlVO;
+import com.sw.patroleditor.domain.vo.RobotSpecialCtrlVO;
+import com.sw.patroleditor.domain.vo.RobotToolCtrlVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.Map;
+
+/**
+ * 机器人控制 api
+ * Created by shiwn on 2021/5/12 10:27
+ */
+@Api(tags = {"机器人控制接口"})
+public interface RobotCtrlApi {
+
+    @ApiOperation("特殊状态控制")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "vo", value = "数据", dataType = "RobotSpecialCtrlVO", required = true)
+    })
+    ResultData specialCtrl(@RequestBody RobotSpecialCtrlVO vo);
+
+    @ApiOperation("机器人移动控制")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "vo", value = "数据", dataType = "RobotMoveCtrlVO", required = true)
+    })
+    ResultData robotMoveCtrl(@RequestBody RobotMoveCtrlVO vo);
+
+    @ApiOperation("补光灯、雨刷控制")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "vo", value = "数据", dataType = "RobotToolCtrlVO", required = true)
+    })
+    ResultData toolCtrl(@RequestBody RobotToolCtrlVO vo);
+
+    @ApiOperation("机器人模式切换")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "vo", value = "数据", dataType = "RobotModelVO", required = true)
+    })
+    ResultData modelChange(@RequestBody RobotModelVO vo);
+}

+ 16 - 0
src/main/java/com/sw/patroleditor/domain/vo/RobotModelVO.java

@@ -0,0 +1,16 @@
+package com.sw.patroleditor.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 机器人模式切换VO
+ * Created by shiwn on 2021/8/10 16:15
+ */
+@Data
+public class RobotModelVO {
+    @ApiModelProperty(value = "机器人ip")
+    private String robotIp;
+    @ApiModelProperty(value = "模式,3-自动巡检模式,4-手动模式")
+    private Integer model;
+}

+ 24 - 0
src/main/java/com/sw/patroleditor/domain/vo/RobotMoveCtrlVO.java

@@ -0,0 +1,24 @@
+package com.sw.patroleditor.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 机器人、云台移动VO
+ * Created by shiwn on 2021/7/8 13:56
+ */
+@Data
+public class RobotMoveCtrlVO {
+    @ApiModelProperty(value = "机器人ip")
+    private String robotIp;
+    @ApiModelProperty(value = "控制方式,1-手动控制,2-定点移动")
+    private int mode = 1;
+    @ApiModelProperty(value = "x坐标")
+    private int x;
+    @ApiModelProperty(value = "y坐标")
+    private int y;
+    @ApiModelProperty(value = "z坐标")
+    private int z;
+    @ApiModelProperty(value = "移动速度")
+    private int speed;
+}

+ 16 - 0
src/main/java/com/sw/patroleditor/domain/vo/RobotSpecialCtrlVO.java

@@ -0,0 +1,16 @@
+package com.sw.patroleditor.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 机器人特殊控制VO
+ * Created by shiwn on 2021/8/6 11:17
+ */
+@Data
+public class RobotSpecialCtrlVO {
+    @ApiModelProperty(value = "机器人ip")
+    private String robotIp;
+    @ApiModelProperty(value = "命令,shutdown-关机,reboot-重启,stop-急停,release-取消急停,goback-一键返航,charge-强制充电")
+    private String type;
+}

+ 18 - 0
src/main/java/com/sw/patroleditor/domain/vo/RobotToolCtrlVO.java

@@ -0,0 +1,18 @@
+package com.sw.patroleditor.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 机器人工具控制
+ * Created by shiwn on 2021/7/8 14:10
+ */
+@Data
+public class RobotToolCtrlVO {
+    @ApiModelProperty(value = "机器人ip")
+    private String robotIp;
+    @ApiModelProperty(value = "1-雨刷,2-补光灯")
+    private Integer type;
+    @ApiModelProperty(value = "状态:0-关闭,1-打开")
+    private Boolean opstatus;
+}

+ 2 - 0
src/main/java/com/sw/patroleditor/exception/ErrorCode.java

@@ -9,6 +9,8 @@ public enum ErrorCode {
 
 
     FAIL(1,"失败"),
     FAIL(1,"失败"),
 
 
+    OPERATION_FAILED(1, "操作失败"),
+
     //    系统用户相关
     //    系统用户相关
     ACCOUNT_NOT_EXIST(1, "用户不存在"),
     ACCOUNT_NOT_EXIST(1, "用户不存在"),
 
 

+ 25 - 0
src/main/java/com/sw/patroleditor/service/RobotCtrlService.java

@@ -0,0 +1,25 @@
+package com.sw.patroleditor.service;
+
+import com.sw.patroleditor.domain.vo.RobotModelVO;
+import com.sw.patroleditor.domain.vo.RobotMoveCtrlVO;
+import com.sw.patroleditor.domain.vo.RobotSpecialCtrlVO;
+import com.sw.patroleditor.domain.vo.RobotToolCtrlVO;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+/**
+ * Created by shiwn on 2024/7/2 13:55
+ */
+@Component
+public interface RobotCtrlService {
+
+    boolean specialCtrl(RobotSpecialCtrlVO vo);
+
+    boolean robotMoveCtrl(RobotMoveCtrlVO vo);
+
+    boolean toolCtrl(RobotToolCtrlVO vo);
+
+    boolean modelChange(RobotModelVO vo);
+
+}

+ 64 - 0
src/main/java/com/sw/patroleditor/service/impl/RobotCtrlServiceImpl.java

@@ -0,0 +1,64 @@
+package com.sw.patroleditor.service.impl;
+
+import com.sw.patroleditor.domain.vo.RobotModelVO;
+import com.sw.patroleditor.domain.vo.RobotMoveCtrlVO;
+import com.sw.patroleditor.domain.vo.RobotSpecialCtrlVO;
+import com.sw.patroleditor.domain.vo.RobotToolCtrlVO;
+import com.sw.patroleditor.service.RobotCtrlService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by shiwn on 2024/7/2 14:05
+ */
+@Service
+public class RobotCtrlServiceImpl implements RobotCtrlService {
+
+    /**
+     * @Description: 机器人特殊状态控制
+     * @Date: 2021/8/6 11:22
+     * @Author: shiwn
+     * @Param: [vo]
+     * @Return:
+     */
+    @Override
+    public boolean specialCtrl(RobotSpecialCtrlVO vo) {
+        return false;
+    }
+
+    /**
+     * @Description: 机器人移动控制
+     * @Date: 2021/7/8 13:57
+     * @Author: shiwn
+     * @Param: [vo]
+     * @Return:
+     */
+    @Override
+    public boolean robotMoveCtrl(RobotMoveCtrlVO vo) {
+        return false;
+    }
+
+    /**
+     * @Description: 补光灯、雨刷控制
+     * @Date: 2021/7/8 14:04
+     * @Author: shiwn
+     * @Param: [openStatus]
+     * @Return:
+     */
+    @Override
+    public boolean toolCtrl(RobotToolCtrlVO vo) {
+        return false;
+    }
+
+    /**
+     * @Description: 模式切换
+     * @Date: 2021/8/10 16:18
+     * @Author: shiwn
+     * @Param: [vo]
+     * @Return:
+     */
+    @Override
+    public boolean modelChange(RobotModelVO vo) {
+        return false;
+    }
+}