rain
2024-08-12 dbecdea3ad1768d1c7f8e88a2d3b64193c62352a
国土调查的任务下发、更新、取消,成果上传
21 files modified
7 files added
903 ■■■■■ changed files
src/main/java/com/dji/sample/common/model/ResponseResult.java 3 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/component/redis/RedisOpsUtils.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/droneairport/controller/RegistController.java 41 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/droneairport/model/dto/AddTaskDto.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/droneairport/model/dto/TaskListDto.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/droneairport/model/dto/UpdataTaskDto.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/droneairport/model/param/ReturnDbParam.java 18 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/droneairport/model/param/ReturnTaskParam.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/droneairport/service/RegistService.java 71 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/droneairport/service/impl/RegistServiceImpl.java 387 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/droneairport/utils/SM4Util.java 35 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/manage/dao/IDeviceMapper.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java 6 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java 2 ●●● 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/dao/TaskInfoMapper.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/model/entity/LotInfo.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/model/entity/TaskInfo.java 34 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/service/GetPatchesService.java 5 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/utils/TimerUtil.java 177 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/territory/pojo/TerritoryConfigPojo.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/territory/utils/WaterMarkUtil.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/wayline/dao/IWaylineJobMapper.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java 23 ●●●●● patch | view | raw | blame | history
src/main/resources/application-dev.yml 1 ●●●● patch | view | raw | blame | history
src/main/resources/application-prod.yml 1 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/common/model/ResponseResult.java
@@ -48,9 +48,10 @@
                .build();
    }
    public static ResponseResult success(int code, String message,String traceid) {
    public static<T> ResponseResult success(int code, String message,String traceid,T data) {
        return ResponseResult.builder()
                .code(code)
                .data(data)
                .message(message)
                .traceid(traceid)
                .build();
src/main/java/com/dji/sample/component/redis/RedisOpsUtils.java
@@ -1,6 +1,7 @@
package com.dji.sample.component.redis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@@ -107,6 +108,13 @@
     * @return
     */
    public static Object get(String key) {
        // Execute the select command to choose the Redis database
        redisTemplate.execute((RedisCallback<Object>) connection -> {
            connection.select(1); // Choose database index 1
            return null;
        });
        // Now perform the get operation
        return redisTemplate.opsForValue().get(key);
    }
src/main/java/com/dji/sample/droneairport/controller/RegistController.java
@@ -1,16 +1,17 @@
package com.dji.sample.droneairport.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dji.sample.common.model.CustomClaim;
import com.dji.sample.common.model.ResponseResult;
import com.dji.sample.droneairport.dao.DeviceExpanSionDao;
import com.dji.sample.droneairport.model.Entity.DeviceExpanSionEntity;
import com.dji.sample.droneairport.model.dto.AddDeviceDto;
import com.dji.sample.droneairport.model.param.ReturnTaskParam;
import com.dji.sample.droneairport.service.RegistService;
import com.dji.sample.manage.service.impl.DeviceRedisServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import static com.dji.sample.component.AuthInterceptor.TOKEN_CLAIM;
@RequestMapping("/droneAirport")
@RestController
@@ -33,12 +34,46 @@
        return registService.authorization(body,headerValue);
    }
    @PostMapping("/addDevice/{workspace_id}")
    public ResponseResult registeDrone(@PathVariable(name = "workspace_id") String workspaceId) {
        return ResponseResult.success(registService.addDrone(workspaceId));
    }
    @GetMapping("/getDroneStatus/{deviceid}")
    public ResponseResult droneStatus(@PathVariable (name = "deviceid") String deviceid , HttpServletRequest request) throws Exception {
        return ResponseResult.success(registService.getDroneState(deviceid));
    }
    @PostMapping("/AddTask")
    public ResponseResult AddTask(HttpServletRequest request, @RequestBody String body) throws Exception {
        String headerValue = request.getHeader("x-lc-secret");
        CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM);
        String creator = customClaim.getUsername();
        ReturnTaskParam param = registService.AddTask(body, headerValue, creator);
        return ResponseResult.success(200, "无人机机场任务添加成功", param.getTraceId(), param.getWaylineId());
    }
    @GetMapping("/cancelTask/{taskId}")
    public ResponseResult cancelTask(@PathVariable(name = "taskId") String taskId) {
        return ResponseResult.success(registService.cancelTask(taskId));
    }
    @PostMapping("/updateTask")
    public ResponseResult updateTask(HttpServletRequest request, @RequestBody String body) throws Exception {
        String headerValue = request.getHeader("x-lc-secret");
        CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM);
        String creator = customClaim.getUsername();
        ReturnTaskParam param = registService.updateTask(body, headerValue, creator);
        return ResponseResult.success(200, "无人机机场任务添加成功", param.getTraceId(), param.getWaylineId());
    }
    @PostMapping("/queryTaskStatus")
    public ResponseResult queryTaskStatus(HttpServletRequest request, @RequestParam String taskid) throws Exception {
        return ResponseResult.success(registService.queryTaskStatus(taskid));
    }
    @GetMapping("/getResult/{taskId}")
    public ResponseResult getResult(@PathVariable(name = "taskId") String taskId) {
        return ResponseResult.success(registService.findDbFilesByTaskId(taskId));
    }
}
src/main/java/com/dji/sample/droneairport/model/dto/AddTaskDto.java
New file
@@ -0,0 +1,11 @@
package com.dji.sample.droneairport.model.dto;
import lombok.Data;
import java.util.List;
@Data
public class AddTaskDto {
    public String deviceid;
    public String bizidname;
    public List<TaskListDto> tasklist;
}
src/main/java/com/dji/sample/droneairport/model/dto/TaskListDto.java
New file
@@ -0,0 +1,15 @@
package com.dji.sample.droneairport.model.dto;
public class TaskListDto {
    public String bsm;  // 图斑标识码
    public String xzqdm; // 县级行政区代码
    public String dkbh; // 地块编号
    public String dklx; // 地块类型
    // 可选字段
    public String zdkbh; // 子地块编号
    public String dkmc; // 地块名称
    public Double dkmj; // 地块面积
    public String dkfw; // 地块范围,cgcs2000的经纬度坐标,wkt格式
    public String bz; // 备注
}
src/main/java/com/dji/sample/droneairport/model/dto/UpdataTaskDto.java
New file
@@ -0,0 +1,11 @@
package com.dji.sample.droneairport.model.dto;
import lombok.Data;
import java.util.List;
@Data
public class UpdataTaskDto {
    public String deviceid;
    public String taskid;
    public List<TaskListDto> tasklist;
}
src/main/java/com/dji/sample/droneairport/model/param/ReturnDbParam.java
New file
@@ -0,0 +1,18 @@
package com.dji.sample.droneairport.model.param;
import lombok.Data;
@Data
public class ReturnDbParam {
    private String taskId;
    private String regionCode;
    private int size;
    private int count;
    private int attachmentCount;
    private String extension;
    private String hash;
    private int timestamp;
    private String url;
    private String key;
    private String sign;
}
src/main/java/com/dji/sample/droneairport/model/param/ReturnTaskParam.java
New file
@@ -0,0 +1,10 @@
package com.dji.sample.droneairport.model.param;
import lombok.Data;
@Data
public class ReturnTaskParam {
    private String waylineId;
    private String traceId;
}
src/main/java/com/dji/sample/droneairport/service/RegistService.java
@@ -2,15 +2,84 @@
import com.dji.sample.common.model.ResponseResult;
import com.dji.sample.droneairport.model.Entity.DeviceExpanSionEntity;
import com.dji.sample.droneairport.model.dto.DroneStateDto;
import com.dji.sample.droneairport.model.param.ReturnTaskParam;
import java.util.List;
public interface RegistService {
    /**
     * 注册端口
     *
     * 该方法用于在系统中注册一个设备扩展端口的信息它接收一个DeviceExpanSionEntity对象作为参数,
     * 其中包含了设备扩展端口的相关信息这个方法的主要目的是将这个端口信息添加到系统的数据库中,
     * 以便于系统能够识别和管理这个端口
     *
     * @param airport 设备扩展端口实体对象,包含了需要注册的端口信息
     * @return 注册操作的状态信息,通常是一个字符串,比如"成功"或"失败"
     */
    String registPort(DeviceExpanSionEntity airport);
    String addDrone(String workspceId);
    /**
     * 获取无人机状态信息
     *
     * @param deviceId 无人机的设备ID,用于唯一标识一台无人机
     * @return 返回一个包含无人机状态信息的ResponseResult对象
     * @throws Exception 如果在获取无人机状态过程中发生错误,将抛出异常
     */
    ResponseResult getDroneState(String deviceId) throws Exception;
    /**
     * 执行授权操作
     *
     * @param base64 经过Base64编码的字符串,通常用于身份验证
     * @param Secret 应用的密钥,用于生成签名
     * @return 返回授权结果,包括成功与否、错误信息等
     * @throws Exception 如果授权过程中出现错误,可能会抛出异常
     */
    ResponseResult authorization(String base64, String Secret) throws Exception;
    /**
     * 添加任务接口
     * 该方法将基础64编码的配置信息、密钥和用户名作为参数,实现任务的添加
     *
     * @param base64 基础64编码的配置信息,用于任务的初始化和配置
     * @param Secret 任务的密钥,用于安全验证和任务的唯一标识
     * @param username 执行任务的用户名,用于权限验证和任务分配
     * @return 返回一个包含任务添加结果的ReturnParam对象,具体结果包括成功与否、错误信息等
     * @throws Exception 如果在任务添加过程中发生错误,将抛出异常
     */
    ReturnTaskParam AddTask(String base64, String Secret, String username) throws Exception;
    /**
     * 更新任务状态
     *
     * @param base64 经过Base64编码的字符串,用于标识任务
     * @param Secret 与任务相关的密钥,用于安全验证
     * @param username 执行任务的用户名,用于权限校验
     * @return 包含更新后任务状态信息的返回参数
     * @throws Exception 如果更新任务状态过程中发生错误,将抛出异常
     */
    ReturnTaskParam updateTask(String base64, String Secret, String username) throws Exception;
    /**
     * 取消指定任务
     *
     * @param taskId 任务ID,用于标识待取消的任务
     * @return 返回任务取消操作的结果,包含是否成功及可能的错误信息
     */
    ResponseResult cancelTask(String taskId);
    /**
     * 查询任务状态
     * 此方法用于根据设备ID查询设备任务的状态
     *
     * @param deviceId 设备ID,用于标识特定的设备
     * @return 返回一个ResponseResult对象,包含查询到的任务状态信息
     */
    ResponseResult queryTaskStatus(String taskid);
    List<String> findDbFilesByTaskId(String taskId);
}
src/main/java/com/dji/sample/droneairport/service/impl/RegistServiceImpl.java
@@ -1,22 +1,36 @@
package com.dji.sample.droneairport.service.impl;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
//import com.alibaba.fastjson.JSON;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.dji.sample.common.model.ResponseResult;
import com.dji.sample.component.redis.RedisOpsUtils;
import com.dji.sample.droneairport.dao.DeviceExpanSionDao;
import com.dji.sample.droneairport.model.Entity.DeviceExpanSionEntity;
import com.dji.sample.droneairport.model.dto.AddDeviceDto;
import com.dji.sample.droneairport.model.dto.DroneStateDto;
import com.dji.sample.droneairport.model.dto.RegistDto;
import com.dji.sample.droneairport.model.dto.*;
import com.dji.sample.droneairport.model.param.ReturnTaskParam;
import com.dji.sample.droneairport.service.RegistService;
import com.dji.sample.droneairport.utils.AuthUtil;
import com.dji.sample.droneairport.utils.SM2.Utils;
import com.dji.sample.droneairport.utils.SM4Util;
import com.dji.sample.manage.dao.IDeviceMapper;
import com.dji.sample.manage.model.entity.DeviceEntity;
import com.dji.sample.manage.model.receiver.OsdSubDeviceReceiver;
import com.dji.sample.manage.service.IDeviceRedisService;
import com.dji.sample.patches.dao.GetPatchesMapper;
import com.dji.sample.patches.dao.TaskInfoMapper;
import com.dji.sample.patches.model.entity.LotInfo;
import com.dji.sample.patches.model.entity.TaskInfo;
import com.dji.sample.patches.utils.TimerUtil;
import com.dji.sample.wayline.dao.IWaylineFileMapper;
import com.dji.sample.wayline.dao.IWaylineJobMapper;
import com.dji.sample.wayline.model.entity.WaylineFileEntity;
import com.dji.sample.wayline.model.entity.WaylineJobEntity;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.bouncycastle.crypto.InvalidCipherTextException;
@@ -24,12 +38,15 @@
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import static com.dji.sample.patches.utils.TimerUtil.getCurrentTimestampPlus8Hours;
@Service
public class RegistServiceImpl implements RegistService {
@@ -39,6 +56,18 @@
    private IDeviceRedisService redisService;
    @Autowired
    private DeviceExpanSionDao expanSionDao;
    @Autowired
    private TaskInfoMapper taskInfoMapper;
    @Autowired
    private GetPatchesMapper patchesMapper;
    @Autowired
    private TimerUtil timerUtil;
    @Autowired
    private IDeviceMapper deviceMapper;
    @Autowired
    private IWaylineJobMapper waylineJobMapper;
    @Autowired
    private IWaylineFileMapper fileMapper;
    public String registPort(DeviceExpanSionEntity airport) {
        try {
@@ -127,16 +156,202 @@
    }
    @Override
    public ResponseResult authorization(String base64, String enSm4) throws Exception {
        String sm4Secrect = deSM2(enSm4, "23E57DA1E4AB865CCBC325B668762207DEF74345B782237808AE0BABDF26734D");
    public ResponseResult authorization(String base64, String Secret) throws Exception {
        String sm4Secrect = deSM2(Secret, "23E57DA1E4AB865CCBC325B668762207DEF74345B782237808AE0BABDF26734D");
        String decryptedJson = SM4Util.decrypt(sm4Secrect, base64);
        JSONObject jsonObject = new JSONObject(decryptedJson);
        String deviceId = jsonObject.getStr("deviceid");
        boolean online = redisService.checkDeviceOnline(deviceId);
        if (online) {
            return ResponseResult.success(200, "无人机机场授权成功!", "");
            return ResponseResult.success(200, "无人机机场授权成功!", "", "");
        }
        return ResponseResult.error(500, "无人机机场授权失败!");
    }
    @Override
    public ReturnTaskParam AddTask(String base64, String Secret, String username) throws Exception {
        ReturnTaskParam param = new ReturnTaskParam();
        String taskId = UUID.randomUUID().toString();
        String traceid = UUID.randomUUID().toString();
        String sm4Secrect = deSM2(Secret, "23E57DA1E4AB865CCBC325B668762207DEF74345B782237808AE0BABDF26734D");
        String decryptedJson = SM4Util.decrypt(sm4Secrect, base64);
        JSONObject jsonObject = new JSONObject(decryptedJson);
        AddTaskDto addTaskDto = jsonToDto(jsonObject);
        TaskInfo taskInfo = new TaskInfo();
        List<String> listx = convertStringToList(addTaskDto.getDeviceid());
        String sn = listx.get(0);
        String workspaceId = getWorkspaceId(sn);
        taskInfo.setId(traceid);
        taskInfo.setTaskId(taskId);
        taskInfo.setName(addTaskDto.getBizidname());
        taskInfo.setDeviceIds(addTaskDto.getDeviceid());
        taskInfo.setCreateUser(username);
        param.setTraceId(traceid);
        taskInfoMapper.insert(taskInfo);
        List<TaskListDto> tasklist = addTaskDto.getTasklist();
        for (TaskListDto taskListDto : tasklist) {
            LotInfo lotInfo = new LotInfo();
            lotInfo = convertToLotInfo(taskListDto);
            lotInfo.setTaskId(taskId);
            lotInfo.setType(0);
            lotInfo.setTaskName(addTaskDto.getBizidname());
            lotInfo.setUserName(username);
            lotInfo.setWorkspaceId(workspaceId);
            patchesMapper.insert(lotInfo);
        }
        Long time = getCurrentTimestampPlus8Hours(14);
//        获取未规划的图斑集合
        List<List<LotInfo>> lists = timerUtil.getNoPlan(workspaceId);
        List<List<LotInfo>> convertedLists = TimerUtil.convertToLists(lists);
        for (List<LotInfo> list : convertedLists) {
            String waylineName = TimerUtil.getTimeName();
            //根据获取的图斑集合获得kmz航线文件
            MultipartFile multipartFile = null;
            try {
                multipartFile = timerUtil.getFile(waylineName, list, 28.62452712442823, 115.85666327144976);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            //上传航线文件
            WaylineFileEntity waylineFile = timerUtil.backWayline(multipartFile, waylineName, workspaceId, username);
            //将为规划的图斑状态更新为已规划
            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 = TimerUtil.convertTimestampToFormattedString(time);
            param.setWaylineId(taskId);
            TimerUtil.sendPostWithParameters(waylineName, waylineFile.getWaylineId(), times, lists1, listOfLists, taskId);
            timerUtil.updatePatchesStatu(list);
        }
        return param;
    }
    @Override
    public ReturnTaskParam updateTask(String base64, String Secret, String username) throws Exception {
        ReturnTaskParam param = new ReturnTaskParam();
        String traceid = UUID.randomUUID().toString();
        String sm4Secrect = deSM2(Secret, "23E57DA1E4AB865CCBC325B668762207DEF74345B782237808AE0BABDF26734D");
        String decryptedJson = SM4Util.decrypt(sm4Secrect, base64);
        JSONObject jsonObject = new JSONObject(decryptedJson);
        UpdataTaskDto addTaskDto = UpjsonToDto(jsonObject);
        String taskId = addTaskDto.getTaskid();
        delPatchesByTaskId(taskId);
//        delWaylineJob(taskId);
        TaskInfo taskInfo = new TaskInfo();
        List<String> listx = convertStringToList(addTaskDto.getDeviceid());
        String sn = listx.get(0);
        String workspaceId = getWorkspaceId(sn);
        taskInfo.setId(traceid);
        taskInfo.setTaskId(taskId);
        taskInfo.setDeviceIds(addTaskDto.getDeviceid());
        taskInfo.setCreateUser(username);
        param.setTraceId(traceid);
        updateTaskInfo(traceid, taskId, addTaskDto.getDeviceid(), username);
        List<TaskListDto> tasklist = addTaskDto.getTasklist();
        for (TaskListDto taskListDto : tasklist) {
            LotInfo lotInfo = new LotInfo();
            lotInfo = convertToLotInfo(taskListDto);
            lotInfo.setUserName(username);
            lotInfo.setTaskId(taskId);
            lotInfo.setWorkspaceId(workspaceId);
            patchesMapper.insert(lotInfo);
        }
        Long time = getCurrentTimestampPlus8Hours(14);
//        获取未规划的图斑集合
        List<List<LotInfo>> lists = timerUtil.getNoPlan(workspaceId);
        List<List<LotInfo>> convertedLists = TimerUtil.convertToLists(lists);
        for (List<LotInfo> list : convertedLists) {
            String waylineName = TimerUtil.getTimeName();
            //根据获取的图斑集合获得kmz航线文件
            MultipartFile multipartFile = null;
            try {
                multipartFile = timerUtil.getFile(waylineName, list, 28.62452712442823, 115.85666327144976);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            //上传航线文件
            WaylineFileEntity waylineFile = timerUtil.backWayline(multipartFile, waylineName, workspaceId, username);
            updateJob(taskId, waylineFile.getWaylineId());
            param.setWaylineId(taskId);
            timerUtil.updatePatchesStatu(list);
        }
        return param;
    }
    @Override
    public ResponseResult cancelTask(String taskId) {
        LambdaUpdateWrapper<WaylineJobEntity> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(WaylineJobEntity::getJobId, taskId)
                .set(WaylineJobEntity::getStatus, 4);
        waylineJobMapper.update(null, updateWrapper);
        return null;
    }
    @Override
    public ResponseResult queryTaskStatus(String taskid) {
        WaylineJobEntity jobEntity = waylineJobMapper.selectOne(new LambdaQueryWrapper<WaylineJobEntity>().eq(WaylineJobEntity::getJobId, taskid));
        if (jobEntity == null) {
            return ResponseResult.error(201, "查询无人机机场任务状态失败!");
        }
        int code = jobEntity.getStatus();
        //1: 待执行; 2: 执行中; 3: 完成; 4: 取消; 5: 失败
        if (code == 1) {
            return ResponseResult.success(200, "查询无人机机场任务状态成功!", "", "");
        } else if (code == 2) {
            return ResponseResult.success(202, "查询无人机机场任务状态成功!", "", "");
        } else if (code == 3) {
            return ResponseResult.success(203, "查询无人机机场任务状态成功!", "", "");
        } else if (code == 4) {
            return ResponseResult.success(204, "查询无人机机场任务状态成功!", "", "");
        } else if (code == 5) {
            return ResponseResult.success(205, "查询无人机机场任务状态成功!", "", "");
        }
        return null;
    }
    private static final String BASE_DIR = "src/main/resources/tmp";
    /**
     * 根据任务 ID 查找对应的 DB 文件路径
     *
     * @param taskId 任务 ID
     * @return 匹配的 DB 文件路径列表
     */
    public  List<String> findDbFilesByTaskId(String taskId) {
        List<String> dbFilePaths = new ArrayList<>();
        File baseDir = new File(BASE_DIR);
        // 检查基础目录是否存在
        if (!baseDir.exists() || !baseDir.isDirectory()) {
            throw new IllegalStateException("Base directory does not exist or is not a directory.");
        }
        // 遍历基础目录下的所有文件夹
        File[] subDirs = baseDir.listFiles(File::isDirectory);
        if (subDirs != null) {
            for (File subDir : subDirs) {
                // 如果文件夹名称包含任务 ID,则查找该文件夹中的 DB 文件
                if (subDir.getName().contains(taskId)) {
                    File[] files = subDir.listFiles((dir, name) -> name.endsWith(".db"));
                    if (files != null) {
                        for (File file : files) {
                            dbFilePaths.add(file.getAbsolutePath());
                        }
                    }
                }
            }
        }
        return dbFilePaths;
    }
    public void delPatchesByTaskId(String taskId) {
        patchesMapper.delete(new LambdaUpdateWrapper<LotInfo>().eq(LotInfo::getTaskId, taskId));
    }
    private String buildRequestBody(AddDeviceDto dto) {
@@ -147,6 +362,11 @@
        }
    }
    public String getWorkspaceId(String devicesn) {
        DeviceEntity entity = deviceMapper.selectOne(new LambdaQueryWrapper<DeviceEntity>()
                .eq(DeviceEntity::getDeviceSn, devicesn));
        return entity.getWorkspaceId();
    }
    public static String enSM2(String data, String pubKey) throws InvalidCipherTextException, IOException {
        String encrypt = Utils.encrypt(data, pubKey);
@@ -159,11 +379,6 @@
        return Utils.decrypt(hex, priKey);
    }
    public static void main(String[] args) throws Exception {
        System.out.println(enSM2("jsimjrby3wqb7dbq", "044D6061FC08A19D3F32CEAA8CF6679B40500008FD741FC26DE7E50AEBF3A9115D47274437730EADEDAEF0CCC4853C5F0B35B30C6AEA83A5F6FBCA4ABEAC9E3B98"));
        System.out.println(deSM2("BK010WH/Ax++jp57tWA4eHwbB26eqiG7bwmDfzaEGAtA6XN6/lQDt34mL0x4l4fEIOmQSzVfMqt4SV901gjzwf19mAeuPfM8AuCqCZsWZ9QU1bEx5ZqMIUDlFn9ngEbSbZ8qb1ERDvYtaMN5YE+9uI8=", "23E57DA1E4AB865CCBC325B668762207DEF74345B782237808AE0BABDF26734D"));
        System.out.println(createKey());
    }
    public static Map<String, String> createKey() throws NoSuchAlgorithmException {
        Map<String, String> keyPair = Utils.createKeyPair();
@@ -209,17 +424,141 @@
    public DroneStateDto getAirportFromCache(String deviceId) {
        OsdSubDeviceReceiver receiver = getDroneFromCache(deviceId);
        if (receiver == null) {
            throw new IllegalArgumentException("Receiver data not found for device ID: " + deviceId);
        }
        DroneStateDto.DroneStateDtoBuilder builder = DroneStateDto.builder();
        builder.gimbalYal(receiver.getAttitudeHead())
                .gimbalPitch(receiver.getAttitudePitch())
                .batteryCapacityPercent(receiver.getBattery().getCapacityPercent())
                .height(receiver.getHeight())
                .latitude(receiver.getLatitude())
                .longitude(receiver.getLongitude())
                .modeCode(0)
                .elevation(receiver.getElevation())
                .gpsState(2)
                .build();
        builder.gimbalYal(receiver.getAttitudeHead() != null ? receiver.getAttitudeHead() : 0.0)
                .gimbalPitch(receiver.getAttitudePitch() != null ? receiver.getAttitudePitch() : 0.0)
                .batteryCapacityPercent(receiver.getBattery() != null ? receiver.getBattery().getCapacityPercent() : 0)
                .height(receiver.getHeight() != null ? receiver.getHeight() : 0.0)
                .latitude(receiver.getLatitude() != null ? receiver.getLatitude() : 0.0)
                .longitude(receiver.getLongitude() != null ? receiver.getLongitude() : 0.0)
                .modeCode(receiver.getModeCode() != null ? receiver.getModeCode().getVal() : 0)
                .elevation(receiver.getElevation() != null ? receiver.getElevation() : 0.0)
                .gpsState(2);
        return builder.build();
    }
    public static AddTaskDto jsonToDto(JSONObject jsonObject) {
        AddTaskDto dto = new AddTaskDto();
        String deviceid = jsonObject.getStr("deviceid");
        dto.setDeviceid(deviceid);
        dto.setBizidname(jsonObject.getStr("bizidname"));
        JSONArray taskListArray = jsonObject.getJSONArray("tasklist");
        if (taskListArray != null) {
            List<TaskListDto> taskList = new ArrayList<>();
            for (int i = 0; i < taskListArray.size(); i++) {
                JSONObject taskObject = taskListArray.getJSONObject(i);
                if (taskObject != null) {
                    TaskListDto task = new TaskListDto();
                    task.bsm = taskObject.getStr("bsm");
                    task.xzqdm = taskObject.getStr("xzqdm");
                    task.dkbh = taskObject.getStr("dkbh");
                    task.dklx = taskObject.getStr("dklx");
                    task.zdkbh = taskObject.getStr("zdkbh");
                    task.dkmc = taskObject.getStr("dkmc");
                    task.dkmj = taskObject.getDouble("dkmj");
                    task.dkfw = taskObject.getStr("dkfw");
                    task.bz = taskObject.getStr("bz");
                    taskList.add(task);
                }
            }
            dto.tasklist = taskList;
        }
        return dto;
    }
    public static UpdataTaskDto UpjsonToDto(JSONObject jsonObject) {
        UpdataTaskDto dto = new UpdataTaskDto();
        String deviceid = jsonObject.getStr("deviceid");
        String taskid = jsonObject.getStr("taskid");
        dto.setDeviceid(deviceid);
        dto.setTaskid(taskid);
        JSONArray taskListArray = jsonObject.getJSONArray("tasklist");
        if (taskListArray != null) {
            List<TaskListDto> taskList = new ArrayList<>();
            for (int i = 0; i < taskListArray.size(); i++) {
                JSONObject taskObject = taskListArray.getJSONObject(i);
                if (taskObject != null) {
                    TaskListDto task = new TaskListDto();
                    task.bsm = taskObject.getStr("bsm");
                    task.xzqdm = taskObject.getStr("xzqdm");
                    task.dkbh = taskObject.getStr("dkbh");
                    task.dklx = taskObject.getStr("dklx");
                    task.zdkbh = taskObject.getStr("zdkbh");
                    task.dkmc = taskObject.getStr("dkmc");
                    task.dkmj = taskObject.getDouble("dkmj");
                    task.dkfw = taskObject.getStr("dkfw");
                    task.bz = taskObject.getStr("bz");
                    taskList.add(task);
                }
            }
            dto.tasklist = taskList;
        }
        return dto;
    }
    public static LotInfo convertToLotInfo(TaskListDto taskListDto) {
        if (taskListDto == null) {
            return null;
        }
        return LotInfo.builder()
                .bsm(taskListDto.bsm)
                .dklx(taskListDto.dklx)
                .xzqdm(taskListDto.xzqdm)
                .dkbh(taskListDto.dkbh)
                .dkmc(taskListDto.dkmc)
                .dkmj(taskListDto.dkmj)
                .dkfw(taskListDto.dkfw)
                .bz(taskListDto.bz)
                .build();
    }
    public static List<String> convertStringToList(String input) {
        // 使用 Hutool 解析字符串
        JSONArray jsonArray = JSONUtil.parseArray(input);
        // 将 JSONArray 转换为 List<String>
        return jsonArray.stream()
                .map(Object::toString)
                .collect(Collectors.toList());
    }
    public void updateTaskInfo(String traceid, String taskId, String deviceIds, String username) {
        TaskInfo taskInfo = new TaskInfo();
        taskInfo.setId(traceid);
        taskInfo.setTaskId(taskId);
        taskInfo.setDeviceIds(deviceIds);
        taskInfo.setCreateUser(username);
        LambdaUpdateWrapper<TaskInfo> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(TaskInfo::getId, traceid);
        updateWrapper.eq(TaskInfo::getTaskId, taskId);
        // 执行更新操作
        taskInfoMapper.update(taskInfo, updateWrapper);
    }
    public void delWaylineFile(String waylineId) {
        fileMapper.delete(new LambdaUpdateWrapper<WaylineFileEntity>().eq(WaylineFileEntity::getWaylineId, waylineId));
    }
    public void updateJob(String jobid, String waylineId) {
        LambdaUpdateWrapper<WaylineJobEntity> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(WaylineJobEntity::getJobId, jobid)
                .set(WaylineJobEntity::getFileId, waylineId);
        // 调用 update 方法进行更新操作
        waylineJobMapper.update(null, updateWrapper);
    }
}
src/main/java/com/dji/sample/droneairport/utils/SM4Util.java
@@ -111,8 +111,35 @@
        byte[] key = "jsimjrby3wqb7dbq".getBytes(StandardCharsets.UTF_8); // 16字节密钥
        // 原始明文
        String plaintext = "{ \"deviceid\": \"1581F6QAD241500BDZ3J\", \"status\": 1 }";
        String plaintext = "{\n" +
                "    \"deviceid\": [\n" +
                "        \"1581F5BMD22CK0014H2U\",\n" +
                "        \"1581F6QAD241800B6V95\"\n" +
                "    ],\n" +
                "    \"taskid\": \"b6e89a1e-5e89-4c9b-aa26-00faa4d8f568\",\n" +
                "    \"tasklist\": [\n" +
                "        {\n" +
                "            \"bsm\": \"2028107171717717107171017\",\n" +
                "            \"xzqdm\": \"310000\",\n" +
                "            \"dkbh\": \"ndbg201102U0172710711\",\n" +
                "            \"dklx\": \"ndbg2024\",\n" +
                "            \"dkmc\": \"小桥头\",\n" +
                "            \"dkmj\": 20.5,\n" +
                "            \"dkfw\": \"MULTIPOLYGON(((115.86528871951153 28.625287925196325,115.86561708513025 28.625787612007546,115.86815834948467 28.624602640426623,115.86773004650362 28.62425999804172,115.86528871951153 28.625287925196325)))\",\n" +
                "            \"bz\": null\n" +
                "        },\n" +
                "        {\n" +
                "            \"bsm\": \"202810717171777\",\n" +
                "            \"xzqdm\": \"310000\",\n" +
                "            \"dkbh\": \"ndbg201102U011\",\n" +
                "            \"dklx\": \"ndbg2024q\",\n" +
                "            \"dkmc\": \"桥头\",\n" +
                "            \"dkmj\": 27.5,\n" +
                "            \"dkfw\": \"MULTIPOLYGON(((115.8537683547021 28.626198084066036,115.85362014017156 28.625905772075246,115.85325749115422 28.625530171307133,115.8532121556319 28.625552314192735,115.85285649743213 28.625719691357663,115.8526650611681 28.62581016383709,115.85251948537035 28.62587896210428,115.8524159923293 28.625927871721817,115.85236695899066 28.625953724319036,115.85242053528945 28.626032126827145,115.85243919323472 28.626059431385023,115.85258924149208 28.626287013655055,115.85275847878526 28.62654053983997,115.85281562628226 28.62662918289837,115.8537683547021 28.626198084066036)))\",\n" +
                "            \"bz\": null\n" +
                "        }\n" +
                "    ]\n" +
                "}\n";
        String secert =encrypt(key,plaintext.getBytes());
//        System.out.println(secert);
@@ -120,11 +147,11 @@
        byte[] ming= Base64.getDecoder().decode(secert);
        byte[] text=decrypt(key,ming);
//        System.out.println(new String(text, StandardCharsets.UTF_8));
//        System.out.println("封装"+encrypt("jsimjrby3wqb7dbq",plaintext));
        System.out.println(encrypt("jsimjrby3wqb7dbq",plaintext));
//        System.out.println("封装"+decrypt("jsimjrby3wqb7dbq","9LFnVDdqleTOFcBJT7TSxs788zPH8PicodLb5634SsixHrKNX+ZAgwODPZxvWFNQ"));
        String encryptedBase64 = encrypt(key, plaintext.getBytes(StandardCharsets.UTF_8));
//        System.out.println("Encrypted (Base64): " + encryptedBase64);
        System.out.println(generateSM4Key());
//        System.out.println(generateSM4Key());
        // 直接解密
        byte[] decoded = Base64.getDecoder().decode(encryptedBase64);
        byte[] decrypted = decrypt(key, decoded);
src/main/java/com/dji/sample/manage/dao/IDeviceMapper.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dji.sample.manage.model.entity.DeviceEntity;
import org.apache.ibatis.annotations.Mapper;
/**
 *
@@ -9,6 +10,7 @@
 * @date 2021/11/10
 * @version 0.1
 */
@Mapper
public interface IDeviceMapper extends BaseMapper<DeviceEntity> {
}
src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
@@ -159,9 +159,9 @@
                    nailEntity.setFileId(UUID.randomUUID().toString());
                    // 上传图片文件
                    uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", file.getObjectKey(), downloadedFile, "image/jpeg");
//                    uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", file.getObjectKey(), downloadedFile, "image/jpeg");
                    uploadFile(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), nailName, nailFile, "image/jpeg");
                    uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", nailName, nailFile, "image/jpeg");
//                    uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", nailName, nailFile, "image/jpeg");
                    nailMapper.insert(nailEntity);
                    // 处理压缩后的图片文件(如果有)
@@ -177,7 +177,7 @@
                    // 上传压缩文件
                    uploadFile(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), zipName, zipFile, "image/jpeg");
                    uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", zipName, zipFile, "image/jpeg");
//                    uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", zipName, zipFile, "image/jpeg");
                    zipMapper.insert(zipEntity);
                }
            } catch (IOException | ImageProcessingException e) {
src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java
@@ -227,7 +227,7 @@
        String objectKey = callback.getFile().getObjectKey();
        callback.getFile().setPath(objectKey.substring(objectKey.indexOf("/") + 1, objectKey.lastIndexOf("/")));
        int count =fileService.saveFile(job.getWorkspaceId(), callback.getFile());
//        fileService.saveFiles(job.getWorkspaceId(), callback.getFile());
        fileService.saveFiles(job.getWorkspaceId(), callback.getFile());
//        fileService.saveZipFile(job.getWorkspaceId(),callback.getFile());
        return count > 0;
    }
src/main/java/com/dji/sample/patches/controller/PatchesController.java
@@ -177,7 +177,7 @@
//            timerUtil.mytask5();
//            timerUtil.mytask6();
//            timerUtil.mytask7();
            timerUtil.GtdbOperation();
        } catch (Exception e) {
            throw new RuntimeException("db存储发送出现异常" + e);
        }
src/main/java/com/dji/sample/patches/dao/TaskInfoMapper.java
New file
@@ -0,0 +1,11 @@
package com.dji.sample.patches.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dji.sample.patches.model.entity.LotInfo;
import com.dji.sample.patches.model.entity.TaskInfo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.web.bind.annotation.Mapping;
@Mapper
public interface TaskInfoMapper extends BaseMapper<TaskInfo> {
}
src/main/java/com/dji/sample/patches/model/entity/LotInfo.java
@@ -78,6 +78,9 @@
    @TableField("is_push")
    private int isPush;
    @TableField("type")
    private int type;
    @TableField("user_name")
    private String userName;
src/main/java/com/dji/sample/patches/model/entity/TaskInfo.java
New file
@@ -0,0 +1,34 @@
package com.dji.sample.patches.model.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "tb_task_info")
public class TaskInfo {
    @TableField("id")
    private String id;
    @TableField("task_id")
    private String taskId;
    @TableField("name")
    private String name;
    @TableField("device_ids")
    private String deviceIds;
    @TableField("create_user")
    private String createUser;
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Long createTime;
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private Long updateTime;
}
src/main/java/com/dji/sample/patches/service/GetPatchesService.java
@@ -17,6 +17,8 @@
    int delPatches(String workspaceId);
    List<LotInfo> getLotInfosByIds(List<Integer> ids);
    void patchesPushed(String taskId, String dkbh, String workspaceId);
    void patchesPushed(String taskId, String dkbh);
    int deleteOne(int id);
    /**
     * 根据条件获取照片的分页数据
@@ -35,7 +37,7 @@
     * @return 返回照片的分页数据,包括分页信息和照片实体列表
     */
     List<MediaFileEntity> listPohto(String dkbh, String workspaceId);
    List<MediaFileEntity> listPohto(String dkbh);
    /**
     * 根据地块编号和工作空间ID获取地块信息。
     * @param dkbh 地块编号,用于查询特定定单的地块信息。
@@ -43,6 +45,7 @@
     * @return 返回匹配给定地块编号和工作空间ID的地块信息对象。如果找不到匹配的记录,则返回null。
     */
     LotInfo getLotinfo(String dkbh,String workspaceId);
     LotInfo getLotinfo(String dkbh);
    List<LotInfo>listLotinfo(String workspaceID);
src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
@@ -167,9 +167,17 @@
                .eq(MediaFileEntity::getWorkspaceId, workspaceId)
                .eq(MediaFileEntity::getExamine,1));
    }
    public List<MediaFileEntity> listPohto(String dkbh) {
        return fileMapper.selectList(new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "%")
                .eq(MediaFileEntity::getExamine,1));
    }
    public LotInfo getLotinfo(String dkbh, String workspaceId) {
        return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh)
                .eq(LotInfo::getWorkspaceId, workspaceId));
    }
    public LotInfo getLotinfo(String dkbh) {
        return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh));
    }
    public void patchesPushed(String taskId, String dkbh, String workspaceId) {
        LambdaUpdateWrapper<LotInfo> updateWrapper = new LambdaUpdateWrapper<>();
@@ -179,6 +187,13 @@
                .eq(LotInfo::getTaskId, taskId);
        mapper.update(null, updateWrapper);
    }
    public void patchesPushed(String taskId, String dkbh) {
        LambdaUpdateWrapper<LotInfo> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(LotInfo::getIsPush, 1)
                .eq(LotInfo::getDkbh, dkbh)
                .eq(LotInfo::getTaskId, taskId);
        mapper.update(null, updateWrapper);
    }
    public LotInfo getLotinfoToDb(String dkbh) {
        return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh));
    }
src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java
@@ -82,6 +82,7 @@
            LotInfo lotInfo = new LotInfo();
            lotInfo.setWorkspaceId(workspaceId);
            lotInfo.setTaskId(id);
            lotInfo.setType(1);
            lotInfo.setTaskName(name);
            lotInfo = dbConvertToEntity(list.get(i), workspaceId, id, name);
            shpToDataSourceMapper.insert(lotInfo);
src/main/java/com/dji/sample/patches/utils/TimerUtil.java
@@ -102,6 +102,7 @@
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            taskId = list.get(0).getTaskId();
            //上传航线文件
            WaylineFileEntity waylineFile = backWayline(multipartFile, waylineName, workspaceId, backclaim().getUsername());
            //将为规划的图斑状态更新为已规划
@@ -236,6 +237,7 @@
//            }
//        }
//    }
    /**
     * 完成对未推送的图斑数据进行整合发送
     *
@@ -268,6 +270,30 @@
            //发送请求给第三方接口
            sendPostWithFileAndParameter(territoryConfigPojo.getResult(), taskId);
        }
    }
    @Scheduled(cron = "0 3 17 * * ?")
    public void GtdbOperation() throws Exception {
        String taskId = "";
        String dkbh = null;
        List<List<LotInfo>> lists = convertToLists(getNoPush());
        for (List<LotInfo> lotInfo : lists) {
            for (LotInfo lotInfo1 : lotInfo) {
                List<MediaFileEntity> media = getPatchesService.listPohto(lotInfo1.getDkbh());
                //清空FJ表
                tbFJService.deleteData();
                for (MediaFileEntity mediaFile : media) {
                    //获取媒体文件名里的dkbh和taskId
                    dkbh = getDkbh(mediaFile.getFileName());
                    //获取该媒体文件的图斑信息
                    LotInfo lotInfo2 = getPatchesService.getLotinfo(dkbh);
                    taskId = lotInfo2.getTaskId();
                    tbFJService.insertOneData(mediaFile, lotInfo2);
                    getPatchesService.patchesPushed(taskId, dkbh);
                }
            }
            //存储db到服务器
            dbSaveGt(territoryConfigPojo.getResult(), territoryConfigPojo.getResultGtsave(), taskId);
        }
    }
@@ -349,8 +375,16 @@
    public List<List<LotInfo>> getNoPush(String workspaceId) {
        List<LotInfo> list = patchesMapper.selectList(new LambdaQueryWrapper<LotInfo>()
                .eq(LotInfo::getIsPush, 0)
                .eq(LotInfo::getType, 1)
                .eq(LotInfo::getInvestigate, 1)
                .eq(LotInfo::getWorkspaceId, workspaceId));
        return groupTasks(list);
    }
    public List<List<LotInfo>> getNoPush() {
        List<LotInfo> list = patchesMapper.selectList(new LambdaQueryWrapper<LotInfo>()
                .eq(LotInfo::getIsPush, 0)
                .eq(LotInfo::getType, 0)
                .eq(LotInfo::getInvestigate, 1));
        return groupTasks(list);
    }
@@ -491,6 +525,70 @@
        return Files.readAllBytes(path);
    }
    public static void sendPostWithParameters(String name, String fileId, String time, List<Long> taskDays, List<List<Long>> taskPeriods, String jobId) throws IOException {
        try {
            RestTemplate restTemplate = new RestTemplate();
            // 构建请求体
            String jsonBody = buildRequestBody(name, fileId, time, taskDays, taskPeriods, jobId);
            // 设置请求头
            HttpHeaders headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_JSON);
            headers.setAccept(List.of(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN, MediaType.ALL));
            headers.set("Accept-Language", "zh-CN,zh;q=0.9");
            headers.setConnection("keep-alive");
            headers.set("x-auth-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3b3Jrc3BhY2VfaWQiOiJlM2RlYTBmNS0zN2YyLTRkNzktYWU1OC00OTBhZjMyMjgwNjkiLCJzdWIiOiJDbG91ZEFwaVNhbXBsZSIsInVzZXJfdHlwZSI6IjEiLCJuYmYiOjE3MTg1ODUxNTQsImxvZyI6IkxvZ2dlcltjb20uZGppLnNhbXBsZS5jb21tb24ubW9kZWwuQ3VzdG9tQ2xhaW1dIiwiaXNzIjoiREpJIiwiaWQiOiI5Y2MwMGY3Zi0yODMwLTRmM2UtYjdmNC1lN2E1ZjIzYjNjNGYiLCJleHAiOjE4MDQ5ODUxNTQsImlhdCI6MTcxODU4NTE1NCwidXNlcm5hbWUiOiJhZG1pbkRQIn0.eTi9DTYGwcTvnIZasKTFq9OHQgMFS1-m840terb7ss0");
            // 构建请求实体
            HttpEntity<String> requestEntity = new HttpEntity<>(jsonBody, headers);
            // 发送请求
            ResponseEntity<String> response = restTemplate.exchange(
//                    "https://wrj.shuixiongit.com/drone-api/wayline/api/v1/workspaces/4a574db8-4ad3-48f7-9f16-3edbcd8056e1/flight-tasks",
                    "http://localhost:6789/wayline/api/v1/workspaces/4a574db8-4ad3-48f7-9f16-3edbcd8056e1/flight-tasks",
                    HttpMethod.POST,
                    requestEntity,
                    String.class);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
            System.out.println(response);
        } catch (Exception e) {
            throw new IllegalArgumentException("Request failed: " + e.getMessage());
        }
    }
    public static void sendPostWithParameters(String name, String fileId, String time, List<Long> taskDays, List<List<Long>> taskPeriods) throws IOException {
        try {
            RestTemplate restTemplate = new RestTemplate();
@@ -554,6 +652,36 @@
                + "}", name, fileId, select_execute_time, taskDays, taskPeriods);
    }
    private static String buildRequestBody(String name, String fileId, String select_execute_time, List<Long> taskDays, List<List<Long>> taskPeriods, String jobid) {
        // 将 List 和 String 类型的参数格式化为 JSON 字符串
        String taskDaysJson = taskDays != null ? taskDays.toString() : "[]";
        String taskPeriodsJson = taskPeriods != null ? taskPeriods.toString() : "[]";
        // 使用 String.format 来生成 JSON 字符串
        return String.format("{"
                + "\"name\":\"%s\","
                + "\"file_id\":\"%s\","
                + "\"dock_sn\":\"4TADKCM0010016\","
                + "\"task_type\":1,"
                + "\"select_execute_time\":\"%s\","
                + "\"rth_altitude\":100,"
                + "\"out_of_control_action\":0,"
                + "\"executeTimeContinuousArr\":[{\"index\":1,\"value\":[]}],"
                + "\"executeTimeRepeatArr\":[{\"index\":1,\"value\":\"\"}],"
                + "\"rep_fre_val\":1,"
                + "\"rep_fre_type\":3,"
                + "\"rep_rule_type\":1,"
                + "\"time_range\":[],"
                + "\"rth_mode\":1,"
                + "\"1conValue\":[],"
                + "\"1repValue\":\"\","
                + "\"task_days\":%s,"
                + "\"task_periods\":%s,"
                + "\"wayline_type\":0,"
                + "\"job_id\":\"%s\""
                + "}", name, fileId, select_execute_time, taskDaysJson, taskPeriodsJson, jobid);
    }
    /**
     * 将上传的db保存一份到本地
     *
@@ -564,6 +692,34 @@
    public void dbSave(String path, String folder, String taskId) {
        String sourceFilePath = path; // 源文件路径
        String targetFolderPath = fileFold(folder).getPath(); // 目标文件夹路径
        try {
            // 创建目标文件夹
            File targetFolder = new File(targetFolderPath);
            if (!targetFolder.exists()) {
                targetFolder.mkdirs();
            }
            // 获取当前时间
            LocalDateTime currentTime = LocalDateTime.now();
            // 格式化时间,生成文件名
            String timeName = currentTime.format(DateTimeFormatter.ofPattern("HHmmss"));
            String fileName = timeName + "_" + taskId + ".db";
            // 构建目标文件路径
            String targetFilePath = targetFolderPath + File.separator + fileName;
            // 复制文件到目标文件夹
            Path sourcePath = Paths.get(sourceFilePath);
            Path targetPath = Paths.get(targetFilePath);
            Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING);
        } catch (IOException e) {
            throw new RuntimeException("Db文件复制失败", e); // 捕获并抛出原始异常
        }
    }
    public void dbSaveGt(String path, String folder, String taskId) {
        String sourceFilePath = path; // 源文件路径
        String targetFolderPath = fileFold(folder,taskId).getPath(); // 目标文件夹路径
        try {
            // 创建目标文件夹
@@ -615,7 +771,22 @@
        }
        return folder;
    }
    private static File fileFold(String fold,String taskId) {
        // 获取当前时间
        LocalDateTime currentTime = LocalDateTime.now();
        // 拼接文件夹路径
        String folderPath = fold + File.separator + taskId;
        // 创建文件夹
        File folder = new File(folderPath);
        if (!folder.exists()) {
            if (!folder.mkdirs()) {
                throw new RuntimeException("文件创建失败" + folderPath);
            }
        }
        return folder;
    }
    public static Long getCurrentTimestampPlus8Hours(long hours) {
        // 获取当前时间
        LocalDateTime now = LocalDateTime.now();
@@ -664,6 +835,12 @@
        return "云飞行计划" + currentTime.format(DateTimeFormatter.ofPattern("MMddHHmmssSS"));
    }
    public static String getTimeName() {
        LocalDateTime currentTime = LocalDateTime.now();
        // 格式化时间,生成当前时间
        return "国土调查云" + currentTime.format(DateTimeFormatter.ofPattern("MMddHHmmssSS"));
    }
    public static String getNowDay() {
        LocalDateTime currentTime = LocalDateTime.now();
src/main/java/com/dji/sample/territory/pojo/TerritoryConfigPojo.java
@@ -26,4 +26,8 @@
    @Value("${db.sqlite.resourceSave}")
    private String resourcesave;
    @Value("${db.sqlite.resultGtSave}")
    private String resultGtsave;
}
src/main/java/com/dji/sample/territory/utils/WaterMarkUtil.java
@@ -61,8 +61,8 @@
        alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f);
        g2d.setComposite(alphaComposite);
        String extraInfo = String.format("Lon:%.7f Lat:%.7f\n%s %s", lng, lat, angel, sd);
        File fontFile = new File("/usr/share/fonts/MiSans-Normal.ttf"); // 替换为你的字体文件路径
//        File fontFile = new File("src/main/resources/MiSans-Normal.ttf"); // 替换为你的字体文件路径
//        File fontFile = new File("/usr/share/fonts/MiSans-Normal.ttf"); // 替换为你的字体文件路径
        File fontFile = new File("src/main/resources/MiSans-Normal.ttf"); // 替换为你的字体文件路径
        Font customFont = Font.createFont(Font.TRUETYPE_FONT, fontFile).deriveFont(36.00F);
        // 注册字体
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
src/main/java/com/dji/sample/wayline/dao/IWaylineJobMapper.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dji.sample.wayline.model.entity.WaylineJobEntity;
import com.dji.sample.wayline.model.param.WaylineJobQueryParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -13,6 +14,7 @@
 * @version 1.1
 * @date 2022/6/1
 */
@Mapper
public interface IWaylineJobMapper extends BaseMapper<WaylineJobEntity> {
    Page<WaylineJobEntity> getPage(Page<WaylineJobEntity> waylineJobEntityPage, @Param("queryParam") WaylineJobQueryParam param, @Param("workspaceId") String workspaceId);
src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
@@ -128,6 +128,29 @@
        if (Objects.isNull(param)) {
            return Optional.empty();
        }
        if (param.getJobId()!=null){
            WaylineJobEntity jobEntity = WaylineJobEntity.builder()
                    .name(param.getName())
                    .dockSn(param.getDockSn())
                    .fileId(param.getFileId())
                    .username(username)
                    .workspaceId(workspaceId)
                    .jobId(param.getJobId())
                    .beginTime(beginTime)
                    .endTime(endTime)
                    .status(WaylineJobStatusEnum.PENDING.getVal())
                    .taskType(param.getTaskType().getVal())
                    .waylineType(param.getWaylineType().getVal())
                    .outOfControlAction(param.getOutOfControlAction())
                    .rthAltitude(param.getRthAltitude())
                    .rthMode(param.getRthMode())
                    .mediaCount(0)
                    .build();
            if (StringUtils.hasText(param.getJobId())) {
                jobEntity.setJobId(param.getJobId());
            }
            return insertWaylineJob(jobEntity);
        }
        // Immediate tasks, allocating time on the backend.
        WaylineJobEntity jobEntity = WaylineJobEntity.builder()
                .name(param.getName())
src/main/resources/application-dev.yml
@@ -124,3 +124,4 @@
    result: DB/result_db.db
    resultSave: src/main/resources/tmp
    resourceSave: src/main/resources/tmp
    resultGtSave: src/main/resources/tmp
src/main/resources/application-prod.yml
@@ -135,4 +135,5 @@
    result: /home/drone/server/sqlite/result_db.db
    resultSave: /home/drone/server/sqlite/retUpload/
    resourceSave: /home/drone/server/sqlite/upload/
    resultGtSave: /home/drone/server/sqlite/GtUpload/