Commit 2fcead108f09a320cae9f16354408ba6a748215b

Authored by 王富生
1 parent 0e964aec

优化时间查询问题

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,6 +10,7 @@ import com.zteits.urbanops.framework.common.pojo.PageParam;
10 import org.springframework.format.annotation.DateTimeFormat; 10 import org.springframework.format.annotation.DateTimeFormat;
11 import java.time.LocalDateTime; 11 import java.time.LocalDateTime;
12 12
  13 +import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
13 import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; 14 import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
14 15
15 @Schema(description = "管理后台 - 巡检计划分页 Request VO") 16 @Schema(description = "管理后台 - 巡检计划分页 Request VO")
@@ -39,12 +40,12 @@ public class InspectionPlanDetailPageReqVO extends PageParam { @@ -39,12 +40,12 @@ public class InspectionPlanDetailPageReqVO extends PageParam {
39 private Integer sortNum; 40 private Integer sortNum;
40 41
41 @Schema(description = "执行开始时间") 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 @Schema(description = "执行时间") 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 @Schema(description = "完成状态 1:未完成;2:进行中;3:已完成") 50 @Schema(description = "完成状态 1:未完成;2:进行中;3:已完成")
50 private Integer finishState; 51 private Integer finishState;
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/inspectionplan/InspectionPlanDetailMapper.java
1 package com.zteits.urbanops.module.garden.dal.mysql.inspectionplan; 1 package com.zteits.urbanops.module.garden.dal.mysql.inspectionplan;
2 2
  3 +import java.time.LocalDateTime;
3 import java.util.*; 4 import java.util.*;
4 5
5 import com.zteits.urbanops.framework.common.pojo.PageResult; 6 import com.zteits.urbanops.framework.common.pojo.PageResult;
@@ -19,6 +20,14 @@ import org.apache.ibatis.annotations.Param; @@ -19,6 +20,14 @@ import org.apache.ibatis.annotations.Param;
19 public interface InspectionPlanDetailMapper extends BaseMapperX<InspectionPlanDetailDO> { 20 public interface InspectionPlanDetailMapper extends BaseMapperX<InspectionPlanDetailDO> {
20 21
21 default PageResult<InspectionPlanDetailDO> selectPage(InspectionPlanDetailPageReqVO reqVO) { 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 return selectPage(reqVO, new LambdaQueryWrapperX<InspectionPlanDetailDO>() 31 return selectPage(reqVO, new LambdaQueryWrapperX<InspectionPlanDetailDO>()
23 .eqIfPresent(InspectionPlanDetailDO::getBatchNo, reqVO.getBatchNo()) 32 .eqIfPresent(InspectionPlanDetailDO::getBatchNo, reqVO.getBatchNo())
24 .eqIfPresent(InspectionPlanDetailDO::getPlanNo, reqVO.getPlanNo()) 33 .eqIfPresent(InspectionPlanDetailDO::getPlanNo, reqVO.getPlanNo())
@@ -27,8 +36,10 @@ public interface InspectionPlanDetailMapper extends BaseMapperX&lt;InspectionPlanDe @@ -27,8 +36,10 @@ public interface InspectionPlanDetailMapper extends BaseMapperX&lt;InspectionPlanDe
27 .eqIfPresent(InspectionPlanDetailDO::getDeptId, reqVO.getDeptId()) 36 .eqIfPresent(InspectionPlanDetailDO::getDeptId, reqVO.getDeptId())
28 .eqIfPresent(InspectionPlanDetailDO::getRoadId, reqVO.getRoadId()) 37 .eqIfPresent(InspectionPlanDetailDO::getRoadId, reqVO.getRoadId())
29 .eqIfPresent(InspectionPlanDetailDO::getSortNum, reqVO.getSortNum()) 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 .eq(InspectionPlanDetailDO::getDeleted,0) 43 .eq(InspectionPlanDetailDO::getDeleted,0)
33 .orderByAsc(InspectionPlanDetailDO::getId)); 44 .orderByAsc(InspectionPlanDetailDO::getId));
34 } 45 }