Browse Source

测试联调 修改

JoeLazy 3 tháng trước cách đây
mục cha
commit
5a4fb60c16

+ 1 - 2
src/main/java/com/sundata/internalevaluation/calc/calcUnit/DataSetCalcUnit.java

@@ -17,7 +17,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
 /**
@@ -132,7 +131,7 @@ public class DataSetCalcUnit extends CalcUnit {
         Map<String,Object> resultMap = new HashMap<>();
         // 合并数据集
         sourceResults.forEach((calcUnit,result)-> {
-            resultMap.putAll(result);
+            resultMap.putAll((Map<String, Object>)result.get(calcUnit.getCalcCode()));
         });
         thisResult.put(this.getCalcCode(),resultMap);
 

+ 17 - 6
src/main/java/com/sundata/internalevaluation/calc/calcUnit/DataSourcesCalcUnit.java

@@ -6,12 +6,10 @@ 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.conf.JsonToCalciteExample;
 import com.sundata.internalevaluation.configuration.model.DataSourcesModel;
 import com.sundata.internalevaluation.configuration.model.SysInterface;
 import com.sundata.internalevaluation.configuration.service.DataSourcesService;
 import com.sundata.internalevaluation.configuration.service.SysInterfaceService;
-import com.sundata.internalevaluation.script.ScriptUtil;
 import com.sundata.internalevaluation.script.TemplateUtil;
 
 import java.util.ArrayList;
@@ -133,20 +131,33 @@ public class DataSourcesCalcUnit extends CalcUnit {
 
         sourceResults.forEach((calcUnit,result)->{
 
-            if (dataSourcesModel.getDataSourcesType().equals("INTERFACE")) {
+            if ("INTERFACE".equals(dataSourcesModel.getDataSourcesType())) {
                 // 数据来源类型为接口时处理逻辑
                 if (calcUnit instanceof InterfaceCalcUnit ) {
                     // 获取json
                     String json = result.get(calcUnit.getCalcCode()) instanceof String ? (String) result.get(calcUnit.getCalcCode()) : "";
-                    Map<Object, Object> objectObjectMap = JsonUtil.jsonToMap(json);
+                    Map<Object, Object> objectObjectMap1 = JsonUtil.jsonToMap(json);
+                    Map<Object, Object> objectObjectMap = objectObjectMap1
+                            .entrySet().stream().collect(Collectors.toMap(entry ->"interface_"+entry.getKey(), Map.Entry::getValue));
+
+//                    objectObjectMap.forEach((key, value)->{
+//                        objectObjectMap.put("interface_"+key,value);
+//                        objectObjectMap.remove(key, value);
+//                    });
+
                     thisResult.put(this.getCalcCode(), objectObjectMap);
                 }
-            } else if (dataSourcesModel.getDataSourcesType().equals("JDBC")) {
+            } 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);
-                    thisResult.put(this.getCalcCode(), DBExecutor.doQueryMap(sql));
+                    Map<String, Object> stringObjectMap = DBExecutor.doQueryMap(sql);
+                    stringObjectMap.forEach((key, value)->{
+                        stringObjectMap.put("jdbc_"+key,value);
+                        stringObjectMap.remove(key, value);
+                    });
+                    thisResult.put(this.getCalcCode(), stringObjectMap);
                 }
             }
         });

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

@@ -1,7 +1,6 @@
 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;
@@ -20,12 +19,10 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
 public class IndexCalcUnit extends CalcUnit {
@@ -183,7 +180,7 @@ public class IndexCalcUnit extends CalcUnit {
             if ( calcUnit instanceof DataSetCalcUnit dataSetCalcUnit){
                 if(dataSetCalcUnit.getCalcType() == CalcType.DATASET){
                     dataSetNumber.getAndIncrement();
-                    dataSetResult.putAll(result);
+                    dataSetResult.putAll((Map) result.get(calcUnit.getCalcCode()));
                 }
             }
             // 其他指标
@@ -195,6 +192,11 @@ public class IndexCalcUnit extends CalcUnit {
             }
         });
 
+
+        // TODO
+        // TODO
+
+
         if (dataSetNumber.get() > 0 && indexNumber.get() == 0){
 
             String json = JsonUtil.toJSONString(dataSetResult);
@@ -205,7 +207,7 @@ public class IndexCalcUnit extends CalcUnit {
             // 获取指标逻辑
             String logic = indexConfigModel.getIndexLogic();
 
-            String resValue = jsonUtil.jsonTotable(this.indexConfigModel.getIndexNo(),json,logic);
+            Object resValue = jsonUtil.jsonTotable(this.getCalcCode(),json,logic);
 
             // 执行sql,并放进结果集内
 
@@ -231,17 +233,24 @@ public class IndexCalcUnit extends CalcUnit {
             // 将数据集得到的数据转json
             String json = JsonUtil.toJSONString(dataSetResult);
             // 执行拿结果
-            String resValue = jsonUtil.jsonTotable(this.indexConfigModel.getIndexNo(),json,editSql);
+            Object resValue = jsonUtil.jsonTotable(this.indexConfigModel.getIndexNo(),json,editSql);
             // 放结果
             thisResult.put(this.getCalcCode(),resValue);
         }
     }
 
-    public String getConnectionTable (CalciteConnection calciteConnection,String sql) {
+
+    /**
+     *
+     * @param calciteConnection
+     * @param sql
+     * @return
+     */
+    public Object getConnectionTable (CalciteConnection calciteConnection,String sql) {
         //获取域
         SchemaPlus rootSchemafter = calciteConnection.getRootSchema();
         //根域中获取子域
-        SchemaPlus childrenSchema=rootSchemafter.getSubSchema("test");
+        SchemaPlus childrenSchema=rootSchemafter.getSubSchema(this.getCalcCode());
         //子域名
         String childrenName = childrenSchema.getName();
         System.out.println("childrenName: " + childrenName);
@@ -254,13 +263,13 @@ public class IndexCalcUnit extends CalcUnit {
             Statement statement = calciteConnection.createStatement();
             ResultSet resultSet = statement.executeQuery(sql);
             if (resultSet.next()){
-                 value = resultSet.getString(1);
+                 //value = resultSet.getString(1);
+                return resultSet.getObject(1);
+//                System.out.println();
             }
         } catch (SQLException e) {
             throw new RuntimeException(e);
         }
-        finally {
-            return value;
-        }
+        return null;
     }
 }

+ 127 - 30
src/main/java/com/sundata/internalevaluation/calc/calcUnit/InterfaceCalcUnit.java

@@ -3,20 +3,22 @@ package com.sundata.internalevaluation.calc.calcUnit;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpResponse;
 import cn.hutool.http.HttpUtil;
+import com.sundata.common.util.DBExecutor;
 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.InvokeUtil;
 import com.sundata.internalevaluation.configuration.model.SysInterface;
 import com.sundata.internalevaluation.configuration.model.SysInterfaceParam;
+import com.sundata.internalevaluation.script.TemplateUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * Created by IntelliJ IDEA.
@@ -75,11 +77,13 @@ 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;
+//        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();
     }
 
     /**
@@ -116,7 +120,7 @@ public class InterfaceCalcUnit extends CalcUnit {
                      Map<String, Object> context,
                      Map<CalcUnit, CalcResult<String, Object>> sourceResults) {
 
-        log.debug("计算{}:编号:{},名称:{},流水号:{}", getCalcType().getName(),getCalcCode(),getCalcName(),calculateInstanceNumber);
+        log.debug("计算{}:编号:{},名称:{},流水号:{}", getCalcType().getName(), getCalcCode(), getCalcName(), calculateInstanceNumber);
 
 
         // 接口内容类型
@@ -124,37 +128,130 @@ public class InterfaceCalcUnit extends CalcUnit {
         // 接口请求类型
         String interfaceTypeCode = this.sysInterface.getInterfaceTypeCode();
 
+        // 请求类型不为 http或者 https   或者   请求体不为 json
+        if (!interfaceTypeCode.startsWith("http") || !"json".equals(reqContentTypeCode)) {
+            // TODO Socket 请求
+            throw new CalcException("目前仅支持http和https的请求和json请求体");
+        }
 
-        // http请求或者 https请求
-        if (interfaceTypeCode.startsWith("http") && "json".equals(reqContentTypeCode)) {
-            Map<String, String> headersMap = new HashMap<>();
-            Map<String, Object> paramMap = new HashMap<>();
-
-            sourceResults.forEach((key, value) -> {
-                String calcCode = key.getCalcCode();
-                Object res = value.get(calcCode);
-                SysInterfaceParam entity = (SysInterfaceParam) value.get("entity");
-
-                // 判断是不是请求头
-                if ("true".equals(entity.getIsHeader())) {
-                    headersMap.put(entity.getParamObjName(), res.toString());
-                } else {
-                    paramMap.put(entity.getParamObjName(), res);
+
+        /**
+         * 计算参数
+         */
+        List<SysInterfaceParam> paramList = sysInterface.getParamList();
+
+        Map<String, String> headersMap = new HashMap<>();
+        Map<String, Object> paramMap = new HashMap<>();
+
+        // 封装请求参数
+        paramList.forEach(
+                param -> {
+                    Object result = getResultByInterfaceParam(param, context);
+                    String isHeader = param.getIsHeader();
+                    if ("true".equals(isHeader)) {
+                        headersMap.put(param.getParamObjName(), JsonUtil.toJSONString(result));
+                    } else {
+                        paramMap.put(param.getParamObjName(), result);
+                    }
                 }
-            });
+        );
+
+
+        // http请求或者 https请求
+        if (interfaceTypeCode.startsWith("http")) {
             String url = interfaceTypeCode + "://" + sysInterface.getInterfaceIp() + ":" + sysInterface.getInterfacePort() + sysInterface.getInterfaceUrl();
             HttpRequest postRequest = HttpUtil.createPost(url);
             postRequest.addHeaders(headersMap);
-            postRequest.body(JsonUtil.toJSONString(paramMap));
-            try (HttpResponse httpResponse = postRequest.execute()){
+            String jsonString = JsonUtil.toJSONString(paramMap);
+            log.warn("请求参数json:{}", jsonString);
+            postRequest.body(jsonString);
+            try (HttpResponse httpResponse = postRequest.execute()) {
                 String responseStr = httpResponse.body();
-//                thisResult.put(getCalcCode(), JsonUtil.jsonToMap(responseStr));
-                thisResult.put(getCalcCode(), (responseStr));
+                log.debug("请求接口【{}】的结果是:{}", url, responseStr);
+                thisResult.put(getCalcCode(), responseStr);
+            }
+        }
+    }
+
+
+
+    private Object getResultByInterfaceParam(SysInterfaceParam sysInterfaceParam, Map<String, Object> context) {
+        // 参数获取类型
+        String paramRetrievalTypeCode = sysInterfaceParam.getParamRetrievalTypeCode();
+
+        // 参数获取内容
+        String paramRetrievalTypeCont = sysInterfaceParam.getParamRetrievalTypeCont();
+
+
+        Object result = null;
+
+        // 获取参数值
+        switch (paramRetrievalTypeCode) {
+            // 固定值
+            case "fixed":
+                result = paramRetrievalTypeCont;
+                break;
+            // java
+            //   获取参数内容
+            case "java":
+                try {
+                    result = InvokeUtil.invokeMethod(paramRetrievalTypeCont);
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+                break;
+            // SQL-Map
+            case "sqlmap":
+                String execute = TemplateUtil.execute("interfaceParam-temp-sqlmap-" + getCalcCode(), paramRetrievalTypeCont, context);
+                log.warn("sql语句为:{}",execute);
+                result = DBExecutor.doQuery(execute);
+                break;
+            // SQL-List
+            case "sqllist":
+                String execute1 = TemplateUtil.execute("interfaceParam-temp-sqllist-" + getCalcCode(), paramRetrievalTypeCont, context);
+                log.warn("sql语句为:{}",execute1);
+                result = DBExecutor.doQueryMapList(execute1);
+                break;
+            // SQL-String
+            case "sqlstring":
+                String execute2 = TemplateUtil.execute("interfaceParam-temp-sqlstring-" + getCalcCode(), paramRetrievalTypeCont, context);
+                log.warn("sql语句为:{}",execute2);
+                result = DBExecutor.doQuery(execute2);
+                break;
+        }
+
+
+        String paramTypeCode = sysInterfaceParam.getParamTypeCode();
+        if ("string".equals(paramTypeCode)) {
+            if (result instanceof String) {
+
+            } else {
+                result = JsonUtil.toJSONString(result);
+            }
+        } else if ("number".equals(paramTypeCode)) {
+            if (result instanceof Number) {
+                if (result instanceof Integer) {
+                    result = ((Number) result).intValue();
+                } else if (result instanceof Long) {
+                    result = ((Number) result).longValue();
+                } else if (result instanceof Float) {
+                    result = ((Number) result).floatValue();
+                } else if (result instanceof Double) {
+                    result = ((Number) result).doubleValue();
+                } else if (result instanceof Short) {
+                    result = ((Number) result).shortValue();
+                } else if (result instanceof Byte) {
+                    result = ((Number) result).byteValue();
+                } else {
+                    throw new RuntimeException("数据类型不匹配:计算机过不为'数字'");
+                }
+
+            } else {
+                throw new RuntimeException("数据类型不匹配:计算机过不为'数字'");
             }
         } else {
-            // TODO Socket 请求
-            throw new CalcException("目前仅支持http和https的请求");
-//            thisResult.put(getCalcCode(), "非http、https请求,并且参数不是json格式");
+            throw new CalcException("返回值类型有无,目前仅有 数字和字符串");
         }
+        return result;
     }
 }

+ 9 - 3
src/main/java/com/sundata/internalevaluation/calc/calcUnit/InterfaceParamCalcUnit.java

@@ -138,15 +138,21 @@ public class InterfaceParamCalcUnit extends CalcUnit {
                 break;
             // SQL-Map
             case "sqlmap":
-                result = DBExecutor.doQuery(TemplateUtil.execute("interfaceParam-temp-sqlmap-"+getCalcCode(),paramRetrievalTypeCont, context));
+                String execute = TemplateUtil.execute("interfaceParam-temp-sqlmap-" + getCalcCode(), paramRetrievalTypeCont, context);
+                log.warn("sql语句为:{}",execute);
+                result = DBExecutor.doQuery(execute);
                 break;
             // SQL-List
             case "sqllist":
-                result = DBExecutor.doQueryMapList(TemplateUtil.execute("interfaceParam-temp-sqllist-"+getCalcCode(),paramRetrievalTypeCont, context));
+                String execute1 = TemplateUtil.execute("interfaceParam-temp-sqllist-" + getCalcCode(), paramRetrievalTypeCont, context);
+                log.warn("sql语句为:{}",execute1);
+                result = DBExecutor.doQueryMapList(execute1);
                 break;
             // SQL-String
             case "sqlstring":
-                result = DBExecutor.doQuery(TemplateUtil.execute("interfaceParam-temp-sqlstring-"+getCalcCode(),paramRetrievalTypeCont, context));
+                String execute2 = TemplateUtil.execute("interfaceParam-temp-sqlstring-" + getCalcCode(), paramRetrievalTypeCont, context);
+                log.warn("sql语句为:{}",execute2);
+                result = DBExecutor.doQuery(execute2);
                 break;
         }
 

+ 164 - 2
src/main/java/com/sundata/internalevaluation/calc/util/JsonToCalciteUtil.java

@@ -35,8 +35,78 @@ public class JsonToCalciteUtil {
         connection = DriverManager.getConnection("jdbc:calcite:");
         CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
 
+
+        String json01 = "[\n" +
+                "    {\n" +
+                "      \"subNo\": \"07cc9eca-4e66-4d1c-9dd1-fe4671c2e18b\",\n" +
+                "      \"subName\": \"Associate Degree in Health Science\"\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"subNo\": \"cda7b717-bbff-40fd-af90-7e22dcea8457\",\n" +
+                "      \"subName\": \"Associate Degree in Medicine\"\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"subNo\": \"9cf8534b-37c6-4365-8453-d1454e336992\",\n" +
+                "      \"subName\": \"Master of Biological Science\"\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"subNo\": \"b21f3d9b-670b-4819-8faa-dbb2324f522a\",\n" +
+                "      \"subName\": \"Bachelor of Criminology\"\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"subNo\": \"635c0a8a-3701-43f1-a1d6-d359465df3c6\",\n" +
+                "      \"subName\": \"Master of Teaching\"\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"subNo\": \"2aa9e2d1-5f0e-41c6-8bf5-970b08d47b67\",\n" +
+                "      \"subName\": \"Associate Degree in Creative Arts\"\n" +
+                "    }\n" +
+                "  ]";
+
+
+        String json02 = "[\n" +
+                "    {\n" +
+                "      \"stuNo\": \"2e482de1-c984-4447-a968-ffc2f9cd4a2a\",\n" +
+                "      \"subNo\": \"07cc9eca-4e66-4d1c-9dd1-fe4671c2e18b\",\n" +
+                "      \"score\": 70.82\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"stuNo\": \"2e482de1-c984-4447-a968-ffc2f9cd4a2a\",\n" +
+                "      \"subNo\": \"cda7b717-bbff-40fd-af90-7e22dcea8457\",\n" +
+                "      \"score\": 24.71\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"stuNo\": \"2e482de1-c984-4447-a968-ffc2f9cd4a2a\",\n" +
+                "      \"subNo\": \"9cf8534b-37c6-4365-8453-d1454e336992\",\n" +
+                "      \"score\": 44.05\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"stuNo\": \"2e482de1-c984-4447-a968-ffc2f9cd4a2a\",\n" +
+                "      \"subNo\": \"b21f3d9b-670b-4819-8faa-dbb2324f522a\",\n" +
+                "      \"score\": 78.65\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"stuNo\": \"2e482de1-c984-4447-a968-ffc2f9cd4a2a\",\n" +
+                "      \"subNo\": \"635c0a8a-3701-43f1-a1d6-d359465df3c6\",\n" +
+                "      \"score\": 26.77\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"stuNo\": \"2e482de1-c984-4447-a968-ffc2f9cd4a2a\",\n" +
+                "      \"subNo\": \"2aa9e2d1-5f0e-41c6-8bf5-970b08d47b67\",\n" +
+                "      \"score\": 3.0\n" +
+                "    }\n" +
+                "  ]";
+
+
         SchemaPlus rootSchema = calciteConnection.getRootSchema();
-        rootSchema.add("credite", new AbstractSchema());
+        SchemaPlus credite = rootSchema.add("credite", new AbstractSchema());
+
+
+        SchemaPlus subjectSc = rootSchema.add("subjectSc", new AbstractSchema());
+        subjectSc.add("subject", new JsonScannableTable(Sources.of(json01)));
+        SchemaPlus scoresSc = rootSchema.add("scoresSc", new AbstractSchema());
+        scoresSc.add("scores", new JsonScannableTable(Sources.of(json02)));
+
 
         // 注册 JSON 数据为表
         rootNode.fields().forEachRemaining(entry -> {
@@ -45,9 +115,22 @@ public class JsonToCalciteUtil {
             rootSchema.add(tableName, new JsonScannableTable(Sources.of(tableData.toString())));
         });
 
+        sql =
+                """
+                        select "subjectSc"."subject"."subName","scoresSc"."scores"."score" from "subjectSc"."subject" inner join "scoresSc"."scores" on "subjectSc"."subject"."subNo" = "scoresSc"."scores"."subNo"
+                        """;
+
+
         // 4. 执行 SQL 查询
         statement = connection.createStatement();
-        return resultSet = statement.executeQuery(sql);
+        resultSet = statement.executeQuery(sql);
+        while (resultSet.next()) {
+            System.out.printf("Order ID: %s, Amount: %.2f\n",
+                    resultSet.getString(1),
+                    resultSet.getDouble(2));
+
+        }
+        return resultSet;
     }
 
     public void closeResource() throws SQLException {
@@ -63,4 +146,83 @@ public class JsonToCalciteUtil {
         }
     }
 
+
+    public static void main(String[] args) throws SQLException, JsonProcessingException {
+        JsonToCalciteUtil jsonToCalciteUtil = new JsonToCalciteUtil();
+
+        String json1 = "{\n" +
+                "  \"student\": [\n" +
+                "    {\n" +
+                "      \"stuNo\": \"2e482de1-c984-4447-a968-ffc2f9cd4a2a\",\n" +
+                "      \"syuName\": \"阎彬\",\n" +
+                "      \"stuSex\": \"男\",\n" +
+                "      \"stuAge\": 26,\n" +
+                "      \"stuClass\": \"1\"\n" +
+                "    }\n" +
+                "  ],\n" +
+                "  \"scores\": [\n" +
+                "    {\n" +
+                "      \"stuNo\": \"2e482de1-c984-4447-a968-ffc2f9cd4a2a\",\n" +
+                "      \"subNo\": \"07cc9eca-4e66-4d1c-9dd1-fe4671c2e18b\",\n" +
+                "      \"score\": 70.82\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"stuNo\": \"2e482de1-c984-4447-a968-ffc2f9cd4a2a\",\n" +
+                "      \"subNo\": \"cda7b717-bbff-40fd-af90-7e22dcea8457\",\n" +
+                "      \"score\": 24.71\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"stuNo\": \"2e482de1-c984-4447-a968-ffc2f9cd4a2a\",\n" +
+                "      \"subNo\": \"9cf8534b-37c6-4365-8453-d1454e336992\",\n" +
+                "      \"score\": 44.05\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"stuNo\": \"2e482de1-c984-4447-a968-ffc2f9cd4a2a\",\n" +
+                "      \"subNo\": \"b21f3d9b-670b-4819-8faa-dbb2324f522a\",\n" +
+                "      \"score\": 78.65\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"stuNo\": \"2e482de1-c984-4447-a968-ffc2f9cd4a2a\",\n" +
+                "      \"subNo\": \"635c0a8a-3701-43f1-a1d6-d359465df3c6\",\n" +
+                "      \"score\": 26.77\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"stuNo\": \"2e482de1-c984-4447-a968-ffc2f9cd4a2a\",\n" +
+                "      \"subNo\": \"2aa9e2d1-5f0e-41c6-8bf5-970b08d47b67\",\n" +
+                "      \"score\": 3.0\n" +
+                "    }\n" +
+                "  ],\n" +
+                "  \"subject\": [\n" +
+                "    {\n" +
+                "      \"subNo\": \"07cc9eca-4e66-4d1c-9dd1-fe4671c2e18b\",\n" +
+                "      \"subName\": \"Associate Degree in Health Science\"\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"subNo\": \"cda7b717-bbff-40fd-af90-7e22dcea8457\",\n" +
+                "      \"subName\": \"Associate Degree in Medicine\"\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"subNo\": \"9cf8534b-37c6-4365-8453-d1454e336992\",\n" +
+                "      \"subName\": \"Master of Biological Science\"\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"subNo\": \"b21f3d9b-670b-4819-8faa-dbb2324f522a\",\n" +
+                "      \"subName\": \"Bachelor of Criminology\"\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"subNo\": \"635c0a8a-3701-43f1-a1d6-d359465df3c6\",\n" +
+                "      \"subName\": \"Master of Teaching\"\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"subNo\": \"2aa9e2d1-5f0e-41c6-8bf5-970b08d47b67\",\n" +
+                "      \"subName\": \"Associate Degree in Creative Arts\"\n" +
+                "    }\n" +
+                "  ]\n" +
+                "}";
+
+        ResultSet resultSet1 = jsonToCalciteUtil.jsonToResultSet(json1, "");
+
+
+    }
+
 }

+ 15 - 16
src/main/java/com/sundata/internalevaluation/conf/JsonToCalciteExample.java

@@ -1,4 +1,5 @@
 package com.sundata.internalevaluation.conf;
+
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.sundata.internalevaluation.calc.calcUnit.IndexCalcUnit;
@@ -19,15 +20,13 @@ import org.apache.calcite.util.Sources;
 
 import java.sql.Connection;
 import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.Statement;
 import java.util.*;
 
 public class JsonToCalciteExample {
 
-    public  String jsonTotable(String schemaName, String jsonDate, String sql)  {
+    public  Object jsonTotable(String schemaName, String jsonDate, String sql)  {
         // 1. JSON 数据
-        String resValue = "";
+        Object resValue = null;
         try{
             // 2. 使用 Jackson 解析 JSON 数据
             ObjectMapper objectMapper = new ObjectMapper();
@@ -71,21 +70,21 @@ public class JsonToCalciteExample {
             /*resultSet.close();
             statement.close();*/
             //获取域
-            SchemaPlus rootSchemafter = calciteConnection.getRootSchema();
-            //根域中获取子域
-            SchemaPlus childrenSchema=rootSchemafter.getSubSchema("test");
-            //子域名
-            String childrenName = childrenSchema.getName();
-            System.out.println("childrenName: " + childrenName);
-            //子域中表名
-            Set<String> tableNames = childrenSchema.getTableNames();
-            for (String tableName : tableNames) {
-                System.out.println("Table: " + tableName);
-            }
+//            SchemaPlus rootSchemafter = calciteConnection.getRootSchema();
+//            //根域中获取子域
+//            SchemaPlus childrenSchema=rootSchemafter.getSubSchema("test");
+//            //子域名
+//            String childrenName = childrenSchema.getName();
+//            System.out.println("childrenName: " + childrenName);
+//            //子域中表名
+//            Set<String> tableNames = childrenSchema.getTableNames();
+//            for (String tableName : tableNames) {
+//                System.out.println("Table: " + tableName);
+//            }
 
             //调用张艳杰接收连接方法,传参  calciteConnection
             //方法示例
-            IndexCalcUnit model = new IndexCalcUnit("","",Map.of(),new IndexConfigModel());
+            IndexCalcUnit model = new IndexCalcUnit(schemaName,"",Map.of(),new IndexConfigModel());
             resValue = model.getConnectionTable(calciteConnection,sql);
 
             connection.close();

+ 1 - 1
src/main/java/com/sundata/internalevaluation/configuration/controller/SysReqRulesController.java

@@ -78,7 +78,7 @@ public class SysReqRulesController extends BaseAction {
 
     @RequestMapping("testRules")
     public Object testRules(@RequestBody SysReqRules sysReqRules) {
-        return CalcUtil.calcRules("rules"+System.currentTimeMillis(), sysReqRules.getRulesNo(), Map.of("name","zhangsan"));
+        return CalcUtil.calcRules("rules"+System.currentTimeMillis(), sysReqRules.getRulesNo(), Map.of("name","zhangsan","custNo","1"));
     }
     
 }