fix:修复增加控制层BaseException处理
This commit is contained in:
parent
f9babad49d
commit
d957404beb
|
|
@ -60,11 +60,12 @@ public class AirlineFileGroupInfoController extends BaseController {
|
|||
* <p>
|
||||
* kmz类似zip,一般情况下内部包含kml和wpml两个文件
|
||||
*
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
@PostMapping("/parseAndUpload")
|
||||
@Operation(summary = " kmz航线文件,并转换成waypoint上传 ,仅仅返航URL")
|
||||
public AjaxResult parseAndUpload(@RequestParam("file") MultipartFile file, Long groupId) throws IOException {
|
||||
public AjaxResult parseAndUpload(@RequestParam("file") MultipartFile file, Long groupId) throws BaseException {
|
||||
AirlineFileDTO dto = iAirlineFileService.parseAndUplload(file);
|
||||
AirlineFileDTO result = iAirlineFileService.save(dto);
|
||||
AirlineFileGroupInfoDTO infoDTO = new AirlineFileGroupInfoDTO();
|
||||
|
|
@ -81,13 +82,16 @@ public class AirlineFileGroupInfoController extends BaseController {
|
|||
*/
|
||||
@PostMapping()
|
||||
@Operation(summary = "在当前分组下添加初始航线,必须上传分组ID")
|
||||
public AjaxResult add(@RequestBody AirlineFileGroupInfoVO vo) throws IOException {
|
||||
public AjaxResult add(@RequestBody AirlineFileGroupInfoVO vo) throws BaseException {
|
||||
if (vo.getGroupId() == null) {
|
||||
throw new BaseException("分组ID不能为空");
|
||||
}
|
||||
AirlineFileGroupInfoDTO dto = AirlineFileGroupInfoControllerConvert.toDTO(vo);
|
||||
AirlineFileGroupInfoDTO result = iAirlineFileGroupInfoService.save(dto);
|
||||
return success(AirlineFileGroupInfoControllerConvert.toVO(result));
|
||||
Long result = iAirlineFileGroupInfoService.save(dto);
|
||||
if (result > 0) {
|
||||
return success(result);
|
||||
}
|
||||
throw new BaseException("新增失败");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,101 @@
|
|||
package com.ruoyi.airline.controller.convert;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ruoyi.airline.api.domain.AirLinePointVO;
|
||||
import com.ruoyi.airline.service.dto.AirLinePointDTO;
|
||||
|
||||
/**
|
||||
* 航线航点Controller转换类
|
||||
* 用于Controller层VO和Service层DTO之间的转换
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-01-26
|
||||
*/
|
||||
public class AirLinePointControllerConvert {
|
||||
|
||||
/**
|
||||
* 将Service DTO转换为Controller VO
|
||||
*
|
||||
* @param dto Service DTO
|
||||
* @return Controller VO
|
||||
*/
|
||||
public static AirLinePointVO toVO(AirLinePointDTO dto) {
|
||||
if (dto == null) {
|
||||
return null;
|
||||
}
|
||||
AirLinePointVO vo = new AirLinePointVO();
|
||||
vo.setId(dto.getId());
|
||||
vo.setCommand(dto.getCommand());
|
||||
vo.setLat(dto.getLat());
|
||||
vo.setLon(dto.getLon());
|
||||
vo.setAlt(dto.getAlt());
|
||||
vo.setLoiterTime(dto.getLoiterTime());
|
||||
vo.setCameraPitch(dto.getCameraPitch());
|
||||
vo.setCameraRoll(dto.getCameraRoll());
|
||||
vo.setCameraYaw(dto.getCameraYaw());
|
||||
vo.setSessionControl(dto.getSessionControl());
|
||||
vo.setShootCommand(dto.getShootCommand());
|
||||
vo.setZoomAbsolute(dto.getZoomAbsolute());
|
||||
vo.setRotateDirection(dto.getRotateDirection());
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Controller VO转换为Service DTO
|
||||
*
|
||||
* @param vo Controller VO
|
||||
* @return Service DTO
|
||||
*/
|
||||
public static AirLinePointDTO toDTO(AirLinePointVO vo) {
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
AirLinePointDTO dto = new AirLinePointDTO();
|
||||
dto.setId(vo.getId());
|
||||
dto.setCommand(vo.getCommand());
|
||||
dto.setLat(vo.getLat());
|
||||
dto.setLon(vo.getLon());
|
||||
dto.setAlt(vo.getAlt());
|
||||
dto.setLoiterTime(vo.getLoiterTime());
|
||||
dto.setCameraPitch(vo.getCameraPitch());
|
||||
dto.setCameraRoll(vo.getCameraRoll());
|
||||
dto.setCameraYaw(vo.getCameraYaw());
|
||||
dto.setSessionControl(vo.getSessionControl());
|
||||
dto.setShootCommand(vo.getShootCommand());
|
||||
dto.setZoomAbsolute(vo.getZoomAbsolute());
|
||||
dto.setRotateDirection(vo.getRotateDirection());
|
||||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Service DTO列表转换为Controller VO列表
|
||||
*
|
||||
* @param dtoList Service DTO列表
|
||||
* @return Controller VO列表
|
||||
*/
|
||||
public static List<AirLinePointVO> toVOList(List<AirLinePointDTO> dtoList) {
|
||||
if (dtoList == null || dtoList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return dtoList.stream()
|
||||
.map(AirLinePointControllerConvert::toVO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Controller VO列表转换为Service DTO列表
|
||||
*
|
||||
* @param voList Controller VO列表
|
||||
* @return Service DTO列表
|
||||
*/
|
||||
public static List<AirLinePointDTO> toDTOList(List<AirLinePointVO> voList) {
|
||||
if (voList == null || voList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return voList.stream()
|
||||
.map(AirLinePointControllerConvert::toDTO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
@ -26,11 +26,12 @@ public class AirlineFileControllerConvert {
|
|||
return null;
|
||||
}
|
||||
AirlineFileVO vo = new AirlineFileVO();
|
||||
vo.setName(dto.getName());
|
||||
vo.setId(dto.getId());
|
||||
vo.setFileName(dto.getFileName());
|
||||
vo.setFileUrl(dto.getFileUrl());
|
||||
vo.setType(dto.getType());
|
||||
vo.setLinePointDtoList(dto.getLinePointDtoList());
|
||||
vo.setLinePointVOList(AirLinePointControllerConvert.toVOList(dto.getLinePointDtoList()));
|
||||
vo.setStatus(dto.getStatus());
|
||||
vo.setDjiRthAltitude(dto.getDjiRthAltitude());
|
||||
return vo;
|
||||
|
|
@ -48,10 +49,11 @@ public class AirlineFileControllerConvert {
|
|||
}
|
||||
AirlineFileDTO dto = new AirlineFileDTO();
|
||||
dto.setId(vo.getId());
|
||||
dto.setName(vo.getName());
|
||||
dto.setFileName(vo.getFileName());
|
||||
dto.setFileUrl(vo.getFileUrl());
|
||||
dto.setType(vo.getType());
|
||||
dto.setLinePointDtoList(vo.getLinePointDtoList());
|
||||
dto.setLinePointDtoList(AirLinePointControllerConvert.toDTOList(vo.getLinePointVOList()));
|
||||
dto.setStatus(vo.getStatus());
|
||||
dto.setDjiRthAltitude(vo.getDjiRthAltitude());
|
||||
return dto;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.ruoyi.airline.controller.convert;
|
|||
|
||||
import com.ruoyi.airline.api.domain.AirlineFileGroupInfoVO;
|
||||
import com.ruoyi.airline.api.domain.AirlineFileGroupVO;
|
||||
import com.ruoyi.airline.service.convert.AirlineFileServiceConvert;
|
||||
import com.ruoyi.airline.service.dto.AirlineFileGroupDTO;
|
||||
import com.ruoyi.airline.service.dto.AirlineFileGroupInfoDTO;
|
||||
|
||||
|
|
@ -33,6 +34,7 @@ public class AirlineFileGroupInfoControllerConvert {
|
|||
vo.setGroupId(dto.getGroupId());
|
||||
vo.setCreateBy(dto.getCreateBy());
|
||||
vo.setCreateTime(dto.getCreateTime());
|
||||
|
||||
vo.setUpdateBy(dto.getUpdateBy());
|
||||
vo.setUpdateTime(dto.getUpdateTime());
|
||||
vo.setRemark(dto.getRemark());
|
||||
|
|
@ -57,6 +59,7 @@ public class AirlineFileGroupInfoControllerConvert {
|
|||
dto.setUpdateBy(vo.getUpdateBy());
|
||||
dto.setUpdateTime(vo.getUpdateTime());
|
||||
dto.setRemark(vo.getRemark());
|
||||
dto.setAirlineFileDTO(AirlineFileControllerConvert.toDTO(vo.getAirlineFileVO()));
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,5 +16,5 @@ public interface IAirlineFileDomain {
|
|||
|
||||
List<AirlineFile> selectFileListByIds(List<Long> ids);
|
||||
|
||||
AirlineFile save(AirlineFile model);
|
||||
Long save(AirlineFile model);
|
||||
}
|
||||
|
|
@ -19,7 +19,16 @@ public interface IAirlineFileGroupInfoDomain {
|
|||
*
|
||||
* @param dto
|
||||
*/
|
||||
int deleteGroupInfo(AirlineFileGroupInfo dto);
|
||||
Long deleteGroupInfo(AirlineFileGroupInfo dto);
|
||||
|
||||
AirlineFileGroupInfo save(AirlineFileGroupInfo model);
|
||||
Long save(AirlineFileGroupInfo model);
|
||||
|
||||
/**
|
||||
* 检查是否存在相同的groupId和airlineId
|
||||
*
|
||||
* @param groupId 分组ID
|
||||
* @param airlineId 航线ID
|
||||
* @return 是否存在
|
||||
*/
|
||||
boolean existsByGroupIdAndAirlineId(Long groupId, Long airlineId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public class AirlineFileDomainConvert {
|
|||
}
|
||||
AirlineFileEntity entity = new AirlineFileEntity();
|
||||
entity.setId(model.getId());
|
||||
entity.setName(model.getName());
|
||||
entity.setFileName(model.getFileName());
|
||||
entity.setFileUrl(model.getFileUrl());
|
||||
entity.setType(model.getType());
|
||||
|
|
@ -51,6 +52,7 @@ public class AirlineFileDomainConvert {
|
|||
}
|
||||
AirlineFile model = new AirlineFile();
|
||||
model.setId(entity.getId());
|
||||
model.setName(entity.getName());
|
||||
model.setFileName(entity.getFileName());
|
||||
model.setFileUrl(entity.getFileUrl());
|
||||
model.setType(entity.getType());
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ public class AirlineFileDomainImpl implements IAirlineFileDomain {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AirlineFile save(AirlineFile model) {
|
||||
public Long save(AirlineFile model) {
|
||||
AirlineFileEntity entity = AirlineFileDomainConvert.toEntity(model);
|
||||
return AirlineFileDomainConvert.toModel(airlineFileMapper.save(entity));
|
||||
return airlineFileMapper.save(entity);
|
||||
}
|
||||
}
|
||||
|
|
@ -32,15 +32,25 @@ public class AirlineFileGroupInfoDomainImpl implements IAirlineFileGroupInfoDoma
|
|||
}
|
||||
|
||||
@Override
|
||||
public int deleteGroupInfo(AirlineFileGroupInfo model) {
|
||||
public Long deleteGroupInfo(AirlineFileGroupInfo model) {
|
||||
model.setDelFlag(1L);
|
||||
AirlineFileGroupInfoEntity Entity = AirlineFileGroupInfoDomainConvert.toEntity(model);
|
||||
return airlineFileGroupInfoMapper.deleteGroupInfo(Entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AirlineFileGroupInfo save(AirlineFileGroupInfo model) {
|
||||
public Long save(AirlineFileGroupInfo model) {
|
||||
AirlineFileGroupInfoEntity Entity = AirlineFileGroupInfoDomainConvert.toEntity(model);
|
||||
return airlineFileGroupInfoMapper.save(Entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existsByGroupIdAndAirlineId(Long groupId, Long airlineId) {
|
||||
AirlineFileGroupInfo model = new AirlineFileGroupInfo();
|
||||
model.setGroupId(groupId);
|
||||
model.setAirlineId(airlineId);
|
||||
AirlineFileGroupInfoEntity entity = AirlineFileGroupInfoDomainConvert.toEntity(model);
|
||||
int count = airlineFileGroupInfoMapper.countByGroupIdAndAirlineId(entity);
|
||||
return count > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,78 @@
|
|||
package com.ruoyi.airline.domain.model;
|
||||
/**
|
||||
* 航线航点VO
|
||||
*
|
||||
* @author 拓恒
|
||||
* @date 2026-01-17
|
||||
*/
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class AirLinePoint implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 动作id
|
||||
*/
|
||||
private Integer command;
|
||||
/**
|
||||
* 经纬度 +-180
|
||||
*/
|
||||
private String lat;
|
||||
/**
|
||||
* 经纬度 +-90
|
||||
*/
|
||||
private String lon;
|
||||
|
||||
/**
|
||||
* 高度
|
||||
*/
|
||||
private Integer alt;
|
||||
|
||||
/**
|
||||
* 悬停时间s
|
||||
*/
|
||||
private String loiterTime;
|
||||
|
||||
/**
|
||||
* 相机俯仰角
|
||||
*/
|
||||
private String cameraPitch;
|
||||
|
||||
/**
|
||||
* 相机滚动角
|
||||
*/
|
||||
private String cameraRoll;
|
||||
|
||||
/**
|
||||
* 相机偏航角
|
||||
*/
|
||||
private String cameraYaw;
|
||||
|
||||
/**
|
||||
* 挂载控制 1 相机
|
||||
*/
|
||||
private Integer sessionControl;
|
||||
/**
|
||||
* 相机指令 1 拍照
|
||||
*/
|
||||
private Integer shootCommand;
|
||||
|
||||
/**
|
||||
* 绝对变焦 目前 1-10
|
||||
*/
|
||||
private Integer zoomAbsolute;
|
||||
|
||||
/***
|
||||
* 转动方向 -1逆时针 1相对机场方向 (硬件定义的)
|
||||
*/
|
||||
private Integer rotateDirection;
|
||||
}
|
||||
|
|
@ -19,7 +19,10 @@ public class AirlineFile {
|
|||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 航线名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
|
|
@ -56,7 +59,7 @@ public class AirlineFile {
|
|||
/**
|
||||
* 航线点列表
|
||||
*/
|
||||
private List<AirLinePointVO> linePointDtoList;
|
||||
private List<AirLinePoint> linePointDtoList;
|
||||
|
||||
/**
|
||||
* 数据来源
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.ruoyi.airline.domain.model;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.web.domain.ExBaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
|
@ -29,6 +28,7 @@ public class AirlineFileGroupInfo extends ExBaseEntity {
|
|||
*/
|
||||
private Long airlineId;
|
||||
|
||||
private AirlineFile airlineFile;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.ruoyi.airline.domain.uitl;
|
|||
|
||||
import com.ruoyi.airline.api.domain.AirLinePointVO;
|
||||
import com.ruoyi.airline.domain.model.kml.*;
|
||||
import com.ruoyi.airline.service.dto.AirLinePointDTO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
|
@ -27,7 +28,7 @@ public class WayPointUitls {
|
|||
StringBuilder waypointBuilder = new StringBuilder("QGC WPL 110\n");
|
||||
// 重置全局id计数器
|
||||
//定义waypoint的航点对象集合备用
|
||||
List<AirLinePointVO> linePoints = new ArrayList<>();
|
||||
List<AirLinePointDTO> linePoints = new ArrayList<>();
|
||||
//m3和m4TD的机型可以从missionConfig获取部分基础数据
|
||||
KmlMissionConfig missionConfig = kmlInfo.getDocument().getKmlMissionConfig();
|
||||
//其他场景下都可以从missionConfig 拿航点和动作集合
|
||||
|
|
@ -67,7 +68,7 @@ public class WayPointUitls {
|
|||
String[] coords = cleanCoords.split(",");
|
||||
|
||||
// 基础航点(安全点22和结束点20之间的其他16普通航点)
|
||||
AirLinePointVO waypoint = buildPoint(
|
||||
AirLinePointDTO waypoint = buildPoint(
|
||||
16,
|
||||
coords[1], coords[0],
|
||||
(int) Float.parseFloat(placeMark.getHeight()),
|
||||
|
|
@ -98,7 +99,7 @@ public class WayPointUitls {
|
|||
|
||||
// 5. 生成Waypoints文件内容
|
||||
for (int i = 0; i < linePoints.size(); i++) {
|
||||
AirLinePointVO point = linePoints.get(i);
|
||||
AirLinePointDTO point = linePoints.get(i);
|
||||
waypointBuilder.append(formatWaypointLine(point, i)).append("\n");
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +108,7 @@ public class WayPointUitls {
|
|||
}
|
||||
|
||||
// 格式化航点行(直接使用DTO字段)
|
||||
public static String formatWaypointLine(AirLinePointVO point, Integer index) {
|
||||
public static String formatWaypointLine(AirLinePointDTO point, Integer index) {
|
||||
switch (point.getCommand()) {
|
||||
case 16:
|
||||
if (index == 0) {
|
||||
|
|
@ -167,7 +168,7 @@ public class WayPointUitls {
|
|||
}
|
||||
|
||||
// 动作解析逻辑
|
||||
public static void processActions(KmlAction action, List<AirLinePointVO> linePoints) {
|
||||
public static void processActions(KmlAction action, List<AirLinePointDTO> linePoints) {
|
||||
|
||||
//kmz航线的动作code
|
||||
String actionType = action.getActionActuatorFunc();
|
||||
|
|
@ -277,10 +278,10 @@ public class WayPointUitls {
|
|||
|
||||
|
||||
//构建waypoint航点
|
||||
public static AirLinePointVO buildPoint(int command, String lat, String lon, int alt,
|
||||
public static AirLinePointDTO buildPoint(int command, String lat, String lon, int alt,
|
||||
String loiterTime, String cameraPitch, String cameraRoll, String cameraYaw,
|
||||
int sessionControl, int zoomAbsolute, int rotateDirection) {
|
||||
AirLinePointVO point = new AirLinePointVO();
|
||||
AirLinePointDTO point = new AirLinePointDTO();
|
||||
point.setCommand(command);
|
||||
point.setLat(lat);
|
||||
point.setLon(lon);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,15 @@ public interface AirlineFileGroupInfoMapper {
|
|||
|
||||
List<AirlineFileGroupInfoEntity> selectGroupList(AirlineFileGroupInfoEntity entity);
|
||||
|
||||
int deleteGroupInfo(AirlineFileGroupInfoEntity entity);
|
||||
Long deleteGroupInfo(AirlineFileGroupInfoEntity entity);
|
||||
|
||||
AirlineFileGroupInfo save(AirlineFileGroupInfoEntity entity);
|
||||
Long save(AirlineFileGroupInfoEntity entity);
|
||||
|
||||
/**
|
||||
* 检查是否存在相同的groupId和airlineId
|
||||
*
|
||||
* @param entity 包含groupId和airlineId的实体
|
||||
* @return 存在的记录数
|
||||
*/
|
||||
int countByGroupIdAndAirlineId(AirlineFileGroupInfoEntity entity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
public interface AirlineFileMapper {
|
||||
|
||||
|
||||
AirlineFileEntity save(AirlineFileEntity entity);
|
||||
Long save(AirlineFileEntity entity);
|
||||
|
||||
List<AirlineFileEntity> selectFileListByIds(List<Long> ids);
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
package com.ruoyi.airline.service.api;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.airline.service.dto.AirlineFileGroupInfoDTO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.common.core.exception.base.BaseException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -13,9 +11,9 @@ import java.util.List;
|
|||
* @author 拓恒
|
||||
*/
|
||||
public interface IAirlineFileGroupInfoService {
|
||||
List<AirlineFileGroupInfoDTO> selectGroupInfoListById(Long groupId);
|
||||
List<AirlineFileGroupInfoDTO> selectGroupInfoListById(Long groupId);
|
||||
|
||||
|
||||
AirlineFileGroupInfoDTO save(AirlineFileGroupInfoDTO dto) throws IOException;
|
||||
Long save(AirlineFileGroupInfoDTO dto) throws BaseException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.airline.service.api;
|
||||
|
||||
import com.ruoyi.airline.domain.model.AirlineFile;
|
||||
import com.ruoyi.airline.service.dto.AirlineFileDTO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
|
@ -19,4 +20,6 @@ public interface IAirlineFileService {
|
|||
AirlineFileDTO parseAndUplload(MultipartFile file);
|
||||
|
||||
AirlineFileDTO createOrupdate(AirlineFileDTO airlineFile) throws IOException;
|
||||
|
||||
AirlineFile selectById(Long airlineId);
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
package com.ruoyi.airline.service.convert;
|
||||
|
||||
import com.ruoyi.airline.service.dto.AirLinePointDTO;
|
||||
import com.ruoyi.airline.domain.model.AirLinePoint;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 航线航点Service转换类
|
||||
* 用于Service DTO和Domain模型之间的转换
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-01-26
|
||||
*/
|
||||
public class AirLinePointServiceConvert {
|
||||
|
||||
/**
|
||||
* 将Service DTO转换为Domain模型
|
||||
*
|
||||
* @param dto Service DTO
|
||||
* @return Domain模型
|
||||
*/
|
||||
public static AirLinePoint toModel(AirLinePointDTO dto) {
|
||||
if (dto == null) {
|
||||
return null;
|
||||
}
|
||||
AirLinePoint model = new AirLinePoint();
|
||||
model.setId(dto.getId());
|
||||
model.setCommand(dto.getCommand());
|
||||
model.setLat(dto.getLat());
|
||||
model.setLon(dto.getLon());
|
||||
model.setAlt(dto.getAlt());
|
||||
model.setLoiterTime(dto.getLoiterTime());
|
||||
model.setCameraPitch(dto.getCameraPitch());
|
||||
model.setCameraRoll(dto.getCameraRoll());
|
||||
model.setCameraYaw(dto.getCameraYaw());
|
||||
model.setSessionControl(dto.getSessionControl());
|
||||
model.setShootCommand(dto.getShootCommand());
|
||||
model.setZoomAbsolute(dto.getZoomAbsolute());
|
||||
model.setRotateDirection(dto.getRotateDirection());
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Domain模型转换为Service DTO
|
||||
*
|
||||
* @param model Domain模型
|
||||
* @return Service DTO
|
||||
*/
|
||||
public static AirLinePointDTO toDTO(AirLinePoint model) {
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
AirLinePointDTO dto = new AirLinePointDTO();
|
||||
dto.setId(model.getId());
|
||||
dto.setCommand(model.getCommand());
|
||||
dto.setLat(model.getLat());
|
||||
dto.setLon(model.getLon());
|
||||
dto.setAlt(model.getAlt());
|
||||
dto.setLoiterTime(model.getLoiterTime());
|
||||
dto.setCameraPitch(model.getCameraPitch());
|
||||
dto.setCameraRoll(model.getCameraRoll());
|
||||
dto.setCameraYaw(model.getCameraYaw());
|
||||
dto.setSessionControl(model.getSessionControl());
|
||||
dto.setShootCommand(model.getShootCommand());
|
||||
dto.setZoomAbsolute(model.getZoomAbsolute());
|
||||
dto.setRotateDirection(model.getRotateDirection());
|
||||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Domain模型列表转换为Service DTO列表
|
||||
*
|
||||
* @param modelList Domain模型列表
|
||||
* @return Service DTO列表
|
||||
*/
|
||||
public static List<AirLinePointDTO> toDTOList(List<AirLinePoint> modelList) {
|
||||
if (modelList == null || modelList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return modelList.stream()
|
||||
.map(AirLinePointServiceConvert::toDTO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Service DTO列表转换为Domain模型列表
|
||||
*
|
||||
* @param dtoList Service DTO列表
|
||||
* @return Domain模型列表
|
||||
*/
|
||||
public static List<AirLinePoint> toModelList(List<AirLinePointDTO> dtoList) {
|
||||
if (dtoList == null || dtoList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return dtoList.stream()
|
||||
.map(AirLinePointServiceConvert::toModel)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ public class AirlineFileGroupInfoServiceConvert {
|
|||
dto.setId(model.getId());
|
||||
dto.setGroupId(model.getGroupId());
|
||||
dto.setAirlineId(model.getAirlineId());
|
||||
dto.setAirlineFileDTO(AirlineFileServiceConvert.toDTO(model.getAirlineFile()));
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
|
@ -47,6 +48,7 @@ public class AirlineFileGroupInfoServiceConvert {
|
|||
model.setId(dto.getId());
|
||||
model.setGroupId(dto.getGroupId());
|
||||
model.setAirlineId(dto.getAirlineId());
|
||||
model.setAirlineFile(AirlineFileServiceConvert.toModel(dto.getAirlineFileDTO()));
|
||||
return model;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.ruoyi.airline.service.convert;
|
||||
|
||||
import com.ruoyi.airline.service.dto.AirlineFileDTO;
|
||||
import com.ruoyi.airline.domain.model.AirlineFile;
|
||||
import com.ruoyi.airline.service.dto.AirlineFileDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -27,12 +27,13 @@ public class AirlineFileServiceConvert {
|
|||
}
|
||||
AirlineFile model = new AirlineFile();
|
||||
model.setId(dto.getId());
|
||||
model.setName(dto.getName());
|
||||
model.setFileName(dto.getFileName());
|
||||
model.setFileUrl(dto.getFileUrl());
|
||||
model.setType(dto.getType());
|
||||
model.setNote(dto.getNote());
|
||||
model.setDistance(dto.getDistance());
|
||||
model.setLinePointDtoList(dto.getLinePointDtoList());
|
||||
model.setLinePointDtoList(AirLinePointServiceConvert.toModelList(dto.getLinePointDtoList()));
|
||||
model.setSource(dto.getSource());
|
||||
model.setStatus(dto.getStatus());
|
||||
model.setFileMd5(dto.getFileMd5());
|
||||
|
|
@ -61,12 +62,13 @@ public class AirlineFileServiceConvert {
|
|||
}
|
||||
AirlineFileDTO dto = new AirlineFileDTO();
|
||||
dto.setId(model.getId());
|
||||
dto.setName(model.getName());
|
||||
dto.setFileName(model.getFileName());
|
||||
dto.setFileUrl(model.getFileUrl());
|
||||
dto.setType(model.getType());
|
||||
dto.setNote(model.getNote());
|
||||
dto.setDistance(model.getDistance());
|
||||
dto.setLinePointDtoList(model.getLinePointDtoList());
|
||||
dto.setLinePointDtoList(AirLinePointServiceConvert.toDTOList(model.getLinePointDtoList()));
|
||||
dto.setSource(model.getSource());
|
||||
dto.setStatus(model.getStatus());
|
||||
dto.setFileMd5(model.getFileMd5());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,78 @@
|
|||
package com.ruoyi.airline.service.dto;
|
||||
/**
|
||||
* 航线航点VO
|
||||
*
|
||||
* @author 拓恒
|
||||
* @date 2026-01-17
|
||||
*/
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class AirLinePointDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 动作id
|
||||
*/
|
||||
private Integer command;
|
||||
/**
|
||||
* 经纬度 +-180
|
||||
*/
|
||||
private String lat;
|
||||
/**
|
||||
* 经纬度 +-90
|
||||
*/
|
||||
private String lon;
|
||||
|
||||
/**
|
||||
* 高度
|
||||
*/
|
||||
private Integer alt;
|
||||
|
||||
/**
|
||||
* 悬停时间s
|
||||
*/
|
||||
private String loiterTime;
|
||||
|
||||
/**
|
||||
* 相机俯仰角
|
||||
*/
|
||||
private String cameraPitch;
|
||||
|
||||
/**
|
||||
* 相机滚动角
|
||||
*/
|
||||
private String cameraRoll;
|
||||
|
||||
/**
|
||||
* 相机偏航角
|
||||
*/
|
||||
private String cameraYaw;
|
||||
|
||||
/**
|
||||
* 挂载控制 1 相机
|
||||
*/
|
||||
private Integer sessionControl;
|
||||
/**
|
||||
* 相机指令 1 拍照
|
||||
*/
|
||||
private Integer shootCommand;
|
||||
|
||||
/**
|
||||
* 绝对变焦 目前 1-10
|
||||
*/
|
||||
private Integer zoomAbsolute;
|
||||
|
||||
/***
|
||||
* 转动方向 -1逆时针 1相对机场方向 (硬件定义的)
|
||||
*/
|
||||
private Integer rotateDirection;
|
||||
}
|
||||
|
|
@ -19,7 +19,10 @@ public class AirlineFileDTO {
|
|||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 航线名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
|
|
@ -57,7 +60,7 @@ public class AirlineFileDTO {
|
|||
/**
|
||||
* 航线点列表
|
||||
*/
|
||||
private List<AirLinePointVO> linePointDtoList;
|
||||
private List<AirLinePointDTO> linePointDtoList;
|
||||
|
||||
/**
|
||||
* 关联机场id
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import com.ruoyi.airline.service.convert.AirlineFileGroupServiceConvert;
|
|||
import com.ruoyi.airline.service.convert.AirlineFileServiceConvert;
|
||||
import com.ruoyi.airline.service.dto.AirlineFileGroupDTO;
|
||||
import com.ruoyi.airline.service.dto.AirlineFileGroupInfoDTO;
|
||||
import com.ruoyi.common.core.exception.base.BaseException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -48,23 +47,20 @@ public class AirlineFileServiceGroupImpl implements IAirlineFileGroupService {
|
|||
AirlineFileGroupInfoDTO dto = new AirlineFileGroupInfoDTO();
|
||||
dto.setGroupId(groupId);
|
||||
AirlineFileGroupInfo model = AirlineFileGroupInfoServiceConvert.toModel(dto);
|
||||
int result = iAirlineFileGroupInfoDomain.deleteGroupInfo(model);
|
||||
if (result > 0) {
|
||||
// 2、删除分组
|
||||
AirlineFileGroup model2 = new AirlineFileGroup();
|
||||
model2.setGroupId(groupId);
|
||||
model2.setUserId(userId);
|
||||
return iAirlineFileGroupDomain.deletegroup(model2);
|
||||
}
|
||||
// TODO 增加事务机制
|
||||
throw new BaseException("删除航线失败");
|
||||
iAirlineFileGroupInfoDomain.deleteGroupInfo(model);
|
||||
|
||||
// 2、删除分组
|
||||
AirlineFileGroup model2 = new AirlineFileGroup();
|
||||
model2.setGroupId(groupId);
|
||||
model2.setUserId(userId);
|
||||
return iAirlineFileGroupDomain.deletegroup(model2);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkGroupNameUnique(AirlineFileGroupDTO group) {
|
||||
AirlineFileGroup model = AirlineFileGroupServiceConvert.toModel(group);
|
||||
return iAirlineFileGroupDomain.checkgroupNameUnique(model) ;
|
||||
return iAirlineFileGroupDomain.checkgroupNameUnique(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -7,13 +7,12 @@ import com.ruoyi.airline.service.api.IAirlineFileService;
|
|||
import com.ruoyi.airline.service.convert.AirlineFileGroupInfoServiceConvert;
|
||||
import com.ruoyi.airline.service.dto.AirlineFileDTO;
|
||||
import com.ruoyi.airline.service.dto.AirlineFileGroupInfoDTO;
|
||||
import com.ruoyi.common.core.exception.base.BaseException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -38,17 +37,27 @@ public class AirlineFileServiceGroupInfoImpl implements IAirlineFileGroupInfoSer
|
|||
@Override
|
||||
public List<AirlineFileGroupInfoDTO> selectGroupInfoListById(Long groupId) {
|
||||
List<AirlineFileGroupInfo> models = iAirlineFileGroupInfoDomain.selectGroupInfoListById(groupId);
|
||||
models.forEach(model -> {
|
||||
model.setAirlineFile(iAirlineFileService.selectById(model.getAirlineId()));
|
||||
});
|
||||
return AirlineFileGroupInfoServiceConvert.toDtoList(models);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AirlineFileGroupInfoDTO save(AirlineFileGroupInfoDTO dto) throws IOException {
|
||||
public Long save(AirlineFileGroupInfoDTO dto) throws BaseException {
|
||||
AirlineFileDTO result = iAirlineFileService.save(dto.getAirlineFileDTO());
|
||||
dto.setAirlineFileDTO(result);
|
||||
|
||||
dto.setAirlineId(result.getId());
|
||||
// 保存分组信息
|
||||
AirlineFileGroupInfo model = AirlineFileGroupInfoServiceConvert.toModel(dto);
|
||||
AirlineFileGroupInfo airlineFileGroupInfoDTO = iAirlineFileGroupInfoDomain.save(model);
|
||||
return AirlineFileGroupInfoServiceConvert.toDTO(airlineFileGroupInfoDTO);
|
||||
|
||||
// 检查唯一性:同一个分组下不能有相同的航线
|
||||
boolean exists = iAirlineFileGroupInfoDomain.existsByGroupIdAndAirlineId(model.getGroupId(), model.getAirlineId());
|
||||
if (exists) {
|
||||
throw new BaseException("该航线已存在于当前分组中");
|
||||
}
|
||||
|
||||
return iAirlineFileGroupInfoDomain.save(model);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import com.ruoyi.airline.domain.uitl.KmlFileUtils;
|
|||
import com.ruoyi.airline.domain.uitl.WayPointUitls;
|
||||
import com.ruoyi.airline.service.api.IAirlineFileService;
|
||||
import com.ruoyi.airline.service.convert.AirlineFileServiceConvert;
|
||||
import com.ruoyi.airline.service.dto.AirLinePointDTO;
|
||||
import com.ruoyi.airline.service.dto.AirlineFileDTO;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.exception.base.BaseException;
|
||||
|
|
@ -47,8 +48,9 @@ public class AirlineFileServiceImpl implements IAirlineFileService {
|
|||
@Override
|
||||
public AirlineFileDTO save(AirlineFileDTO dto) {
|
||||
AirlineFile model = AirlineFileServiceConvert.toModel(dto);
|
||||
AirlineFile result = iAirlineFileDomain.save(model);
|
||||
return AirlineFileServiceConvert.toDTO(result);
|
||||
Long id = iAirlineFileDomain.save(model);
|
||||
dto.setId(id);
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -102,11 +104,11 @@ public class AirlineFileServiceImpl implements IAirlineFileService {
|
|||
public AirlineFileDTO createOrupdate(AirlineFileDTO airlineFile) {
|
||||
|
||||
StringBuilder waypointBuilder = new StringBuilder("QGC WPL 110\n");
|
||||
List<AirLinePointVO> LineDto = airlineFile.getLinePointDtoList();
|
||||
List<AirLinePointDTO> LineDto = airlineFile.getLinePointDtoList();
|
||||
// 新建字节输出流,Freemarker操作此输出流写入生成的业务文件.
|
||||
if (LineDto != null && !LineDto.isEmpty()) {
|
||||
for (int i = 0; i < LineDto.size(); i++) {
|
||||
AirLinePointVO point = LineDto.get(i);
|
||||
AirLinePointDTO point = LineDto.get(i);
|
||||
waypointBuilder.append(WayPointUitls.formatWaypointLine(point, i)).append("\n");
|
||||
}
|
||||
|
||||
|
|
@ -118,10 +120,21 @@ public class AirlineFileServiceImpl implements IAirlineFileService {
|
|||
airlineFile.setSource("airport");
|
||||
airlineFile.setStatus(airlineFile.getStatus() == null ? 1 : airlineFile.getStatus());
|
||||
AirlineFile model = AirlineFileServiceConvert.toModel(airlineFile);
|
||||
AirlineFile result = iAirlineFileDomain.save(model);
|
||||
return AirlineFileServiceConvert.toDTO(result);
|
||||
Long id = iAirlineFileDomain.save(model);
|
||||
model.setId(id);
|
||||
return AirlineFileServiceConvert.toDTO(model);
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AirlineFile selectById(Long airlineId) {
|
||||
if (airlineId == null) {
|
||||
return null;
|
||||
}
|
||||
List<Long> ids = List.of(airlineId);
|
||||
List<AirlineFile> airlineFiles = iAirlineFileDomain.selectFileListByIds(ids);
|
||||
return airlineFiles != null && !airlineFiles.isEmpty() ? airlineFiles.get(0) : null;
|
||||
}
|
||||
}
|
||||
|
|
@ -52,4 +52,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
values (#{groupId}, #{airlineId}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, 0)
|
||||
</insert>
|
||||
|
||||
<!-- 检查是否存在相同的groupId和airlineId -->
|
||||
<select id="countByGroupIdAndAirlineId" parameterType="com.ruoyi.airline.mapper.entity.AirlineFileGroupInfoEntity" resultType="int">
|
||||
select count(*)
|
||||
from airline_file_group_info
|
||||
where del_flag = 0
|
||||
<if test="groupId != null">
|
||||
and group_id = #{groupId}
|
||||
</if>
|
||||
<if test="airlineId != null">
|
||||
and airline_id = #{airlineId}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue