From cb77a6b162f59b6664e10bdfc26463fc909f4c22 Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期三, 18 十月 2023 15:48:55 +0800
Subject: [PATCH] 查询所有未挂锁的车辆
---
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarLockServiceImpl.java | 36 +++++++++++++++++-
ard-work/src/main/java/com/ruoyi/sy/vo/CarVo.java | 2
ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarLockController.java | 61 +++++++++++++++++++++++++-----
ard-work/src/main/java/com/ruoyi/sy/service/ArdSyCarLockService.java | 2
4 files changed, 87 insertions(+), 14 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 d467c11..a5d3a43 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
@@ -1,51 +1,92 @@
package com.ruoyi.sy.controller;
+import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.sy.domain.ArdSyCarLock;
+import com.ruoyi.sy.domain.ArdSyUser;
+import com.ruoyi.sy.service.ArdSyCarLockService;
+import com.ruoyi.sy.service.IArdSyCarService;
+import com.ruoyi.sy.service.IArdSyUserService;
+import com.ruoyi.sy.vo.CarVo;
+import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.utils.result.Results;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
@RestController
@RequestMapping("syLock")
@Api(tags = "杞﹁締閿佺鐞�")
public class ArdSyCarLockController {
+ @Autowired
+ private IArdSyUserService iArdSyUserService;
+ @Autowired
+ private ISysConfigService sysConfigService;
+ @Autowired
+ private IArdSyCarService ardSyCarService;
+ @Autowired
+ private ArdSyCarLockService ardSyCarLockService;
+
@GetMapping("/car")
@ApiOperation("鏌ヨ鎵�鏈夋湭鎸傞攣鐨勮溅杈�")
public Results car(){
- return Results.succeed();
+ List<CarVo> list = ardSyCarLockService.car();
+ String usersId = SecurityUtils.getUserId();
+ ArdSyUser ardSyUser = iArdSyUserService.userById(usersId);
+ String syURL = sysConfigService.getSYURL();
+ for (int i = 0; i < list.size(); i++) {
+ CarVo carVo = list.get(i);
+ String carId = carVo.getCarId();
+ Results results = ardSyCarService.getCarGPSBycarId(usersId,carId,syURL,ardSyUser);
+ Map<String,Object> map = (Map<String, Object>) results.getData();
+ List list1 = (List) map.get("list");
+ JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(list1.get(0)));
+ String carPlate = (String) jsonObject.get("carPlate");
+ carVo.setCarPlate(carPlate);
+ String drvName = (String) jsonObject.get("drvName");
+ carVo.setDrvName(drvName);
+ String drvPhone = (String) jsonObject.get("drvPhone");
+ carVo.setDrvPhone(drvPhone);
+ }
+ return Results.succeed(list);
}
@PostMapping("/add")
@ApiOperation("娣诲姞rtu")
- public Results add(){
- return Results.succeed("鎴愬姛娣诲姞"+1+"鏉℃暟鎹�");
+ public Results add(String carId){
+ return Results.succeed("鎴愬姛娣诲姞"+ardSyCarLockService.addRtu(carId)+"鏉℃暟鎹�");
}
@DeleteMapping("/del")
@ApiOperation("鍒犻櫎rtu")
- public Results del(String id){
- return Results.succeed("鎴愬姛鍒犻櫎"+1+"鏉℃暟鎹�");
+ public Results del(String carId){
+ return Results.succeed("鎴愬姛鍒犻櫎"+ardSyCarLockService.delCar(carId)+"鏉℃暟鎹�");
}
@GetMapping("/one")
@ApiOperation("鏌ヨ涓�鏉tu鍙婇攣")
- public Results one(String id){
- return Results.succeed();
+ public Results one(String carId){
+ return Results.succeed(ardSyCarLockService.carLock(carId));
}
@GetMapping("/query")
@ApiOperation("鏌ヨ鎵�鏈塺tu鎸傝浇鐨勮溅杈�")
public Results query(){
- return Results.succeed();
+ return Results.succeed(ardSyCarLockService.carList());
}
@GetMapping("/addLock")
- @ApiOperation("鏌ヨ鎵�鏈塺tu鎸傝浇鐨勮溅杈�")
+ @ApiOperation("娣诲姞淇敼閿�")
public Results addLock(@RequestBody List<ArdSyCarLock> locks){
- return Results.succeed();
+ 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 b17bc54..5a94468 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
@@ -24,6 +24,6 @@
List<CarLockVo> carLock(String carId);
- int addUpdLock(ArdSyCarLock ardSyCarLock);
+ int addUpdLock(List<ArdSyCarLock> ardSyCarLock);
}
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 055a6f3..b66c268 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
@@ -1,18 +1,49 @@
package com.ruoyi.sy.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ruoyi.common.core.domain.entity.SysDept;
+import com.ruoyi.sy.domain.ArdSyCar;
import com.ruoyi.sy.domain.ArdSyCarLock;
+import com.ruoyi.sy.mapper.ArdSyCarMapper;
import com.ruoyi.sy.service.ArdSyCarLockService;
import com.ruoyi.sy.vo.CarLockVo;
import com.ruoyi.sy.vo.CarVo;
+import com.ruoyi.system.mapper.SysDeptMapper;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
import java.util.List;
+/**
+ * @author Administrator
+ */
@Service
public class ArdSyCarLockServiceImpl implements ArdSyCarLockService {
+
+ @Autowired
+ private ArdSyCarMapper ardSyCarMapper;
+ @Autowired
+ private SysDeptMapper sysDeptMapper;
+
@Override
public List<CarVo> car() {
- return null;
+ List<CarVo> list = new ArrayList<>();
+ QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>();
+ queryWrapper.isNull("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;
}
@Override
@@ -36,7 +67,8 @@
}
@Override
- public int addUpdLock(ArdSyCarLock ardSyCarLock) {
+ public int addUpdLock(List<ArdSyCarLock> ardSyCarLock) {
return 0;
}
+
}
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 9c1c09a..b8fb82e 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
@@ -13,6 +13,6 @@
private String drvPhone;
private String carType;
private String carPicture;
- private Integer deptId;
+ private String deptId;
private String deptName;
}
--
Gitblit v1.9.3