From 28f661933ffdeb1f65ecee52f8f4b7a3b373da9b Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Mon, 03 Jun 2024 18:29:52 +0800
Subject: [PATCH] 完善图斑功能,完善水印,增加图片的角度信息

---
 src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java b/src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java
index 816a922..afc83aa 100644
--- a/src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java
+++ b/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,7 +139,7 @@
         //对应图片和视频文件进行不同处理
         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);
@@ -151,11 +163,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 +248,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值情况

--
Gitblit v1.9.3