gunshi-project-ss/src/main/java/com/gunshi/project/ss/service/WarningRuleInfoService.java

49 lines
2.2 KiB
Java
Raw Normal View History

2025-12-29 17:13:09 +08:00
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;
2025-12-29 17:13:09 +08:00
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;
2025-11-26 18:00:57 +08:00
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
2025-11-26 18:00:57 +08:00
import java.util.List;
@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)
public class WarningRuleInfoService extends ServiceImpl<WarningRuleInfoMapper,WarningRuleInfo> {
2025-11-26 18:00:57 +08:00
@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);
2025-11-26 18:00:57 +08:00
List<WarningRuleInfo> records = warningRuleInfoPage.getRecords();
for (WarningRuleInfo record : records) {
List<WarningCondition> listByRuleId = warningConditionService.getListByRuleId(record.getRuleId());
record.setConditions(listByRuleId);
}
return warningRuleInfoPage;
}
}