From 14b27f8940eb9c8d5fe18d99ff2c260643084eaa Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 11 Jun 2021 16:28:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E7=94=A8lambda=E6=96=B9=E5=BC=8F=20?= =?UTF-8?q?=E5=88=9B=E5=BB=BAsql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/StaffPatrolRecordServiceImpl.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java index 3150361c7a..eb7a8bb590 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java @@ -1,5 +1,6 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; @@ -23,11 +24,11 @@ import com.epmet.feign.GovOrgFeignClient; import com.epmet.service.StaffPatrolDetailService; import com.epmet.service.StaffPatrolRecordService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.apache.commons.collections4.CollectionUtils; import javax.annotation.Resource; import java.util.ArrayList; @@ -71,10 +72,10 @@ public class StaffPatrolRecordServiceImpl extends BaseServiceImpl wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(formDTO.getGridId()), "GRID", formDTO.getGridId()) - .eq("STAFF_ID", tokenDto.getUserId()) - .orderByDesc("PATROL_START_TIME") + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(formDTO.getGridId()), StaffPatrolRecordEntity::getGrid, formDTO.getGridId()) + .eq(StaffPatrolRecordEntity::getStaffId, tokenDto.getUserId()) + .orderByDesc(StaffPatrolRecordEntity::getPatrolStartTime) .last("limit 1"); StaffPatrolRecordEntity entity = baseDao.selectOne(wrapper); if (null == entity) {