Browse Source

#智能预警

zhongwei
yang_shj 2 years ago
parent
commit
09dae80f0a
  1. 6
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpMonitorClient.java
  2. 6
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpMonitorClientFallBack.java
  3. 40
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/UpdateFaultStateVo.java
  4. 9
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java
  5. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlarmHandleEntity.java
  6. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmHandleVo.java
  7. 8
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/FdpMonitorClient.java
  8. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java
  9. 36
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java
  10. 44
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlarmHandleServiceImpl.java
  11. 1
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/StAlamRecordController.java
  12. 16
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java
  13. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/FaultVo.java
  14. 1
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java

6
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpMonitorClient.java

@ -3,6 +3,7 @@ package com.hnac.hzims.fdp.feign;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.fdp.entity.FdpMonitorEntity;
import com.hnac.hzims.fdp.vo.UpdateFaultStateVo;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
@ -22,6 +23,8 @@ public interface IFdpMonitorClient {
String GET_FAULT_LIST = API_PREFIX + "/getFaultList";
String UPDATE_FAULT_STATE = API_PREFIX + "/updateFaultState";
@GetMapping(GET_ALL)
R<List<FdpMonitorEntity>> getAll();
@ -30,4 +33,7 @@ public interface IFdpMonitorClient {
@GetMapping(GET_FAULT_LIST)
String getFaultList();
@GetMapping(UPDATE_FAULT_STATE)
String updateFaultState(UpdateFaultStateVo state);
}

6
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpMonitorClientFallBack.java

@ -2,6 +2,7 @@ package com.hnac.hzims.fdp.feign;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.fdp.entity.FdpMonitorEntity;
import com.hnac.hzims.fdp.vo.UpdateFaultStateVo;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Component;
@ -26,4 +27,9 @@ public class IFdpMonitorClientFallBack implements IFdpMonitorClient{
public String getFaultList() {
return null;
}
@Override
public String updateFaultState(UpdateFaultStateVo state) {
return null;
}
}

40
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/UpdateFaultStateVo.java

@ -0,0 +1,40 @@
package com.hnac.hzims.fdp.vo;
import com.hnac.hzims.fdp.entity.FdpFaultEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 更新预警状态对象
* @author Lch
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class UpdateFaultStateVo{
@ApiModelProperty("创建人名称")
private String stationId;
@ApiModelProperty("故障ID")
private String faultId;
@ApiModelProperty("故障的置信度:发生为1,不发生为0")
private Float confidence;
@ApiModelProperty("时间字符串:2021-01-01 00:00:00")
private String createTime;
@ApiModelProperty("创建人ID")
private String createUser;
@ApiModelProperty("故障状态会持续的时间:单位小时")
private Integer lifeTime;
@ApiModelProperty("优先级")
private Integer priority;
@ApiModelProperty("描述")
private String info;
}

9
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java

@ -16,13 +16,18 @@ public interface AbnormalAlarmConstant {
/**故障**/
String FAULT = "3";
/**预警**/
Long EARLY_WARNING = 20L;
String WEBSOCKET_FAULT = "3";
String[] TYPE_NAMES = {"默认", "系统", "告警"
, "故障", "用户操作", "遥测越限", "遥信变位", "注册信息", "信息提示", "设备巡检", "遥控操作", "遥测越限恢复","未定义","通讯中断","数据异常"};
/**处理、延后、误报*/
List<Long> HANDLE_WAY = Arrays.asList(1L,2L,3L,4L);
/**误报 、延后、缺陷 、检修、处理*/
List<Long> HANDLE_WAY = Arrays.asList(1L,2L,3L,4L,5L);
List<Long> HANDLE = Arrays.asList(3L,4L,5L);
/**
* 2-告警,3-故障,5-遥测越限,13-通讯异常,14-数据异常

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlarmHandleEntity.java

@ -16,7 +16,7 @@ import java.util.Date;
public class AlarmHandleEntity extends BaseEntity {
@ApiModelProperty("告警Id")
private Long alarmId;
private String alarmId;
@ApiModelProperty("站点编码")
private String stationCode;

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmHandleVo.java

@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.hnac.hzims.operational.alert.entity.AlarmHandleEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
@ -14,6 +15,7 @@ import java.util.Date;
* @version 4.0.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class AlarmHandleVo extends AlarmHandleEntity {
@ApiModelProperty("站点名称")

8
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/FdpMonitorClient.java

@ -1,8 +1,8 @@
package com.hnac.hzims.fdp.feign;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.fdp.entity.FdpMonitorEntity;
import com.hnac.hzims.fdp.service.IFdpMonitorService;
import com.hnac.hzims.fdp.vo.UpdateFaultStateVo;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -33,4 +33,10 @@ public class FdpMonitorClient implements IFdpMonitorClient{
public String getFaultList() {
return fdpMonitorService.getFaultList();
}
@GetMapping(UPDATE_FAULT_STATE)
@Override
public String updateFaultState(UpdateFaultStateVo state) {
return fdpMonitorService.updateFaultState(state);
}
}

2
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java

@ -160,4 +160,6 @@ public interface IFdpMonitorService extends BaseService<FdpMonitorEntity> {
List<String> getRealIds();
String getFaultList();
String updateFaultState(UpdateFaultStateVo state);
}

36
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java

@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.constants.MonitorConstants;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.service.IEmInfoService;
import com.hnac.hzims.fdp.constants.DeviceInstanceTypeConstant;
@ -29,7 +28,6 @@ import com.hnac.hzims.fdp.request.DiagnoseFaultAllReq;
import com.hnac.hzims.fdp.request.DiagnoseFaultReq;
import com.hnac.hzims.fdp.request.DiagnoseNextstepReq;
import com.hnac.hzims.fdp.request.MonitorBandingReq;
import com.hnac.hzims.fdp.response.AutoDataResp;
import com.hnac.hzims.fdp.response.BaseResp;
import com.hnac.hzims.fdp.response.DiagnoseNextstepResp;
import com.hnac.hzims.fdp.response.MonitorFaultResp;
@ -68,7 +66,6 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@ -78,8 +75,6 @@ import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
/**
@ -124,6 +119,9 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
@Value("${url.getAutoFault}")
public String autoFaultPath;
@Value("${url.updateFaultState}")
public String updateFaultState;
private final static String JOINT_RELAY_SIGNAGE = "joint_relay";//合位继电器
@ -528,7 +526,33 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
return null;
}
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("stationIds", list.toArray(new String[list.size()]));
paramMap.put("stationIds", list.toArray(new String[0]));
String result = HttpRequestUtil.postCall(paramMap, autoFaultPath, "POST");
if(StringUtil.isBlank(result)){
return null;
}
return JSONObject.parseObject(result).get("data").toString();
}
@Override
public String updateFaultState(UpdateFaultStateVo state) {
Map<String, Object> paramMap = new HashMap<>();
// 站点ID
paramMap.put("stationId", state.getStationId());
// 故障ID
paramMap.put("faultId", state.getFaultId());
// 故障的置信度 : 发生为1,不发生为0。
paramMap.put("confidence", state.getConfidence());
// 时间字符串
paramMap.put("createTime", state.getCreateTime());
// 创建人
paramMap.put("createUser", state.getCreateUser());
// 单位小时,默认值为1
paramMap.put("lifeTime", state.getLifeTime());
// 优先级
paramMap.put("priority", state.getPriority());
// 描述
paramMap.put("info", state.getInfo());
String result = HttpRequestUtil.postCall(paramMap, autoFaultPath, "POST");
if(StringUtil.isBlank(result)){
return null;

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

@ -1,6 +1,8 @@
package com.hnac.hzims.operational.alert.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.fdp.feign.IFdpMonitorClient;
import com.hnac.hzims.fdp.vo.UpdateFaultStateVo;
import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant;
import com.hnac.hzims.operational.alert.entity.AlarmHandleDetailEntity;
import com.hnac.hzims.operational.alert.entity.AlarmHandleEntity;
@ -10,23 +12,26 @@ import com.hnac.hzims.operational.alert.service.AlarmHandleService;
import com.hnac.hzims.operational.alert.vo.AlarmHandleVo;
import com.hnac.hzims.operational.alert.vo.HandleQueryVo;
import com.hnac.hzims.operational.alert.wrapper.HandleWrapper;
import com.hnac.hzims.operational.fill.wrapper.StorageWrapper;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jsoup.helper.DataUtil;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -42,9 +47,11 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl<AlarmHandleMapper, A
private final AlarmHandleDetailService detailService;
private final ISysClient sysClient;
private final IUserClient userClient;
private final ISysClient sysClient;
private final IFdpMonitorClient fdpMonitorClient;
/**
* 告警处理
@ -58,6 +65,11 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl<AlarmHandleMapper, A
if (!AbnormalAlarmConstant.HANDLE_WAY.contains(way)) {
throw new ServiceException("无效处理!");
}
// 预警
if(AbnormalAlarmConstant.EARLY_WARNING.equals(param.getAlarmType())){
this.updateFalultState(param);
}
// 详情
AlarmHandleDetailEntity detail = new AlarmHandleDetailEntity();
detail.setAccessId(param.getAccessId());
detail.setPhenomenonId(param.getPhenomenonId());
@ -67,6 +79,7 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl<AlarmHandleMapper, A
detail.setFalseAlarmDesc(param.getFalseAlarmDesc());
detail.setFilePath(param.getFilePath());
detailService.save(detail);
// 处理记录
AlarmHandleEntity entity = new AlarmHandleEntity();
entity.setAlarmId(param.getAlarmId());
entity.setDetailId(detail.getId());
@ -79,6 +92,31 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl<AlarmHandleMapper, A
}
/**
* 预警处理推送智能诊断服务
* @param param
*/
private void updateFalultState(AlarmHandleVo param) {
try{
UpdateFaultStateVo state = new UpdateFaultStateVo();
state.setStationId(param.getStationCode());
state.setFaultId(param.getAlarmId());
if(AbnormalAlarmConstant.HANDLE.contains(param.getHandleWay())){
state.setConfidence(1f);
}else{
state.setConfidence(0f);
}
state.setCreateTime(DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME));
state.setCreateUser(String.valueOf(AuthUtil.getUserId()));
state.setLifeTime(1);
state.setPriority(1);
state.setInfo(param.getFalseAlarmDesc());
String result = fdpMonitorClient.updateFaultState(state);
}catch (Exception exception){
log.error("update_falult_state: {}",exception.getMessage());
}
}
/**
* 分页
* @param query
* @param param

1
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/StAlamRecordController.java

@ -65,6 +65,7 @@ public class StAlamRecordController {
}
return stAlamRecordService.getDaySoeList(AuthUtil.getUser(), date, type,current,size,code);
}
@OperationAnnotation(moduleName = "集中监控",title = "集中监控", operatorType = OperatorType.MOBILE,
businessType = BusinessType.GENCODE,action = "获取故障列表数据")
@ApiOperation("获取故障列表数据")

16
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java

@ -732,10 +732,19 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl<StAlarmRecordMapper
}
List<FaultVo> list = JSONArray.parseArray(result,FaultVo.class);
if(CollectionUtil.isEmpty(list)){
return null;
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);
}
log.error("fault_list_stations: {}",stations);
log.error("fault_list_list: {}",list);
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()));
@ -743,6 +752,7 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl<StAlarmRecordMapper
}).collect(Collectors.toList());
}
/**
* map添加redis原有数据
* @param map

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/FaultVo.java

@ -2,6 +2,9 @@ package com.hnac.hzims.operational.config.vo;
import lombok.Data;
/**
* @author ysj
*/
@Data
public class FaultVo {

1
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java

@ -40,7 +40,6 @@ public class HomeController extends BladeController {
@ApiOperation("首页关键指标")
@GetMapping("/target")
@ApiOperationSupport(order = 2)
public R<TargetVo> target(@ApiParam(value = "指标类型",required = true) Integer type) {
return R.data(service.target(type));
}

Loading…
Cancel
Save