123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- package com.gyee.alarm.service;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.gyee.alarm.mapper.auto.AlarmTsMapper;
- import com.gyee.alarm.mapper.auto.ProEconAlarmRuleMapper;
- import com.gyee.alarm.model.auto.ProEconAlarmRule;
- import com.gyee.alarm.model.auto.ProEconAlarmType;
- import com.gyee.alarm.model.auto.ProEconCurveFittingMain;
- import com.gyee.alarm.model.vo.AlarmRuleVo;
- import com.gyee.alarm.service.auto.IProEconAlarmTypeService;
- import com.gyee.alarm.util.SnowflakeGenerator;
- import com.gyee.alarm.util.StringUtil;
- import com.gyee.alarm.util.StringUtils;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.*;
- import java.util.stream.Collectors;
- @Service
- public class AlarmRuleService {
- @Resource
- private ProEconAlarmRuleMapper proEconAlarmRuleMapper;
- @Resource
- private IProEconAlarmTypeService proEconAlarmTypeService;
- private int saveAlertrule(ProEconAlarmRule alarmRule) throws Exception {
- int result = 0;
- if (StringUtils.notEmp(alarmRule)) {
- alarmRule.setCreateTime(new Date());
- alarmRule.setId(String.valueOf(SnowflakeGenerator.generateId()));
- result= proEconAlarmRuleMapper.insert(alarmRule);
- }
- // if (result > 0) {
- // int i = eventService.saveEventAlertRule(alarmRule, oldRule2, userData.getUserName());
- return result;
- }
- public int saveAndUpdateAlertrule(ProEconAlarmRule alarmRule) throws Exception {
- int result = 0;
- if (StringUtils.notEmp(alarmRule)) {
- if (StringUtils.notEmp(alarmRule.getId())) {
- ProEconAlarmRule oldRule2 = proEconAlarmRuleMapper.selectById(alarmRule.getId());
- if (oldRule2 != null) {
- result = proEconAlarmRuleMapper.updateByAlertruleId(alarmRule);
- }else
- {
- result = saveAlertrule(alarmRule);
- }
- }
- else
- {
- result = saveAlertrule(alarmRule);
- }
- }
- return result;
- }
- public int deleteAlertrule(ProEconAlarmRule alarmRule) {
- return proEconAlarmRuleMapper.deleteById(alarmRule.getId());
- }
- public IPage<ProEconAlarmRule> pageQueryAll(Page page, String name, String station, String modelId, String rank, String category, String enabled, String relatedparts) {
- IPage<ProEconAlarmRule> AlertruleIPage = proEconAlarmRuleMapper.pageQueryAll(page, name, station, modelId, rank, category, enabled, relatedparts);
- return AlertruleIPage;
- }
- public List<AlarmRuleVo> queryTree() {
- List<AlarmRuleVo> dsList = proEconAlarmRuleMapper.queryTree();
- return dsList;
- }
- //首页风机部件查询
- public Map<String, Integer> queryList(String station, String modelId) {
- Map<String, Integer> map2 = new HashMap<>();
- map2.put("CLX", 0);
- map2.put("YP", 0);
- map2.put("YY", 0);
- map2.put("BJXT", 0);
- map2.put("PHXT", 0);
- map2.put("BPXT", 0);
- map2.put("CFXT", 0);
- map2.put("ZZ", 0);
- map2.put("FDJ", 0);
- map2.put("QT", 0);
- List<ProEconAlarmRule> dslist = proEconAlarmRuleMapper.getAllByStationIdAndModelId(station, modelId);
- map2.put("SUM", dslist.size());
- for (ProEconAlarmRule ar : dslist) {
- int cnt = 0;
- switch (ar.getRelatedParts()) {
- case "CLX":
- cnt = map2.get("CLX").intValue();
- map2.put("CLX", ++cnt);
- break;
- case "YP":
- cnt = map2.get("YP").intValue();
- map2.put("YP", ++cnt);
- break;
- case "YY":
- cnt = map2.get("YY").intValue();
- map2.put("YY", ++cnt);
- break;
- case "BJXT":
- cnt = map2.get("BJXT").intValue();
- map2.put("BJXT", ++cnt);
- break;
- case "PHXT":
- cnt = map2.get("PHXT").intValue();
- map2.put("PHXT", ++cnt);
- break;
- case "BPXT":
- cnt = map2.get("BPXT").intValue();
- map2.put("BPXT", ++cnt);
- break;
- case "CFXT":
- cnt = map2.get("CFXT").intValue();
- map2.put("CFXT", ++cnt);
- break;
- case "ZZ":
- cnt = map2.get("ZZ").intValue();
- map2.put("ZZ", ++cnt);
- break;
- case "FDJ":
- cnt = map2.get("FDJ").intValue();
- map2.put("FDJ", ++cnt);
- break;
- default:
- cnt = map2.get("QT").intValue();
- map2.put("QT", ++cnt);
- break;
- }
- }
- return map2;
- }
- public List<String> getUniformCodeByNameAndStation(String name, String station, String modelid) {
- List<ProEconAlarmRule> rules = proEconAlarmRuleMapper.getUniformCodeByNameAndStation(name, station, modelid);
- if (rules == null || rules.size() == 0)
- return null;
- ProEconAlarmRule rule = rules.get(0);
- String expression = "(([A][I])|([D][I]))([0-9]+)";
- List<String> list = StringUtil.pattern(rule.getExpression(), expression);
- return list;
- }
- public ProEconAlarmRule selectByAlertruleId(String id) {
- return proEconAlarmRuleMapper.selectById(id);
- }
- }
|