|
|
@@ -10,10 +10,12 @@ import com.dji.sample.common.util.ThumbnailatorUtil;
|
|
|
import com.dji.sample.common.util.UserRequest;
|
|
|
import com.dji.sample.component.oss.model.OssConfiguration;
|
|
|
import com.dji.sample.component.oss.service.impl.OssServiceContext;
|
|
|
-import com.dji.sample.manage.model.common.AMap;
|
|
|
import com.dji.sample.manage.model.dto.DeviceDictionaryDTO;
|
|
|
import com.dji.sample.manage.service.IDeviceDictionaryService;
|
|
|
+import com.dji.sample.map.model.entity.GroupElementEntity;
|
|
|
import com.dji.sample.map.model.param.MediaFileQueryParam;
|
|
|
+import com.dji.sample.map.service.IGroupElementService;
|
|
|
+import com.dji.sample.map.service.IGroupService;
|
|
|
import com.dji.sample.media.dao.IFileMapper;
|
|
|
import com.dji.sample.media.dao.IFileSumMapper;
|
|
|
import com.dji.sample.media.model.*;
|
|
|
@@ -21,6 +23,7 @@ import com.dji.sample.media.service.IFileService;
|
|
|
import com.dji.sample.media.service.IMediaDirService;
|
|
|
import com.dji.sample.wayline.service.IWaylineFileService;
|
|
|
import com.dji.sdk.cloudapi.device.DeviceEnum;
|
|
|
+import com.dji.sdk.cloudapi.map.*;
|
|
|
import com.dji.sdk.cloudapi.media.MediaSubFileTypeEnum;
|
|
|
import com.dji.sdk.cloudapi.media.MediaUploadCallbackRequest;
|
|
|
import com.dji.sdk.cloudapi.wayline.GetWaylineListResponse;
|
|
|
@@ -76,6 +79,12 @@ public class FileServiceImpl implements IFileService {
|
|
|
@Autowired
|
|
|
private IWaylineFileService waylineFileService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IGroupElementService groupElementService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IGroupService groupService;
|
|
|
+
|
|
|
private static final String IMAGE = "image";
|
|
|
private static final String VIDEO = "video";
|
|
|
private static final String TAIL = "_100x100";
|
|
|
@@ -100,6 +109,16 @@ public class FileServiceImpl implements IFileService {
|
|
|
return entityConvertToDto(fileEntity);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ElementPicture getMediaFileByElementId(String workspaceId, String elementId) {
|
|
|
+ MediaFileEntity fileEntity = mapper.selectOne(new LambdaQueryWrapper<MediaFileEntity>()
|
|
|
+ .eq(MediaFileEntity::getWorkspaceId, workspaceId)
|
|
|
+ .eq(MediaFileEntity::getElementId, elementId)
|
|
|
+ .last(" limit 1 "));
|
|
|
+ String thumbnailURL = getThumbnailURL(fileEntity);
|
|
|
+ return new ElementPicture().setFileId(fileEntity.getFileId()).setMediaType(fileEntity.getMediaType()).setThumbnailUrl(thumbnailURL);
|
|
|
+ }
|
|
|
+
|
|
|
private Optional<MediaFileEntity> getMediaByFileId(String workspaceId, String fileId) {
|
|
|
MediaFileEntity fileEntity = mapper.selectOne(new LambdaQueryWrapper<MediaFileEntity>()
|
|
|
.eq(MediaFileEntity::getWorkspaceId, workspaceId)
|
|
|
@@ -428,7 +447,8 @@ public class FileServiceImpl implements IFileService {
|
|
|
.mediaType(mediaTypeEnum.getVal())
|
|
|
.mediaTypeText(mediaTypeEnum.getText())
|
|
|
.pictureType(entity.getPictureType())
|
|
|
- .durationSeconds(entity.getDurationSeconds());
|
|
|
+ .durationSeconds(entity.getDurationSeconds())
|
|
|
+ .elementId(entity.getElementId());
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -439,9 +459,9 @@ public class FileServiceImpl implements IFileService {
|
|
|
String originFileName = entity.getFileName();
|
|
|
//缩略图路径
|
|
|
String tObjectKey = getThumbnailObjectKey(originFileName);
|
|
|
- if(!putThumbnailImage(tObjectKey,entity.getObjectKey(),false)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
+// if(!putThumbnailImage(tObjectKey,entity.getObjectKey(),false)) {
|
|
|
+// return null;
|
|
|
+// }
|
|
|
return ossService.getObjectUrl(OssConfiguration.bucket, tObjectKey).toString();
|
|
|
|
|
|
}
|
|
|
@@ -631,6 +651,57 @@ public class FileServiceImpl implements IFileService {
|
|
|
return update > 0;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean updateElementId(MediaFileDTO mediaFileDTO) {
|
|
|
+ int update = mapper.update(null,
|
|
|
+ new LambdaUpdateWrapper<MediaFileEntity>().set(MediaFileEntity::getElementId,mediaFileDTO.getElementId())
|
|
|
+ .eq(MediaFileEntity::getFileId, mediaFileDTO.getFileId()));
|
|
|
+ return update > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean createMediaElement(String workspaceId, Integer elementFrom, MediaFileDTO mediaFileDTO) {
|
|
|
+ Optional<GetMapElementsResponse> groupOpt = groupService.getGroupByWorkspaceId(workspaceId,GroupTypeEnum.PICTURE);
|
|
|
+ if (groupOpt.isEmpty()) {
|
|
|
+ throw new RuntimeException("图片标注文件夹不存在");
|
|
|
+ }
|
|
|
+ //保存图片地图元素
|
|
|
+ String elementId = UUID.randomUUID().toString();
|
|
|
+ GroupElementEntity groupElementEntity = GroupElementEntity.builder()
|
|
|
+ .groupId(groupOpt.get().getId())
|
|
|
+ .elementId(elementId)
|
|
|
+ .elementName(mediaFileDTO.getFileName())
|
|
|
+ .username(UserRequest.getCurrentUser().getUsername())
|
|
|
+ .elementType(ElementResourceTypeEnum.MEDIA.getType())
|
|
|
+ .elementFrom(elementFrom)
|
|
|
+ .build();
|
|
|
+ ElementCoordinate elementCoordinate = new ElementCoordinate();
|
|
|
+ elementCoordinate.setAltitude(mediaFileDTO.getRelativeAltitude().doubleValue());
|
|
|
+ elementCoordinate.setLatitude(mediaFileDTO.getLatitude().doubleValue());
|
|
|
+ elementCoordinate.setLongitude(mediaFileDTO.getLongitude().doubleValue());
|
|
|
+ boolean isSuccess = groupElementService.saveElement(groupOpt.get().getId(),elementFrom,groupElementEntity,elementCoordinate);
|
|
|
+ //更新图片中的elementId
|
|
|
+ if(isSuccess) {
|
|
|
+ mediaFileDTO.setElementId(elementId);
|
|
|
+ return updateFile(mediaFileDTO);
|
|
|
+ };
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean deleteMediaElement(String workspaceId, MediaFileDTO mediaFileDTO) {
|
|
|
+ if(!StringUtils.hasText(mediaFileDTO.getElementId())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ boolean isSucc = groupElementService.deleteElement(mediaFileDTO.getElementId());
|
|
|
+ if(isSucc) {
|
|
|
+ mediaFileDTO.setElementId(null);
|
|
|
+ return updateElementId(mediaFileDTO);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private MediaFileEntity dtoToEntity(MediaFileDTO mediaFileDTO) {
|
|
|
MediaFileEntity.MediaFileEntityBuilder builder = MediaFileEntity.builder();
|
|
|
|
|
|
@@ -666,7 +737,8 @@ public class FileServiceImpl implements IFileService {
|
|
|
.longitudeRef(mediaFileDTO.getLongitudeRef())
|
|
|
.latitudeRef(mediaFileDTO.getLatitudeRef())
|
|
|
.pictureType(mediaFileDTO.getPictureType())
|
|
|
- .durationSeconds(mediaFileDTO.getDurationSeconds());
|
|
|
+ .durationSeconds(mediaFileDTO.getDurationSeconds())
|
|
|
+ .elementId(mediaFileDTO.getElementId());
|
|
|
}
|
|
|
|
|
|
return builder.build();
|