2025-08-29 09:20:47 +08:00
|
|
|
package com.gunshi.project.hsz.service;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
2025-09-26 17:11:26 +08:00
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
2025-08-29 09:20:47 +08:00
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
2025-11-05 15:53:54 +08:00
|
|
|
import com.gunshi.project.hsz.common.model.StStbprpB;
|
2025-08-29 09:20:47 +08:00
|
|
|
import com.gunshi.project.hsz.entity.so.AlarmSetPageSo;
|
|
|
|
|
import com.gunshi.project.hsz.mapper.AlarmSetMapper;
|
|
|
|
|
import com.gunshi.project.hsz.model.AlarmSet;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
2025-09-26 17:11:26 +08:00
|
|
|
import java.util.Date;
|
2025-11-05 15:53:54 +08:00
|
|
|
import java.util.List;
|
2025-09-26 17:11:26 +08:00
|
|
|
|
2025-08-29 09:20:47 +08:00
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public class AlarmSetService extends ServiceImpl<AlarmSetMapper, AlarmSet> {
|
|
|
|
|
public Page<AlarmSet> queryPage(AlarmSetPageSo page) {
|
|
|
|
|
LambdaQueryWrapper<AlarmSet> queryWrapper = new LambdaQueryWrapper<>();
|
2025-11-05 16:28:51 +08:00
|
|
|
if (page.getStcd() != null) {
|
|
|
|
|
queryWrapper.eq(AlarmSet::getStcd, page.getStcd());
|
2025-08-29 09:20:47 +08:00
|
|
|
}
|
|
|
|
|
queryWrapper.orderByDesc(AlarmSet::getCreateDate);
|
|
|
|
|
Page<AlarmSet> alarmSetPage = this.baseMapper.selectPage(page.getPageSo().toPage(), queryWrapper);
|
|
|
|
|
return alarmSetPage;
|
|
|
|
|
}
|
2025-09-26 17:11:26 +08:00
|
|
|
|
|
|
|
|
public boolean saveData(AlarmSet dto) {
|
|
|
|
|
dto.setId(IdWorker.getId());
|
|
|
|
|
dto.setCreateDate(new Date());
|
|
|
|
|
LambdaQueryWrapper<AlarmSet> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper.eq(AlarmSet::getStcd, dto.getStcd());
|
|
|
|
|
AlarmSet alarmSet = this.baseMapper.selectOne(queryWrapper);
|
|
|
|
|
if(alarmSet != null){
|
|
|
|
|
throw new IllegalArgumentException("对不起,该站点的告警设置已存在,请勿重复添加");
|
|
|
|
|
}
|
|
|
|
|
return save(dto);
|
|
|
|
|
}
|
2025-11-05 15:53:54 +08:00
|
|
|
|
|
|
|
|
public List<StStbprpB> listStation() {
|
|
|
|
|
return this.baseMapper.listStation();
|
|
|
|
|
}
|
2025-11-05 16:28:51 +08:00
|
|
|
|
|
|
|
|
public boolean updateInfo(AlarmSet dto) {
|
|
|
|
|
LambdaQueryWrapper<AlarmSet> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper.ne(AlarmSet::getId, dto.getId());
|
|
|
|
|
queryWrapper.eq(AlarmSet::getStcd, dto.getStcd());
|
|
|
|
|
AlarmSet alarmSet = this.baseMapper.selectOne(queryWrapper);
|
|
|
|
|
if(alarmSet != null){
|
|
|
|
|
throw new IllegalArgumentException("对不起站点:" + dto.getStcd() +"已存在");
|
|
|
|
|
}
|
|
|
|
|
return updateById(dto);
|
|
|
|
|
}
|
2025-08-29 09:20:47 +08:00
|
|
|
}
|