From 24e152d8a574e77b1909a8fea4703d4fe835c2a5 Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期五, 05 七月 2024 11:53:07 +0800
Subject: [PATCH] 查询电磁锁及挂接的车辆提交

---
 ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockServiceImpl.java |  118 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 100 insertions(+), 18 deletions(-)

diff --git a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockServiceImpl.java b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockServiceImpl.java
index d7980f6..95d0239 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockServiceImpl.java
@@ -2,7 +2,6 @@
 
 import java.util.*;
 
-import com.dtflys.forest.annotation.Var;
 import com.ruoyi.common.core.domain.entity.SysConfig;
 import com.ruoyi.common.utils.uuid.IdUtils;
 import com.ruoyi.sy.domain.ArdSyUser;
@@ -11,15 +10,11 @@
 import com.ruoyi.sy.mapper.ArdTankWallLockTemporaryMapper;
 import com.ruoyi.system.mapper.SysConfigMapper;
 import com.ruoyi.utils.forest.SYClient;
-import com.ruoyi.utils.result.Results;
 import org.apache.commons.codec.digest.DigestUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.stream.Collectors;
 
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.sy.mapper.ArdTankLockMapper;
 import com.ruoyi.sy.domain.ArdTankLock;
 import com.ruoyi.sy.service.IArdTankLockService;
@@ -77,7 +72,6 @@
     /**
      * 鏂板鐢电閿�
      *
-     * @param ardTankLock 鐢电閿�
      * @return 缁撴灉
      */
     @Override
@@ -146,16 +140,16 @@
     //public Results List<Map<String,Object>> getAll(String usersId) {
     public List<Map<String,Object>> getAll(String usersId) {
         ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId);
-        /*if(ardSyUser == null){
-            return Results.error("娌℃湁鎸傛帴涓変竴杞﹁締鐢ㄦ埛");
-        }*/
+        if(ardSyUser == null){
+            return new ArrayList();
+        }
         List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT");
         String syURL = "";
         if(syURLResult.size() != 0){
             syURL = syURLResult.get(0).getConfigValue();
-        }/*else{
-            return Results.error("涓変竴杞﹁締鍦板潃鏈綍鍏�");
-        }*/
+        }else{
+            return new ArrayList();
+        }
         String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword());
         Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, ardSyUser.getUserId());
         String sessionId = (String) LogInResult.get("sessionId");
@@ -213,16 +207,16 @@
     @Override
     public Map<String, Object> getLockByCarId(String carId, String usersId) {
         ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId);
-        /*if(ardSyUser == null){
-            return Results.error("娌℃湁鎸傛帴涓変竴杞﹁締鐢ㄦ埛");
-        }*/
+        if(ardSyUser == null){
+            return new HashMap();
+        }
         List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT");
         String syURL = "";
         if(syURLResult.size() != 0){
             syURL = syURLResult.get(0).getConfigValue();
-        }/*else{
-            return Results.error("涓変竴杞﹁締鍦板潃鏈綍鍏�");
-        }*/
+        }else{
+            return new HashMap();
+        }
         String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword());
         Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, ardSyUser.getUserId());
         String sessionId = (String) LogInResult.get("sessionId");
@@ -324,4 +318,92 @@
         }
         return result;
     }
+
+    @Override
+    public List<Map<String, String>> getLockByCarPlate(String usersId, String carPlate) {
+        ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId);
+        if(ardSyUser == null){
+            return new ArrayList();
+        }
+        List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT");
+        String syURL = "";
+        if(syURLResult.size() != 0){
+            syURL = syURLResult.get(0).getConfigValue();
+        }else{
+            return new ArrayList();
+        }
+        String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword());
+        Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, ardSyUser.getUserId());
+        String sessionId = (String) LogInResult.get("sessionId");
+        List<ArdTankLock> ardTankLockList = ardTankLockMapper.getAll();
+        List<Map<String,String>> result = new ArrayList();
+        if(!carPlate.equals("")){
+            Map<String,Object> carMap = sYClient.getCarListByPlate(syURL,carPlate,ardSyUser.getUserId(),sessionId);//杞︾墝鍙锋ā绯婃悳绱㈣溅杈�
+            List<Map<String,Object>> carList = new ArrayList();
+            if(((String)carMap.get("rspCode")).equals("1")){
+                carList = (List<Map<String, Object>>) carMap.get("list");
+            }else{
+                return new ArrayList();
+            }
+            List<String> carIdList = new ArrayList();//璁板綍涓変竴杞﹁締涓婚敭
+            for(Map<String,Object> map : carList){
+                carIdList.add((String) map.get("carId"));
+            }
+            for(ArdTankLock ardTankLock : ardTankLockList){
+                if(carIdList.contains(ardTankLock.getCarId())){//杩斿洖鐨勮溅杈嗗寘鍚暟鎹簱褰曞叆鐨勮溅杈�
+                    Map<String,String> map = new HashMap();
+                    map.put("id",ardTankLock.getId());
+                    map.put("lockNum",ardTankLock.getLockNum());
+                    map.put("lockName",ardTankLock.getLockName());
+                    map.put("imgPositionTop",ardTankLock.getImgPositionTop());
+                    map.put("imgPositionLeft",ardTankLock.getImgPositionLeft());
+                    map.put("carId",ardTankLock.getCarId());
+                    map.put("enable",ardTankLock.getEnable());
+                    if(ardTankLock.getRestartState() == null){
+                        map.put("restartState","");
+                    }else{
+                        map.put("restartState",ardTankLock.getRestartState());
+                    }
+                    if(ardTankLock.getOnlineTime() == null){
+                        map.put("onlineTime","");
+                    }else{
+                        map.put("onlineTime",ardTankLock.getOnlineTime());
+                    }
+                    Map<String,Object> car = carList.stream().filter(mapCar -> ((String)mapCar.get("carId")).equals(ardTankLock.getCarId())).collect(Collectors.toList()).get(0);
+                    map.put("carPlate", (String) car.get("carPlate"));
+                    result.add(map);
+                }else{
+                    continue;
+                }
+            }
+        }else{
+            for(ArdTankLock ardTankLock : ardTankLockList){
+                Map<String,String> map = new HashMap();
+                map.put("id",ardTankLock.getId());
+                map.put("lockNum",ardTankLock.getLockNum());
+                map.put("lockName",ardTankLock.getLockName());
+                map.put("imgPositionTop",ardTankLock.getImgPositionTop());
+                map.put("imgPositionLeft",ardTankLock.getImgPositionLeft());
+                map.put("carId",ardTankLock.getCarId());
+                map.put("enable",ardTankLock.getEnable());
+                if(ardTankLock.getRestartState() == null){
+                    map.put("restartState","");
+                }else{
+                    map.put("restartState",ardTankLock.getRestartState());
+                }
+                if(ardTankLock.getOnlineTime() == null){
+                    map.put("onlineTime","");
+                }else{
+                    map.put("onlineTime",ardTankLock.getOnlineTime());
+                }
+                Map<String,Object> syResult = sYClient.getCarNearPositionByCarId(syURL, ardTankLock.getCarId(), ardSyUser.getUserId(), sessionId);
+                if(((String)syResult.get("rspCode")).equals("1")){
+                    Map<String,Object> carMap = ((List<Map<String,Object>>)syResult.get("list")).get(0);
+                    map.put("carPlate", (String) carMap.get("carPlate"));
+                }
+                result.add(map);
+            }
+        }
+        return result;
+    }
 }

--
Gitblit v1.9.3