新增临时文件自动删除定时器,增加巡河喊话,修改水印文件上传方式
6 files modified
139 ■■■■■ changed files
src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java 103 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/controller/PatchesController.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/utils/TimerUtil.java 19 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/speak/controller/SpeakVoiceController.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/speak/service/SpeakVoiceService.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/speak/service/serviceImpl/SpeakVoiceServiceImpl.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
@@ -115,65 +115,64 @@
        return mapper.insert(fileEntity);
    }
    public void saveMarkFile(String workspaceId, FileUploadDTO file) throws IOException, FontFormatException, ImageProcessingException {
        String endpoint = pojo.getEndpoint();
        String accessKey = pojo.getAccessKey();
        String secretKey = pojo.getSecretKey();
        String bucketName = pojo.getBucket();
        String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey();
        File file1 = TbFjServiceImpl.downloadFile(url);
        File nailFile = new File(ImgZipUtil.compressImage(file1, 50).toURI());
        MediaFileNailEntity nailEntity = this.fileUploadConvertToNailEntity(file);
        nailEntity.setIsOriginal(false);
        nailEntity.setWorkspaceId(workspaceId);
        nailEntity.setFileName("nail" + file.getName());
        nailEntity.setObjectKey("/nail" + file.getPath() + "/" + file.getName());
        nailEntity.setFilePath("nail" + file.getPath());
        String nailName = nailEntity.getObjectKey();
        nailEntity.setFileId(UUID.randomUUID().toString());
        uploadFile(endpoint, accessKey, secretKey, bucketName, nailName, nailFile, "image/jpeg");
        nailMapper.insert(nailEntity);
        try {
            boolean contains = file.getName().contains("~");
            if (contains) {
                String name = TimerUtil.getDkbh(file.getName());
                List<LotInfo> lotInfos = patchesMapper.selectList(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, name));
                if (!lotInfos.isEmpty()) {
                    LambdaUpdateWrapper<LotInfo> updateWrapper = new LambdaUpdateWrapper<>();
                    updateWrapper.eq(LotInfo::getDkbh, name)
                            .eq(LotInfo::getInvestigate, 0)
                            .set(LotInfo::getInvestigate, 1);
                    patchesMapper.update(null, updateWrapper);
    public void saveMarkFile(String workspaceId, FileUploadDTO file) throws IOException {
        boolean endsWith = file.getObjectKey().endsWith(".mp4");
        if (endsWith) {
            MediaFileNailEntity nailEntity = this.fileUploadConvertToNailEntity((file));
            nailEntity.setWorkspaceId(workspaceId);
            nailEntity.setFileId(UUID.randomUUID().toString());
            nailMapper.insert(nailEntity);
        } else {
            String endpoint = pojo.getEndpoint();
            String accessKey = pojo.getAccessKey();
            String secretKey = pojo.getSecretKey();
            String bucketName = pojo.getBucket();
            String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey();
            File file1 = TbFjServiceImpl.downloadFile(url);
            File nailFile = new File(ImgZipUtil.compressImage(file1, 50).toURI());
            MediaFileNailEntity nailEntity = this.fileUploadConvertToNailEntity(file);
            nailEntity.setIsOriginal(false);
            nailEntity.setWorkspaceId(workspaceId);
            nailEntity.setFileName("nail" + file.getName());
            nailEntity.setObjectKey("/nail" + file.getPath() + "/" + file.getName());
            nailEntity.setFilePath("nail" + file.getPath());
            String nailName = nailEntity.getObjectKey();
            nailEntity.setFileId(UUID.randomUUID().toString());
            uploadFile(endpoint, accessKey, secretKey, bucketName, nailName, nailFile, "image/jpeg");
            nailMapper.insert(nailEntity);
            try {
                if (file.getName().contains("~")) {
                    String name = TimerUtil.getDkbh(file.getName());
                    List<LotInfo> lotInfos = patchesMapper.selectList(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, name));
                    if (!lotInfos.isEmpty()) {
                        LambdaUpdateWrapper<LotInfo> updateWrapper = new LambdaUpdateWrapper<>();
                        updateWrapper.eq(LotInfo::getDkbh, name)
                                .eq(LotInfo::getInvestigate, 0)
                                .set(LotInfo::getInvestigate, 1);
                        patchesMapper.update(null, updateWrapper);
                    }
                }
                boolean endsWith = file.getObjectKey().endsWith(".mp4");
                if (endsWith) {
                    MediaFileMarkEntity mediaFileMarkEntity = this.fileUploadConvertToMarkEntity(file);
                    long timestamp = convertToTimestamp(file.getMetadata().getCreatedTime());
                    File markFile = new File(WaterMarkUtil.addWatermark(file1, timestamp, file.getMetadata().getShootPosition().getLat(),
                            file.getMetadata().getShootPosition().getLng(), file.getMetadata().getGimbalYawDegree()).toURI());
                    Object data = ImgUtil.getInfo(file1);
                    mediaFileMarkEntity.setDronedata(data);
                    mediaFileMarkEntity.setWorkspaceId(workspaceId);
                    mediaFileMarkEntity.setIsadd(0);
                    mediaFileMarkEntity.setIsOriginal(false);
                    mediaFileMarkEntity.setFileId(UUID.randomUUID().toString());
                    mediaFileMarkEntity.setObjectKey("/mark" + file.getPath() + "/" + file.getName());
                    mediaFileMarkEntity.setFileName("mark" + file.getName());
                    mediaFileMarkEntity.setFilePath("mark" + file.getPath());
                    String objectName = mediaFileMarkEntity.getObjectKey(); // 例如 "folder/file.txt"
                    uploadFile(endpoint, accessKey, secretKey, bucketName, objectName, markFile, "image/jpeg");
                    markMapper.insert(mediaFileMarkEntity);
                }
                MediaFileMarkEntity mediaFileMarkEntity = this.fileUploadConvertToMarkEntity(file);
                long timestamp = convertToTimestamp(file.getMetadata().getCreatedTime());
                File markFile = new File(WaterMarkUtil.addWatermark(file1, timestamp, file.getMetadata().getShootPosition().getLat(),
                        file.getMetadata().getShootPosition().getLng(), file.getMetadata().getGimbalYawDegree()).toURI());
                Object data = ImgUtil.getInfo(file1);
                mediaFileMarkEntity.setDronedata(data);
                mediaFileMarkEntity.setWorkspaceId(workspaceId);
                mediaFileMarkEntity.setIsadd(0);
                mediaFileMarkEntity.setIsOriginal(false);
                mediaFileMarkEntity.setFileId(UUID.randomUUID().toString());
                mediaFileMarkEntity.setObjectKey("/mark" + file.getPath() + "/" + file.getName());
                mediaFileMarkEntity.setFileName("mark" + file.getName());
                mediaFileMarkEntity.setFilePath("mark" + file.getPath());
                String objectName = mediaFileMarkEntity.getObjectKey(); // 例如 "folder/file.txt"
                uploadFile(endpoint, accessKey, secretKey, bucketName, objectName, markFile, "image/jpeg");
                markMapper.insert(mediaFileMarkEntity);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
            }
    }
    @Override
    public Object mediaInfo(String filename) {
src/main/java/com/dji/sample/patches/controller/PatchesController.java
@@ -165,7 +165,7 @@
    @GetMapping("/useMyTask")
    public ResponseResult useMyTask() throws Exception {
        try {
            timerUtil.myTask();
            TimerUtil.mytask10();
//            timerUtil.myTask2();
//            timerUtil.myTask3();
//            timerUtil.mytask4();
src/main/java/com/dji/sample/patches/utils/TimerUtil.java
@@ -218,6 +218,24 @@
        String times = convertTimestampToFormattedString(time);
        sendPostWithParameters("定时任务4:30", "c3a7b125-bc0b-49d4-96ed-80743200ab80", times, lists1, listOfLists);
    }
    @Scheduled(cron = "0 0 6 * * ?")
    public static void mytask10() {
        File directory = new File("/tmp");
        String[] partialFileNames = {"temp", "mark"}; // 要匹配的部分文件名
        if (directory.isDirectory()) {
            File[] files = directory.listFiles();
            if (files != null) {
                for (File file : files) {
                    for (String partialFileName : partialFileNames) {
                        if (file.isFile() && file.getName().contains(partialFileName)) {
                            file.delete();
                            break; // 跳出内层循环,以免重复删除同一个文件
                        }
                    }
                }
            }
        }
    }
    /**
     * 完成对未推送的图斑数据进行整合发送
     *
@@ -272,6 +290,7 @@
        return convert(new File(destKMZFile));
    }
    /**
     * 将航线上传Oss
     *
src/main/java/com/dji/sample/speak/controller/SpeakVoiceController.java
@@ -57,8 +57,8 @@
    }
    @PostMapping("/putVoice")
    public ResponseResult putVoice(int id) {
        return ResponseResult.success(voiceServicel.awayRiver(id));
    public ResponseResult putVoice() {
        return ResponseResult.success(voiceServicel.awayRiver());
    }
    @GetMapping("/selectVoice")
src/main/java/com/dji/sample/speak/service/SpeakVoiceService.java
@@ -26,7 +26,7 @@
    int setVoiceVolume(SpeakVolumeDto dto,String sn);
    int awayRiver (int id);
    int awayRiver ();
    PaginationData<SpeakVoiceEntity> getVoices(Integer pages,Integer page_size);
}
src/main/java/com/dji/sample/speak/service/serviceImpl/SpeakVoiceServiceImpl.java
@@ -89,14 +89,13 @@
    }
    @Override
    public int awayRiver(int id) {
        SpeakVoiceEntity voiceEntity=voiceMapper.selectById(id);
    public int awayRiver() {
        SpeakVoiceStartDto dto = new SpeakVoiceStartDto();
        SpeakVoiceFileDto fileDto = new SpeakVoiceFileDto();
        fileDto.setUrl(voiceEntity.getUrl());
        fileDto.setMd5(voiceEntity.getMd5());
        fileDto.setUrl("http://dev.jxpskj.com:9000/cloud-bucket/请远离河道07151604");
        fileDto.setMd5("d2b448dcba09071834d02f082dc5386f");
        fileDto.setFormat(FormatEnum.PCM);
        fileDto.setName(voiceEntity.getName());
        fileDto.setName("河道危险");
        dto.setPsdk_index(2);
        dto.setFile(fileDto);
        return messageSenderService.publishServicesTopic("4TADKCM0010016", VoiceEnums.SPEAKER_AUDIO_PLAY_START.getMethod(), dto).getResult();