java110
2022-06-15 6a259fd0c1559aab8813b805d67c72111e20476e
java110-service/src/main/java/com/java110/service/smo/impl/QueryServiceSMOImpl.java
@@ -4,6 +4,7 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import com.alibaba.fastjson.parser.Feature;
import com.java110.core.factory.DataTransactionFactory;
import com.java110.db.dao.IQueryServiceDAO;
import com.java110.entity.service.ServiceSql;
@@ -18,12 +19,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;
@@ -350,10 +352,32 @@
    public JSONObject execJava(JSONObject params, String javaCode) throws BusinessException {
        try {
            //JSONObject params = dataQuery.getRequestParams();
            List<String> columns = new ArrayList<>();
            Interpreter interpreter = new Interpreter();
            interpreter.eval(javaCode);
            interpreter.set("params", params);
            return JSONObject.parseObject(interpreter.eval("execute(dataQuery)").toString());
            interpreter.set("queryServiceDAOImpl",queryServiceDAOImpl);
            JSONObject results = JSONObject.parseObject(interpreter.eval("execute(params,queryServiceDAOImpl)").toString(), Feature.OrderedField);
            JSONArray data = null;
            if (results == null || results.size() < 1) {
                data = new JSONArray();
            } else {
                data = results.getJSONArray("data");
            }
            JSONArray th = new JSONArray();
            if(data.size()>0) {
                for (String key : data.getJSONObject(0).keySet()) {
                    th.add(key);
                }
            }
            JSONObject paramOut = new JSONObject();
            paramOut.put("th", th);
            paramOut.put("td", data);
            paramOut.put("total",results.getString("total"));
            return paramOut;
        } catch (Exception e) {
            logger.error("数据交互异常:", e);
            throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR, "数据交互异常," + e.getMessage());
@@ -449,7 +473,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;