Merge branch 'master' of http://122.51.230.86:3000/dianliang/lanan-system
# Conflicts: # dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarMainMapper.java
This commit is contained in:
commit
893e93563d
@ -42,21 +42,38 @@ public class CarMainController {
|
||||
@Resource
|
||||
private CarMainService carMainService;
|
||||
|
||||
/**
|
||||
* 创建车辆信息
|
||||
*
|
||||
* @param createReqVO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建车辆信息")
|
||||
@PreAuthorize("@ss.hasPermission('base:car-main:create')")
|
||||
public CommonResult<String> createCarMain(@RequestBody CarMainReqVO createReqVO) {
|
||||
return success(carMainService.createCarMain(createReqVO));
|
||||
return carMainService.createCarMain(createReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新车辆信息
|
||||
*
|
||||
* @param updateReqVO
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新车辆信息")
|
||||
@PreAuthorize("@ss.hasPermission('base:car-main:update')")
|
||||
public CommonResult<Boolean> updateCarMain(@RequestBody CarMainReqVO updateReqVO) {
|
||||
carMainService.updateCarMain(updateReqVO);
|
||||
return success(true);
|
||||
public CommonResult<String> updateCarMain(@RequestBody CarMainReqVO updateReqVO) {
|
||||
return carMainService.updateCarMain(updateReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除车辆信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除车辆信息")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@ -66,6 +83,12 @@ public class CarMainController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得车辆信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得车辆信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@ -75,15 +98,27 @@ public class CarMainController {
|
||||
return success(BeanUtils.toBean(carMain, CarMainRespVO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得车辆信息分页
|
||||
*
|
||||
* @param pageReqVO
|
||||
* @return
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出车辆信息
|
||||
*
|
||||
* @param pageReqVO
|
||||
* @param response
|
||||
* @throws IOException
|
||||
*/
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出车辆信息 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('base:car-main:export')")
|
||||
|
@ -20,7 +20,13 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface CarMainMapper extends BaseMapper<CarMain> {
|
||||
|
||||
|
||||
/**
|
||||
* 获得车辆信息分页
|
||||
*
|
||||
* @param page
|
||||
* @param pageReqVO
|
||||
* @return
|
||||
*/
|
||||
IPage<CarMainRespVO> findPage(Page<CarMain> page, @Param("dto") CarMainReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
@ -31,4 +37,6 @@ public interface CarMainMapper extends BaseMapper<CarMain> {
|
||||
* @return java.util.List<cn.iocoder.yudao.module.custom.entity.CarMain>
|
||||
**/
|
||||
List<CarMain> selectListByCusId( @Param("cusId") String cusId);
|
||||
List<CarMain> isDataKeyValueRepeat(@Param("dto") CarMain carMain);
|
||||
|
||||
}
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.custom.service;
|
||||
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.custom.entity.CarMain;
|
||||
import cn.iocoder.yudao.module.custom.vo.CarMainReqVO;
|
||||
import cn.iocoder.yudao.module.custom.vo.CarMainRespVO;
|
||||
@ -24,14 +25,14 @@ public interface CarMainService extends IService<CarMain> {
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
String createCarMain(CarMainReqVO createReqVO);
|
||||
CommonResult<String> createCarMain(CarMainReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新车辆信息
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateCarMain(CarMainReqVO updateReqVO);
|
||||
CommonResult<String> updateCarMain(CarMainReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除车辆信息
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.custom.service;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
|
||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
|
||||
|
@ -1,5 +1,8 @@
|
||||
package cn.iocoder.yudao.module.custom.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||
import cn.iocoder.yudao.module.custom.entity.CarMain;
|
||||
import cn.iocoder.yudao.module.custom.mapper.CarMainMapper;
|
||||
import cn.iocoder.yudao.module.custom.service.CarMainService;
|
||||
@ -11,6 +14,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆信息 Service 实现类
|
||||
*
|
||||
@ -19,40 +24,170 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
@Service
|
||||
public class CarMainServiceImpl extends ServiceImpl<CarMainMapper, CarMain> implements CarMainService{
|
||||
|
||||
|
||||
/**
|
||||
* 创建车辆信息
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String createCarMain(CarMainReqVO createReqVO) {
|
||||
public CommonResult<String> createCarMain(CarMainReqVO createReqVO) {
|
||||
//车牌号license_number,车架号vin,发动机号码engine_number 重复校验
|
||||
int checkResult = isDataKeyValueRepeat(createReqVO);
|
||||
//如果查重失败
|
||||
if (checkResult != 0){
|
||||
switch (checkResult){
|
||||
case 1: return CommonResult.error(4051,"该车牌号已在系统中登记");
|
||||
case 2: return CommonResult.error(4052,"该车架号已在系统中登记");
|
||||
case 3: return CommonResult.error(4053,"该发动机号码已在系统中登记");
|
||||
|
||||
}
|
||||
}
|
||||
// 插入
|
||||
CarMain carMain = BeanUtils.toBean(createReqVO, CarMain.class);
|
||||
baseMapper.insert(carMain);
|
||||
// 返回
|
||||
return carMain.getId();
|
||||
return CommonResult.success("新增成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新车辆信息
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
@Override
|
||||
public void updateCarMain(CarMainReqVO updateReqVO){
|
||||
public CommonResult<String> updateCarMain(CarMainReqVO updateReqVO){
|
||||
//车牌号license_number,车架号vin,发动机号码engine_number 重复校验
|
||||
int checkResult = isDataKeyValueRepeat(updateReqVO);
|
||||
//如果查重失败
|
||||
if (checkResult != 0){
|
||||
switch (checkResult){
|
||||
case 1: return CommonResult.error(4051,"该车牌号已在系统中登记");
|
||||
case 2: return CommonResult.error(4052,"该车架号已在系统中登记");
|
||||
case 3: return CommonResult.error(4053,"该发动机号码已在系统中登记");
|
||||
|
||||
}
|
||||
}
|
||||
// 更新
|
||||
CarMain updateObj = BeanUtils.toBean(updateReqVO, CarMain.class);
|
||||
baseMapper.updateById(updateObj);
|
||||
return CommonResult.success("修改成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除车辆信息
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
@Override
|
||||
public void deleteCarMain(String id) {
|
||||
// 删除
|
||||
//判断车辆是否发生过业务
|
||||
CarMain target = baseMapper.selectById(id);
|
||||
if (ObjectUtil.isEmpty(target.getRecentlyHandledBusiness()) && !"".equals(target.getRecentlyHandledBusiness()) ){
|
||||
|
||||
}
|
||||
// 逻辑删除
|
||||
baseMapper.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获得车辆信息
|
||||
*
|
||||
* @param id 编号
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CarMain getCarMain(String id) {
|
||||
//数据单查
|
||||
return baseMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得车辆信息分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public IPage<CarMainRespVO> getCarMainPage(CarMainReqVO pageReqVO) {
|
||||
//取分页参数
|
||||
Page<CarMain> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
|
||||
//分页查询
|
||||
return baseMapper.findPage(page,pageReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 车牌号,车架号,发动机号码 查重
|
||||
* @param reqVO
|
||||
* @return 0无重复,1车牌号重复,2车架号重复,发动机号码重复
|
||||
*/
|
||||
private int isDataKeyValueRepeat(CarMainReqVO reqVO){
|
||||
|
||||
//车牌号license_number 查重
|
||||
if(ObjectUtil.isNotEmpty(reqVO.getLicenseNumber())){
|
||||
CarMain target = new CarMain();
|
||||
target.setLicenseNumber(reqVO.getLicenseNumber());
|
||||
List<CarMain> results = baseMapper.isDataKeyValueRepeat(target);
|
||||
//判断是否登记过这个车牌号的车辆
|
||||
if (results.size()>0){
|
||||
//无id是新增,有相应登记记录
|
||||
if(ObjectUtil.isEmpty(reqVO.getId()) ){
|
||||
return 1;
|
||||
}
|
||||
//有id是修改,如果登记过,比较id查验是否是当前要修改的车辆本身
|
||||
for (CarMain item: results) {
|
||||
if (!item.getId().equals(reqVO.getId())){
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//车架号vin 查重
|
||||
}else if (ObjectUtil.isNotEmpty(reqVO.getVin())){
|
||||
CarMain target = new CarMain();
|
||||
target.setVin(reqVO.getVin());
|
||||
List<CarMain> results = baseMapper.isDataKeyValueRepeat(target);
|
||||
//判断是否登记过这个车架号的车辆
|
||||
if (results.size()>0){
|
||||
//无id是新增,有相应登记记录
|
||||
if(ObjectUtil.isEmpty(reqVO.getId()) ){
|
||||
return 2;
|
||||
}
|
||||
//有id是修改,如果登记过,比较id查验是否是当前要修改的车辆本身
|
||||
for (CarMain item: results) {
|
||||
if (!item.getId().equals(reqVO.getId())){
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//发动机号码engine_number 查重
|
||||
}else if (ObjectUtil.isNotEmpty(reqVO.getEngineNumber())){
|
||||
CarMain target = new CarMain();
|
||||
target.setEngineNumber(reqVO.getEngineNumber());
|
||||
List<CarMain> results = baseMapper.isDataKeyValueRepeat(target);
|
||||
//判断是否登记过这个发动机号的车辆
|
||||
if (results.size()>0){
|
||||
//无id是新增,有相应登记记录
|
||||
if(ObjectUtil.isEmpty(reqVO.getId()) ){
|
||||
return 3;
|
||||
}
|
||||
//有id是修改,如果登记过,比较id查验是否是当前要修改的车辆本身
|
||||
for (CarMain item: results) {
|
||||
if (!item.getId().equals(reqVO.getId())){
|
||||
return 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//返回查验无重复结果
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
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;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 车辆信息分页 Request VO")
|
||||
@ -30,22 +30,22 @@ public class CarMainReqVO extends PageParam {
|
||||
private String carModel;
|
||||
|
||||
@Schema(description = "保养日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDateTime maintenanceDate;
|
||||
|
||||
@Schema(description = "保养里程")
|
||||
private String maintenanceMileage;
|
||||
|
||||
@Schema(description = "年检日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDateTime inspectionDate;
|
||||
|
||||
@Schema(description = "保险日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDateTime insuranceDate;
|
||||
|
||||
@Schema(description = "二级维护时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDateTime checkDate;
|
||||
|
||||
@Schema(description = "车辆品牌")
|
||||
@ -58,7 +58,7 @@ public class CarMainReqVO extends PageParam {
|
||||
private String carCategory;
|
||||
|
||||
@Schema(description = "车辆注册日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDateTime carRegisterDate;
|
||||
|
||||
@Schema(description = "行驶证图片")
|
||||
@ -68,11 +68,11 @@ public class CarMainReqVO extends PageParam {
|
||||
private String recentlyHandledBusiness;
|
||||
|
||||
@Schema(description = "最近办理业务的时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDateTime recentlyHandleBusinessTime;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.custom.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.custom.entity.CarMain;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
@ -12,7 +13,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
@Schema(description = "管理后台 - 车辆信息 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CarMainRespVO {
|
||||
public class CarMainRespVO extends CarMain {
|
||||
|
||||
@Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "8714")
|
||||
@ExcelProperty("主键标识")
|
||||
|
@ -0,0 +1,49 @@
|
||||
package cn.iocoder.yudao.utils.CarMain;
|
||||
|
||||
import cn.iocoder.yudao.module.custom.entity.CarMain;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class GetNextBusinessTimeUtils {
|
||||
|
||||
// /**
|
||||
// * 取下次保养日期
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// public static LocalDateTime getNextMaintenanceDate(CarMain target){
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 取下次保养里程
|
||||
// * @return
|
||||
// */
|
||||
// public static Long getNextMaintenanceMileage(CarMain target){
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 下次年检日期
|
||||
// * @return
|
||||
// */
|
||||
// public static LocalDateTime getNextMaintenanceDate(CarMain target){
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 保险到期日期
|
||||
// */
|
||||
// public static LocalDateTime getInsuranceExpiryDate(CarMain target){
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 下次二级维护时间
|
||||
// */
|
||||
// public static LocalDateTime getNextCheckDate(CarMain target){
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,188 @@
|
||||
package cn.iocoder.yudao.utils;
|
||||
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 时间工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
{
|
||||
public static String YYYY = "yyyy";
|
||||
|
||||
public static String YYYY_MM = "yyyy-MM";
|
||||
|
||||
public static String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
|
||||
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
private static String[] parsePatterns = {
|
||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
|
||||
|
||||
/**
|
||||
* 获取当前Date型日期
|
||||
*
|
||||
* @return Date() 当前日期
|
||||
*/
|
||||
public static Date getNowDate()
|
||||
{
|
||||
return new Date();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期, 默认格式为yyyy-MM-dd
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public static String getDate()
|
||||
{
|
||||
return dateTimeNow(YYYY_MM_DD);
|
||||
}
|
||||
|
||||
public static final String getTime()
|
||||
{
|
||||
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNow()
|
||||
{
|
||||
return dateTimeNow(YYYYMMDDHHMMSS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNow(final String format)
|
||||
{
|
||||
return parseDateToStr(format, new Date());
|
||||
}
|
||||
|
||||
public static final String dateTime(final Date date)
|
||||
{
|
||||
return parseDateToStr(YYYY_MM_DD, date);
|
||||
}
|
||||
|
||||
public static final String parseDateToStr(final String format, final Date date)
|
||||
{
|
||||
return new SimpleDateFormat(format).format(date);
|
||||
}
|
||||
|
||||
public static final Date dateTime(final String format, final String ts)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new SimpleDateFormat(format).parse(ts);
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期路径 即年/月/日 如2018/08/08
|
||||
*/
|
||||
public static final String datePath()
|
||||
{
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyy/MM/dd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期路径 即年/月/日 如20180808
|
||||
*/
|
||||
public static final String dateTime()
|
||||
{
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyyMMdd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期型字符串转化为日期 格式
|
||||
*/
|
||||
public static Date parseDate(Object str)
|
||||
{
|
||||
if (str == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
return parseDate(str.toString(), parsePatterns);
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器启动时间
|
||||
*/
|
||||
public static Date getServerStartDate()
|
||||
{
|
||||
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
return new Date(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算相差天数
|
||||
*/
|
||||
public static int differentDaysByMillisecond(Date date1, Date date2)
|
||||
{
|
||||
return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算时间差
|
||||
*
|
||||
* @param endDate 最后时间
|
||||
* @param startTime 开始时间
|
||||
* @return 时间差(天/小时/分钟)
|
||||
*/
|
||||
public static String timeDistance(Date endDate, Date startTime)
|
||||
{
|
||||
long nd = 1000 * 24 * 60 * 60;
|
||||
long nh = 1000 * 60 * 60;
|
||||
long nm = 1000 * 60;
|
||||
// long ns = 1000;
|
||||
// 获得两个时间的毫秒时间差异
|
||||
long diff = endDate.getTime() - startTime.getTime();
|
||||
// 计算差多少天
|
||||
long day = diff / nd;
|
||||
// 计算差多少小时
|
||||
long hour = diff % nd / nh;
|
||||
// 计算差多少分钟
|
||||
long min = diff % nd % nh / nm;
|
||||
// 计算差多少秒//输出结果
|
||||
// long sec = diff % nd % nh % nm / ns;
|
||||
return day + "天" + hour + "小时" + min + "分钟";
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加 LocalDateTime ==> Date
|
||||
*/
|
||||
public static Date toDate(LocalDateTime temporalAccessor)
|
||||
{
|
||||
ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
|
||||
return Date.from(zdt.toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加 LocalDate ==> Date
|
||||
*/
|
||||
public static Date toDate(LocalDate temporalAccessor)
|
||||
{
|
||||
LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
|
||||
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
|
||||
return Date.from(zdt.toInstant());
|
||||
}
|
||||
}
|
@ -2,69 +2,91 @@
|
||||
<!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 id="baseCarMainColumn">
|
||||
tbcm.id,
|
||||
tbcm.engine_number,
|
||||
tbcm.vin,
|
||||
tbcm.license_number,
|
||||
tbcm.car_model,
|
||||
tbcm.maintenance_date,
|
||||
tbcm.maintenance_mileage,
|
||||
tbcm.inspection_date,
|
||||
tbcm.insurance_date,
|
||||
tbcm.check_date,
|
||||
tbcm.next_maintenance_date,
|
||||
tbcm.next_maintenance_mileage,
|
||||
tbcm.next_inspection_date,
|
||||
tbcm.insurance_expiry_date,
|
||||
tbcm.next_check_date,
|
||||
tbcm.car_brand,
|
||||
tbcm.car_nature,
|
||||
tbcm.car_category,
|
||||
tbcm.car_register_date,
|
||||
tbcm.car_license_img,
|
||||
tbcm.recently_handled_business,
|
||||
tbcm.recently_handle_business_time,
|
||||
tbcm.deleted,
|
||||
tbcm.creator,
|
||||
tbcm.create_time,
|
||||
tbcm.updater,
|
||||
tbcm.update_time
|
||||
</sql>
|
||||
|
||||
<select id="findPage" resultType="cn.iocoder.yudao.module.custom.vo.CarMainRespVO">
|
||||
SELECT
|
||||
<include refid="column"></include>
|
||||
FROM `base_car_main`
|
||||
<include refid="baseCarMainColumn"></include>
|
||||
FROM `base_car_main` tbcm
|
||||
WHERE
|
||||
deleted = 0
|
||||
tbcm.deleted = 0
|
||||
<if test="dto.licenseNumber != null and dto.licenseNumber != ''">
|
||||
AND license_number LIKE CONCAT('%',#{dto.licenseNumber},'%')
|
||||
AND tbcm.license_number LIKE CONCAT('%',#{dto.licenseNumber},'%')
|
||||
</if>
|
||||
<if test="dto.carBrand != null and dto.carBrand != ''">
|
||||
AND car_brand = #{dto.carBrand}
|
||||
AND tbcm.car_brand = #{dto.carBrand}
|
||||
</if>
|
||||
<if test="dto.carCategory != null and dto.carCategory != ''">
|
||||
AND car_category = #{dto.carCategory}
|
||||
AND tbcm.car_category = #{dto.carCategory}
|
||||
</if>
|
||||
<if test="dto.recentlyHandledBusiness != null and dto.recentlyHandledBusiness != ''">
|
||||
AND recently_handled_business = #{dto.recentlyHandledBusiness}
|
||||
AND tbcm.recently_handled_business = #{dto.recentlyHandledBusiness}
|
||||
</if>
|
||||
<if test="dto.recentlyHandleBusinessTime != null">
|
||||
AND recently_handle_business_time = #{dto.recentlyHandleBusinessTime}
|
||||
AND tbcm.recently_handle_business_time = #{dto.recentlyHandleBusinessTime}
|
||||
</if>
|
||||
<if test="dto.vin != null and dto.vin != ''">
|
||||
AND vin LIKE CONCAT('%',#{dto.vin},'%')
|
||||
AND tbcm.vin LIKE CONCAT('%',#{dto.vin},'%')
|
||||
</if>
|
||||
<if test="dto.recentlyHandledBusiness != null and dto.recentlyHandledBusiness != ''">
|
||||
AND tenant_id = #{dto.tenant}
|
||||
AND tbcm.tenant_id = #{dto.tenant}
|
||||
</if>
|
||||
<if test="dto.carModel != null and dto.carModel != ''">
|
||||
AND tbcm.car_model = #{dto.carModel}
|
||||
</if>
|
||||
<if test="dto.carNature != null and dto.carNature != ''">
|
||||
AND tbcm.car_nature = #{dto.carNature}
|
||||
</if>
|
||||
<if test="dto.engineNumber != null and dto.engineNumber != ''">
|
||||
AND tbcm.engine_number LIKE CONCAT('%',#{dto.engineNumber},'%')
|
||||
</if>
|
||||
|
||||
ORDER BY
|
||||
tbcm.car_register_date DESC
|
||||
</select>
|
||||
|
||||
<select id="isDataKeyValueRepeat" resultType="cn.iocoder.yudao.module.custom.entity.CarMain">
|
||||
SELECT
|
||||
tbcm.id
|
||||
FROM `base_car_main` tbcm
|
||||
WHERE
|
||||
tbcm.deleted = 0
|
||||
<if test="dto.licenseNumber != null and dto.licenseNumber != ''">
|
||||
AND tbcm.license_number = #{dto.licenseNumber}
|
||||
</if>
|
||||
<if test="dto.vin != null and dto.vin != ''">
|
||||
AND tbcm.vin = #{dto.vin}
|
||||
</if>
|
||||
<if test="dto.engineNumber != null and dto.engineNumber != ''">
|
||||
AND tbcm.engine_number = #{dto.engineNumber}
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
Loading…
Reference in New Issue
Block a user