Browse Source

升级智能诊断-数据溯源和历史数据接口

zhongwei
tyty 1 year ago
parent
commit
43b24547ba
  1. 3
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/dto/FdpFaultRealDataDTO.java
  2. 2
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultRealDataVO.java
  3. 24
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/FaultStateResp.java
  4. 55
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpFaultServiceImpl.java

3
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/dto/FdpFaultRealDataDTO.java

@ -39,7 +39,8 @@ public class FdpFaultRealDataDTO {
private String identifier; private String identifier;
@ApiModelProperty("物模型是否开机:无法获取当作开机处理") @ApiModelProperty("物模型是否开机:无法获取当作开机处理")
private Boolean powerOn; private Boolean powerOn;
@ApiModelProperty("数据来源:yc、yx、soe分别为遥测、遥信、事件")
private String style;
@ApiModelProperty("获取的实时数据如果MULTI是“单”则为数值,MULTI是“多”则为数组") @ApiModelProperty("获取的实时数据如果MULTI是“单”则为数值,MULTI是“多”则为数组")
private List<String> real; private List<String> real;
@ApiModelProperty("获取的实时数据如果MULTI是“单”则为数值,MULTI是“多”则为数组") @ApiModelProperty("获取的实时数据如果MULTI是“单”则为数值,MULTI是“多”则为数组")

2
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultRealDataVO.java

@ -30,6 +30,8 @@ public class FdpFaultRealDataVO {
private String name; private String name;
@ApiModelProperty("位置") @ApiModelProperty("位置")
private String ord; private String ord;
@ApiModelProperty("数据来源:yc、yx、soe分别为遥测、遥信、事件")
private String style;
@ApiModelProperty("单代表对应一个实时数据,多代表对应一组实时数据") @ApiModelProperty("单代表对应一个实时数据,多代表对应一组实时数据")
private String multi; private String multi;
@ApiModelProperty("数据的物模型id") @ApiModelProperty("数据的物模型id")

24
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/FaultStateResp.java

@ -16,14 +16,16 @@ import java.time.LocalDateTime;
@Data @Data
public class FaultStateResp { public class FaultStateResp {
@ApiModelProperty("故障ID") // @ApiModelProperty("故障ID")
@JSONField(name = "ID") // @JSONField(name = "ID")
private String id; // private String id;
//
@ApiModelProperty("故障名称") // @ApiModelProperty("故障名称")
// @JSONField(name = "NAME")
// private String name;
@ApiModelProperty("数据时间")
@JSONField(name = "NAME") @JSONField(name = "NAME")
private String name; private String ts;
@ApiModelProperty("状态") @ApiModelProperty("状态")
@JSONField(name = "STATUS") @JSONField(name = "STATUS")
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
@ -62,10 +64,10 @@ public class FaultStateResp {
@JSONField(name = "INFO") @JSONField(name = "INFO")
private String info; private String info;
@ApiModelProperty("优先级") // @ApiModelProperty("优先级")
@JSONField(name = "PRIORITY") // @JSONField(name = "PRIORITY")
@JsonSerialize(nullsUsing = NullSerializer.class) // @JsonSerialize(nullsUsing = NullSerializer.class)
private int priority; // private int priority;
@ApiModelProperty("该状态的创建来源(auto/manual)") @ApiModelProperty("该状态的创建来源(auto/manual)")
@JSONField(name = "SOURCE") @JSONField(name = "SOURCE")

55
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpFaultServiceImpl.java

@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.fdp.dto.FdpFaultDTO; import com.hnac.hzims.fdp.dto.FdpFaultDTO;
import com.hnac.hzims.fdp.entity.FdpFaultEntity; import com.hnac.hzims.fdp.entity.FdpFaultEntity;
@ -14,7 +13,6 @@ import com.hnac.hzims.fdp.service.IFdpFaultService;
import com.hnac.hzims.fdp.util.HttpRequestUtil; import com.hnac.hzims.fdp.util.HttpRequestUtil;
import com.hnac.hzims.fdp.vo.FdpFaultVO; import com.hnac.hzims.fdp.vo.FdpFaultVO;
import com.hnac.hzims.fdp.wrapper.FdpFaultWrapper; import com.hnac.hzims.fdp.wrapper.FdpFaultWrapper;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.feign.IStationClient;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -43,7 +41,7 @@ public class FdpFaultServiceImpl extends BaseServiceImpl<FdpFaultMapper, FdpFaul
private final ISysClient sysClient; private final ISysClient sysClient;
private final IStationClient stationClient; private final IStationClient stationClient;
@Value("${url.searchFaultState}") @Value("${url.searchFaultHistoryState}")
private String url; private String url;
@Value("${url.getGraph}") @Value("${url.getGraph}")
private String getGraphPath; private String getGraphPath;
@ -111,11 +109,11 @@ public class FdpFaultServiceImpl extends BaseServiceImpl<FdpFaultMapper, FdpFaul
throw new ServiceException("获取当前故障站点ID失败"); throw new ServiceException("获取当前故障站点ID失败");
} }
params.put("faultId",faultId); params.put("faultId",faultId);
params.put("stationId",stationId); // params.put("stationId",stationId);
Map<String,Object> history = new HashMap<>(2); // Map<String,Object> history = new HashMap<>(2);
history.put("start",start); params.put("start",start);
history.put("end",end); params.put("end",end);
params.put("history",history); // params.put("history",history);
String result = HttpRequestUtil.postCall(params,url,"POST"); String result = HttpRequestUtil.postCall(params,url,"POST");
// HashMap<String, Object> stringObjectHashMap = JSONObject.parseObject(result, new TypeReference<HashMap<String, Object>>() { // HashMap<String, Object> stringObjectHashMap = JSONObject.parseObject(result, new TypeReference<HashMap<String, Object>>() {
// }); // });
@ -127,27 +125,26 @@ public class FdpFaultServiceImpl extends BaseServiceImpl<FdpFaultMapper, FdpFaul
throw new ServiceException(r.getMsg()); throw new ServiceException(r.getMsg());
} }
List<FaultStateResp> respList = r.getData(); List<FaultStateResp> respList = r.getData();
/**根据开始时间排序**/ // /**根据开始时间排序**/
respList = respList.stream().sorted(Comparator.comparing(FaultStateResp::getCreateTime)).collect(Collectors.toList()); // respList = respList.stream().sorted(Comparator.comparing(FaultStateResp::getCreateTime)).collect(Collectors.toList());
List<FaultStateResp> addList = new ArrayList<>(); // List<FaultStateResp> addList = new ArrayList<>();
for(int i=0;i<respList.size()-1;i++){ // for(int i=0;i<respList.size()-1;i++){
/**如果下一条数据的开始时间大于当前数据的结束时间 则造一条数据添加**/ // /**如果下一条数据的开始时间大于当前数据的结束时间 则造一条数据添加**/
try{ // try{
if( Func.isNotEmpty(respList.get(i).getDeleteTime()) && respList.get(i).getDeleteTime().isBefore(respList.get(i+1).getCreateTime())){ // if( Func.isNotEmpty(respList.get(i).getDeleteTime()) && respList.get(i).getDeleteTime().isBefore(respList.get(i+1).getCreateTime())){
FaultStateResp stateResp = BeanUtil.copy(respList.get(i),FaultStateResp.class); // FaultStateResp stateResp = BeanUtil.copy(respList.get(i),FaultStateResp.class);
stateResp.setCreateTime(respList.get(i).getDeleteTime()); // stateResp.setCreateTime(respList.get(i).getDeleteTime());
stateResp.setDeleteTime(respList.get(i+1).getCreateTime()); // stateResp.setDeleteTime(respList.get(i+1).getCreateTime());
stateResp.setStatus(null); // stateResp.setStatus(null);
addList.add(stateResp); // addList.add(stateResp);
} // }
} // }
catch(NullPointerException e){ // catch(NullPointerException e){
log.info("第{}条数据转换失败",i+1); // log.info("第{}条数据转换失败",i+1);
throw new ServiceException(e.getMessage()); // throw new ServiceException(e.getMessage());
} // }
} // }
if(CollectionUtil.isNotEmpty(addList)){ if(CollectionUtil.isNotEmpty(respList)){
respList.addAll(addList);
respList = respList.stream().sorted(Comparator.comparing(FaultStateResp::getCreateTime)).collect(Collectors.toList()); respList = respList.stream().sorted(Comparator.comparing(FaultStateResp::getCreateTime)).collect(Collectors.toList());
} }
return respList; return respList;

Loading…
Cancel
Save