From 506168ae540c5aabb34f97a46a6248cd73b77f8b Mon Sep 17 00:00:00 2001
From: whycxzp <glperry@163.com>
Date: 星期三, 02 四月 2025 00:46:03 +0800
Subject: [PATCH] 更新计算

---
 src/main/java/com/whyc/service/BattStationTempAlarmService.java |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/whyc/service/BattStationTempAlarmService.java b/src/main/java/com/whyc/service/BattStationTempAlarmService.java
index 90275be..94ef711 100644
--- a/src/main/java/com/whyc/service/BattStationTempAlarmService.java
+++ b/src/main/java/com/whyc/service/BattStationTempAlarmService.java
@@ -4,9 +4,12 @@
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.whyc.dto.Point;
 import com.whyc.dto.Response;
 import com.whyc.mapper.BattStationTempAlarmMapper;
 import com.whyc.pojo.db_alarm.BattStationTempAlarm;
+import com.whyc.util.HikTempUtil;
+import com.whyc.util.PointUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -21,6 +24,37 @@
     public Response<PageInfo<BattStationTempAlarm>> getPage(int pageNum, int pageSize, Integer level) {
         PageHelper.startPage(pageNum,pageSize);
         List<BattStationTempAlarm> list = mapper.getList(level);
+        //瀵硅繖浜涘憡璀﹁繘琛岃绠楀湪纾佹潯鍝竟,骞惰绠椾笌纾佹潯鐨勫瀭鐩寸嚎鐨勭櫨鍒嗘瘮
+        list.forEach(alarm->{
+            Integer battGroupId = alarm.getBattGroupId();
+            //灏唌axTempPoint杩涜瑙f瀽锛屽緱鍒皒,y鍧愭爣,骞舵斁鍏oint瀵硅薄涓� TODO 杩欓噷鏆傚畾鏈�澶ф俯搴﹀搴旂殑鐐逛负1涓潗鏍�
+            String maxTempPoint = alarm.getMaxTempPoint();
+            String[] split = maxTempPoint.split("\\*");
+            Point tempPoint = new Point(Integer.valueOf(split[0]),Integer.valueOf(split[1]));
+            //纾佹潯鐨勫潗鏍�,鏍煎紡涓� x1*y1,x2*y2
+            String mstPoints = HikTempUtil.cameraInfoList.stream().filter(c -> c.getBattGroupId().equals(battGroupId)).findFirst().get().getMstPoints();
+            String[] mstPointsSplit = mstPoints.split(",");
+            Point mstPointStart = null;
+            Point mstPointEnd = null;
+            for (int i = 0; i < mstPointsSplit.length; i++) {
+                String mstPointsStr = mstPointsSplit[i];
+                if (i == 0) {
+                    mstPointStart = new Point(Integer.valueOf(mstPointsStr.split("\\*")[0]),Integer.valueOf(mstPointsStr.split("\\*")[1]));
+                }else{
+                    mstPointEnd = new Point(Integer.valueOf(mstPointsStr.split("\\*")[0]),Integer.valueOf(mstPointsStr.split("\\*")[1]));
+                }
+            }
+            //璁$畻tempPoint鍧愭爣鐐瑰湪 mstPointStart鍜宮stPointEnd缁勬垚鐨勭嚎鐨勫摢杈�
+            String position = PointUtil.determinePosition(mstPointStart.getX(), mstPointEnd.getX(), mstPointStart.getY(), mstPointEnd.getY(), tempPoint.getX(), tempPoint.getY());
+            //璁$畻tempPoint涓庣嚎鐨勫瀭瓒�
+            Point footPoint = PointUtil.findIntersection2(mstPointStart, mstPointEnd, tempPoint);
+            //鍒ゆ柇鍨傝冻footPoint涓巑stPointStart鍜宮stPointEnd缁勬垚鐨勭嚎娈�,鍦ㄧ嚎涓婅繕鏄湪寤堕暱绾夸笂
+            double pointPercentage = PointUtil.calculateProportion(footPoint.getX(), footPoint.getY(), mstPointStart.getX(), mstPointStart.getY(), mstPointEnd.getX(), mstPointEnd.getY());
+
+            alarm.setPosition(position);
+            alarm.setPointPercentage(pointPercentage);
+
+        });
         PageInfo<BattStationTempAlarm> pageInfo = new PageInfo<>(list);
         return new Response<PageInfo<BattStationTempAlarm>>().set(1,pageInfo);
     }
@@ -35,6 +69,7 @@
     public BattStationTempAlarm getByBattGroupId(int battGroupId) {
         QueryWrapper<BattStationTempAlarm> query = Wrappers.query();
         query.eq("batt_group_id",battGroupId);
+        query.isNull("end_time");
         return mapper.selectOne(query);
     }
 

--
Gitblit v1.9.1