|
@@ -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;
|
|
|
+ }
|
|
|
}
|
|
|
}
|