|
@@ -1,13 +1,16 @@
|
|
|
package com.sundata.internalevaluation.calc.calcUnit;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.sundata.common.util.DBExecutor;
|
|
|
import com.sundata.internalevaluation.calc.model.CalcException;
|
|
|
import com.sundata.internalevaluation.calc.model.CalcResult;
|
|
|
import com.sundata.internalevaluation.calc.model.CalcUnit;
|
|
|
import com.sundata.internalevaluation.calc.model.finals.CalcType;
|
|
|
+import com.sundata.internalevaluation.configuration.model.DataSetConfigModel;
|
|
|
import com.sundata.internalevaluation.configuration.model.IndexConfigModel;
|
|
|
import com.sundata.internalevaluation.configuration.model.IndexSourceModel;
|
|
|
+import com.sundata.internalevaluation.configuration.service.DataSetConfigService;
|
|
|
import com.sundata.internalevaluation.configuration.service.IndexConfigService;
|
|
|
import com.sundata.internalevaluation.script.ScriptUtil;
|
|
|
import org.slf4j.Logger;
|
|
@@ -17,11 +20,10 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
public class IndexCalcUnit extends CalcUnit {
|
|
|
|
|
|
- private IndexConfigService indexConfigService;
|
|
|
-
|
|
|
private IndexConfigModel indexConfigModel;
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(IndexCalcUnit.class);
|
|
@@ -32,10 +34,9 @@ public class IndexCalcUnit extends CalcUnit {
|
|
|
* @param calcName 计算对象名称
|
|
|
* @param initContext 计算单元初始化参数
|
|
|
*/
|
|
|
- public IndexCalcUnit(String calcCode, String calcName, Map<String, Object> initContext, IndexConfigModel indexConfigModel,IndexConfigService indexConfigService) {
|
|
|
+ public IndexCalcUnit(String calcCode, String calcName, Map<String, Object> initContext, IndexConfigModel indexConfigModel) {
|
|
|
super(calcCode, calcName, CalcType.INDEX, initContext);
|
|
|
this.indexConfigModel = indexConfigModel;
|
|
|
- this.indexConfigService = indexConfigService;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -77,9 +78,40 @@ public class IndexCalcUnit extends CalcUnit {
|
|
|
@Override
|
|
|
public List<CalcUnit> getSourceCalcUnits() {
|
|
|
// TODO 获取源头节点
|
|
|
- List<IndexSourceModel> indexList = indexConfigService.getIndexSourceList(new IndexConfigModel());
|
|
|
- indexList.stream().map(sourceModel -> new IndexSourceCalcUnit
|
|
|
- (sourceModel.getOtherIndexNo(),"",CalcType.INDEX,Map.of(),sourceModel));
|
|
|
+ DataSetConfigService dataSetService = SpringUtil.getBean(DataSetConfigService.class);
|
|
|
+ IndexConfigService indexConfigService = SpringUtil.getBean(IndexConfigService.class);
|
|
|
+ List<IndexSourceModel> selectList = indexConfigService.getIndexSourceList(this.indexConfigModel);
|
|
|
+ // 定义存放数据集和其他指标的集合
|
|
|
+ List<IndexConfigModel> indexList = new ArrayList<>();
|
|
|
+ List<DataSetConfigModel> dataSetList = new ArrayList<>();
|
|
|
+ // 查询个指标编号和数据集对应的数据
|
|
|
+ for ( IndexSourceModel m : selectList) {
|
|
|
+ if (m.getDataSourceType().equals("DATASET")) {
|
|
|
+ DataSetConfigModel datasetModel = dataSetService.selectDetailData(new DataSetConfigModel());
|
|
|
+ dataSetList.add(datasetModel);
|
|
|
+ } else if (m.getDataSourceType().equals("INDEX")) {
|
|
|
+ IndexConfigModel indexConfigModel = indexConfigService.selectDetailData(new IndexConfigModel());
|
|
|
+ indexList.add(indexConfigModel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CalcUnit> indexCalcList = null;
|
|
|
+ List<CalcUnit> dataSetCalcList = null;
|
|
|
+ List<CalcUnit> resultCalcMap = new ArrayList<>();
|
|
|
+ // 数据源头节点生成
|
|
|
+ if (indexList.size() > 0) {
|
|
|
+ indexCalcList = indexList.stream().map(indexConfigModel -> new IndexCalcUnit
|
|
|
+ (indexConfigModel.getIndexNo(),indexConfigModel.getIndexName(),Map.of(),indexConfigModel)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if (dataSetList.size() > 0) {
|
|
|
+ dataSetCalcList = dataSetList.stream().map(dataSetModel -> new DataSetCalcUnit
|
|
|
+ (dataSetModel.getDataSetNo(),dataSetModel.getDataSetName(),Map.of(),dataSetModel)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+// selectList.stream().map(sourceModel -> new IndexSourceCalcUnit
|
|
|
+// (sourceModel.getOtherIndexNo(),"",CalcType.INDEX,Map.of(),sourceModel));
|
|
|
+ // 结果封装
|
|
|
+ resultCalcMap.addAll(indexCalcList);
|
|
|
+ resultCalcMap.addAll(dataSetCalcList);
|
|
|
return new ArrayList<>();
|
|
|
// return ConfigImages.indexCalcUnitListMap.get(this);
|
|
|
}
|