From a9d64eb20fc006e4915631bd1496b050f399b798 Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期三, 28 二月 2024 17:52:13 +0800
Subject: [PATCH] 三一车辆模型修改提交

---
 ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java |   99 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 95 insertions(+), 4 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 69cf50d..ea18e26 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
@@ -346,7 +346,7 @@
                             listObjetcName.add(map);
                         }
                     }catch(Exception e){
-
+                        e.printStackTrace();
                     }
                 }
                 return listObjetcName;
@@ -441,13 +441,15 @@
     public Map<String, Object> getArdSyCarAndDeptByCarId(String carId) {
         Map<String, Object> result = ardSyCarMapper.getArdSyCarAndDeptByCarId(carId);
         if (result != null) {
-            if (result.get("carPicture") != null) {
+            /*if (result.get("carPicture") != null) {
                 if (!((String) result.get("carPicture")).equals("")) {
-                    /*String url = ((String) result.get("carPicture")).split("sycar")[0];
-                    String carModel = url + (String) result.get("carModel");*/
                     String carModel = this.minioEndpoint + "/" + (String) result.get("carModel");
                     result.put("carModel", carModel);
                 }
+            }*/
+            if(result.get("carModel") != null || "".equals(result.get("carModel"))){
+                String carModel = this.minioEndpoint + "/" + (String) result.get("carModel");
+                result.put("carModel", carModel);
             }
         }
         return result;
@@ -901,6 +903,23 @@
 
     @Override
     public Results chaseCarByCarId(String usersId, String carId, String cycle) {
+        ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId);
+        String userId ="";
+        String password = "";
+        if(ardSyUser != null){
+            userId = ardSyUser.getUserId();
+            password = DigestUtils.md5Hex(ardSyUser.getPassword());
+        }else{
+            return Results.error("娌℃湁鎸傛帴涓変竴杞﹁締鐢ㄦ埛");
+        }
+        List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT");
+        String syURL = "";
+        if(syURLResult.size() != 0){
+            syURL = syURLResult.get(0).getConfigValue();
+        }else{
+            return Results.error("涓変竴杞﹁締鍦板潃鏈綍鍏�");
+        }
+
         String sessionId = "";
         for(String key : ONLINE_USER_SESSIONS.keySet()){
             if(key.startsWith(usersId + "_")){
@@ -916,6 +935,10 @@
                     userCarTimerMap.get(usersId).cancel();
                     userCarTimerMap.remove(usersId);
                     PositionContainer.getUserPositionMap().remove(usersId);
+                    Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId);
+                    String sySessionId = (String) loginResult.get("sessionId");
+                    String params = "%7B%220020%22:%220%22,%220029%22:%2230%22%7d";
+                    sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//鍋滄杩借釜锛屾敼涓哄畾鏃�30s鎺ㄩ��
                     System.out.println("鍋滄杩借釜");
                 }
                 return Results.succeed("鍋滄杩借釜");
@@ -927,9 +950,24 @@
                     Map<String, Map<String, Object>> map = new HashMap();
                     map.put(carId, new HashMap());
                     PositionContainer.getUserPositionMap().put(usersId, map);
+
+                    Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId);
+                    String sySessionId = (String) loginResult.get("sessionId");
+                    List<SysConfig> distanceSYResult = sysConfigMapper.selectByType("31time");
+                    String time = "";
+                    if(distanceSYResult.size() != 0){
+                        time = distanceSYResult.get(0).getConfigValue();
+                    }else{
+                        return Results.error("涓変竴杞﹁締瀹氭椂鏈綍鍏�");
+                    }
+                    String params = "%7B%220020%22:%220%22,%220029%22:%22"+time+"%22%7d";
+                    sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//寮�濮嬭拷韪紝鏀逛负瀹氭椂鎺ㄩ��
+
                     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));
@@ -952,6 +990,25 @@
                                             userCarTimerMap.get(usersId).cancel();
                                             userCarTimerMap.remove(usersId);
                                             PositionContainer.getUserPositionMap().remove(usersId);
+
+                                            ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId);
+                                            String userId ="";
+                                            String password = "";
+                                            if(ardSyUser != null){
+                                                userId = ardSyUser.getUserId();
+                                                password = ardSyUser.getPassword();
+                                            }
+                                            List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT");
+                                            String syURL = "";
+                                            if(syURLResult.size() != 0){
+                                                syURL = syURLResult.get(0).getConfigValue();
+                                            }
+                                            if(!userId.equals("") && !password.equals("") && !syURL.equals("")){
+                                                Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId);
+                                                String sySessionId = (String) loginResult.get("sessionId");
+                                                String params = "%7B%220020%22:%220%22,%220029%22:%2230%22%7d";
+                                                sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//鍋滄杩借釜锛屾敼涓哄畾鏃�30s
+                                            }
                                             System.out.println("鐢ㄦ埛绂荤嚎锛屽仠姝㈣拷韪�");
                                         }
                                     }
@@ -967,9 +1024,24 @@
                     Map<String, Map<String, Object>> map = new HashMap();
                     map.put(carId, new HashMap());
                     PositionContainer.getUserPositionMap().put(usersId, map);
+
+                    Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId);
+                    String sySessionId = (String) loginResult.get("sessionId");
+                    List<SysConfig> distanceSYResult = sysConfigMapper.selectByType("31time");
+                    String time = "";
+                    if(distanceSYResult.size() != 0){
+                        time = distanceSYResult.get(0).getConfigValue();
+                    }else{
+                        return Results.error("涓変竴杞﹁締瀹氭椂鏈綍鍏�");
+                    }
+                    String params = "%7B%220020%22:%220%22,%220029%22:%22"+time+"%22%7d";
+                    sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//寮�濮嬭拷韪紝鏀逛负瀹氭椂鎺ㄩ��
+
                     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));
@@ -992,6 +1064,25 @@
                                             userCarTimerMap.get(usersId).cancel();
                                             userCarTimerMap.remove(usersId);
                                             PositionContainer.getUserPositionMap().remove(usersId);
+
+                                            ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId);
+                                            String userId ="";
+                                            String password = "";
+                                            if(ardSyUser != null){
+                                                userId = ardSyUser.getUserId();
+                                                password = ardSyUser.getPassword();
+                                            }
+                                            List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT");
+                                            String syURL = "";
+                                            if(syURLResult.size() != 0){
+                                                syURL = syURLResult.get(0).getConfigValue();
+                                            }
+                                            if(!userId.equals("") && !password.equals("") && !syURL.equals("")){
+                                                Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId);
+                                                String sySessionId = (String) loginResult.get("sessionId");
+                                                String params = "%7B%220020%22:%220%22,%220029%22:%2230%22%7d";
+                                                sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//鍋滄杩借釜锛屾敼涓哄畾鏃�30s
+                                            }
                                             System.out.println("鐢ㄦ埛绂荤嚎锛屽仠姝㈣拷韪�");
                                         }
                                     }

--
Gitblit v1.9.3