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 | 341 ++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 216 insertions(+), 125 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 f360ce8..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
@@ -20,11 +20,13 @@
import com.ruoyi.utils.qymqtt.newM.EmqClient;
import com.ruoyi.utils.qymqtt.newM.QosEnum;
import com.ruoyi.utils.qymqtt.oldM.MqttCustomerClient;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.paho.client.mqttv3.MqttException;
import java.awt.geom.Point2D;
+import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -35,9 +37,10 @@
* @author chencq
* @version 1.0
*/
+@Slf4j(topic = "mqttCar")
public class PushClientImplPosition extends PushClient implements Runnable {
- private static final Log log = LogFactory.getLog(PushClientImplPosition.class);
+// private static final Log log = LogFactory.getLog(PushClientImplPosition.class);
private String ip;
@@ -78,24 +81,35 @@
/*String carName = MapUtil.getStrVal(gpsMap, "carName","");//鑾峰彇杞︾墝鍙�
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(new Date()));*/
-// log.info(String.format(" ---->鏀跺埌瀹氫綅鏁版嵁:%s",JSON.toJSONString(gpsMap)));
+ log.debug(String.format(" ---->----鏀跺埌瀹氫綅鏁版嵁濡備笅:%s",JSON.toJSONString(gpsMap)));
String carId = (String)gpsMap.get("carId");
-
((ArdSyCarDayServiceImpl)SpringUtils.getBean("ardSyCarDayServiceImpl")).insertArdSyCarDay(carId);//鏂板杞﹁締涓婃姤鏃堕棿
Map<String,Object> result = ((ArdSyCarServiceImpl)SpringUtils.getBean("ardSyCarServiceImpl")).getArdSyCarAndDeptByCarId(carId);//鏌ヨ杞﹁締鍙婇儴闂�
if(result != null){
-// if("30".equals(carId)){
- //娓呮筏寮�濮�----------
+ //娓呮筏寮�濮�----------
+ try{
String lng = (String) gpsMap.get("lng").toString();//鑾峰彇缁忓害
String lat = (String) gpsMap.get("lat").toString();//鑾峰彇绾害
String carName = (String) gpsMap.get("carName");//鑾峰彇杞︾墝鍙�
- String time = (String) gpsMap.get("result");//瀹氫綅鏃堕棿
+ String time = (String) gpsMap.get("time");//瀹氫綅鏃堕棿
+ //鏃堕棿鐘舵��
+ Boolean timeType = true;
+ if(time==null || time == ""){
+ timeType = false;
+ }
String deptNum = (String) result.get("deptId").toString();//鑾峰彇閮ㄩ棬ID
String deptName = (String) result.get("deptName");//鑾峰彇閮ㄩ棬鍚嶇О
String carModel = (String) result.get("carModel");//鑾峰彇杞﹁締妯″瀷
Integer drct = (Integer) gpsMap.get("drct");//鑾峰彇杞﹁締妯″瀷
- Integer speed = (Integer) gpsMap.get("speed");
- log.debug("瀹氫綅鏁版嵁锛歝arId:"+carId+"lng:"+lng+"lat:"+lat);
+ Integer speed = (Integer) gpsMap.get("speed");//杞﹂��
+ String reserved = (String) result.get("reserved_1");//rtu鍏宠仈
+ //rtu鏍囪瘑
+ boolean rtuType = true;
+ if(reserved==null || reserved==""){
+ //鏃犻攣
+ rtuType = false;
+ }
+ // log.debug("瀹氫綅鏁版嵁锛氳溅杈哻arId:"+carId+"缁忓害lng:"+lng+"绾害lat:"+lat);
//瀹氫箟2缁寸┖闂�
Point2D.Double point = new Point2D.Double(Double.parseDouble(lng), Double.parseDouble(lat));
List<Point2D.Double> pts = new ArrayList<Point2D.Double>();
@@ -114,15 +128,7 @@
//鏌ヨ鎵�鏈夎娌圭偣鍥存爮
List<ArdOilWall> ardOilWalls = ardOilWallService.accessAll();
//鏃ユ湡鏍煎紡
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- //杞﹂�熸爣璁�
- Boolean stop = true;
- //鍒ゆ柇杞﹂��
- if(speed>5){
- //mqtt鍙戦�佹棦瀹歊tu鐘舵��
- feng(carId,"鏂藉皝",carRtuService,lockService);
- stop = false;
- }
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
//濡傛灉娌℃湁璇存槑杞﹁締鏈繘鍏ヨ娌圭偣锛岄渶瑕佸尮閰嶆墍鏈夎娌圭偣鍥存爮
if(ardAccessFence==null){
//杞﹁締鏈繘鍏ヨ娌圭偣
@@ -152,47 +158,26 @@
ardAccessFence1.setDrct(drct);
ardAccessFence1.setIsAlarm(0);
ardAccessFenceService.access(ardAccessFence1);
- if(stop){
+ if(rtuType){
//mqtt鍙戦�佹棦瀹歊tu鐘舵��
feng(carId,"瑁呮补鐐�",carRtuService,lockService);
+ break;
}
- break;
}
}
}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)){
- 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 {
- //濡傛灉涓嶄竴鏍锋洿鏂板潗鏍�
- ardAccessFence.setLat(lat);
- ardAccessFence.setLng(lng);
- ardAccessFence.setLastTime(time);
- ardAccessFenceService.updAccess(ardAccessFence);
+ //杞﹂�熸爣璁�
+ Boolean stop = true;
+ //鍒ゆ柇杞﹂��
+ if(rtuType){
+ if(speed>5){
+ //mqtt鍙戦�佹棦瀹歊tu鐘舵��
+ feng(carId,"鏂藉皝",carRtuService,lockService);
+ stop = false;
}
- }else if(ardAccessFence.getIsAlarm() == 0 || ardAccessFence.getIsAlarm() == null){
+ }
+ //杞﹁締鏈夊�间紭鍏堝垽鏂槸鍚︿负鎵嬪姩娣诲姞杞﹁締
+ if(ardAccessFence.getIsAlarm() == 0 || ardAccessFence.getIsAlarm() == null){
//杞﹁締闈炴墜鍔ㄦ坊鍔犳暟鎹紝鍒ゆ柇鏄惁鏈夎繘鍏ュ洿鏍廔D
if(ardAccessFence.getIntoShipmentId()==null){
//娌℃湁杩涘叆瑁呮补鐐癸紝璧嬪�肩粡绾害
@@ -212,9 +197,11 @@
ardAccessFence.setIntoShipmentTime(time);
ardAccessFence.setNowWallName("杩涘叆瑁呮补鐐癸細"+ardOilWall.getName());
ardAccessFence.setLastTime(time);
- if(stop){
- //mqtt鍙戦�佹棦瀹歊tu鐘舵��
- feng(carId,"瑁呮补鐐�",carRtuService,lockService);
+ if(rtuType){
+ if(stop){
+ //mqtt鍙戦�佹棦瀹歊tu鐘舵��
+ feng(carId,"瑁呮补鐐�",carRtuService,lockService);
+ }
}
break;
}
@@ -242,8 +229,10 @@
ardAccessFence.setLng(lng);
ardAccessFence.setLat(lat);
ardAccessFenceService.updAccess(ardAccessFence);
- //寮�鍑鸿娌圭偣鍥存爮锛屽彂閫佷笂閿佸強鏂藉皝鍛戒护
- feng(carId,"鏂藉皝",carRtuService,lockService);
+ if(rtuType){
+ //寮�鍑鸿娌圭偣鍥存爮锛屽彂閫佷笂閿佸強鏂藉皝鍛戒护
+ feng(carId,"鏂藉皝",carRtuService,lockService);
+ }
}
}else {
//杞﹁締宸茬粡寮�鍑鸿娌圭偣锛屾煡鐪嬫槸鍚︽湁鍗告补鐐笽D
@@ -273,9 +262,11 @@
ardAccessFenceService.updAccess(ardAccessFence);
//宸茬粡杩涘叆鍗告补鐐癸紝涓嶅湪璺笂涓嶉渶瑕佸仠杞︽姤璀�
isRoad = false;
- if(stop){
- //mqtt鍙戦�佹棦瀹歊tu鐘舵��
- feng(carId,"鍗告补鐐�",carRtuService,lockService);
+ if(rtuType){
+ if(stop){
+ //mqtt鍙戦�佹棦瀹歊tu鐘舵��
+ feng(carId,"鍗告补鐐�",carRtuService,lockService);
+ }
}
break;
}
@@ -287,19 +278,23 @@
//濡傛灉鍦ㄨ矾涓婂垽鏂潗鏍囨槸鍚︿笌涓婃涓�鏍�
if(ardAccessFence.getLng().equals(lng) && ardAccessFence.getLat().equals(lat)){
if(ardAccessFence.getLastTime()!=null){
- //濡傛灉鍧愭爣涓�鏍风浉鍑�
- 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){
- ardAccessFence.setIsWarning(1);
- ardAccessFence.setAlarmLat(lat);
- ardAccessFence.setAlarmLng(lng);
- ardAccessFenceService.updAccess(ardAccessFence);
+ 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){
+ ardAccessFence.setIsWarning(1);
+ ardAccessFence.setAlarmLat(lat);
+ ardAccessFence.setAlarmLng(lng);
+ ardAccessFenceService.updAccess(ardAccessFence);
+ }
}
+ }else {
+ log.debug(carId+"鍙疯溅瀹氫綅鏃堕棿涓虹┖");
}
}else {
ardAccessFence.setLastTime(time);
@@ -322,8 +317,10 @@
pts.add(new Point2D.Double(Double.parseDouble(coord[j]), Double.parseDouble(coord[j + 1])));
}
if (!GeoTools.IsPtInPoly(point, pts)) {
- //寮�鍑轰簡鍗告补鐐瑰洿鏍忥紝鍙戦�佷笂閿佸強鏂借В灏佹寚浠�
- feng(carId,"鏂藉皝",carRtuService,lockService);
+ if(rtuType){
+ //寮�鍑轰簡鍗告补鐐瑰洿鏍忥紝鍙戦�佷笂閿佸強鏂借В灏佹寚浠�
+ feng(carId,"鏂藉皝",carRtuService,lockService);
+ }
//鍒犻櫎璇ユ潯杞﹁締鏁版嵁
ardAccessFenceService.delAccess(carId);
}else {
@@ -336,10 +333,48 @@
}
}
}
+ }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);
+ }
}
-// }
+ }
+ //娓呮筏缁撴潫------------
+ }catch(Exception e){
+
}
- //娓呮筏缁撴潫------------
gpsMap.putAll(result);
String ancestors = (String) gpsMap.get("ancestors");//鑾峰彇鐖剁骇閮ㄩ棬
@@ -378,6 +413,30 @@
}
}
}
+ //鑻ユ湁鐢ㄦ埛闇�瑕佽拷韪溅杈嗭紝鍒欒绠楅浼颁綅缃�
+ 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);
//瀛樺叆鐢ㄦ埛瀹瑰櫒
if(PositionContainer.getUserPositionMap().size() != 0){
for(String userId : PositionContainer.getUserPositionMap().keySet()){
@@ -458,77 +517,78 @@
//1瑙e皝
if(fengType==1){
//濡傛灉涓嶆槸瑙e皝灏佺姸鎬侊紝鍒欏彂閫佹柦灏佸懡浠�
- if(ardSyCarLocks.get(0).getRelayInfo()!=null){
- if(ardSyCarLocks.get(0).getRelayInfo()==0){
+ if(ardSyCarLocks.get(0).getRelayInfo()==0 || ardSyCarLocks.get(0).getRelayInfo()==null){
// Map<String,Object> map = new HashMap<>();
// map.put("A01", 110000);//瀵奸�氱涓�璺户鐢靛櫒
// map.put("A02", 110000);//瀵奸�氱浜岃矾缁х數鍣�
// map.put("res", String.valueOf(System.currentTimeMillis()));
// String mapString = com.alibaba.fastjson.JSON.toJSONString(map);
- String mapString = "{\"A01\":110000,\"A02\":110000,\"res\":\""+String.valueOf(System.currentTimeMillis())+"\"}";
- log.debug("鑷姩瑙e皝锛�"+mapString);
- EmqClient emqClient = new EmqClient(carId+"mqttPublish"+UUID.randomUUID());
- emqClient.connect();
- emqClient.publish(ardSyCarRtu.getTopicPublish(),mapString, QosEnum.QoS2,false);
- log.debug("杞﹁締"+carId+"瑙e皝鍛戒护鍙戦�佹垚鍔燂紒");
- // mqttOnce.publishCar(carId,ardSyCarRtu.getTopicPublish(),String.valueOf(new JSONObject(map)),"瑙e皝");
- }
+ String mapString = "{\"A01\":110000,\"A02\":110000,\"res\":\""+String.valueOf(System.currentTimeMillis())+"\"}";
+ log.debug("鑷姩瑙e皝锛�"+mapString);
+ EmqClient emqClient = new EmqClient(carId+"mqttPublish"+UUID.randomUUID());
+ emqClient.connect();
+ emqClient.publish(ardSyCarRtu.getTopicPublish(),mapString, QosEnum.QoS2,false);
+ log.debug("杞﹁締"+carId+"瑙e皝鍛戒护鍙戦�佹垚鍔燂紒");
+ // mqttOnce.publishCar(carId,ardSyCarRtu.getTopicPublish(),String.valueOf(new JSONObject(map)),"瑙e皝");
}
}
+
//0鏂藉皝
if(fengType==0){
- //閿佸紑鍏崇姸鎬�
- int lockCloseNum = 0;
- String mapString1 = "{\"A01\":100000,\"A02\":100000,\"res\":\""+String.valueOf(System.currentTimeMillis())+"\"}";
- System.out.println("鑷姩鏂藉皝锛�"+mapString1);
- EmqClient emqClient1 = new EmqClient(carId+"mqttPublish"+UUID.randomUUID());
- emqClient1.connect();
- emqClient1.publish(ardSyCarRtu.getTopicPublish(),mapString1, QosEnum.QoS2,false);
- //濡傛灉涓嶆槸鏂藉皝鐘舵�侊紝鍒欏彂閫佹柦灏佸懡浠�
- if(ardSyCarLocks.get(0).getRelayInfo()!=null){
- if(ardSyCarLocks.get(0).getRelayInfo()==1){
- for (int j = 0; j < ardSyCarLocks.size(); j++) {
- ArdSyCarLock ardSyCarLock = ardSyCarLocks.get(j);
- String currents = ardSyCarLock.getCurrents();
- Double currentInfo = ardSyCarLock.getCurrentInfo();
- //鐢垫祦鍊间负4.0鏄叧閿佺姸鎬�
- if(currentInfo.equals(4.00) || currentInfo.equals(4)){
- lockCloseNum += 1;
- }else {
- String key = "";
- if(currents.equals("C01")){
- key = "D03";
- }else if(currents.equals("C02")){
- key = "D04";
- }
+ if(ardSyCarLocks.get(0).getRelayInfo()==1 || ardSyCarLocks.get(0).getRelayInfo()==null){
+ //閿佸紑鍏崇姸鎬�
+ int lockCloseNum = 0;
+ String mapString1 = "{\"A01\":100000,\"A02\":100000,\"res\":\""+String.valueOf(System.currentTimeMillis())+"\"}";
+ System.out.println("鑷姩鏂藉皝锛�"+mapString1);
+ EmqClient emqClient1 = new EmqClient(carId+"mqttPublish"+UUID.randomUUID());
+ emqClient1.connect();
+ emqClient1.publish(ardSyCarRtu.getTopicPublish(),mapString1, QosEnum.QoS2,false);
+ //濡傛灉涓嶆槸鏂藉皝鐘舵�侊紝鍒欏彂閫佹柦灏佸懡浠�
+ if(ardSyCarLocks.get(0).getRelayInfo()!=null){
+ if(ardSyCarLocks.get(0).getRelayInfo()==1){
+ for (int j = 0; j < ardSyCarLocks.size(); j++) {
+ ArdSyCarLock ardSyCarLock = ardSyCarLocks.get(j);
+ String currents = ardSyCarLock.getCurrents();
+ Double currentInfo = ardSyCarLock.getCurrentInfo();
+ //鐢垫祦鍊间负4.0鏄叧閿佺姸鎬�
+ if(currentInfo.equals(4.00) || currentInfo.equals(4)){
+ lockCloseNum += 1;
+ }else {
+ String key = "";
+ if(currents.equals("C01")){
+ key = "D03";
+ }else if(currents.equals("C02")){
+ key = "D04";
+ }
// Map<String,Object> map = new HashMap();
// map.put(key, 0.01);
// map.put("res", String.valueOf(System.currentTimeMillis()));
// String mapString = com.alibaba.fastjson.JSON.toJSONString(map);
- String mapString = "{\""+key+"\":0.01,\"res\":\""+String.valueOf(System.currentTimeMillis())+"\"}";
- log.debug("鑷姩鍏抽攣锛�"+mapString);
- EmqClient emqClient = new EmqClient(carId+"mqttPublish"+UUID.randomUUID());
- emqClient.connect();
- emqClient.publish(ardSyCarRtu.getTopicPublish(),mapString, QosEnum.QoS2,false);
- // mqttOnce.publishCar("carId",ardSyCarRtu.getTopicPublish(),String.valueOf(new JSONObject(map)),"寮�閿侊細"+currents);
- while(true){
- ArdSyCarLock ardSyCarLock1 = lockService.getCurrentInfo(ardSyCarRtu.getId(),currents);
- Double currentInfo1 = ardSyCarLock1.getCurrentInfo();
- if(currentInfo1.equals(4.00) || currentInfo1.equals(4)){
- lockCloseNum +=1;
- break;
+ String mapString = "{\""+key+"\":0.01,\"res\":\""+String.valueOf(System.currentTimeMillis())+"\"}";
+ log.debug("鑷姩鍏抽攣锛�"+mapString);
+ EmqClient emqClient = new EmqClient(carId+"mqttPublish"+UUID.randomUUID());
+ emqClient.connect();
+ emqClient.publish(ardSyCarRtu.getTopicPublish(),mapString, QosEnum.QoS2,false);
+ // mqttOnce.publishCar("carId",ardSyCarRtu.getTopicPublish(),String.valueOf(new JSONObject(map)),"寮�閿侊細"+currents);
+ while(true){
+ ArdSyCarLock ardSyCarLock1 = lockService.getCurrentInfo(ardSyCarRtu.getId(),currents);
+ Double currentInfo1 = ardSyCarLock1.getCurrentInfo();
+ if(currentInfo1.equals(4.00) || currentInfo1.equals(4)){
+ lockCloseNum +=1;
+ break;
+ }
}
}
}
- }
- if(lockCloseNum == 2){
+ if(lockCloseNum == 2){
// Map<String,Object> map = new HashMap<>();
// map.put("A01", 100000);//鏂紑绗竴璺户鐢靛櫒
// map.put("A02", 100000);//鏂紑绗簩璺户鐢靛櫒
// map.put("res", String.valueOf(System.currentTimeMillis()));
// String mapString = com.alibaba.fastjson.JSON.toJSONString(map);
- log.debug("杞﹁締"+carId+"鏂藉皝鍛戒护鍙戦�佹垚鍔燂紒");
- // mqttOnce.publishCar(carId,ardSyCarRtu.getTopicPublish(),String.valueOf(new JSONObject(map)),"鏂藉皝");
+ log.debug("杞﹁締"+carId+"鏂藉皝鍛戒护鍙戦�佹垚鍔燂紒");
+ // mqttOnce.publishCar(carId,ardSyCarRtu.getTopicPublish(),String.valueOf(new JSONObject(map)),"鏂藉皝");
+ }
}
}
}
@@ -536,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