From b2b5bdf6f42597e582da96aa56707e1f68d3936e Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期二, 10 五月 2022 11:41:44 +0800
Subject: [PATCH] 优化 费用

---
 java110-service/src/main/java/com/java110/service/smo/impl/QueryServiceSMOImpl.java |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/java110-service/src/main/java/com/java110/service/smo/impl/QueryServiceSMOImpl.java b/java110-service/src/main/java/com/java110/service/smo/impl/QueryServiceSMOImpl.java
index 5ae8d2d..2ddb2f3 100755
--- a/java110-service/src/main/java/com/java110/service/smo/impl/QueryServiceSMOImpl.java
+++ b/java110-service/src/main/java/com/java110/service/smo/impl/QueryServiceSMOImpl.java
@@ -18,12 +18,13 @@
 import com.java110.utils.util.StringUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.ognl.Ognl;
+import org.apache.ibatis.ognl.OgnlContext;
 import org.apache.ibatis.ognl.OgnlException;
 import org.dom4j.DocumentException;
 import org.dom4j.DocumentHelper;
 import org.dom4j.Element;
 import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.java110.core.log.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -341,6 +342,25 @@
         }
     }
 
+    /**
+     * 鎵цjava鑴氭湰
+     *
+     * @param javaCode
+     * @throws BusinessException
+     */
+    public JSONObject execJava(JSONObject params, String javaCode) throws BusinessException {
+        try {
+            //JSONObject params = dataQuery.getRequestParams();
+            Interpreter interpreter = new Interpreter();
+            interpreter.eval(javaCode);
+            interpreter.set("params", params);
+            return JSONObject.parseObject(interpreter.eval("execute(dataQuery)").toString());
+        } catch (Exception e) {
+            logger.error("鏁版嵁浜や簰寮傚父锛�", e);
+            throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR, "鏁版嵁浜や簰寮傚父," + e.getMessage());
+        }
+    }
+
     @Override
     public JSONObject execQuerySql(JSONObject params, String currentSql) throws BusinessException {
         List<Map<String, Object>> results = null;
@@ -430,7 +450,9 @@
 
             Object condObj = Ognl.parseExpression(condition);
 
-            Object value = Ognl.getValue(condObj, requestParams);
+            OgnlContext context = new OgnlContext(null,null,new DefaultMemberAccess(true));
+
+            Object value = Ognl.getValue(condObj,context, requestParams);
 
             if (value instanceof Boolean) {
                 conditionResult = (Boolean) value;

--
Gitblit v1.8.0