rain
2024-08-21 2db1aa88e8ab53096a936163d686b90d8e056a99
src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java
@@ -5,6 +5,7 @@
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;
@@ -48,7 +49,9 @@
    @Autowired
    private MinioPojo pojo;
    @Autowired
    private IMarkMapper markMapper;
    private IFileService fileService;
    @Autowired
    private WaterMarkUtil waterMarkUtil;
    /**
     * 按照地块编号所对应的信息和音视频文件存入sqlite数据库
     *
@@ -72,11 +75,10 @@
        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
@@ -141,11 +143,11 @@
        //对应图片和视频文件进行不同处理
        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);
@@ -188,7 +190,7 @@
    }
    /**
     * 将音视频文件转换成字节流
     * 文件下载
     *
     * @param fileUrl
     * @return
@@ -235,23 +237,6 @@
        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);