From 4c7e2078a1439ad6fb42f8854f5f8ac1e6859cbc Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期一, 18 十二月 2023 15:19:58 +0800
Subject: [PATCH] fly
---
ard-work/src/main/java/com/ruoyi/utils/qymqtt/newM/MessageCallback.java | 4
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarLockServiceImpl.java | 16 ++++-
ard-work/src/main/java/com/ruoyi/utils/qymqtt/AutoMqtt.java | 2
ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java | 131 +++++++++++++++++++++++++++----------------
ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessFence.java | 2
5 files changed, 99 insertions(+), 56 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessFence.java b/ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessFence.java
index 0f6e348..15928f9 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessFence.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessFence.java
@@ -1,5 +1,6 @@
package com.ruoyi.sy.domain;
+import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
/**
@@ -27,5 +28,6 @@
private String alarmLat;
private String carModel;
private Integer drct;
+ @TableField(value = "is_alarm")
private Integer isAlarm;
}
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 b53d824..6b28819 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,6 +20,7 @@
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;
@@ -35,9 +36,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,9 +80,8 @@
/*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){
@@ -89,13 +90,25 @@
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,7 +127,7 @@
//鏌ヨ鎵�鏈夎娌圭偣鍥存爮
List<ArdOilWall> ardOilWalls = ardOilWallService.accessAll();
//鏃ユ湡鏍煎紡
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
//濡傛灉娌℃湁璇存槑杞﹁締鏈繘鍏ヨ娌圭偣锛岄渶瑕佸尮閰嶆墍鏈夎娌圭偣鍥存爮
if(ardAccessFence==null){
//杞﹁締鏈繘鍏ヨ娌圭偣
@@ -144,21 +157,25 @@
ardAccessFence1.setDrct(drct);
ardAccessFence1.setIsAlarm(0);
ardAccessFenceService.access(ardAccessFence1);
- //mqtt鍙戦�佹棦瀹歊tu鐘舵��
- feng(carId,"瑁呮补鐐�",carRtuService,lockService);
- break;
+ if(rtuType){
+ //mqtt鍙戦�佹棦瀹歊tu鐘舵��
+ feng(carId,"瑁呮补鐐�",carRtuService,lockService);
+ break;
+ }
}
}
}else {
//杞﹂�熸爣璁�
Boolean stop = true;
//鍒ゆ柇杞﹂��
- if(speed>5){
- //mqtt鍙戦�佹棦瀹歊tu鐘舵��
- feng(carId,"鏂藉皝",carRtuService,lockService);
- stop = false;
+ if(rtuType){
+ if(speed>5){
+ //mqtt鍙戦�佹棦瀹歊tu鐘舵��
+ feng(carId,"鏂藉皝",carRtuService,lockService);
+ stop = false;
+ }
}
- //甯﹂攣杞﹁締鏈夊�间紭鍏堝垽鏂槸鍚︿负鎵嬪姩娣诲姞杞﹁締
+ //杞﹁締鏈夊�间紭鍏堝垽鏂槸鍚︿负鎵嬪姩娣诲姞杞﹁締
if(ardAccessFence.getIsAlarm()==1){
//1涓烘墜鍔ㄦ坊鍔犺溅杈嗘棤闇�鎶ヨ淇℃伅锛屾洿鏂颁綅缃嵆鍙�
ardAccessFence.setLng(lng);
@@ -169,19 +186,23 @@
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);
+ 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 {
//濡傛灉涓嶄竴鏍锋洿鏂板潗鏍�
@@ -210,9 +231,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;
}
@@ -240,8 +263,10 @@
ardAccessFence.setLng(lng);
ardAccessFence.setLat(lat);
ardAccessFenceService.updAccess(ardAccessFence);
- //寮�鍑鸿娌圭偣鍥存爮锛屽彂閫佷笂閿佸強鏂藉皝鍛戒护
- feng(carId,"鏂藉皝",carRtuService,lockService);
+ if(rtuType){
+ //寮�鍑鸿娌圭偣鍥存爮锛屽彂閫佷笂閿佸強鏂藉皝鍛戒护
+ feng(carId,"鏂藉皝",carRtuService,lockService);
+ }
}
}else {
//杞﹁締宸茬粡寮�鍑鸿娌圭偣锛屾煡鐪嬫槸鍚︽湁鍗告补鐐笽D
@@ -271,9 +296,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;
}
@@ -285,19 +312,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);
@@ -320,8 +351,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 {
diff --git a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarLockServiceImpl.java b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarLockServiceImpl.java
index c27a0a6..4bb43b6 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarLockServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarLockServiceImpl.java
@@ -194,13 +194,21 @@
@Override
public List<CarVo> queryCar(List<String> list) {
- QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>();
+// QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>();
+// if(list.size()>0){
+// queryWrapper.ne("reserved_1","").notIn("car_id",list);
+// }else {
+// queryWrapper.ne("reserved_1","");
+// }
+// List<ArdSyCar> ardSyCars = ardSyCarMapper.selectList(queryWrapper);
+ List<ArdSyCar> ardSyCars = new ArrayList<>();
if(list.size()>0){
- queryWrapper.ne("reserved_1","").notIn("car_id",list);
+ QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>();
+ queryWrapper.notIn("car_id",list);
+ ardSyCars = ardSyCarMapper.selectList(queryWrapper);
}else {
- queryWrapper.ne("reserved_1","");
+ ardSyCars = ardSyCarMapper.selectList(null);
}
- List<ArdSyCar> ardSyCars = ardSyCarMapper.selectList(queryWrapper);
return carAnalysis(ardSyCars);
}
diff --git a/ard-work/src/main/java/com/ruoyi/utils/qymqtt/AutoMqtt.java b/ard-work/src/main/java/com/ruoyi/utils/qymqtt/AutoMqtt.java
index 2fe2ecd..10c9c6d 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/qymqtt/AutoMqtt.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/qymqtt/AutoMqtt.java
@@ -36,7 +36,7 @@
EmqClient emqClient = new EmqClient(carId+"mqttSubscribe"+UUID.randomUUID());
emqClient.connect();
emqClient.subscribe(subscribe, QosEnum.QoS2);
- log.info("璁㈤槄涓婚锛�"+subscribe);
+ log.debug("璁㈤槄涓婚锛�"+subscribe);
}catch (Exception e) {
e.printStackTrace();
}
diff --git a/ard-work/src/main/java/com/ruoyi/utils/qymqtt/newM/MessageCallback.java b/ard-work/src/main/java/com/ruoyi/utils/qymqtt/newM/MessageCallback.java
index bc313ec..32c6eb2 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/qymqtt/newM/MessageCallback.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/qymqtt/newM/MessageCallback.java
@@ -40,7 +40,7 @@
@Override //娑堟伅鍙戝竷鑰呮秷鎭彂甯冨畬鎴愪骇鐢熺殑鍥炶皟
public void deliveryComplete(IMqttDeliveryToken token) {
- log.info("deliveryComplete---------" + token.isComplete());
+ log.debug("deliveryComplete---------" + token.isComplete());
int messageId = token.getMessageId();
String[] topics = token.getTopics();
String clientId = token.getClient().getClientId();
@@ -50,7 +50,7 @@
topicStr = topicStr + topic + ",";
}
topicStr = topicStr.substring(0, topicStr.length() - 1);
- log.info("娑堟伅鍙戝竷瀹屾垚,messageId="+messageId+",topics="+topicStr+",clientId="+clientId);
+ log.debug("娑堟伅鍙戝竷瀹屾垚,messageId="+messageId+",topics="+topicStr+",clientId="+clientId);
}
@Override//娑堟伅璁㈤槄鑰呮敹鍒版秷鎭悗瑙﹀彂鐨勫洖璋�
--
Gitblit v1.9.3