From 463363f6ef3f5761a074016cc7d61778db0d6cd9 Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期三, 18 十月 2023 17:33:05 +0800
Subject: [PATCH] rtu管理
---
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarLockServiceImpl.java | 64 +++++++++++++++------
ard-work/src/main/java/com/ruoyi/sy/vo/CarVo.java | 1
ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarLockController.java | 70 ++++++++++++----------
ard-work/src/main/java/com/ruoyi/sy/service/ArdSyCarLockService.java | 2
4 files changed, 86 insertions(+), 51 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarLockController.java b/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarLockController.java
index a5d3a43..2abf37f 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarLockController.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarLockController.java
@@ -38,6 +38,43 @@
@ApiOperation("鏌ヨ鎵�鏈夋湭鎸傞攣鐨勮溅杈�")
public Results car(){
List<CarVo> list = ardSyCarLockService.car();
+ analysis(list);
+ return Results.succeed(list);
+ }
+
+ @PostMapping("/add")
+ @ApiOperation("娣诲姞rtu")
+ public Results add(String carId){
+ return Results.succeed("鎴愬姛娣诲姞"+ardSyCarLockService.addRtu(carId)+"鏉℃暟鎹�");
+ }
+
+ @DeleteMapping("/del")
+ @ApiOperation("鍒犻櫎rtu")
+ public Results del(String id){
+ return Results.succeed("鎴愬姛鍒犻櫎"+ardSyCarLockService.delCar(id)+"鏉℃暟鎹�");
+ }
+
+ @GetMapping("/one")
+ @ApiOperation("鏌ヨ涓�鏉tu鍙婇攣")
+ public Results one(String carId){
+ return Results.succeed(ardSyCarLockService.carLock(carId));
+ }
+
+ @GetMapping("/query")
+ @ApiOperation("鏌ヨ鎵�鏈塺tu鎸傝浇鐨勮溅杈�")
+ public Results query(){
+ List<CarVo> list = ardSyCarLockService.carList();
+ analysis(list);
+ return Results.succeed(list);
+ }
+
+ @GetMapping("/addLock")
+ @ApiOperation("娣诲姞淇敼閿�")
+ public Results addLock(@RequestBody List<ArdSyCarLock> locks){
+ return Results.succeed(ardSyCarLockService.addUpdLock(locks));
+ }
+
+ public List<CarVo> analysis(List<CarVo> list){
String usersId = SecurityUtils.getUserId();
ArdSyUser ardSyUser = iArdSyUserService.userById(usersId);
String syURL = sysConfigService.getSYURL();
@@ -55,38 +92,7 @@
String drvPhone = (String) jsonObject.get("drvPhone");
carVo.setDrvPhone(drvPhone);
}
- return Results.succeed(list);
+ return list;
}
-
- @PostMapping("/add")
- @ApiOperation("娣诲姞rtu")
- public Results add(String carId){
- return Results.succeed("鎴愬姛娣诲姞"+ardSyCarLockService.addRtu(carId)+"鏉℃暟鎹�");
- }
-
- @DeleteMapping("/del")
- @ApiOperation("鍒犻櫎rtu")
- public Results del(String carId){
- return Results.succeed("鎴愬姛鍒犻櫎"+ardSyCarLockService.delCar(carId)+"鏉℃暟鎹�");
- }
-
- @GetMapping("/one")
- @ApiOperation("鏌ヨ涓�鏉tu鍙婇攣")
- public Results one(String carId){
- return Results.succeed(ardSyCarLockService.carLock(carId));
- }
-
- @GetMapping("/query")
- @ApiOperation("鏌ヨ鎵�鏈塺tu鎸傝浇鐨勮溅杈�")
- public Results query(){
- return Results.succeed(ardSyCarLockService.carList());
- }
-
- @GetMapping("/addLock")
- @ApiOperation("娣诲姞淇敼閿�")
- public Results addLock(@RequestBody List<ArdSyCarLock> locks){
- return Results.succeed(ardSyCarLockService.addUpdLock(locks));
- }
-
}
diff --git a/ard-work/src/main/java/com/ruoyi/sy/service/ArdSyCarLockService.java b/ard-work/src/main/java/com/ruoyi/sy/service/ArdSyCarLockService.java
index 5a94468..cf986df 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/service/ArdSyCarLockService.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/service/ArdSyCarLockService.java
@@ -20,7 +20,7 @@
*/
List<CarVo> carList();
- int delCar(String CarId);
+ int delCar(String id);
List<CarLockVo> carLock(String carId);
diff --git a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarLockServiceImpl.java b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarLockServiceImpl.java
index b66c268..ac7e54c 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarLockServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarLockServiceImpl.java
@@ -4,7 +4,9 @@
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.sy.domain.ArdSyCar;
import com.ruoyi.sy.domain.ArdSyCarLock;
+import com.ruoyi.sy.domain.ArdSyCarRtu;
import com.ruoyi.sy.mapper.ArdSyCarMapper;
+import com.ruoyi.sy.mapper.ArdSyCarRtuMapper;
import com.ruoyi.sy.service.ArdSyCarLockService;
import com.ruoyi.sy.vo.CarLockVo;
import com.ruoyi.sy.vo.CarVo;
@@ -14,6 +16,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
/**
* @author Administrator
@@ -25,40 +28,48 @@
private ArdSyCarMapper ardSyCarMapper;
@Autowired
private SysDeptMapper sysDeptMapper;
+ @Autowired
+ private ArdSyCarRtuMapper rtuMapper;
@Override
public List<CarVo> car() {
- List<CarVo> list = new ArrayList<>();
QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>();
- queryWrapper.isNull("reserved_1");
+ queryWrapper.isNull("reserved_1").or().eq("reserved_1","");
List<ArdSyCar> ardSyCars= ardSyCarMapper.selectList(queryWrapper);
- for (int i = 0; i < ardSyCars.size(); i++) {
- ArdSyCar ardSyCar = ardSyCars.get(i);
- CarVo carVo = new CarVo();
- carVo.setCarId(ardSyCar.getCarId());
- carVo.setCarPicture(ardSyCar.getCarPicture());
- carVo.setCarType(ardSyCar.getCarType());
- carVo.setDeptId(ardSyCar.getDeptId());
- SysDept sysDept = sysDeptMapper.selectById(ardSyCar.getDeptId());
- carVo.setDeptName(sysDept.getDeptName());
- list.add(carVo);
- }
- return list;
+ return carAnalysis(ardSyCars);
}
@Override
public int addRtu(String carId) {
- return 0;
+ ArdSyCarRtu ardSyCarRtu = new ArdSyCarRtu();
+ ardSyCarRtu.setId(String.valueOf(UUID.randomUUID()));
+ ardSyCarRtu.setCarId(carId);
+ ardSyCarRtu.setTopicPublish("/p"+carId+"/");
+ ardSyCarRtu.setTopicSubscribe("/p"+carId+"/set/");
+ rtuMapper.insert(ardSyCarRtu);
+ QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("car_id",carId);
+ ArdSyCar ardSyCar = ardSyCarMapper.selectOne(queryWrapper);
+ ardSyCar.setReserved1(ardSyCarRtu.getId());
+ return ardSyCarMapper.updateById(ardSyCar);
}
@Override
public List<CarVo> carList() {
- return null;
+ QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>();
+ queryWrapper.ne("reserved_1","");
+ List<ArdSyCar> ardSyCars = ardSyCarMapper.selectList(queryWrapper);
+ return carAnalysis(ardSyCars);
}
@Override
- public int delCar(String CarId) {
- return 0;
+ public int delCar(String id) {
+ rtuMapper.deleteById(id);
+ QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("reserved_1",id);
+ ArdSyCar ardSyCar = ardSyCarMapper.selectOne(queryWrapper);
+ ardSyCar.setReserved1("");
+ return ardSyCarMapper.updateById(ardSyCar);
}
@Override
@@ -71,4 +82,21 @@
return 0;
}
+ public List<CarVo> carAnalysis(List<ArdSyCar> ardSyCars){
+ List<CarVo> list = new ArrayList<>();
+ for (int i = 0; i < ardSyCars.size(); i++) {
+ ArdSyCar ardSyCar = ardSyCars.get(i);
+ CarVo carVo = new CarVo();
+ carVo.setCarId(ardSyCar.getCarId());
+ carVo.setCarPicture(ardSyCar.getCarPicture());
+ carVo.setCarType(ardSyCar.getCarType());
+ carVo.setDeptId(ardSyCar.getDeptId());
+ SysDept sysDept = sysDeptMapper.selectById(ardSyCar.getDeptId());
+ carVo.setDeptName(sysDept.getDeptName());
+ carVo.setRtu(ardSyCar.getReserved1());
+ list.add(carVo);
+ }
+ return list;
+ }
+
}
diff --git a/ard-work/src/main/java/com/ruoyi/sy/vo/CarVo.java b/ard-work/src/main/java/com/ruoyi/sy/vo/CarVo.java
index b8fb82e..b448f73 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/vo/CarVo.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/vo/CarVo.java
@@ -15,4 +15,5 @@
private String carPicture;
private String deptId;
private String deptName;
+ private String rtu;
}
--
Gitblit v1.9.3