Browse Source

优化智能诊断列表页查询速度

zhongwei
ty 8 months ago
parent
commit
2ff1e14ce5
  1. 120
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpListTableDataServiceImpl.java

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

@ -38,61 +38,69 @@ import java.util.Map;
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j @Slf4j
public class FdpListTableDataServiceImpl implements IFdpListTableDataService { public class FdpListTableDataServiceImpl implements IFdpListTableDataService {
@Resource @Resource
private IStationClient stationClient; private IStationClient stationClient;
@Value("${url.getNeoFaultPropertyList}") @Value("${url.getNeoFaultPropertyList}")
private String getNeoFaultPropertyList; private String getNeoFaultPropertyList;
@Value("${url.getNeoFaultTableData}") @Value("${url.getNeoFaultTableData}")
private String getNeoFaultTableData; private String getNeoFaultTableData;
@Override
public R getProperty(String property) {
Map<String,Object> params = new HashMap<>();
params.put("property",property);
String result = HttpRequestUtil.postCall(params,getNeoFaultPropertyList,"POST");
if ("STATION".equals(property)){
List<StationEntity> list=new ArrayList<>();
R<List<String>> res = JSONObject.parseObject(result, new TypeReference<R<List<String>>>() {
});
if (res.isSuccess()&& CollectionUtil.isNotEmpty(res.getData())){
for (String s : res.getData()) {
R<StationEntity> stationEntityR = stationClient.getStationByCode(s);
if (stationEntityR.isSuccess()&&ObjectUtil.isNotEmpty(stationEntityR.getData())){
StationEntity station = stationEntityR.getData();
list.add(station);
}
}
}
return R.data(list);
}
R<List<String>> res = JSONObject.parseObject(result, new TypeReference<R<List<String>>>() {
});
return res;
}
@Override @Override
public R getListByProperty(FDPFaultListInfoDTO req) { public R getProperty(String property) {
IPage<FdpFaultTableListEntity> page = new Page<>(); Map<String, Object> params = new HashMap<>();
req.setPageIndex(req.getPageIndex()-1); params.put("property", property);
page.setSize(req.getPageSize()); Long startMillis=System.currentTimeMillis();
page.setCurrent(req.getPageIndex()+1); String result = HttpRequestUtil.postCall(params, getNeoFaultPropertyList, "POST");
req.setDisplay(1); log.info("fdp查询列表项"+property+"耗时:"+(System.currentTimeMillis()-startMillis)+"ms");
req.setIsRoot(0); Long endMillis=System.currentTimeMillis();
req.setOrderBy("NAME"); if ("STATION".equals(property)) {
req.setOrderKind("desc"); List<StationEntity> list = new ArrayList<>();
String result = HttpRequestUtil.postCallObjectParam(req, getNeoFaultTableData, "POST"); R<List<String>> res = JSONObject.parseObject(result, new TypeReference<R<List<String>>>() {
if (StringUtil.isNotBlank(result)) { });
R<FdpFaultTableDataVo> fdpFaultHistoryDataVoR = JSONObject.parseObject(result, new TypeReference<R<FdpFaultTableDataVo>>() { if (res.isSuccess() && CollectionUtil.isNotEmpty(res.getData())) {
}); R<List<StationEntity>> listAll = stationClient.getListAll();
if (!fdpFaultHistoryDataVoR.isSuccess()){ if (listAll.isSuccess() && ObjectUtil.isNotEmpty(listAll.getData())) {
throw new WebServiceException("请求失败,请紧急联系管理员!!!"); for (String s : res.getData()) {
} for (StationEntity station : listAll.getData()) {
if (fdpFaultHistoryDataVoR.isSuccess()&&ObjectUtil.isNotEmpty(fdpFaultHistoryDataVoR.getData()) if (station.getCode().equals(s)) {
&&ObjectUtil.isNotEmpty(fdpFaultHistoryDataVoR.getData().getList())){ list.add(station);
List<FdpFaultTableListEntity> list = fdpFaultHistoryDataVoR.getData().getList(); }
page.setTotal(fdpFaultHistoryDataVoR.getData().getTotalCount()); }
page.setRecords(list); }
} }
} }
return R.data(page); log.info("fdp查询站点列表项:耗时:"+(System.currentTimeMillis()-endMillis)+"ms");
} return R.data(list);
}
R<List<String>> res = JSONObject.parseObject(result, new TypeReference<R<List<String>>>() {
});
return res;
}
@Override
public R getListByProperty(FDPFaultListInfoDTO req) {
IPage<FdpFaultTableListEntity> page = new Page<>();
req.setPageIndex(req.getPageIndex() - 1);
page.setSize(req.getPageSize());
page.setCurrent(req.getPageIndex() + 1);
req.setDisplay(1);
req.setIsRoot(0);
req.setOrderBy("NAME");
req.setOrderKind("desc");
String result = HttpRequestUtil.postCallObjectParam(req, getNeoFaultTableData, "POST");
if (StringUtil.isNotBlank(result)) {
R<FdpFaultTableDataVo> fdpFaultHistoryDataVoR = JSONObject.parseObject(result, new TypeReference<R<FdpFaultTableDataVo>>() {
});
if (!fdpFaultHistoryDataVoR.isSuccess()) {
throw new WebServiceException("请求失败,请紧急联系管理员!!!");
}
if (fdpFaultHistoryDataVoR.isSuccess() && ObjectUtil.isNotEmpty(fdpFaultHistoryDataVoR.getData())
&& ObjectUtil.isNotEmpty(fdpFaultHistoryDataVoR.getData().getList())) {
List<FdpFaultTableListEntity> list = fdpFaultHistoryDataVoR.getData().getList();
page.setTotal(fdpFaultHistoryDataVoR.getData().getTotalCount());
page.setRecords(list);
}
}
return R.data(page);
}
} }

Loading…
Cancel
Save