Browse Source

智能诊断流程修正

zhongwei
ty 9 months ago
parent
commit
9a4434b86b
  1. 2
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmHandleConstant.java
  2. 6
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java
  3. 2
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpDiagnoseClient.java
  4. 18
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpHistoryDataController.java
  5. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java
  6. 3
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/FdpDiagnoseClient.java
  7. 13
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpFocusSurveillanceServiceImpl.java
  8. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpHistoryDataServiceImpl.java
  9. 4
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpListTableDataServiceImpl.java
  10. 46
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java
  11. 16
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java
  12. 22
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java
  13. 34
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java
  14. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java

2
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmHandleConstant.java

@ -26,7 +26,7 @@ public interface AlarmHandleConstant {
String FAULT = "3";
/**预警**/
Long EARLY_WARNING = 20L;
Long EARLY_WARNING = 30L;
String WEBSOCKET_FAULT = "3";

6
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java

@ -49,6 +49,12 @@ public class AlarmEntity extends TenantEntity {
@ApiModelProperty(value = "告警内容")
private String alarmContext;
@ApiModelProperty(value = "初步分析原因")
private String diagReason;
@ApiModelProperty(value = "建议处置方式")
private String diagSolution;
@ApiModelProperty(value = "告警状态")
private Integer alarmStatus;

2
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpDiagnoseClient.java

@ -34,5 +34,5 @@ public interface IFdpDiagnoseClient {
@PostMapping(GET_HISTORY_DATA)
List<FdpFaultHistoryDataEntity> getHistoryData(@RequestBody FDPFaultTableDTO req);
@PostMapping(SET_FAULT_STATUS_INFO)
R setFaultStatusInfo(Map<String, Object> map);
R setFaultStatusInfo(@RequestBody Map<String, Object> map);
}

18
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpHistoryDataController.java

@ -10,6 +10,7 @@ import com.hnac.hzims.fdp.dto.FDPFaultTableDTO;
import com.hnac.hzims.fdp.dto.FdpTaskDTO;
import com.hnac.hzims.fdp.entity.FdpFaultHistoryDataEntity;
import com.hnac.hzims.fdp.entity.FdpTaskEntity;
import com.hnac.hzims.fdp.service.IFdpFocusSurveillanceService;
import com.hnac.hzims.fdp.service.IFdpHistoryDataService;
import com.hnac.hzims.fdp.service.IFdpTaskService;
import com.hnac.hzims.fdp.vo.FdpTaskVO;
@ -32,6 +33,8 @@ import org.springblade.core.tool.utils.StringUtil;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.Map;
/**
* 故障诊断任务表
@ -46,6 +49,8 @@ import javax.validation.Valid;
public class FdpHistoryDataController extends BladeController {
private final IFdpHistoryDataService service;
private final IFdpFocusSurveillanceService fdpFocusSurveillanceService;
/**
* 分页
*/
@ -61,5 +66,18 @@ public class FdpHistoryDataController extends BladeController {
}
/**
* 分页
*/
@ApiLog
@PostMapping("/updateFaultHistory")
@ApiOperationSupport(order = 50)
@ApiOperation(value = "分页 查询参数:name,emId,faultId,reasonId,satisfaction")
@OperationAnnotation(moduleName = "智能诊断",title = "智能诊断任务",operatorType = OperatorType.MOBILE,businessType =
BusinessType.GENCODE,
action = "分页查询智能诊断任务列表")
public R<IPage<FdpFaultHistoryDataEntity>> updateFaultHistory(@RequestBody Map<String, Object> map) {
return fdpFocusSurveillanceService.setFaultStatusInfo(map);
}
}

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

@ -194,7 +194,7 @@ public class FdpMonitorController extends BladeController {
@ApiOperationSupport(order = 160)
@ApiOperation(value = "数据追溯")
public R dataBack(@RequestBody DataBackVo vo) {
service.dataBackV2(vo.getFaultId());
// service.dataBackV2(vo.getFaultId());
return service.dataBackV2(vo.getFaultId());
}

3
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/FdpDiagnoseClient.java

@ -11,6 +11,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@ -42,7 +43,7 @@ public class FdpDiagnoseClient implements IFdpDiagnoseClient {
@Override
@PostMapping(SET_FAULT_STATUS_INFO)
public R setFaultStatusInfo(Map<String, Object> map) {
public R setFaultStatusInfo(@RequestBody Map<String, Object> map) {
return iFdpFocusSurveillanceService.setFaultStatusInfo(map);
}
}

13
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpFocusSurveillanceServiceImpl.java

@ -33,18 +33,6 @@ import java.util.*;
@Service
@RequiredArgsConstructor
public class FdpFocusSurveillanceServiceImpl implements IFdpFocusSurveillanceService {
private final FdpDeviceMapper fdpDeviceMapper;
private final IEmInfoService emInfoService;
private final IAnalyseInstanceClient deviceInstanceClient;
private final IAnalyseInstanceClient analyseInstanceClient;
private final IRealDataSearchClient realDataSearchClient;
private final IAnalyseDataSearchClient deviceDataSearchClient;
private final IFdpTaskService fdpTaskService;
private final IDiagnoseProxy diagnoseProxy;
private final FdpMonitorNoScopeMapper fdpMonitorNoScopeMapper;
private final IStationClient stationClient;
private final IFdpFaultService fdpFaultService;
private final RedisTemplate redisTemplate;
@Value("${url.setFaultStatusInfo}")
public String setFaultStatusInfo;
@ -56,6 +44,7 @@ public class FdpFocusSurveillanceServiceImpl implements IFdpFocusSurveillanceSer
*/
@Override
public R setFaultStatusInfo( Map<String, Object> map) {
// map.put("diag_reason","");
String post = HttpRequestUtil.postCallObjectParam(map, setFaultStatusInfo, "POST");
R r = JSONObject.parseObject(post, new TypeReference<R>() {{}});
return r;

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

@ -50,7 +50,7 @@ public class FdpHistoryDataServiceImpl implements IFdpHistoryDataService {
@Override
public R<IPage<FdpFaultHistoryDataEntity>> getHistoryData(FDPFaultTableDTO req) {
IPage<FdpFaultHistoryDataEntity> page = new Page<>();
page.setSize(req.getPageSize());
page.setSize(req.getPageSize()-1);
page.setCurrent(req.getPageIndex());
req.setOrderBy("CREATE_TIME");
if (StringUtil.isBlank(req.getSource())){

4
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpListTableDataServiceImpl.java

@ -73,9 +73,9 @@ public class FdpListTableDataServiceImpl implements IFdpListTableDataService {
public R getListByProperty(FDPFaultListInfoDTO req) {
IPage<FdpFaultTableListEntity> page = new Page<>();
page.setSize(req.getPageSize());
page.setCurrent(req.getPageIndex());
page.setCurrent(req.getPageIndex()-1);
req.setDisplay(1);
req.setIsRoot(1);
req.setIsRoot(0);
req.setOrderBy("NAME");
req.setOrderKind("desc");
String result = HttpRequestUtil.postCallObjectParam(req, getNeoFaultTableData, "POST");

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

@ -392,12 +392,12 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
return R.fail("未传入faultId参数");
}
/**获取故障对象**/
LambdaQueryWrapper<FdpFaultEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(FdpFaultEntity::getFdpId, taskDTO.getFaultId()).last("limit 1");
FdpFaultEntity fdpFaultEntity = fdpFaultService.getOne(wrapper);
if (ObjectUtil.isEmpty(fdpFaultEntity)) {
throw new ServiceException("获取对应故障对象失败");
}
// LambdaQueryWrapper<FdpFaultEntity> wrapper = new LambdaQueryWrapper<>();
// wrapper.eq(FdpFaultEntity::getFdpId, taskDTO.getFaultId()).last("limit 1");
// FdpFaultEntity fdpFaultEntity = fdpFaultService.getOne(wrapper);
// if (ObjectUtil.isEmpty(fdpFaultEntity)) {
// throw new ServiceException("获取对应故障对象失败");
// }
//拿到最近一次未完成的任务
FdpTaskEntity fdpTaskEntity = fdpTaskService.getOne(new LambdaQueryWrapper<FdpTaskEntity>() {{
eq(FdpTaskEntity::getFaultId, taskDTO.getFaultId());
@ -440,7 +440,7 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
r2.setSuccess(true);
r2.setMsg("获取信息成功");
DiagnoseStatusVo diagnoseStatusVo = new DiagnoseStatusVo();
R nextstep = fdpFaultService.getNextStepWithTree(fdpFaultEntity.getFdpId(), fdpFaultEntity.getStationId());
R nextstep = fdpFaultService.getNextStepWithTree(taskDTO.getFaultId(), taskDTO.getStation());
diagnoseStatusVo.setStatus(4);
diagnoseStatusVo.setMessage("诊断成功");
diagnoseStatusVo.setData(nextstep.getData());
@ -589,18 +589,21 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
@Override
public R updateFaultState(DiagnoseFaultReq diagnoseFaultReq) {
diagnoseFaultReq.setPriority(2);
/**获取故障对象**/
LambdaQueryWrapper<FdpFaultEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(FdpFaultEntity::getFdpId, diagnoseFaultReq.getFaultId()).last("limit 1");
FdpFaultEntity fdpFaultEntity = fdpFaultService.getOne(wrapper);
if (ObjectUtil.isEmpty(fdpFaultEntity)) {
throw new ServiceException("获取对应故障对象失败");
}
Boolean hasKey = redisTemplate.hasKey(KEY_FOR_FDP_TASK_ID + "_" + diagnoseFaultReq.getTaskId().toString());
//Redis中不存在,该任务过期
if (!hasKey) {
return R.fail("该任务已过期,请重新生成任务");
// /**获取故障对象**/
// LambdaQueryWrapper<FdpFaultEntity> wrapper = new LambdaQueryWrapper<>();
// wrapper.eq(FdpFaultEntity::getFdpId, diagnoseFaultReq.getFaultId()).last("limit 1");
// FdpFaultEntity fdpFaultEntity = fdpFaultService.getOne(wrapper);
// if (ObjectUtil.isEmpty(fdpFaultEntity)) {
// throw new ServiceException("获取对应故障对象失败");
// }
if(StringUtil.isNotBlank(diagnoseFaultReq.getTaskId())){
Boolean hasKey = redisTemplate.hasKey(KEY_FOR_FDP_TASK_ID + "_" + diagnoseFaultReq.getTaskId().toString());
//Redis中不存在,该任务过期
if (!hasKey) {
return R.fail("该任务已过期,请重新生成任务");
}
}
/**更新故障状态**/
DiagnoseFaultAllReq faultAllReq = new DiagnoseFaultAllReq();
/**推送数据**/
@ -608,14 +611,15 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
// FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept());
// faultAllReq.setAutoData(pushResp);
faultAllReq.setStationId(fdpFaultEntity.getStationId());
diagnoseFaultReq.setTenantId(fdpFaultEntity.getStationId());
faultAllReq.setStationId(diagnoseFaultReq.getTenantId());
diagnoseFaultReq.setLifeTime(24*3);//一旦用户进行修改,智能诊断时效性刷新为3天
faultAllReq.setManualData(diagnoseFaultReq);
String jsonString = JSONObject.toJSONString(faultAllReq);
System.out.println(jsonString);
HttpResponse r = HttpClientUtils.post(updateFaultStateAll, JSONObject.toJSONString(faultAllReq));
redisTemplate.expire(KEY_FOR_FDP_TASK_ID + "_" + diagnoseFaultReq.getTaskId(), 3, TimeUnit.DAYS);
if(StringUtil.isNotBlank(diagnoseFaultReq.getTaskId())) {
redisTemplate.expire(KEY_FOR_FDP_TASK_ID + "_" + diagnoseFaultReq.getTaskId(), 3, TimeUnit.DAYS);
}
return JSONObject.parseObject(r.getData(), BaseResp.class).convert2R();
}

16
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java

@ -254,14 +254,18 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
}
HttpResponse r = HttpClientUtils.post(submitResult, JSONObject.toJSONString(fdpSubmitResultDTO));
if (200 != r.getCode()) {
throw new ServiceException("智能诊断回传失败");
log.error("调用fdp接口submitResult失败,参数为:"+JSONObject.toJSONString(fdpSubmitResultDTO));
throw new ServiceException("保存失败,请稍后重试!!!");
}
boolean b = this.updateById(req);
if (b) {
return R.success("保存成功");
} else {
return R.fail("保存失败,请稍后重试");
if (ObjectUtil.isNotEmpty(req.getId())) {
boolean b = this.updateById(req);
if (b) {
return R.success("保存成功");
} else {
return R.fail("保存失败,请稍后重试");
}
}
return R.success("保存成功");
}
private static Wrapper<FdpTaskEntity> getFdpTaskEntityWrapper(TaskStatisticsVo statisticsVo) {

22
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java

@ -63,6 +63,7 @@ public class AlarmHandleFlowServiceImpl extends BaseServiceImpl<AlarmHandleFlowM
return R.fail("消息转换失败");
}
taskId = alarmHandleFlowEntity.getId();
//设置当前环节+当前环节处理人
if (StringUtils.isNotEmpty(processWorkFlowResponse.getNextStepOperator())) {
alarmHandleFlowEntity.setCurrentOperator(processWorkFlowResponse.getTaskName());
@ -70,6 +71,8 @@ public class AlarmHandleFlowServiceImpl extends BaseServiceImpl<AlarmHandleFlowM
} else {
alarmHandleFlowEntity.setCurrentOperator("流程结束");
alarmHandleFlowEntity.setCurrentLinkHandler("");
Map<String, Object> map = new HashMap<>();
map.put("uuid", alarmHandleFlowEntity.getAlarmId());
if (1l == alarmHandleFlowEntity.getHandleWay()) {
//如果是误诊,把处理结果复制到误报原因
alarmHandleFlowEntity.setFalseAlarmDesc(alarmHandleFlowEntity.getDealDesc());
@ -77,6 +80,18 @@ public class AlarmHandleFlowServiceImpl extends BaseServiceImpl<AlarmHandleFlowM
.set(AlarmHandleEntity::getHandleWay, alarmHandleFlowEntity.getHandleWay())
.set(AlarmHandleEntity::getFalseAlarmDesc, alarmHandleFlowEntity.getDealDesc())
.eq(AlarmHandleEntity::getAlarmId, alarmHandleFlowEntity.getAlarmId()));
map.put("result", "误报");
map.put("result_info","");
map.put("diag_solution", alarmHandleFlowEntity.getDealDesc());
} else if (2l == alarmHandleFlowEntity.getHandleWay()) {
alarmHandleMapper.update(null, Wrappers.<AlarmHandleEntity>lambdaUpdate()
.set(AlarmHandleEntity::getHandleWay, alarmHandleFlowEntity.getHandleWay())
.set(AlarmHandleEntity::getDelayCause, alarmHandleFlowEntity.getDelayCause())
.set(AlarmHandleEntity::getDelayTime, alarmHandleFlowEntity.getDelayTime())
.eq(AlarmHandleEntity::getAlarmId, alarmHandleFlowEntity.getAlarmId()));
map.put("result", "延后处理");
map.put("result_info", alarmHandleFlowEntity.getDealDesc());
map.put("diag_solution","");
} else {
//流程结束把告警状态修改为结束
alarmHandleFlowEntity.setHandleWay(6L);
@ -85,13 +100,12 @@ public class AlarmHandleFlowServiceImpl extends BaseServiceImpl<AlarmHandleFlowM
.set(AlarmHandleEntity::getHandleWay, 6l)
.set(AlarmHandleEntity::getFalseAlarmDesc, alarmHandleFlowEntity.getDealDesc())
.eq(AlarmHandleEntity::getAlarmId, alarmHandleFlowEntity.getAlarmId()));
map.put("result", "处理完成");
map.put("result_info","");
map.put("diag_solution", alarmHandleFlowEntity.getDealDesc());
}
// 预警,调用fdp
if (AlarmHandleConstant.EARLY_WARNING.equals(alarmHandleFlowEntity.getAlarmType())) {
Map<String, Object> map = new HashMap<>();
map.put("uuid", alarmHandleFlowEntity.getAlarmId());
map.put("result", alarmHandleFlowEntity.getHandleWay());
map.put("result_info", alarmHandleFlowEntity.getDealDesc());
//流程结束后才,调用fdp修改状态的接口
R r = iFdpDiagnoseClient.setFaultStatusInfo(map);
if (!r.isSuccess()) {

34
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java

@ -74,21 +74,6 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl<AlarmHandleMapper, A
if (!AlarmHandleConstant.HANDLE_WAY.contains(way)) {
throw new ServiceException("无效处理!");
}
// 预警
if(AlarmHandleConstant.EARLY_WARNING.equals(param.getAlarmType())){
Map<String, Object> map=new HashMap<>();
map.put("uuid",param.getAlarmId());
map.put("result",param.getHandleWay());
if (1l==way){
map.put("result_info",param.getFalseAlarmDesc());
} else if (2l==way){
map.put("result_info",param.getDelayCause());
}
R r = iFdpDiagnoseClient.setFaultStatusInfo(map);
if (!r.isSuccess()){
throw new ServiceException("修改告警状态异常,请稍后重试!");
}
}
// 处理记录
AlarmHandleEntity entity = new AlarmHandleEntity();
entity.setAlarmId(param.getAlarmId());
@ -112,6 +97,25 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl<AlarmHandleMapper, A
entity.setCreateDeptName(param.getCreateDeptName());
}
this.save(entity);
// 预警
if(AlarmHandleConstant.EARLY_WARNING.equals(param.getAlarmType())){
Map<String, Object> map=new HashMap<>();
map.put("uuid",param.getAlarmId());
if (1l==way){
map.put("result","误报");
map.put("diag_solution",param.getFalseAlarmDesc());
} else if (2l==way){
map.put("result","延后处理");
map.put("result_info",param.getDelayCause());
}else {
map.put("result","处理中");
}
R r = iFdpDiagnoseClient.setFaultStatusInfo(map);
if (!r.isSuccess()){
log.error("setFaultStatusInfo接口修改处理状态异常,参数为:"+param);
throw new ServiceException("修改告警状态异常,请稍后重试!");
}
}
//开启流程
if (AlarmHandleConstant.HANDLE.contains(way)) {
alarmHandleFlowMapper.insert(param);

2
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java

@ -93,6 +93,8 @@ public class FdpAlarmServiceImpl implements FdpAlarmService {
entity.setAlarmStatus(Integer.valueOf(item.getStatus()));
entity.setAlarmValue(item.getInfo());
entity.setStationId(item.getStation());
entity.setDiagReason(item.getDiagReason());
entity.setDiagSolution(item.getDiagSolution());
entity.setAlarmSource(EARLY_WARNING);
entity.setTenantId("200000");
R<StationEntity> stationByCode = stationClient.getStationByCode(item.getStation());

Loading…
Cancel
Save