This commit is contained in:
PQZ 2024-08-01 17:25:26 +08:00
commit cdbc9919f3
8 changed files with 605 additions and 0 deletions

View File

@ -0,0 +1,99 @@
package cn.iocoder.yudao.module.custom.controller.admin;
import cn.iocoder.yudao.module.custom.entity.CarMain;
import cn.iocoder.yudao.module.custom.service.CarMainService;
import cn.iocoder.yudao.module.custom.vo.CarMainReqVO;
import cn.iocoder.yudao.module.custom.vo.CarMainRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
@Tag(name = "管理后台 - 车辆信息")
@RestController
@RequestMapping("/base/carMain")
@Validated
public class CarMainController {
@Resource
private CarMainService carMainService;
@PostMapping("/create")
@Operation(summary = "创建车辆信息")
@PreAuthorize("@ss.hasPermission('base:car-main:create')")
public CommonResult<String> createCarMain(@RequestBody CarMainReqVO createReqVO) {
return success(carMainService.createCarMain(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新车辆信息")
@PreAuthorize("@ss.hasPermission('base:car-main:update')")
public CommonResult<Boolean> updateCarMain(@RequestBody CarMainReqVO updateReqVO) {
carMainService.updateCarMain(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除车辆信息")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('base:car-main:delete')")
public CommonResult<Boolean> deleteCarMain(@RequestParam("id") String id) {
carMainService.deleteCarMain(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得车辆信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('base:car-main:query')")
public CommonResult<CarMainRespVO> getCarMain(@RequestParam("id") String id) {
CarMain carMain = carMainService.getCarMain(id);
return success(BeanUtils.toBean(carMain, CarMainRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得车辆信息分页")
@PreAuthorize("@ss.hasPermission('base:car-main:query')")
public CommonResult<IPage<CarMainRespVO>> getCarMainPage(CarMainReqVO pageReqVO) {
IPage<CarMainRespVO> pageResult = carMainService.getCarMainPage(pageReqVO);
return success(pageResult);
}
@GetMapping("/export-excel")
@Operation(summary = "导出车辆信息 Excel")
@PreAuthorize("@ss.hasPermission('base:car-main:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportCarMainExcel(CarMainReqVO pageReqVO, HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<CarMainRespVO> list = carMainService.getCarMainPage(pageReqVO).getRecords();
// 导出 Excel
ExcelUtils.write(response, "车辆信息.xls", "数据", CarMainRespVO.class,
BeanUtils.toBean(list, CarMainRespVO.class));
}
}

View File

@ -0,0 +1,121 @@
package cn.iocoder.yudao.module.custom.entity;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 车辆信息 DO
*
* @author 后台管理员
*/
@TableName("base_car_main")
@Data
@EqualsAndHashCode(callSuper = true)
public class CarMain extends TenantBaseDO {
/**
* 主键标识
*/
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/**
* 发动机号码
*/
private String engineNumber;
/**
* 车架号
*/
private String vin;
/**
* 车牌号
*/
private String licenseNumber;
/**
* 车辆型号
*/
private String carModel;
/**
* 保养日期
*/
private LocalDateTime maintenanceDate;
/**
* 保养里程
*/
private String maintenanceMileage;
/**
* 年检日期
*/
private LocalDateTime inspectionDate;
/**
* 保险日期
*/
private LocalDateTime insuranceDate;
/**
* 二级维护时间
*/
private LocalDateTime checkDate;
/**
* 下次保养日期
*/
private LocalDateTime nextMaintenanceDate;
/**
* 下次保养里程
*/
private Integer nextMaintenanceMileage;
/**
* 下次年检日期
*/
private LocalDateTime nextInspectionDate;
/**
* 保险到期日期
*/
private LocalDateTime insuranceExpiryDate;
/**
* 下次二级维护时间
*/
private LocalDateTime nextCheckDate;
/**
* 车辆品牌
*/
private String carBrand;
/**
* 车辆性质营运 非营运等
*/
private String carNature;
/**
* 车辆类别私家车 货车 教练车 公务车 出租车
*/
private String carCategory;
/**
* 车辆注册日期
*/
private LocalDateTime carRegisterDate;
/**
* 行驶证图片
*/
private String carLicenseImg;
/**
* 最近办理业务
*/
private String recentlyHandledBusiness;
/**
* 最近办理业务的时间
*/
private LocalDateTime recentlyHandleBusinessTime;
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.custom.mapper;
import cn.iocoder.yudao.module.custom.entity.CarMain;
import cn.iocoder.yudao.module.custom.vo.CarMainReqVO;
import cn.iocoder.yudao.module.custom.vo.CarMainRespVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 车辆信息 Mapper
*
* @author 后台管理员
*/
@Mapper
public interface CarMainMapper extends BaseMapper<CarMain> {
IPage<CarMainRespVO> findPage(Page<CarMain> page, @Param("dto") CarMainReqVO pageReqVO);
}

View File

@ -0,0 +1,60 @@
package cn.iocoder.yudao.module.custom.service;
import javax.validation.*;
import cn.iocoder.yudao.module.custom.entity.CarMain;
import cn.iocoder.yudao.module.custom.vo.CarMainReqVO;
import cn.iocoder.yudao.module.custom.vo.CarMainRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 车辆信息 Service 接口
*
* @author 后台管理员
*/
public interface CarMainService extends IService<CarMain> {
/**
* 创建车辆信息
*
* @param createReqVO 创建信息
* @return 编号
*/
String createCarMain(CarMainReqVO createReqVO);
/**
* 更新车辆信息
*
* @param updateReqVO 更新信息
*/
void updateCarMain(CarMainReqVO updateReqVO);
/**
* 删除车辆信息
*
* @param id 编号
*/
void deleteCarMain(String id);
/**
* 获得车辆信息
*
* @param id 编号
* @return 车辆信息
*/
CarMain getCarMain(String id);
/**
* 获得车辆信息分页
*
* @param pageReqVO 分页查询
* @return 车辆信息分页
*/
IPage<CarMainRespVO> getCarMainPage(CarMainReqVO pageReqVO);
}

View File

@ -0,0 +1,58 @@
package cn.iocoder.yudao.module.custom.service.impl;
import cn.iocoder.yudao.module.custom.entity.CarMain;
import cn.iocoder.yudao.module.custom.mapper.CarMainMapper;
import cn.iocoder.yudao.module.custom.service.CarMainService;
import cn.iocoder.yudao.module.custom.vo.CarMainReqVO;
import cn.iocoder.yudao.module.custom.vo.CarMainRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
/**
* 车辆信息 Service 实现类
*
* @author 后台管理员
*/
@Service
public class CarMainServiceImpl extends ServiceImpl<CarMainMapper, CarMain> implements CarMainService{
@Override
public String createCarMain(CarMainReqVO createReqVO) {
// 插入
CarMain carMain = BeanUtils.toBean(createReqVO, CarMain.class);
baseMapper.insert(carMain);
// 返回
return carMain.getId();
}
@Override
public void updateCarMain(CarMainReqVO updateReqVO){
// 更新
CarMain updateObj = BeanUtils.toBean(updateReqVO, CarMain.class);
baseMapper.updateById(updateObj);
}
@Override
public void deleteCarMain(String id) {
// 删除
baseMapper.deleteById(id);
}
@Override
public CarMain getCarMain(String id) {
return baseMapper.selectById(id);
}
@Override
public IPage<CarMainRespVO> getCarMainPage(CarMainReqVO pageReqVO) {
Page<CarMain> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
return baseMapper.findPage(page,pageReqVO);
}
}

View File

@ -0,0 +1,83 @@
package cn.iocoder.yudao.module.custom.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 车辆信息分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CarMainReqVO extends PageParam {
@Schema(description = "主键ID")
private String id;
@Schema(description = "发动机号码")
private String engineNumber;
@Schema(description = "车架号")
private String vin;
@Schema(description = "车牌号")
private String licenseNumber;
@Schema(description = "车辆型号")
private String carModel;
@Schema(description = "保养日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime maintenanceDate;
@Schema(description = "保养里程")
private String maintenanceMileage;
@Schema(description = "年检日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime inspectionDate;
@Schema(description = "保险日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime insuranceDate;
@Schema(description = "二级维护时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime checkDate;
@Schema(description = "车辆品牌")
private String carBrand;
@Schema(description = "车辆性质:营运 非营运等")
private String carNature;
@Schema(description = "车辆类别:私家车 货车 教练车 公务车 出租车")
private String carCategory;
@Schema(description = "车辆注册日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime carRegisterDate;
@Schema(description = "行驶证图片")
private String carLicenseImg;
@Schema(description = "最近办理业务")
private String recentlyHandledBusiness;
@Schema(description = "最近办理业务的时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime recentlyHandleBusinessTime;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime createTime;
@Schema(description = "租户ID")
private String tenantId;
}

View File

@ -0,0 +1,89 @@
package cn.iocoder.yudao.module.custom.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 车辆信息 Response VO")
@Data
@ExcelIgnoreUnannotated
public class CarMainRespVO {
@Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "8714")
@ExcelProperty("主键标识")
private String id;
@Schema(description = "发动机号码", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("发动机号码")
private String engineNumber;
@Schema(description = "车架号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("车架号")
private String vin;
@Schema(description = "车牌号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("车牌号")
private String licenseNumber;
@Schema(description = "车辆型号")
@ExcelProperty("车辆型号")
private String carModel;
@Schema(description = "保养日期")
@ExcelProperty("保养日期")
private LocalDateTime maintenanceDate;
@Schema(description = "保养里程")
@ExcelProperty("保养里程")
private String maintenanceMileage;
@Schema(description = "年检日期", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("年检日期")
private LocalDateTime inspectionDate;
@Schema(description = "保险日期")
@ExcelProperty("保险日期")
private LocalDateTime insuranceDate;
@Schema(description = "二级维护时间")
@ExcelProperty("二级维护时间")
private LocalDateTime checkDate;
@Schema(description = "车辆品牌", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("车辆品牌")
private String carBrand;
@Schema(description = "车辆性质:营运 非营运等", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("车辆性质")
private String carNature;
@Schema(description = "车辆类别:私家车 货车 教练车 公务车 出租车")
@ExcelProperty("车辆类别")
private String carCategory;
@Schema(description = "车辆注册日期", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("车辆注册日期")
private LocalDateTime carRegisterDate;
@Schema(description = "行驶证图片")
@ExcelProperty("行驶证图片")
private String carLicenseImg;
@Schema(description = "最近办理业务")
@ExcelProperty("最近办理业务")
private String recentlyHandledBusiness;
@Schema(description = "最近办理业务的时间")
@ExcelProperty("最近办理业务的时间")
private LocalDateTime recentlyHandleBusinessTime;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.custom.mapper.CarMainMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<sql id="column">
id,
engine_number,
vin,
license_number,
car_model,
maintenance_date,
maintenance_mileage,
inspection_date,
insurance_date,
check_date,
next_maintenance_date,
next_maintenance_mileage,
next_inspection_date,
insurance_expiry_date,
next_check_date,
car_brand,
car_nature,
car_category,
car_register_date,
car_license_img,
recently_handled_business,
recently_handle_business_time,
deleted,
creator,
create_time,
updater,
update_time
</sql>
<select id="findPage" resultType="cn.iocoder.yudao.module.custom.vo.CarMainRespVO">
SELECT
<include refid="column"></include>
FROM `base_car_main`
WHERE
deleted = 0
<if test="dto.licenseNumber != null and dto.licenseNumber != ''">
AND license_number LIKE CONCAT('%',#{dto.licenseNumber},'%')
</if>
<if test="dto.carBrand != null and dto.carBrand != ''">
AND car_brand = #{dto.carBrand}
</if>
<if test="dto.carCategory != null and dto.carCategory != ''">
AND car_category = #{dto.carCategory}
</if>
<if test="dto.recentlyHandledBusiness != null and dto.recentlyHandledBusiness != ''">
AND recently_handled_business = #{dto.recentlyHandledBusiness}
</if>
<if test="dto.recentlyHandleBusinessTime != null">
AND recently_handle_business_time = #{dto.recentlyHandleBusinessTime}
</if>
<if test="dto.vin != null and dto.vin != ''">
AND vin LIKE CONCAT('%',#{dto.vin},'%')
</if>
<if test="dto.recentlyHandledBusiness != null and dto.recentlyHandledBusiness != ''">
AND tenant_id = #{dto.tenant}
</if>
</select>
</mapper>