修复车辆模块字段映射问题

- 修正 VehicleBaseDO:删除不存在的 vehicleNo、noticeModel 等字段,添加 vehicleModelId
- 修正 VehicleLocationDO:使用 vehicleId 替代 vin
- 修正 VehicleBusinessDO:使用 vehicleId 替代 vin,更新字段为实际表结构
- 修正 VehicleStatusDO:使用 vehicleId 替代 vin,更新字段为实际表结构
- 更新所有 Mapper:selectByVins -> selectByVehicleIds
- 更新 Service:使用 vehicleId 作为关联键
- 更新 VehicleRespVO:字段与数据库表结构对应
- 完善 VehicleConvert:补充位置、业务、状态信息的映射

测试结果:
-  分页查询接口正常(100条测试数据)
-  精简列表接口正常
-  车型参数接口正常
This commit is contained in:
kkfluous
2026-03-12 13:55:37 +08:00
parent 3c36ff6adf
commit 40ea4fabd6
12 changed files with 196 additions and 242 deletions

View File

@@ -12,34 +12,13 @@ import lombok.ToString;
@ToString(callSuper = true)
public class VehiclePageReqVO extends PageParam {
@Schema(description = "车牌号(模糊搜索)", example = "A12345")
@Schema(description = "车牌号(模糊搜索)", example = "A12345")
private String plateNo;
@Schema(description = "运营城市-省", example = "广东省")
private String regionProvince;
@Schema(description = "车架号(模糊搜索)", example = "LTEST000000000001")
private String vin;
@Schema(description = "运营城市-市", example = "广州市")
private String regionCity;
@Schema(description = "停车场ID", example = "1")
private Long parkingId;
@Schema(description = "客户ID", example = "1")
private Long customerId;
@Schema(description = "业务部门ID", example = "1")
private Long departmentId;
@Schema(description = "合同ID", example = "1")
private Long contractId;
@Schema(description = "登记所有权", example = "某某租赁公司")
private String ownership;
@Schema(description = "运营状态", example = "1")
private Integer operateStatus;
@Schema(description = "库位状态", example = "3")
private Integer storageStatus;
@Schema(description = "车型ID", example = "1")
private Long vehicleModelId;
}

View File

@@ -14,102 +14,93 @@ public class VehicleRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
// ==================== 基础信息 ====================
@Schema(description = "辆识别代号VIN", requiredMode = Schema.RequiredMode.REQUIRED, example = "LGWEF4A59NS123456")
private String vin;
@Schema(description = "车牌号", example = "粤A12345")
// ==================== 基础信息asset_vehicle_base====================
@Schema(description = "牌号", requiredMode = Schema.RequiredMode.REQUIRED, example = "粤A12345")
private String plateNo;
@Schema(description = "车辆编号", example = "V001")
private String vehicleNo;
@Schema(description = "车辆识别代号VIN", example = "LGWEF4A59NS123456")
private String vin;
@Schema(description = "辆公告型号", example = "BYD7009BEV5")
private String noticeModel;
@Schema(description = "型ID", example = "1")
private Long vehicleModelId;
@Schema(description = "发动机号", example = "ENG12345678")
private String engineNo;
@Schema(description = "行驶证注册日期", example = "2023-07-01")
private LocalDate registerDate;
@Schema(description = "采购日期", example = "2023-06-15")
private LocalDate purchaseDate;
@Schema(description = "采购价格", example = "180000.00")
private BigDecimal purchasePrice;
@Schema(description = "车身颜色", example = "白色")
private String color;
@Schema(description = "出厂年份", example = "2023")
private String year;
@Schema(description = "行驶里程(公里)", example = "12580")
private Integer mileage;
@Schema(description = "运营城市-省", example = "广东省")
private String regionProvince;
@Schema(description = "运营城市-市", example = "广州市")
private String regionCity;
@Schema(description = "归属停车场ID", example = "1")
// ==================== 位置信息asset_vehicle_location====================
@Schema(description = "停车场ID", example = "1")
private Long parkingId;
@Schema(description = "采购入库时间", example = "2023-06-15")
private LocalDate purchaseDate;
@Schema(description = "停车位", example = "A1-001")
private String parkingSpace;
@Schema(description = "行驶证注册日期", example = "2023-07-01")
private LocalDate regDate;
@Schema(description = "入场时间", example = "2024-01-15 10:30:00")
private LocalDateTime entryTime;
@Schema(description = "行驶证检验有效期", example = "2025-07")
private String inspectExpire;
@Schema(description = "出场时间", example = "2024-01-20 16:45:00")
private LocalDateTime exitTime;
@Schema(description = "强制报废期", example = "2038-12-31")
private LocalDate scrapDate;
// ==================== 位置和里程 ====================
@Schema(description = "GPS位置", example = "广东省广州市天河区天河路100号")
private String location;
@Schema(description = "GPS最后上传时间", example = "2024-02-12 14:30:00")
private LocalDateTime gpsTime;
@Schema(description = "行驶公里数KM", example = "12580.50")
private BigDecimal mileage;
// ==================== 业务关联 ====================
// ==================== 业务信息asset_vehicle_business====================
@Schema(description = "客户ID", example = "1")
private Long customerId;
@Schema(description = "业务部门ID", example = "1")
private Long departmentId;
@Schema(description = "业务负责人ID", example = "1")
private Long managerId;
@Schema(description = "合同ID", example = "1")
private Long contractId;
@Schema(description = "登记所有权", example = "某某租赁公司")
private String ownership;
@Schema(description = "交车日期", example = "2024-01-10")
private LocalDate deliveryDate;
// ==================== 状态信息 ====================
@Schema(description = "运营状态", example = "1")
private Integer operateStatus;
@Schema(description = "还车日期", example = "2024-07-10")
private LocalDate returnDate;
@Schema(description = "库位状态", example = "3")
private Integer storageStatus;
@Schema(description = "月租金", example = "3500.00")
private BigDecimal monthlyRent;
@Schema(description = "出库状态", example = "10")
private Integer outStatus;
@Schema(description = "押金", example = "12000.00")
private BigDecimal deposit;
@Schema(description = "预占状态", example = "1")
private Integer preemptStatus;
// ==================== 状态信息asset_vehicle_status====================
@Schema(description = "车辆状态0=正常 1=维修中 2=报废)", example = "0")
private Integer status;
@Schema(description = "整备状态", example = "3")
private Integer prepareStatus;
@Schema(description = "是否已备车", example = "true")
private Boolean isPrepared;
@Schema(description = "过户状态", example = "4")
private Integer transferStatus;
@Schema(description = "是否已交车", example = "false")
private Boolean isDelivered;
@Schema(description = "维修状态", example = "3")
private Integer repairStatus;
@Schema(description = "是否已还车", example = "false")
private Boolean isReturned;
@Schema(description = "证照状态", example = "1")
private Integer licenseStatus;
@Schema(description = "上次保养日期", example = "2024-01-05")
private LocalDate lastMaintainDate;
@Schema(description = "报废状态", example = "3")
private Integer scrapStatus;
@Schema(description = "下次保养日期", example = "2024-04-05")
private LocalDate nextMaintainDate;
@Schema(description = "在线状态", example = "2")
private Integer onlineStatus;
@Schema(description = "上次年检日期", example = "2023-12-20")
private LocalDate lastInspectDate;
@Schema(description = "下次年检日期", example = "2024-12-20")
private LocalDate nextInspectDate;
@Schema(description = "保险到期日期", example = "2024-12-31")
private LocalDate insuranceExpireDate;
// ==================== 系统字段 ====================
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)

View File

@@ -31,50 +31,47 @@ public interface VehicleConvert {
// 基础信息
if (base != null) {
vo.setId(base.getId());
vo.setVin(base.getVin());
vo.setPlateNo(base.getPlateNo());
vo.setVehicleNo(base.getVehicleNo());
vo.setNoticeModel(base.getNoticeModel());
vo.setColor(base.getColor());
vo.setYear(base.getYear());
vo.setRegionProvince(base.getRegionProvince());
vo.setRegionCity(base.getRegionCity());
vo.setParkingId(base.getParkingId());
vo.setVin(base.getVin());
vo.setVehicleModelId(base.getVehicleModelId());
vo.setEngineNo(base.getEngineNo());
vo.setRegisterDate(base.getRegisterDate());
vo.setPurchaseDate(base.getPurchaseDate());
vo.setRegDate(base.getRegDate());
vo.setInspectExpire(base.getInspectExpire());
vo.setScrapDate(base.getScrapDate());
vo.setPurchasePrice(base.getPurchasePrice());
vo.setColor(base.getColor());
vo.setMileage(base.getMileage());
vo.setCreateTime(base.getCreateTime());
}
// 位置和里程
// 位置信息
if (location != null) {
vo.setLocation(location.getLocation());
vo.setGpsTime(location.getGpsTime());
vo.setMileage(location.getMileage());
vo.setParkingId(location.getParkingId());
vo.setParkingSpace(location.getParkingSpace());
vo.setEntryTime(location.getEntryTime());
vo.setExitTime(location.getExitTime());
}
// 业务关联
// 业务信息
if (business != null) {
vo.setCustomerId(business.getCustomerId());
vo.setDepartmentId(business.getDepartmentId());
vo.setManagerId(business.getManagerId());
vo.setContractId(business.getContractId());
vo.setOwnership(business.getOwnership());
vo.setDeliveryDate(business.getDeliveryDate());
vo.setReturnDate(business.getReturnDate());
vo.setMonthlyRent(business.getMonthlyRent());
vo.setDeposit(business.getDeposit());
}
// 状态信息
if (status != null) {
vo.setOperateStatus(status.getOperateStatus());
vo.setStorageStatus(status.getStorageStatus());
vo.setOutStatus(status.getOutStatus());
vo.setPreemptStatus(status.getPreemptStatus());
vo.setPrepareStatus(status.getPrepareStatus());
vo.setTransferStatus(status.getTransferStatus());
vo.setRepairStatus(status.getRepairStatus());
vo.setLicenseStatus(status.getLicenseStatus());
vo.setScrapStatus(status.getScrapStatus());
vo.setOnlineStatus(status.getOnlineStatus());
vo.setStatus(status.getStatus());
vo.setIsPrepared(status.getIsPrepared());
vo.setIsDelivered(status.getIsDelivered());
vo.setIsReturned(status.getIsReturned());
vo.setLastMaintainDate(status.getLastMaintainDate());
vo.setNextMaintainDate(status.getNextMaintainDate());
vo.setLastInspectDate(status.getLastInspectDate());
vo.setNextInspectDate(status.getNextInspectDate());
vo.setInsuranceExpireDate(status.getInsuranceExpireDate());
}
return vo;

View File

@@ -40,14 +40,29 @@ public class VehicleBaseDO extends BaseDO {
private String plateNo;
/**
* 车辆编号
* 车型ID
*/
private String vehicleNo;
private Long vehicleModelId;
/**
* 车辆公告型
* 发动机
*/
private String noticeModel;
private String engineNo;
/**
* 行驶证注册日期
*/
private LocalDate registerDate;
/**
* 采购日期
*/
private LocalDate purchaseDate;
/**
* 采购价格
*/
private java.math.BigDecimal purchasePrice;
/**
* 车身颜色
@@ -55,43 +70,8 @@ public class VehicleBaseDO extends BaseDO {
private String color;
/**
* 出厂年份
* 行驶里程(公里)
*/
private String year;
/**
* 运营城市-省
*/
private String regionProvince;
/**
* 运营城市-市
*/
private String regionCity;
/**
* 归属停车场ID
*/
private Long parkingId;
/**
* 采购入库时间
*/
private LocalDate purchaseDate;
/**
* 行驶证注册日期
*/
private LocalDate regDate;
/**
* 行驶证检验有效期
*/
private String inspectExpire;
/**
* 强制报废期
*/
private LocalDate scrapDate;
private Integer mileage;
}

View File

@@ -6,8 +6,11 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDate;
/**
* 车辆业务关联 DO
* 车辆业务信息 DO
*
* @author 芋道源码
*/
@@ -28,33 +31,38 @@ public class VehicleBusinessDO extends BaseDO {
private Long id;
/**
* 车辆识别代号
* 车辆ID
*/
private String vin;
private Long vehicleId;
/**
* 客户ID
*/
private Long customerId;
/**
* 业务部门ID
*/
private Long departmentId;
/**
* 业务负责人ID
*/
private Long managerId;
/**
* 合同ID
*/
private Long contractId;
/**
* 登记所有权
* 交车日期
*/
private String ownership;
private LocalDate deliveryDate;
/**
* 还车日期
*/
private LocalDate returnDate;
/**
* 月租金
*/
private BigDecimal monthlyRent;
/**
* 押金
*/
private BigDecimal deposit;
}

View File

@@ -6,11 +6,10 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 车辆位置和里程 DO
* 车辆位置信息 DO
*
* @author 芋道源码
*/
@@ -31,23 +30,28 @@ public class VehicleLocationDO extends BaseDO {
private Long id;
/**
* 车辆识别代号
* 车辆ID
*/
private String vin;
private Long vehicleId;
/**
* GPS位置
* 停车场ID
*/
private String location;
private Long parkingId;
/**
* GPS最后上传时间
* 停车位
*/
private LocalDateTime gpsTime;
private String parkingSpace;
/**
* 行驶公里数KM
* 入场时间
*/
private BigDecimal mileage;
private LocalDateTime entryTime;
/**
* 出场时间
*/
private LocalDateTime exitTime;
}

View File

@@ -6,8 +6,10 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.time.LocalDate;
/**
* 车辆状态 DO
* 车辆状态信息 DO
*
* @author 芋道源码
*/
@@ -28,58 +30,53 @@ public class VehicleStatusDO extends BaseDO {
private Long id;
/**
* 车辆识别代号
* 车辆ID
*/
private String vin;
private Long vehicleId;
/**
* 运营状态
* 车辆状态0=正常 1=维修中 2=报废)
*/
private Integer operateStatus;
private Integer status;
/**
* 库位状态
* 是否已备车
*/
private Integer storageStatus;
private Boolean isPrepared;
/**
* 出库状态
* 是否已交车
*/
private Integer outStatus;
private Boolean isDelivered;
/**
* 预占状态
* 是否已还车
*/
private Integer preemptStatus;
private Boolean isReturned;
/**
* 整备状态
* 上次保养日期
*/
private Integer prepareStatus;
private LocalDate lastMaintainDate;
/**
* 过户状态
* 下次保养日期
*/
private Integer transferStatus;
private LocalDate nextMaintainDate;
/**
* 维修状态
* 上次年检日期
*/
private Integer repairStatus;
private LocalDate lastInspectDate;
/**
* 证照状态
* 下次年检日期
*/
private Integer licenseStatus;
private LocalDate nextInspectDate;
/**
* 报废状态
* 保险到期日期
*/
private Integer scrapStatus;
/**
* 在线状态
*/
private Integer onlineStatus;
private LocalDate insuranceExpireDate;
}

View File

@@ -20,18 +20,16 @@ public interface VehicleBaseMapper extends BaseMapperX<VehicleBaseDO> {
default PageResult<VehicleBaseDO> selectPage(VehiclePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<VehicleBaseDO>()
.likeIfPresent(VehicleBaseDO::getPlateNo, reqVO.getPlateNo())
.eqIfPresent(VehicleBaseDO::getRegionProvince, reqVO.getRegionProvince())
.eqIfPresent(VehicleBaseDO::getRegionCity, reqVO.getRegionCity())
.eqIfPresent(VehicleBaseDO::getParkingId, reqVO.getParkingId())
.likeIfPresent(VehicleBaseDO::getVin, reqVO.getVin())
.eqIfPresent(VehicleBaseDO::getVehicleModelId, reqVO.getVehicleModelId())
.orderByDesc(VehicleBaseDO::getId));
}
default List<VehicleBaseDO> selectList(VehiclePageReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<VehicleBaseDO>()
.likeIfPresent(VehicleBaseDO::getPlateNo, reqVO.getPlateNo())
.eqIfPresent(VehicleBaseDO::getRegionProvince, reqVO.getRegionProvince())
.eqIfPresent(VehicleBaseDO::getRegionCity, reqVO.getRegionCity())
.eqIfPresent(VehicleBaseDO::getParkingId, reqVO.getParkingId())
.likeIfPresent(VehicleBaseDO::getVin, reqVO.getVin())
.eqIfPresent(VehicleBaseDO::getVehicleModelId, reqVO.getVehicleModelId())
.orderByDesc(VehicleBaseDO::getId));
}

View File

@@ -8,16 +8,16 @@ import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 车辆业务关联 Mapper
* 车辆业务信息 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface VehicleBusinessMapper extends BaseMapperX<VehicleBusinessDO> {
default List<VehicleBusinessDO> selectByVins(List<String> vins) {
default List<VehicleBusinessDO> selectByVehicleIds(List<Long> vehicleIds) {
return selectList(new LambdaQueryWrapperX<VehicleBusinessDO>()
.in(VehicleBusinessDO::getVin, vins));
.in(VehicleBusinessDO::getVehicleId, vehicleIds));
}
}

View File

@@ -8,16 +8,16 @@ import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 车辆位置和里程 Mapper
* 车辆位置信息 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface VehicleLocationMapper extends BaseMapperX<VehicleLocationDO> {
default List<VehicleLocationDO> selectByVins(List<String> vins) {
default List<VehicleLocationDO> selectByVehicleIds(List<Long> vehicleIds) {
return selectList(new LambdaQueryWrapperX<VehicleLocationDO>()
.in(VehicleLocationDO::getVin, vins));
.in(VehicleLocationDO::getVehicleId, vehicleIds));
}
}

View File

@@ -8,16 +8,16 @@ import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 车辆状态 Mapper
* 车辆状态信息 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface VehicleStatusMapper extends BaseMapperX<VehicleStatusDO> {
default List<VehicleStatusDO> selectByVins(List<String> vins) {
default List<VehicleStatusDO> selectByVehicleIds(List<Long> vehicleIds) {
return selectList(new LambdaQueryWrapperX<VehicleStatusDO>()
.in(VehicleStatusDO::getVin, vins));
.in(VehicleStatusDO::getVehicleId, vehicleIds));
}
}

View File

@@ -51,28 +51,28 @@ public class VehicleServiceImpl implements VehicleService {
return PageResult.empty();
}
// 2. 提取 VIN 列表
List<String> vins = pageResult.getList().stream()
.map(VehicleBaseDO::getVin)
// 2. 提取车辆ID列表
List<Long> vehicleIds = pageResult.getList().stream()
.map(VehicleBaseDO::getId)
.collect(Collectors.toList());
// 3. 批量查询关联表
List<VehicleLocationDO> locations = vehicleLocationMapper.selectByVins(vins);
List<VehicleBusinessDO> businesses = vehicleBusinessMapper.selectByVins(vins);
List<VehicleStatusDO> statuses = vehicleStatusMapper.selectByVins(vins);
List<VehicleLocationDO> locations = vehicleLocationMapper.selectByVehicleIds(vehicleIds);
List<VehicleBusinessDO> businesses = vehicleBusinessMapper.selectByVehicleIds(vehicleIds);
List<VehicleStatusDO> statuses = vehicleStatusMapper.selectByVehicleIds(vehicleIds);
// 4. 组装数据
Map<String, VehicleLocationDO> locationMap = CollectionUtils.convertMap(locations, VehicleLocationDO::getVin);
Map<String, VehicleBusinessDO> businessMap = CollectionUtils.convertMap(businesses, VehicleBusinessDO::getVin);
Map<String, VehicleStatusDO> statusMap = CollectionUtils.convertMap(statuses, VehicleStatusDO::getVin);
// 4. 组装数据(使用 vehicleId 作为 key
Map<Long, VehicleLocationDO> locationMap = CollectionUtils.convertMap(locations, VehicleLocationDO::getVehicleId);
Map<Long, VehicleBusinessDO> businessMap = CollectionUtils.convertMap(businesses, VehicleBusinessDO::getVehicleId);
Map<Long, VehicleStatusDO> statusMap = CollectionUtils.convertMap(statuses, VehicleStatusDO::getVehicleId);
// 5. 转换为 VO
List<VehicleRespVO> list = pageResult.getList().stream()
.map(base -> VehicleConvert.INSTANCE.convert(
base,
locationMap.get(base.getVin()),
businessMap.get(base.getVin()),
statusMap.get(base.getVin())
locationMap.get(base.getId()),
businessMap.get(base.getId()),
statusMap.get(base.getId())
))
.collect(Collectors.toList());