Kaynağa Gözat

保存停靠点

shiwn 3 ay önce
ebeveyn
işleme
15a2a63750

+ 6 - 4
src/main/java/com/sw/patroleditor/controller/LocationController.java

@@ -1,10 +1,12 @@
 package com.sw.patroleditor.controller;
 
 import com.sw.patroleditor.common.ResultData;
+import com.sw.patroleditor.domain.vo.PointVO;
 import com.sw.patroleditor.service.LocationService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -20,9 +22,9 @@ public class LocationController {
     @Resource
     private LocationService locationService;
 
-    @ApiOperation(value = "保存点")
-    @PostMapping("/save")
-    public ResultData save() {
-        return ResultData.success(locationService.save());
+    @ApiOperation(value = "保存停靠点")
+    @PostMapping("/savePoint")
+    public ResultData savePoint(@RequestBody PointVO vo) {
+        return ResultData.success(locationService.savePoint(vo));
     }
 }

+ 4 - 1
src/main/java/com/sw/patroleditor/domain/dto/PointDTO.java

@@ -1,5 +1,7 @@
 package com.sw.patroleditor.domain.dto;
 
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
@@ -16,6 +18,7 @@ public class PointDTO{
     /**
      * 编号
      */
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**
@@ -24,7 +27,7 @@ public class PointDTO{
     private String uuid;
 
     /**
-     * 种类:起点、充电点、交点、停靠点
+     * 种类:0-起点、1-充电点、交点、3-停靠点
      */
     private Integer type;
 

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

@@ -0,0 +1,16 @@
+package com.sw.patroleditor.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by shiwn on 2024/8/9 16:08
+ */
+@Data
+public class PointVO {
+    @ApiModelProperty(value = "备注")
+    private String note;
+
+    @ApiModelProperty(value = "种类:0-起点、1-充电点、2-交点、3-停靠点")
+    private Integer type;
+}

+ 3 - 1
src/main/java/com/sw/patroleditor/service/LocationService.java

@@ -1,8 +1,10 @@
 package com.sw.patroleditor.service;
 
+import com.sw.patroleditor.domain.vo.PointVO;
+
 /**
  * Created by shiwn on 2024/7/26 15:07
  */
 public interface LocationService {
-    int save();
+    int savePoint(PointVO vo);
 }

+ 23 - 28
src/main/java/com/sw/patroleditor/service/impl/LocationServiceImpl.java

@@ -3,11 +3,15 @@ package com.sw.patroleditor.service.impl;
 import com.sw.patroleditor.component.rosBridge.RobotDataCallBack;
 import com.sw.patroleditor.component.rosBridge.RobotDataModel;
 import com.sw.patroleditor.domain.dto.AimDTO;
+import com.sw.patroleditor.domain.dto.PointDTO;
 import com.sw.patroleditor.domain.dto.ZoominDTO;
+import com.sw.patroleditor.domain.vo.PointVO;
+import com.sw.patroleditor.mapper.PointMapper;
 import com.sw.patroleditor.service.LocationService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.UUID;
 
 /**
  * Created by shiwn on 2024/7/26 15:08
@@ -16,42 +20,33 @@ import javax.annotation.Resource;
 public class LocationServiceImpl implements LocationService {
     @Resource
     private RobotDataCallBack robotDataCallBack;
+    @Resource
+    private PointMapper pointMapper;
 
     /**
-     * @Description: 保存点
+     * @Description: 保存停靠
      * @Date: 2024/7/26 15:09
      * @Author: shiwn
      */
     @Override
-    public int save() {
+    public int savePoint(PointVO vo) {
         RobotDataModel robotDataModel = robotDataCallBack.getRobotDataModel();
-        Long id = System.currentTimeMillis();
-        AimDTO aimDTO = new AimDTO();
-        aimDTO.setId(id);
-        aimDTO.setRoll(robotDataModel.getRoll());
-        aimDTO.setPitch(robotDataModel.getPitch());
-        aimDTO.setYaw(robotDataModel.getYaw());
-//        aimDTO.setHeight();
-        aimDTO.setFocus(robotDataModel.getFocalDistance());
-        aimDTO.setRatio(robotDataModel.getRatio());
-        aimDTO.setAperture(robotDataModel.getDiaphragm());
-//        aimDTO.setTopleftX();
-//        aimDTO.setTopleftY();
-//        aimDTO.setBotrightX();
-//        aimDTO.setBotrightY();
+        PointDTO dto = new PointDTO();
+        dto.setUuid(UUID.randomUUID().toString());
+        dto.setType(vo.getType());
+        dto.setNote(vo.getNote());
+        dto.setAbsolutePosX(robotDataModel.getPosX());
+        dto.setAbsolutePosY(robotDataModel.getPosY());
+        return pointMapper.insert(dto);
+    }
 
-        ZoominDTO zoominDTO = new ZoominDTO();
-        zoominDTO.setId(id);
-        zoominDTO.setRoll(robotDataModel.getRoll());
-        zoominDTO.setPitch(robotDataModel.getPitch());
-        zoominDTO.setYaw(robotDataModel.getYaw());
-        zoominDTO.setFocus(robotDataModel.getFocalDistance());
-        zoominDTO.setRatio(robotDataModel.getRatio());
-        zoominDTO.setAperture(robotDataModel.getDiaphragm());
-//        zoominDTO.setTopleftX();
-//        zoominDTO.setTopleftY();
-//        zoominDTO.setBotrightX();
-//        zoominDTO.setBotrightY();
+    /**
+     * @Description: 保存巡检点
+     * @Date: 2024/8/9 15:56
+     * @Author: shiwn
+     */
+    public int saveTarget() {
+        RobotDataModel robotDataModel = robotDataCallBack.getRobotDataModel();
         return 1;
     }
 }