From 065142057ba3983af899991085e37ac1ec502320 Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期二, 19 九月 2023 14:06:30 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java | 68 +++++++++++++++++++++++++++++++---
1 files changed, 62 insertions(+), 6 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 00765d5..9be6f79 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
@@ -12,6 +12,9 @@
import com.gps31.push.netty.PushMsg;
import com.gps31.push.netty.client.TcpClient;
import com.gps31.push.util.MapUtil;
+import com.ruoyi.common.utils.spring.SpringUtils;
+import com.ruoyi.sy.service.impl.ArdSyCarDayServiceImpl;
+import com.ruoyi.sy.service.impl.ArdSyCarServiceImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -64,13 +67,66 @@
}else if("8003".equals(pushMsg.getCmd())){//璁㈤槄鍔ㄦ�佹秷鎭簲绛�
String rspResult = MapUtil.getStrVal(pushMsg.getJsonMap(),"rspResult","1");
- log.error(String.format(" 璁㈤槄搴旂瓟:%s", "0".equals(rspResult)?"鎴愬姛":"澶辫触"));
+ //log.error(String.format(" 璁㈤槄搴旂瓟:%s", "0".equals(rspResult)?"鎴愬姛":"澶辫触"));
}else if("0200".equals(pushMsg.getCmd())) {//瀹氫綅淇℃伅
Map<String,Object> gpsMap = pushMsg.getJsonMap();
- String carName = MapUtil.getStrVal(gpsMap, "carName","");//鑾峰彇杞︾墝鍙�
+ /*String carName = MapUtil.getStrVal(gpsMap, "carName","");//鑾峰彇杞︾墝鍙�
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(new Date()));
- log.error(String.format(" ---->鏀跺埌瀹氫綅鏁版嵁:%s",JSON.toJSONString(gpsMap)));
+ log.error(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){
+ gpsMap.putAll(result);
+ String ancestors = (String) gpsMap.get("ancestors");//鑾峰彇鐖剁骇閮ㄩ棬
+ String[] ancestorsArray = ancestors.split(",");
+ if(ancestorsArray.length == 1){//鏈�楂樼骇閮ㄩ棬
+ String deptId = String.valueOf(gpsMap.get("deptId"));
+ Map<String,Map<String,Object>> deptMap = PositionContainer.getDeptPositionMap().get(deptId);
+ if(deptMap == null){
+ deptMap = new HashMap();
+ deptMap.put((String)gpsMap.get("carId"),gpsMap);
+ PositionContainer.getDeptPositionMap().put(deptId,deptMap);
+ }else{
+ deptMap.put((String)gpsMap.get("carId"),gpsMap);
+ }
+ }else{//鍏朵粬閮ㄩ棬
+ //鍔犲叆鏈儴闂ㄥ鍣�
+ String deptId = String.valueOf(gpsMap.get("deptId"));
+ Map<String,Map<String,Object>> deptMap = PositionContainer.getDeptPositionMap().get(deptId);
+ if(deptMap == null){
+ deptMap = new HashMap();
+ deptMap.put((String)gpsMap.get("carId"),gpsMap);
+ PositionContainer.getDeptPositionMap().put(deptId,deptMap);
+ }else{
+ deptMap.put((String)gpsMap.get("carId"),gpsMap);
+ }
+ //鍔犲叆鐖剁骇閮ㄩ棬瀹瑰櫒
+ for(int i = 1;i <= ancestorsArray.length - 1;i++){
+ String deptIdp = ancestorsArray[i];
+ Map<String,Map<String,Object>> deptMapp = PositionContainer.getDeptPositionMap().get(deptIdp);
+ if(deptMapp == null){
+ deptMapp = new HashMap();
+ deptMapp.put((String)gpsMap.get("carId"),gpsMap);
+ 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)){
+ PositionContainer.getUserPositionMap().get(userId).put(carId,gpsMap);
+ }
+ }
+ }
+ }
+ }
/**
*
* 璇峰姞鍏ヤ笁鏂归泦鎴愭柟鐨勪笟鍔¢�昏緫
@@ -79,7 +135,7 @@
}else if("0300".equals(pushMsg.getCmd())) {//鎶ヨ娑堟伅
Map<String,Object> alarmMap = pushMsg.getJsonMap();
String carName = MapUtil.getStrVal(alarmMap, "carName","");//鑾峰彇杞︾墝鍙�
- log.error(String.format(" ---->鏀跺埌鎶ヨ鏁版嵁:%s",JSON.toJSONString(alarmMap)));
+ //log.error(String.format(" ---->鏀跺埌鎶ヨ鏁版嵁:%s",JSON.toJSONString(alarmMap)));
/**
*
* 璇峰姞鍏ヤ笁鏂归泦鎴愭柟鐨勪笟鍔¢�昏緫
@@ -88,7 +144,7 @@
}else if("0401".equals(pushMsg.getCmd())) {//閫忎紶娑堟伅
Map<String,Object> dataMap = pushMsg.getJsonMap();
String carName = MapUtil.getStrVal(dataMap, "carName","");//鑾峰彇杞︾墝鍙�
- log.error(String.format(" ---->鏀跺埌閫忎紶鏁版嵁:%s",JSON.toJSONString(dataMap)));
+ //log.error(String.format(" ---->鏀跺埌閫忎紶鏁版嵁:%s",JSON.toJSONString(dataMap)));
/**
*
* 璇峰姞鍏ヤ笁鏂归泦鎴愭柟鐨勪笟鍔¢�昏緫
@@ -100,7 +156,7 @@
public void sendMassage() {
try {
PushClientImplPosition client = new PushClientImplPosition();
- client.setLog(true);//鏄惁鎵撳嵃鏄庢枃
+ client.setLog(false);//鏄惁鎵撳嵃鏄庢枃
client.setHost(this.ip);//鏈嶅姟鍣↖P
client.setPort(10100);//鏈嶅姟鍣ㄧ鍙�
client.setUserName(this.userId);//绯荤粺鐢ㄦ埛鍚�
--
Gitblit v1.9.3