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/service/impl/ArdSyCarServiceImpl.java | 120 ++++++++++++++++++++++++++--------------------------------- 1 files changed, 53 insertions(+), 67 deletions(-) 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 70c35e3..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 @@ -328,59 +328,26 @@ @Override public List<Map<String, String>> getAllCarModel() { - boolean exsit = MinioUtil.exitsBucket("sycar"); + boolean exsit = MinioUtil.exitsBucket("system"); if (exsit) { List<Map<String, String>> listObjetcName = new ArrayList<>(); try { - // ListObjectsArgs listObjectsArgs = ListObjectsArgs.builder().prefix("carmodel/").bucket("sycar").build(); - Iterable<Result<Item>> myObjects = MinioUtil.getObjectsByBucket("sycar","carmodel"); + //Iterable<Result<Item>> myObjects = MinioUtil.getObjectsByBucket("sycar","carmodel"); + Iterable<Result<Item>> myObjects = MinioUtil.getObjectsByBucket("system","model/car"); for (Result<Item> result : myObjects) { Item item = result.get(); Map<String, String> map = new HashMap(); String[] strArr = item.objectName().split("/"); - map.put("carType", strArr[1]); - map.put("carModel", "sycar/" + item.objectName()); - /*switch (item.objectName()) { - case "carmodel/aodi.glb": - map.put("carType", "濂ヨ开"); - break; - case "carmodel/baolai.glb": - map.put("carType", "瀹濇潵"); - break; - case "carmodel/bieke.glb": - map.put("carType", "鍒厠"); - break; - case "carmodel/bus1.glb": - map.put("carType", "澶у杞�"); - break; - case "carmodel/car.glb": - map.put("carType", "灏忓瀷杞�"); - break; - case "carmodel/fire(1).glb": - map.put("carType", "娑堥槻杞�"); - break; - case "carmodel/fute.glb": - map.put("carType", "绂忕壒"); - break; - case "carmodel/jingche_a.glb": - map.put("carType", "璀﹁溅"); - break; - case "carmodel/jiuhu.glb": - map.put("carType", "鏁戞姢杞�"); - break; - case "carmodel/oil.glb": - map.put("carType", "娌圭綈杞�"); - break; - case "carmodel/truck.glb": - map.put("carType", "宸ョ▼鐢ㄨ溅"); - break; - case "carmodel/van1.glb": - map.put("carType", "澶ц揣杞�"); - break; - default: - break; - }*/ - listObjetcName.add(map); + try{ + String carType = strArr[2]; + if(!carType.contains(".")){ + map.put("carType", carType); + map.put("carModel", "system/" + item.objectName()); + listObjetcName.add(map); + } + }catch(Exception e){ + + } } return listObjetcName; } catch (Exception ex) { @@ -934,15 +901,22 @@ @Override public Results chaseCarByCarId(String usersId, String carId, String cycle) { + String sessionId = ""; + for(String key : ONLINE_USER_SESSIONS.keySet()){ + if(key.startsWith(usersId + "_")){ + sessionId = key; + } + } + if(sessionId.equals("")){//娌℃湁session灏辫繑鍥炲け璐� + return Results.error("杩借釜澶辫触"); + } try { - /*Map<String,Map<String,Object>> map = new HashMap(); - map.put(carId,new HashMap()); - PositionContainer.getUserPositionMap().put(usersId,map);*/ if (cycle.equals("0")) { if (userCarTimerMap.get(usersId) != null) { userCarTimerMap.get(usersId).cancel(); userCarTimerMap.remove(usersId); PositionContainer.getUserPositionMap().remove(usersId); + System.out.println("鍋滄杩借釜"); } return Results.succeed("鍋滄杩借釜"); } else { @@ -953,8 +927,19 @@ Map<String, Map<String, Object>> map = new HashMap(); map.put(carId, new HashMap()); PositionContainer.getUserPositionMap().put(usersId, map); + 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)); + } + } + Date date = new Date(); - Timer carPositionTimer = new Timer();//瀹氭椂鎺ㄩ�佸疄鏃朵綅缃� + Timer carPositionTimer = new Timer(sessionId);//瀹氭椂鎺ㄩ�佸疄鏃朵綅缃� TimerTask carPositionTask = new TimerTask() { @Override public void run() { @@ -963,18 +948,13 @@ if (position.size() != 0) { Map<String, Map<String, Object>> data = new HashMap(); data.put("31000", position); - //WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data)); - String sessionId = ""; - for(String key : ONLINE_USER_SESSIONS.keySet()){ - if(key.startsWith(usersId + "_")){ - sessionId = key; - } - } - if(sessionId.equals("")){//鐢ㄦ埛绂荤嚎閲婃斁璧勬簮 + String sessionId = Thread.currentThread().getName(); + if(ONLINE_USER_SESSIONS.get(sessionId) == null){//鐢ㄦ埛绂荤嚎閲婃斁璧勬簮 if (userCarTimerMap.get(usersId) != null) { userCarTimerMap.get(usersId).cancel(); userCarTimerMap.remove(usersId); PositionContainer.getUserPositionMap().remove(usersId); + System.out.println("鐢ㄦ埛绂荤嚎锛屽仠姝㈣拷韪�"); } } WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data)); @@ -989,8 +969,19 @@ Map<String, Map<String, Object>> map = new HashMap(); map.put(carId, new HashMap()); PositionContainer.getUserPositionMap().put(usersId, map); + 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)); + } + } + Date date = new Date(); - Timer carPositionTimer = new Timer();//瀹氭椂鎺ㄩ�佸疄鏃朵綅缃� + Timer carPositionTimer = new Timer(sessionId);//瀹氭椂鎺ㄩ�佸疄鏃朵綅缃� TimerTask carPositionTask = new TimerTask() { @Override public void run() { @@ -999,18 +990,13 @@ if (position.size() != 0) { Map<String, Map<String, Object>> data = new HashMap(); data.put("31000", position); - //WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data)); - String sessionId = ""; - for(String key : ONLINE_USER_SESSIONS.keySet()){ - if(key.startsWith(usersId + "_")){ - sessionId = key; - } - } - if(sessionId.equals("")){//鐢ㄦ埛绂荤嚎閲婃斁璧勬簮 + String sessionId = Thread.currentThread().getName(); + if(ONLINE_USER_SESSIONS.get(sessionId) == null){//鐢ㄦ埛绂荤嚎閲婃斁璧勬簮 if (userCarTimerMap.get(usersId) != null) { userCarTimerMap.get(usersId).cancel(); userCarTimerMap.remove(usersId); PositionContainer.getUserPositionMap().remove(usersId); + System.out.println("鐢ㄦ埛绂荤嚎锛屽仠姝㈣拷韪�"); } } WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data)); -- Gitblit v1.9.3