From a2e85a4911dd285f7a1ac9fde312187aec597198 Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期二, 23 七月 2024 16:34:54 +0800
Subject: [PATCH] 异常停车逻辑修改提交
---
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockServiceImpl.java | 224 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 202 insertions(+), 22 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 cf528dc..6ac1b8b 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,24 +2,21 @@
import java.util.*;
-import com.dtflys.forest.annotation.Var;
+import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.domain.entity.SysConfig;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.sy.domain.ArdSyUser;
+import com.ruoyi.sy.domain.ArdTankLockState;
import com.ruoyi.sy.mapper.ArdSyUserMapper;
import com.ruoyi.sy.mapper.ArdTankWallLockMapper;
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 +74,6 @@
/**
* 鏂板鐢电閿�
*
- * @param ardTankLock 鐢电閿�
* @return 缁撴灉
*/
@Override
@@ -144,22 +140,23 @@
@Override
//public Results List<Map<String,Object>> getAll(String usersId) {
- public List<Map<String,Object>> getAll(String usersId) {
+ public Map<String,Object> getAll(String usersId) {
+ List<ArdTankLock> ardTankLockList = ardTankLockMapper.getAll();
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");
- List<ArdTankLock> ardTankLockList = ardTankLockMapper.getAll();
+ //List<ArdTankLock> ardTankLockList = ardTankLockMapper.getAll();
List<Map<String,Object>> result = new ArrayList();
for(ArdTankLock ardTankLock : ardTankLockList){
Map<String,Object> map = new HashMap();
@@ -206,23 +203,26 @@
}
}
}
- //return Results.succeed(result0);
- return result0;
+ Long total = ardTankLockMapper.selectArdTankLockTotal();
+ Map<String,Object> resultMap = new HashMap();
+ resultMap.put("list",result0);
+ resultMap.put("total",total);
+ return resultMap;
}
@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");
@@ -265,6 +265,24 @@
}else{
map.put("onlineTime",ardTankLock.getOnlineTime());
}
+ if(ardTankLock.getArdTankLockState() != null){//鐢电閿佺姸鎬�
+ map.put("ardTankLockState",ardTankLock.getArdTankLockState());
+ }else{
+ ArdTankLockState ardTankLockState = new ArdTankLockState();
+ ardTankLockState.setId("");
+ ardTankLockState.setLockId("");
+ ardTankLockState.setLockNum("");
+ ardTankLockState.setLockState("");
+ ardTankLockState.setLockPositionState("");
+ ardTankLockState.setLockShellState("");
+ ardTankLockState.setRestartState("");
+ ardTankLockState.setBatterVoltage("");
+ ardTankLockState.setPowerVoltage("");
+ ardTankLockState.setUploadTime("");
+ ardTankLockState.setUniqueMark("");
+ ardTankLockState.setLockStateMark(false);
+ map.put("ardTankLockState",ardTankLockState);
+ }
Map<String,Object> carMap = ((List<Map<String,Object>>)syResult.get("list")).get(0);
map.put("carPlate",carMap.get("carPlate"));
result.add(map);
@@ -278,4 +296,166 @@
int result = ardTankLockMapper.deleteLockByCarId(carId);
return result;
}
+
+ @Override
+ public int updateLockByCarId(Map<String, Object> para) {
+ int result = 0;
+ String carId = (String) para.get("carId");
+ List<ArdTankLock> ardTankLockOldList = ardTankLockMapper.getLockByCarId(carId);
+ Set<String> idSet = new HashSet();//涔嬪墠鐨勪富閿�
+ for(ArdTankLock ardTankLock : ardTankLockOldList){
+ idSet.add(ardTankLock.getId());
+ }
+ //Set<String> newIdSet = new HashSet();//浼犲弬鐨勪富閿�
+ List<Map<String,Object>> lockList = (List<Map<String, Object>>) para.get("lockList");
+ if(lockList.isEmpty()){//鏁扮粍涓虹┖锛屽仛鍒犻櫎鎿嶄綔
+ if(ardTankLockOldList.isEmpty()){//鑻ユ病鏈夋寕鎺ワ紝涓嶅仛鎿嶄綔
+ return 1;
+ }
+ result = ardTankLockMapper.deleteLockByCarId(carId);
+ return result;
+ }
+
+ List<ArdTankLock> ardTankLocks = new ArrayList();
+ for(Map<String,Object> map : lockList){
+ if(map.get("id") != null){//鏈変富閿紝鍋氫慨鏀规搷浣�
+ //newIdSet.add((String) map.get("id"));
+ idSet.remove((String) map.get("id"));
+ ArdTankLock ardTankLock = new ArdTankLock();
+ ardTankLock.setId((String) map.get("id"));
+ ardTankLock.setLockNum((String) map.get("lockNum"));
+ ardTankLock.setLockName((String) map.get("lockName"));
+ ardTankLock.setImgPositionTop((String) map.get("imgPositionTop"));
+ ardTankLock.setImgPositionLeft((String) map.get("imgPositionLeft"));
+ ardTankLock.setCarId((String) map.get("carId"));
+ ardTankLock.setEnable((String) map.get("enable"));
+ result = result + ardTankLockMapper.updateArdTankLock(ardTankLock);
+ }else{//鏃犱富閿紝鍋氭柊澧炴搷浣�
+ ArdTankLock ardTankLock = new ArdTankLock();
+ ardTankLock.setId(IdUtils.simpleUUID());
+ ardTankLock.setLockNum((String) map.get("lockNum"));
+ ardTankLock.setLockName((String) map.get("lockName"));
+ ardTankLock.setImgPositionTop((String) map.get("imgPositionTop"));
+ ardTankLock.setImgPositionLeft((String) map.get("imgPositionLeft"));
+ ardTankLock.setCarId(carId);
+ ardTankLock.setEnable((String) map.get("enable"));
+ ardTankLocks.add(ardTankLock);
+ }
+ }
+ if(ardTankLocks.size() != 0){
+ result = result + ardTankLockMapper.insertArdTankLocks(ardTankLocks);
+ }
+ if(!idSet.isEmpty()){
+ result = result + ardTankLockMapper.deleteArdTankLockByIdSet(idSet);
+ }
+ return result;
+ }
+
+ @Override
+ public Map<String,Object> getLockByCarPlate(String usersId, String carPlate, Integer pageNum, Integer pageSize) {
+ ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId);
+ 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 new HashMap();
+ }
+ 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 = new ArrayList();
+ List<Map<String,Object>> result = new ArrayList();
+ List<String> carIdList = 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 HashMap();
+ }
+ //List<String> carIdList = new ArrayList();//璁板綍涓変竴杞﹁締涓婚敭
+ for(Map<String,Object> map : carList){
+ carIdList.add((String) map.get("carId"));
+ }
+ PageHelper.startPage(pageNum, pageSize);//鍒嗛〉
+ ardTankLockList = ardTankLockMapper.getLockByCarIdList(carIdList);
+ for(ArdTankLock ardTankLock : ardTankLockList){
+ if(carIdList.contains(ardTankLock.getCarId())){//杩斿洖鐨勮溅杈嗗寘鍚暟鎹簱褰曞叆鐨勮溅杈�
+ Map<String,Object> 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{
+ PageHelper.startPage(pageNum, pageSize);//鍒嗛〉
+ ardTankLockList = ardTankLockMapper.getAll();
+ for(ArdTankLock ardTankLock : ardTankLockList){
+ Map<String,Object> 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);
+ }
+ }
+ Long total = Long.valueOf(0);
+ if(!carPlate.equals("")){
+ total = ardTankLockMapper.selectArdTankLockTotalByCarIdList(carIdList);
+ }else{
+ total = ardTankLockMapper.selectArdTankLockAllTotal();
+ }
+ Map<String,Object> mapResult = new HashMap();
+ mapResult.put("list",result);
+ mapResult.put("total",total);
+ return mapResult;
+ }
+
+ @Override
+ public List<ArdTankLock> getArdTankLockAll() {
+ List<ArdTankLock> result = ardTankLockMapper.getAll();
+ return result;
+ }
}
--
Gitblit v1.9.3