rain
2024-07-08 8b12caa558dd66a3c5d70f701426a53521c8deae
修改每日定时任务,修复文件信息返回空对象问题
8 files modified
61 ■■■■ changed files
src/main/java/com/dji/sample/media/controller/FileController.java 8 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/media/controller/MediaController.java 3 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/media/service/IFileService.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/media/service/IMediaService.java 3 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java 7 ●●●●● 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 28 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/media/controller/FileController.java
@@ -65,6 +65,10 @@
    @GetMapping("/getMediaInfo")
    public ResponseResult mediaInfo(@RequestParam String fileName) {
        Object info = fileService.mediaInfo(fileName);
        if (info == null) {
            return ResponseResult.error("图片正在解析中");
        }
        return ResponseResult.success(fileService.mediaInfo(fileName));
    }
@@ -82,10 +86,10 @@
                                       @RequestParam(name = "updateStart", required = false) Long photoStart,
                                       @RequestParam(name = "updateEnd", required = false) Long photoEnd,
                                       @RequestParam(name = "jobName", required = false) String jobName,
                                       @RequestParam( required = false) String type
                                       @RequestParam(required = false) String type
    ) {
        return ResponseResult.success(fileService.MediaQuery(page, pageSize, updateStart, updateEnd, photoStart, photoEnd, jobName,workspaceId,type));
        return ResponseResult.success(fileService.MediaQuery(page, pageSize, updateStart, updateEnd, photoStart, photoEnd, jobName, workspaceId, type));
    }
src/main/java/com/dji/sample/media/controller/MediaController.java
@@ -8,6 +8,7 @@
import com.dji.sample.media.model.param.SearchMediaParam;
import com.dji.sample.media.service.IMediaService;
import com.dji.sample.wayline.model.dto.WaylineJobDTO;
import com.drew.imaging.ImageProcessingException;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -57,7 +58,7 @@
     * @return
     */
    @PostMapping("/{workspace_id}/upload-callback")
    public ResponseResult<String> uploadCallback(@PathVariable(name = "workspace_id") String workspaceId, @RequestBody FileUploadDTO file) throws IOException, FontFormatException {
    public ResponseResult<String> uploadCallback(@PathVariable(name = "workspace_id") String workspaceId, @RequestBody FileUploadDTO file) throws IOException, FontFormatException, ImageProcessingException {
        mediaService.saveMediaFile(workspaceId, file);
        return ResponseResult.success(file.getObjectKey());
    }
src/main/java/com/dji/sample/media/service/IFileService.java
@@ -37,7 +37,7 @@
     * @param file
     * @return
     */
    Integer saveFile(String workspaceId, FileUploadDTO file);
    Integer saveFile(String workspaceId, FileUploadDTO file) throws ImageProcessingException, IOException;
    /**
     * 存储水印图片
src/main/java/com/dji/sample/media/service/IMediaService.java
@@ -5,6 +5,7 @@
import com.dji.sample.media.model.MediaJobDTO;
import com.dji.sample.media.model.param.SearchMediaParam;
import com.dji.sample.wayline.model.dto.WaylineJobDTO;
import com.drew.imaging.ImageProcessingException;
import org.springframework.web.bind.annotation.RequestParam;
import java.awt.*;
@@ -34,7 +35,7 @@
     * @param file
     * @return
     */
    Integer saveMediaFile(String workspaceId, FileUploadDTO file);
    Integer saveMediaFile(String workspaceId, FileUploadDTO file) throws ImageProcessingException, IOException;
    /**
src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
@@ -102,10 +102,11 @@
    }
    @Override
    public Integer saveFile(String workspaceId, FileUploadDTO file) {
    public Integer saveFile(String workspaceId, FileUploadDTO file) throws ImageProcessingException, IOException {
        MediaFileEntity fileEntity = this.fileUploadConvertToEntity(file);
        fileEntity.setWorkspaceId(workspaceId);
        fileEntity.setFileId(UUID.randomUUID().toString());
        Integer count= mapper.insert(fileEntity);
        try {
            boolean contains = file.getName().contains("~");
            if (contains) {
@@ -122,7 +123,7 @@
        } catch (Exception e) {
            e.printStackTrace();
        }
        return mapper.insert(fileEntity);
        return count;
    }
    public void saveMarkFile(String workspaceId, FileUploadDTO file) throws IOException, FontFormatException, ImageProcessingException {
@@ -160,7 +161,7 @@
    @Override
    public Object mediaInfo(String filename) {
        String name = "mark" + filename;
        String name = "mark"+filename;
        MediaFileMarkEntity entity = markMapper.selectOne(new LambdaQueryWrapper<MediaFileMarkEntity>()
                .eq(MediaFileMarkEntity::getFileName, name));
        return entity.getDronedata();
@@ -545,6 +546,7 @@
        }
    }
    @Override
    public void updateMarkMediaFileNames(String jobId) {
        try {
src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java
@@ -25,6 +25,7 @@
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;
@@ -88,7 +89,7 @@
    }
    @Override
    public Integer saveMediaFile(String workspaceId, FileUploadDTO file) {
    public Integer saveMediaFile(String workspaceId, FileUploadDTO file) throws ImageProcessingException, IOException {
        return fileService.saveFile(workspaceId, file);
    }
@@ -131,7 +132,7 @@
     * @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!");
@@ -217,7 +218,7 @@
                BizCodeEnum.FILE_UPLOAD_CALLBACK.getCode(), mediaFileCount);
    }
    private Boolean parseMediaFile(FileUploadCallback callback, WaylineJobDTO job) throws IOException, FontFormatException {
    private Boolean parseMediaFile(FileUploadCallback callback, WaylineJobDTO job) throws IOException, FontFormatException, ImageProcessingException {
        // Set the drone sn that shoots the media
        Optional<DeviceDTO> dockDTO = deviceService.getDeviceBySn(job.getDockSn());
        dockDTO.ifPresent(dock -> callback.getFile().getExt().setSn(dock.getChildDeviceSn()));
src/main/java/com/dji/sample/patches/controller/PatchesController.java
@@ -68,6 +68,7 @@
                                                        @RequestParam(name = "xmc", required = false) String xmc,
                                                        @RequestParam(name = "investigate", required = false) Integer investigate
    ) {
        fileService.getNoaddFile();
        //调用service分页查询
        PatchesParam param = PatchesParam.builder()
                .page(page)
@@ -207,7 +208,6 @@
                                                                           @RequestParam String dkbh) {
        try {
            fileService.getNoaddFile();
            PatchesParam param = PatchesParam.builder()
                    .page(page)
                    .workspaceId(workspaceId)
src/main/java/com/dji/sample/patches/utils/TimerUtil.java
@@ -144,7 +144,7 @@
//    }
    @Scheduled(cron = "0 0 1 * * ?")
    public void mytask4() throws IOException {
        Long time = getCurrentTimestampPlus8Hours(1);
        Long time = getCurrentTimestampPlus8Hours(8);
        List<List<Long>> listOfLists = new ArrayList<>();
        List<Long> sublist = new ArrayList<>();
        sublist.add(time); // 添加整数值
@@ -165,7 +165,7 @@
        List<Long> lists1 = new ArrayList<>();
        lists1.add(time);
        String times = convertTimestampToFormattedString(time);
        sendPostWithParameters("别墅巡查二段", "561ecb37-d673-40f8-a859-05dbfc7d9976", times, lists1, listOfLists);
        sendPostWithParameters("别墅巡查二段", "a07229af-471a-4058-9da6-5a2b84308b9e", times, lists1, listOfLists);
    }
    @Scheduled(cron = "0 40 1 * * ?")
@@ -194,6 +194,30 @@
        sendPostWithParameters("九洲巡河二段", "58cd4261-02d7-4c4e-b876-25a4a2630c18", times, lists1, listOfLists);
    }
    @Scheduled(cron = "0 30 2 * * ?")
    public void mytask8() throws IOException {
        Long time = getCurrentTimestampPlus8Hours(12);
        List<List<Long>> listOfLists = new ArrayList<>();
        List<Long> sublist = new ArrayList<>();
        sublist.add(time); // 添加整数值
        listOfLists.add(sublist);
        List<Long> lists1 = new ArrayList<>();
        lists1.add(time);
        String times = convertTimestampToFormattedString(time);
        sendPostWithParameters("定时任务2:30", "c3a7b125-bc0b-49d4-96ed-80743200ab80", times, lists1, listOfLists);
    }
    @Scheduled(cron = "0 30 2 * * ?")
    public void mytask9() throws IOException {
        Long time = getCurrentTimestampPlus8Hours(14);
        List<List<Long>> listOfLists = new ArrayList<>();
        List<Long> sublist = new ArrayList<>();
        sublist.add(time); // 添加整数值
        listOfLists.add(sublist);
        List<Long> lists1 = new ArrayList<>();
        lists1.add(time);
        String times = convertTimestampToFormattedString(time);
        sendPostWithParameters("定时任务4:30", "c3a7b125-bc0b-49d4-96ed-80743200ab80", times, lists1, listOfLists);
    }
    /**
     * 完成对未推送的图斑数据进行整合发送
     *