From f989336efe8cce86b7732524812a60a8d5c62a94 Mon Sep 17 00:00:00 2001 From: richie Date: Mon, 21 Dec 2020 17:12:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/cal/ParameterKit.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/com/fanruan/api/cal/ParameterKit.java b/src/main/java/com/fanruan/api/cal/ParameterKit.java index d399884..e2fc4a8 100644 --- a/src/main/java/com/fanruan/api/cal/ParameterKit.java +++ b/src/main/java/com/fanruan/api/cal/ParameterKit.java @@ -2,16 +2,19 @@ package com.fanruan.api.cal; import com.fanruan.api.util.ArrayKit; import com.fanruan.api.util.AssistKit; +import com.fr.base.DataSetFunctionParameterMapNameSpace; import com.fr.base.Parameter; import com.fr.base.ParameterHelper; import com.fr.base.ParameterMapNameSpace; import com.fr.base.ParameterTypeHandler; +import com.fr.base.TemplateUtils; import com.fr.data.impl.TableColumn; import com.fr.general.DateUtils; import com.fr.json.JSON; import com.fr.json.JSONArray; import com.fr.json.JSONFactory; import com.fr.json.JSONObject; +import com.fr.script.Calculator; import com.fr.stable.ArrayUtils; import com.fr.stable.ParameterProvider; import com.fr.stable.script.NameSpace; @@ -144,6 +147,22 @@ public class ParameterKit { return parameters; } + /** + * 增加处理数据集间联系,例如:select * from t where time=${today()} + * + * @param text 原文本字符串 + * @param parameters 参数集合 + * @return 新的文本字符串 + */ + public static String analyzeCurrentContextTableData4Template(String text, ParameterProvider[] parameters) { + Calculator c = Calculator.createCalculator(); + NameSpace ns = DataSetFunctionParameterMapNameSpace.creat(parameters); + c.pushNameSpace(ns); + String str = TemplateUtils.renderTpl(c, text); + c.removeNameSpace(ns); + return str; + } + /** * 从JSON中解析出来参数信息 *