Package Com.bfrj.core.groovy;import Java.util.hashmap;import Java.util.map;import Org.jeecgframework.core.util.applicationcontextutil;import org.springframework.context.applicationcontext;/** * Formula Calculation * */public class Groovyparse {/** * formula parsing calculation */public static Object formulaparse (String formula, map<string, OBJ Ect> map) {ApplicationContext context = Applicationcontextutil.getcontext (); Groovyscriptengine groovyscriptengine = Context.getbean (groovyscriptengine.class), Object value = Groovyscriptengine.executeobject (formula, map); return value;} public static void Main (string[] args) {String formula = "Return (A * b);"; Map map = new HashMap (); Map.put ("A", "10"); Map.put ("B"; Groovyscriptengine groovyscriptengine = new Groovyscriptengine (); Object value = Groovyscriptengine.executeobject ( formula, map); System.out.println (value);}}
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
Assuming that Java text is running dynamically when in scripted configuration, this is very handy