diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultRealDataVO.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultRealDataVO.java new file mode 100644 index 0000000..af45be3 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultRealDataVO.java @@ -0,0 +1,47 @@ +package com.hnac.hzims.fdp.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * 模型VO + * + * @author tangyu + * @created 2023-07-03 17:38 + **/ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class FdpFaultRealDataVO { + + private static final long serialVersionUID = 1L; + + /** + * 监测点ID + */ + @ApiModelProperty("监测点ID") + private String monitorId; + + @ApiModelProperty("监测点名称") + private String name; + @ApiModelProperty("位置") + private String ord; + @ApiModelProperty("单代表对应一个实时数据,多代表对应一组实时数据") + private String multi; + @ApiModelProperty("数据的物模型id") + private String instance; + @ApiModelProperty("数据的物模型属性:如果multi是“多”,则包含该字符串起始的所有属性") + private String identifier; + @ApiModelProperty("物模型是否开机:无法获取当作开机处理") + private Boolean powerOn; + + @ApiModelProperty("获取的实时数据如果MULTI是“单”则为数值,MULTI是“多”则为数组") + private List real; + @ApiModelProperty("实时数据时间,如果MULTI是“单”则为数值,MULTI是“多”则为数组") + private List realTime; +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java index 18fe5f4..c43348a 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java @@ -194,7 +194,8 @@ public class FdpMonitorController extends BladeController { @ApiOperationSupport(order = 160) @ApiOperation(value = "数据追溯") public R dataBack(@RequestBody DataBackVo vo) { - return R.data(service.dataBack(vo.getFaultId())); + service.dataBackV2(vo.getFaultId()); + return service.dataBackV2(vo.getFaultId()); } @PostMapping("/monthly/report/dataBack") diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java index e36e698..d8f16cf 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java @@ -97,7 +97,7 @@ public interface IFdpMonitorService extends BaseService { Map dataBack(String faultId); - + R dataBackV2(String faultId); Map monthlyDataBack(DataBackVo vo); /** diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java index 80df684..c1bb70a 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java @@ -40,10 +40,10 @@ import com.hnac.hzims.fdp.vo.*; import com.hnac.hzims.fdp.wrapper.FdpMonitorWrapper; import com.hnac.hzims.monitor.dto.FdpMonitorBindingDTO; import com.hnac.hzims.monitor.utils.DateUtils; -import com.hnac.hzims.util.HttpClientUtils; -import com.hnac.hzims.util.pojo.HttpResponse; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzims.util.HttpClientUtils; +import com.hnac.hzims.util.pojo.HttpResponse; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.IAnalyseInstanceClient; import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; @@ -54,7 +54,6 @@ import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeInstanceFieldVO; import com.hnac.hzinfo.datasearch.real.IRealDataSearchClient; import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; - import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -66,6 +65,7 @@ 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.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -113,6 +113,9 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl resultMap = new HashMap<>(); + resultMap.put("faultId", faultId); + String post = HttpRequestUtil.postCallObjectParam(resultMap, getRealByFault, "POST"); + FdpHttpResponseVo fdpHttpResponseVo = JSONObject.parseObject(post, new TypeReference() {}); + if (1==fdpHttpResponseVo.getSuccess()) { + if (Func.isNotEmpty(fdpHttpResponseVo.getData())) { + List list = JSONObject.parseObject(fdpHttpResponseVo.getData(), new TypeReference>() {}); + if (CollectionUtil.isEmpty(list)){ + return R.success("暂无数据,请稍后重试"); + } + List res =new ArrayList<>(); + for (FdpFaultRealDataVO fdpFaultRealDataVO : list) { + if (null!=fdpFaultRealDataVO.getReal()){ + for (int i = 0; i < fdpFaultRealDataVO.getReal().size(); i++ ) { + FdpFaultRealDataVO dataVO=new FdpFaultRealDataVO(); + BeanUtils.copyProperties(fdpFaultRealDataVO,dataVO); + String real = fdpFaultRealDataVO.getReal().get(i); + Date time = fdpFaultRealDataVO.getRealTime().get(i); + dataVO.setReal(Arrays.asList(real)); + dataVO.setRealTime(Arrays.asList(time)); + res.add(dataVO); + } + }else { + res.add(fdpFaultRealDataVO); + } + } +// JSONObject jsonParams = JSONObject.parseObject(fdpHttpResponseVo.getData()); +// list=list.stream().map(s -> { +// if ("单".equals(s.getMulti())) { +// if (null == s.getReal()) { +// s.setReal(new ArrayList<>().toString()); +// } else { +// String real = jsonParams.get("real").toString(); +// s.setReal(Arrays.asList(Double.valueOf(real)).toString()); +// } +// } +// return s; +// }).collect(Collectors.toList()); + return R.data(res); + } + return R.success("暂无数据,请稍后重试"); + } + return R.fail("智能诊断接口异常,请联系管理员"); + } + //此接口已经弃用20230628 + @Deprecated @Override public Map dataBack(String faultId) { //根据故障ID查询监测点列表