Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
haungxing 2 years ago
parent
commit
b4fca7409b
  1. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java
  2. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlarmHandleEntity.java
  3. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/AlarmHandleMapper.java
  4. 19
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/AlarmHandleMapper.xml
  5. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/AlarmHandleService.java
  6. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlarmHandleServiceImpl.java
  7. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java
  8. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java
  9. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryLevelAlarmServiceImpl.java
  10. 43
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/LevelAlarmServiceImpl.java
  11. 38
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java
  12. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ws/LevelAlarmRegular.java

2
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<String> TYPE_LIST = Arrays.asList("3","2","5","10","13","14");
List<Long> LONG_TYPE_LIST = Arrays.asList(3L,2L,5L,10L,13L,14L);
List<String> SEND_MESSSAGE_TYPE_LIST = Arrays.asList("2","13","14");
String LEVEL_TYPE_LIST = "3,2,5,10,13,14";

4
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)

4
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<AlarmHandleEn
@UserDataAuth
IPage<AlarmHandleVo> selectHandlePage(IPage<Object> page,@Param("param") HandleQueryVo param);
List<AlarmHandleEntity> handles(@Param("types") List<Long> types,@Param("start") String start,@Param("end") String end);
}

19
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/AlarmHandleMapper.xml

@ -35,4 +35,23 @@
</where>
order by create_time desc
</select>
<select id="handles" resultType="com.hnac.hzims.operational.alert.entity.AlarmHandleEntity">
select handler.*
from hzims_alarm_handle handler
left join hzims_alarm_handle_detail detail
on handler.detail_id = detail.id
<where>
handler.is_deleted = 0
<if test="types != null and types.size > 0">
and alarm_type in
<foreach collection="types" item="type" index="index" open="(" close=")" separator=",">
#{type}
</foreach>
</if>
<if test="start != null and end != null">
and handler.create_time between #{start} and #{end}
</if>
and (detail.DELAY_TIME &gt; #{end} or detail.DELAY_TIME is null);
</where>
</select>
</mapper>

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/AlarmHandleService.java

@ -22,4 +22,6 @@ public interface AlarmHandleService extends BaseService<AlarmHandleEntity> {
IPage<AlarmHandleVo> pageCondition(Query query, HandleQueryVo param);
List<User> handleUser();
List<AlarmHandleEntity> handles(List<Long> types);
}

12
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlarmHandleServiceImpl.java

@ -143,4 +143,16 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl<AlarmHandleMapper, A
});
return users.stream().distinct().collect(Collectors.toList());
}
/**
* 查询处理告警记录
* @param types 告警类型
* @return
*/
@Override
public List<AlarmHandleEntity> handles(List<Long> 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);
}
}

7
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<AlarmHandleEntity> handles = alarmHandleService.list(Wrappers.<AlarmHandleEntity>lambdaQuery()
.in(AlarmHandleEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
.in(AlarmHandleEntity::getAlarmType, AbnormalAlarmConstant.TYPE_LIST)
.between(AlarmHandleEntity::getCreateTime,start,end)
);
List<AlarmHandleEntity> handles = alarmHandleService.handles(AbnormalAlarmConstant.LONG_TYPE_LIST);
List<AlarmMergeVo> alarms = new ArrayList<>();
if(CollectionUtil.isNotEmpty(faults)){
alarms.addAll(faults.stream().filter(o -> CollectionUtil.isEmpty(handles)

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java

@ -243,14 +243,15 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
condition.setLimit(param.getSize());
condition.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
//condition.setStationIds(Collections.singletonList("901900000234"));
condition.setTypes(Arrays.asList(param.getType().split(",")));
List<String> types = Arrays.asList(param.getType().split(","));
condition.setTypes(types);
Result<HzPage<SoeData>> result = alarmClient.getByStationsAndTime(condition);
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){
return new AlarmReustVo();
}
// 查询处理告警
List<String> handles = this.getAlarmHandleIds();
List<AlarmHandleEntity> handles = handleService.handles(types.stream().map(Long::parseLong).collect(Collectors.toList()));
// 返回数据
AlarmReustVo response = new AlarmReustVo();
@ -261,7 +262,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
if(CollectionUtil.isEmpty(handles)){
record.setIsHandle(false);
}else{
record.setIsHandle(handles.contains(String.valueOf(alarm.getId())));
record.setIsHandle(handles.stream().map(AlarmHandleEntity::getAlarmId).collect(Collectors.toList()).contains(String.valueOf(alarm.getId())));
}
record.setStationCode(alarm.getStation());
record.setContent(alarm.getSoeExplain());

10
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryLevelAlarmServiceImpl.java

@ -21,6 +21,8 @@ import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -59,12 +61,8 @@ public class HistoryLevelAlarmServiceImpl extends BaseServiceImpl<HistoryLevelAl
IPage<HistoryLevelAlarmEntity> page = super.page(Condition.getPage(query), wrapper);
List<HistoryLevelAlarmEntity> records = page.getRecords();
// 步骤2. 过滤已处理等級告警
LambdaQueryWrapper<AlarmHandleEntity> 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<AlarmHandleEntity> handles = handleService.list();
List<AlarmHandleEntity> 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;
}

43
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<HistoryLevelAlarmEntity> entitys = alarms.stream().filter(alarm -> CollectionUtil.isEmpty(historys) || !historys.stream().map(HistoryLevelAlarmEntity::getAlarmId).collect(Collectors.toList()).contains(alarm.getId())).map(item->{
List<HistoryLevelAlarmEntity> 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<List<User>> 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<String> 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);
});
}
}

38
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<StAlarmRecordMapper
private final IStationService stationService;
private final AlarmHandleService handleService;
private final ISoeClient soeClient;
private final RedisTemplate redisTemplate;
@ -188,7 +193,7 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl<StAlarmRecordMapper
}
if ("1".equals(data.getValue()) && 0 == data.getQ()) {
dataSet.setStatus(ConfigStatus.ConfigStatusEnum.RED.getStatus());
/*if (alarmList.size() > 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<StAlarmRecordMapper
}
//结果排序
List<Map.Entry<String, Map<String, Object>>> mapList1 =
new ArrayList<Map.Entry<String, Map<String, Object>>>(map.entrySet());
new ArrayList<Map.Entry<String, Map<String, Object>>>(map.entrySet());
Collections.sort(mapList1, new Comparator<Map.Entry<String, Map<String, Object>>>() {
@Override
@ -451,7 +456,7 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl<StAlarmRecordMapper
R<List<String>> 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<StAlarmRecordMapper
if("1".equals(em.getRunStatus())){
shutdown.add(device.getDeviceCode());
};
//开机
//开机
}else if ("1".equals(value)) {
if(CollectionUtil.isEmpty(emList)){
boot.add(device.getDeviceCode());
@ -707,7 +712,7 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl<StAlarmRecordMapper
}
if (CollectionUtil.isNotEmpty(list)) {
R<List<AnalyzeCodeBySignagesVO>> 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<StAlarmRecordMapper
}
List<FaultVo> 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<String,String> 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<AlarmHandleEntity> 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());
}

2
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()){

Loading…
Cancel
Save