From 0771b90c0e49714e1682dc133d1bebafb545dd5a Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期六, 02 三月 2024 19:45:12 +0800
Subject: [PATCH] app无人机航线管理提交
---
ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java | 127 ++++++++++++++++++++++++++++++------------
1 files changed, 91 insertions(+), 36 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java b/ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java
index 214523c..bf31f63 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java
@@ -26,6 +26,7 @@
import org.eclipse.paho.client.mqttv3.MqttException;
import java.awt.geom.Point2D;
+import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -176,42 +177,7 @@
}
}
//杞﹁締鏈夊�间紭鍏堝垽鏂槸鍚︿负鎵嬪姩娣诲姞杞﹁締
- if(ardAccessFence.getIsAlarm()==1){
- //1涓烘墜鍔ㄦ坊鍔犺溅杈嗘棤闇�鎶ヨ淇℃伅锛屾洿鏂颁綅缃嵆鍙�
- ardAccessFence.setLng(lng);
- ardAccessFence.setLat(lat);
- ardAccessFenceService.updAccess(ardAccessFence);
- }else if(ardAccessFence.getIsAlarm() == 2){
- //2涓烘墜鍔ㄦ坊鍔犳姤璀﹁溅杈嗘湁鎶ヨ锛屾墍鍦ㄥ洿鏍忓悕绉拌祴null,鎺掓煡鎶ヨ淇℃伅,鍙渶澶勭悊璺笂鎯呭喌
- ardAccessFence.setNowWallName(null);
- //濡傛灉鍦ㄨ矾涓婂垽鏂潗鏍囨槸鍚︿笌涓婃涓�鏍�
- if(ardAccessFence.getLng().equals(lng) && ardAccessFence.getLat().equals(lat)){
- if(timeType){
- Date nowTime = sdf.parse(time);
- Date lastTime = sdf.parse(ardAccessFence.getLastTime());
- Long diff = (nowTime.getTime() - lastTime.getTime())/1000;
- ArdAccessNum list = accessNumService.queryNum();
- if(list!=null){
- int alarm = list.getAlarm();
- if(diff>=alarm){
- //鎶ヨ瀛楁涓�1鎻愮ず鎶ヨ
- ardAccessFence.setIsWarning(1);
- ardAccessFence.setAlarmLat(lat);
- ardAccessFence.setAlarmLng(lng);
- ardAccessFenceService.updAccess(ardAccessFence);
- }
- }
- }else {
- log.debug(carId+"鍙疯溅瀹氫綅鏃堕棿涓虹┖");
- }
- }else {
- //濡傛灉涓嶄竴鏍锋洿鏂板潗鏍�
- ardAccessFence.setLat(lat);
- ardAccessFence.setLng(lng);
- ardAccessFence.setLastTime(time);
- ardAccessFenceService.updAccess(ardAccessFence);
- }
- }else if(ardAccessFence.getIsAlarm() == 0 || ardAccessFence.getIsAlarm() == null){
+ if(ardAccessFence.getIsAlarm() == 0 || ardAccessFence.getIsAlarm() == null){
//杞﹁締闈炴墜鍔ㄦ坊鍔犳暟鎹紝鍒ゆ柇鏄惁鏈夎繘鍏ュ洿鏍廔D
if(ardAccessFence.getIntoShipmentId()==null){
//娌℃湁杩涘叆瑁呮补鐐癸紝璧嬪�肩粡绾害
@@ -367,6 +333,42 @@
}
}
}
+ }else
+ if(ardAccessFence.getIsAlarm()==1){
+ //1涓烘墜鍔ㄦ坊鍔犺溅杈嗘棤闇�鎶ヨ淇℃伅锛屾洿鏂颁綅缃嵆鍙�
+ ardAccessFence.setLng(lng);
+ ardAccessFence.setLat(lat);
+ ardAccessFenceService.updAccess(ardAccessFence);
+ }else if(ardAccessFence.getIsAlarm() == 2){
+ //2涓烘墜鍔ㄦ坊鍔犳姤璀﹁溅杈嗘湁鎶ヨ锛屾墍鍦ㄥ洿鏍忓悕绉拌祴null,鎺掓煡鎶ヨ淇℃伅,鍙渶澶勭悊璺笂鎯呭喌
+ ardAccessFence.setNowWallName(null);
+ //濡傛灉鍦ㄨ矾涓婂垽鏂潗鏍囨槸鍚︿笌涓婃涓�鏍�
+ if(ardAccessFence.getLng().equals(lng) && ardAccessFence.getLat().equals(lat)){
+ if(timeType){
+ Date nowTime = sdf.parse(time);
+ Date lastTime = sdf.parse(ardAccessFence.getLastTime());
+ Long diff = (nowTime.getTime() - lastTime.getTime())/1000;
+ ArdAccessNum list = accessNumService.queryNum();
+ if(list!=null){
+ int alarm = list.getAlarm();
+ if(diff>=alarm){
+ //鎶ヨ瀛楁涓�1鎻愮ず鎶ヨ
+ ardAccessFence.setIsWarning(1);
+ ardAccessFence.setAlarmLat(lat);
+ ardAccessFence.setAlarmLng(lng);
+ ardAccessFenceService.updAccess(ardAccessFence);
+ }
+ }
+ }else {
+ log.debug(carId+"鍙疯溅瀹氫綅鏃堕棿涓虹┖");
+ }
+ }else {
+ //濡傛灉涓嶄竴鏍锋洿鏂板潗鏍�
+ ardAccessFence.setLat(lat);
+ ardAccessFence.setLng(lng);
+ ardAccessFence.setLastTime(time);
+ ardAccessFenceService.updAccess(ardAccessFence);
+ }
}
}
//娓呮筏缁撴潫------------
@@ -408,6 +410,28 @@
PositionContainer.getDeptPositionMap().put(deptIdp,deptMapp);
}else{
deptMapp.put((String)gpsMap.get("carId"),gpsMap);
+ }
+ }
+ }
+ //鑻ユ湁鐢ㄦ埛闇�瑕佽拷韪溅杈嗭紝鍒欒绠楅浼颁綅缃�
+ if(PositionContainer.getUserPositionMap().size() != 0){
+ for(String userId : PositionContainer.getUserPositionMap().keySet()){
+ Map<String,Map<String,Object>> carIdCarMap = PositionContainer.getUserPositionMap().get(userId);
+ if(carIdCarMap != null){
+ if(carIdCarMap.keySet().contains(carId)){
+ if(PositionContainer.getCarPositionMap().get(carId) == null){
+ gpsMap.put("elng",gpsMap.get("lng"));
+ gpsMap.put("elat",gpsMap.get("lat"));
+ }else{
+ Double velocityOld = ((Integer) PositionContainer.getCarPositionMap().get(carId).get("speed")).doubleValue();
+ Double velocityNew = ((Integer) gpsMap.get("speed")).doubleValue();
+ Double acceleration = Double.valueOf(1000*(velocityNew - velocityOld)/3600);
+ Double distance = getDistance(velocityNew, acceleration ,"1.5");
+ Double[] eposition = azimuth_offset(((BigDecimal)gpsMap.get("lng")).doubleValue(),((BigDecimal)gpsMap.get("lat")).doubleValue(),(Integer)gpsMap.get("drct"),distance);
+ gpsMap.put("elng",eposition[0]);
+ gpsMap.put("elat",eposition[1]);
+ }
+ }
}
}
}
@@ -572,4 +596,35 @@
}
}
}
+
+ public Double[] azimuth_offset(double origin_lon, double origin_lat, Integer direction,double distance){
+ Double[] lonlat = new Double[2];
+ if(direction != null && distance > 0){
+ lonlat[0] = origin_lon + distance * Math.sin(direction* Math.PI / 180) * 180 / ( Math.PI * 6371229 * Math.cos(origin_lat * Math.PI / 180));
+ lonlat[1] = origin_lat + distance * Math.cos(direction* Math.PI / 180) / ( Math.PI * 6371229 / 180);
+ }else{
+ lonlat[0] = origin_lon;
+ lonlat[1] = origin_lat;
+ }
+ return lonlat;
+ }
+
+ public Double getDistance(Double velocity ,Double acceleration ,String time){
+ Double distance = velocity*Double.parseDouble(time) + 0.5*acceleration*Double.parseDouble(time)*Double.parseDouble(time);
+ return distance;
+ }
+
+ /*public Double getVelocity(Double velocity ,Double acceleration ,String time){
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ Long t = (long) 0;
+ try {
+ t = (new Date().getTime() - simpleDateFormat.parse(time).getTime())/1000;
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Double velocityt = velocity + acceleration*t;
+ return velocityt;
+ }*/
+
}
--
Gitblit v1.9.3