| | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.dji.sample.media.dao.IMarkMapper; |
| | | import com.dji.sample.media.model.*; |
| | | import com.dji.sample.media.service.IFileService; |
| | | import com.dji.sample.media.util.ImgUtil; |
| | | import com.dji.sample.patches.config.pojo.PatchesConfigPojo; |
| | | import com.dji.sample.patches.model.entity.LotInfo; |
| | |
| | | @Autowired |
| | | private MinioPojo pojo; |
| | | @Autowired |
| | | private IMarkMapper markMapper; |
| | | private IFileService fileService; |
| | | @Autowired |
| | | private WaterMarkUtil waterMarkUtil; |
| | | /** |
| | | * 按照地块编号所对应的信息和音视频文件存入sqlite数据库 |
| | | * |
| | |
| | | return count; |
| | | } |
| | | |
| | | public void insertOneData(MediaFileEntity mediaFile, LotInfo lotInfo) throws Exception { |
| | | public int insertOneData(MediaFileEntity mediaFile, LotInfo lotInfo) throws Exception { |
| | | TbFjEntity tbFj = dbConvertToEntity(mediaFile, lotInfo); |
| | | if (tbFj.getFjysgd() == 3000) { |
| | | tbFjMapper.insert(tbFj); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | |
| | | //对应图片和视频文件进行不同处理 |
| | | boolean endsWith = key.endsWith(".mp4"); |
| | | if (!endsWith) { |
| | | file1 = WaterMarkUtil.addWatermark(file, sj, lat, lng, gimbalYawDegree); |
| | | file1 = waterMarkUtil.addWatermark(file, sj, lat, lng, gimbalYawDegree,lotInfo.getType()); |
| | | byte[] bytesArray = Files.readAllBytes(file1.toPath()); |
| | | fjhxz= sm3(bytesArray); |
| | | FJ = fileToByteArray(file1); |
| | | saveMarkFile(lotInfo.getWorkspaceId(),mediaFile,file1); |
| | | // fileService.saveMarkFile(lotInfo.getWorkspaceId(),mediaFile,file1); |
| | | } else { |
| | | file1 = VideoZipUtil.compressVideo(file, 800000, 128000, 1280, 720); |
| | | FJ = fileToByteArray(file1); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 将音视频文件转换成字节流 |
| | | * 文件下载 |
| | | * |
| | | * @param fileUrl |
| | | * @return |
| | |
| | | fis.close(); |
| | | return data; |
| | | } |
| | | public void saveMarkFile(String workspaceId, MediaFileEntity file,File file1) { |
| | | try { |
| | | MediaFileMarkEntity mediaFileMarkEntity= new MediaFileMarkEntity(); |
| | | mediaFileMarkEntity.setWorkspaceId(workspaceId); |
| | | mediaFileMarkEntity.setIsadd(0); |
| | | mediaFileMarkEntity.setIsOriginal(false); |
| | | mediaFileMarkEntity.setFileId(UUID.randomUUID().toString()); |
| | | mediaFileMarkEntity.setObjectKey("/mark" + file.getFilePath()+ "/" + file.getFileName()); |
| | | mediaFileMarkEntity.setFileName("mark" + file.getFileName()); |
| | | mediaFileMarkEntity.setFilePath("mark" + file.getFilePath()); |
| | | uploadFile(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), mediaFileMarkEntity.getObjectKey(), file1, "image/jpeg"); |
| | | markMapper.insert(mediaFileMarkEntity); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public static String convertTimestampToDateTime(long timestamp) { |
| | | // 将时间戳转换为 Instant 对象 |
| | | Instant instant = Instant.ofEpochMilli(timestamp); |