| | |
| | | import com.dji.sample.media.service.IMediaService; |
| | | import com.dji.sample.wayline.model.dto.WaylineJobDTO; |
| | | import com.dji.sample.wayline.service.IWaylineJobService; |
| | | import com.drew.imaging.ImageProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer saveMediaFile(String workspaceId, FileUploadDTO file) { |
| | | public Integer saveMediaFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException { |
| | | return fileService.saveFile(workspaceId, file); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_FILE_UPLOAD_CALLBACK, outputChannel = ChannelName.OUTBOUND_EVENTS) |
| | | public CommonTopicReceiver handleFileUploadCallBack(CommonTopicReceiver receiver) throws IOException, FontFormatException { |
| | | public CommonTopicReceiver handleFileUploadCallBack(CommonTopicReceiver receiver) throws IOException, FontFormatException, ImageProcessingException { |
| | | FileUploadCallback callback = objectMapper.convertValue(receiver.getData(), FileUploadCallback.class); |
| | | if (callback.getResult() != ResponseResult.CODE_SUCCESS) { |
| | | log.error("媒体文件上传失败;Media file upload failed!"); |
| | |
| | | BizCodeEnum.FILE_UPLOAD_CALLBACK.getCode(), mediaFileCount); |
| | | } |
| | | |
| | | private Boolean parseMediaFile(FileUploadCallback callback, WaylineJobDTO job) throws IOException, FontFormatException { |
| | | private Boolean parseMediaFile(FileUploadCallback callback, WaylineJobDTO job) throws ImageProcessingException, IOException, FontFormatException { |
| | | // Set the drone sn that shoots the media |
| | | Optional<DeviceDTO> dockDTO = deviceService.getDeviceBySn(job.getDockSn()); |
| | | dockDTO.ifPresent(dock -> callback.getFile().getExt().setSn(dock.getChildDeviceSn())); |
| | |
| | | // set path |
| | | String objectKey = callback.getFile().getObjectKey(); |
| | | callback.getFile().setPath(objectKey.substring(objectKey.indexOf("/") + 1, objectKey.lastIndexOf("/"))); |
| | | try { |
| | | ExecutorService executor = Executors.newSingleThreadExecutor(); |
| | | executor.execute(() -> { |
| | | try { |
| | | fileService.saveMarkFile(job.getWorkspaceId(), callback.getFile()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | }); |
| | | executor.shutdown(); |
| | | } catch (Exception e) { |
| | | log.error("方法执行有误==============: ", e); |
| | | throw e; |
| | | } |
| | | |
| | | |
| | | return fileService.saveFile(job.getWorkspaceId(), callback.getFile()) > 0; |
| | | int count =fileService.saveFile(job.getWorkspaceId(), callback.getFile()); |
| | | fileService.saveNailFile(job.getWorkspaceId(), callback.getFile()); |
| | | // fileService.saveZipFile(job.getWorkspaceId(),callback.getFile()); |
| | | return count > 0; |
| | | } |
| | | |
| | | /** |