package com.gunshi.project.ss.service; import com.alibaba.excel.util.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gunshi.project.ss.entity.so.WarningRulePageSo; import com.gunshi.project.ss.mapper.WarningRuleInfoMapper; import com.gunshi.project.ss.model.WarningCondition; import com.gunshi.project.ss.model.WarningRuleInfo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @Service @Slf4j @Transactional(rollbackFor = Exception.class) public class WarningRuleInfoService extends ServiceImpl { @Autowired private WarningConditionService warningConditionService; public Page pageQuery(WarningRulePageSo page) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); // if(!StringUtils.isBlank(page.getRuleName())){ // queryWrapper.like(WarningRuleInfo::getRuleName, page.getRuleName()); // } if(!StringUtils.isBlank(page.getWarningType())){ queryWrapper.eq(WarningRuleInfo::getWarningType, page.getWarningType()); } // if(page.getDateTimeRangeSo() != null){ // queryWrapper.ge(WarningRuleInfo::getCreateTime,page.getDateTimeRangeSo().getStart()); // queryWrapper.le(WarningRuleInfo::getCreateTime,page.getDateTimeRangeSo().getEnd()); // } queryWrapper.orderByDesc(WarningRuleInfo::getCreateTime); Page warningRuleInfoPage = this.baseMapper.selectPage(page.getPageSo().toPage(), queryWrapper); List records = warningRuleInfoPage.getRecords(); for (WarningRuleInfo record : records) { List listByRuleId = warningConditionService.getListByRuleId(record.getRuleId()); record.setConditions(listByRuleId); } return warningRuleInfoPage; } }