rain
2024-06-11 6c321434d8f0bc78ae86640653eccbf4cfc2c1d3
src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java
@@ -1,8 +1,10 @@
package com.dji.sample.territory.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.dji.sample.media.model.MediaFileEntity;
import com.dji.sample.media.util.ImgUtil;
import com.dji.sample.patches.config.pojo.PatchesConfigPojo;
import com.dji.sample.patches.model.entity.LotInfo;
import com.dji.sample.territory.dao.ITbFjMapper;
@@ -72,7 +74,7 @@
    public void insertOneData(MediaFileEntity mediaFile, LotInfo lotInfo) throws Exception {
        TbFjEntity tbFj = dbConvertToEntity(mediaFile, lotInfo);
        if (tbFj.getFjysgd()==3000){
        if (tbFj.getFjysgd() == 3000) {
            tbFjMapper.insert(tbFj);
        }
    }
@@ -106,7 +108,7 @@
//        double x = Double.parseDouble(((formatCoordinate(coordinates[1]))));
//        double y = Double.parseDouble(((formatCoordinate(coordinates[0]))));
        //本地数据库没有的数据在FJ表非空用0
        int psjd = 0;
        double psjd = WaterMarkUtil.convertAngle(gimbalYawDegree);
        int pshgj = 0;
        String psry = "中图智绘无人机";
        String zsdm = "23C8CCC61E3042FBA6A658F319337B1A";
@@ -120,6 +122,16 @@
        String head = "http://dev.jxpskj.com:9000/cloud-bucket";
        String url = head + key;
        File file = downloadFile(url);
//        JSONObject jsonObjects = JSONObject.parseObject(ImgUtil.getInfo(file));
        JSONObject jsons = (JSONObject) (ImgUtil.getInfo(file));
        String str = jsons.toJSONString();
        String newstr = str.replace("+", "");
        JSONObject json = JSON.parseObject(newstr);
        Double pitch = json.getDouble("GimbalPitchDegree");
        String focal = json.getString("FocalLength");
        String numberPart = focal.replaceAll("[^\\d]", "");
        int psjj = Integer.parseInt(numberPart);
        json.getString("GimbalYawDegree");
        String fjhxz = HashUtil.SM3Hash(file);
        BufferedImage image = ImageIO.read(file);
        int width = image.getWidth();
@@ -127,15 +139,14 @@
        //对应图片和视频文件进行不同处理
        boolean endsWith = key.endsWith(".mp4");
        if (!endsWith) {
            file1 = WaterMarkUtil.addWatermark(file,  sj, lat, lng, gimbalYawDegree);
            file1 = WaterMarkUtil.addWatermark(file, sj, lat, lng, gimbalYawDegree);
            FJ = fileToByteArray(file1);
        } else {
            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或其他哈希算法来计算数据的哈希值
        String hxz = HashUtil.calculateHash((fjhxz + "," + pssj + "," + lng + "," + lat + "," + gimbalYawDegree + "," + psjd + "," + pshgj + "," + psry + "," + zsdm).getBytes());
        byte[] hash = hxz.getBytes(); // 注意:使用SM3或其他哈希算法来计算数据的哈希值
        // 加载私钥
        ECPrivateKeyParameters sm2PrivateKey = getSM2PrivateKey();
        // 使用SM2私钥对哈希值进行签名
@@ -151,11 +162,12 @@
                    .Latitude(truncateToSevenDecimalPlaces(lat))
                    .longitude(truncateToSevenDecimalPlaces(lng))
                    .fj(FJ)
                    .psjj(psjj)
                    .fjmc(fjmc)
                    .fjlx(fjlx)
                    .psfyj(gimbalYawDegree)
                    .psfyj(pitch)
                    .pssj(pssj)
                    .psjd(psjd)
                    .psjd((int) psjd)
                    .fjhxz(fjhxz)
                    .pshgj(pshgj)
                    .zsdm(zsdm)
@@ -235,6 +247,7 @@
        BigDecimal bd = new BigDecimal(value).setScale(2, RoundingMode.DOWN);
        return bd.doubleValue();
    }
    public static Double truncateToSevenDecimalPlaces(Double value) {
        if (value == null) {
            return null;  // 处理null值情况