shiwn 3 місяців тому
батько
коміт
a1c37e6a87

+ 30 - 1
src/main/java/com/sw/patroleditor/controller/LocationController.java

@@ -2,6 +2,8 @@ package com.sw.patroleditor.controller;
 
 import com.sw.patroleditor.common.ResultData;
 import com.sw.patroleditor.domain.vo.PointVO;
+import com.sw.patroleditor.domain.vo.TargetVO;
+import com.sw.patroleditor.exception.ErrorCode;
 import com.sw.patroleditor.service.LocationService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -25,6 +27,33 @@ public class LocationController {
     @ApiOperation(value = "保存停靠点")
     @PostMapping("/savePoint")
     public ResultData savePoint(@RequestBody PointVO vo) {
-        return ResultData.success(locationService.savePoint(vo));
+        int flag = locationService.savePoint(vo);
+        if (flag > 0) {
+            return ResultData.success();
+        } else {
+            return ResultData.fail(ErrorCode.FAIL);
+        }
+    }
+
+    @ApiOperation(value = "保存巡检点")
+    @PostMapping("/saveTarget")
+    public ResultData saveTarget(@RequestBody TargetVO vo) {
+        int flag = locationService.saveTarget(vo);
+        if (flag > 0) {
+            return ResultData.success();
+        } else {
+            return ResultData.fail(ErrorCode.FAIL);
+        }
+    }
+
+    @ApiOperation(value = "删除巡检点")
+    @PostMapping("/deleteTarget")
+    public ResultData deleteTarget(@RequestBody Long targetId) {
+        int flag = locationService.deleteTarget(targetId);
+        if (flag > 0) {
+            return ResultData.success();
+        } else {
+            return ResultData.fail(ErrorCode.FAIL);
+        }
     }
 }

+ 2 - 0
src/main/java/com/sw/patroleditor/domain/dto/StrategyDTO.java

@@ -1,5 +1,6 @@
 package com.sw.patroleditor.domain.dto;
 
+import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -10,6 +11,7 @@ import java.io.Serializable;
  * strategy
  */
 @Data
+@TableName("strategy")
 public class StrategyDTO {
     /**
      * 编号

+ 8 - 6
src/main/java/com/sw/patroleditor/domain/dto/TargetDTO.java

@@ -1,5 +1,6 @@
 package com.sw.patroleditor.domain.dto;
 
+import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -10,6 +11,7 @@ import java.io.Serializable;
  * target
  */
 @Data
+@TableName("target")
 public class TargetDTO implements Serializable {
     /**
      * 编号
@@ -34,27 +36,27 @@ public class TargetDTO implements Serializable {
     /**
      * 通用描述信息:区域管理 lv1 id(供电公司id)
      */
-    private Integer info0;
+    private Integer info_0;
 
     /**
      * 通用描述信息:区域管理 lv2 id(变电站id)
      */
-    private Integer info1;
+    private Integer info_1;
 
     /**
      * 通用描述信息:区域管理 lv3 id(间隔/机柜id)
      */
-    private Integer info2;
+    private Integer info_2;
 
     /**
      * 通用描述信息:区域管理 lv4 id(小类设备id)
      */
-    private Integer info3;
+    private Integer info_3;
 
     /**
      * 通用描述信息
      */
-    private Integer info4;
+    private Integer info_4;
 
     /**
      * 通用描述信息
@@ -79,7 +81,7 @@ public class TargetDTO implements Serializable {
     /**
      * 通用描述信息:算法类型 大类编码(1:图像识别 2:红外检测 3:局放检测 4:环境检测 5:声音检测)
      */
-    private Integer info9;
+    private Integer info_9;
 
     /**
      * 通用描述信息

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

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 /**
+ * 标记点
  * Created by shiwn on 2024/8/9 16:08
  */
 @Data

+ 50 - 0
src/main/java/com/sw/patroleditor/domain/vo/TargetVO.java

@@ -0,0 +1,50 @@
+package com.sw.patroleditor.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 巡检点
+ * Created by shiwn on 2024/8/9 16:21
+ */
+@Data
+public class TargetVO {
+    @ApiModelProperty(value = "停靠点id")
+    private Integer pointId;
+
+    @ApiModelProperty(value = "巡检点名称")
+    private String name;
+
+    @ApiModelProperty(value = "数据单位")
+    private String unit;
+
+    @ApiModelProperty(value = "区域id(type1)")
+    private Integer info0;
+
+    @ApiModelProperty(value = "区域id(type2)")
+    private Integer info1;
+
+    @ApiModelProperty(value = "区域id(type3)")
+    private Integer info2;
+
+    @ApiModelProperty(value = "区域id(type4)")
+    private Integer info3;
+
+    @ApiModelProperty(value = "区域id(type5)")
+    private Integer info4;
+
+    @ApiModelProperty(value = "算法类型 大类编码(1:图像识别 2:红外检测 3:局放检测 4:环境检测 5:声音检测)")
+    private Integer info9;
+
+    @ApiModelProperty(value = "目标框选左上角X坐标")
+    private Integer topleftX;
+
+    @ApiModelProperty(value = "目标框选左上角Y坐标")
+    private Integer topleftY;
+
+    @ApiModelProperty(value = "目标框选右下角X坐标")
+    private Integer botrightX;
+
+    @ApiModelProperty(value = "目标框选右下角Y坐标")
+    private Integer botrightY;
+}

+ 5 - 0
src/main/java/com/sw/patroleditor/service/LocationService.java

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

+ 91 - 3
src/main/java/com/sw/patroleditor/service/impl/LocationServiceImpl.java

@@ -4,11 +4,19 @@ 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.TargetDTO;
 import com.sw.patroleditor.domain.dto.ZoominDTO;
 import com.sw.patroleditor.domain.vo.PointVO;
+import com.sw.patroleditor.domain.vo.TargetVO;
+import com.sw.patroleditor.mapper.AimMapper;
 import com.sw.patroleditor.mapper.PointMapper;
+import com.sw.patroleditor.mapper.TargetMapper;
+import com.sw.patroleditor.mapper.ZoominMapper;
 import com.sw.patroleditor.service.LocationService;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.UUID;
@@ -22,6 +30,12 @@ public class LocationServiceImpl implements LocationService {
     private RobotDataCallBack robotDataCallBack;
     @Resource
     private PointMapper pointMapper;
+    @Resource
+    private TargetMapper targetMapper;
+    @Resource
+    private AimMapper aimMapper;
+    @Resource
+    private ZoominMapper zoominMapper;
 
     /**
      * @Description: 保存停靠点
@@ -45,8 +59,82 @@ public class LocationServiceImpl implements LocationService {
      * @Date: 2024/8/9 15:56
      * @Author: shiwn
      */
-    public int saveTarget() {
-        RobotDataModel robotDataModel = robotDataCallBack.getRobotDataModel();
-        return 1;
+    @Override
+    @Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public int saveTarget(TargetVO vo) {
+        try {
+            RobotDataModel robotDataModel = robotDataCallBack.getRobotDataModel();
+            Long id = System.currentTimeMillis();
+            //  巡检点数据TargetDTO
+            TargetDTO targetDTO = new TargetDTO();
+            targetDTO.setId(id);
+            targetDTO.setPointId(vo.getPointId());
+            targetDTO.setName(vo.getName());
+            targetDTO.setInfo_0(vo.getInfo0());
+            targetDTO.setInfo_1(vo.getInfo1());
+            targetDTO.setInfo_2(vo.getInfo2());
+            targetDTO.setInfo_3(vo.getInfo3());
+            targetDTO.setInfo_4(vo.getInfo4());
+            targetDTO.setInfo_9(vo.getInfo9());
+            targetMapper.insert(targetDTO);
+
+            //  巡检目标瞄准控制参数表AimDTO
+            AimDTO aimDTO = new AimDTO();
+            aimDTO.setId(id);
+            aimDTO.setRoll(robotDataModel.getRoll());
+            aimDTO.setPitch(robotDataModel.getPitch());
+            aimDTO.setYaw(robotDataModel.getYaw());
+            aimDTO.setHeight(robotDataModel.getPosZ());
+            aimDTO.setFocus(robotDataModel.getFocalDistance());
+            aimDTO.setRatio(robotDataModel.getRatio());
+            aimDTO.setAperture(robotDataModel.getDiaphragm());
+            aimDTO.setTopleftX(vo.getTopleftX());
+            aimDTO.setTopleftY(vo.getTopleftY());
+            aimDTO.setBotrightX(vo.getBotrightX());
+            aimDTO.setBotrightY(vo.getBotrightY());
+            aimMapper.insert(aimDTO);
+
+            //  巡检目标抵近控制参数表ZoominDTO
+            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(vo.getTopleftX());
+            zoominDTO.setTopleftY(vo.getTopleftY());
+            zoominDTO.setBotrightX(vo.getBotrightX());
+            zoominDTO.setBotrightY(vo.getBotrightY());
+            zoominMapper.insert(zoominDTO);
+
+            //  返回
+            return 1;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 0;
+        }
+    }
+
+    /**
+     * @Description: 删除巡检点
+     * @Date: 2024/8/9 17:09
+     * @Author: shiwn
+     * @Param: targetId:
+     * @Return:
+     */
+    @Override
+    @Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public int deleteTarget(Long targetId) {
+        try {
+            targetMapper.deleteById(targetId);
+            aimMapper.deleteById(targetId);
+            zoominMapper.deleteById(targetId);
+            return 1;
+        } catch (Exception e) {
+            e.getMessage();
+            return 0;
+        }
     }
 }