Browse Source

#集中监控消息bug解决

zhongwei
yang_shj 1 year ago
parent
commit
b821e12d77
  1. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealDeviceVo.java
  2. 1
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/AbnormalAlarmService.java
  3. 17
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java
  4. 32
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java

3
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealDeviceVo.java

@ -9,6 +9,9 @@ import java.util.List;
@Data
public class RealDeviceVo implements Serializable {
@ApiModelProperty("站点编码")
private String stationId;
@ApiModelProperty("设备编号")
private String deviceCode;

1
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/AbnormalAlarmService.java

@ -7,6 +7,7 @@ import java.util.List;
/**
* 告警处理接口
* @author ysj
*/
public interface AbnormalAlarmService extends BaseService<AbnormalAlarmEntity> {

17
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java

@ -95,6 +95,8 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
// 遍历告警信息
soes.forEach(item -> {
// 告警内容站点名称包含处理
List<StationEntity> soeStation = stations.stream().filter(o->o.getCode().equals(item.getStation())).collect(Collectors.toList());
if(!AbnormalAlarmConstant.INTERRUPT_LIST.contains(item.getSoeType())){
return;
}
@ -102,9 +104,10 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
});
// 历史数据处理
this.saveHistoryAlarm(stations,result.getData().getRecords());
this.saveHistoryAlarm(stations,soes);
}
/**
* 中断异常数据处理
* @param stations
@ -171,13 +174,9 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
entity.setStationId(item.getStation());
entity.setStationName(stationName);
entity.setRealId(item.getRealId());
if(AbnormalAlarmConstant.INTERRUPT_LIST.contains(entity.getType())){
entity.setSoeExplain(stationName+ ":" + item.getSoeExplain());
}else{
entity.setSoeExplain(item.getSoeExplain());
}
entity.setType(item.getSoeType());
entity.setStartTime(item.getTs());
entity.setSoeExplain(item.getSoeExplain());
if(AbnormalAlarmConstant.ABNORMAL_STATUS.equals(item.getSoeAlarmType())){
entity.setStatus(1);
}else{
@ -191,7 +190,7 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
explains.add(item.getSoeExplain());
}
// 发送消息
this.sendAlarmMessage(entity,stations);
this.sendAlarmMessage(entity,stations,stationName);
// 推送短信: 只推送拥有项目经理角色用户
};
}
@ -200,7 +199,7 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
* 告警消息推送
* @param entity
*/
private void sendAlarmMessage(HistoryAbnormalAlarmEntity entity,List<StationEntity> stations) {
private void sendAlarmMessage(HistoryAbnormalAlarmEntity entity,List<StationEntity> stations,String stationName) {
if(StringUtil.isEmpty(entity.getStationId())){
return;
}
@ -218,7 +217,7 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
message.setBusinessClassify("warning");
message.setUserIds(users.stream().map(o->String.valueOf(o.getId())).distinct().collect(Collectors.joining(",")));
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey());
message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription());
message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription() + "-[" + stationName + "]");
message.setTaskId(entity.getId());
message.setTenantId("200000");
message.setContent(entity.getSoeExplain());

32
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java

@ -19,18 +19,13 @@ import com.hnac.hzims.operational.config.vo.StationRealVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;
import com.hnac.hzims.operational.main.service.IWeatherService;
import com.hnac.hzims.operational.main.vo.JointRelayVo;
import com.hnac.hzims.operational.main.vo.WaterLevelVo;
import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.station.entity.StationAttributeEntity;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IRealMonitorService;
import com.hnac.hzims.operational.station.service.IStationAttrConfigService;
import com.hnac.hzims.operational.station.service.IStationAttributeService;
import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.main.vo.RealAttributeVo;
import com.hnac.hzims.operational.main.vo.RealDeviceVo;
import com.hnac.hzims.operational.main.vo.RealStationVo;
import com.hnac.hzims.operational.main.vo.WeatherVo;
import com.hnac.hzinfo.sdk.v5.redis.RedisClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -50,6 +45,7 @@ import org.springframework.web.socket.TextMessage;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors;
@ -433,8 +429,6 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
RealStationVo station = new RealStationVo();
// 站点编码
station.setStationCode(key);
// 设置站点状态
this.setStationStatus(alarmList,station,key);
// 名称、限制水位、服务类型、机构、排序
this.stationParam(stationEntityList,station,deptAll.getData());
// 根据设备名称分组
@ -454,6 +448,8 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
this.getDeviceParam(emList, deviceClassifyMap, deviceList);
// 运行设备状态设置
this.deviceState(deviceList);
// 设置站点状态
this.setStationStatus(alarmList,station,key,deviceList);
station.setDeviceList(deviceList.stream().sorted(Comparator.comparing((RealDeviceVo::getDeviceName))).collect(Collectors.toList()));
stationList.add(station);
});
@ -503,8 +499,24 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
* @param station
* @param key
*/
private void setStationStatus(List<String> alarmList, RealStationVo station, String key) {
private void setStationStatus(List<String> alarmList, RealStationVo station, String key,List<RealDeviceVo> deviceList) {
station.setStatus(0);
// 站点功率大于0为正常上送数据
double powerSum = deviceList.stream().mapToDouble(o->{
List<RealAttributeVo> attbts = o.getAttbtList();
if(CollectionUtil.isEmpty(attbts)){
return 0;
}
// 功率属性记录
List<RealAttributeVo> powers = attbts.stream().filter(att-> HomePageConstant.powerList.contains(att.getName())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(powers)){
return 0;
}
return powers.stream().filter(power-> !"0.000000".equals(power.getValue()) && !"-".equals(power.getValue()) && !HomePageConstant.ON.equals(power.getValue())).mapToDouble(value->Double.parseDouble(value.getValue())).sum();
}).sum();
if(powerSum > 0){
return;
}
if(alarmList.contains(key)){
station.setStatus(1);
}
@ -975,7 +987,7 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
return;
}
// 获取设备中属性为P/p的value值总和
powerSum += BigDecimal.valueOf(powerList.stream().mapToDouble(m -> Double.parseDouble(m.getValue())).sum()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
powerSum += BigDecimal.valueOf(powerList.stream().mapToDouble(m -> Double.parseDouble(m.getValue())).sum()).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
station.setPowerSum(powerSum);
}

Loading…
Cancel
Save