package com.gyee.runeconomy.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.gyee.runeconomy.model.auto.ProEconShutdownEvent2; import com.gyee.runeconomy.service.auto.IProEconShutdownEvent2Service; import com.gyee.runeconomy.util.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; @Service public class ShutdownEvent2Service { @Resource private IProEconShutdownEvent2Service proEconShutdownEvent2Service; public Page getShutdownEventList(Integer pageNum, Integer pageSize, String wtId, Date beginDate, Date endDate) { if (StringUtils.empty(pageNum)) { pageNum = 1; } if (StringUtils.empty(pageSize)) { pageSize = 10; } //构造分页构造器 Page pageInfo = new Page<>(pageNum, pageSize); if (StringUtils.notEmp(wtId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate)) { //构造条件构造器 QueryWrapper queryWrapper = new QueryWrapper<>(); //添加过滤条件 queryWrapper.eq("windturbine_id", wtId) .ge("stop_time", beginDate) .le("stop_time", endDate) .apply("EXTRACT(EPOCH FROM (start_time - stop_time)) / 60 > 10"); //执行查询 proEconShutdownEvent2Service.page(pageInfo, queryWrapper); } return pageInfo; } }