rain
2024-05-09 74d0031c16c468fa82208dbcdde4fa3766a58eeb
完成成果数据入库(DB)方式,修改DB文件上传接口。
17 files modified
346 ■■■■ changed files
src/main/java/com/dji/sample/patches/model/entity/LotInfo.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/service/GetPatchesService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/service/ShpToDataSourceService.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/utils/TimerUtil.java 226 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/xml/mode/XMLTemplateModel.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/territory/controller/TbDkjbxxController.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/territory/controller/TbFjController.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/territory/model/entity/param/UploadUrlParam.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/territory/pojo/TerritoryConfigPojo.java 5 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/territory/service/ITbDkjbxxService.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/territory/service/ITbFJService.java 3 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/territory/service/impl/TbDkjbxxServiceImpl.java 44 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java 30 ●●●● patch | view | raw | blame | history
src/main/resources/application-dev.yml 3 ●●●● patch | view | raw | blame | history
src/main/resources/application-prod.yml 3 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/model/entity/LotInfo.java
@@ -70,7 +70,7 @@
    private String taskName;
    @TableField("task_id")
    private int taskId;
    private String taskId;
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Long createTime;
src/main/java/com/dji/sample/patches/service/GetPatchesService.java
@@ -45,4 +45,6 @@
    List<LotInfo>listLotinfo();
    void insertLotinfo(List<LotInfo> list);
    LotInfo getLotinfoToDb(String dkbh);
}
src/main/java/com/dji/sample/patches/service/ShpToDataSourceService.java
@@ -31,7 +31,7 @@
     * 将List<TbDkjbxxEntity>类型的数据批量插入到数据库中。
     * @param list 需要保存到数据库的TbDkjbxxEntity实体列表。
     */
    void savaInMysql(List<TbDkjbxxEntity> list, String workspaceId,int id,String name);
    void savaInMysql(List<TbDkjbxxEntity> list, String workspaceId,String id,String name);
     List<LotInfo> getNoPlan();
}
src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
@@ -81,6 +81,9 @@
       return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh)
                .eq(LotInfo::getWorkspaceId, workspaceId));
    }
    public LotInfo getLotinfoToDb(String dkbh) {
        return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh));
    }
    public List<LotInfo>listLotinfo(){
        return mapper.selectList(null);
    }
src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java
@@ -79,7 +79,7 @@
    }
    @Transactional
    public void savaInMysql(List<TbDkjbxxEntity> list, String workspaceId,int id,String name) {
    public void savaInMysql(List<TbDkjbxxEntity> list, String workspaceId,String id,String name) {
        for (int i = 0; i < list.size(); i++) {
            LotInfo lotInfo = new LotInfo();
            lotInfo.setWorkspaceId(workspaceId);
@@ -97,7 +97,7 @@
     * @param file 需要转换的DKJBXX对象。
     * @return 返回一个构建好的LotInfo对象,包含从数据库实体中转换来的信息。
     */
    private LotInfo dbConvertToEntity(TbDkjbxxEntity file, String workspaceId,int id,String name) {
    private LotInfo dbConvertToEntity(TbDkjbxxEntity file, String workspaceId,String id,String name) {
        LotInfo.LotInfoBuilder builder = LotInfo.builder();
        builder.bsm(file.getFId())
                .xzqdm(file.getFXzqdmsys())
src/main/java/com/dji/sample/patches/utils/TimerUtil.java
@@ -1,30 +1,48 @@
package com.dji.sample.patches.utils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dji.sample.common.model.CustomClaim;
import com.dji.sample.media.dao.IFileMapper;
import com.dji.sample.media.model.MediaFileEntity;
import com.dji.sample.patches.config.pojo.PatchesConfigPojo;
import com.dji.sample.patches.dao.ShpToDataSourceMapper;
import com.dji.sample.patches.model.entity.LotInfo;
import com.dji.sample.patches.service.GetPatchesService;
import com.dji.sample.patches.xml.mode.XMLTemplateModel;
import com.dji.sample.patches.xml.utils.CreateWaylineFileUtils;
import com.dji.sample.wayline.model.dto.WaylineFileDTO;
import com.dji.sample.territory.pojo.TerritoryConfigPojo;
import com.dji.sample.territory.service.ITbFJService;
import com.dji.sample.wayline.model.entity.WaylineFileEntity;
import com.dji.sample.wayline.model.enums.WaylineTaskTypeEnum;
import com.dji.sample.wayline.model.param.CreateJobParam;
import com.dji.sample.wayline.service.IWayLineTaskService;
import com.dji.sample.wayline.service.IWaylineFileService;
import com.dji.sample.wayline.service.IWaylineJobService;
import org.locationtech.jts.geom.Coordinate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.*;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.time.LocalDateTime;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.Map;
import java.util.stream.Collectors;
import static com.dji.sample.patches.utils.MultipartFileTOFileUtil.convert;
import static com.dji.sample.patches.utils.ZipUtil.zipFolder;
@@ -40,44 +58,65 @@
    @Autowired
    public IWaylineFileService waylineFileService;
    @Autowired
    private IFileMapper fileMapper;
    @Autowired
    private ITbFJService tbFJService;
    @Autowired
    private GetPatchesService getPatchesService;
    @Autowired
    private IWaylineJobService waylineJobService;
    @Autowired
    private IWayLineTaskService wayLineTaskService;
    private TerritoryConfigPojo territoryConfigPojo;
    /**
     * 定时
     *
     * @throws IOException
     * @throws SQLException
     */
    @Scheduled(cron = "0 25 14 * * ?")
    public void myTask() throws IOException, SQLException {
    @Scheduled(cron = "45 1 16 * * ?")
    public void myTask() throws Exception {
        String workspaceId = "4a574db8-4ad3-48f7-9f16-3edbcd8056e1";
        //获取未规划的图斑集合
        List<LotInfo> list = getNoPlan();
        long timestamp = System.currentTimeMillis();
        String waylineName = "云飞行调查" + timestamp;
        String workspaceId ="4a574db8-4ad3-48f7-9f16-3edbcd8056e1";
        //根据获取的图斑集合获得kmz航线文件
        MultipartFile multipartFile = getFile(waylineName, list);
        //上传航线文件
        String waylineId=backWayline(multipartFile, waylineName, workspaceId, backclaim().getUsername());
        //将为规划的图斑状态更新为已规划
        updateStatu(list);
        //调用publshFlightTask方法创建定时任务
        waylineJobService.publishFlightTask(JobParam(waylineId), backclaim());
//        List<List<LotInfo>> lists = getNoPlan();
//        List<List<LotInfo>> convertedLists = convertToLists(lists);
//        for (List<LotInfo> list : convertedLists) {
//            long timestamp = System.currentTimeMillis();
//            String waylineName = "云飞行调查" + timestamp;
//            //根据获取的图斑集合获得kmz航线文件
//            MultipartFile multipartFile = getFile(waylineName, list);
//            //上传航线文件
//            String waylineId = backWayline(multipartFile, waylineName, workspaceId, backclaim().getUsername());
//            //将为规划的图斑状态更新为已规划
//            updatePatchesStatu(list);
//            //调用publshFlightTask方法创建定时任务
//            waylineJobService.publishFlightTask(JobParam(waylineId), backclaim());
//        }
        List<List<MediaFileEntity>> list = getNoadd();
        List<List<MediaFileEntity>> media = convertToLists(list);
        for (int i = 0; i < media.size(); i++) {
            tbFJService.deleteData();
            String dkbh = getDkbh(media.get(i).get(i).getFileName());
            String taskId = getTaskId(media.get(i).get(i).getFileName());
            LotInfo lotInfo = getPatchesService.getLotinfo(dkbh, workspaceId);
            tbFJService.insertData(media.get(i), lotInfo);
            updateMediaStatu(media.get(i));
            sendPostWithFileAndParameter(territoryConfigPojo.getResult(), taskId);
        }
    }
    public MultipartFile getFile(String waylineName, List<LotInfo> list) throws IOException {
        List<PointPO> coordinates = GeoToolsUtil.getRoutePointOrder(list, 28.218512, 115.856725497);
        List<PointPO> coordinates = GeoToolsUtil.getRoutePointOrder(list, 28.62703, 115.867719);
        XMLTemplateModel xmlModel = XMLTemplateModel.init(coordinates, list);
        CreateWaylineFileUtils.createWaylineFile(xmlModel, patchesConfigPojo.getTemplate(), patchesConfigPojo.getTargetTemplate(), patchesConfigPojo.getWaylines(), patchesConfigPojo.getTargetWaylines());
        String destKMZFile = patchesConfigPojo.getDestKMZFile() + waylineName + ".kmz";
        // 压缩文件夹中的内容
        String destKMZFile = patchesConfigPojo.getDestKMZFile() + waylineName + ".kmz"; // 输出的KMZ文件路径
        zipFolder(patchesConfigPojo.getSourceDir(), destKMZFile);
        MultipartFile multipartFile = convert(new File(destKMZFile));
        return multipartFile;
        return convert(new File(destKMZFile));
    }
    public String backWayline(MultipartFile multipartFile, String waylineName, String workspaceId,String username) {
        waylineFileService.importKmzFileBack(multipartFile, workspaceId,username);
    public String backWayline(MultipartFile multipartFile, String waylineName, String workspaceId, String username) {
        waylineFileService.importKmzFile(multipartFile, workspaceId, username);
        WaylineFileEntity entity = waylineFileService.selectByName(waylineName);
        try {
            waylineFileService.getObjectUrl(workspaceId, entity.getWaylineId());
@@ -87,23 +126,54 @@
        return entity.getWaylineId();
    }
    public List<LotInfo> getNoPlan() {
        return shpToDataSourceMapper.selectList(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getIsplan, 0));
    /**
     * 获取未规划的图斑集合
     *
     * @return
     */
    public List<List<LotInfo>> getNoPlan() {
        List<LotInfo> list = shpToDataSourceMapper.selectList(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getIsPlan, 0));
        List<List<LotInfo>> combinedTasks = list.stream()
                .collect(Collectors.groupingBy(LotInfo::getTaskId))
                .values().stream()
                .map(ArrayList::new)
                .collect(Collectors.toList());
        return combinedTasks;
    }
    public void updateStatu(List<LotInfo> list) {
    /**
     * 更新图斑执行状态
     *
     * @param list
     */
    public void updatePatchesStatu(List<LotInfo> list) {
        for (LotInfo lotInfo : list) {
            lotInfo.setIsplan(1);
            lotInfo.setIsPlan(1);
            shpToDataSourceMapper.updateById(lotInfo);
        }
    }
    public void updateMediaStatu(List<MediaFileEntity> list) {
        for (MediaFileEntity mediaFile : list) {
            mediaFile.setIsadd(1);
            fileMapper.updateById(mediaFile);
        }
    }
    public List<List<MediaFileEntity>> getNoadd() {
        List<MediaFileEntity> list = fileMapper.selectList(new LambdaQueryWrapper<MediaFileEntity>()
                .eq(MediaFileEntity::getIsadd, 0).like(MediaFileEntity::getFileName, "~"));
        List<List<MediaFileEntity>> groupedFilenames = groupTasks(list);
        return groupedFilenames;
    }
    public CreateJobParam JobParam(String waylineId) {
        List<List<Long>> listOfLists = new ArrayList<>();
        List<Long> sublist = new ArrayList<>();
        sublist.add(1714944600L); // 添加整数值
        sublist.add(177271980L); // 添加整数值
        listOfLists.add(sublist);
        List<Long> list = new ArrayList<>();
        list.add(1714944600L);
        list.add(177271980L);
        CreateJobParam param = new CreateJobParam();
        param.setName("云飞行调查");
        param.setTaskType(TIMED);
@@ -111,7 +181,6 @@
        param.setRepFreType(3);
        param.setRepFreVal(1);
        param.setRepRuleType(1);
        param.setExecuteStartTimeArr(listOfLists);
        param.setRthAltitude(80);
        param.setWaylineType(WAYPOINT);
        param.setTaskPeriods(listOfLists);
@@ -120,12 +189,97 @@
        param.setDockSn("4TADKCMB010016");
        return param;
    }
    public CustomClaim backclaim() {
        CustomClaim claim=new CustomClaim();
        CustomClaim claim = new CustomClaim();
        claim.setId("1");
        claim.setUsername("adminPC");
        claim.setWorkspaceId("4a574db8-4ad3-48f7-9f16-3edbcd8056e1");
        claim.setUserType(1);
        return claim;
    }
    public static <T> List<List<T>> convertToLists(List<List<T>> listOfLists) {
        List<List<T>> convertedLists = new ArrayList<>();
        for (List<T> list : listOfLists) {
            convertedLists.add(new ArrayList<>(list));
        }
        return convertedLists;
    }
    // 对任务ID进行分组
    public static List<List<MediaFileEntity>> groupTasks(List<MediaFileEntity> mediaFiles) {
        Map<String, List<MediaFileEntity>> groupedTasks = new HashMap<>();
        for (MediaFileEntity mediaFile : mediaFiles) {
            String taskId = getTaskId(mediaFile.getFileName());
            if (!groupedTasks.containsKey(taskId)) {
                groupedTasks.put(taskId, new ArrayList<>());
            }
            groupedTasks.get(taskId).add(mediaFile);
        }
        return new ArrayList<>(groupedTasks.values());
    }
    // 从filename字段中提取任务ID(假设任务ID在文件名中以"~"开头、"."结尾)
    public static String getTaskId(String filename) {
        // 这里只是一个示例,你需要根据实际情况编写提取task_id的逻辑
        int startIndex = filename.indexOf("~") + 1;
        int endIndex = filename.indexOf(".");
        return filename.substring(startIndex, endIndex);
    }
    public static String getDkbh(String filename) {
        // 这里只是一个示例,你需要根据实际情况编写提取task_id的逻辑
        int startIndex = filename.indexOf("点") + 1;
        int endIndex = filename.indexOf("~");
        return filename.substring(startIndex, endIndex);
    }
    public static void sendPostWithFileAndParameter(String filePath, String taskId) throws IOException {
        // 创建 RestTemplate 实例
        RestTemplate restTemplate = new RestTemplate();
        // 读取文件内容为字节数组
        byte[] fileContent = readFileToBytes(filePath);
        // 构建请求体
        MultiValueMap<String, Object> body = buildRequestBody(taskId, fileContent, filePath);
        // 设置请求头
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.MULTIPART_FORM_DATA);
        // 构建请求实体
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers);
        // 发送请求
        ResponseEntity<String> response = restTemplate.exchange(
                "http://localhost:6789/territory/tbdkjbxx/upload",
                HttpMethod.POST,
                requestEntity,
                String.class);
        // 输出响应结果
        System.out.println("Response: " + response.getBody());
    }
    private static MultiValueMap<String, Object> buildRequestBody(String taskId, byte[] fileContent, String filePath) {
        MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
        body.add("taskId", taskId);
        body.add("file", new ByteArrayResource(fileContent) {
            @Override
            public String getFilename() {
                return Paths.get(filePath).getFileName().toString();
            }
        });
        return body;
    }
    private static byte[] readFileToBytes(String filePath) throws IOException {
        Path path = Paths.get(filePath);
        return Files.readAllBytes(path);
    }
}
src/main/java/com/dji/sample/patches/xml/mode/XMLTemplateModel.java
@@ -75,7 +75,7 @@
//                actionMode.setActionActuatorFuncParam(ActionUtils.setTakePhoto(lotInfos.get(quotient-1).getDkbh()));
                // 设置媒体文件名称后缀
                actionMode.setActionActuatorFuncParam(ActionUtils.setTakePhoto(lotInfos.get(pointPO.getIndex()).getDkbh() + "-" + lotInfos.get(pointPO.getIndex()).getTaskId()));
                actionMode.setActionActuatorFuncParam(ActionUtils.setTakePhoto(lotInfos.get(pointPO.getIndex()).getDkbh() + "~" + lotInfos.get(pointPO.getIndex()).getTaskId()));
//                actionMode.setActionActuatorFuncParam(ActionUtils.setTakePhoto("测试"));
                list.add(actionMode);
src/main/java/com/dji/sample/territory/controller/TbDkjbxxController.java
@@ -74,7 +74,7 @@
    @PostMapping("/upload")
    public ResponseResult uploadFile(@RequestParam("file") MultipartFile file,
                                     @RequestParam String taskName,
                                     @RequestParam int taskId){
                                     @RequestParam String taskId){
        String workspaceId="4a574db8-4ad3-48f7-9f16-3edbcd8056e1";
        tbDkjbxxService.uploadFile(file);
        List<TbDkjbxxEntity> list = tbDkjbxxService.list();
@@ -82,12 +82,16 @@
        return ResponseResult.success("上传成功");
    }
    @PostMapping("/uploadUrl")
    public ResponseResult uploadUrl( @RequestBody UploadUrlParam param){
        tbDkjbxxService.uploadUrl(param.getDbUrl());
    public ResponseResult uploadUrl( @RequestParam String url,
                                     @RequestParam String taskName,
                                     @RequestParam String taskId){
        tbDkjbxxService.uploadUrl(url);
        String workspaceId="4a574db8-4ad3-48f7-9f16-3edbcd8056e1";
        List<TbDkjbxxEntity> list = tbDkjbxxService.list();
        shpToDataSourceService.savaInMysql(list, workspaceId,param.getTaskId(),param.getTaskName());
        shpToDataSourceService.savaInMysql(list, workspaceId,taskId,taskName);
        return ResponseResult.success("上传成功");
    }
src/main/java/com/dji/sample/territory/controller/TbFjController.java
@@ -34,7 +34,7 @@
     * @throws IOException
     */
    @PostMapping("/insertDb")
    public ResponseResult insertDb(String dkbh, String workspaceId) throws IOException {
    public ResponseResult insertDb(String dkbh, String workspaceId) throws Exception {
        List<MediaFileEntity> list = getPatchesService.listPohto(dkbh, workspaceId);
        if (list.size() == 0) {
            return ResponseResult.error("未找到该照片、视频信息");
src/main/java/com/dji/sample/territory/model/entity/param/UploadUrlParam.java
@@ -16,5 +16,5 @@
        private String count;
        private int taskId;
        private String taskId;
}
src/main/java/com/dji/sample/territory/pojo/TerritoryConfigPojo.java
@@ -15,5 +15,8 @@
@Data
public class TerritoryConfigPojo {
    @Value("${db.sqlite.resource}")
    private String Path;
    private String resource;
    @Value("${db.sqlite.result}")
    private String result;
}
src/main/java/com/dji/sample/territory/service/ITbDkjbxxService.java
@@ -27,7 +27,6 @@
     */
    ResponseResult uploadFile(MultipartFile file);
    MultipartFile listFile(String workspaceId, String waylineName, double airportLat, double airportLon) throws IOException;
    ResponseResult uploadUrl(String url);
src/main/java/com/dji/sample/territory/service/ITbFJService.java
@@ -16,5 +16,6 @@
     * @return
     * @throws IOException
     */
    int insertData(List<MediaFileEntity> mediaFile, LotInfo lotInfo) throws IOException;
    int insertData(List<MediaFileEntity> mediaFile, LotInfo lotInfo) throws Exception;
    void deleteData();
}
src/main/java/com/dji/sample/territory/service/impl/TbDkjbxxServiceImpl.java
@@ -33,6 +33,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import static com.dji.sample.patches.utils.MultipartFileTOFileUtil.convert;
import static com.dji.sample.patches.utils.ZipUtil.zipFolder;
@@ -75,7 +76,7 @@
            // 获取上传的文件输入流
            InputStream inputStream = file.getInputStream();
            // 创建输出流,将文件内容写入资源文件
            OutputStream outputStream = new FileOutputStream(territoryConfigPojo.getPath());
            OutputStream outputStream = new FileOutputStream(territoryConfigPojo.getResource());
            byte[] buffer = new byte[1024];
            int bytesRead;
            while ((bytesRead = inputStream.read(buffer)) != -1) {
@@ -121,30 +122,29 @@
        if (url.isEmpty()) {
            throw new IllegalArgumentException("上传文件为空");
        }
        downloadFile(url);
        String saveFilePath = territoryConfigPojo.getResource(); // 要保存文件的本地路径
        try {
            downloadFile(url, saveFilePath);
            System.out.println("文件下载完成");
        } catch (IOException e) {
            System.out.println("下载文件时发生错误:" + e.getMessage());
        }
        return ResponseResult.success();
    }
    public File downloadFile(String fileUrl) {
        File downloadedFile = null;
        try {
            URL url = new URL(fileUrl);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            InputStream inputStream = connection.getInputStream();
            downloadedFile = new File(territoryConfigPojo.getPath());
            OutputStream outputStream = new FileOutputStream(downloadedFile);
            byte[] buffer = new byte[1024];
            int bytesRead;
            while ((bytesRead = inputStream.read(buffer)) != -1) {
                outputStream.write(buffer, 0, bytesRead);
            }
            inputStream.close();
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    public static void downloadFile(String fileUrl, String saveFilePath) throws IOException {
        // 创建URL对象
        URL url = new URL(fileUrl);
        return downloadedFile;
        // 打开连接
        try (BufferedInputStream in = new BufferedInputStream(url.openStream());
             FileOutputStream fileOutputStream = new FileOutputStream(saveFilePath)) {
            byte[] dataBuffer = new byte[1024];
            int bytesRead;
            while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
                fileOutputStream.write(dataBuffer, 0, bytesRead);
            }
        }
    }
    /**
src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java
@@ -8,8 +8,10 @@
import com.dji.sample.territory.dao.ITbFjMapper;
import com.dji.sample.territory.model.entity.TbFjEntity;
import com.dji.sample.territory.service.ITbFJService;
import com.dji.sample.territory.utils.Sm3Util;
import com.dji.sample.territory.utils.VideoZipUtil;
import com.dji.sample.territory.utils.WaterMarkUtil;
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -22,6 +24,8 @@
import java.util.UUID;
import static com.dji.sample.territory.utils.CoordinateSystemUtil.*;
import static com.dji.sample.territory.utils.SM2SignUtil.getSM2PrivateKey;
import static com.dji.sample.territory.utils.SM2SignUtil.signWithSM2;
@Service
@DS("sqlite-ret")
@@ -40,7 +44,7 @@
     * @throws IOException
     */
    @Transactional
    public int insertData(List<MediaFileEntity> mediaFile, LotInfo lotInfo) throws IOException {
    public int insertData(List<MediaFileEntity> mediaFile, LotInfo lotInfo) throws Exception {
        int count = 0;
        List<TbFjEntity> list = new ArrayList<>();
        TbFjEntity tbFj;
@@ -54,6 +58,11 @@
        return count;
    }
    @Override
    public void deleteData() {
        tbFjMapper.delete(null);
    }
    /**
     * 将Media和Lotinfo实体类转化为TbFjEntity实体类
     *
@@ -62,7 +71,7 @@
     * @return
     * @throws IOException
     */
    private TbFjEntity dbConvertToEntity(MediaFileEntity mediaFile, LotInfo lotInfo) throws IOException {
    private TbFjEntity dbConvertToEntity(MediaFileEntity mediaFile, LotInfo lotInfo) throws Exception {
        File file1 = null;
        byte[] FJ = null;
        String jsonString = JSONObject.toJSONString(mediaFile.getMetadata());
@@ -80,9 +89,8 @@
        int psjd = 0;
        String fjhxz = "0";
        int pshgj = 0;
        String jym = "0";
        String psry = "0";
        String zsdm = "0";
        String zsdm = "23C8CCC61E3042FBA6A658F319337B1A";
        String dklx = "0";
        String xzqdm = "0";
        int fjlx = 1;
@@ -102,6 +110,13 @@
            file1 = VideoZipUtil.compressVideo(file, 800000, 128000, 1280, 720);
            FJ = fileToByteArray(file1);
        }
        String sm3 = Sm3Util.calculateSM3Hash(fjhxz+","+pssj+","+lng+","+lat+","+gimbalYawDegree+","+psjd+","+pshgj+","+psry+","+zsdm);
        byte[] hash = sm3.getBytes(); // 注意:使用SM3或其他哈希算法来计算数据的哈希值
        // 加载私钥
        ECPrivateKeyParameters sm2PrivateKey = getSM2PrivateKey();
        // 使用SM2私钥对哈希值进行签名
        String signatureHex = signWithSM2(hash, sm2PrivateKey);
        TbFjEntity.TbFjEntityBuilder builder = TbFjEntity.builder();
        if (lotInfo != null) {
            builder.bsm(bsm)
@@ -122,12 +137,13 @@
                    .pshgj(pshgj)
                    .zsdm(zsdm)
                    .psry(psry)
                    .jym(jym)
                    .jym(signatureHex)
                    .url(url)
                    .build();
        } else {
            throw new IllegalArgumentException("未匹配到相关地块");
        }
//        else {
////            throw new IllegalArgumentException("未匹配到相关地块");
//        }
        return builder.build();
    }
src/main/resources/application-dev.yml
@@ -114,4 +114,5 @@
db:
  sqlite:
    resource: DB/resource_db.db
    resource: DB/resource_db.db
    result: DB/result_db.db
src/main/resources/application-prod.yml
@@ -113,4 +113,5 @@
db:
  sqlite:
    resource: /home/drone/server/sqlite/resource_db.db
    resource: /home/drone/server/sqlite/resource_db.db
    result: /home/drone/server/sqlite/result_db.db