67 lines
2.4 KiB
Java
67 lines
2.4 KiB
Java
|
|
package com.gunshi.project.ss.service;
|
||
|
|
|
||
|
|
|
||
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||
|
|
import com.gunshi.project.ss.common.model.StStbprpB;
|
||
|
|
import com.gunshi.project.ss.entity.so.WaterAlarmPageSo;
|
||
|
|
|
||
|
|
import com.gunshi.project.ss.entity.vo.WaterAlarmCount;
|
||
|
|
import com.gunshi.project.ss.entity.vo.WaterAlarmTypeCount;
|
||
|
|
import com.gunshi.project.ss.mapper.WaterAlarmMapper;
|
||
|
|
|
||
|
|
import com.gunshi.project.ss.model.WaterAlarm;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
import org.springframework.transaction.annotation.Transactional;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
@Service
|
||
|
|
@Slf4j
|
||
|
|
@Transactional(rollbackFor = Exception.class)
|
||
|
|
public class WaterAlarmService extends ServiceImpl<WaterAlarmMapper, WaterAlarm> {
|
||
|
|
|
||
|
|
public boolean saveData(WaterAlarm dto) {
|
||
|
|
dto.setId(IdWorker.getId());
|
||
|
|
boolean save = save(dto);
|
||
|
|
return save;
|
||
|
|
}
|
||
|
|
|
||
|
|
public Page<WaterAlarm> queryPage(WaterAlarmPageSo pageSo) {
|
||
|
|
LambdaQueryWrapper<WaterAlarm> queryWrapper = new LambdaQueryWrapper<>();
|
||
|
|
if (pageSo.getStcd() != null) {
|
||
|
|
queryWrapper.eq(WaterAlarm::getStcd,pageSo.getStcd());
|
||
|
|
}
|
||
|
|
if(pageSo.getType() != null){
|
||
|
|
queryWrapper.eq(WaterAlarm::getAlarmType,pageSo.getType());
|
||
|
|
}
|
||
|
|
if(!StringUtils.isBlank(pageSo.getName())){
|
||
|
|
queryWrapper.like(WaterAlarm::getStnm,pageSo.getName());
|
||
|
|
}
|
||
|
|
|
||
|
|
if(pageSo.getTimeRangeSo() != null){
|
||
|
|
queryWrapper.between(WaterAlarm::getAlarmTime,pageSo.getTimeRangeSo().getStart(),pageSo.getTimeRangeSo().getEnd());
|
||
|
|
}
|
||
|
|
queryWrapper.orderByDesc(WaterAlarm::getAlarmTime);
|
||
|
|
Page<WaterAlarm> waterAlarmPage = this.baseMapper.selectPage(pageSo.getPageSo().toPage(), queryWrapper);
|
||
|
|
return waterAlarmPage;
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<WaterAlarmCount> count12(Integer year) {
|
||
|
|
return this.baseMapper.count12(year);
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<WaterAlarmTypeCount> countTypeByYear(Integer year) {
|
||
|
|
List<WaterAlarmTypeCount> res = this.baseMapper.countTypeByYear(year);
|
||
|
|
return res;
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<StStbprpB> listStation() {
|
||
|
|
return this.baseMapper.listStation();
|
||
|
|
}
|
||
|
|
}
|