|
@@ -81,15 +81,28 @@ public class DataSourcesCalcUnit extends CalcUnit {
|
|
|
DataSourcesService sourcesService = SpringUtil.getBean(DataSourcesService.class);
|
|
|
SysInterfaceService sysInterfaceService = SpringUtil.getBean(SysInterfaceService.class);
|
|
|
DataSourcesModel selectModel = sourcesService.selectDetailData(this.dataSourcesModel.getDataSourcesNo());
|
|
|
- List<String> interfaceNos = selectModel.getRequestInterfaces();
|
|
|
+
|
|
|
+ // 记录所有源头节点
|
|
|
+ List<CalcUnit> allUnitList = new ArrayList<>();
|
|
|
+
|
|
|
List<SysInterface> sysInterfaceModelList = new ArrayList<>();
|
|
|
- for ( String s : interfaceNos) {
|
|
|
- sysInterfaceModelList.add(sysInterfaceService.getById(s));
|
|
|
+
|
|
|
+ // 接口源节点
|
|
|
+ if ("INTERFACE".equals(dataSourcesModel.getDataSourcesType())) {
|
|
|
+ List<String> interfaceNos = selectModel.getRequestInterfaces();
|
|
|
+ for ( String s : interfaceNos) {
|
|
|
+ sysInterfaceModelList.add(sysInterfaceService.getById(s));
|
|
|
+ }
|
|
|
+ List<CalcUnit> interFaceList = sysInterfaceModelList.stream().map(interfaceModel -> new InterfaceCalcUnit(interfaceModel.getId(),interfaceModel.getInterfaceName(),CalcType.INTERFACE,Map.of(),interfaceModel)).collect(Collectors.toList());
|
|
|
+ allUnitList.addAll(interFaceList);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询逻辑源节点
|
|
|
+ if ("JDBC".equals(dataSourcesModel.getDataSourcesType())) {
|
|
|
+ List<CalcUnit> queryList = dataSourcesModel.getQueryLogic().stream().map(queryParam -> new QueryLogicCalcUnit(queryParam.getDataItemName(),queryParam.getScriptDescription(),CalcType.QUERYLOGIC,Map.of(),queryParam)).collect(Collectors.toList());
|
|
|
+ allUnitList.addAll(queryList);
|
|
|
}
|
|
|
- List<CalcUnit> interFaceList = sysInterfaceModelList.stream().map(interfaceModel -> new InterfaceCalcUnit(interfaceModel.getId(),interfaceModel.getInterfaceName(),CalcType.INTERFACE,Map.of(),interfaceModel)).collect(Collectors.toList());
|
|
|
- List<CalcUnit> queryList = dataSourcesModel.getQueryLogic().stream().map(queryParam -> new QueryLogicCalcUnit(queryParam.getDataItemName(),queryParam.getScriptDescription(),CalcType.QUERYLOGIC,Map.of(),queryParam)).collect(Collectors.toList());
|
|
|
- interFaceList.addAll(queryList);
|
|
|
- return interFaceList;
|
|
|
+ return allUnitList;
|
|
|
|
|
|
// 取得个配置信息
|
|
|
// List<DataSourcesModel> dataList = sourcesService.getDataList(new DataSourcesModel());
|
|
@@ -150,14 +163,8 @@ public class DataSourcesCalcUnit extends CalcUnit {
|
|
|
} else if ("JDBC".equals(dataSourcesModel.getDataSourcesType())) {
|
|
|
// 数据来源类型为jdbc时处理逻辑
|
|
|
if (calcUnit instanceof QueryLogicCalcUnit queryLogicCalcUnit) {
|
|
|
- // 取得查询逻辑脚本
|
|
|
- String sqlTemplate = queryLogicCalcUnit.queryLogicModel.getSelectSqlScript();
|
|
|
- // 执行模板
|
|
|
- String sql = TemplateUtil.execute(calcUnit.getCalcCode(), sqlTemplate, result);
|
|
|
- // 查询本地数据库
|
|
|
- Map<String, Object> stringObjectMap = DBExecutor.doQueryMap(sql);
|
|
|
// 结果封装,数据项名做key
|
|
|
- thisResult.put(queryLogicCalcUnit.queryLogicModel.getDataItemName(), stringObjectMap);
|
|
|
+ thisResult.put(queryLogicCalcUnit.queryLogicModel.getDataItemName(), result.get(queryLogicCalcUnit.getCalcCode()));
|
|
|
}
|
|
|
}
|
|
|
});
|