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;
@ApiModelProperty("物模型是否开机:无法获取当作开机处理")
private Boolean powerOn;
@ApiModelProperty("数据来源:yc、yx、soe分别为遥测、遥信、事件")
private String style;
@ApiModelProperty("获取的实时数据如果MULTI是“单”则为数值,MULTI是“多”则为数组")
private List<String> real;
@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;
@ApiModelProperty("位置")
private String ord;
@ApiModelProperty("数据来源:yc、yx、soe分别为遥测、遥信、事件")
private String style;
@ApiModelProperty("单代表对应一个实时数据,多代表对应一组实时数据")
private String multi;
@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
public class FaultStateResp {
@ApiModelProperty("故障ID")
@JSONField(name = "ID")
private String id;
@ApiModelProperty("故障名称")
// @ApiModelProperty("故障ID")
// @JSONField(name = "ID")
// private String id;
//
// @ApiModelProperty("故障名称")
// @JSONField(name = "NAME")
// private String name;
@ApiModelProperty("数据时间")
@JSONField(name = "NAME")
private String name;
private String ts;
@ApiModelProperty("状态")
@JSONField(name = "STATUS")
@JsonSerialize(nullsUsing = NullSerializer.class)
@ -62,10 +64,10 @@ public class FaultStateResp {
@JSONField(name = "INFO")
private String info;
@ApiModelProperty("优先级")
@JSONField(name = "PRIORITY")
@JsonSerialize(nullsUsing = NullSerializer.class)
private int priority;
// @ApiModelProperty("优先级")
// @JSONField(name = "PRIORITY")
// @JsonSerialize(nullsUsing = NullSerializer.class)
// private int priority;
@ApiModelProperty("该状态的创建来源(auto/manual)")
@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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.fdp.dto.FdpFaultDTO;
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.vo.FdpFaultVO;
import com.hnac.hzims.fdp.wrapper.FdpFaultWrapper;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -43,7 +41,7 @@ public class FdpFaultServiceImpl extends BaseServiceImpl<FdpFaultMapper, FdpFaul
private final ISysClient sysClient;
private final IStationClient stationClient;
@Value("${url.searchFaultState}")
@Value("${url.searchFaultHistoryState}")
private String url;
@Value("${url.getGraph}")
private String getGraphPath;
@ -111,11 +109,11 @@ public class FdpFaultServiceImpl extends BaseServiceImpl<FdpFaultMapper, FdpFaul
throw new ServiceException("获取当前故障站点ID失败");
}
params.put("faultId",faultId);
params.put("stationId",stationId);
Map<String,Object> history = new HashMap<>(2);
history.put("start",start);
history.put("end",end);
params.put("history",history);
// params.put("stationId",stationId);
// Map<String,Object> history = new HashMap<>(2);
params.put("start",start);
params.put("end",end);
// params.put("history",history);
String result = HttpRequestUtil.postCall(params,url,"POST");
// 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());
}
List<FaultStateResp> respList = r.getData();
/**根据开始时间排序**/
respList = respList.stream().sorted(Comparator.comparing(FaultStateResp::getCreateTime)).collect(Collectors.toList());
List<FaultStateResp> addList = new ArrayList<>();
for(int i=0;i<respList.size()-1;i++){
/**如果下一条数据的开始时间大于当前数据的结束时间 则造一条数据添加**/
try{
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);
stateResp.setCreateTime(respList.get(i).getDeleteTime());
stateResp.setDeleteTime(respList.get(i+1).getCreateTime());
stateResp.setStatus(null);
addList.add(stateResp);
}
}
catch(NullPointerException e){
log.info("第{}条数据转换失败",i+1);
throw new ServiceException(e.getMessage());
}
}
if(CollectionUtil.isNotEmpty(addList)){
respList.addAll(addList);
// /**根据开始时间排序**/
// respList = respList.stream().sorted(Comparator.comparing(FaultStateResp::getCreateTime)).collect(Collectors.toList());
// List<FaultStateResp> addList = new ArrayList<>();
// for(int i=0;i<respList.size()-1;i++){
// /**如果下一条数据的开始时间大于当前数据的结束时间 则造一条数据添加**/
// try{
// 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);
// stateResp.setCreateTime(respList.get(i).getDeleteTime());
// stateResp.setDeleteTime(respList.get(i+1).getCreateTime());
// stateResp.setStatus(null);
// addList.add(stateResp);
// }
// }
// catch(NullPointerException e){
// log.info("第{}条数据转换失败",i+1);
// throw new ServiceException(e.getMessage());
// }
// }
if(CollectionUtil.isNotEmpty(respList)){
respList = respList.stream().sorted(Comparator.comparing(FaultStateResp::getCreateTime)).collect(Collectors.toList());
}
return respList;

Loading…
Cancel
Save