Browse Source

处理报错信息

JoeLazy 1 day ago
parent
commit
cedd691ead

+ 8 - 17
src/main/java/com/sundata/internalevaluation/calc/calcUnit/DataSetCalcUnit.java

@@ -7,12 +7,9 @@ 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.calc.util.CalciteUtil;
-import com.sundata.internalevaluation.configuration.model.DataSetConfigModel;
-import com.sundata.internalevaluation.configuration.model.DataSourcesModel;
+import com.sundata.internalevaluation.configuration.model.DataSetModel;
+import com.sundata.internalevaluation.configuration.model.DataSourceModel;
 import com.sundata.internalevaluation.configuration.service.DataSourcesService;
-import org.apache.calcite.adapter.file.JsonScannableTable;
-import org.apache.calcite.schema.impl.AbstractSchema;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -28,7 +25,7 @@ import java.util.stream.Collectors;
 public class DataSetCalcUnit extends CalcUnit {
     private static final Logger log = LoggerFactory.getLogger(DataSetCalcUnit.class);
 
-    DataSetConfigModel dataSetConfigModel;
+    DataSetModel dataSetConfigModel;
 
     /**
      * 创建数据单元的绝对对象,对象必须包含如下参数
@@ -37,7 +34,7 @@ public class DataSetCalcUnit extends CalcUnit {
      * @param calcName    计算对象名称
      * @param initContext 计算单元初始化参数
      */
-    public DataSetCalcUnit(String calcCode, String calcName, Map<String, Object> initContext, DataSetConfigModel dataSetConfigModel) {
+    public DataSetCalcUnit(String calcCode, String calcName, Map<String, Object> initContext, DataSetModel dataSetConfigModel) {
         super(calcCode, calcName, CalcType.DATASET, initContext);
         this.dataSetConfigModel = dataSetConfigModel;
     }
@@ -84,9 +81,9 @@ public class DataSetCalcUnit extends CalcUnit {
         // 获取数据来源service对象
         DataSourcesService sourcesService = SpringUtil.getBean(DataSourcesService.class);
         // 放入该数据集下的所有数据源对象
-        List<DataSourcesModel> sourceList = new ArrayList<>();
+        List<DataSourceModel> sourceList = new ArrayList<>();
         for (String s :dataSetConfigModel.getDataSourcesNos()) {
-            DataSourcesModel model = sourcesService.selectDetailData(s);
+            DataSourceModel model = sourcesService.selectDetailData(s);
             sourceList.add(model);
         }
 
@@ -131,18 +128,12 @@ public class DataSetCalcUnit extends CalcUnit {
         log.info("当前计算节点为:[{}-{}-{}],计算流水号为:{}", this.getCalcType(), this.getCalcCode(), this.getCalcName(), calculateInstanceNumber);
         // TODO 实际的计算过程
         // 合并后结果集
-        Map<String,JsonScannableTable> resultMap = new HashMap<>();
+        Map<String,Object> resultMap = new HashMap<>();
         // 合并数据集
         sourceResults.forEach((calcUnit,result)-> {
-            // resultMap.putAll(result);
-            // 获取构造后的table表
-            Map<String, JsonScannableTable> tableMap = (Map) result.get(calcUnit.getCalcCode());
-            resultMap.putAll(tableMap);
-
+            resultMap.putAll(result);
         });
         log.debug("合并后结果集结构:{}",resultMap);
-        // 声明域,将表结构放入
-        AbstractSchema schema = CalciteUtil.createSchema(resultMap);
         // 合并数据集结果集放入
         thisResult.put(this.getCalcCode(),resultMap);
 

+ 9 - 11
src/main/java/com/sundata/internalevaluation/calc/calcUnit/DataSourcesCalcUnit.java

@@ -1,17 +1,15 @@
 package com.sundata.internalevaluation.calc.calcUnit;
 
 import cn.hutool.extra.spring.SpringUtil;
-import com.sundata.common.util.DBExecutor;
 import com.sundata.common.util.JsonUtil;
 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.calc.util.CalciteUtil;
-import com.sundata.internalevaluation.configuration.model.DataSourcesModel;
-import com.sundata.internalevaluation.configuration.model.SysInterface;
+import com.sundata.internalevaluation.configuration.model.DataSourceModel;
+import com.sundata.internalevaluation.configuration.model.Interface;
 import com.sundata.internalevaluation.configuration.service.DataSourcesService;
-import com.sundata.internalevaluation.configuration.service.SysInterfaceService;
-import com.sundata.internalevaluation.script.TemplateUtil;
+import com.sundata.internalevaluation.configuration.service.InterfaceService;
 import org.apache.calcite.adapter.file.JsonScannableTable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -34,7 +32,7 @@ public class DataSourcesCalcUnit extends CalcUnit {
 
     private static final Logger log = LoggerFactory.getLogger(DataSourcesCalcUnit.class);
 
-    final DataSourcesModel dataSourcesModel;
+    final DataSourceModel dataSourcesModel;
 
     /**
     /**
@@ -46,7 +44,7 @@ public class DataSourcesCalcUnit extends CalcUnit {
      * @param initContext 计算单元初始化参数
      */
     public DataSourcesCalcUnit(String calcCode, String calcName,CalcType calcType, Map<String, Object> initContext,
-                               DataSourcesModel dataSourcesModel) {
+                               DataSourceModel dataSourcesModel) {
         super(calcCode, calcName, calcType, initContext);
         this.dataSourcesModel = dataSourcesModel;
 
@@ -85,13 +83,13 @@ public class DataSourcesCalcUnit extends CalcUnit {
     public List<CalcUnit> getSourceCalcUnits() {
         // 通过bean获取对象
         DataSourcesService sourcesService = SpringUtil.getBean(DataSourcesService.class);
-        SysInterfaceService sysInterfaceService = SpringUtil.getBean(SysInterfaceService.class);
-        DataSourcesModel selectModel = sourcesService.selectDetailData(this.dataSourcesModel.getDataSourcesNo());
+        InterfaceService sysInterfaceService = SpringUtil.getBean(InterfaceService.class);
+        DataSourceModel selectModel = sourcesService.selectDetailData(this.dataSourcesModel.getDataSourcesNo());
 
         // 记录所有源头节点
         List<CalcUnit> allUnitList = new ArrayList<>();
 
-        List<SysInterface> sysInterfaceModelList = new ArrayList<>();
+        List<Interface> sysInterfaceModelList = new ArrayList<>();
 
         // 接口源节点
         if ("INTERFACE".equals(dataSourcesModel.getDataSourcesType())) {
@@ -101,7 +99,7 @@ public class DataSourcesCalcUnit extends CalcUnit {
 //                sysInterfaceModelList.add(sysInterfaceService.getById(s));
 //            }
             sysInterfaceModelList.add(sysInterfaceService.getById(selectModel.getRequestInterface()));
-            List<CalcUnit> interFaceList = sysInterfaceModelList.stream().map(interfaceModel -> new InterfaceCalcUnit(interfaceModel.getId(),interfaceModel.getInterfaceName(),CalcType.INTERFACE,Map.of(),interfaceModel)).collect(Collectors.toList());
+            List<CalcUnit> interFaceList = sysInterfaceModelList.stream().map(interfaceModel -> new InterfaceCalcUnit(interfaceModel.getInterfaceNo(),interfaceModel.getInterfaceName(),CalcType.INTERFACE,Map.of(),interfaceModel)).collect(Collectors.toList());
             allUnitList.addAll(interFaceList);
         }
 

+ 12 - 18
src/main/java/com/sundata/internalevaluation/calc/calcUnit/IndexCalcUnit.java

@@ -4,36 +4,30 @@ import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.sundata.common.exception.BusinessException;
-import com.sundata.common.util.JsonUtil;
 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.calc.util.CalciteUtil;
-import com.sundata.internalevaluation.conf.JsonToCalciteExample;
-import com.sundata.internalevaluation.configuration.model.DataSetConfigModel;
-import com.sundata.internalevaluation.configuration.model.IndexConfigModel;
+import com.sundata.internalevaluation.configuration.model.DataSetModel;
+import com.sundata.internalevaluation.configuration.model.IndexModel;
 import com.sundata.internalevaluation.configuration.model.IndexSourceModel;
-import com.sundata.internalevaluation.configuration.service.DataSetConfigService;
+import com.sundata.internalevaluation.configuration.service.DataSetService;
 import com.sundata.internalevaluation.configuration.service.IndexConfigService;
 import com.sundata.internalevaluation.script.ScriptUtil;
 import com.sundata.internalevaluation.script.TemplateUtil;
-import org.apache.calcite.jdbc.CalciteConnection;
-import org.apache.calcite.schema.SchemaPlus;
 import org.apache.calcite.schema.impl.AbstractSchema;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.sql.Statement;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 public class IndexCalcUnit extends CalcUnit {
 
-    private final IndexConfigModel indexConfigModel;
+    private final IndexModel indexConfigModel;
 
     private static final Logger log = LoggerFactory.getLogger(IndexCalcUnit.class);
 
@@ -47,7 +41,7 @@ public class IndexCalcUnit extends CalcUnit {
      * @param calcName    计算对象名称
      * @param initContext 计算单元初始化参数
      */
-    public IndexCalcUnit(String calcCode, String calcName, Map<String, Object> initContext, IndexConfigModel indexConfigModel) {
+    public IndexCalcUnit(String calcCode, String calcName, Map<String, Object> initContext, IndexModel indexConfigModel) {
         super(calcCode, calcName, CalcType.INDEX, initContext);
         this.indexConfigModel = indexConfigModel;
     }
@@ -91,23 +85,23 @@ public class IndexCalcUnit extends CalcUnit {
     @Override
     public List<CalcUnit> getSourceCalcUnits() {
         // TODO 获取源头节点
-        DataSetConfigService dataSetService = SpringUtil.getBean(DataSetConfigService.class);
+        DataSetService dataSetService = SpringUtil.getBean(DataSetService.class);
         IndexConfigService indexConfigService = SpringUtil.getBean(IndexConfigService.class);
         List<IndexSourceModel> selectList = indexConfigService.getIndexSourceList(this.indexConfigModel);
         // 定义存放数据集和其他指标的集合
-        List<IndexConfigModel> indexList = new ArrayList<>();
-        List<DataSetConfigModel> dataSetList = new ArrayList<>();
+        List<IndexModel> indexList = new ArrayList<>();
+        List<DataSetModel> dataSetList = new ArrayList<>();
         // 查询个指标编号和数据集对应的数据
         for ( IndexSourceModel m : selectList) {
             if ("DATASET".equals(m.getDataSourceType())) {
-                DataSetConfigModel conditionModel = new DataSetConfigModel();
+                DataSetModel conditionModel = new DataSetModel();
                 conditionModel.setDataSetNo(m.getDataSetNo());
-                DataSetConfigModel datasetModel =  dataSetService.selectDetailData(conditionModel);
+                DataSetModel datasetModel =  dataSetService.selectDetailData(conditionModel);
                 dataSetList.add(datasetModel);
             } else if ("INDEX".equals(m.getDataSourceType())) {
-                IndexConfigModel conditionModel = new IndexConfigModel();
+                IndexModel conditionModel = new IndexModel();
                 conditionModel.setIndexNo(m.getOtherIndexNo());
-                IndexConfigModel indexConfigModel = indexConfigService.selectDetailData(conditionModel);
+                IndexModel indexConfigModel = indexConfigService.selectDetailData(conditionModel);
                 indexList.add(indexConfigModel);
             }
         }

+ 91 - 76
src/main/java/com/sundata/internalevaluation/calc/calcUnit/InterfaceCalcUnit.java

@@ -1,13 +1,13 @@
 package com.sundata.internalevaluation.calc.calcUnit;
 
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpResponse;
 import cn.hutool.http.HttpUtil;
-import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.sundata.admin.AdminUtil;
-import com.sundata.common.util.DBExecutor;
+import com.sundata.common.exception.BusinessException;
 import com.sundata.common.util.JsonUtil;
 import com.sundata.internalevaluation.calc.calcUnit.interfaces.InterfaceRunning;
 import com.sundata.internalevaluation.calc.model.CalcException;
@@ -15,17 +15,15 @@ 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.calc.util.InvokeUtil;
-import com.sundata.internalevaluation.configuration.model.SysInterface;
-import com.sundata.internalevaluation.configuration.model.SysInterfaceParam;
+import com.sundata.internalevaluation.calc.util.JdbcUtils;
+import com.sundata.internalevaluation.configuration.model.Interface;
+import com.sundata.internalevaluation.configuration.model.InterfaceParam;
 import com.sundata.internalevaluation.script.TemplateUtil;
-import io.swagger.v3.oas.annotations.responses.ApiResponse;
 import org.apache.commons.text.StringSubstitutor;
-import org.apache.flink.connector.jdbc.utils.JdbcUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.jdbc.core.JdbcTemplate;
 
-import javax.swing.*;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -42,7 +40,7 @@ public class InterfaceCalcUnit extends CalcUnit {
     private static final Logger log = LoggerFactory.getLogger(InterfaceCalcUnit.class);
 
 
-    private final SysInterface sysInterface;
+    private final Interface interfaceModel;
 
 
     /**
@@ -53,9 +51,9 @@ public class InterfaceCalcUnit extends CalcUnit {
      * @param calcType    计算类型
      * @param initContext 计算单元初始化参数
      */
-    public InterfaceCalcUnit(String calcCode, String calcName, CalcType calcType, Map<String, Object> initContext, SysInterface sysInterface) {
+    public InterfaceCalcUnit(String calcCode, String calcName, CalcType calcType, Map<String, Object> initContext, Interface interfaceModel) {
         super(calcCode, calcName, calcType, initContext);
-        this.sysInterface = sysInterface;
+        this.interfaceModel = interfaceModel;
     }
 
     /**
@@ -87,12 +85,6 @@ public class InterfaceCalcUnit extends CalcUnit {
      */
     @Override
     public List<CalcUnit> getSourceCalcUnits() {
-//        List<SysInterfaceParam> paramList = sysInterface.getParamList();
-//        List<CalcUnit> childCalcUnitList = paramList.stream()
-//                .map(item -> new InterfaceParamCalcUnit(item.getParamObjName(), item.getParamChineseName(), CalcType.INTERFACEPARAM, Map.of(), item))
-//                .collect(Collectors.toList());
-//        return childCalcUnitList;
-
         return List.of();
     }
 
@@ -134,22 +126,22 @@ public class InterfaceCalcUnit extends CalcUnit {
         // 获取新流水号,每次请求接口必须不一样
         String globalReqNo = AdminUtil.getNextId("cretSeqno");
         context.put("globalReqNo",globalReqNo);
-        // creditSeqNo 查询正i性能的流水号 如果不存在就重新赋值 只有征信的请求才会用到
+        // creditSeqNo 查询征信的流水号 如果不存在就重新赋值 只有征信的请求才会用到
         context.putIfAbsent("creditSeqNo",globalReqNo);
 
         // 接口内容类型
-        String reqContentTypeCode = this.sysInterface.getReqContentTypeCode();
+        String reqContentTypeCode = this.interfaceModel.getReqContentTypeCode();
         // 接口请求类型
-        String interfaceTypeCode = this.sysInterface.getInterfaceTypeCode();
+        String interfaceTypeCode = this.interfaceModel.getInterfaceTypeCode();
 
         // 请求类型不为 http或者 https   或者   请求体不为 json
         if (!interfaceTypeCode.startsWith("http") || !"json".equals(reqContentTypeCode)) {
             // TODO Socket 请求
-            throw new CalcException("目前仅支持http和https的请求和json请求体");
+            throw new BusinessException("目前仅支持http和https的请求和json请求体");
         }
 
         // 请求参数实体列表
-        List<SysInterfaceParam> paramList = sysInterface.getParamList();
+        List<InterfaceParam> paramList = interfaceModel.getParamList();
         Map<String, String> headersMap = new HashMap<>();
         Map<String, Object> paramMap = new HashMap<>();
 
@@ -171,10 +163,11 @@ public class InterfaceCalcUnit extends CalcUnit {
 
         // http请求或者 https请求
         if (interfaceTypeCode.startsWith("http")) {
+            // 拼接url  其中可能存在变量
             String url = interfaceTypeCode + "://" +
-                    sysInterface.getInterfaceIp() + ":" +
-                    sysInterface.getInterfacePort() +
-                    sysInterface.getInterfaceUrl();
+                    interfaceModel.getInterfaceIp() + ":" +
+                    interfaceModel.getInterfacePort() +
+                    interfaceModel.getInterfaceUrl();
 
             Map<String,Object> allMap = new HashMap<>(headersMap);
             allMap.putAll(paramMap);
@@ -183,83 +176,105 @@ public class InterfaceCalcUnit extends CalcUnit {
             url = sub.replace(url);
 
             // 请求体模板和完整请求体
-            String reqBodyTemplate = sysInterface.getReqBodyTemplate();
+            String reqBodyTemplate = interfaceModel.getReqBodyTemplate();
             String jsonString = "";
+
+
+
             // 替换请求报文模板中的变量
             if (reqBodyTemplate != null && !reqBodyTemplate.trim().isEmpty()) {
                 jsonString = TemplateUtil.execute("interface-temp-bodyTemp" + getCalcCode(),reqBodyTemplate,allMap);
             }
 
-            // 需要使用sdk发送请求的接口编号
-            List<String> sdkInterfaceNo = List.of("OY15120241127004","IY15120250124001");
-            // 拿到响应体
-            String responseStr = null;
-            String interfaceNo = sysInterface.getId();
-            if (sdkInterfaceNo.contains(interfaceNo)) {
-                HashMap<String,Object> allparam = new HashMap<>(paramMap);
-                allparam.putAll(headersMap);
-                // responseStr = sendRequestBySDKAPI(url,jsonString,allparam);
-            } else {
-                //  创建 HttpRequest 对象
-                HttpRequest httpRequest = null;
-                String reqMethod = sysInterface.getReqMethod();
-                if ("get".equals(reqMethod)) {
-                    httpRequest = HttpUtil.createGet(url);
-                } else {
-                    httpRequest = HttpUtil.createPost(url);
-                }
+            // 声明 接口参数处理的对象
+            InterfaceRunning interfaceRunning;
 
-                // 设置请求头和请求体
-                httpRequest.addHeaders(headersMap);
-                if (jsonString != null && !jsonString.trim().isEmpty()) {
-                    httpRequest.body(jsonString);
+            // 加密逻辑
+            String encodeLogic = interfaceModel.getReqEncryptionLogic();
+            if (StrUtil.isNotBlank(encodeLogic)) {
+                interfaceRunning = SpringUtil.getBean(encodeLogic);
+                if (interfaceRunning != null) {
+                    jsonString = interfaceRunning.encode(jsonString);
                 }
+            }
+
+            //  声明 HttpRequest 对象
+            HttpRequest httpRequest;
+
+            // 拿到响应体
+            String responseStr;
+            String interfaceNo = interfaceModel.getInterfaceNo();
+            String reqMethod = interfaceModel.getReqMethod();
+            if ("get".equals(reqMethod)) {
+                httpRequest = HttpUtil.createGet(url);
+            } else {
+                httpRequest = HttpUtil.createPost(url);
+            }
 
-                HttpResponse httpResponse = httpRequest.execute();
+            // 设置请求头和请求体
+            httpRequest.addHeaders(headersMap);
+            if (jsonString != null && !jsonString.trim().isEmpty()) {
+                httpRequest.body(jsonString);
+            }
+            log.debug("接口-[{}({})]-请求地址-[{}]-请求body报文:{}",getCalcName(),getCalcCode(),url,jsonString);
+            try (HttpResponse httpResponse = httpRequest.execute()) {
                 responseStr = httpResponse.body();
+                log.debug("接口-[{}({})]-请求地址-[{}]-响应body报文:{}",getCalcName(),getCalcCode(),url,responseStr);
+                String respParamTypeCode = interfaceModel.getRespParamTypeCode();
+                if ("json".equals(respParamTypeCode)){
+                    responseStr = JSONUtil.toJsonPrettyStr(responseStr);
+                }
+                // TODO 可继续增加其他类型
+                else
+                {
+                    throw new RuntimeException("接口-目前只支持 json 返回报文");
+                }
 
-                InterfaceRunning interfaceRunning = null;
+            }catch (Exception e){
+                String errMsg = StrUtil.format("接口-[{}({})]-请求地址-[{}] - 请求出现异常:{}", getCalcName(), getCalcCode(), url, e.getMessage());
+                log.error(errMsg);
+                throw new BusinessException(errMsg, e);
+            }
 
-                String decryptionLogic = sysInterface.getDecryptionLogic();
 
-                // 解密逻辑
-                if (null != decryptionLogic && !decryptionLogic.trim().isEmpty()) {
-                    interfaceRunning = SpringUtil.getBean(decryptionLogic);
-                    if (interfaceRunning != null) {
-                        responseStr = interfaceRunning.decode(responseStr);
-                    }
+            // 解密逻辑
+            String decryptionLogic = interfaceModel.getDecryptionLogic();
+            if (null != decryptionLogic && !decryptionLogic.trim().isEmpty()) {
+                interfaceRunning = SpringUtil.getBean(decryptionLogic);
+                if (interfaceRunning != null) {
+                    responseStr = interfaceRunning.decode(responseStr);
+                    log.debug("接口-[{}({})]-请求地址-[{}]-解密后数据:{}",getCalcName(),getCalcCode(),url,responseStr);
                 }
+            }
 
-                // 解密后处理逻辑
-                String processLogic = sysInterface.getProcessLogic();
-                if (processLogic != null && !processLogic.trim().isEmpty()) {
-                    interfaceRunning = SpringUtil.getBean(processLogic);
-                    if (interfaceRunning != null) {
-                        responseStr = interfaceRunning.afterDecode(interfaceNo,responseStr,calculateInstanceNumber);
-                    }
+            // 解密后处理逻辑
+            String processLogic = interfaceModel.getProcessLogic();
+            if (processLogic != null && !processLogic.trim().isEmpty()) {
+                interfaceRunning = SpringUtil.getBean(processLogic);
+                if (interfaceRunning != null) {
+                    responseStr = interfaceRunning.afterDecode(interfaceNo, responseStr, calculateInstanceNumber);
+                    log.debug("接口-[{}({})]-请求地址-[{}]-解析后数据:{}",getCalcName(),getCalcCode(),url,responseStr);
                 }
+            }
 
-                thisResult.put(getCalcCode(),responseStr);
+            /*
+            responseStr 一定是如下结果,否则后期计算会报错
+            {
+                "propA":[
+                ]
+            }
 
 
-            }
 
-//            HttpRequest postRequest = HttpUtil.createPost(url);
-//            postRequest.addHeaders(headersMap);
-//            String jsonString = JsonUtil.toJSONString(paramMap);
-//            log.warn("请求参数json:{}", jsonString);
-//            postRequest.body(jsonString);
-//            try (HttpResponse httpResponse = postRequest.execute()) {
-//                String responseStr = httpResponse.body();
-//                log.debug("请求接口【{}】的结果是:{}", url, responseStr);
-//                thisResult.put(getCalcCode(), responseStr);
-//            }
+             */
+            // 保存结果
+            thisResult.put(getCalcCode(), responseStr);
         }
     }
 
 
 
-    private Object getParamValue(SysInterfaceParam sysInterfaceParam, Map<String, Object> context) {
+    private Object getParamValue(InterfaceParam sysInterfaceParam, Map<String, Object> context) {
         // 参数获取类型
         String paramRetrievalTypeCode = sysInterfaceParam.getParamRetrievalTypeCode();
 

+ 21 - 17
src/main/java/com/sundata/internalevaluation/calc/calcUnit/RuleCalcUnit.java

@@ -4,11 +4,11 @@ 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.IndexConfigModel;
-import com.sundata.internalevaluation.configuration.model.SysReqRule;
-import com.sundata.internalevaluation.configuration.model.SysRuleIndex;
+import com.sundata.internalevaluation.configuration.model.IndexModel;
+import com.sundata.internalevaluation.configuration.model.Rule;
+import com.sundata.internalevaluation.configuration.model.RuleIndex;
 import com.sundata.internalevaluation.configuration.service.IndexConfigService;
-import com.sundata.internalevaluation.configuration.service.SysReqRuleService;
+import com.sundata.internalevaluation.configuration.service.RuleService;
 import com.sundata.internalevaluation.script.ScriptUtil;
 import com.sundata.internalevaluation.script.TemplateUtil;
 import org.slf4j.Logger;
@@ -17,8 +17,8 @@ import org.slf4j.LoggerFactory;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
 
 /**
  * Created by IntelliJ IDEA.
@@ -31,7 +31,7 @@ public class RuleCalcUnit extends CalcUnit {
 
     private static final Logger log = LoggerFactory.getLogger(RuleCalcUnit.class);
 
-    private final SysReqRule reqRule;
+    private final Rule reqRule;
 
     private final IndexConfigService indexConfigService;
 
@@ -43,7 +43,7 @@ public class RuleCalcUnit extends CalcUnit {
      * @param calcType    计算类型
      * @param initContext 计算单元初始化参数
      */
-    public RuleCalcUnit(String calcCode, String calcName, CalcType calcType, Map<String, Object> initContext, SysReqRule reqRule) {
+    public RuleCalcUnit(String calcCode, String calcName, CalcType calcType, Map<String, Object> initContext, Rule reqRule) {
         super(calcCode, calcName, calcType, initContext);
         this.reqRule = reqRule;
         this.indexConfigService = SpringUtil.getBean(IndexConfigService.class);
@@ -83,7 +83,7 @@ public class RuleCalcUnit extends CalcUnit {
      */
     @Override
     public List<CalcUnit> getSourceCalcUnits() {
-        List<IndexConfigModel> indexConfigModels = indexConfigService.selectIndexListByRuleNo(this.reqRule.getRuleNo());
+        List<IndexModel> indexConfigModels = indexConfigService.selectIndexListByRuleNo(this.reqRule.getRuleNo());
         List<CalcUnit> collect =indexConfigModels.stream()
                 .map(item -> new IndexCalcUnit(item.getIndexNo(), item.getIndexName(), Map.of(), item)).collect(Collectors.toList());
         return collect;
@@ -124,9 +124,9 @@ public class RuleCalcUnit extends CalcUnit {
                      Map<CalcUnit, CalcResult<String, Object>> sourceResults) {
         log.debug("计算{}:编号:{},名称:{},流水号:{}", getCalcType().getName(),getCalcCode(),getCalcName(),calculateInstanceNumber);
 
-        SysReqRuleService ruleService = SpringUtil.getBean(SysReqRuleService.class);
-        List<SysRuleIndex> sysRuleIndices = ruleService.selectRuleIndexListByRuleNo(getCalcCode());
-        Map<String, String> indexParamMap = sysRuleIndices.stream().collect(Collectors.toMap(SysRuleIndex::getIndexNo, SysRuleIndex::getRuleLogicParam));
+        RuleService ruleService = SpringUtil.getBean(RuleService.class);
+        List<RuleIndex> sysRuleIndices = ruleService.selectRuleIndexListByRuleNo(getCalcCode());
+        Map<String, String> indexParamMap = sysRuleIndices.stream().collect(Collectors.toMap(RuleIndex::getIndexNo, RuleIndex::getRuleLogicParam));
 
         // 所有规则计算的结果
         Map<String, Object> indexResMap = new HashMap<>();
@@ -150,14 +150,18 @@ public class RuleCalcUnit extends CalcUnit {
 
         Map<String, Object> resMap = new HashMap<>();
 
-        resMap.put("resCalc",res);//计算结果 true false
-        resMap.put("ruleNo", getCalcCode());//规则编号
-        resMap.put("indexRes", indexResMap);//指标结果
-        resMap.put("resultType", reqRule.getRuleResult());//规则的结果 0=无 1=拦截 2=预警
+        //计算结果 true false
+        resMap.put("resCalc",res);
+        //规则编号
+        resMap.put("ruleNo", getCalcCode());
+        //指标结果
+        resMap.put("indexRes", indexResMap);
+        //规则的结果 0=无 1=拦截 2=预警
+        resMap.put("resultType", reqRule.getRuleResult());
         //resMap.put("ruleDesc",reqRule.getTemplateDesc());//规则描述
-        resMap.put("datasource",reqRule.getRuleDatasour());
+        resMap.put("datasource",reqRule.getRuleDataSour());
         //规则结论
-        Map<String,Object> tempMap=new HashMap<>()(resMap);
+        Map<String, Object> tempMap = new HashMap<>(resMap);
         tempMap.putAll(indexResMap);
         resMap.put("ruleResult",TemplateUtil.execute("template-ruleConclusion-" + getCalcCode(),reqRule.getRuleConclusionTemplate(), tempMap));
 

+ 8 - 8
src/main/java/com/sundata/internalevaluation/calc/calcUnit/interfaces/InterfaceRunning.java

@@ -4,23 +4,23 @@ public interface InterfaceRunning {
 
     /**
      * 加密逻辑
-     * @param interfaceStr
+     * @param interfaceStr 待处理字符串
      * @return 加密后逻辑
      */
     String encode(String interfaceStr);
 
     /**
-     *
-     * @param encodeString
-     * @return 保温内存
+     * 解密逻辑
+     * @param encodeString 待处理字符串
+     * @return 解密后的逻辑
      */
     String decode(String encodeString);
 
     /**
-     *
-     * @param interfaceNo
-     * @param interfaceStr
-     * @param calculateInstanceNumber
+     * 根据解密后的报文内容,对报文内容做出一定的处理
+     * @param interfaceNo 接口编号
+     * @param interfaceStr 待处理字符串
+     * @param calculateInstanceNumber 计算实例编号
      * @return 处理后的字符串报文
      */
     String afterDecode(String interfaceNo, String interfaceStr, String calculateInstanceNumber);

+ 32 - 0
src/main/java/com/sundata/internalevaluation/calc/util/JdbcUtils.java

@@ -0,0 +1,32 @@
+package com.sundata.internalevaluation.calc.util;
+
+import cn.hutool.extra.spring.SpringUtil;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.sql.DataSource;
+
+/**
+ * Created by IntelliJ IDEA.
+ *
+ * @author JoeLazy
+ * @date 2025-04-27 16:25:14
+ * @description: Jdbc工具类
+ */
+public class JdbcUtils {
+
+    private static volatile JdbcTemplate jdbcTemplate = null;
+
+    public static JdbcTemplate getJdbcTemplate() {
+        if (jdbcTemplate == null) {
+            synchronized (JdbcUtils.class) {
+                if (jdbcTemplate == null) {
+                    jdbcTemplate = SpringUtil.getBean(JdbcTemplate.class);
+                    if (jdbcTemplate == null){
+                        jdbcTemplate = new JdbcTemplate(SpringUtil.getBean(DataSource.class));
+                    }
+                }
+            }
+        }
+        return jdbcTemplate;
+    }
+}

+ 0 - 20
src/main/java/com/sundata/internalevaluation/configuration/model/IndexModel.java

@@ -8,10 +8,6 @@ public class IndexModel {
     private String indexNo;
     // 指标名称
     private String indexName;
-    // 默认值
-    private String defaultValue;
-    // 默认值类型
-    private String defaultValueType;
     // 指标逻辑
     private String indexLogic;
     /**
@@ -52,22 +48,6 @@ public class IndexModel {
         this.indexName = indexName;
     }
 
-    public String getDefaultValueType() {
-        return defaultValueType;
-    }
-
-    public void setDefaultValueType(String defaultValueType) {
-        this.defaultValueType = defaultValueType;
-    }
-
-    public String getDefaultValue() {
-        return defaultValue;
-    }
-
-    public void setDefaultValue(String defaultValue) {
-        this.defaultValue = defaultValue;
-    }
-
     public String getIndexLogic() {
         return indexLogic;
     }