车辆管理模块:新增车辆查询接口和数据表结构
This commit is contained in:
@@ -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.beans.factory.annotation.Autowired;
|
||||
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 jakarta.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 {
|
||||
|
||||
@Autowired
|
||||
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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 车辆 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class VehicleServiceImpl implements VehicleService {
|
||||
|
||||
@Autowired
|
||||
private VehicleBaseMapper vehicleBaseMapper;
|
||||
@Autowired
|
||||
private VehicleLocationMapper vehicleLocationMapper;
|
||||
@Autowired
|
||||
private VehicleBusinessMapper vehicleBusinessMapper;
|
||||
@Autowired
|
||||
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