diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java index 4423f4f..c67229b 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java @@ -10,6 +10,8 @@ public interface AbnormalAlarmConstant { List TYPE_LIST = Arrays.asList("3","2","5","10","13","14"); + List LONG_TYPE_LIST = Arrays.asList(3L,2L,5L,10L,13L,14L); + List SEND_MESSSAGE_TYPE_LIST = Arrays.asList("2","13","14"); String LEVEL_TYPE_LIST = "3,2,5,10,13,14"; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlarmHandleEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlarmHandleEntity.java index 9af58de..88a300f 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlarmHandleEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlarmHandleEntity.java @@ -1,6 +1,5 @@ package com.hnac.hzims.operational.alert.entity; -import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,6 +9,9 @@ import org.springblade.core.mp.base.BaseEntity; import java.util.Date; +/** + * @author ysj + */ @Data @TableName("hzims_alarm_handle") @EqualsAndHashCode(callSuper = true) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/AlarmHandleMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/AlarmHandleMapper.java index c3fb870..c989ecc 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/AlarmHandleMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/AlarmHandleMapper.java @@ -8,6 +8,8 @@ import org.apache.ibatis.annotations.Param; import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; +import java.util.List; + /** * @author ysj * @date 2023/03/09 09:19:13 @@ -17,4 +19,6 @@ public interface AlarmHandleMapper extends UserDataScopeBaseMapper selectHandlePage(IPage page,@Param("param") HandleQueryVo param); + + List handles(@Param("types") List types,@Param("start") String start,@Param("end") String end); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/AlarmHandleMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/AlarmHandleMapper.xml index 1ef357c..ab07923 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/AlarmHandleMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/AlarmHandleMapper.xml @@ -35,4 +35,23 @@ order by create_time desc + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/AlarmHandleService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/AlarmHandleService.java index ecb5b88..9fe3eb2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/AlarmHandleService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/AlarmHandleService.java @@ -22,4 +22,6 @@ public interface AlarmHandleService extends BaseService { IPage pageCondition(Query query, HandleQueryVo param); List handleUser(); + + List handles(List types); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlarmHandleServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlarmHandleServiceImpl.java index ebd3780..b78f73d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlarmHandleServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlarmHandleServiceImpl.java @@ -143,4 +143,16 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl handles(List types) { + String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"; + String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); + return this.baseMapper.handles(types,start,end); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java index 8d3af89..65aba88 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java @@ -76,11 +76,8 @@ public class AlertMerageServiceImpl implements AlarmMergeService { .between(HistoryAbnormalAlarmEntity::getStartTime,start,end) ); // 处理告警记录 - List handles = alarmHandleService.list(Wrappers.lambdaQuery() - .in(AlarmHandleEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) - .in(AlarmHandleEntity::getAlarmType, AbnormalAlarmConstant.TYPE_LIST) - .between(AlarmHandleEntity::getCreateTime,start,end) - ); + List handles = alarmHandleService.handles(AbnormalAlarmConstant.LONG_TYPE_LIST); + List alarms = new ArrayList<>(); if(CollectionUtil.isNotEmpty(faults)){ alarms.addAll(faults.stream().filter(o -> CollectionUtil.isEmpty(handles) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java index e3b5372..9a234f2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java @@ -243,14 +243,15 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl types = Arrays.asList(param.getType().split(",")); + condition.setTypes(types); Result> result = alarmClient.getByStationsAndTime(condition); if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){ return new AlarmReustVo(); } // 查询处理告警 - List handles = this.getAlarmHandleIds(); + List handles = handleService.handles(types.stream().map(Long::parseLong).collect(Collectors.toList())); // 返回数据 AlarmReustVo response = new AlarmReustVo(); @@ -261,7 +262,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl page = super.page(Condition.getPage(query), wrapper); List records = page.getRecords(); // 步骤2. 过滤已处理等級告警 - LambdaQueryWrapper handleWarpper = new LambdaQueryWrapper(); - handleWarpper.between(AlarmHandleEntity::getCreateTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00", - DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME)); - handleWarpper.in(AlarmHandleEntity::getStationCode, records.stream().map(HistoryLevelAlarmEntity::getStationId).collect(Collectors.toList())); - handleWarpper.in(AlarmHandleEntity::getAlarmId,records.stream().map(HistoryLevelAlarmEntity::getAlarmId).collect(Collectors.toList())); - List handles = handleService.list(); + List handles = handleService.handles(ObjectUtil.isEmpty(entity.getType()) ? AbnormalAlarmConstant.LONG_TYPE_LIST : Collections.singletonList(Long.parseLong(entity.getType()))); + page.setRecords(records.stream().peek(record-> record.setIsHandle(CollectionUtil.isNotEmpty(handles) || handles.stream().map(AlarmHandleEntity::getAlarmId).collect(Collectors.toList()).contains(record.getAlarmId()))).collect(Collectors.toList())); return page; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/LevelAlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/LevelAlarmServiceImpl.java index f7f5ef7..3839214 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/LevelAlarmServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/LevelAlarmServiceImpl.java @@ -27,10 +27,7 @@ import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @@ -104,7 +101,7 @@ public class LevelAlarmServiceImpl implements LevelAlarmService { ); // 数据过滤 - List entitys = alarms.stream().filter(alarm -> CollectionUtil.isEmpty(historys) || !historys.stream().map(HistoryLevelAlarmEntity::getAlarmId).collect(Collectors.toList()).contains(alarm.getId())).map(item->{ + List entitys = alarms.stream().filter(alarm -> CollectionUtil.isNotEmpty(historys) /*|| !historys.stream().map(HistoryLevelAlarmEntity::getAlarmId).collect(Collectors.toList()).contains(alarm.getId())*/).map(item->{ HistoryLevelAlarmEntity entity = new HistoryLevelAlarmEntity(); entity.setAlarmId(item.getId()); entity.setAlarmTime(DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s")); @@ -165,7 +162,7 @@ public class LevelAlarmServiceImpl implements LevelAlarmService { // app,web消息推送 this.sendMessageByWebApp(depts.get(0),entity); // 短信推送 - this.message(depts.get(0),entity); + //this.message(depts.get(0),entity); }); } @@ -189,13 +186,12 @@ public class LevelAlarmServiceImpl implements LevelAlarmService { if (deptName.isSuccess()) { message.setDeptName(deptName.getData()); } - User admin = userClient.userByAccount("200000", "admin").getData(); - message.setCreateDept(admin.getCreateDept()); - message.setCreateUser(admin.getId()); + message.setCreateDept(dept); result.getData().forEach(user->{ message.setPusher(String.valueOf(user.getId())); message.setPusherName(user.getName()); message.setAccount(String.valueOf(user.getId())); + message.setCreateUser(user.getId()); messageClient.sendMessage(message); }); } @@ -206,6 +202,33 @@ public class LevelAlarmServiceImpl implements LevelAlarmService { * @param entity */ private void message(Long dept,HistoryLevelAlarmEntity entity) { - + // 获取站点用户 + R> result = userClient.relationUserListByRoleAlias("200000",dept,"projectManager"); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return; + } + MessagePushRecordDto message = new MessagePushRecordDto(); + message.setBusinessClassify("warning"); + message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()); + message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription()); + message.setTaskId(entity.getId()); + message.setTenantId("200000"); + message.setContent(entity.getSoeExplain()); + message.setTypes(Collections.singletonList(MessageConstants.SMS_PUSH)); + message.setPushType(MessageConstants.IMMEDIATELY); + message.setDeptId(dept); + R deptName = sysClient.getDeptName(dept); + if (deptName.isSuccess()) { + message.setDeptName(deptName.getData()); + } + User admin = userClient.userByAccount("200000", "admin").getData(); + message.setCreateDept(admin.getCreateDept()); + message.setCreateUser(admin.getId()); + result.getData().forEach(user->{ + message.setPusher(String.valueOf(user.getId())); + message.setPusherName(user.getName()); + message.setAccount(String.valueOf(user.getId())); + messageClient.sendMessage(message); + }); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java index a2120de..f11f3ae 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java @@ -12,6 +12,9 @@ import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.fdp.feign.IFdpMonitorClient; import com.hnac.hzims.fdp.vo.FdpFaultStatusVo; +import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant; +import com.hnac.hzims.operational.alert.entity.AlarmHandleEntity; +import com.hnac.hzims.operational.alert.service.AlarmHandleService; import com.hnac.hzims.operational.config.entity.DataSet; import com.hnac.hzims.operational.config.entity.StAlarmRecordEntity; import com.hnac.hzims.operational.config.entity.StFocusPropertiesEntity; @@ -67,6 +70,8 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl 0) { + /*if (alarmList.size() > 0) { StAlarmRecordEntity stAlarmRecordEntity = alarmList.get(0); if (null != stAlarmRecordEntity.getProcessTime()) { time = new Date().getTime() - stAlarmRecordEntity.getProcessTime().getTime(); @@ -290,7 +295,7 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl>> mapList1 = - new ArrayList>>(map.entrySet()); + new ArrayList>>(map.entrySet()); Collections.sort(mapList1, new Comparator>>() { @Override @@ -451,7 +456,7 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl> fdpRealIds = fdpMonitorClient.getRealIds(); SoeQueryConditionByStation soeQueryConditionByStation = new SoeQueryConditionByStation(); - /*if (Func.isNotBlank(date)) { + /*if (Func.isNotBlank(date)) { soeQueryConditionByStation.setBeginTime(LocalDateTime.parse(date, df)); } else { soeQueryConditionByStation.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00", df)); @@ -662,7 +667,7 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl> analyzeCodeBySignages = - analyseDataSearchClient.getAnalyzeCodeBySignages(list); + analyseDataSearchClient.getAnalyzeCodeBySignages(list); if (analyzeCodeBySignages.isSuccess() && CollectionUtil.isNotEmpty(analyzeCodeBySignages.getData())) { return analyzeCodeBySignages.getData(); } @@ -732,24 +737,15 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl list = JSONArray.parseArray(result,FaultVo.class); if(CollectionUtil.isEmpty(list)){ - FaultVo faultVo = new FaultVo(); - faultVo.setCreateTime("2023-04-06 15:19:09"); - faultVo.setFaultId("902100000026|1#机组|bd32990711354cb89f1fc4f76abc77c0"); - faultVo.setFinfo("1#机组断路器未分闸"); - faultVo.setFtype("智能预警"); - faultVo.setInfo("正常状态为0,当前状态为1"); - faultVo.setName("断路器未分闸"); - faultVo.setOrd("1#机组"); - faultVo.setStation("902100000026"); - faultVo.setStationName("海南三亚大隆一级电站"); - faultVo.setStatus("1.0"); - return Collections.singletonList(faultVo); + return new ArrayList<>(); } Map map = stations.stream().collect(Collectors.toMap(StationEntity::getCode,StationEntity::getName)); - return list.stream().filter(fault -> map.containsKey(fault.getStation())).map(o->{ - o.setStationName(map.get(o.getStation())); - return o; - }).collect(Collectors.toList()); + // 查询已处理预警数据 + List handles = handleService.handles(Collections.singletonList(AbnormalAlarmConstant.EARLY_WARNING)); + if(CollectionUtil.isEmpty(handles)){ + return list.stream().filter(fault -> map.containsKey(fault.getStation())).peek(o-> o.setStationName(map.get(o.getStation()))).collect(Collectors.toList()); + } + return list.stream().filter(fault -> !handles.stream().map(AlarmHandleEntity::getAlarmId).collect(Collectors.toList()).contains(fault.getFaultId()) && map.containsKey(fault.getStation())).peek(o-> o.setStationName(map.get(o.getStation()))).collect(Collectors.toList()); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ws/LevelAlarmRegular.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ws/LevelAlarmRegular.java index 9975360..70d8ce4 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ws/LevelAlarmRegular.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ws/LevelAlarmRegular.java @@ -29,7 +29,7 @@ public class LevelAlarmRegular{ private LevelAlarmService levelAlarmService; // 定时发送消息 - @Scheduled(cron = "0 0 1 * * ?") + @Scheduled(cron = "0/40 * * * * ?") private void regular(){ // 检查链接存活状态 if(ObjectUtil.isNotEmpty(client) && client.isOpen()){