From fb486d8c2447a9a18eb929d81094bfd46c78fe27 Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: Tue, 06 Aug 2024 08:09:52 +0800
Subject: [PATCH] 电磁锁加入电子围栏自动开关提交

---
 ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankWallLock.java                        |   10 +
 ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankLockMapper.java                      |    2 
 ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankLock.java                            |   10 +
 ard-work/src/main/resources/mapper/sy/ArdTankLockMapper.xml                            |   62 ++++++++++
 ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockProcessLogServiceImpl.java |  258 ++++++++++++++++++++++++++++++++----------
 5 files changed, 281 insertions(+), 61 deletions(-)

diff --git a/ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankLock.java b/ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankLock.java
index d964901..f41d496 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankLock.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankLock.java
@@ -56,6 +56,8 @@
 
     private List<ArdTankLockPassword> ardTankLockPasswords;
 
+    private List<ArdTankWallLock> ardTankWallLockList;
+
     public void setId(String id) 
     {
         this.id = id;
@@ -154,6 +156,14 @@
         this.ardTankLockPasswords = ardTankLockPasswords;
     }
 
+    public List<ArdTankWallLock> getArdTankWallLockList() {
+        return ardTankWallLockList;
+    }
+
+    public void setArdTankWallLockList(List<ArdTankWallLock> ardTankWallLockList) {
+        this.ardTankWallLockList = ardTankWallLockList;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
diff --git a/ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankWallLock.java b/ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankWallLock.java
index 5ce2aba..70c8eae 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankWallLock.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankWallLock.java
@@ -30,6 +30,8 @@
     @Excel(name = "锁主键")
     private String lockId;
 
+    private ArdTankWall ardTankWall;
+
     public void setProcessType(String processType) 
     {
         this.processType = processType;
@@ -67,6 +69,14 @@
         return lockId;
     }
 
+    public ArdTankWall getArdTankWall() {
+        return ardTankWall;
+    }
+
+    public void setArdTankWall(ArdTankWall ardTankWall) {
+        this.ardTankWall = ardTankWall;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
diff --git a/ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankLockMapper.java b/ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankLockMapper.java
index 724c442..5e86eba 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankLockMapper.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankLockMapper.java
@@ -93,4 +93,6 @@
     public List<ArdTankLock> getArdTankLockWithStateByCarId(String carId);
 
     public int updateLockEnableByCarId(@Param("carId")String carId, @Param("enable") String enable);
+
+    public List<ArdTankLock> selectArdTankLockWithWallAndStateByCarId(String carId);
 }
diff --git a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockProcessLogServiceImpl.java b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockProcessLogServiceImpl.java
index 14c3c3c..d1d5335 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockProcessLogServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockProcessLogServiceImpl.java
@@ -217,64 +217,69 @@
             return AjaxResult.error("当前车辆正处在电子围栏外");
         }else{
             try{
-                String lockNumHead = lockNum.substring(0,2);
-                String lockNumTail = lockNum.substring(2,4);
-                String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16)//锁编号高8位
-                        + Integer.parseInt(lockNumTail, 16)//锁编号低8位
-                        + Integer.parseInt("02", 16)//设置锁芯状态功能码02
-                        + Integer.parseInt(process, 16));//操作
-                if(checkNum.length() == 1){
-                    checkNum = "0" + checkNum;
-                }
-                if(checkNum.length() > 2){
-                    checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length());
-                }
-
-                String paramsStr = lockNum + "02" + process + checkNum;
-                paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + paramsStr + "%22%7D";
-                PositionContainer.getCarLockProcessThreadMap().get(carId).get(lockNum).put("lockProcess",new Thread());//加入容器
-                Map<String,Object> result = sendCmd(syURL, ardSyUser.getUserId(), carId, 199, "DataDownTransfer", paramsStr, sessionId);
-                PositionContainer.getCarLockProcessThreadMap().get(carId).get(lockNum).remove("lockProcess");//移除容器
-                if(((String)result.get("rspCode")).equals("0")){
-                    ArdTankLockProcessLog ardTankLockProcessLog = new ArdTankLockProcessLog();
-                    ardTankLockProcessLog.setId(IdUtils.simpleUUID());
-                    ardTankLockProcessLog.setLockId(lockId);
-                    ardTankLockProcessLog.setLockNum(lockNum);
-                    ardTankLockProcessLog.setCarId(carId);
-                    ardTankLockProcessLog.setCarPlate(carPlate);
-                    ardTankLockProcessLog.setUserId(userId);
-                    ardTankLockProcessLog.setUserName(username);
-                    if(process.equals("01")){
-                        ardTankLockProcessLog.setProcess("开动作");
-                    }else if(process.equals("02")){
-                        ardTankLockProcessLog.setProcess("关动作");
+                if(PositionContainer.getCarLockProcessThreadMap().get(carId).get(lockNum).get("lockProcess") != null){
+                    PositionContainer.getCarLockProcessThreadMap().get(carId).get(lockNum).put("lockProcess",new Thread());//加入容器
+                    String lockNumHead = lockNum.substring(0,2);
+                    String lockNumTail = lockNum.substring(2,4);
+                    String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16)//锁编号高8位
+                            + Integer.parseInt(lockNumTail, 16)//锁编号低8位
+                            + Integer.parseInt("02", 16)//设置锁芯状态功能码02
+                            + Integer.parseInt(process, 16));//操作
+                    if(checkNum.length() == 1){
+                        checkNum = "0" + checkNum;
                     }
-                    ardTankLockProcessLog.setProcessReason(processReason);
-                    ardTankLockProcessLog.setLongitude(lng);
-                    ardTankLockProcessLog.setLatitude(lat);
-                    ardTankLockProcessLog.setProcessTime(this.sdf.format(new Date()));
-                    ardTankLockProcessLogMapper.insertArdTankLockProcessLog(ardTankLockProcessLog);
-                    return AjaxResult.success("发送成功");
-                }else if(((String)result.get("rspCode")).equals("-6")){
-                    return AjaxResult.error("找不到车辆");
-                }else if(((String)result.get("rspCode")).equals("-5")){
-                    return AjaxResult.error("找不到用户");
-                }else if(((String)result.get("rspCode")).equals("-4")){
-                    return AjaxResult.error("找不到指令");
-                }else if(((String)result.get("rspCode")).equals("-3")){
-                    return AjaxResult.error("指令发送超时");
-                }else if(((String)result.get("rspCode")).equals("-2")){
-                    return AjaxResult.error("离线待发");
-                }else if(((String)result.get("rspCode")).equals("-1")){
-                    return AjaxResult.error("车辆离线");
-                }else if(((String)result.get("rspCode")).equals("1")){
-                    return AjaxResult.error("发送失败");
-                }else if(((String)result.get("rspCode")).equals("2")){
-                    return AjaxResult.error("消息有误");
-                }else if(((String)result.get("rspCode")).equals("3")){
-                    return AjaxResult.error("不支持");
+                    if(checkNum.length() > 2){
+                        checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length());
+                    }
+
+                    String paramsStr = lockNum + "02" + process + checkNum;
+                    paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + paramsStr + "%22%7D";
+                    //PositionContainer.getCarLockProcessThreadMap().get(carId).get(lockNum).put("lockProcess",new Thread());//加入容器
+                    Map<String,Object> result = sendCmd(syURL, ardSyUser.getUserId(), carId, 199, "DataDownTransfer", paramsStr, sessionId);
+                    PositionContainer.getCarLockProcessThreadMap().get(carId).get(lockNum).remove("lockProcess");//移除容器
+                    if(((String)result.get("rspCode")).equals("0")){
+                        ArdTankLockProcessLog ardTankLockProcessLog = new ArdTankLockProcessLog();
+                        ardTankLockProcessLog.setId(IdUtils.simpleUUID());
+                        ardTankLockProcessLog.setLockId(lockId);
+                        ardTankLockProcessLog.setLockNum(lockNum);
+                        ardTankLockProcessLog.setCarId(carId);
+                        ardTankLockProcessLog.setCarPlate(carPlate);
+                        ardTankLockProcessLog.setUserId(userId);
+                        ardTankLockProcessLog.setUserName(username);
+                        if(process.equals("01")){
+                            ardTankLockProcessLog.setProcess("开动作");
+                        }else if(process.equals("02")){
+                            ardTankLockProcessLog.setProcess("关动作");
+                        }
+                        ardTankLockProcessLog.setProcessReason(processReason);
+                        ardTankLockProcessLog.setLongitude(lng);
+                        ardTankLockProcessLog.setLatitude(lat);
+                        ardTankLockProcessLog.setProcessTime(this.sdf.format(new Date()));
+                        ardTankLockProcessLogMapper.insertArdTankLockProcessLog(ardTankLockProcessLog);
+                        return AjaxResult.success("发送成功");
+                    }else if(((String)result.get("rspCode")).equals("-6")){
+                        return AjaxResult.error("找不到车辆");
+                    }else if(((String)result.get("rspCode")).equals("-5")){
+                        return AjaxResult.error("找不到用户");
+                    }else if(((String)result.get("rspCode")).equals("-4")){
+                        return AjaxResult.error("找不到指令");
+                    }else if(((String)result.get("rspCode")).equals("-3")){
+                        return AjaxResult.error("指令发送超时");
+                    }else if(((String)result.get("rspCode")).equals("-2")){
+                        return AjaxResult.error("离线待发");
+                    }else if(((String)result.get("rspCode")).equals("-1")){
+                        return AjaxResult.error("车辆离线");
+                    }else if(((String)result.get("rspCode")).equals("1")){
+                        return AjaxResult.error("发送失败");
+                    }else if(((String)result.get("rspCode")).equals("2")){
+                        return AjaxResult.error("消息有误");
+                    }else if(((String)result.get("rspCode")).equals("3")){
+                        return AjaxResult.error("不支持");
+                    }else{
+                        return AjaxResult.error("其他原因发送失败");
+                    }
                 }else{
-                    return AjaxResult.error("其他原因发送失败");
+                    return AjaxResult.error("其他操控正在进行中,请稍后");
                 }
             }catch(Exception e){
                 e.printStackTrace();
@@ -315,9 +320,10 @@
             for(ArdTankLock ardTankLock : ardTankLockResult){
                 ArdTankLockState ardTankLockState = ardTankLock.getArdTankLockState();
                 if(ardTankLockState != null){
-                    if(ardTankLockState.getLockState().equals("开锁状态")){
+                    if(ardTankLockState.getLockState().equals("开锁状态") || ardTankLockState.getLockState().equals("异常状态")){
                         String lockNum = ardTankLock.getLockNum();
                         if(PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum) == null){
+                            PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).put("lockProcess",new Thread());//加入容器
                             String lockNumHead = lockNum.substring(0,2);
                             String lockNumTail = lockNum.substring(2,4);
                             String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16)//锁编号高8位
@@ -333,8 +339,7 @@
 
                             String paramsStr = lockNum + "02" + "02" + checkNum;
                             paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + paramsStr + "%22%7D";
-                            PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).put("lockProcess",new Thread());//加入容器
-                            //String syURL = "http://" + ip + ":9999";
+                            //PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).put("lockProcess",new Thread());//加入容器
                             String passwordMd5 = DigestUtils.md5Hex(password);
                             Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, userId);
                             String sessionId = (String) LogInResult.get("sessionId");
@@ -388,9 +393,10 @@
                         for(ArdTankLock ardTankLock : ardTankLockResult){
                             ArdTankLockState ardTankLockState = ardTankLock.getArdTankLockState();
                             if(ardTankLockState != null){
-                                if(ardTankLockState.getLockState().equals("关锁状态")){
+                                if(ardTankLockState.getLockState().equals("关锁状态") || ardTankLockState.getLockState().equals("异常状态")){
                                     String lockNum = ardTankLock.getLockNum();
                                     if(PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).get("lockProcess") == null){
+                                        PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).put("lockProcess",new Thread());//加入容器
                                         String lockNumHead = lockNum.substring(0,2);
                                         String lockNumTail = lockNum.substring(2,4);
                                         String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16)//锁编号高8位
@@ -406,7 +412,7 @@
 
                                         String paramsStr = lockNum + "02" + "01" + checkNum;
                                         paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + paramsStr + "%22%7D";
-                                        PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).put("lockProcess",new Thread());//加入容器
+                                        //PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).put("lockProcess",new Thread());//加入容器
                                         String passwordMd5 = DigestUtils.md5Hex(password);
                                         Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, userId);
                                         String sessionId = (String) LogInResult.get("sessionId");
@@ -444,11 +450,141 @@
                                 continue;
                             }
                         }
+                        break;//处在任意电子围栏中
                     }
                 }
             }
             //电子围栏逻辑
+            Point2D.Double point = new Point2D.Double(((Number) gpsMap.get("lng")).doubleValue(), ((Number) gpsMap.get("lat")).doubleValue());//车辆当前位置
+            List<ArdTankLock> ardTankLockList = ardTankLockMapper.selectArdTankLockWithWallAndStateByCarId((String) gpsMap.get("carId"));
+            for(ArdTankLock ardTankLock : ardTankLockList){
+                ArdTankLockState ardTankLockState = ardTankLock.getArdTankLockState();
+                if(ardTankLockState == null){
+                    break;
+                }
+                String lockState = ardTankLockState.getLockState();
 
+                String lockNum = ardTankLock.getLockNum();
+
+                List<ArdTankWallLock> ardTankWallLockList = ardTankLock.getArdTankWallLockList();//中间表
+                if(ardTankWallLockList.isEmpty()){//没有挂接电子围栏
+                    break;
+                }
+                for(ArdTankWallLock ardTankWallLock : ardTankWallLockList){
+                    ArdTankWall ardTankWall = ardTankWallLock.getArdTankWall();//电子围栏
+
+                    List<Point2D.Double> pts = new ArrayList<Point2D.Double>();
+                    String[] wallpoiArro = ardTankWall.getWallPoi().split(",");
+                    for (int j = 0; j < wallpoiArro.length; j = j + 3) {//构建多边形
+                        pts.add(new Point2D.Double(Double.parseDouble(wallpoiArro[j]), Double.parseDouble(wallpoiArro[j+1])));
+                    }
+                    if(GeoTools.IsPtInPoly(point, pts)){//在电子围栏内
+                        if(ardTankWallLock.getProcessType().equals("1")){//电子围栏操作是否为开锁
+                            if(lockState.equals("关锁状态") || lockState.equals("异常状态")){
+                                //执行开锁动作
+                                if(PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).get("lockProcess") == null){
+                                    PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).put("lockProcess",new Thread());//加入容器
+                                    String lockNumHead = lockNum.substring(0,2);
+                                    String lockNumTail = lockNum.substring(2,4);
+                                    String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16)//锁编号高8位
+                                            + Integer.parseInt(lockNumTail, 16)//锁编号低8位
+                                            + Integer.parseInt("02", 16)//设置锁芯状态功能码02
+                                            + Integer.parseInt("01", 16));//操作
+                                    if(checkNum.length() == 1){
+                                        checkNum = "0" + checkNum;
+                                    }
+                                    if(checkNum.length() > 2){
+                                        checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length());
+                                    }
+
+                                    String paramsStr = lockNum + "02" + "01" + checkNum;
+                                    paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + paramsStr + "%22%7D";
+                                    //PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).put("lockProcess",new Thread());//加入容器
+                                    String passwordMd5 = DigestUtils.md5Hex(password);
+                                    Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, userId);
+                                    String sessionId = (String) LogInResult.get("sessionId");
+                                    try{
+                                        Map<String,Object> result = sendCmd(syURL, userId, (String) gpsMap.get("carId"), 199, "DataDownTransfer", paramsStr, sessionId);
+                                        if(((String)result.get("rspCode")).equals("0")){
+                                            ArdTankLockAutoProcessLog ardTankLockAutoProcessLog = new ArdTankLockAutoProcessLog();
+                                            ardTankLockAutoProcessLog.setId(IdUtils.simpleUUID());
+                                            ardTankLockAutoProcessLog.setLockId(ardTankLock.getId());
+                                            ardTankLockAutoProcessLog.setLockNum(ardTankLock.getLockNum());
+                                            ardTankLockAutoProcessLog.setCarId(ardTankLock.getCarId());
+                                            ardTankLockAutoProcessLog.setCarPlate((String) gpsMap.get("carName"));
+                                            ardTankLockAutoProcessLog.setWallId(ardTankWall.getId());
+                                            ardTankLockAutoProcessLog.setWallName(ardTankWall.getWallName());
+                                            ardTankLockAutoProcessLog.setWallType("永久");
+                                            ardTankLockAutoProcessLog.setProcess("开动作");
+                                            ardTankLockAutoProcessLog.setProcessReason("速度小于" + electromagneticLockVelocity +",并进入电子围栏'" + ardTankWall.getWallName() + "'" + ",开锁");
+                                            ardTankLockAutoProcessLog.setLongitude(String.valueOf(gpsMap.get("lng")));
+                                            ardTankLockAutoProcessLog.setLatitude(String.valueOf(gpsMap.get("lat")));
+                                            ardTankLockAutoProcessLog.setVelocity(String.valueOf(gpsMap.get("speed")));
+                                            ardTankLockAutoProcessLog.setProcessTime(this.sdf.format(new Date()));
+                                            ardTankLockAutoProcessLogMapper.insertArdTankLockAutoProcessLog(ardTankLockAutoProcessLog);
+                                        }
+                                    }catch(Exception e){
+
+                                    }
+                                    PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).remove("lockProcess");//移除容器
+                                }
+                            }
+                        }else if(ardTankWallLock.getProcessType().equals("-1")){//电子围栏操作是否为关锁
+                            if(lockState.equals("开锁状态") || lockState.equals("异常状态")){
+                                //执行关锁动作
+                                if(PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).get("lockProcess") == null){
+                                    String lockNumHead = lockNum.substring(0,2);
+                                    String lockNumTail = lockNum.substring(2,4);
+                                    String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16)//锁编号高8位
+                                            + Integer.parseInt(lockNumTail, 16)//锁编号低8位
+                                            + Integer.parseInt("02", 16)//设置锁芯状态功能码02
+                                            + Integer.parseInt("02", 16));//操作
+                                    if(checkNum.length() == 1){
+                                        checkNum = "0" + checkNum;
+                                    }
+                                    if(checkNum.length() > 2){
+                                        checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length());
+                                    }
+
+                                    String paramsStr = lockNum + "02" + "02" + checkNum;
+                                    paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + paramsStr + "%22%7D";
+                                    PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).put("lockProcess",new Thread());//加入容器
+                                    String passwordMd5 = DigestUtils.md5Hex(password);
+                                    Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, userId);
+                                    String sessionId = (String) LogInResult.get("sessionId");
+                                    try{
+                                        Map<String,Object> result = sendCmd(syURL, userId, (String) gpsMap.get("carId"), 199, "DataDownTransfer", paramsStr, sessionId);
+                                        if(((String)result.get("rspCode")).equals("0")){
+                                            ArdTankLockAutoProcessLog ardTankLockAutoProcessLog = new ArdTankLockAutoProcessLog();
+                                            ardTankLockAutoProcessLog.setId(IdUtils.simpleUUID());
+                                            ardTankLockAutoProcessLog.setLockId(ardTankLock.getId());
+                                            ardTankLockAutoProcessLog.setLockNum(ardTankLock.getLockNum());
+                                            ardTankLockAutoProcessLog.setCarId(ardTankLock.getCarId());
+                                            ardTankLockAutoProcessLog.setCarPlate((String) gpsMap.get("carName"));
+                                            ardTankLockAutoProcessLog.setWallId(ardTankWall.getId());
+                                            ardTankLockAutoProcessLog.setWallName(ardTankWall.getWallName());
+                                            ardTankLockAutoProcessLog.setWallType("永久");
+                                            ardTankLockAutoProcessLog.setProcess("关动作");
+                                            ardTankLockAutoProcessLog.setProcessReason("速度小于" + electromagneticLockVelocity +",并进入电子围栏'" + ardTankWall.getWallName() + "'" + ",关锁");
+                                            ardTankLockAutoProcessLog.setLongitude(String.valueOf(gpsMap.get("lng")));
+                                            ardTankLockAutoProcessLog.setLatitude(String.valueOf(gpsMap.get("lat")));
+                                            ardTankLockAutoProcessLog.setVelocity(String.valueOf(gpsMap.get("speed")));
+                                            ardTankLockAutoProcessLog.setProcessTime(this.sdf.format(new Date()));
+                                            ardTankLockAutoProcessLogMapper.insertArdTankLockAutoProcessLog(ardTankLockAutoProcessLog);
+                                        }
+                                    }catch(Exception e){
+
+                                    }
+                                    PositionContainer.getCarLockProcessThreadMap().get((String) gpsMap.get("carId")).get(lockNum).remove("lockProcess");//移除容器
+                                }
+                            }
+                        }
+                        break;//处在任意电子围栏中
+                    }else{
+                        continue;
+                    }
+                }
+            }
         }
     }
 
diff --git a/ard-work/src/main/resources/mapper/sy/ArdTankLockMapper.xml b/ard-work/src/main/resources/mapper/sy/ArdTankLockMapper.xml
index 0a21a5e..4d5bebe 100644
--- a/ard-work/src/main/resources/mapper/sy/ArdTankLockMapper.xml
+++ b/ard-work/src/main/resources/mapper/sy/ArdTankLockMapper.xml
@@ -62,6 +62,44 @@
         </collection>
     </resultMap>
 
+    <resultMap type="ArdTankLock" id="ArdTankLockWithWallAndStateResult">
+        <result property="id"    column="id"    />
+        <result property="lockNum"    column="lock_num"    />
+        <result property="lockName"    column="lock_name"    />
+        <result property="imgPositionTop"    column="img_position_top"    />
+        <result property="imgPositionLeft"    column="img_position_left"    />
+        <result property="carId"    column="car_id"    />
+        <result property="enable"    column="enable"    />
+        <result property="restartState"    column="restart_state"    />
+        <result property="onlineTime"    column="online_time"    />
+        <association property="ardTankLockState" javaType="com.ruoyi.sy.domain.ArdTankLockState">
+            <result property="id"    column="sid"    />
+            <result property="lockId"    column="slock_id"    />
+            <result property="lockNum"    column="slock_num"    />
+            <result property="lockState"    column="lock_state"    />
+            <result property="lockPositionState"    column="lock_position_state"    />
+            <result property="lockShellState"    column="lock_shell_state"    />
+            <result property="restartState"    column="srestart_state"    />
+            <result property="batterVoltage"    column="batter_voltage"    />
+            <result property="powerVoltage"    column="power_voltage"    />
+            <result property="uploadTime"    column="upload_time"    />
+            <result property="uniqueMark"    column="unique_mark"    />
+            <result property="lockStateMark"    column="lock_state_mark"    />
+        </association>
+        <collection property="ardTankWallLockList" ofType="com.ruoyi.sy.domain.ArdTankWallLock">
+            <result property="processType"    column="process_type"    />
+            <result property="id"    column="mid"    />
+            <result property="wallId"    column="wall_id"    />
+            <result property="lockId"    column="lock_id"    />
+            <association property="ardTankWall" javaType="com.ruoyi.sy.domain.ArdTankWall">
+                <result property="id"    column="wid"    />
+                <result property="wallName"    column="wall_name"    />
+                <result property="wallPoi"    column="wall_poi"    />
+                <result property="wallType"    column="wall_type"    />
+            </association>
+        </collection>
+    </resultMap>
+
     <sql id="selectArdTankLockVo">
         select id, lock_num, lock_name, img_position_top, img_position_left, car_id, enable, restart_state, online_time from ard_tank_lock
     </sql>
@@ -290,4 +328,28 @@
         update ard_tank_lock set enable = #{enable}
         where car_id = #{carId}
     </update>
+
+    <select id="selectArdTankLockWithWallAndStateByCarId" resultMap="ArdTankLockWithWallAndStateResult" >
+        select t.id,t.lock_num,t.lock_name,t.img_position_top,t.img_position_left,
+        t.car_id,t.enable,t.restart_state,t.online_time,t.mid,t.wall_id,t.lock_id,
+        t.process_type,t.wid,t.wall_name,t.wall_poi,t.wall_type,t.sid,t.slock_id,
+        t.slock_num,t.lock_state,t.lock_position_state,t.lock_shell_state,t.srestart_state,
+        t.batter_voltage,t.power_voltage,t.upload_time,t.unique_mark from
+        (select atl.id,atl.lock_num,atl.lock_name,atl.img_position_top,
+        atl.img_position_left,atl.car_id,atl.enable,atl.restart_state,
+        coalesce(atl.online_time,'') as online_time,atwl.id as mid,
+        atwl.wall_id,atwl.lock_id,atwl.process_type,atw.id as wid,
+        atw.wall_name,atw.wall_poi,atw.wall_type,coalesce(atls.id,'') as sid,
+        coalesce(atls.lock_id,'') as slock_id,coalesce(atls.lock_num,'') as slock_num,
+        coalesce(atls.lock_state,'') as lock_state,coalesce(atls.lock_position_state,'') as lock_position_state,
+        coalesce(atls.lock_shell_state,'') as lock_shell_state,coalesce(atls.restart_state,'') as srestart_state,
+        coalesce(atls.batter_voltage,'') as batter_voltage,coalesce(atls.power_voltage,'') as power_voltage,
+        coalesce(atls.upload_time,'') as upload_time,coalesce(atls.unique_mark,'') as unique_mark,
+        rank() over(partition by atl.lock_num order by atls.upload_time desc,atl.lock_num) rn
+        from ard_tank_lock atl
+        inner join ard_tank_wall_lock atwl on atl.id = atwl.lock_id
+        inner join ard_tank_wall atw on atwl.wall_id = atw.id
+        left join ard_tank_lock_state atls on atl."id" = atls.lock_id
+        where atl.car_id = #{carId} and atwl.process_type != '0')t where t.rn = 1
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3