修改水印部分信息,添加图斑图片审核,大屏图斑图片添加水印
12 files modified
1 files deleted
| | |
| | | import com.dji.sample.common.model.CustomClaim; |
| | | import com.dji.sample.common.model.PaginationData; |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.media.model.FileUploadDTO; |
| | | import com.dji.sample.media.model.MediaFileDTO; |
| | | import com.dji.sample.media.model.MediaFileEntity; |
| | | import com.dji.sample.media.model.MediaFileQueryParam; |
| | | import com.dji.sample.media.service.IFileService; |
| | | import org.apache.ibatis.annotations.Update; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.URL; |
| | | import java.util.List; |
| | | |
| | | import static com.dji.sample.component.AuthInterceptor.TOKEN_CLAIM; |
| | | |
| | |
| | | /** |
| | | * Get information about all the media files in this workspace based on the workspace id. |
| | | * 根据工作空间id获取有关此工作空间中所有媒体文件的信息。 |
| | | * |
| | | * @param workspaceId |
| | | * @return |
| | | */ |
| | | @GetMapping("/{workspace_id}/files") |
| | | public ResponseResult<PaginationData<MediaFileEntity>> getFilesList(@RequestParam(defaultValue = "1") Long page, |
| | | @RequestParam(name = "page_size", defaultValue = "10") Long pageSize, |
| | | @PathVariable(name = "workspace_id") String workspaceId, |
| | | MediaFileQueryParam mediaFileQueryParam) { |
| | | PaginationData<MediaFileEntity> filesList = fileService.getMediaFilesPaginationByWorkspaceId(workspaceId, page, pageSize,mediaFileQueryParam); |
| | | @RequestParam(name = "page_size", defaultValue = "10") Long pageSize, |
| | | @PathVariable(name = "workspace_id") String workspaceId, |
| | | MediaFileQueryParam mediaFileQueryParam) { |
| | | PaginationData<MediaFileEntity> filesList = fileService.getMediaFilesPaginationByWorkspaceId(workspaceId, page, pageSize, mediaFileQueryParam); |
| | | return ResponseResult.success(filesList); |
| | | } |
| | | |
| | | @GetMapping("/listAdded") |
| | | public ResponseResult listIsadd() { |
| | | List<MediaFileEntity> entityList = fileService.listByIsadd(); |
| | | return ResponseResult.success(entityList); |
| | | } |
| | | |
| | | @PutMapping("/examine") |
| | | public ResponseResult examineData(@RequestParam String fileId) { |
| | | int is = fileService.updateExamByFileId(fileId); |
| | | if (is != 0) { |
| | | return ResponseResult.success(); |
| | | } else { |
| | | return ResponseResult.error("更新状态失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @GetMapping("/{workspace_id}/files/{job_id}") |
| | | public ResponseResult findFilesList(@PathVariable(name = "workspace_id") String workspaceId,@PathVariable(name = "job_id") String jobId) { |
| | | return ResponseResult.success(fileService.listMediaFileEntity(workspaceId,jobId)); |
| | | public ResponseResult findFilesList(@PathVariable(name = "workspace_id") String workspaceId, @PathVariable(name = "job_id") String jobId) { |
| | | return ResponseResult.success(fileService.listMediaFileEntity(workspaceId, jobId)); |
| | | } |
| | | |
| | | @PostMapping("/{workspace_id}/updateFile") |
| | |
| | | mediaFileEntity.setUserId(claims.getId()); |
| | | return ResponseResult.success(fileService.updateMediaFile(workspaceId, mediaFileEntity)); |
| | | } |
| | | |
| | | @DeleteMapping("/{workspace_id}/deleteFile") |
| | | |
| | | public ResponseResult deleteFile(@PathVariable(name = "workspace_id") String workspaceId, @RequestParam String fileId) { |
| | | int count=fileService.deleteMedia(workspaceId, fileId); |
| | | if(count==0){ |
| | | int count = fileService.deleteMedia(workspaceId, fileId); |
| | | if (count == 0) { |
| | | return ResponseResult.error("删除失败"); |
| | | } |
| | | return ResponseResult.success(); |
| | |
| | | /** |
| | | * Query the download address of the file according to the media file id, |
| | | * and redirect to this address directly for download. |
| | | * |
| | | * @param workspaceId |
| | | * @param fileId |
| | | * @param response |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | // @PostMapping("/{workspace_id}/files/download") |
| | | // public ResponseResult<String> waterMarkFile(){ |
| | | // //获取media实体信息 |
| | | // |
| | | // //对mediaUrl进行下载 |
| | | // |
| | | // //对图片进行水印 |
| | | // |
| | | // //将带有水印的图片存入本地 |
| | | // |
| | | // //将链接返回 |
| | | // } |
| | | } |
| | |
| | | /** |
| | | * Check if the file has been uploaded by the fingerprint. |
| | | * 检查文件是否已通过指纹上传。 |
| | | * |
| | | * @param workspaceId |
| | | * @param file |
| | | * @return |
| | |
| | | /** |
| | | * When the file is uploaded to the storage server by pilot, |
| | | * the basic information of the file is reported through this interface. |
| | | * |
| | | * @param workspaceId |
| | | * @param file |
| | | * @return |
| | |
| | | @PostMapping("/{workspace_id}/upload-callback") |
| | | public ResponseResult<String> uploadCallback(@PathVariable(name = "workspace_id") String workspaceId, @RequestBody FileUploadDTO file) throws IOException, FontFormatException { |
| | | mediaService.saveMediaFile(workspaceId, file); |
| | | mediaService.saveMediaMarkFile(workspaceId, file); |
| | | return ResponseResult.success(file.getObjectKey()); |
| | | } |
| | | |
| | | /** |
| | | * Query the files that already exist in this workspace based on the workspace id and the collection of tiny fingerprints. |
| | | * |
| | | * @param workspaceId |
| | | * @param tinyFingerprints There is only one tiny_fingerprint parameter in the body. |
| | | * But it is not recommended to use Map to receive the parameter. |
| | |
| | | |
| | | @GetMapping("/{workspace_id}/files/media_page") |
| | | public ResponseResult<PaginationData<MediaJobDTO>> mediaPage( |
| | | @PathVariable(name = "workspace_id") String workspaceId, @RequestBody SearchMediaParam param) { |
| | | @PathVariable(name = "workspace_id") String workspaceId, @RequestBody SearchMediaParam param) { |
| | | |
| | | PaginationData<MediaJobDTO> data = mediaService.mediaPage(workspaceId, param); |
| | | return ResponseResult.success(data); |
| | |
| | | * @version 0.2 |
| | | * @date 2021/12/9 |
| | | */ |
| | | @TableName(value = "media_file",autoResultMap = true) |
| | | @TableName(value = "media_file", autoResultMap = true) |
| | | @Data |
| | | @Builder |
| | | @AllArgsConstructor |
| | |
| | | @TableField("isadd") |
| | | private Integer isadd; |
| | | |
| | | @TableField("examine") |
| | | private Integer examine; |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * Query if the file already exists based on the workspace id and the fingerprint of the file. |
| | | * |
| | | * @param workspaceId |
| | | * @param fingerprint |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * Save the basic information of the file to the database. |
| | | * |
| | | * @param workspaceId |
| | | * @param file |
| | | * @return |
| | | */ |
| | | Integer saveFile(String workspaceId, FileUploadDTO file); |
| | | |
| | | Integer saveMarkFile(String workspaceId, FileUploadDTO file) throws IOException, FontFormatException; |
| | | |
| | | /** |
| | | * Query information about all files in this workspace based on the workspace id. |
| | | * |
| | | * @param workspaceId |
| | | * @return |
| | | */ |
| | | List<MediaFileDTO> getAllFilesByWorkspaceId(String workspaceId); |
| | | |
| | | List<MediaFileEntity> listByIsadd(); |
| | | |
| | | int updateExamByFileId(String fileId); |
| | | |
| | | List<MediaFileEntity> listMediaFileEntity(String workspaceId, String jobId); |
| | | |
| | | /** |
| | | * Paginate through all media files in this workspace. |
| | | * |
| | | * @param workspaceId |
| | | * @param page |
| | | * @param pageSize |
| | |
| | | |
| | | /** |
| | | * Get the download address of the file. |
| | | * |
| | | * @param workspaceId |
| | | * @param fileId |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * Query all media files of a job. |
| | | * |
| | | * @param workspaceId |
| | | * @param jobId |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 更新文件 |
| | | * @param workspaceId 项目id |
| | | * |
| | | * @param workspaceId 项目id |
| | | * @param mediaFileEntity |
| | | * @return |
| | | */ |
| | | Boolean updateMediaFile(String workspaceId, MediaFileEntity mediaFileEntity); |
| | | |
| | | int deleteMedia(String workspaceId, String fileId); |
| | | int deleteMedia(String workspaceId, String fileId); |
| | | } |
| | |
| | | |
| | | /** |
| | | * Check if the file has been uploaded by the fingerprint. |
| | | * |
| | | * @param workspaceId |
| | | * @param fingerprint |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * Save the basic information of the file to the database. |
| | | * |
| | | * @param workspaceId |
| | | * @param file |
| | | * @return |
| | | */ |
| | | Integer saveMediaFile(String workspaceId, FileUploadDTO file); |
| | | |
| | | Integer saveMediaMarkFile(String workspaceId, FileUploadDTO file) throws IOException, FontFormatException; |
| | | |
| | | /** |
| | | * Query tiny fingerprints about all files in this workspace based on the workspace id. |
| | | * |
| | | * @param workspaceId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Query the fingerprints that already exist in it based on the incoming tiny fingerprints data. |
| | | * |
| | | * @param workspaceId |
| | | * @param tinyFingerprints |
| | | * @return |
| | |
| | | |
| | | PaginationData<MediaJobDTO> mediaPage(String workspaceId, SearchMediaParam param); |
| | | |
| | | PaginationData<MediaJobDTO> mediaDetail(String jobId,Long page, Long pageSize); |
| | | PaginationData<MediaJobDTO> mediaDetail(String jobId, Long page, Long pageSize); |
| | | } |
| | |
| | | package com.dji.sample.media.service.impl; |
| | | |
| | | import com.aliyun.oss.OSS; |
| | | import com.aliyun.oss.OSSClientBuilder; |
| | | import com.aliyun.oss.model.PutObjectRequest; |
| | | import com.aliyun.oss.model.PutObjectResult; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | |
| | | import com.dji.sample.media.model.*; |
| | | import com.dji.sample.media.service.IFileService; |
| | | import com.dji.sample.territory.service.impl.TbFjServiceImpl; |
| | | import com.dji.sample.territory.utils.VideoZipUtil; |
| | | import com.dji.sample.territory.utils.WaterMarkUtil; |
| | | import io.minio.MinioClient; |
| | | import io.minio.PutObjectArgs; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.awt.*; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.net.URL; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.Arrays; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | fileEntity.setFileId(UUID.randomUUID().toString()); |
| | | return mapper.insert(fileEntity); |
| | | } |
| | | public Integer saveMarkFile(String workspaceId, FileUploadDTO file) throws IOException, FontFormatException { |
| | | MediaFileMarkEntity mediaFileMarkEntity =this.fileUploadConvertToMarkEntity(file); |
| | | String url = "http://dev.jxpskj.com:9000/cloud-bucket" + file.getObjectKey(); |
| | | File file1=TbFjServiceImpl.downloadFile(url); |
| | | File file2= new File(WaterMarkUtil.addWatermark(file1, Long.valueOf(file.getMetadata().getCreatedTime().toString()),file.getMetadata().getPhotoedPosition().getLat(), |
| | | file.getMetadata().getPhotoedPosition().getLng(),file.getMetadata().getGimbalYawDegree()).toURI()); |
| | | mediaFileMarkEntity.setObjectKey(file.getPath()); |
| | | mediaFileMarkEntity.setWorkspaceId(workspaceId); |
| | | mediaFileMarkEntity.setFileId(UUID.randomUUID().toString()); |
| | | mediaFileMarkEntity.setObjectKey("/mark"+file.getPath()+"/"+file.getName()); |
| | | mediaFileMarkEntity.setFileName("mark"+file.getName()); |
| | | mediaFileMarkEntity.setFilePath("mark"+file.getPath()); |
| | | uploadFile(String.valueOf(file2), mediaFileMarkEntity.getObjectKey()); |
| | | return markMapper.insert(mediaFileMarkEntity); |
| | | |
| | | public Integer saveMarkFile(String workspaceId, FileUploadDTO file) throws IOException, FontFormatException { |
| | | File file2 = null; |
| | | MediaFileMarkEntity mediaFileMarkEntity = this.fileUploadConvertToMarkEntity(file); |
| | | String url = "http://dev.jxpskj.com:9000/cloud-bucket" + file.getObjectKey(); |
| | | File file1 = TbFjServiceImpl.downloadFile(url); |
| | | long timestamp = convertToTimestamp(file.getMetadata().getCreatedTime()); |
| | | boolean endsWith = file.getObjectKey().endsWith(".mp4"); |
| | | if (!endsWith) { |
| | | file2 = new File(WaterMarkUtil.addWatermark(file1, timestamp, file.getMetadata().getShootPosition().getLat(), |
| | | file.getMetadata().getShootPosition().getLng(), file.getMetadata().getGimbalYawDegree()).toURI()); |
| | | } else { |
| | | file2 = VideoZipUtil.compressVideo(file1, 1600000, 128000, 1280, 720); |
| | | } |
| | | mediaFileMarkEntity.setWorkspaceId(workspaceId); |
| | | mediaFileMarkEntity.setFileId(UUID.randomUUID().toString()); |
| | | mediaFileMarkEntity.setObjectKey("/mark" + file.getPath() + "/" + file.getName()); |
| | | mediaFileMarkEntity.setFileName("mark" + file.getName()); |
| | | mediaFileMarkEntity.setFilePath("mark" + file.getPath()); |
| | | String endpoint = "http://dev.jxpskj.com:9000"; |
| | | String accessKey = "pskj"; |
| | | String secretKey = "pskj@2021"; |
| | | String bucketName = "cloud-bucket"; |
| | | String objectName = mediaFileMarkEntity.getObjectKey(); // 例如 "folder/file.txt" |
| | | uploadFile(endpoint, accessKey, secretKey, bucketName, objectName, file2); |
| | | return markMapper.insert(mediaFileMarkEntity); |
| | | } |
| | | |
| | | @Override |
| | | public List<MediaFileDTO> getAllFilesByWorkspaceId(String workspaceId) { |
| | | return mapper.selectList(new LambdaQueryWrapper<MediaFileEntity>() |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId)) |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId)) |
| | | .stream() |
| | | .map(this::entityConvertToDto) |
| | | .collect(Collectors.toList()); |
| | |
| | | @Override |
| | | public List<MediaFileEntity> listMediaFileEntity(String workspaceId, String jobId) { |
| | | return mapper.selectList(new LambdaQueryWrapper<MediaFileEntity>() |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId).eq(MediaFileEntity::getJobId,jobId)); |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId).eq(MediaFileEntity::getJobId, jobId)); |
| | | } |
| | | |
| | | public List<MediaFileEntity> listByIsadd() { |
| | | return mapper.selectList(new LambdaQueryWrapper<MediaFileEntity>().eq(MediaFileEntity::getIsadd, 0) |
| | | .like(MediaFileEntity::getFileName, "~")); |
| | | } |
| | | |
| | | public int updateExamByFileId(String fileId) { |
| | | // 创建并配置 LambdaUpdateWrapper |
| | | LambdaUpdateWrapper<MediaFileEntity> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(MediaFileEntity::getFileId, fileId) |
| | | .set(MediaFileEntity::getExamine, 0); |
| | | // 执行更新操作并返回更新的行数 |
| | | return mapper.update(null, updateWrapper); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // .eq(MediaFileEntity::getWorkspaceId, workspaceId) |
| | | // .orderByDesc(MediaFileEntity::getId)); |
| | | Page<MediaFileEntity> pageData = mapper.selectPage(new Page<MediaFileEntity>(page, pageSize), new LambdaQueryWrapper<MediaFileEntity>() |
| | | .eq(MediaFileEntity::getWorkspaceId,workspaceId) |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId) |
| | | .orderByDesc(MediaFileEntity::getCreateTime)); |
| | | |
| | | List<MediaFileEntity> records = pageData.getRecords() |
| | |
| | | return new PaginationData<MediaFileEntity>(records, new Pagination(pageData)); |
| | | } |
| | | |
| | | public int deleteMedia(String workspaceId, String fileId) { |
| | | int count=mapper.delete(new LambdaUpdateWrapper<MediaFileEntity>().eq(MediaFileEntity::getFileId, fileId) |
| | | public int deleteMedia(String workspaceId, String fileId) { |
| | | int count = mapper.delete(new LambdaUpdateWrapper<MediaFileEntity>().eq(MediaFileEntity::getFileId, fileId) |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId)); |
| | | return count; |
| | | return count; |
| | | } |
| | | |
| | | @Override |
| | | public URL getObjectUrl(String workspaceId, String fileId) { |
| | | Optional<MediaFileEntity> mediaFileOpt = getMediaByFileId(workspaceId, fileId); |
| | |
| | | @Override |
| | | public List<MediaFileDTO> getFilesByWorkspaceAndJobId(String workspaceId, String jobId) { |
| | | return mapper.selectList(new LambdaQueryWrapper<MediaFileEntity>() |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId) |
| | | .eq(MediaFileEntity::getJobId, jobId)) |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId) |
| | | .eq(MediaFileEntity::getJobId, jobId)) |
| | | .stream() |
| | | .map(this::entityConvertToDto).collect(Collectors.toList()); |
| | | } |
| | |
| | | params.setWorkspaceId(mediaFileEntity.getWorkspaceId());*/ |
| | | boolean update1 = new LambdaUpdateChainWrapper<>(mapper).eq(MediaFileEntity::getFileId, mediaFileEntity.getFileId()) |
| | | .set(MediaFileEntity::getFileName, mediaFileEntity.getFileName()) |
| | | .set(MediaFileEntity::getCollectStatus,mediaFileEntity.getCollectStatus()) |
| | | .set(MediaFileEntity::getUserId,mediaFileEntity.getUserId()) |
| | | .set(MediaFileEntity::getCollectStatus, mediaFileEntity.getCollectStatus()) |
| | | .set(MediaFileEntity::getUserId, mediaFileEntity.getUserId()) |
| | | .update(); |
| | | // int update = mapper.update(mediaFileEntity, Wrappers.update(params)); |
| | | return update1; |
| | |
| | | |
| | | /** |
| | | * Convert the received file object into a database entity object. |
| | | * |
| | | * @param file |
| | | * @return |
| | | */ |
| | |
| | | builder.fileName(file.getName()) |
| | | .filePath(file.getPath()) |
| | | .isadd(0) |
| | | .examine(1) |
| | | .fingerprint(file.getFingerprint()) |
| | | .objectKey(file.getObjectKey()) |
| | | .subFileType(file.getSubFileType()) |
| | |
| | | } |
| | | return builder.build(); |
| | | } |
| | | |
| | | private MediaFileMarkEntity fileUploadConvertToMarkEntity(FileUploadDTO file) { |
| | | MediaFileMarkEntity.MediaFileMarkEntityBuilder builder = MediaFileMarkEntity.builder(); |
| | | |
| | |
| | | |
| | | /** |
| | | * Convert database entity objects into file data transfer object. |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | |
| | | |
| | | return builder.build(); |
| | | } |
| | | public void uploadFile(String filePath, String key) { |
| | | OSS ossClient = new OSSClientBuilder().build(OssConfiguration.endpoint, OssConfiguration.accessKey, OssConfiguration.secretKey); |
| | | |
| | | public static void uploadFile(String endpoint, String accessKey, String secretKey, String bucketName, String objectName, File file) { |
| | | try { |
| | | File file = new File(filePath); |
| | | PutObjectRequest putObjectRequest = new PutObjectRequest(OssConfiguration.bucket, key, file); |
| | | PutObjectResult putObjectResult = ossClient.putObject(putObjectRequest); |
| | | // 创建MinIO客户端实例 |
| | | MinioClient minioClient = MinioClient.builder() |
| | | .endpoint(endpoint) |
| | | .credentials(accessKey, secretKey) |
| | | .build(); |
| | | // 上传文件 |
| | | FileInputStream fileInputStream = new FileInputStream(file); |
| | | minioClient.putObject( |
| | | PutObjectArgs.builder() |
| | | .bucket(bucketName) |
| | | .object(objectName) |
| | | .stream(fileInputStream, file.length(), -1) |
| | | .build() |
| | | ); |
| | | fileInputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | ossClient.shutdown(); |
| | | throw new RuntimeException("上传文件至服务器失败" + e); |
| | | } |
| | | } |
| | | |
| | | public static long convertToTimestamp(Date date) { |
| | | // 获取时间戳(毫秒级别) |
| | | return date.getTime(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | import com.dji.sample.component.websocket.service.ISendMessageService; |
| | | import com.dji.sample.manage.model.dto.DeviceDTO; |
| | | import com.dji.sample.manage.model.enums.UserTypeEnum; |
| | | import com.dji.sample.manage.model.receiver.OsdSubDeviceReceiver; |
| | | import com.dji.sample.manage.service.IDeviceRedisService; |
| | | import com.dji.sample.manage.service.IDeviceService; |
| | | import com.dji.sample.media.dao.IFileMapper; |
| | |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private String fileAddress; |
| | | @Value("${oss.bucket}") |
| | | private String bucket; |
| | | |
| | | @Override |
| | | public Boolean fastUpload(String workspaceId, String fingerprint) { |
| | | return fileService.checkExist(workspaceId, fingerprint); |
| | |
| | | @Override |
| | | public Integer saveMediaFile(String workspaceId, FileUploadDTO file) { |
| | | return fileService.saveFile(workspaceId, file); |
| | | } |
| | | public Integer saveMediaMarkFile(String workspaceId, FileUploadDTO file) throws IOException, FontFormatException { |
| | | return fileService.saveMarkFile(workspaceId, file); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public PaginationData<MediaJobDTO> mediaPage(String workspaceId, SearchMediaParam param) { |
| | | param.setFileAddress(fileAddress+"/"+bucket); |
| | | param.setFileAddress(fileAddress + "/" + bucket); |
| | | Page<MediaJobDTO> waylineJobDTOPage = mapper.mediaPage(new Page<MediaJobDTO>(param.getPage(), param.getPageSize()), workspaceId, param); |
| | | return new PaginationData<MediaJobDTO>(waylineJobDTOPage.getRecords(), new Pagination(waylineJobDTOPage)); |
| | | } |
| | | |
| | | @Override |
| | | public PaginationData<MediaJobDTO> mediaDetail( String jobId,Long page, Long pageSize) { |
| | | Page<MediaJobDTO> waylineJobDTOPage = mapper.mediaDetail(new Page<MediaJobDTO>(page, pageSize), jobId,fileAddress+"/"+bucket); |
| | | public PaginationData<MediaJobDTO> mediaDetail(String jobId, Long page, Long pageSize) { |
| | | Page<MediaJobDTO> waylineJobDTOPage = mapper.mediaDetail(new Page<MediaJobDTO>(page, pageSize), jobId, fileAddress + "/" + bucket); |
| | | return new PaginationData<MediaJobDTO>(waylineJobDTOPage.getRecords(), new Pagination(waylineJobDTOPage)); |
| | | } |
| | | |
| | | /** |
| | | * Handle media files messages reported by dock. |
| | | * 处理由dock报告的媒体文件消息。 |
| | | * |
| | | * @param receiver |
| | | * @return |
| | | */ |
| | | @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_FILE_UPLOAD_CALLBACK, outputChannel = ChannelName.OUTBOUND_EVENTS) |
| | | public CommonTopicReceiver handleFileUploadCallBack(CommonTopicReceiver receiver) { |
| | | public CommonTopicReceiver handleFileUploadCallBack(CommonTopicReceiver receiver) throws IOException, FontFormatException { |
| | | FileUploadCallback callback = objectMapper.convertValue(receiver.getData(), FileUploadCallback.class); |
| | | |
| | | if (callback.getResult() != ResponseResult.CODE_SUCCESS) { |
| | | log.error("媒体文件上传失败;Media file upload failed!"); |
| | | return null; |
| | |
| | | /** |
| | | * update the uploaded count and notify web side |
| | | * 更新上传的计数并通知web端 |
| | | * |
| | | * @param mediaFileCount |
| | | * @param receiver |
| | | * @param jobId |
| | |
| | | |
| | | //通过websocket把数据发送给web |
| | | sendMessageService.sendBatch(dock.getWorkspaceId(), UserTypeEnum.WEB.getVal(), |
| | | BizCodeEnum.FILE_UPLOAD_CALLBACK.getCode(), mediaFileCount); |
| | | BizCodeEnum.FILE_UPLOAD_CALLBACK.getCode(), mediaFileCount); |
| | | } |
| | | |
| | | private Boolean parseMediaFile(FileUploadCallback callback, WaylineJobDTO job) { |
| | | private Boolean parseMediaFile(FileUploadCallback callback, WaylineJobDTO job) throws 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 { |
| | | System.out.println(callback.getFile().toString()); |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * Handles the highest priority message about media uploads. |
| | | * |
| | | * @param receiver |
| | | * @param headers |
| | | * @return |
| | |
| | | return null; |
| | | } |
| | | sendMessageService.sendBatch(deviceOpt.get().getWorkspaceId(), UserTypeEnum.WEB.getVal(), |
| | | BizCodeEnum.HIGHEST_PRIORITY_UPLOAD_FLIGHT_TASK_MEDIA.getCode(), countDTO); |
| | | BizCodeEnum.HIGHEST_PRIORITY_UPLOAD_FLIGHT_TASK_MEDIA.getCode(), countDTO); |
| | | |
| | | return receiver; |
| | | } |
| | |
| | | private TbDkjbxxServiceImpl tbDkjbxxService; |
| | | @Autowired |
| | | private TimerUtil timerUtil; |
| | | |
| | | /** |
| | | * 根据workspaceId获取图斑列表信息 |
| | | * |
| | |
| | | getPatchesService.delPatches(); |
| | | return ResponseResult.success(); |
| | | } |
| | | |
| | | @GetMapping("/useMyTask") |
| | | public ResponseResult useMyTask() throws Exception { |
| | | try { |
| | | timerUtil.myTask(); |
| | | // timerUtil.myTask2(); |
| | | // timerUtil.myTask(); |
| | | timerUtil.myTask2(); |
| | | return ResponseResult.success(); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("db存储发送出现异常"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据图斑的地块编号获取相对应音视频 |
| | | * |
| | |
| | | import com.dji.sample.wayline.model.entity.WaylineFileEntity; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | /** |
| | | * 分页获取数据的接口实现。 |
| | | * |
| | | * @param param 包含分页信息和查询条件的工作空间ID。 |
| | | * @return 返回一个包含查询结果和分页信息的PaginationData对象。 |
| | | */ |
| | |
| | | public PaginationData<LotInfo> limitGet(PatchesParam param) { |
| | | Page<LotInfo> page = mapper.selectPage(new Page<LotInfo>(param.getPage(), param.getPageSize()), |
| | | new LambdaQueryWrapper<LotInfo>() |
| | | .eq(LotInfo::getWorkspaceId,param.getWorkspaceId())); |
| | | .eq(LotInfo::getWorkspaceId, param.getWorkspaceId())); |
| | | List<LotInfo> records = page.getRecords() |
| | | .stream() |
| | | .collect(Collectors.toList()); |
| | |
| | | public void delPatches() { |
| | | mapper.delete(null); |
| | | } |
| | | |
| | | /** |
| | | * 根据条件获取照片的分页数据 |
| | | * |
| | | * @param param 包含分页信息和查询条件的参数对象 |
| | | * @param dkbh 查询条件中带有地块编号关键字,用于文件名的模糊搜索 |
| | | * @param dkbh 查询条件中带有地块编号关键字,用于文件名的模糊搜索 |
| | | * @return 返回照片的分页数据,包括分页信息和照片实体列表 |
| | | */ |
| | | @Override |
| | | public PaginationData<MediaFileEntity> getPhoto(PatchesParam param,String dkbh) { |
| | | Page<MediaFileEntity> page=fileMapper.selectPage(new Page<MediaFileEntity>(param.getPage(), param.getPageSize()), |
| | | new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "%") ); |
| | | public PaginationData<MediaFileEntity> getPhoto(PatchesParam param, String dkbh) { |
| | | Page<MediaFileEntity> page = fileMapper.selectPage(new Page<MediaFileEntity>(param.getPage(), param.getPageSize()), |
| | | new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "~" + "%")); |
| | | List<MediaFileEntity> records = page.getRecords() |
| | | .stream() |
| | | .collect(Collectors.toList()); |
| | | return new PaginationData<MediaFileEntity>(records, new Pagination(page)); |
| | | } |
| | | |
| | | /** |
| | | * 根据条件获取照片的分页数据 |
| | | * |
| | | * @param workspaceId 工作空间的ID,用于指定查询的工作空间 |
| | | * @param dkbh 查询条件中带有地块编号关键字,用于文件名的模糊搜索 |
| | | * @param dkbh 查询条件中带有地块编号关键字,用于文件名的模糊搜索 |
| | | * @return 返回照片的分页数据,包括分页信息和照片实体列表 |
| | | */ |
| | | public List<MediaFileEntity> listPohto(String dkbh,String workspaceId){ |
| | | return fileMapper.selectList(new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "%") |
| | | .eq(MediaFileEntity::getWorkspaceId,workspaceId)); |
| | | public List<MediaFileEntity> listPohto(String dkbh, String workspaceId) { |
| | | return fileMapper.selectList(new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "%") |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId)); |
| | | } |
| | | |
| | | /** |
| | | * 根据地块编号和工作空间ID获取地块信息。 |
| | | * @param dkbh 地块编号,用于查询特定定单的地块信息。 |
| | | * |
| | | * @param dkbh 地块编号,用于查询特定定单的地块信息。 |
| | | * @param workspaceId 工作空间ID,用于查询属于特定工作空间的地块信息。 |
| | | * @return 返回匹配给定地块编号和工作空间ID的地块信息对象。如果找不到匹配的记录,则返回null。 |
| | | */ |
| | | public LotInfo getLotinfo(String dkbh,String workspaceId) { |
| | | return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh) |
| | | public LotInfo getLotinfo(String dkbh, String workspaceId) { |
| | | return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh) |
| | | .eq(LotInfo::getWorkspaceId, workspaceId)); |
| | | } |
| | | |
| | | public LotInfo getLotinfoToDb(String dkbh) { |
| | | return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh)); |
| | | } |
| | | public List<LotInfo>listLotinfo(){ |
| | | |
| | | public List<LotInfo> listLotinfo() { |
| | | return mapper.selectList(null); |
| | | } |
| | | |
| | |
| | | * @throws IOException |
| | | */ |
| | | public MultipartFile getFile(String waylineName, List<LotInfo> list) throws IOException { |
| | | List<PointPO> coordinates = GeoToolsUtil.getRoutePointOrder(list, 28.62452712442823, 115.85666327144976); |
| | | List<PointPO> coordinates = GeoToolsUtil.getRoutePointOrder(list, 28.62452712442823, 115.85666327144976); |
| | | XMLTemplateModel xmlModel = XMLTemplateModel.init(coordinates, list); |
| | | CreateWaylineFileUtils.createWaylineFile(xmlModel, patchesConfigPojo.getTemplate(), patchesConfigPojo.getTargetTemplate(), patchesConfigPojo.getWaylines(), patchesConfigPojo.getTargetWaylines()); |
| | | // 压缩文件夹中的内容 |
| | |
| | | |
| | | public List<List<MediaFileEntity>> getNoadd() { |
| | | List<MediaFileEntity> list = fileMapper.selectList(new LambdaQueryWrapper<MediaFileEntity>() |
| | | .eq(MediaFileEntity::getIsadd, 0).like(MediaFileEntity::getFileName, "~")); |
| | | .eq(MediaFileEntity::getIsadd, 0) |
| | | .eq(MediaFileEntity::getExamine, 1) |
| | | .like(MediaFileEntity::getFileName, "~")); |
| | | List<List<MediaFileEntity>> groupedFilenames = groupTasks(list); |
| | | return groupedFilenames; |
| | | } |
| | |
| | | .samplingRate("240000") |
| | | .scanningMode("repetitive") |
| | | .payloadPositionIndex(0) |
| | | .imageFormat("wide,ir") |
| | | // .imageFormat("wide,ir") |
| | | .imageFormat("wide") |
| | | .build(); |
| | | return pp; |
| | | } |
| | |
| | | g2d.drawString(watermarkText, x1, y1); |
| | | alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f); |
| | | g2d.setComposite(alphaComposite); |
| | | String extraInfo = String.format("Lon:%.9f Lat:%.6f\n%s 时间:%s", lng, lat,angel,sd); |
| | | String extraInfo = String.format("Lon:%.7f Lat:%.7f\n%s %s", lng, lat,angel,sd); |
| | | |
| | | File fontFile = new File("/tmp/jave/MiSans-Normal.ttf"); // 替换为你的字体文件路径 |
| | | Font customFont = Font.createFont(Font.TRUETYPE_FONT, fontFile).deriveFont(36.00F); |
| | |
| | | int y2 = originalImage.getHeight() - textHeight - 30; // 最底部位置 y 坐标 |
| | | |
| | | |
| | | int rectX = originalImage.getWidth() - textWidth +530; |
| | | int rectX = originalImage.getWidth() - textWidth +490; |
| | | int rectY = originalImage.getHeight() - textHeight -15; |
| | | // 绘制半透明黑色背景矩形 |
| | | Color semiTransparentColor = new Color(0, 0, 0, 156); // 0-255 的 alpha 值,0 表示完全透明,255 表示完全不透明 |
| | | g2d.setColor(semiTransparentColor); |
| | | g2d.fillRect(rectX, rectY, textWidth, textHeight-6); |
| | | |
| | | int rectXs = originalImage.getWidth() - textWidth +450 ; |
| | | int rectXs = originalImage.getWidth() - textWidth +420 ; |
| | | int rectYs = originalImage.getHeight() - textHeight -62; |
| | | // 绘制半透明黑色背景矩形 |
| | | g2d.setColor(semiTransparentColor); |
| | |
| | | // 释放 Graphics2D 对象 |
| | | g2d.dispose(); |
| | | // 保存添加水印后的图片 |
| | | File outputFile = new File("src/main/copy.jpeg"); |
| | | File outputFile = File.createTempFile("mark", ".jpg"); |
| | | |
| | | try { |
| | | ImageIO.write(originalImage, "jpg", outputFile); // 将图像写入临时文件 |
| | | } catch (IOException e) { |