feat(alarm): 添加告警统计功能并优化设备管理
- 在AlarmVO中新增interruptCounts和warnCounts字段用于统计通信中断和终端告警次数 - 在CsAlarmServiceImpl中实现告警次数统计逻辑,解析告警事件数据并计算各类告警数量 - 重构CsEventUserPOServiceImpl中的查询逻辑,优化暂态事件详细信息查询接口 - 在CsEquipmentDeliveryServiceImpl中集成事件查询功能,实时获取设备告警状态 - 优化数据库查询语句,改进事件查询的排序和过滤逻辑
This commit is contained in:
@@ -66,6 +66,9 @@ public class ProjectEquipmentVO {
|
||||
@ApiModelProperty(value = "设备类型(监测设备:DEV_CLD 治理设备:Direct_Connected_Device)")
|
||||
private String devType;
|
||||
|
||||
@ApiModelProperty(value = "是否存在告警(告警通过查询当日的未读的暂态事件判断)")
|
||||
private Boolean isAlarm;
|
||||
|
||||
@ApiModelProperty(value = "监测点集合")
|
||||
private List<CsLinePO> lineList;
|
||||
|
||||
|
||||
@@ -315,126 +315,6 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
return vo;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public DevCountVO devCount(String id,String time) {
|
||||
// QueryWrapper<CsEquipmentDeliveryPO> queryWrapper = new QueryWrapper<>();
|
||||
//
|
||||
// DevCountVO devCountVO = new DevCountVO();
|
||||
//
|
||||
// String userRole = RequestUtil.getUserRole();
|
||||
// List<String> strings = JSONArray.parseArray(userRole, String.class);
|
||||
// if(CollectionUtils.isEmpty(strings)){
|
||||
// throw new BusinessException(AlgorithmResponseEnum.UNKNOW_ROLE);
|
||||
//
|
||||
// }
|
||||
// userRole=strings.get(0);
|
||||
//
|
||||
// List<String> device = roleEngineerDevService.getDevice();
|
||||
// if(CollectionUtils.isEmpty(device)){
|
||||
// devCountVO.setOnLineDevCount(0);
|
||||
// devCountVO.setOnLineDevs(new ArrayList<>());
|
||||
// devCountVO.setOffLineDevCount(0);
|
||||
// devCountVO.setOffLineDevs(new ArrayList<>());
|
||||
// }else {
|
||||
// queryWrapper.clear();
|
||||
// queryWrapper.in("id",device);
|
||||
//
|
||||
// List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryMapper.selectList(queryWrapper);
|
||||
// List<CsEquipmentDeliveryPO> collect = csEquipmentDeliveryPOS.stream().filter(temp -> temp.getRunStatus() == 1).collect(Collectors.toList());
|
||||
// List<CsEquipmentDeliveryPO> collect2= csEquipmentDeliveryPOS.stream().filter(temp -> temp.getRunStatus() == 2).collect(Collectors.toList());
|
||||
// devCountVO.setOnLineDevCount(collect2.size());
|
||||
// devCountVO.setOnLineDevs(collect2);
|
||||
// devCountVO.setOffLineDevCount(collect.size());
|
||||
// devCountVO.setOffLineDevs(collect);
|
||||
// List<String> roleengineer = roleEngineerDevService.getRoleengineer();
|
||||
// devCountVO.setEningerCount(roleengineer.size());
|
||||
// }
|
||||
//
|
||||
// List<CsLedgerVO> deviceTree = iCsLedgerService.getDeviceTree(null);
|
||||
// //由于多加了一程便携式设备
|
||||
// List<String> collect1 = deviceTree.stream()
|
||||
// .map(CsLedgerVO::getChildren).flatMap(Collection::stream)
|
||||
// .filter(temp -> temp.getId().equals(id))
|
||||
// .map(CsLedgerVO::getChildren).flatMap(Collection::stream)
|
||||
// .map(CsLedgerVO::getChildren).flatMap(Collection::stream)
|
||||
// .map(CsLedgerVO::getId).collect(Collectors.toList());
|
||||
// //求交集
|
||||
// device.retainAll(collect1);
|
||||
// if(CollectionUtils.isEmpty(device)){
|
||||
// devCountVO.setCurrentOnLineDevCount(0);
|
||||
// devCountVO.setCurrentOnLineDevs(new ArrayList<>());
|
||||
// devCountVO.setCurrentOffLineDevCount(0);
|
||||
// devCountVO.setCurrentOffLineDevs(new ArrayList<>());
|
||||
// devCountVO.setCurrentProjectCount(0);
|
||||
//
|
||||
// }else {
|
||||
// queryWrapper.clear();
|
||||
// queryWrapper.in("id",device);
|
||||
//
|
||||
// List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryMapper.selectList(queryWrapper);
|
||||
// List<CsEquipmentDeliveryPO> collect = csEquipmentDeliveryPOS.stream().filter(temp -> temp.getRunStatus() == 1).collect(Collectors.toList());
|
||||
// List<CsEquipmentDeliveryPO> collect2= csEquipmentDeliveryPOS.stream().filter(temp -> temp.getRunStatus() == 2).collect(Collectors.toList());
|
||||
// devCountVO.setCurrentOnLineDevCount(collect2.size());
|
||||
// devCountVO.setCurrentOnLineDevs(collect2);
|
||||
// devCountVO.setCurrentOffLineDevCount(collect.size());
|
||||
// devCountVO.setCurrentOffLineDevs(collect);
|
||||
// List<CsLedger> list = iCsLedgerService.lambdaQuery().eq(CsLedger::getPid, id).eq(CsLedger::getState, 1).list();
|
||||
// devCountVO.setCurrentProjectCount(list.size());
|
||||
// }
|
||||
// CsEventUserQueryParam csEventUserQueryParam = new CsEventUserQueryParam();
|
||||
// csEventUserQueryParam.setStatus("0");
|
||||
//
|
||||
// //查询暂态事件、运行事件还是使用之前的方法
|
||||
// List<EventDetailVO> data = eventUserFeignClient.queryEventList(csEventUserQueryParam).getData();
|
||||
// //查询稳态事件 先获取监测点id
|
||||
// csLinePOService.getLinesByDevList(device);
|
||||
//
|
||||
//
|
||||
// //查询运行告警事件
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// List<EventDetailVO> event = data.stream().filter(temp -> temp.getType() == 0).collect(Collectors.toList());
|
||||
// List<EventDetailVO> harmonic = data.stream().filter(temp -> temp.getType() == 1).collect(Collectors.toList());
|
||||
// List<EventDetailVO> alarm = data.stream().filter(temp -> temp.getType() == 3).collect(Collectors.toList());
|
||||
//
|
||||
// if(Objects.equals(userRole, AppRoleEnum.APP_VIP_USER.getCode())){
|
||||
// alarm = alarm.stream().filter(temp -> Objects.equals("3", temp.getLevel())).collect(Collectors.toList());
|
||||
// }
|
||||
// List<EventDetailVO> run = data.stream().filter(temp -> temp.getType() == 2).collect(Collectors.toList());
|
||||
// if(Objects.equals(userRole,AppRoleEnum.APP_VIP_USER.getCode())||Objects.equals(userRole,AppRoleEnum.TOURIST.getCode())
|
||||
// ||Objects.equals(userRole,AppRoleEnum.MARKET_USER.getCode())){
|
||||
// devCountVO.setFeedBackCount(0);
|
||||
//
|
||||
// }else {
|
||||
// CsFeedbackQueryParm csFeedbackQueryParm = new CsFeedbackQueryParm();
|
||||
// csFeedbackQueryParm.setPageNum(1);
|
||||
// csFeedbackQueryParm.setPageSize(100000);
|
||||
// csFeedbackQueryParm.setStatus("1");
|
||||
// Page<CsFeedbackVO> data1 = feedBackFeignClient.queryFeedBackPage(csFeedbackQueryParm).getData();
|
||||
// List<CsFeedbackVO> collect = data1.getRecords().stream().filter(temp -> !Objects.equals(temp.getUserId(), RequestUtil.getUserIndex())).collect(Collectors.toList());
|
||||
// devCountVO.setFeedBackCount(collect.size());
|
||||
// }
|
||||
//
|
||||
// //todo 后续添加警告数,事件数
|
||||
// devCountVO.setEventCount(event.size());
|
||||
// devCountVO.setAlarmCount(alarm.size());
|
||||
// devCountVO.setRunCount(run.size());
|
||||
// devCountVO.setHarmonicCount(harmonic.size());
|
||||
// List<EventDetailVO> curEvent = event.stream().filter(temp -> Objects.equals(temp.getEngineeringid(), id)).collect(Collectors.toList());
|
||||
// List<EventDetailVO> curHarmonic = harmonic.stream().filter(temp -> Objects.equals(temp.getEngineeringid(), id)).collect(Collectors.toList());
|
||||
// List<EventDetailVO> curAlarm = alarm.stream().filter(temp -> Objects.equals(temp.getEngineeringid(), id)).collect(Collectors.toList());
|
||||
// List<EventDetailVO> curRun = run.stream().filter(temp -> Objects.equals(temp.getEngineeringid(), id)).collect(Collectors.toList());
|
||||
//
|
||||
// devCountVO.setCurrentEventCount(curEvent.size());
|
||||
// devCountVO.setCurrentAlarmCount(curAlarm.size());
|
||||
// devCountVO.setCurrentRunCount(curRun.size());
|
||||
// devCountVO.setCurrentHarmonicCount(curHarmonic.size());
|
||||
//
|
||||
//
|
||||
// return devCountVO;
|
||||
// }
|
||||
/**
|
||||
* @Description: 判断当前用户是否是主用户 0-否1-是
|
||||
* @Param:
|
||||
|
||||
@@ -41,6 +41,9 @@ import com.njcn.csdevice.service.*;
|
||||
import com.njcn.csdevice.util.QRCodeUtil;
|
||||
import com.njcn.csdevice.utils.ExcelStyleUtil;
|
||||
import com.njcn.csdevice.utils.StringUtil;
|
||||
import com.njcn.csharmonic.api.EventUserFeignClient;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
@@ -68,6 +71,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
@@ -109,6 +113,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
private final ICsCommunicateService csCommunicateService;
|
||||
private final ICsUserPinsService csUserPinsService;
|
||||
private final EngineeringFeignClient engineeringFeignClient;
|
||||
private final EventUserFeignClient eventUserFeignClient;
|
||||
|
||||
@Override
|
||||
public void refreshDeviceDataCache() {
|
||||
@@ -248,7 +253,17 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
Page<ProjectEquipmentVO> list = this.baseMapper.queryProjectEquipmentVO(returnpage,projectEquipmentQueryParm,device);
|
||||
//根据设备id获取监测点id集合
|
||||
List<CsLinePO> lineIds = csLinePOService.getLineByDev(device);
|
||||
|
||||
//根据设备获取当日是否存在未读取的暂态事件
|
||||
CsEventUserQueryParam param = new CsEventUserQueryParam();
|
||||
param.setUserId(RequestUtil.getUserIndex());
|
||||
param.setStartTime(LocalDate.now().atStartOfDay().format(DatePattern.NORM_DATETIME_FORMATTER));
|
||||
param.setEndTime(LocalDateTime.now().format(DatePattern.NORM_DATETIME_FORMATTER));
|
||||
param.setEventIds(lineIds.stream().map(CsLinePO::getLineId).collect(Collectors.toList()));
|
||||
List<CsEventPO> eventList = eventUserFeignClient.queryTempEventDetail(param).getData();
|
||||
Map<String, List<CsEventPO>> eventMap = Optional.ofNullable(eventList)
|
||||
.orElse(Collections.emptyList())
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(CsEventPO::getDeviceId));
|
||||
|
||||
List<ProjectEquipmentVO> recordList = new ArrayList<>();
|
||||
list.getRecords().forEach(temp->{
|
||||
@@ -260,6 +275,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
if (!Objects.equals(DicDataEnum.PORTABLE.getCode(),temp.getDevType())) {
|
||||
recordList.add(temp);
|
||||
}
|
||||
//判断设备是否存在告警
|
||||
temp.setIsAlarm(CollectionUtil.isNotEmpty(eventMap.get(temp.getEquipmentId())));
|
||||
});
|
||||
|
||||
//获取用户置顶的设备
|
||||
@@ -816,11 +833,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CsEquipmentDeliveryPO saveCld(CsEquipmentDeliveryAddParm param) {
|
||||
boolean result;
|
||||
//设备名称可以重复
|
||||
//CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, param.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
|
||||
//if(Objects.nonNull (one)){
|
||||
// throw new BusinessException ("设备名称不能重复");
|
||||
//}
|
||||
StringUtil.containsSpecialCharacters(param.getNdid());
|
||||
CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid (param.getNdid());
|
||||
if(!Objects.isNull (po)){
|
||||
|
||||
Reference in New Issue
Block a user