| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.dingTalk.DingTalk; |
| | | import com.doumee.core.dingTalk.DingTalkStream; |
| | |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.hikvision.artemis.sdk.config.ArtemisConfig; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private JkCabinetLogMapper jkCabinetLogMapper; |
| | | |
| | | @Autowired |
| | | private WarningMapper warningMapper; |
| | | private WarningEventMapper warningEventMapper; |
| | | |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | |
| | | @Autowired |
| | | private WarningMapper warningMapper; |
| | | @Autowired |
| | | private WarningRuleMapper warningRuleMapper; |
| | | |
| | | @Autowired |
| | | private WarningRuleDetailMapper warningRuleDetailMapper; |
| | | |
| | | @Autowired |
| | | private WarningPushMapper warningPushMapper; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Autowired |
| | | private DingTalk dingTalk; |
| | |
| | | MPJLambdaWrapper<JkCabinetGrid> wrapper = new MPJLambdaWrapper<JkCabinetGrid>() |
| | | .selectAll(JkCabinetGrid.class) |
| | | .selectAs(JkCabinet::getName,JkCabinetGrid::getCabinetName) |
| | | .selectAs(JkKeys::getCode,JkCabinetGrid::getKeyCode) |
| | | .selectAs(JkKeys::getRfidLable,JkCabinetGrid::getKeyCode) |
| | | .leftJoin(JkCabinet.class,JkCabinet::getId,JkCabinetGrid::getCabinetId) |
| | | .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId) |
| | | .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | |
| | | } |
| | | List<JkCabinetGrid> jkCabinetGridList = jkCabinetGridMapper.selectJoinList(JkCabinetGrid.class, |
| | | new MPJLambdaWrapper<JkCabinetGrid>().selectAll(JkCabinetGrid.class) |
| | | .selectAs(JkKeys::getCode,JkCabinetGrid::getKeyCode) |
| | | .selectAs(JkKeys::getRfidLable,JkCabinetGrid::getKeyCode) |
| | | .selectAs(JkKeys::getCarCode,JkCabinetGrid::getCarCode) |
| | | .selectAs(JkKeys::getCarId,JkCabinetGrid::getCarId) |
| | | .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId) |
| | |
| | | jkCabinetLog.setAuthType(Constants.TWO); |
| | | jkCabinetLog.setMemberId(loginUserInfo.getMemberId()); |
| | | jkCabinetLog.setStatus(Constants.ZERO); |
| | | jkCabinetLog.setIsNotice(Constants.ZERO); |
| | | jkCabinetLog.setInfo(Objects.isNull(dto.getOpenType())||Constants.equalsInteger(dto.getOpenType(),Constants.ZERO)?"系统开启":"手动开启"); |
| | | if(Objects.nonNull(jkCabinetGrid.getKeyId())){ |
| | | jkCabinetLog.setKeyId(jkCabinetGrid.getKeyId()); |
| | | JkKeys jkKeys = jkKeysMapper.selectById(jkCabinetGrid.getKeyId()); |
| | |
| | | jkCabinetLog.setType(Constants.ZERO); |
| | | jkCabinetLogs.add(jkCabinetLog); |
| | | } |
| | | |
| | | jkCabinetLogMapper.insert(jkCabinetLogs); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | jkCabinetLog.setIsNotice(Constants.ZERO); |
| | | jkCabinetLog.setType(Constants.ONE); |
| | | jkCabinetLogMapper.insert(jkCabinetLog); |
| | | //查询钥匙的开门记录 进行添加关门记录主键 |
| | | jkCabinetLogMapper.update(null,new UpdateWrapper<JkCabinetLog>().lambda() |
| | | .set(JkCabinetLog::getCloseLogId,jkCabinetLog.getId()) |
| | | .eq(JkCabinetLog::getKeyId,jkCabinetLog.getKeyId()) |
| | | .eq(JkCabinetLog::getType,Constants.ZERO) |
| | | .isNull(JkCabinetLog::getCloseLogId)); |
| | | if(Constants.equalsInteger(dto.getKeyStatus(),Constants.ONE)){ |
| | | jkCabinetLogMapper.update(null,new UpdateWrapper<JkCabinetLog>().lambda() |
| | | .set(JkCabinetLog::getCloseLogId,jkCabinetLog.getId()) |
| | | .eq(JkCabinetLog::getKeyId,jkCabinetLog.getKeyId()) |
| | | .eq(JkCabinetLog::getType,Constants.ONE) |
| | | .eq(JkCabinetLog::getKeyStatus,Constants.TWO) |
| | | .isNull(JkCabinetLog::getCloseLogId)); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // public void saveAbnormalOpenGridLog(AbnormalOpenGridDTO dto){ |
| | | // if(Objects.isNull(dto) |
| | | // || StringUtils.isBlank(dto.getBoardCode()) |
| | | // || StringUtils.isBlank(dto.getBoardCode()) |
| | | // || Objects.isNull(dto.getCabinetId()) |
| | | // || Objects.isNull(dto.getKeyStatus()) |
| | | // || Objects.isNull(dto.getAuthType()) |
| | | // ){ |
| | | // throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | // } |
| | | // JkCabinetGrid jkCabinetGrid = jkCabinetGridMapper.selectOne(new QueryWrapper<JkCabinetGrid>().lambda().eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | | // .eq(JkCabinetGrid::getCabinetId,dto.getCabinetId()) |
| | | // .eq(JkCabinetGrid::getId,dto.getGridId()) |
| | | // .last(" limit 1 ") |
| | | // ); |
| | | // JkCabinetLog jkCabinetLog = new JkCabinetLog(); |
| | | // jkCabinetLog.setCreateDate(new Date()); |
| | | // jkCabinetLog.setIsdeleted(Constants.ZERO); |
| | | // jkCabinetLog.setCabinetId(dto.getCabinetId()); |
| | | // jkCabinetLog.setGridId(jkCabinetGrid.getId()); |
| | | // jkCabinetLog.setAuthType(dto.getAuthType()); |
| | | // jkCabinetLog.setMemberId(dto.getMemberId()); |
| | | // jkCabinetLog.setKeyStatus(Constants.ZERO); |
| | | // jkCabinetLog.setStatus(Constants.ZERO); |
| | | // |
| | | // } |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | jkCabinetGridList = jkCabinetGridMapper.selectJoinList(JkCabinetGrid.class, |
| | | new MPJLambdaWrapper<JkCabinetGrid>().selectAll(JkCabinetGrid.class) |
| | | .selectAs(JkKeys::getCode,JkCabinetGrid::getKeyCode) |
| | | .selectAs(JkKeys::getRfidLable,JkCabinetGrid::getKeyCode) |
| | | .selectAs(JkKeys::getCarCode,JkCabinetGrid::getCarCode) |
| | | .selectAs(JkKeys::getCarId,JkCabinetGrid::getCarId) |
| | | .selectAs(JkKeys::getStatus,JkCabinetGrid::getKeyStatus) |
| | | .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId) |
| | | .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getWorkingStatus,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getStatus,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getCabinetId,dto.getCabinetId()) |
| | | .in(Constants.equalsInteger(dto.getType(),Constants.ONE),JkKeys::getStatus,Constants.TWO,Constants.THREE) |
| | | .in(Constants.equalsInteger(dto.getType(),Constants.ZERO),JkKeys::getStatus,Constants.ONE) |
| | |
| | | if(Objects.isNull(jkCabinetGrid)){ |
| | | return ; |
| | | } |
| | | // LoginUserInfo loginUserInfo = openGridDriverDTO.getLoginUserInfo(); |
| | | JkCabinetLog jkCabinetLog = new JkCabinetLog(); |
| | | jkCabinetLog.setCreateDate(new Date()); |
| | | // jkCabinetLog.setCreator(loginUserInfo.getId()); |
| | | jkCabinetLog.setIsdeleted(Constants.ZERO); |
| | | jkCabinetLog.setCabinetId(openGridDriverDTO.getCabinetId()); |
| | | jkCabinetLog.setGridId(jkCabinetGrid.getId()); |
| | |
| | | jkCabinetLog.setMemberId(openGridDriverDTO.getMemberId()); |
| | | jkCabinetLog.setType(Constants.ZERO); |
| | | jkCabinetLog.setStatus(Constants.ZERO); |
| | | jkCabinetLog.setInfo(Objects.isNull(openGridDriverDTO.getOpenType())||Constants.equalsInteger(openGridDriverDTO.getOpenType(),Constants.ZERO)?"系统开启":"手动开启"); |
| | | if(Objects.nonNull(jkCabinetGrid.getKeyId())){ |
| | | jkCabinetLog.setKeyId(jkCabinetGrid.getKeyId()); |
| | | JkKeys jkKeys = jkKeysMapper.selectById(jkCabinetGrid.getKeyId()); |
| | |
| | | jkCabinetLog.setRoleType(jkKeys.getRoleType()); |
| | | } |
| | | } |
| | | jkCabinetLog.setIsNotice(Constants.ZERO); |
| | | jkCabinetLogMapper.insert(jkCabinetLog); |
| | | } |
| | | |
| | |
| | | .eq(JkCabinetGrid::getId,dto.getGridId()) |
| | | .last(" limit 1 ") |
| | | ); |
| | | |
| | | if(Objects.nonNull(jkCabinetGrid)){ |
| | | log.error("柜格开门超时未关闭告警信息:{}"+JSONObject.toJSONString(jkCabinetGrid)); |
| | | //规则类型 |
| | | Constants.WarningConfig warningConfig = Constants.WarningConfig.GRID_TIME_OUT_INFO; |
| | | Warning warning = warningMapper.selectOne(new QueryWrapper<Warning>().lambda() |
| | | .eq(Warning::getType,Constants.THREE).eq(Warning::getCode,Constants.WarningConfig.GRID_TIME_OUT_INFO.getKey()).eq(Warning::getIsdeleted,Constants.ZERO).last("limt 1")); |
| | | .eq(Warning::getIsdeleted,Constants.ZERO) |
| | | .eq(Warning::getStatus,Constants.ONE) |
| | | .eq(Warning::getCode,warningConfig.getKey()) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.isNull(warning)){ |
| | | return; |
| | | } |
| | | List<Member> memberList = this.getWarningList(warning); |
| | | if(CollectionUtils.isEmpty(memberList)){ |
| | | List<Integer> ruleIdList = this.processWarnFront(warningConfig); |
| | | if(CollectionUtils.isEmpty(ruleIdList)){ |
| | | return; |
| | | } |
| | | //todo 存储异常日志 |
| | | for (Integer ruleId:ruleIdList) { |
| | | WarningRule warningRule = warningRuleMapper.selectById(ruleId); |
| | | if(Objects.isNull(warningRule)){ |
| | | continue; |
| | | } |
| | | List<Member> memberList = this.getWarningRuleMemberList(warningRule); |
| | | if(CollectionUtils.isEmpty(memberList)){ |
| | | return; |
| | | } |
| | | |
| | | String content = "【钥匙柜-"+jkCabinetGrid.getCabinetName()+"】下【柜格-"+jkCabinetGrid.getCode()+"】超时未关闭"; |
| | | |
| | | }else{ |
| | | JkCabinet jkCabinet = jkCabinetMapper.selectById(dto.getCabinetId()); |
| | | //存储报警异常记录 |
| | | WarningEvent warningEvent = new WarningEvent(); |
| | | warningEvent.setCreateDate(new Date()); |
| | | warningEvent.setWarningId(warning.getId()); |
| | | warningEvent.setTitle(warningConfig.getInfo()); |
| | | warningEvent.setContent(content ); |
| | | warningEvent.setStatus(Constants.ZERO); |
| | | warningEvent.setRegion(Objects.nonNull(jkCabinet)&&StringUtils.isNotBlank(jkCabinet.getLocation())?jkCabinet.getLocation():"未知位置"); |
| | | warningEventMapper.insert(warningEvent); |
| | | |
| | | } |
| | | } |
| | | } |
| | | try { |
| | | // 存储异常通知日志 |
| | | WarningPush warningPush = new WarningPush(); |
| | | warningPush.setCreateDate(new Date()); |
| | | warningPush.setIsdeleted(Constants.ZERO); |
| | | warningPush.setWarningId(warning.getId()); |
| | | warningPush.setTitle(warningConfig.getInfo()); |
| | | warningPush.setContent(content); |
| | | warningPush.setStatus(Constants.ZERO); |
| | | warningPush.setPushType(Constants.ZERO); |
| | | warningPush.setRegion(Objects.nonNull(jkCabinet)&&StringUtils.isNotBlank(jkCabinet.getLocation())?jkCabinet.getLocation():"未知位置"); |
| | | warningPush.setMemberIds( |
| | | StringUtils.join(memberList.stream().map(i->i.getId()).collect(Collectors.toList()),",") |
| | | ); |
| | | warningPush.setMemberIds( |
| | | StringUtils.join(memberList.stream().map(i->i.getId()).collect(Collectors.toList()),",") |
| | | ); |
| | | warningPush.setMemberNames(StringUtils.join(memberList.stream().map(i->i.getName()).collect(Collectors.toList()),",") |
| | | ); |
| | | //todo 暂时关闭 钉钉通知 |
| | | |
| | | // Boolean noticeFlag = dingTalk.workInfoOANotice(Long.valueOf(systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.AGENT_ID).getCode()), |
| | | // StringUtils.join(memberList.stream().filter(i->StringUtils.isNotBlank(i.getDdId())).map(i->i.getDdId()).collect(Collectors.toList()),","), |
| | | // dingTalk.getAlarmNoticeMsg(warningPush.getRegion(),DateUtil.getCurrDateTime(),content)); |
| | | // warningPush.setStatus(noticeFlag?Constants.ONE:Constants.TWO); |
| | | warningPushMapper.insert(warningPush); |
| | | warningEvent.setStatus(Constants.ONE); |
| | | warningEventMapper.updateById(warningEvent); |
| | | }catch (Exception e){ |
| | | warningEvent.setStatus(Constants.TWO); |
| | | warningEventMapper.updateById(warningEvent); |
| | | } |
| | | |
| | | public List<Member> getWarningList(Warning warning){ |
| | | if(Constants.equalsInteger(warning.getStatus(),Constants.ZERO)){ |
| | | return null; |
| | | } |
| | | //查询通知人员 |
| | | List<WarningRule> warningRuleList = warningRuleMapper.selectList(new QueryWrapper<WarningRule>().lambda() |
| | | .eq(WarningRule::getIsdeleted,Constants.ZERO) |
| | | .apply(" id in ( select w.RULE_ID from warning_rule_detail w where w.WARNING_ID = '"+warning.getId()+"' and w.ISDELETED = 0 ) ") |
| | | ); |
| | | List<Member> memberList = new ArrayList<>(); |
| | | if(org.apache.commons.collections.CollectionUtils.isNotEmpty(warningRuleList)){ |
| | | List<String> memberIdStr = warningRuleList.stream().map(i->i.getMemberIds()).collect(Collectors.toList()); |
| | | if(org.apache.commons.collections.CollectionUtils.isNotEmpty(memberIdStr)){ |
| | | List<String> memberIdList = new ArrayList<>(); |
| | | for (String s:memberIdStr) { |
| | | memberIdList.addAll( |
| | | Arrays.asList(s.split(",")) |
| | | ); |
| | | } |
| | | memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO) |
| | | .notIn(Member::getErpId) |
| | | .in(Member::getId,memberIdList) |
| | | ); |
| | | |
| | | } |
| | | } |
| | | return memberList; |
| | | } |
| | | |
| | | |
| | | 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(" 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); |
| | | //获取时间内所有事件信息 |
| | | List<WarningEvent> warningEventList = warningEventMapper.selectList(new QueryWrapper<WarningEvent>().lambda() |
| | | .eq(WarningEvent::getIsdeleted,Constants.ZERO) |
| | | .in(WarningEvent::getWarningId,setWarningIdList) |
| | | .apply(" DATE_ADD(CREATE_DATE , INTERVAL "+warningRule.getIntervalSec()+" SECOND) > now() ") |
| | | ); |
| | | if(this.processWarnFlag(wList,warningEventList)){ |
| | | resultList.add(ruleId); |
| | | } |
| | | } |
| | | } |
| | | return resultList; |
| | | } |
| | | return new ArrayList<>(); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 判断处理是否可以发送通知 当前告警配置的数据列表是否满足 |
| | | * @param warningRuleDetails |
| | | * @return |
| | | */ |
| | | public boolean processWarnFlag(List<WarningRuleDetail> warningRuleDetails,List<WarningEvent> warningEventList){ |
| | | if(CollectionUtils.isEmpty(warningEventList)){ |
| | | return false; |
| | | } |
| | | for (WarningRuleDetail warningRuleDetail:warningRuleDetails) { |
| | | if(Objects.nonNull(warningRuleDetail.getRegionId())){ |
| | | if(warningEventList.stream().filter(i->Constants.equalsInteger(i.getWarningId(),warningRuleDetail.getWarningId()) |
| | | && StringUtils.isNotBlank(i.getRegionId()) && i.getRegionId().equals(warningRuleDetail.getRegionId()) |
| | | ).collect(Collectors.toList()).size()<=Constants.ZERO){ |
| | | return false; |
| | | } |
| | | }else{ |
| | | if(warningEventList.stream().filter(i->Constants.equalsInteger(i.getWarningId(),warningRuleDetail.getWarningId()) |
| | | ).collect(Collectors.toList()).size()<=Constants.ZERO){ |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | public List<Member> getWarningRuleMemberList(WarningRule warningRule){ |
| | | List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO) |
| | | .isNotNull(Member::getErpId) |
| | | .in(Member::getId,Arrays.asList(warningRule.getMemberIds().split(","))) |
| | | ); |
| | | return memberList; |
| | | } |
| | | |
| | | |
| | | @Override |
| | |
| | | .last(" limit 1 ") |
| | | ); |
| | | |
| | | JkCabinet jkCabinet = jkCabinetMapper.selectById(dto.getCabinetId()); |
| | | Constants.WarningConfig warningConfig = Constants.WarningConfig.ALARM_TEST; |
| | | Warning warning = warningMapper.selectOne(new QueryWrapper<Warning>().lambda() |
| | | .eq(Warning::getType,Constants.THREE).eq(Warning::getCode,Constants.WarningConfig.KEY_TIME_OUT_BACK.getKey()).eq(Warning::getIsdeleted,Constants.ZERO).last("limt 1")); |
| | | .eq(Warning::getIsdeleted,Constants.ZERO) |
| | | .eq(Warning::getStatus,Constants.ONE) |
| | | .eq(Warning::getCode,warningConfig.getKey()) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.isNull(warning)){ |
| | | return; |
| | | } |
| | | List<Member> memberList = this.getWarningList(warning); |
| | | if(CollectionUtils.isEmpty(memberList)){ |
| | | List<Integer> ruleIdList = this.processWarnFront(warningConfig); |
| | | if(CollectionUtils.isEmpty(ruleIdList)){ |
| | | return; |
| | | } |
| | | //todo 存储异常日志 |
| | | if(CollectionUtils.isEmpty(ruleIdList)){ |
| | | return; |
| | | } |
| | | for (Integer ruleId:ruleIdList) { |
| | | WarningRule warningRule = warningRuleMapper.selectById(ruleId); |
| | | if (Objects.isNull(warningRule)) { |
| | | continue; |
| | | } |
| | | List<Member> memberList = this.getWarningRuleMemberList(warningRule); |
| | | |
| | | //存储异常日志 |
| | | if(Objects.nonNull(systemUser)){ |
| | | log.error("司机酒精检测,超出酒精值告警信息:{}"+JSONObject.toJSONString(systemUser)); |
| | | String content = ""; |
| | | if(Objects.nonNull(systemUser.getRealname())){ |
| | | content = content + systemUser.getRealname(); |
| | | } |
| | | if(Objects.nonNull(jkCabinet)){ |
| | | content = content + "于"+jkCabinet.getName()+"钥匙柜"; |
| | | } |
| | | content = content + "酒精检测异常"; |
| | | if(Objects.nonNull(dto.getAlcoholNum())){ |
| | | content = content + ",酒精度数【"+dto.getAlcoholNum()+"°】"; |
| | | } |
| | | |
| | | //存储报警异常记录 |
| | | WarningEvent warningEvent = new WarningEvent(); |
| | | warningEvent.setCreateDate(new Date()); |
| | | warningEvent.setWarningId(warning.getId()); |
| | | warningEvent.setTitle(warningConfig.getInfo()); |
| | | warningEvent.setContent(content ); |
| | | warningEvent.setStatus(Constants.ZERO); |
| | | warningEvent.setRegion(Objects.nonNull(jkCabinet)&&StringUtils.isNotBlank(jkCabinet.getLocation())?jkCabinet.getLocation():"未知位置"); |
| | | warningEventMapper.insert(warningEvent); |
| | | |
| | | try{ |
| | | WarningPush warningPush = new WarningPush(); |
| | | warningPush.setCreateDate(new Date()); |
| | | warningPush.setIsdeleted(Constants.ZERO); |
| | | warningPush.setWarningId(warning.getId()); |
| | | warningPush.setTitle(warningConfig.getInfo()); |
| | | warningPush.setContent(content); |
| | | warningPush.setStatus(Constants.ZERO); |
| | | warningPush.setPushType(Constants.ZERO); |
| | | warningPush.setRegion(Objects.nonNull(jkCabinet)&&StringUtils.isNotBlank(jkCabinet.getLocation())?jkCabinet.getLocation():"未知位置"); |
| | | warningPush.setMemberId(dto.getMemberId()); |
| | | warningPush.setMemberIds( |
| | | StringUtils.join(memberList.stream().map(i->i.getId()).collect(Collectors.toList()),",") |
| | | ); |
| | | warningPush.setMemberIds( |
| | | StringUtils.join(memberList.stream().map(i->i.getId()).collect(Collectors.toList()),",") |
| | | ); |
| | | warningPush.setMemberNames(StringUtils.join(memberList.stream().map(i->i.getName()).collect(Collectors.toList()),",") |
| | | ); |
| | | //todo 暂时关闭 钉钉通知 |
| | | // Boolean noticeFlag = dingTalk.workInfoOANotice(Long.valueOf(systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.AGENT_ID).getCode()), |
| | | // StringUtils.join(memberList.stream().filter(i->StringUtils.isNotBlank(i.getDdId())).map(i->i.getDdId()).collect(Collectors.toList()),","), |
| | | // dingTalk.getAlarmNoticeMsg(warningPush.getRegion(),DateUtil.getCurrDateTime(),warningConfig.getInfo())); |
| | | // warningPush.setStatus(noticeFlag?Constants.ONE:Constants.TWO); |
| | | warningPushMapper.insert(warningPush); |
| | | warningEvent.setStatus(Constants.ONE); |
| | | warningEventMapper.updateById(warningEvent); |
| | | }catch (Exception e){ |
| | | warningEvent.setStatus(Constants.TWO); |
| | | warningEventMapper.updateById(warningEvent); |
| | | } |
| | | |
| | | |
| | | //存储异常日志 |
| | | if(Objects.nonNull(systemUser)){ |
| | | log.error("司机酒精检测,超出酒精值告警信息:{}"+JSONObject.toJSONString(systemUser)); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |