feat: 车辆管理模块 - 分页查询和精简列表接口
- 创建5张车辆表(垂直分表设计) - 实现分页查询接口(支持9个筛选条件) - 实现精简列表接口(返回id、vin、plateNo) - 创建16个文件(DO、Mapper、VO、Service、Controller)
This commit is contained in:
210
sql/create-vehicle-tables.sql
Normal file
210
sql/create-vehicle-tables.sql
Normal file
@@ -0,0 +1,210 @@
|
||||
-- ==================== 车辆管理表 - 数据库脚本 ====================
|
||||
-- 作者:DBA
|
||||
-- 日期:2026-03-12
|
||||
-- 说明:车辆管理垂直分表设计(5张表)
|
||||
|
||||
-- ==================== 1. 修改车型参数表(添加公告型号) ====================
|
||||
ALTER TABLE `asset_vehicle_model`
|
||||
ADD COLUMN `notice_model` varchar(100) DEFAULT NULL COMMENT '车辆公告型号' AFTER `model_name`,
|
||||
ADD UNIQUE KEY `uk_notice_model` (`notice_model`, `tenant_id`) COMMENT '公告型号唯一性约束';
|
||||
|
||||
-- ==================== 2. 创建车辆基础信息表 ====================
|
||||
CREATE TABLE `asset_vehicle_base` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
|
||||
-- 基础标识信息
|
||||
`vin` varchar(17) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '车辆识别代号(车架号,17位,区分大小写)',
|
||||
`plate_no` varchar(20) DEFAULT NULL COMMENT '车牌号(如:粤A12345)',
|
||||
`vehicle_no` varchar(50) DEFAULT NULL COMMENT '车辆编号(内部编号)',
|
||||
|
||||
-- 车型关联
|
||||
`notice_model` varchar(100) DEFAULT NULL COMMENT '车辆公告型号(关联 asset_vehicle_model.notice_model)',
|
||||
|
||||
-- 车辆个体属性
|
||||
`color` varchar(50) DEFAULT NULL COMMENT '车身颜色',
|
||||
`year` char(4) DEFAULT NULL COMMENT '出厂年份(YYYY格式)',
|
||||
|
||||
-- 运营城市
|
||||
`region_province` varchar(50) DEFAULT NULL COMMENT '运营城市-省',
|
||||
`region_city` varchar(50) DEFAULT NULL COMMENT '运营城市-市',
|
||||
|
||||
-- 停车场
|
||||
`parking_id` bigint DEFAULT NULL COMMENT '归属停车场ID(关联 asset_parking.id)',
|
||||
|
||||
-- 采购和登记信息
|
||||
`purchase_date` date DEFAULT NULL COMMENT '采购入库时间',
|
||||
`reg_date` date DEFAULT NULL COMMENT '行驶证注册日期',
|
||||
`inspect_expire` char(7) DEFAULT NULL COMMENT '行驶证检验有效期(YYYY-MM格式)',
|
||||
|
||||
-- 报废期
|
||||
`scrap_date` date DEFAULT NULL COMMENT '强制报废期',
|
||||
|
||||
-- 系统字段
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除(0=未删除 1=已删除)',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号(多租户隔离)',
|
||||
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `uk_vin_tenant` (`vin`, `tenant_id`) USING BTREE COMMENT 'VIN唯一性约束',
|
||||
KEY `idx_plate_no` (`plate_no`) USING BTREE COMMENT '车牌号查询',
|
||||
KEY `idx_vehicle_no` (`vehicle_no`) USING BTREE COMMENT '车辆编号查询',
|
||||
KEY `idx_notice_model` (`notice_model`) USING BTREE COMMENT '公告型号关联查询',
|
||||
KEY `idx_parking_id` (`parking_id`) USING BTREE COMMENT '停车场查询',
|
||||
KEY `idx_region` (`region_province`, `region_city`) USING BTREE COMMENT '运营城市组合查询',
|
||||
KEY `idx_tenant_deleted` (`tenant_id`, `deleted`) USING BTREE COMMENT '租户隔离 + 逻辑删除'
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='车辆基础信息表';
|
||||
|
||||
-- ==================== 3. 创建车辆位置和里程表 ====================
|
||||
CREATE TABLE `asset_vehicle_location` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
|
||||
-- 车辆标识
|
||||
`vin` varchar(17) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '车辆识别代号',
|
||||
|
||||
-- GPS位置信息
|
||||
`location` varchar(500) DEFAULT NULL COMMENT 'GPS位置(详细地址)',
|
||||
`gps_time` datetime DEFAULT NULL COMMENT 'GPS最后上传时间',
|
||||
|
||||
-- 里程信息
|
||||
`mileage` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '行驶公里数(KM,保留2位小数)',
|
||||
|
||||
-- 系统字段
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `uk_vin_tenant` (`vin`, `tenant_id`) USING BTREE COMMENT 'VIN唯一性约束',
|
||||
KEY `idx_mileage` (`mileage`) USING BTREE COMMENT '里程查询',
|
||||
KEY `idx_gps_time` (`gps_time`) USING BTREE COMMENT 'GPS时间查询',
|
||||
KEY `idx_tenant_deleted` (`tenant_id`, `deleted`) USING BTREE COMMENT '租户隔离 + 逻辑删除'
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='车辆位置和里程表(高频更新)';
|
||||
|
||||
-- ==================== 4. 创建车辆业务关联表 ====================
|
||||
CREATE TABLE `asset_vehicle_business` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
|
||||
-- 车辆标识
|
||||
`vin` varchar(17) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '车辆识别代号',
|
||||
|
||||
-- 业务关联信息
|
||||
`customer_id` bigint DEFAULT NULL COMMENT '客户ID(关联 asset_customer.id)',
|
||||
`department_id` bigint DEFAULT NULL COMMENT '业务部门ID(关联 system_dept.id)',
|
||||
`manager_id` bigint DEFAULT NULL COMMENT '业务负责人ID(关联 system_user.id)',
|
||||
`contract_id` bigint DEFAULT NULL COMMENT '合同ID(关联 asset_contract.id)',
|
||||
`ownership` varchar(100) DEFAULT NULL COMMENT '登记所有权(如:某某租赁公司)',
|
||||
|
||||
-- 系统字段
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `uk_vin_tenant` (`vin`, `tenant_id`) USING BTREE COMMENT 'VIN唯一性约束',
|
||||
KEY `idx_customer_id` (`customer_id`) USING BTREE COMMENT '客户查询',
|
||||
KEY `idx_department_id` (`department_id`) USING BTREE COMMENT '部门查询',
|
||||
KEY `idx_manager_id` (`manager_id`) USING BTREE COMMENT '负责人查询',
|
||||
KEY `idx_contract_id` (`contract_id`) USING BTREE COMMENT '合同查询',
|
||||
KEY `idx_tenant_deleted` (`tenant_id`, `deleted`) USING BTREE COMMENT '租户隔离 + 逻辑删除'
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='车辆业务关联表';
|
||||
|
||||
-- ==================== 5. 创建车辆状态表 ====================
|
||||
CREATE TABLE `asset_vehicle_status` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
|
||||
-- 车辆标识
|
||||
`vin` varchar(17) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '车辆识别代号',
|
||||
|
||||
-- 状态信息(10个状态字段)
|
||||
`operate_status` tinyint NOT NULL DEFAULT 1 COMMENT '运营状态(1=待运营 2=库存 3=租赁 4=自营 5=退出运营)',
|
||||
`storage_status` tinyint DEFAULT NULL COMMENT '库位状态(1=新车入库-待验车 2=新车入库-证照办理 3=库存车-可交付车 4=库存车-不可交付车 5=库存车-呆滞车 6=已交付车-租赁交车 7=已交付车-自营交车 8=已交付车-替换交车 9=退出运营-报废车 10=退出运营-三方退租车 11=退出运营-过户售车)',
|
||||
`out_status` tinyint DEFAULT NULL COMMENT '出库状态(1=异动出库 2=调拨出库 3=展示出库 4=租赁交车 5=自营交车 6=替换交车 7=过户售车 8=外租退车 9=报废出库 10=无)',
|
||||
`preempt_status` tinyint NOT NULL DEFAULT 1 COMMENT '预占状态(1=未预占 2=已预占)',
|
||||
`prepare_status` tinyint DEFAULT NULL COMMENT '整备状态(1=待整备 2=整备中 3=正常 4=无)',
|
||||
`transfer_status` tinyint DEFAULT NULL COMMENT '过户状态(1=过户中 2=内部过户完成 3=销售过户完成 4=无)',
|
||||
`repair_status` tinyint NOT NULL DEFAULT 3 COMMENT '维修状态(1=待服务站接单 2=维修中 3=正常)',
|
||||
`license_status` tinyint NOT NULL DEFAULT 1 COMMENT '证照状态(1=正常 2=异常)',
|
||||
`scrap_status` tinyint NOT NULL DEFAULT 3 COMMENT '报废状态(1=报废中 2=已报废 3=无)',
|
||||
`online_status` tinyint NOT NULL DEFAULT 2 COMMENT '在线状态(1=在线 2=离线)',
|
||||
|
||||
-- 系统字段
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `uk_vin_tenant` (`vin`, `tenant_id`) USING BTREE COMMENT 'VIN唯一性约束',
|
||||
KEY `idx_operate_status` (`operate_status`) USING BTREE COMMENT '运营状态查询',
|
||||
KEY `idx_storage_status` (`storage_status`) USING BTREE COMMENT '库位状态查询',
|
||||
KEY `idx_repair_status` (`repair_status`) USING BTREE COMMENT '维修状态查询',
|
||||
KEY `idx_status_composite` (`operate_status`, `storage_status`, `deleted`) USING BTREE COMMENT '状态组合查询',
|
||||
KEY `idx_tenant_deleted` (`tenant_id`, `deleted`) USING BTREE COMMENT '租户隔离 + 逻辑删除'
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='车辆状态表(高频查询)';
|
||||
|
||||
-- ==================== 6. 创建统一查询视图 ====================
|
||||
CREATE OR REPLACE VIEW `v_asset_vehicle_full` AS
|
||||
SELECT
|
||||
-- 基础信息
|
||||
b.id,
|
||||
b.vin,
|
||||
b.plate_no,
|
||||
b.vehicle_no,
|
||||
b.notice_model,
|
||||
b.color,
|
||||
b.year,
|
||||
b.region_province,
|
||||
b.region_city,
|
||||
b.parking_id,
|
||||
b.purchase_date,
|
||||
b.reg_date,
|
||||
b.inspect_expire,
|
||||
b.scrap_date,
|
||||
|
||||
-- 位置和里程
|
||||
l.location,
|
||||
l.gps_time,
|
||||
l.mileage,
|
||||
|
||||
-- 业务关联
|
||||
biz.customer_id,
|
||||
biz.department_id,
|
||||
biz.manager_id,
|
||||
biz.contract_id,
|
||||
biz.ownership,
|
||||
|
||||
-- 状态信息
|
||||
s.operate_status,
|
||||
s.storage_status,
|
||||
s.out_status,
|
||||
s.preempt_status,
|
||||
s.prepare_status,
|
||||
s.transfer_status,
|
||||
s.repair_status,
|
||||
s.license_status,
|
||||
s.scrap_status,
|
||||
s.online_status,
|
||||
|
||||
-- 系统字段
|
||||
b.creator,
|
||||
b.create_time,
|
||||
b.updater,
|
||||
b.update_time,
|
||||
b.deleted,
|
||||
b.tenant_id
|
||||
FROM asset_vehicle_base b
|
||||
LEFT JOIN asset_vehicle_location l ON b.vin = l.vin AND b.tenant_id = l.tenant_id AND l.deleted = 0
|
||||
LEFT JOIN asset_vehicle_business biz ON b.vin = biz.vin AND b.tenant_id = biz.tenant_id AND biz.deleted = 0
|
||||
LEFT JOIN asset_vehicle_status s ON b.vin = s.vin AND b.tenant_id = s.tenant_id AND s.deleted = 0
|
||||
WHERE b.deleted = 0;
|
||||
@@ -0,0 +1,48 @@
|
||||
package cn.iocoder.yudao.module.asset.controller.admin.vehicle;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehiclePageReqVO;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehicleRespVO;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehicleSimpleRespVO;
|
||||
import cn.iocoder.yudao.module.asset.service.vehicle.VehicleService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 车辆管理")
|
||||
@RestController
|
||||
@RequestMapping("/asset/vehicle")
|
||||
@Validated
|
||||
public class VehicleController {
|
||||
|
||||
@Resource
|
||||
private VehicleService vehicleService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得车辆分页")
|
||||
@PreAuthorize("@ss.hasPermission('asset:vehicle:query')")
|
||||
public CommonResult<PageResult<VehicleRespVO>> getVehiclePage(@Valid VehiclePageReqVO pageReqVO) {
|
||||
PageResult<VehicleRespVO> pageResult = vehicleService.getVehiclePage(pageReqVO);
|
||||
return success(pageResult);
|
||||
}
|
||||
|
||||
@GetMapping("/simple-list")
|
||||
@Operation(summary = "获得车辆精简列表")
|
||||
@PreAuthorize("@ss.hasPermission('asset:vehicle:query')")
|
||||
public CommonResult<List<VehicleSimpleRespVO>> getVehicleSimpleList(@Valid VehiclePageReqVO reqVO) {
|
||||
List<VehicleSimpleRespVO> list = vehicleService.getVehicleSimpleList(reqVO);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 车辆分页查询 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class VehiclePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "车牌号(模糊搜索)", example = "粤A12345")
|
||||
private String plateNo;
|
||||
|
||||
@Schema(description = "运营城市-省", example = "广东省")
|
||||
private String regionProvince;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 车辆 Response VO")
|
||||
@Data
|
||||
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")
|
||||
private String plateNo;
|
||||
|
||||
@Schema(description = "车辆编号", example = "V001")
|
||||
private String vehicleNo;
|
||||
|
||||
@Schema(description = "车辆公告型号", example = "BYD7009BEV5")
|
||||
private String noticeModel;
|
||||
|
||||
@Schema(description = "车身颜色", example = "白色")
|
||||
private String color;
|
||||
|
||||
@Schema(description = "出厂年份", example = "2023")
|
||||
private String year;
|
||||
|
||||
@Schema(description = "运营城市-省", example = "广东省")
|
||||
private String regionProvince;
|
||||
|
||||
@Schema(description = "运营城市-市", example = "广州市")
|
||||
private String regionCity;
|
||||
|
||||
@Schema(description = "归属停车场ID", example = "1")
|
||||
private Long parkingId;
|
||||
|
||||
@Schema(description = "采购入库时间", example = "2023-06-15")
|
||||
private LocalDate purchaseDate;
|
||||
|
||||
@Schema(description = "行驶证注册日期", example = "2023-07-01")
|
||||
private LocalDate regDate;
|
||||
|
||||
@Schema(description = "行驶证检验有效期", example = "2025-07")
|
||||
private String inspectExpire;
|
||||
|
||||
@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;
|
||||
|
||||
// ==================== 业务关联 ====================
|
||||
@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 = "1")
|
||||
private Integer operateStatus;
|
||||
|
||||
@Schema(description = "库位状态", example = "3")
|
||||
private Integer storageStatus;
|
||||
|
||||
@Schema(description = "出库状态", example = "10")
|
||||
private Integer outStatus;
|
||||
|
||||
@Schema(description = "预占状态", example = "1")
|
||||
private Integer preemptStatus;
|
||||
|
||||
@Schema(description = "整备状态", example = "3")
|
||||
private Integer prepareStatus;
|
||||
|
||||
@Schema(description = "过户状态", example = "4")
|
||||
private Integer transferStatus;
|
||||
|
||||
@Schema(description = "维修状态", example = "3")
|
||||
private Integer repairStatus;
|
||||
|
||||
@Schema(description = "证照状态", example = "1")
|
||||
private Integer licenseStatus;
|
||||
|
||||
@Schema(description = "报废状态", example = "3")
|
||||
private Integer scrapStatus;
|
||||
|
||||
@Schema(description = "在线状态", example = "2")
|
||||
private Integer onlineStatus;
|
||||
|
||||
// ==================== 系统字段 ====================
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 车辆精简 Response VO")
|
||||
@Data
|
||||
public class VehicleSimpleRespVO {
|
||||
|
||||
@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")
|
||||
private String plateNo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package cn.iocoder.yudao.module.asset.convert.vehicle;
|
||||
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehicleRespVO;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehicleSimpleRespVO;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.vehicle.VehicleBaseDO;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.vehicle.VehicleBusinessDO;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.vehicle.VehicleLocationDO;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.vehicle.VehicleStatusDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface VehicleConvert {
|
||||
|
||||
VehicleConvert INSTANCE = Mappers.getMapper(VehicleConvert.class);
|
||||
|
||||
/**
|
||||
* 转换为完整响应 VO
|
||||
*/
|
||||
default VehicleRespVO convert(VehicleBaseDO base, VehicleLocationDO location,
|
||||
VehicleBusinessDO business, VehicleStatusDO status) {
|
||||
VehicleRespVO vo = new VehicleRespVO();
|
||||
|
||||
// 基础信息
|
||||
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.setPurchaseDate(base.getPurchaseDate());
|
||||
vo.setRegDate(base.getRegDate());
|
||||
vo.setInspectExpire(base.getInspectExpire());
|
||||
vo.setScrapDate(base.getScrapDate());
|
||||
vo.setCreateTime(base.getCreateTime());
|
||||
}
|
||||
|
||||
// 位置和里程
|
||||
if (location != null) {
|
||||
vo.setLocation(location.getLocation());
|
||||
vo.setGpsTime(location.getGpsTime());
|
||||
vo.setMileage(location.getMileage());
|
||||
}
|
||||
|
||||
// 业务关联
|
||||
if (business != null) {
|
||||
vo.setCustomerId(business.getCustomerId());
|
||||
vo.setDepartmentId(business.getDepartmentId());
|
||||
vo.setManagerId(business.getManagerId());
|
||||
vo.setContractId(business.getContractId());
|
||||
vo.setOwnership(business.getOwnership());
|
||||
}
|
||||
|
||||
// 状态信息
|
||||
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());
|
||||
}
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为精简响应 VO
|
||||
*/
|
||||
default VehicleSimpleRespVO convertSimple(VehicleBaseDO base) {
|
||||
if (base == null) {
|
||||
return null;
|
||||
}
|
||||
VehicleSimpleRespVO vo = new VehicleSimpleRespVO();
|
||||
vo.setId(base.getId());
|
||||
vo.setVin(base.getVin());
|
||||
vo.setPlateNo(base.getPlateNo());
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量转换为精简响应 VO
|
||||
*/
|
||||
default List<VehicleSimpleRespVO> convertSimpleList(List<VehicleBaseDO> list) {
|
||||
return list.stream().map(this::convertSimple).toList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package cn.iocoder.yudao.module.asset.dal.dataobject.vehicle;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 车辆基础信息 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("asset_vehicle_base")
|
||||
@KeySequence("asset_vehicle_base_seq")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class VehicleBaseDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 车辆识别代号(车架号)
|
||||
*/
|
||||
private String vin;
|
||||
|
||||
/**
|
||||
* 车牌号
|
||||
*/
|
||||
private String plateNo;
|
||||
|
||||
/**
|
||||
* 车辆编号
|
||||
*/
|
||||
private String vehicleNo;
|
||||
|
||||
/**
|
||||
* 车辆公告型号
|
||||
*/
|
||||
private String noticeModel;
|
||||
|
||||
/**
|
||||
* 车身颜色
|
||||
*/
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package cn.iocoder.yudao.module.asset.dal.dataobject.vehicle;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 车辆业务关联 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("asset_vehicle_business")
|
||||
@KeySequence("asset_vehicle_business_seq")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class VehicleBusinessDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 车辆识别代号
|
||||
*/
|
||||
private String vin;
|
||||
|
||||
/**
|
||||
* 客户ID
|
||||
*/
|
||||
private Long customerId;
|
||||
|
||||
/**
|
||||
* 业务部门ID
|
||||
*/
|
||||
private Long departmentId;
|
||||
|
||||
/**
|
||||
* 业务负责人ID
|
||||
*/
|
||||
private Long managerId;
|
||||
|
||||
/**
|
||||
* 合同ID
|
||||
*/
|
||||
private Long contractId;
|
||||
|
||||
/**
|
||||
* 登记所有权
|
||||
*/
|
||||
private String ownership;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package cn.iocoder.yudao.module.asset.dal.dataobject.vehicle;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 车辆位置和里程 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("asset_vehicle_location")
|
||||
@KeySequence("asset_vehicle_location_seq")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class VehicleLocationDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 车辆识别代号
|
||||
*/
|
||||
private String vin;
|
||||
|
||||
/**
|
||||
* GPS位置
|
||||
*/
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* GPS最后上传时间
|
||||
*/
|
||||
private LocalDateTime gpsTime;
|
||||
|
||||
/**
|
||||
* 行驶公里数(KM)
|
||||
*/
|
||||
private BigDecimal mileage;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package cn.iocoder.yudao.module.asset.dal.dataobject.vehicle;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 车辆状态 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("asset_vehicle_status")
|
||||
@KeySequence("asset_vehicle_status_seq")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class VehicleStatusDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 车辆识别代号
|
||||
*/
|
||||
private String vin;
|
||||
|
||||
/**
|
||||
* 运营状态
|
||||
*/
|
||||
private Integer operateStatus;
|
||||
|
||||
/**
|
||||
* 库位状态
|
||||
*/
|
||||
private Integer storageStatus;
|
||||
|
||||
/**
|
||||
* 出库状态
|
||||
*/
|
||||
private Integer outStatus;
|
||||
|
||||
/**
|
||||
* 预占状态
|
||||
*/
|
||||
private Integer preemptStatus;
|
||||
|
||||
/**
|
||||
* 整备状态
|
||||
*/
|
||||
private Integer prepareStatus;
|
||||
|
||||
/**
|
||||
* 过户状态
|
||||
*/
|
||||
private Integer transferStatus;
|
||||
|
||||
/**
|
||||
* 维修状态
|
||||
*/
|
||||
private Integer repairStatus;
|
||||
|
||||
/**
|
||||
* 证照状态
|
||||
*/
|
||||
private Integer licenseStatus;
|
||||
|
||||
/**
|
||||
* 报废状态
|
||||
*/
|
||||
private Integer scrapStatus;
|
||||
|
||||
/**
|
||||
* 在线状态
|
||||
*/
|
||||
private Integer onlineStatus;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.module.asset.dal.mysql.vehicle;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehiclePageReqVO;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.vehicle.VehicleBaseDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆基础信息 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
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())
|
||||
.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())
|
||||
.orderByDesc(VehicleBaseDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.asset.dal.mysql.vehicle;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.vehicle.VehicleBusinessDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆业务关联 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface VehicleBusinessMapper extends BaseMapperX<VehicleBusinessDO> {
|
||||
|
||||
default List<VehicleBusinessDO> selectByVins(List<String> vins) {
|
||||
return selectList(new LambdaQueryWrapperX<VehicleBusinessDO>()
|
||||
.in(VehicleBusinessDO::getVin, vins));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.asset.dal.mysql.vehicle;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.vehicle.VehicleLocationDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆位置和里程 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface VehicleLocationMapper extends BaseMapperX<VehicleLocationDO> {
|
||||
|
||||
default List<VehicleLocationDO> selectByVins(List<String> vins) {
|
||||
return selectList(new LambdaQueryWrapperX<VehicleLocationDO>()
|
||||
.in(VehicleLocationDO::getVin, vins));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.asset.dal.mysql.vehicle;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.vehicle.VehicleStatusDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆状态 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface VehicleStatusMapper extends BaseMapperX<VehicleStatusDO> {
|
||||
|
||||
default List<VehicleStatusDO> selectByVins(List<String> vins) {
|
||||
return selectList(new LambdaQueryWrapperX<VehicleStatusDO>()
|
||||
.in(VehicleStatusDO::getVin, vins));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.asset.service.vehicle;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehiclePageReqVO;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehicleRespVO;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehicleSimpleRespVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface VehicleService {
|
||||
|
||||
/**
|
||||
* 获得车辆分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 车辆分页
|
||||
*/
|
||||
PageResult<VehicleRespVO> getVehiclePage(VehiclePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得车辆精简列表
|
||||
*
|
||||
* @param reqVO 查询条件
|
||||
* @return 车辆精简列表
|
||||
*/
|
||||
List<VehicleSimpleRespVO> getVehicleSimpleList(VehiclePageReqVO reqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package cn.iocoder.yudao.module.asset.service.vehicle;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehiclePageReqVO;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehicleRespVO;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehicleSimpleRespVO;
|
||||
import cn.iocoder.yudao.module.asset.convert.vehicle.VehicleConvert;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.vehicle.VehicleBaseDO;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.vehicle.VehicleBusinessDO;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.vehicle.VehicleLocationDO;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.vehicle.VehicleStatusDO;
|
||||
import cn.iocoder.yudao.module.asset.dal.mysql.vehicle.VehicleBaseMapper;
|
||||
import cn.iocoder.yudao.module.asset.dal.mysql.vehicle.VehicleBusinessMapper;
|
||||
import cn.iocoder.yudao.module.asset.dal.mysql.vehicle.VehicleLocationMapper;
|
||||
import cn.iocoder.yudao.module.asset.dal.mysql.vehicle.VehicleStatusMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 车辆 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class VehicleServiceImpl implements VehicleService {
|
||||
|
||||
@Resource
|
||||
private VehicleBaseMapper vehicleBaseMapper;
|
||||
@Resource
|
||||
private VehicleLocationMapper vehicleLocationMapper;
|
||||
@Resource
|
||||
private VehicleBusinessMapper vehicleBusinessMapper;
|
||||
@Resource
|
||||
private VehicleStatusMapper vehicleStatusMapper;
|
||||
|
||||
@Override
|
||||
public PageResult<VehicleRespVO> getVehiclePage(VehiclePageReqVO pageReqVO) {
|
||||
// 1. 查询基础信息(带分页)
|
||||
PageResult<VehicleBaseDO> pageResult = vehicleBaseMapper.selectPage(pageReqVO);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return PageResult.empty();
|
||||
}
|
||||
|
||||
// 2. 提取 VIN 列表
|
||||
List<String> vins = pageResult.getList().stream()
|
||||
.map(VehicleBaseDO::getVin)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 3. 批量查询关联表
|
||||
List<VehicleLocationDO> locations = vehicleLocationMapper.selectByVins(vins);
|
||||
List<VehicleBusinessDO> businesses = vehicleBusinessMapper.selectByVins(vins);
|
||||
List<VehicleStatusDO> statuses = vehicleStatusMapper.selectByVins(vins);
|
||||
|
||||
// 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);
|
||||
|
||||
// 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())
|
||||
))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return new PageResult<>(list, pageResult.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VehicleSimpleRespVO> getVehicleSimpleList(VehiclePageReqVO reqVO) {
|
||||
// 只查询基础信息表,不分页
|
||||
List<VehicleBaseDO> list = vehicleBaseMapper.selectList(reqVO);
|
||||
|
||||
// 转换为精简 VO(只包含 id、vin、plateNo)
|
||||
return VehicleConvert.INSTANCE.convertSimpleList(list);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user