From 748ab31dc10c24dd4cdfffdcbc39527d1f79ae12 Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期一, 05 二月 2024 16:20:38 +0800
Subject: [PATCH] 三一车辆追踪加入预推送位置提交
---
ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java | 4 ++++
2 files changed, 58 insertions(+), 0 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..83c365d 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.*;
@@ -411,6 +412,28 @@
}
}
}
+ //鑻ユ湁鐢ㄦ埛闇�瑕佽拷韪溅杈嗭紝鍒欒绠楅浼颁綅缃�
+ 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]);
+ }
+ }
+ }
+ }
+ }
//瀛樺叆瀹炴椂浣嶇疆瀹瑰櫒
PositionContainer.getCarPositionMap().put(carId,gpsMap);
//瀛樺叆鐢ㄦ埛瀹瑰櫒
@@ -572,4 +595,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;
+ }*/
+
}
diff --git a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
index 69cf50d..de5e323 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
@@ -930,6 +930,8 @@
Map<String, Object> position = PositionContainer.getCarPositionMap().get(carId);//鏌ヨ褰撳墠杞﹁締浣嶇疆
if (position != null) {
if (position.size() != 0) {
+ position.put("elng",position.get("lng"));
+ position.put("elat",position.get("lat"));
Map<String, Map<String, Object>> data = new HashMap();
data.put("31000", position);
WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data));
@@ -970,6 +972,8 @@
Map<String, Object> position = PositionContainer.getCarPositionMap().get(carId);//鏌ヨ褰撳墠杞﹁締浣嶇疆
if (position != null) {
if (position.size() != 0) {
+ position.put("elng",position.get("lng"));
+ position.put("elat",position.get("lat"));
Map<String, Map<String, Object>> data = new HashMap();
data.put("31000", position);
WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data));
--
Gitblit v1.9.3