|
@@ -0,0 +1,106 @@
|
|
|
+package com.sundata.internalevaluation.calc.calcUnit;
|
|
|
+
|
|
|
+
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
+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.IndexListModel;
|
|
|
+import com.sundata.internalevaluation.configuration.model.RiskControlStrategyModel;
|
|
|
+import com.sundata.internalevaluation.configuration.model.SysReqRules;
|
|
|
+import com.sundata.internalevaluation.configuration.service.IndexListConfigService;
|
|
|
+import com.sundata.internalevaluation.configuration.service.RiskControlStrategyService;
|
|
|
+import com.sundata.internalevaluation.configuration.service.SysReqRuleService;
|
|
|
+import com.sundata.internalevaluation.configuration.service.SysReqRulesService;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+public class RiskControlStrategyCalcUnit extends CalcUnit {
|
|
|
+
|
|
|
+ RiskControlStrategyModel riskControlStrategyModel;
|
|
|
+ /**
|
|
|
+ * 创建数据单元的绝对对象,对象必须包含如下参数
|
|
|
+ *
|
|
|
+ * @param calcCode 计算对象编号
|
|
|
+ * @param calcName 计算对象名称
|
|
|
+ * @param calcType 计算类型
|
|
|
+ * @param initContext 计算单元初始化参数
|
|
|
+ */
|
|
|
+ public RiskControlStrategyCalcUnit(String calcCode, String calcName, CalcType calcType, Map<String, Object> initContext, RiskControlStrategyModel riskControlStrategyModel) {
|
|
|
+ super(calcCode, calcName, calcType, initContext);
|
|
|
+ this.riskControlStrategyModel = riskControlStrategyModel;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean isCalcFinished(String calculateInstanceNumber) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initResultContext(String calculateInstanceNumber) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CalcUnit> getSourceCalcUnits() {
|
|
|
+ List<IndexListModel> indexListModels = new ArrayList<>();
|
|
|
+ List<SysReqRules> sysReqRules = new ArrayList<>();
|
|
|
+ List<CalcUnit> allListUnit = new ArrayList<>();
|
|
|
+ RiskControlStrategyService riskControlStrategyService = SpringUtil.getBean(RiskControlStrategyService.class);
|
|
|
+ IndexListConfigService indexListConfigService = SpringUtil.getBean(IndexListConfigService.class);
|
|
|
+ SysReqRulesService sysReqRulesService = SpringUtil.getBean(SysReqRulesService.class);
|
|
|
+ SysReqRuleService sysReqRuleService = SpringUtil.getBean(SysReqRuleService.class);
|
|
|
+ RiskControlStrategyModel selectModel = riskControlStrategyService.selectDetailData(this.riskControlStrategyModel);
|
|
|
+ // 获取所有指标清单对象
|
|
|
+ if (null != selectModel && null != selectModel.getIndexListNos() && selectModel.getIndexListNos().size()>0) {
|
|
|
+ for(String indexListNo : selectModel.getIndexListNos()) {
|
|
|
+ IndexListModel model = new IndexListModel();
|
|
|
+ model.setIndexListNo(indexListNo);
|
|
|
+ IndexListModel afterSelectModel = indexListConfigService.selectDetailData(model);
|
|
|
+ if (null != afterSelectModel) {
|
|
|
+ indexListModels.add(afterSelectModel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取所有规则集对象
|
|
|
+ if (null != selectModel && null != selectModel.getRulesNos() && selectModel.getRulesNos().size()>0) {
|
|
|
+ for(String rulesNo : selectModel.getRulesNos()) {
|
|
|
+ SysReqRules afterSelectModel = sysReqRulesService.getById(rulesNo);
|
|
|
+ if (null != afterSelectModel ) {
|
|
|
+ sysReqRules.add(afterSelectModel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<CalcUnit> indexListUnit = indexListModels.stream().map(indexListModel -> new IndexListConfigCalcUnit(indexListModel.getIndexListNo(),indexListModel.getIndexListName(),CalcType.INDEXLIST,Map.of(),indexListModel)).collect(Collectors.toList());
|
|
|
+ List<CalcUnit> rulesUnit = sysReqRules.stream().map(rulesModel -> new RulesCalcUnit(rulesModel.getRulesNo(),rulesModel.getRulesName(),Map.of(),rulesModel,sysReqRuleService)).collect(Collectors.toList());
|
|
|
+ allListUnit.addAll(indexListUnit);
|
|
|
+ allListUnit.addAll(rulesUnit);
|
|
|
+ return allListUnit;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterCalc(Map<String, Object> context) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void beforeCalc(Map<String, Object> context) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void calc(CalcResult<String, Object> thisResult, String calculateInstanceNumber, Map<String, Object> context, Map<CalcUnit, CalcResult<String, Object>> sourceResults) {
|
|
|
+
|
|
|
+ Map<String,Object> resResultMap =new HashMap<>();
|
|
|
+ sourceResults.forEach(
|
|
|
+ (calcUnit,result) -> {
|
|
|
+ resResultMap.putAll(result);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ thisResult.put(this.getCalcCode(),resResultMap);
|
|
|
+ }
|
|
|
+}
|