Browse Source

修改智能诊断逻辑,去除实时数据的推送

zhongwei
tyty 2 years ago
parent
commit
e69dd1dc6d
  1. 4
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java
  2. 3
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/DiagnoseFaultReq.java
  3. 39
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/scheduled/ThreadTask.java
  4. 3
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java
  5. 58
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java
  6. 8
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java

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

@ -22,7 +22,6 @@ import com.hnac.hzims.monitor.dto.FdpMonitorBindingDTO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeInstanceFieldVO;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.mp.support.Condition;
@ -274,7 +273,8 @@ public class FdpMonitorController extends BladeController {
@ApiOperationSupport(order = 180)
@ApiOperation(value = "获取实时、历史数据返回生成ID-旧版")
public R getRealTimeHisData(@RequestBody FdpTaskDTO taskDTO){
return service.getRealTimeHisData(taskDTO);
// return service.getRealTimeHisData(taskDTO);
return R.fail("此端口弃用,请访问新的接口");
}
@PostMapping("/updateFaultStateAll/getRealTimeHisDataNew")

3
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/DiagnoseFaultReq.java

@ -1,7 +1,6 @@
package com.hnac.hzims.fdp.request;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -24,7 +23,7 @@ public class DiagnoseFaultReq implements Serializable {
@ApiModelProperty(value = "故障可信度 人工诊断点击或者人工发现时,该故障的状态,发生为1,不发生为0。不确认发生或没发生时填入0-1之间的值。", required = true)
@JSONField(name = "confidence")
private Double status;
private Double confidence;
@ApiModelProperty("是否有效")
@JSONField(name = "is_deleted")

39
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/scheduled/ThreadTask.java

@ -13,7 +13,6 @@ import com.hnac.hzims.fdp.response.DiagnoseNextstepResp;
import com.hnac.hzims.fdp.service.IFdpFaultService;
import com.hnac.hzims.fdp.util.HttpRequestUtil;
import com.hnac.hzims.fdp.vo.FdpHttpResponseVo;
import com.hnac.hzims.fdp.vo.FdpRealTimeAndHisDataVo;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
@ -50,13 +49,13 @@ public class ThreadTask {
//诊断
public static void fdpTask(FdpTaskDTO taskDTO, FdpFaultEntity fdpFaultEntity, FdpRealTimeAndHisDataVo vo, String key) {
public static void fdpTask(FdpTaskDTO taskDTO, FdpFaultEntity fdpFaultEntity, String key) {
try {
Runnable runnable = new Runnable() {
@Override
public void run() {
//异步任务
updateFaultState(taskDTO, fdpFaultEntity, vo, key);
updateFaultState(taskDTO, fdpFaultEntity, key);
}
};
Thread thread = new Thread(runnable);
@ -84,6 +83,24 @@ public class ThreadTask {
// }
// }
//诊断
public static void fdpTaskNew(FdpTaskDTO taskDTO, FdpFaultEntity fdpFaultEntity, String key) {
try {
Runnable runnable = new Runnable() {
@Override
public void run() {
//异步任务
updateFaultStateNew(taskDTO, fdpFaultEntity, key);
}
};
Thread thread = new Thread(runnable);
thread.start();
} catch (Exception e) {
log.error(e.getMessage(), e.toString());
}
}
// 声明对象
public static ThreadTask threadTask;
@ -102,20 +119,18 @@ public class ThreadTask {
/**
* 修改诊断状态
*
* @param vo
* @param key
*/
private static void updateFaultState(FdpTaskDTO req, FdpFaultEntity fdpFaultEntity, FdpRealTimeAndHisDataVo vo, String key) {
private static void updateFaultState(FdpTaskDTO req, FdpFaultEntity fdpFaultEntity, String key) {
/**更新故障状态**/
DiagnoseFaultAllReq faultAllReq = new DiagnoseFaultAllReq();
faultAllReq.setAutoData(vo);
// faultAllReq.setAutoData(vo);
faultAllReq.setStationId(fdpFaultEntity.getStationId());
DiagnoseFaultReq diagnoseFaultReq = new DiagnoseFaultReq();
diagnoseFaultReq.setTaskId(req.getId().toString());
diagnoseFaultReq.setFaultId(req.getFaultId());
diagnoseFaultReq.setStatus(1.0);
diagnoseFaultReq.setConfidence(1.0);
diagnoseFaultReq.setLifeTime(1);
diagnoseFaultReq.setPriority(2);
diagnoseFaultReq.setTenantId(fdpFaultEntity.getStationId());
@ -181,20 +196,18 @@ public class ThreadTask {
/**
* 修改诊断状态
*
* @param vo
* @param key
*/
private static void updateFaultStateNew(FdpTaskDTO req, FdpFaultEntity fdpFaultEntity, FdpRealTimeAndHisDataVo vo, String key) {
private static void updateFaultStateNew(FdpTaskDTO req, FdpFaultEntity fdpFaultEntity, String key) {
/**更新故障状态**/
DiagnoseFaultAllReq faultAllReq = new DiagnoseFaultAllReq();
faultAllReq.setAutoData(vo);
// faultAllReq.setAutoData(vo);
faultAllReq.setStationId(fdpFaultEntity.getStationId());
DiagnoseFaultReq diagnoseFaultReq = new DiagnoseFaultReq();
diagnoseFaultReq.setTaskId(req.getId().toString());
diagnoseFaultReq.setFaultId(req.getFaultId());
diagnoseFaultReq.setStatus(1.0);
diagnoseFaultReq.setConfidence(1.0);
diagnoseFaultReq.setLifeTime(1);
diagnoseFaultReq.setPriority(2);
diagnoseFaultReq.setTenantId(fdpFaultEntity.getStationId());

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

@ -1,6 +1,5 @@
package com.hnac.hzims.fdp.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.fdp.dto.FdpMonitorDTO;
import com.hnac.hzims.fdp.dto.FdpMonitorExtendDTO;
@ -148,7 +147,7 @@ public interface IFdpMonitorService extends BaseService<FdpMonitorEntity> {
R updateFaultState(@RequestBody DiagnoseFaultReq diagnoseFaultReq);
R getRealTimeHisData(@RequestBody FdpTaskDTO taskDTO);
// R getRealTimeHisData(@RequestBody FdpTaskDTO taskDTO);
R getRealTimeHisDataNew(@RequestBody FdpTaskDTO taskDTO);

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

@ -418,32 +418,32 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
}
}
@Override
public R getRealTimeHisData(FdpTaskDTO taskDTO) {
/**获取故障对象**/
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("获取对应故障对象失败");
}
/**获取实时、历史数据**/
FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept());
//String key = UUID.randomUUID().toString();
boolean flag = fdpTaskService.save(taskDTO);
if (!flag) {
return R.fail("诊断任务保存失败");
}
String key = taskDTO.getId().toString();
//异步处理
ThreadTask.fdpTask(taskDTO, fdpFaultEntity, pushResp, key);
//获取数据成功-》 告知前端
Map<String, String> map = new HashMap<>();
map.put("id", key);
return R.data(map);
}
// @Override
// public R getRealTimeHisData(FdpTaskDTO taskDTO) {
// /**获取故障对象**/
// 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("获取对应故障对象失败");
// }
// /**获取实时、历史数据**/
// FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept());
//
//
// //String key = UUID.randomUUID().toString();
// boolean flag = fdpTaskService.save(taskDTO);
// if (!flag) {
// return R.fail("诊断任务保存失败");
// }
// String key = taskDTO.getId().toString();
// //异步处理
// ThreadTask.fdpTask(taskDTO, fdpFaultEntity, pushResp, key);
// //获取数据成功-》 告知前端
// Map<String, String> map = new HashMap<>();
// map.put("id", key);
// return R.data(map);
// }
@Override
public R getRealTimeHisDataNew(FdpTaskDTO taskDTO) {
@ -456,14 +456,14 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
}
// /**获取实时、历史数据**/
// FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept());
//String key = UUID.randomUUID().toString();
// String key = UUID.randomUUID().toString();
boolean flag = fdpTaskService.save(taskDTO);
if (!flag) {
return R.fail("诊断任务保存失败");
}
String key = taskDTO.getId().toString();
// //异步处理 20230426 此接口弃用
// ThreadTask.fdpTaskNew(taskDTO, fdpFaultEntity, pushResp, key);
ThreadTask.fdpTaskNew(taskDTO, fdpFaultEntity, key);
//获取数据成功-》 告知前端
Map<String, String> map = new HashMap<>();
map.put("id", key);
@ -582,7 +582,7 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
diagnoseFaultReq.setTaskId(req.getId().toString());
log.info("存入taskId为:{}", req.getId().toString());
diagnoseFaultReq.setFaultId(req.getFaultId());
diagnoseFaultReq.setStatus(1.0);
diagnoseFaultReq.setConfidence(1.0);
diagnoseFaultReq.setLifeTime(1);
diagnoseFaultReq.setPriority(2);
diagnoseFaultReq.setTenantId(fdpFaultEntity.getStationId());

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

@ -17,21 +17,15 @@ import com.hnac.hzims.operational.defect.feign.IOperPhenomenonClient;
import com.hnac.hzims.operational.defect.vo.OperPhenomenonVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
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.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* @author xiashandong
* @created 2021-05-25 17:32
@ -52,7 +46,7 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
diagnoseFaultReq.setTaskId(req.getId().toString());
log.info("存入taskId为:{}",req.getId().toString());
diagnoseFaultReq.setFaultId(req.getFaultId());
diagnoseFaultReq.setStatus(1.0);
diagnoseFaultReq.setConfidence(1.0);
diagnoseFaultReq.setLifeTime(1);
diagnoseFaultReq.setPriority(2);
diagnoseProxy.updateFaultState(diagnoseFaultReq);

Loading…
Cancel
Save