渗压,渗流,位移告警生成消息;考核模板查询时返回是否被使用

master
wany 2024-09-20 14:42:31 +08:00
parent 0512f7d4a5
commit ac14c3032a
3 changed files with 55 additions and 0 deletions

View File

@ -10,8 +10,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.xyt.entity.dto.InspectItemDto; import com.gunshi.project.xyt.entity.dto.InspectItemDto;
import com.gunshi.project.xyt.entity.so.AttCctvBasePage; import com.gunshi.project.xyt.entity.so.AttCctvBasePage;
import com.gunshi.project.xyt.mapper.AssessTaskMapper;
import com.gunshi.project.xyt.mapper.AssessTemplateMapper; import com.gunshi.project.xyt.mapper.AssessTemplateMapper;
import com.gunshi.project.xyt.model.AssessIndicator; import com.gunshi.project.xyt.model.AssessIndicator;
import com.gunshi.project.xyt.model.AssessTask;
import com.gunshi.project.xyt.model.AssessTemplate; import com.gunshi.project.xyt.model.AssessTemplate;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -20,7 +22,9 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* : * :
@ -38,6 +42,9 @@ public class AssessTemplateService extends ServiceImpl<AssessTemplateMapper, Ass
@Autowired @Autowired
private AssessIndicatorService indicatorService; private AssessIndicatorService indicatorService;
@Autowired
private AssessTaskMapper taskMapper;
public AssessTemplate saveData(AssessTemplate dto) { public AssessTemplate saveData(AssessTemplate dto) {
dto.setId(IdWorker.getId()); dto.setId(IdWorker.getId());
dto.setStatus(0); dto.setStatus(0);
@ -72,9 +79,21 @@ public class AssessTemplateService extends ServiceImpl<AssessTemplateMapper, Ass
} }
query.orderByAsc(AssessTemplate::getStatus).orderByDesc(AssessTemplate::getCreateTime); query.orderByAsc(AssessTemplate::getStatus).orderByDesc(AssessTemplate::getCreateTime);
Page<AssessTemplate> res = this.page(page.getPageSo().toPage(), query); Page<AssessTemplate> res = this.page(page.getPageSo().toPage(), query);
if (res.getRecords() != null && res.getRecords().size() > 0) {
fillUsedInfo(res.getRecords());
}
return res; return res;
} }
private void fillUsedInfo(List<AssessTemplate> records) {
List<Long> ids = records.stream().map(AssessTemplate::getId).collect(Collectors.toList());
List<AssessTask> list = taskMapper.selectList(new QueryWrapper<AssessTask>().in("template_id", ids));
Map<Long, Long> map = list.stream().collect(Collectors.groupingBy(AssessTask::getTemplateId, Collectors.counting()));
for (AssessTemplate record : records) {
record.setIsUsed(map.containsKey(record.getId()) ? 1 : 0);
}
}
public String startStop(InspectItemDto dto) { public String startStop(InspectItemDto dto) {
Integer status = dto.getStatus(); Integer status = dto.getStatus();
AssessTemplate template = super.getById(dto.getId()); AssessTemplate template = super.getById(dto.getId());

View File

@ -12,6 +12,7 @@ import com.gunshi.project.xyt.mapper.AttResBaseMapper;
import com.gunshi.project.xyt.mapper.MessageCenterMapper; import com.gunshi.project.xyt.mapper.MessageCenterMapper;
import com.gunshi.project.xyt.model.AttResBase; import com.gunshi.project.xyt.model.AttResBase;
import com.gunshi.project.xyt.model.MessageCenter; import com.gunshi.project.xyt.model.MessageCenter;
import com.gunshi.project.xyt.model.OsmoticWarnR;
import com.gunshi.project.xyt.model.StRsvrR; import com.gunshi.project.xyt.model.StRsvrR;
import com.gunshi.project.xyt.util.DateUtil; import com.gunshi.project.xyt.util.DateUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -136,6 +137,36 @@ public class MessageCenterService extends ServiceImpl<MessageCenterMapper, Messa
} }
/**
*
* @param warnR
* @param desc
*/
public void osmoticWarnMes(OsmoticWarnR warnR,String desc) {
MessageCenter center = new MessageCenter();
String stationCode = warnR.getStationCode();
String title = null;
String content = "系统检测到";
switch (warnR.getType()){
case 1 :
title = "渗压告警";
content = content + "渗压测点" + stationCode + desc +",请注意核实。";
break;
case 2 :
title = "渗流告警";
content = content + "渗流测点" + stationCode + desc +",请注意核实。";
break;
case 3 :
title = "位移告警";
content = content + "位移测点" + stationCode + desc +",请注意核实。";
break;
}
center.setPublishUserId(1L);
center.setPublishUserName("admin");
center.setTitle(title);
center.setContent(content);
rzMesHandle(center);
}
} }

View File

@ -40,6 +40,9 @@ public class OsmoticWarnRService extends ServiceImpl<OsmoticWarnRMapper, Osmotic
@Resource @Resource
private OsmoticWarnRuleMapper warnRuleMapper; private OsmoticWarnRuleMapper warnRuleMapper;
@Resource
private MessageCenterService messageCenterService;
public Page<OsmoticWarnVo> queryPage(WarnPageSo warnPageSo) { public Page<OsmoticWarnVo> queryPage(WarnPageSo warnPageSo) {
return this.baseMapper.queryPage(warnPageSo.getPageSo().toPage(),warnPageSo); return this.baseMapper.queryPage(warnPageSo.getPageSo().toPage(),warnPageSo);
} }
@ -158,6 +161,8 @@ public class OsmoticWarnRService extends ServiceImpl<OsmoticWarnRMapper, Osmotic
warnR.setType(rule.getType()); warnR.setType(rule.getType());
warnR.setLevel(rule.getLevel()); warnR.setLevel(rule.getLevel());
this.baseMapper.insert(warnR); this.baseMapper.insert(warnR);
//生成消息
messageCenterService.osmoticWarnMes(warnR,rule.getRuleDesc());
return true; return true;
} }