From ee84e559e6077ad7215716b834da0bf280530fe4 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Thu, 27 Jul 2023 12:44:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=B8=E7=A7=91=E5=8C=BB=E9=99=A2=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/aiyh/utils/ScriptUtil.java | 10 +++++++++- .../xuanran/wang/xk_hospital/test/XkHospitalTest.java | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/aiyh/utils/ScriptUtil.java b/src/main/java/aiyh/utils/ScriptUtil.java index 6c53d1d..9e59a3d 100644 --- a/src/main/java/aiyh/utils/ScriptUtil.java +++ b/src/main/java/aiyh/utils/ScriptUtil.java @@ -1,5 +1,6 @@ package aiyh.utils; +import aiyh.utils.interfaces.script_util.CusScriptFunInterface; import aiyh.utils.tool.org.apache.commons.jexl3.*; import java.util.Map; @@ -13,9 +14,16 @@ import java.util.Map; */ public class ScriptUtil { private static final JexlEngine JEXL = new JexlBuilder().create(); - + public static Object invokeScript(String script, Map params) { + return invokeScript(script, params, null); + } + + public static Object invokeScript(String script, Map params, CusScriptFunInterface scriptFunInterface) { JexlContext jc = new MapContext(); + if(null != scriptFunInterface){ + jc.set(scriptFunInterface.getClass().getSimpleName(), scriptFunInterface); + } for (Map.Entry entry : params.entrySet()) { jc.set(entry.getKey(), entry.getValue()); } diff --git a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java index 7926f48..827640d 100644 --- a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java +++ b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java @@ -117,4 +117,12 @@ public class XkHospitalTest extends BaseTest { Util.null2DefaultStr(null,""); service.async("4bce0693734d","common", map); } + + @Test + public void testD(){ + String json = "{\"data\":[{\"ID\":\"2\",\"GroupID\":\"test_yl_01\",\"Wards\":[]},{\"ID\":\"1\",\"GroupID\":\"test_yl_01\",\"Wards\":[{\"ID\":\"1\",\"WardCode\":\"bq_01\",\"WardName\":\"病区名称01_1\"},{\"ID\":\"2\",\"WardCode\":\"bq_02\",\"WardName\":\"病区名称01_2\"},{\"ID\":\"3\",\"WardCode\":\"bq_03\",\"WardName\":\"病区名称0_2_3\"},{\"ID\":\"4\",\"WardCode\":\"bq_04\",\"WardName\":\"病区名称02_1_3\"}]}]}\n"; + System.out.println(json); + Map map = JSONObject.parseObject(json, Map.class); + service.async("testarr","common", map); + } }