| | |
| | | private DeviceMapper deviceMapper; |
| | | |
| | | @Autowired |
| | | private InterfaceLogMapper interfaceLogMapper; |
| | | |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | |
| | | @Autowired |
| | |
| | | warningEvent.setStatus(Constants.TWO); |
| | | warningEventMapper.updateById(warningEvent); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | if(CollectionUtils.isNotEmpty(deviceList)){ |
| | | for (Device device:deviceList) { |
| | | device.setSendInfo(warningRule.getDeviceNoticeContent()); |
| | | DeviceServiceImpl.sendBroadcaseBobaoHttpBiz(device); |
| | | DeviceServiceImpl.sendBroadcaseBobaoHttpBiz(device,interfaceLogMapper); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public List<Integer> processWarnFront(Constants.WarningConfig warningConfig){ |
| | | /* public List<Integer> processWarnFront(Constants.WarningConfig warningConfig){ |
| | | List<WarningRuleDetail> warningRuleDetailList = warningRuleDetailMapper.selectJoinList(WarningRuleDetail.class,new MPJLambdaWrapper<WarningRuleDetail>() |
| | | .selectAll(WarningRuleDetail.class) |
| | | .leftJoin(Warning.class,Warning::getId,WarningRuleDetail::getWarningId) |
| | |
| | | return new ArrayList<>(); |
| | | |
| | | |
| | | }*/ |
| | | |
| | | public List<Integer> processWarnFront(Constants.WarningConfig warningConfig){ |
| | | |
| | | List<WarningRuleDetail> warningRuleDetailList = warningRuleDetailMapper.selectJoinList(WarningRuleDetail.class,new MPJLambdaWrapper<WarningRuleDetail>() |
| | | .selectAll(WarningRuleDetail.class) |
| | | .leftJoin(Warning.class,Warning::getId,WarningRuleDetail::getWarningId) |
| | | .eq(WarningRuleDetail::getIsdeleted,Constants.ZERO) |
| | | .eq(Warning::getIsdeleted,Constants.ZERO) |
| | | .eq(Warning::getStatus,Constants.ONE) |
| | | .eq(Warning::getCode,warningConfig.getKey()) |
| | | ); |
| | | if(CollectionUtils.isEmpty(warningRuleDetailList)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | //所有报警规则配置信息 |
| | | List<Integer> ruleIdList = warningRuleDetailList.stream().map(i->i.getRuleId()).collect(Collectors.toList());; |
| | | Set<Integer> ruleIdSet = new HashSet<>(ruleIdList); |
| | | if(CollectionUtils.isNotEmpty(ruleIdSet)){ |
| | | List<Integer> resultList = new ArrayList<>(); |
| | | for (Integer ruleId:ruleIdSet) { |
| | | WarningRule warningRule = warningRuleMapper.selectById(ruleId); |
| | | //查询其他规则信息 |
| | | List<WarningRuleDetail> warningRuleDetails = warningRuleDetailMapper.selectJoinList(WarningRuleDetail.class,new MPJLambdaWrapper<WarningRuleDetail>() |
| | | .selectAll(WarningRuleDetail.class) |
| | | .selectAs(Warning::getCode,WarningRuleDetail::getCode) |
| | | .leftJoin(Warning.class,Warning::getId,WarningRuleDetail::getWarningId) |
| | | .eq(WarningRuleDetail::getIsdeleted,Constants.ZERO) |
| | | .eq(Warning::getIsdeleted,Constants.ZERO) |
| | | .eq(Warning::getStatus,Constants.ONE) |
| | | .eq(WarningRuleDetail::getRuleId,ruleId) |
| | | // .in(Warning::getCode,Constants.WarningConfig.ALARM_TEST.getKey(), |
| | | // Constants.WarningConfig.GRID_TIME_OUT_INFO.getKey(), |
| | | // Constants.WarningConfig.KEY_TIME_OUT_BACK.getKey() |
| | | // ) |
| | | ); |
| | | //无任何规则 直接跳过 |
| | | if(CollectionUtils.isEmpty(warningRuleDetails)){ |
| | | return resultList; |
| | | }else if(!Constants.equalsInteger(warningRuleDetails.stream().filter(i->!i.getCode().equals(warningConfig.getKey()+"")).collect(Collectors.toList()).size(),Constants.ZERO)){ |
| | | List<WarningRuleDetail> wList = warningRuleDetails.stream().filter(i->!i.getCode().equals(warningConfig.getKey()+"")).collect(Collectors.toList()); |
| | | //获取所有其他所有事件主键信息 |
| | | List<Integer> warningIdList = wList.stream().map(i->i.getWarningId()).collect(Collectors.toList()); |
| | | Set<Integer> setWarningIdList = new HashSet<>(warningIdList); |
| | | //获取时间内所有事件信息 |
| | | List<WarningEvent> warningEventList = warningEventMapper.selectList(new QueryWrapper<WarningEvent>().lambda() |
| | | .eq(WarningEvent::getIsdeleted,Constants.ZERO) |
| | | .in(WarningEvent::getWarningId,setWarningIdList) |
| | | .apply(Objects.nonNull(warningRule.getIntervalSec())," DATE_ADD(CREATE_DATE , INTERVAL "+warningRule.getIntervalSec()+" SECOND) > now() ") |
| | | ); |
| | | if(this.processWarnFlag(wList,warningEventList)){ |
| | | resultList.add(ruleId); |
| | | }; |
| | | }else{ |
| | | List<WarningRuleDetail> wList = warningRuleDetails.stream().filter(i->i.getCode().equals(warningConfig.getKey()+"")).collect(Collectors.toList()); |
| | | //获取本次事件主键信息 |
| | | List<Integer> warningIdList = wList.stream().map(i->i.getWarningId()).collect(Collectors.toList()); |
| | | Set<Integer> setWarningIdList = new HashSet<>(warningIdList); |
| | | if(Objects.isNull(warningRule.getIntervalSec())){ |
| | | resultList.add(ruleId); |
| | | }else{ |
| | | //获取时间内所有事件信息 |
| | | List<WarningEvent> warningEventList = warningEventMapper.selectList(new QueryWrapper<WarningEvent>().lambda() |
| | | .eq(WarningEvent::getIsdeleted,Constants.ZERO) |
| | | .in(WarningEvent::getWarningId,setWarningIdList) |
| | | .apply(Objects.nonNull(warningRule.getIntervalSec())," DATE_ADD(CREATE_DATE , INTERVAL "+warningRule.getIntervalSec()+" SECOND) > now() ") |
| | | ); |
| | | if(this.processWarnFlag(wList,warningEventList)){ |
| | | resultList.add(ruleId); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return resultList; |
| | | } |
| | | return new ArrayList<>(); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | return false; |
| | | } |
| | | for (WarningRuleDetail warningRuleDetail:warningRuleDetails) { |
| | | if(Objects.nonNull(warningRuleDetail.getRegionId())){ |
| | | if(Objects.nonNull(warningRuleDetail.getDeviceId())){ |
| | | if(warningEventList.stream().filter(i->Constants.equalsInteger(i.getWarningId(),warningRuleDetail.getWarningId()) |
| | | && StringUtils.isNotBlank(i.getRegionId()) && i.getRegionId().equals(warningRuleDetail.getRegionId()) |
| | | && StringUtils.isNotBlank(i.getDeviceId()) && i.getDeviceId().equals(warningRuleDetail.getDeviceId()) |
| | | ).collect(Collectors.toList()).size()<=Constants.ZERO){ |
| | | return false; |
| | | } |