Browse Source

采用lambda方式 创建sql

dev_shibei_match
jianjun 4 years ago
parent
commit
14b27f8940
  1. 11
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java

11
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<StaffPatrolRec
@Override
public StaffPatrolInitResultDTO init(TokenDto tokenDto, StaffPatrolInitFormDTO formDTO) {
StaffPatrolInitResultDTO result = new StaffPatrolInitResultDTO();
QueryWrapper<StaffPatrolRecordEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(formDTO.getGridId()), "GRID", formDTO.getGridId())
.eq("STAFF_ID", tokenDto.getUserId())
.orderByDesc("PATROL_START_TIME")
LambdaQueryWrapper<StaffPatrolRecordEntity> 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) {

Loading…
Cancel
Save