Commit df20c5d598aba5edc6531ecf4b27a16a1d1d1e15
1 parent
4d77af8a
机械费用增加开始时间和结束时间筛选
Showing
4 changed files
with
56 additions
and
10 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/mechanicalcost/vo/MechanicalCostPageReqVO.java
| 1 | package com.zteits.urbanops.module.garden.controller.admin.mechanicalcost.vo; | 1 | package com.zteits.urbanops.module.garden.controller.admin.mechanicalcost.vo; |
| 2 | 2 | ||
| 3 | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; | 3 | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; |
| 4 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 4 | import com.zteits.urbanops.framework.common.pojo.PageParam; | 5 | import com.zteits.urbanops.framework.common.pojo.PageParam; |
| 5 | import com.zteits.urbanops.module.garden.dal.dataobject.mechanicalcost.MechanicalCostDO; | 6 | import com.zteits.urbanops.module.garden.dal.dataobject.mechanicalcost.MechanicalCostDO; |
| 6 | import io.swagger.v3.oas.annotations.media.Schema; | 7 | import io.swagger.v3.oas.annotations.media.Schema; |
| 8 | +import jakarta.validation.constraints.AssertTrue; | ||
| 7 | import lombok.Data; | 9 | import lombok.Data; |
| 8 | import org.springframework.format.annotation.DateTimeFormat; | 10 | import org.springframework.format.annotation.DateTimeFormat; |
| 9 | 11 | ||
| @@ -47,15 +49,17 @@ public class MechanicalCostPageReqVO extends PageParam { | @@ -47,15 +49,17 @@ public class MechanicalCostPageReqVO extends PageParam { | ||
| 47 | private String vehicleType; | 49 | private String vehicleType; |
| 48 | 50 | ||
| 49 | @Schema(description = "开始使用时间") | 51 | @Schema(description = "开始使用时间") |
| 50 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 51 | - private LocalDate[] startUseTime; | 52 | + @JsonFormat(pattern = "yyyy-MM-dd", shape = JsonFormat.Shape.STRING) |
| 53 | + @DateTimeFormat(pattern = "yyyy-MM-dd") | ||
| 54 | + private LocalDate startUseTime; | ||
| 52 | 55 | ||
| 53 | @Schema(description = "使用年限") | 56 | @Schema(description = "使用年限") |
| 54 | private Long serviceLife; | 57 | private Long serviceLife; |
| 55 | 58 | ||
| 56 | @Schema(description = "结束使用时间") | 59 | @Schema(description = "结束使用时间") |
| 57 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 58 | - private LocalDate[] endUseTime; | 60 | + @JsonFormat(pattern = "yyyy-MM-dd", shape = JsonFormat.Shape.STRING) |
| 61 | + @DateTimeFormat(pattern = "yyyy-MM-dd") | ||
| 62 | + private LocalDate endUseTime; | ||
| 59 | 63 | ||
| 60 | @Schema(description = "归属公司", example = "张三") | 64 | @Schema(description = "归属公司", example = "张三") |
| 61 | private String companyName; | 65 | private String companyName; |
| @@ -70,7 +74,6 @@ public class MechanicalCostPageReqVO extends PageParam { | @@ -70,7 +74,6 @@ public class MechanicalCostPageReqVO extends PageParam { | ||
| 70 | private String remark; | 74 | private String remark; |
| 71 | 75 | ||
| 72 | @Schema(description = "创建时间") | 76 | @Schema(description = "创建时间") |
| 73 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 74 | private LocalDateTime[] createTime; | 77 | private LocalDateTime[] createTime; |
| 75 | 78 | ||
| 76 | //对应前端排序字段 | 79 | //对应前端排序字段 |
| @@ -82,4 +85,23 @@ public class MechanicalCostPageReqVO extends PageParam { | @@ -82,4 +85,23 @@ public class MechanicalCostPageReqVO extends PageParam { | ||
| 82 | "startUseTime", MechanicalCostDO::getStartUseTime, | 85 | "startUseTime", MechanicalCostDO::getStartUseTime, |
| 83 | "endUseTime" , MechanicalCostDO::getEndUseTime | 86 | "endUseTime" , MechanicalCostDO::getEndUseTime |
| 84 | ); | 87 | ); |
| 88 | + | ||
| 89 | + @AssertTrue(message = "结束时间不能小于开始时间") | ||
| 90 | + @Schema(hidden = true) | ||
| 91 | + public boolean isStartTimeNotAfterEndTime() { | ||
| 92 | + // 1. 两个时间都为空:校验通过(分页查询条件可选) | ||
| 93 | + if (startUseTime == null && endUseTime == null) { | ||
| 94 | + return true; | ||
| 95 | + } | ||
| 96 | + // 2. 仅开始时间为空:校验通过(可根据业务调整为false强制要求) | ||
| 97 | + if (startUseTime == null) { | ||
| 98 | + return true; | ||
| 99 | + } | ||
| 100 | + // 3. 仅结束时间为空:校验通过(分页查询条件可选) | ||
| 101 | + if (endUseTime == null) { | ||
| 102 | + return true; | ||
| 103 | + } | ||
| 104 | + // 4. 两个时间都不为空:核心判断 - 开始时间 <= 结束时间 | ||
| 105 | + return !startUseTime.isAfter(endUseTime); | ||
| 106 | + } | ||
| 85 | } | 107 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/rentalmechanicalcost/vo/RentalMechanicalCostPageReqVO.java
| 1 | package com.zteits.urbanops.module.garden.controller.admin.rentalmechanicalcost.vo; | 1 | package com.zteits.urbanops.module.garden.controller.admin.rentalmechanicalcost.vo; |
| 2 | 2 | ||
| 3 | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; | 3 | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; |
| 4 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 4 | import com.zteits.urbanops.framework.common.pojo.PageParam; | 5 | import com.zteits.urbanops.framework.common.pojo.PageParam; |
| 5 | import com.zteits.urbanops.module.garden.dal.dataobject.rentalmechanicalcost.RentalMechanicalCostDO; | 6 | import com.zteits.urbanops.module.garden.dal.dataobject.rentalmechanicalcost.RentalMechanicalCostDO; |
| 6 | import io.swagger.v3.oas.annotations.media.Schema; | 7 | import io.swagger.v3.oas.annotations.media.Schema; |
| 8 | +import jakarta.validation.constraints.AssertTrue; | ||
| 7 | import lombok.Data; | 9 | import lombok.Data; |
| 8 | import org.springframework.format.annotation.DateTimeFormat; | 10 | import org.springframework.format.annotation.DateTimeFormat; |
| 9 | 11 | ||
| @@ -25,13 +27,16 @@ public class RentalMechanicalCostPageReqVO extends PageParam { | @@ -25,13 +27,16 @@ public class RentalMechanicalCostPageReqVO extends PageParam { | ||
| 25 | @Schema(description = "租赁总价格", example = "316") | 27 | @Schema(description = "租赁总价格", example = "316") |
| 26 | private BigDecimal rentalTotalPriceMax; | 28 | private BigDecimal rentalTotalPriceMax; |
| 27 | @Schema(description = "开始使用时间") | 29 | @Schema(description = "开始使用时间") |
| 30 | + @JsonFormat(pattern = "yyyy-MM-dd", shape = JsonFormat.Shape.STRING) | ||
| 28 | @DateTimeFormat(pattern = "yyyy-MM-dd") | 31 | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| 29 | - private Date startUseTime; | 32 | + private LocalDate startUseTime; |
| 30 | 33 | ||
| 31 | @Schema(description = "使用时长(天)") | 34 | @Schema(description = "使用时长(天)") |
| 32 | private Integer useDuration; | 35 | private Integer useDuration; |
| 33 | 36 | ||
| 34 | @Schema(description = "结束日期") | 37 | @Schema(description = "结束日期") |
| 38 | + @JsonFormat(pattern = "yyyy-MM-dd", shape = JsonFormat.Shape.STRING) | ||
| 39 | + @DateTimeFormat(pattern = "yyyy-MM-dd") | ||
| 35 | private LocalDate endUseTime; | 40 | private LocalDate endUseTime; |
| 36 | 41 | ||
| 37 | @Schema(description = "数量") | 42 | @Schema(description = "数量") |
| @@ -48,4 +53,23 @@ public class RentalMechanicalCostPageReqVO extends PageParam { | @@ -48,4 +53,23 @@ public class RentalMechanicalCostPageReqVO extends PageParam { | ||
| 48 | "startUseTime", RentalMechanicalCostDO::getStartUseTime, | 53 | "startUseTime", RentalMechanicalCostDO::getStartUseTime, |
| 49 | "endUseTime", RentalMechanicalCostDO::getEndUseTime | 54 | "endUseTime", RentalMechanicalCostDO::getEndUseTime |
| 50 | ); | 55 | ); |
| 56 | + | ||
| 57 | + @AssertTrue(message = "结束时间不能小于开始时间") | ||
| 58 | + @Schema(hidden = true) | ||
| 59 | + public boolean isStartTimeNotAfterEndTime() { | ||
| 60 | + // 1. 两个时间都为空:校验通过(分页查询条件可选) | ||
| 61 | + if (startUseTime == null && endUseTime == null) { | ||
| 62 | + return true; | ||
| 63 | + } | ||
| 64 | + // 2. 仅开始时间为空:校验通过(可根据业务调整为false强制要求) | ||
| 65 | + if (startUseTime == null) { | ||
| 66 | + return true; | ||
| 67 | + } | ||
| 68 | + // 3. 仅结束时间为空:校验通过(分页查询条件可选) | ||
| 69 | + if (endUseTime == null) { | ||
| 70 | + return true; | ||
| 71 | + } | ||
| 72 | + // 4. 两个时间都不为空:核心判断 - 开始时间 <= 结束时间 | ||
| 73 | + return !startUseTime.isAfter(endUseTime); | ||
| 74 | + } | ||
| 51 | } | 75 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/mechanicalcost/MechanicalCostMapper.java
| @@ -29,9 +29,9 @@ public interface MechanicalCostMapper extends BaseMapperX<MechanicalCostDO> { | @@ -29,9 +29,9 @@ public interface MechanicalCostMapper extends BaseMapperX<MechanicalCostDO> { | ||
| 29 | .eqIfPresent(MechanicalCostDO::getLicensePlate, reqVO.getLicensePlate()) | 29 | .eqIfPresent(MechanicalCostDO::getLicensePlate, reqVO.getLicensePlate()) |
| 30 | .eqIfPresent(MechanicalCostDO::getVehicleCategory, reqVO.getVehicleCategory()) | 30 | .eqIfPresent(MechanicalCostDO::getVehicleCategory, reqVO.getVehicleCategory()) |
| 31 | .eqIfPresent(MechanicalCostDO::getVehicleType, reqVO.getVehicleType()) | 31 | .eqIfPresent(MechanicalCostDO::getVehicleType, reqVO.getVehicleType()) |
| 32 | - .betweenIfPresent(MechanicalCostDO::getStartUseTime, reqVO.getStartUseTime()) | 32 | + .geIfPresent(MechanicalCostDO::getStartUseTime, reqVO.getStartUseTime()) |
| 33 | .eqIfPresent(MechanicalCostDO::getServiceLife, reqVO.getServiceLife()) | 33 | .eqIfPresent(MechanicalCostDO::getServiceLife, reqVO.getServiceLife()) |
| 34 | - .betweenIfPresent(MechanicalCostDO::getEndUseTime, reqVO.getEndUseTime()) | 34 | + .leIfPresent(MechanicalCostDO::getEndUseTime, reqVO.getEndUseTime()) |
| 35 | .likeIfPresent(MechanicalCostDO::getCompanyName, reqVO.getCompanyName()) | 35 | .likeIfPresent(MechanicalCostDO::getCompanyName, reqVO.getCompanyName()) |
| 36 | .eqIfPresent(MechanicalCostDO::getCompanyId, reqVO.getCompanyId()) | 36 | .eqIfPresent(MechanicalCostDO::getCompanyId, reqVO.getCompanyId()) |
| 37 | .eqIfPresent(MechanicalCostDO::getDeptId, reqVO.getDeptId()) | 37 | .eqIfPresent(MechanicalCostDO::getDeptId, reqVO.getDeptId()) |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/rentalmechanicalcost/RentalMechanicalCostMapper.java
| @@ -28,9 +28,9 @@ public interface RentalMechanicalCostMapper extends BaseMapperX<RentalMechanical | @@ -28,9 +28,9 @@ public interface RentalMechanicalCostMapper extends BaseMapperX<RentalMechanical | ||
| 28 | //.eqIfPresent(RentalMechanicalCostDO::getVehicleCategory, reqVO.getVehicleCategory()) | 28 | //.eqIfPresent(RentalMechanicalCostDO::getVehicleCategory, reqVO.getVehicleCategory()) |
| 29 | // .eqIfPresent(RentalMechanicalCostDO::getVehicleType, reqVO.getVehicleType()) | 29 | // .eqIfPresent(RentalMechanicalCostDO::getVehicleType, reqVO.getVehicleType()) |
| 30 | //.betweenIfPresent(RentalMechanicalCostDO::getStartUseTime, reqVO.getStartUseTime()) | 30 | //.betweenIfPresent(RentalMechanicalCostDO::getStartUseTime, reqVO.getStartUseTime()) |
| 31 | - .eqIfPresent(RentalMechanicalCostDO::getStartUseTime, reqVO.getStartUseTime()) | 31 | + .geIfPresent(RentalMechanicalCostDO::getStartUseTime, reqVO.getStartUseTime()) |
| 32 | .eqIfPresent(RentalMechanicalCostDO::getUseDuration, reqVO.getUseDuration()) | 32 | .eqIfPresent(RentalMechanicalCostDO::getUseDuration, reqVO.getUseDuration()) |
| 33 | - //.betweenIfPresent(RentalMechanicalCostDO::getEndUseTime, reqVO.getEndUseTime()) | 33 | + .leIfPresent(RentalMechanicalCostDO::getEndUseTime, reqVO.getEndUseTime()) |
| 34 | //.likeIfPresent(RentalMechanicalCostDO::getCompanyName, reqVO.getCompanyName()) | 34 | //.likeIfPresent(RentalMechanicalCostDO::getCompanyName, reqVO.getCompanyName()) |
| 35 | .eqIfPresent(RentalMechanicalCostDO::getCompanyId, reqVO.getCompanyId()) | 35 | .eqIfPresent(RentalMechanicalCostDO::getCompanyId, reqVO.getCompanyId()) |
| 36 | //.eqIfPresent(RentalMechanicalCostDO::getDeptId, reqVO.getDeptId()) | 36 | //.eqIfPresent(RentalMechanicalCostDO::getDeptId, reqVO.getDeptId()) |