feat:新增标注返回groupid,标注属性保存
This commit is contained in:
parent
ca475c5fb1
commit
3b89fd90dd
|
|
@ -3,11 +3,8 @@ package com.ruoyi.airline.controller.convert;
|
|||
import com.ruoyi.airline.api.domain.AirlineMarkerVO;
|
||||
import com.ruoyi.airline.service.dto.AirlineMarkerDTO;
|
||||
import com.ruoyi.common.core.utils.BaseConvert;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 标注Controller转换类
|
||||
|
|
@ -17,8 +14,6 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public class AirlineMarkerControllerConvert extends BaseConvert<AirlineMarkerDTO, AirlineMarkerVO>
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(AirlineMarkerControllerConvert.class);
|
||||
|
||||
private static final AirlineMarkerControllerConvert INSTANCE = new AirlineMarkerControllerConvert();
|
||||
|
||||
private AirlineMarkerControllerConvert() {
|
||||
|
|
@ -54,20 +49,7 @@ public class AirlineMarkerControllerConvert extends BaseConvert<AirlineMarkerDTO
|
|||
vo.setColor(dto.getColor());
|
||||
vo.setIcon(dto.getIcon());
|
||||
vo.setFontSize(dto.getFontSize());
|
||||
|
||||
// 转换coordinates
|
||||
if (dto.getCoordinates() != null) {
|
||||
vo.setCoordinates(dto.getCoordinates().stream()
|
||||
.map(point -> {
|
||||
AirlineMarkerVO.PointInfo voPoint = new AirlineMarkerVO.PointInfo();
|
||||
voPoint.setLatitude(point.getLatitude());
|
||||
voPoint.setLongitude(point.getLongitude());
|
||||
voPoint.setAsl(point.getAsl());
|
||||
return voPoint;
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
vo.setCoordinates(dto.getCoordinates());
|
||||
vo.setDescription(dto.getDescription());
|
||||
vo.setGroupId(dto.getGroupId());
|
||||
vo.setCreateBy(dto.getCreateBy());
|
||||
|
|
@ -90,20 +72,7 @@ public class AirlineMarkerControllerConvert extends BaseConvert<AirlineMarkerDTO
|
|||
dto.setColor(vo.getColor());
|
||||
dto.setIcon(vo.getIcon());
|
||||
dto.setFontSize(vo.getFontSize());
|
||||
|
||||
// 转换coordinates
|
||||
if (vo.getCoordinates() != null) {
|
||||
dto.setCoordinates(vo.getCoordinates().stream()
|
||||
.map(point -> {
|
||||
AirlineMarkerDTO.PointInfo dtoPoint = new AirlineMarkerDTO.PointInfo();
|
||||
dtoPoint.setLatitude(point.getLatitude());
|
||||
dtoPoint.setLongitude(point.getLongitude());
|
||||
dtoPoint.setAsl(point.getAsl());
|
||||
return dtoPoint;
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
dto.setCoordinates(vo.getCoordinates());
|
||||
dto.setDescription(vo.getDescription());
|
||||
dto.setGroupId(vo.getGroupId());
|
||||
dto.setCreateBy(vo.getCreateBy());
|
||||
|
|
@ -112,4 +81,4 @@ public class AirlineMarkerControllerConvert extends BaseConvert<AirlineMarkerDTO
|
|||
dto.setUpdateTime(vo.getUpdateTime());
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
package com.ruoyi.airline.domain.convert;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.ruoyi.common.core.utils.BaseConvert;
|
||||
import com.ruoyi.airline.domain.model.AirlineMarker;
|
||||
import com.ruoyi.airline.mapper.entity.AirlineMarkerEntity;
|
||||
|
|
@ -17,7 +15,6 @@ import java.util.List;
|
|||
public class AirlineMarkerDomainConvert extends BaseConvert<AirlineMarkerEntity, AirlineMarker>
|
||||
{
|
||||
private static final AirlineMarkerDomainConvert INSTANCE = new AirlineMarkerDomainConvert();
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
private AirlineMarkerDomainConvert() {
|
||||
super(AirlineMarkerEntity.class, AirlineMarker.class);
|
||||
|
|
@ -52,16 +49,7 @@ public class AirlineMarkerDomainConvert extends BaseConvert<AirlineMarkerEntity,
|
|||
model.setColor(entity.getColor());
|
||||
model.setIcon(entity.getIcon());
|
||||
model.setFontSize(entity.getFontSize());
|
||||
|
||||
// 从JSON字符串转换为List<PointInfo>
|
||||
if (entity.getCoordinates() != null) {
|
||||
try {
|
||||
model.setCoordinates(objectMapper.readValue(entity.getCoordinates(), objectMapper.getTypeFactory().constructCollectionType(List.class, AirlineMarker.PointInfo.class)));
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
model.setCoordinates(entity.getCoordinates());
|
||||
model.setDescription(entity.getDescription());
|
||||
model.setCreateBy(entity.getCreateBy());
|
||||
model.setCreateTime(entity.getCreateTime());
|
||||
|
|
@ -84,16 +72,7 @@ public class AirlineMarkerDomainConvert extends BaseConvert<AirlineMarkerEntity,
|
|||
entity.setColor(model.getColor());
|
||||
entity.setIcon(model.getIcon());
|
||||
entity.setFontSize(model.getFontSize());
|
||||
|
||||
// 从List<PointInfo>转换为JSON字符串
|
||||
if (model.getCoordinates() != null) {
|
||||
try {
|
||||
entity.setCoordinates(objectMapper.writeValueAsString(model.getCoordinates()));
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
entity.setCoordinates(model.getCoordinates());
|
||||
entity.setDescription(model.getDescription());
|
||||
entity.setCreateBy(model.getCreateBy());
|
||||
entity.setCreateTime(model.getCreateTime());
|
||||
|
|
@ -102,4 +81,4 @@ public class AirlineMarkerDomainConvert extends BaseConvert<AirlineMarkerEntity,
|
|||
entity.setRemark(model.getRemark());
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,8 +6,6 @@ import lombok.EqualsAndHashCode;
|
|||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 标注
|
||||
*
|
||||
|
|
@ -52,9 +50,9 @@ public class AirlineMarker extends ExBaseEntity {
|
|||
private Integer fontSize;
|
||||
|
||||
/**
|
||||
* 经纬度,格式:[经,纬,asl高度]
|
||||
* 坐标JSON字符串
|
||||
*/
|
||||
private List<PointInfo> coordinates;
|
||||
private String coordinates;
|
||||
|
||||
/**
|
||||
* 简介
|
||||
|
|
@ -66,24 +64,6 @@ public class AirlineMarker extends ExBaseEntity {
|
|||
*/
|
||||
private String remark;
|
||||
|
||||
@Data
|
||||
public static class PointInfo {
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private Double latitude;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private Double longitude;
|
||||
|
||||
/**
|
||||
* 海拔高度
|
||||
*/
|
||||
private Double asl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
@ -99,4 +79,4 @@ public class AirlineMarker extends ExBaseEntity {
|
|||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@ import com.ruoyi.airline.domain.model.AirlineMarker;
|
|||
import com.ruoyi.airline.service.dto.AirlineMarkerDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 标注Service转换类
|
||||
|
|
@ -51,20 +50,7 @@ public class AirlineMarkerServiceConvert extends BaseConvert<AirlineMarker, Airl
|
|||
dto.setColor(model.getColor());
|
||||
dto.setIcon(model.getIcon());
|
||||
dto.setFontSize(model.getFontSize());
|
||||
|
||||
// 转换coordinates
|
||||
if (model.getCoordinates() != null) {
|
||||
dto.setCoordinates(model.getCoordinates().stream()
|
||||
.map(point -> {
|
||||
AirlineMarkerDTO.PointInfo dtoPoint = new AirlineMarkerDTO.PointInfo();
|
||||
dtoPoint.setLatitude(point.getLatitude());
|
||||
dtoPoint.setLongitude(point.getLongitude());
|
||||
dtoPoint.setAsl(point.getAsl());
|
||||
return dtoPoint;
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
dto.setCoordinates(model.getCoordinates());
|
||||
dto.setDescription(model.getDescription());
|
||||
dto.setCreateBy(model.getCreateBy());
|
||||
dto.setCreateTime(model.getCreateTime());
|
||||
|
|
@ -86,20 +72,7 @@ public class AirlineMarkerServiceConvert extends BaseConvert<AirlineMarker, Airl
|
|||
model.setColor(dto.getColor());
|
||||
model.setIcon(dto.getIcon());
|
||||
model.setFontSize(dto.getFontSize());
|
||||
|
||||
// 转换coordinates
|
||||
if (dto.getCoordinates() != null) {
|
||||
model.setCoordinates(dto.getCoordinates().stream()
|
||||
.map(point -> {
|
||||
AirlineMarker.PointInfo modelPoint = new AirlineMarker.PointInfo();
|
||||
modelPoint.setLatitude(point.getLatitude());
|
||||
modelPoint.setLongitude(point.getLongitude());
|
||||
modelPoint.setAsl(point.getAsl());
|
||||
return modelPoint;
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
model.setCoordinates(dto.getCoordinates());
|
||||
model.setDescription(dto.getDescription());
|
||||
model.setCreateBy(dto.getCreateBy());
|
||||
model.setCreateTime(dto.getCreateTime());
|
||||
|
|
@ -107,4 +80,4 @@ public class AirlineMarkerServiceConvert extends BaseConvert<AirlineMarker, Airl
|
|||
model.setUpdateTime(dto.getUpdateTime());
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,8 +6,6 @@ import lombok.EqualsAndHashCode;
|
|||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 标注表 airline_marker
|
||||
*
|
||||
|
|
@ -52,9 +50,9 @@ public class AirlineMarkerDTO extends BaseEntity {
|
|||
private Integer fontSize;
|
||||
|
||||
/**
|
||||
* 经纬度,格式:[经,纬,asl高度]
|
||||
* 坐标JSON字符串
|
||||
*/
|
||||
private List<PointInfo> coordinates;
|
||||
private String coordinates;
|
||||
|
||||
/**
|
||||
* 简介
|
||||
|
|
@ -66,24 +64,6 @@ public class AirlineMarkerDTO extends BaseEntity {
|
|||
*/
|
||||
private Long groupId;
|
||||
|
||||
@Data
|
||||
public static class PointInfo {
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private Double latitude;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private Double longitude;
|
||||
|
||||
/**
|
||||
* 海拔高度
|
||||
*/
|
||||
private Double asl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
|
|||
|
|
@ -108,22 +108,35 @@ public class AirlineMarkerGroupInfoServiceImpl implements IAirlineMarkerGroupInf
|
|||
public AirlineMarkerGroupInfoDTO selectMarkersByGroupId(Long groupId) {
|
||||
AirlineMarkerGroupInfoDTO dto = new AirlineMarkerGroupInfoDTO();
|
||||
dto.setGroupId(groupId);
|
||||
|
||||
|
||||
// 先获取该分组下的所有标注ID
|
||||
AirlineMarkerGroupInfo airlineMarkerGroupInfo = new AirlineMarkerGroupInfo();
|
||||
airlineMarkerGroupInfo.setGroupId(groupId);
|
||||
List<AirlineMarkerGroupInfo> airlineMarkerGroupInfos= iAirlineMarkerGroupInfoDomain.selectMarkerGroupInfoList(airlineMarkerGroupInfo);
|
||||
List<Long> markerIds = airlineMarkerGroupInfos.stream().map(AirlineMarkerGroupInfo::getMarkerId).toList();
|
||||
|
||||
|
||||
if (markerIds != null && !markerIds.isEmpty()) {
|
||||
// 建立 markerId -> groupId 的映射
|
||||
java.util.Map<Long, Long> markerGroupMap = new java.util.HashMap<>();
|
||||
for (AirlineMarkerGroupInfo info : airlineMarkerGroupInfos) {
|
||||
markerGroupMap.put(info.getMarkerId(), info.getGroupId());
|
||||
}
|
||||
|
||||
// 根据ID列表查询标注详情
|
||||
List<AirlineMarker> markers = iAirlineMarkerDomain.selectMarkerListByIds(markerIds);
|
||||
if (markers != null && !markers.isEmpty()) {
|
||||
List<AirlineMarkerDTO> markerDTOs = AirlineMarkerServiceConvert.fromList(markers);
|
||||
List<AirlineMarkerDTO> markerDTOs = new java.util.ArrayList<>();
|
||||
for (AirlineMarker marker : markers) {
|
||||
AirlineMarkerDTO markerDTO = AirlineMarkerServiceConvert.from(marker);
|
||||
if (markerGroupMap.containsKey(marker.getId())) {
|
||||
markerDTO.setGroupId(markerGroupMap.get(marker.getId()));
|
||||
}
|
||||
markerDTOs.add(markerDTO);
|
||||
}
|
||||
dto.setGroupInfos(markerDTOs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue