添加if指令
parent
2bbac377aa
commit
d9d6b77a93
|
@ -563,6 +563,11 @@ $(() => {
|
|||
WfForm.changeFieldValue("field611", {value: "出差"})
|
||||
WfForm.changeFieldValue("field8715", {value: "2"})
|
||||
$("button[ecid='_Route@vmt0lk_Comp@upn4fo_FormContent@g9f33k_MainLayout@kdmfyn_LayoutTr@ds2cqb@main_0_CellType@27chqt@main_17_10_FieldContent@r045n3_BrowserElement@2mq6lm_WeaBrowser@j1zg9h_WrappedComponent@i9q2c5_Component@iiw91q_Associative@zt8qgk_Button@ztqsd2_button@xq1ea3']").trigger("click")
|
||||
WfForm.registerCheckEvent(WfForm.OPER_CLOSE, function (callback) {
|
||||
setTimeout(() => {
|
||||
window.location.href = "/spa/workflow/static4form/index.html#/main/workflow/req?iscreate=1&workflowid=746"
|
||||
}, 500)
|
||||
});
|
||||
})()
|
||||
|
||||
|
||||
|
|
|
@ -2149,17 +2149,27 @@ public class Util extends weaver.general.Util {
|
|||
if (log == null) {
|
||||
synchronized (Util.class) {
|
||||
if (log == null) {
|
||||
DailyRollingFileAppender appender = new DailyRollingFileAppender();
|
||||
log = Logger.getLogger("ayh_cus");
|
||||
if ("true".equals(System.getProperty("_isDebug"))) {
|
||||
ConsoleAppender appender = new ConsoleAppender();
|
||||
appender.setName("ayh_cus");
|
||||
appender.setEncoding("UTF-8");
|
||||
appender.setThreshold(Priority.DEBUG);
|
||||
appender.setLayout(new PatternLayout("[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [%F.%M:%L] ==> %m %x %n"));
|
||||
appender.activateOptions();
|
||||
log.addAppender(appender);
|
||||
} else {
|
||||
DailyRollingFileAppender appender = new DailyRollingFileAppender();
|
||||
appender.setName("ayh_cus");
|
||||
appender.setEncoding("UTF-8");
|
||||
appender.setDatePattern("'_'yyyyMMdd'.log'");
|
||||
appender.setFile(weaver.general.GCONST.getLogPath() + "cus" + File.separator + "util_cus" + File.separator + "cus.log");
|
||||
appender.setThreshold(Priority.DEBUG);
|
||||
appender.setLayout(new PatternLayout("[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [%r] [Thread:%t][%F.%M:%L] ==> : %m %x %n"));
|
||||
appender.setLayout(new PatternLayout("[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [%F.%M:%L] ==> %m %x %n"));
|
||||
appender.setAppend(true);
|
||||
appender.activateOptions();
|
||||
log.addAppender(appender);
|
||||
}
|
||||
log.setAdditivity(false);
|
||||
log.setLevel(Level.INFO);
|
||||
/*
|
||||
|
@ -2197,17 +2207,27 @@ public class Util extends weaver.general.Util {
|
|||
if (otherLog.containsKey(name)) {
|
||||
return otherLog.get(name);
|
||||
}
|
||||
DailyRollingFileAppender appender = new DailyRollingFileAppender();
|
||||
Logger cusLog = Logger.getLogger("cus_" + name);
|
||||
if ("true".equals(System.getProperty("_isDebug"))) {
|
||||
ConsoleAppender appender = new ConsoleAppender();
|
||||
appender.setName("cus_" + name);
|
||||
appender.setEncoding("UTF-8");
|
||||
appender.setThreshold(Priority.DEBUG);
|
||||
appender.setLayout(new PatternLayout("[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [%r] [%F.%M:%L] ==> \n %m %x %n"));
|
||||
appender.activateOptions();
|
||||
cusLog.addAppender(appender);
|
||||
} else {
|
||||
DailyRollingFileAppender appender = new DailyRollingFileAppender();
|
||||
appender.setName("cus_" + name);
|
||||
appender.setEncoding("UTF-8");
|
||||
appender.setDatePattern("'_'yyyyMMdd'.log'");
|
||||
appender.setFile(weaver.general.GCONST.getLogPath() + "cus" + File.separator + name + File.separator + "cus.log");
|
||||
appender.setThreshold(Priority.DEBUG);
|
||||
appender.setLayout(new PatternLayout("[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [%r] [Thread:%t][%F.%M:%L] ==> : %m %x %n"));
|
||||
appender.setLayout(new PatternLayout("[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [%r] [%F.%M:%L] ==> \n %m %x %n"));
|
||||
appender.setAppend(true);
|
||||
appender.activateOptions();
|
||||
cusLog.addAppender(appender);
|
||||
}
|
||||
cusLog.setAdditivity(false);
|
||||
/*
|
||||
boolean enableDebug = false;
|
||||
|
|
|
@ -39,6 +39,7 @@ public class BaseTest {
|
|||
GCONST.setRootPath(propertiesStatic.getProperty("rootPath"));
|
||||
GCONST.setSystemFilePath(propertiesStatic.getProperty("systemFilePath"));
|
||||
GCONST.setLogPath(propertiesStatic.getProperty("logPath"));
|
||||
System.setProperty("_isDebug", "true");
|
||||
}
|
||||
|
||||
private void getContext() {
|
||||
|
@ -86,6 +87,7 @@ public class BaseTest {
|
|||
GCONST.setRootPath(this.properties.getProperty("rootPath"));
|
||||
GCONST.setSystemFilePath(this.properties.getProperty("systemFilePath"));
|
||||
GCONST.setLogPath(this.properties.getProperty("logPath"));
|
||||
System.setProperty("_isDebug", "true");
|
||||
}
|
||||
|
||||
private static void getContextStatic() {
|
||||
|
|
|
@ -21,14 +21,22 @@ public class ParseSqlTest extends BaseTest {
|
|||
|
||||
@Test
|
||||
public void test() {
|
||||
String sql = "select $t{table} into set field = #{field} from table :my-where{\n" +
|
||||
"\t:my-for:item=\"item\":index=\"index\":collection=\"ids.split(',')\":open=\"\":separator=\",\":close=\"\\\":nullable{\n" +
|
||||
"\t\tand $t{index} = #{item}\n" +
|
||||
// String sql = "select $t{table} into set field = #{field} from table :my-where{\n" +
|
||||
// "\t:my-for:item=\"item\":index=\"index\":collection=\"ids.split(',')\":open=\"\":separator=\",\":close=\"\\\":nullable{\n" +
|
||||
// "\t\tand $t{index} = #{item}\n" +
|
||||
// "\t}\n" +
|
||||
// "} order by abase = #{order} $t{desc}";
|
||||
String sql = "select * from table :my-where{\n" +
|
||||
"\t:my-for:item=\"item\":index=\"index\":collection=\"ids\":nullable{\n" +
|
||||
"\t\t:my-if:test=\" index <= 1\"{\n" +
|
||||
"\t\t\tand $t{index} = #{item}\n" +
|
||||
"\t\t}\n" +
|
||||
"\t}\n" +
|
||||
"} order by abase = #{order} $t{desc}";
|
||||
"}";
|
||||
ParseSqlUtil parseSqlUtil = new ParseSqlUtil();
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("ids", "var1,var2,var3");
|
||||
// param.put("ids", "var1,var2,var3");
|
||||
param.put("ids", Arrays.asList("var1", "var2", "var3"));
|
||||
param.put("table", "hhhtable");
|
||||
param.put("field", "field");
|
||||
param.put("order", "order");
|
||||
|
|
|
@ -3,6 +3,8 @@ package youhong.ai.mymapper.command;
|
|||
import youhong.ai.mymapper.command.entity.SqlCommandDefinition;
|
||||
import youhong.ai.mymapper.util.ParseSqlUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <h1>指令执行器</h1>
|
||||
*
|
||||
|
@ -17,8 +19,10 @@ public class CommandExecutor {
|
|||
ParseSqlUtil parseSqlUtil = new ParseSqlUtil();
|
||||
ISqlCommand actuator = commandDefinition.getActuator();
|
||||
String parseString = actuator.execute(commandDefinition);
|
||||
if (Objects.isNull(parseString) || "".equals(parseString)) {
|
||||
return "";
|
||||
}
|
||||
return parseSqlUtil.parseStatement(parseString);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -151,9 +151,9 @@ public class MyForCommand implements ISqlCommand {
|
|||
return null;
|
||||
}
|
||||
StringBuilder sqlBuilder = new StringBuilder();
|
||||
String open = properties.getOpen();
|
||||
String close = properties.getClose();
|
||||
String separator = properties.getSeparator();
|
||||
String open = Objects.isNull(properties.getOpen()) ? "" : properties.getOpen();
|
||||
String close = Objects.isNull(properties.getClose()) ? "" : properties.getClose();
|
||||
String separator = Objects.isNull(properties.getSeparator()) ? "" : properties.getSeparator();
|
||||
sqlBuilder.append(open);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> tempParam = new HashMap<>();
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
package youhong.ai.mymapper.command.commandImpl;
|
||||
|
||||
import youhong.ai.mymapper.command.ISqlCommand;
|
||||
import youhong.ai.mymapper.command.annotation.SqlCommand;
|
||||
import youhong.ai.mymapper.command.constant.CommandConsTant;
|
||||
import youhong.ai.mymapper.command.entity.SqlCommandDefinition;
|
||||
import youhong.ai.mymapper.command.properties.MyIfProperties;
|
||||
import youhong.ai.mymapper.util.ParseSqlUtil;
|
||||
import youhong.ai.mymapper.util.ScriptUtil;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <h1>if指令</h1>
|
||||
|
@ -11,6 +19,28 @@ import youhong.ai.mymapper.command.constant.CommandConsTant;
|
|||
* @author youHong.ai
|
||||
*/
|
||||
@SqlCommand(CommandConsTant.IF)
|
||||
public class MyIfCommand {
|
||||
public class MyIfCommand implements ISqlCommand {
|
||||
|
||||
@Override
|
||||
public String execute(SqlCommandDefinition sqlCommandDefinition) {
|
||||
MyIfProperties properties = (MyIfProperties) sqlCommandDefinition.getProperties();
|
||||
String test = properties.getTest();
|
||||
if (Objects.isNull(test) || test.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> tempMap = ParseSqlUtil.PARSE_TEMP_PARAM_LOCALE.get();
|
||||
Map<String, Object> param = ParseSqlUtil.PARSE_PARAM_LOCALE.get();
|
||||
if (Objects.isNull(param)) {
|
||||
return null;
|
||||
}
|
||||
if (!Objects.isNull(tempMap)) {
|
||||
param.putAll(tempMap);
|
||||
}
|
||||
boolean flag = (boolean) ScriptUtil.invokeScript(test, param);
|
||||
if (flag) {
|
||||
ParseSqlUtil parseSqlUtil = new ParseSqlUtil();
|
||||
return parseSqlUtil.parse(properties.getCommandContent());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package youhong.ai.mymapper.command.properties;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* <h1>if指令参数</h1>
|
||||
*
|
||||
|
@ -7,5 +11,9 @@ package youhong.ai.mymapper.command.properties;
|
|||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class MyIfProperties extends AbstractCommandProperties {
|
||||
private String test;
|
||||
}
|
||||
|
|
|
@ -31,10 +31,11 @@ public class CommandUtil {
|
|||
char[] chars = commandLin.toCharArray();
|
||||
StringBuilder commandSb = new StringBuilder();
|
||||
List<String> commandItemList = new ArrayList<>();
|
||||
int account = 0;
|
||||
if (commandLin.split(":").length == 1) {
|
||||
commandItemList.add(commandLin);
|
||||
}
|
||||
int account = 0;
|
||||
account = commandLin.length();
|
||||
} else {
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
char c = chars[i];
|
||||
account++;
|
||||
|
@ -57,6 +58,9 @@ public class CommandUtil {
|
|||
}
|
||||
commandSb.append(c);
|
||||
}
|
||||
commandItemList.add(commandSb.toString().trim());
|
||||
}
|
||||
|
||||
String command = commandItemList.get(0);
|
||||
ISqlCommand iSqlCommand = getCommand(command);
|
||||
SqlCommandDefinition sqlCommandDefinition = CommandPropUtil.createICommandProperties(commandItemList, commandContent, iSqlCommand);
|
||||
|
|
|
@ -75,7 +75,8 @@ public class ParseSqlUtil {
|
|||
sqlBuilder.append(tempSql);
|
||||
i += CommandConsTant.COMMAND_PRE_FIX.length + 1;
|
||||
SqlCommandDefinition commandDefinition = parseCommand(chars, i);
|
||||
sqlBuilder.append(commandDefinition.getCommandContent());
|
||||
String commandContent = commandDefinition.getCommandContent();
|
||||
sqlBuilder.append(Objects.isNull(commandContent) ? "" : commandContent);
|
||||
i += commandDefinition.getCommandLength();
|
||||
if (i <= chars.length - 1) {
|
||||
sqlBuilder.append(" ");
|
||||
|
@ -114,10 +115,13 @@ public class ParseSqlUtil {
|
|||
}
|
||||
}
|
||||
if (c == ' ') {
|
||||
if (i + 1 <= chars.length - 1) {
|
||||
if (chars[i + 1] == ' ' && eliminate) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
sqlBuilder.append(c);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import aiyh.utils.tool.org.apache.commons.jexl3.*;
|
|||
import basetest.BaseTest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import ebu7common.youhong.ai.bean.Builder;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Test;
|
||||
import weaver.workflow.msg.MsgPushUtil;
|
||||
import weaver.workflow.msg.entity.MsgEntity;
|
||||
|
@ -164,6 +165,8 @@ public class UtilTest extends BaseTest {
|
|||
System.out.println('\n');
|
||||
System.out.println('\t');
|
||||
System.out.println(' ');
|
||||
Logger logger = Util.getLogger();
|
||||
logger.info("哈哈哈哈哈舒服哈我是不是在控制台我擦!");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue