车辆管理代码更新
parent
bd1724e3c2
commit
e1de510a3e
|
@ -2,6 +2,7 @@ package com.dragon.vehicle.history.common.domain;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -56,6 +57,7 @@ public class Fence {
|
|||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新人
|
||||
|
@ -64,5 +66,6 @@ public class Fence {
|
|||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
}
|
||||
|
|
|
@ -44,9 +44,9 @@ public class ReqCar {
|
|||
*/
|
||||
private Integer carTypeId;
|
||||
/**
|
||||
* 电子围栏ID
|
||||
* 电子围栏
|
||||
*/
|
||||
private Integer fenceId;
|
||||
private String fenceName;
|
||||
/**
|
||||
* 车辆状态 1-在线 0-离线
|
||||
*/
|
||||
|
|
|
@ -95,7 +95,10 @@
|
|||
<artifactId>mybatis-plus-join</artifactId>
|
||||
<version>1.2.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.dragon</groupId>
|
||||
<artifactId>dragon-common-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
|
|
@ -59,4 +59,14 @@ public class CarController {
|
|||
public Result deleteCar(@RequestParam String carVin){
|
||||
return carService.deleteCar(carVin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 入驻新车辆
|
||||
* @param car
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/insertCar")
|
||||
public Result insertCar(@RequestBody Car car){
|
||||
return carService.insertCar(car);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
package com.dragon.vehicle.history.server.controller;
|
||||
|
||||
import com.dragon.common.core.domain.Result;
|
||||
import com.dragon.vehicle.history.common.domain.VehicleOperation;
|
||||
import com.dragon.vehicle.history.server.service.HistoricalTrackService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Wenkang Tang
|
||||
* @date 2023/11/19 19:54
|
||||
|
@ -20,4 +14,6 @@ import java.util.List;
|
|||
public class HistoricalTrackController {
|
||||
@Autowired
|
||||
private HistoricalTrackService historicalTrackService;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.dragon.vehicle.history.server.mapper;
|
||||
|
||||
import com.dragon.vehicle.history.common.domain.Fence;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Wenkang Tang
|
||||
* @date 2023/11/22 20:51
|
||||
* @description
|
||||
*/
|
||||
@Mapper
|
||||
public interface FenceMapper extends MPJBaseMapper<Fence> {
|
||||
}
|
|
@ -39,4 +39,11 @@ public interface CarService {
|
|||
* @return
|
||||
*/
|
||||
Result deleteCar(String carVin);
|
||||
|
||||
/**
|
||||
* 入驻新车辆
|
||||
* @param car
|
||||
* @return
|
||||
*/
|
||||
Result insertCar(Car car);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.dragon.vehicle.history.server.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.dragon.common.core.domain.Result;
|
||||
import com.dragon.vehicle.history.common.domain.Car;
|
||||
|
@ -11,6 +13,7 @@ import com.dragon.vehicle.history.server.mapper.CarMapper;
|
|||
import com.dragon.vehicle.history.server.mapper.CarTypeMapper;
|
||||
import com.dragon.vehicle.history.server.service.CarService;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -22,6 +25,7 @@ import java.util.List;
|
|||
* @description
|
||||
*/
|
||||
@Service
|
||||
@Log4j2
|
||||
public class CarServiceImpl implements CarService {
|
||||
@Autowired
|
||||
private CarMapper carMapper;
|
||||
|
@ -35,6 +39,7 @@ public class CarServiceImpl implements CarService {
|
|||
*/
|
||||
@Override
|
||||
public Result<List<ResCar>> listCar(ReqCar reqCar) {
|
||||
log.info(reqCar);
|
||||
Page<ResCar> resCarPage = new Page<>(reqCar.getPageNum(), reqCar.getPageSize());
|
||||
List<ResCar> resCars = carMapper.selectJoinPage(resCarPage, ResCar.class, new MPJLambdaWrapper<Car>()
|
||||
.selectAll(Car.class)
|
||||
|
@ -47,8 +52,9 @@ public class CarServiceImpl implements CarService {
|
|||
.like(reqCar.getCarVin() != null, Car::getCarVin, reqCar.getCarVin())
|
||||
.eq(reqCar.getCarStatus() != null, Car::getCarStatus, reqCar.getCarStatus())
|
||||
.eq(reqCar.getCarTypeId() != null, CarType::getCarTypeId, reqCar.getCarTypeId())
|
||||
.eq(reqCar.getFenceId() != null, Car::getFenceId, reqCar.getFenceId())).getRecords();
|
||||
return Result.success(resCars);
|
||||
.like(reqCar.getFenceName() != null, Fence::getFenceName, reqCar.getFenceName())
|
||||
).getRecords();
|
||||
return Result.success(resCars,"查询成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +64,7 @@ public class CarServiceImpl implements CarService {
|
|||
@Override
|
||||
public Result<List<CarType>> listCarType() {
|
||||
MPJLambdaWrapper<CarType> carTypeMPJLambdaWrapper = new MPJLambdaWrapper<CarType>().selectAll(CarType.class);
|
||||
return Result.success(carTypeMapper.selectList(carTypeMPJLambdaWrapper));
|
||||
return Result.success(carTypeMapper.selectList(carTypeMPJLambdaWrapper),"查询成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,10 +75,10 @@ public class CarServiceImpl implements CarService {
|
|||
*/
|
||||
@Override
|
||||
public Result updateCar(Car car) {
|
||||
MPJLambdaWrapper<Car> carMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
||||
MPJLambdaWrapper<Car> lambdaWrapper = carMPJLambdaWrapper.eq(Car::getCarVin, car.getCarVin());
|
||||
carMapper.update(car,lambdaWrapper);
|
||||
return Result.success();
|
||||
LambdaUpdateWrapper<Car> wrapper = new LambdaUpdateWrapper<>();
|
||||
LambdaUpdateWrapper<Car> lambdaUpdateWrapper = wrapper.eq(Car::getCarId, car.getCarId());
|
||||
carMapper.update(car,lambdaUpdateWrapper);
|
||||
return Result.success("修改成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,7 +88,28 @@ public class CarServiceImpl implements CarService {
|
|||
*/
|
||||
@Override
|
||||
public Result deleteCar(String carVin) {
|
||||
carMapper.deleteById(carVin);
|
||||
return Result.success();
|
||||
LambdaUpdateWrapper<Car> wrapper = new LambdaUpdateWrapper<>();
|
||||
LambdaUpdateWrapper<Car> carLambdaUpdateWrapper = wrapper.eq(Car::getCarVin, carVin);
|
||||
carMapper.delete(carLambdaUpdateWrapper);
|
||||
return Result.success("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 入驻新车辆
|
||||
* @param car
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result insertCar(Car car) {
|
||||
Car inserCar = new Car();
|
||||
inserCar.setCarTypeId(car.getCarTypeId());
|
||||
inserCar.setCarBrand(car.getCarBrand());
|
||||
inserCar.setCarName(car.getCarName());
|
||||
inserCar.setCarVin(car.getCarVin());
|
||||
inserCar.setFenceId(car.getFenceId());
|
||||
inserCar.setIsDelete(0);
|
||||
inserCar.setCarStatus(0);
|
||||
carMapper.insert(inserCar);
|
||||
return Result.success("添加成功!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.dragon.vehicle.history.server.mapper.FenceMapper">
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue