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

- 修正 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) @ToString(callSuper = true)
public class VehiclePageReqVO extends PageParam { public class VehiclePageReqVO extends PageParam {
@Schema(description = "车牌号(模糊搜索)", example = "A12345") @Schema(description = "车牌号(模糊搜索)", example = "A12345")
private String plateNo; private String plateNo;
@Schema(description = "运营城市-省", example = "广东省") @Schema(description = "车架号(模糊搜索)", example = "LTEST000000000001")
private String regionProvince; private String vin;
@Schema(description = "运营城市-市", example = "广州市") @Schema(description = "车型ID", example = "1")
private String regionCity; private Long vehicleModelId;
@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;
} }

View File

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

View File

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

View File

@@ -40,14 +40,29 @@ public class VehicleBaseDO extends BaseDO {
private String plateNo; 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 color;
/** /**
* 出厂年份 * 行驶里程(公里)
*/ */
private String year; private Integer mileage;
/**
* 运营城市-省
*/
private String regionProvince;
/**
* 运营城市-市
*/
private String regionCity;
/**
* 归属停车场ID
*/
private Long parkingId;
/**
* 采购入库时间
*/
private LocalDate purchaseDate;
/**
* 行驶证注册日期
*/
private LocalDate regDate;
/**
* 行驶证检验有效期
*/
private String inspectExpire;
/**
* 强制报废期
*/
private LocalDate scrapDate;
} }

View File

@@ -6,8 +6,11 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*; import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDate;
/** /**
* 车辆业务关联 DO * 车辆业务信息 DO
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@@ -28,33 +31,38 @@ public class VehicleBusinessDO extends BaseDO {
private Long id; private Long id;
/** /**
* 车辆识别代号 * 车辆ID
*/ */
private String vin; private Long vehicleId;
/** /**
* 客户ID * 客户ID
*/ */
private Long customerId; private Long customerId;
/**
* 业务部门ID
*/
private Long departmentId;
/**
* 业务负责人ID
*/
private Long managerId;
/** /**
* 合同ID * 合同ID
*/ */
private Long contractId; 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 com.baomidou.mybatisplus.annotation.TableName;
import lombok.*; import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
* 车辆位置和里程 DO * 车辆位置信息 DO
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@@ -31,23 +30,28 @@ public class VehicleLocationDO extends BaseDO {
private Long id; 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 com.baomidou.mybatisplus.annotation.TableName;
import lombok.*; import lombok.*;
import java.time.LocalDate;
/** /**
* 车辆状态 DO * 车辆状态信息 DO
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@@ -28,58 +30,53 @@ public class VehicleStatusDO extends BaseDO {
private Long id; 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 LocalDate insuranceExpireDate;
/**
* 在线状态
*/
private Integer onlineStatus;
} }

View File

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

View File

@@ -8,16 +8,16 @@ import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
/** /**
* 车辆业务关联 Mapper * 车辆业务信息 Mapper
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Mapper @Mapper
public interface VehicleBusinessMapper extends BaseMapperX<VehicleBusinessDO> { 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>() 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; import java.util.List;
/** /**
* 车辆位置和里程 Mapper * 车辆位置信息 Mapper
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Mapper @Mapper
public interface VehicleLocationMapper extends BaseMapperX<VehicleLocationDO> { 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>() 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; import java.util.List;
/** /**
* 车辆状态 Mapper * 车辆状态信息 Mapper
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Mapper @Mapper
public interface VehicleStatusMapper extends BaseMapperX<VehicleStatusDO> { 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>() 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(); return PageResult.empty();
} }
// 2. 提取 VIN 列表 // 2. 提取车辆ID列表
List<String> vins = pageResult.getList().stream() List<Long> vehicleIds = pageResult.getList().stream()
.map(VehicleBaseDO::getVin) .map(VehicleBaseDO::getId)
.collect(Collectors.toList()); .collect(Collectors.toList());
// 3. 批量查询关联表 // 3. 批量查询关联表
List<VehicleLocationDO> locations = vehicleLocationMapper.selectByVins(vins); List<VehicleLocationDO> locations = vehicleLocationMapper.selectByVehicleIds(vehicleIds);
List<VehicleBusinessDO> businesses = vehicleBusinessMapper.selectByVins(vins); List<VehicleBusinessDO> businesses = vehicleBusinessMapper.selectByVehicleIds(vehicleIds);
List<VehicleStatusDO> statuses = vehicleStatusMapper.selectByVins(vins); List<VehicleStatusDO> statuses = vehicleStatusMapper.selectByVehicleIds(vehicleIds);
// 4. 组装数据 // 4. 组装数据(使用 vehicleId 作为 key
Map<String, VehicleLocationDO> locationMap = CollectionUtils.convertMap(locations, VehicleLocationDO::getVin); Map<Long, VehicleLocationDO> locationMap = CollectionUtils.convertMap(locations, VehicleLocationDO::getVehicleId);
Map<String, VehicleBusinessDO> businessMap = CollectionUtils.convertMap(businesses, VehicleBusinessDO::getVin); Map<Long, VehicleBusinessDO> businessMap = CollectionUtils.convertMap(businesses, VehicleBusinessDO::getVehicleId);
Map<String, VehicleStatusDO> statusMap = CollectionUtils.convertMap(statuses, VehicleStatusDO::getVin); Map<Long, VehicleStatusDO> statusMap = CollectionUtils.convertMap(statuses, VehicleStatusDO::getVehicleId);
// 5. 转换为 VO // 5. 转换为 VO
List<VehicleRespVO> list = pageResult.getList().stream() List<VehicleRespVO> list = pageResult.getList().stream()
.map(base -> VehicleConvert.INSTANCE.convert( .map(base -> VehicleConvert.INSTANCE.convert(
base, base,
locationMap.get(base.getVin()), locationMap.get(base.getId()),
businessMap.get(base.getVin()), businessMap.get(base.getId()),
statusMap.get(base.getVin()) statusMap.get(base.getId())
)) ))
.collect(Collectors.toList()); .collect(Collectors.toList());