公式描述
This commit is contained in:
parent
9dc41706b2
commit
3e8ac01049
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
<settings>
|
||||
<setting name="mapUnderscoreToCamelCase" value="true"></setting>
|
||||
<setting name="jdbcTypeForNull" value="NULL"/>
|
||||
</settings>
|
||||
<plugins>
|
||||
<plugin interceptor="weaver.conn.mybatis.MyBatisCachePlugin"></plugin>
|
||||
</plugins>
|
||||
<environments default="development">
|
||||
<environment id="development">
|
||||
<transactionManager type="JDBC"/>
|
||||
<dataSource type="weaver.conn.mybatis.MyBatisDataSourceFactory">
|
||||
</dataSource>
|
||||
</environment>
|
||||
</environments>
|
||||
<databaseIdProvider type="weaver.conn.mybatis.DatabaseIdProvider">
|
||||
</databaseIdProvider>
|
||||
<mappers>
|
||||
<!--mapper resource="MyBatis/mapper/WorkflowBaseMapper.xml"/-->
|
||||
<!--package name="*.mapper"></package 不可行,Mybatis不支持通配符,这是spring的ant匹配模式提供的-->
|
||||
<package name="weaver.conn.mybatis.mapper"></package><!-- 示例Mapper -->
|
||||
|
||||
<!-- 项目Mapper -->
|
||||
<package name="com.weaver.mapper"></package>
|
||||
<package name="weaver.general.mapper"></package>
|
||||
<package name="weaver.hrm.mapper"></package>
|
||||
<package name="weaver.workflow.mapper"></package>
|
||||
<package name="weaver.interfaces.mapper"></package>
|
||||
<package name="weaver.portal.mapper"></package>
|
||||
<package name="com.api.formmode.mybatis.mapper"></package>
|
||||
<package name="com.cloudstore.dev.api.mapper"></package>
|
||||
<package name="com.engine.integration.mapper"></package>
|
||||
<package name="com.engine.salary.mapper"></package>
|
||||
<package name="com.engine.organization.mapper"></package>
|
||||
<!-- 需要把现在的配置文件都调整到WEB-INF/config/mapper目录下 -->
|
||||
<!-- 在WEB-INF/config/mapper目录下配置的xml文件也不必加入这里的package -->
|
||||
</mappers>
|
||||
</configuration>
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,5 @@
|
|||
log=false
|
||||
defaultCloseNonStandard149=true
|
||||
AESEncryptScrect=990EB004A1C862721C1513AE90038C9E
|
||||
version=2.7.3.2304.01
|
||||
openFormulaForcedEditing=false
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,6 +1,5 @@
|
|||
package com.engine.salary.formlua.core;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.salary.formlua.entity.parameter.DataType;
|
||||
import com.engine.salary.formlua.entity.parameter.FuncNames;
|
||||
|
|
@ -16,7 +15,6 @@ import com.engine.salary.formlua.func.math.MathFuncsService;
|
|||
import com.engine.salary.formlua.func.math.MathFuncsServiceImpl;
|
||||
import com.engine.salary.formlua.func.string.StringFormulaService;
|
||||
import com.engine.salary.formlua.func.string.StringFormulaServiceImpl;
|
||||
import com.engine.salary.formlua.util.ExcelParamUtil;
|
||||
import com.engine.salary.formlua.util.ExpressRegularUtil;
|
||||
import com.ql.util.express.DynamicParamsUtil;
|
||||
import com.ql.util.express.ExpressRunner;
|
||||
|
|
@ -29,7 +27,7 @@ import java.util.Map;
|
|||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
/**
|
||||
* 考勤执行业务类
|
||||
* 执行业务类
|
||||
*/
|
||||
public class QlExpress {
|
||||
|
||||
|
|
@ -79,12 +77,11 @@ public class QlExpress {
|
|||
// threadLocalData.setExpressContext(context);
|
||||
// ParamContext.get().setValue("formulaParam",threadLocalData);
|
||||
// ParamContext.get().setValue("currentUser",simpleEmployee);
|
||||
Object obj = null;
|
||||
try {
|
||||
ExpressRegularUtil.checkFuncExpress(expressSql);
|
||||
expressSql = expressSql.replaceAll("\\{", "");
|
||||
expressSql = expressSql.replaceAll("\\}", "");
|
||||
obj = runner.execute(expressSql, expressContext, null, true, false);
|
||||
Object obj = runner.execute(expressSql, expressContext, null, true, false);
|
||||
JSONObject resultObj = new JSONObject();
|
||||
if (obj != null) {
|
||||
resultObj.put("excute", true);
|
||||
|
|
@ -116,58 +113,12 @@ public class QlExpress {
|
|||
}
|
||||
}
|
||||
}
|
||||
JSONObject errorJSON = new JSONObject();
|
||||
if (null == jsonError) {
|
||||
errorJSON.put("error", "参数为空");
|
||||
obj = errorJSON;
|
||||
|
||||
JSONObject resultObj = new JSONObject();
|
||||
resultObj.put("data", "");
|
||||
resultObj.put("excute", false);
|
||||
return resultObj;
|
||||
}
|
||||
try {
|
||||
errorJSON = JSON.parseObject(jsonError);
|
||||
} catch (Exception ex) {
|
||||
errorJSON.put("error", "参数为空");
|
||||
obj = errorJSON;
|
||||
|
||||
JSONObject resultObj = new JSONObject();
|
||||
resultObj.put("data", "");
|
||||
resultObj.put("excute", false);
|
||||
return resultObj;
|
||||
}
|
||||
if (!(e instanceof PatternSyntaxException)) {
|
||||
String func = errorJSON.getString("func");
|
||||
int funcIdx = errorJSON.getInteger("errorFunc");
|
||||
String[] funcSplit = statement.split(func);
|
||||
int startError = 1;
|
||||
int loopLength = funcSplit.length - funcIdx;
|
||||
for (int i = 0; i < loopLength; i++) {
|
||||
if (loopLength > 1 && i == 0) {
|
||||
startError += funcSplit[i].length() + func.length();
|
||||
} else {
|
||||
startError += funcSplit[i].length();
|
||||
}
|
||||
}
|
||||
int startIdx = startError;
|
||||
int endIdx = startError + func.length() - 1;
|
||||
Map<String, Integer> replaceMap = ExcelParamUtil.replaceErrorPlace(startIdx, endIdx, func, expressSql, context);
|
||||
errorJSON.put("errorIdx", replaceMap.get("startIdx"));
|
||||
errorJSON.put("errorEndIdx", replaceMap.get("endIdx"));
|
||||
|
||||
}
|
||||
if (errorJSON.containsKey("error") && null != errorJSON.getString("msg") && !ExpressRegularUtil.isContainChinese(errorJSON.getString("msg"))) {
|
||||
errorJSON.put("error", "校验失败或参数错误");
|
||||
}
|
||||
|
||||
errorJSON.remove("errorFunc");
|
||||
errorJSON.remove("formula");
|
||||
errorJSON.remove("func");
|
||||
errorJSON.remove("errorData");
|
||||
obj = errorJSON;
|
||||
JSONObject resultObj = new JSONObject();
|
||||
resultObj.put("excute", false);
|
||||
resultObj.put("data", "");
|
||||
resultObj.put("err", jsonError);
|
||||
return resultObj;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
private void initRunner(ExpressRunner runner) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package com.engine.salary.formlua.core;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 执行业务类
|
||||
*/
|
||||
public class QlExpressTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
QlExpress express = new QlExpress();
|
||||
Map<String, Object> context = new HashMap<>();
|
||||
context.put("a", 1);
|
||||
context.put("b", 2);
|
||||
context.put("c", 3);
|
||||
String formula = "AGGREGATION(a+b,0,'AVG')";
|
||||
|
||||
Object execute = express.execute(formula, context);
|
||||
if(execute instanceof JSONObject){
|
||||
Object data = ((JSONObject) execute).get("data");
|
||||
System.out.println(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -129,13 +129,12 @@ public class FormulaRunServiceImpl extends Service implements FormulaRunService
|
|||
boolean isCustomFunction = true;
|
||||
|
||||
String extendParam = expressFormula.getExtendParam();
|
||||
String formulaType;
|
||||
try {
|
||||
JsonNode jsonNode = objectMapper.readTree(extendParam);
|
||||
//返回值配置
|
||||
JsonNode isCustomFunctionNode = jsonNode.get("isCustomFunction");
|
||||
if (isCustomFunctionNode != null) {
|
||||
isCustomFunction = StringUtils.equals(isCustomFunctionNode.asText().trim(), "true");
|
||||
isCustomFunction = StringUtils.equals(isCustomFunctionNode.asText().trim(), "1");
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("express execute fail, sql extendParam parse fail", e);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue