49 lines
2.2 KiB
Java
49 lines
2.2 KiB
Java
|
|
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<WarningRuleInfoMapper,WarningRuleInfo> {
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private WarningConditionService warningConditionService;
|
||
|
|
|
||
|
|
|
||
|
|
public Page<WarningRuleInfo> pageQuery(WarningRulePageSo page) {
|
||
|
|
LambdaQueryWrapper<WarningRuleInfo> 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<WarningRuleInfo> warningRuleInfoPage = this.baseMapper.selectPage(page.getPageSo().toPage(), queryWrapper);
|
||
|
|
List<WarningRuleInfo> records = warningRuleInfoPage.getRecords();
|
||
|
|
for (WarningRuleInfo record : records) {
|
||
|
|
List<WarningCondition> listByRuleId = warningConditionService.getListByRuleId(record.getRuleId());
|
||
|
|
record.setConditions(listByRuleId);
|
||
|
|
}
|
||
|
|
return warningRuleInfoPage;
|
||
|
|
}
|
||
|
|
}
|