Commit 2fcead108f09a320cae9f16354408ba6a748215b
1 parent
0e964aec
优化时间查询问题
Showing
2 changed files
with
18 additions
and
6 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/inspectionplan/vo/InspectionPlanDetailPageReqVO.java
| ... | ... | @@ -10,6 +10,7 @@ import com.zteits.urbanops.framework.common.pojo.PageParam; |
| 10 | 10 | import org.springframework.format.annotation.DateTimeFormat; |
| 11 | 11 | import java.time.LocalDateTime; |
| 12 | 12 | |
| 13 | +import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; | |
| 13 | 14 | import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 14 | 15 | |
| 15 | 16 | @Schema(description = "管理后台 - 巡检计划分页 Request VO") |
| ... | ... | @@ -39,12 +40,12 @@ public class InspectionPlanDetailPageReqVO extends PageParam { |
| 39 | 40 | private Integer sortNum; |
| 40 | 41 | |
| 41 | 42 | @Schema(description = "执行开始时间") |
| 42 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 43 | - private LocalDate[] beginTime; | |
| 43 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) | |
| 44 | + private LocalDate beginTime; | |
| 44 | 45 | |
| 45 | 46 | @Schema(description = "执行时间") |
| 46 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 47 | - private LocalDate[] endTime; | |
| 47 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) | |
| 48 | + private LocalDate endTime; | |
| 48 | 49 | |
| 49 | 50 | @Schema(description = "完成状态 1:未完成;2:进行中;3:已完成") |
| 50 | 51 | private Integer finishState; | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/inspectionplan/InspectionPlanDetailMapper.java
| 1 | 1 | package com.zteits.urbanops.module.garden.dal.mysql.inspectionplan; |
| 2 | 2 | |
| 3 | +import java.time.LocalDateTime; | |
| 3 | 4 | import java.util.*; |
| 4 | 5 | |
| 5 | 6 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| ... | ... | @@ -19,6 +20,14 @@ import org.apache.ibatis.annotations.Param; |
| 19 | 20 | public interface InspectionPlanDetailMapper extends BaseMapperX<InspectionPlanDetailDO> { |
| 20 | 21 | |
| 21 | 22 | default PageResult<InspectionPlanDetailDO> selectPage(InspectionPlanDetailPageReqVO reqVO) { |
| 23 | + LocalDateTime startTime = null; | |
| 24 | + LocalDateTime endTime = null; | |
| 25 | + if(reqVO.getBeginTime() != null){ | |
| 26 | + startTime = reqVO.getBeginTime().atStartOfDay(); | |
| 27 | + } | |
| 28 | + if(reqVO.getEndTime() != null){ | |
| 29 | + endTime = reqVO.getEndTime().atTime(23, 59, 59); | |
| 30 | + } | |
| 22 | 31 | return selectPage(reqVO, new LambdaQueryWrapperX<InspectionPlanDetailDO>() |
| 23 | 32 | .eqIfPresent(InspectionPlanDetailDO::getBatchNo, reqVO.getBatchNo()) |
| 24 | 33 | .eqIfPresent(InspectionPlanDetailDO::getPlanNo, reqVO.getPlanNo()) |
| ... | ... | @@ -27,8 +36,10 @@ public interface InspectionPlanDetailMapper extends BaseMapperX<InspectionPlanDe |
| 27 | 36 | .eqIfPresent(InspectionPlanDetailDO::getDeptId, reqVO.getDeptId()) |
| 28 | 37 | .eqIfPresent(InspectionPlanDetailDO::getRoadId, reqVO.getRoadId()) |
| 29 | 38 | .eqIfPresent(InspectionPlanDetailDO::getSortNum, reqVO.getSortNum()) |
| 30 | - .betweenIfPresent(InspectionPlanDetailDO::getCreateTime, reqVO.getBeginTime(), reqVO.getEndTime()) | |
| 31 | - .eqIfPresent(InspectionPlanDetailDO::getFinishState, reqVO.getFinishState()) | |
| 39 | + // >= | |
| 40 | + .ge(reqVO.getBeginTime() != null, InspectionPlanDetailDO::getBeginTime, startTime) | |
| 41 | + // <= | |
| 42 | + .le(reqVO.getEndTime()!= null, InspectionPlanDetailDO::getEndTime, endTime) | |
| 32 | 43 | .eq(InspectionPlanDetailDO::getDeleted,0) |
| 33 | 44 | .orderByAsc(InspectionPlanDetailDO::getId)); |
| 34 | 45 | } | ... | ... |