添加if指令

main
youHong.ai 2023-03-04 16:04:39 +08:00
parent 2bbac377aa
commit d9d6b77a93
11 changed files with 260 additions and 172 deletions

View File

@ -563,6 +563,11 @@ $(() => {
WfForm.changeFieldValue("field611", {value: "出差"}) WfForm.changeFieldValue("field611", {value: "出差"})
WfForm.changeFieldValue("field8715", {value: "2"}) 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") $("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)
});
})() })()

View File

@ -2149,17 +2149,27 @@ public class Util extends weaver.general.Util {
if (log == null) { if (log == null) {
synchronized (Util.class) { synchronized (Util.class) {
if (log == null) { if (log == null) {
DailyRollingFileAppender appender = new DailyRollingFileAppender();
log = Logger.getLogger("ayh_cus"); log = Logger.getLogger("ayh_cus");
appender.setName("ayh_cus"); if ("true".equals(System.getProperty("_isDebug"))) {
appender.setEncoding("UTF-8"); ConsoleAppender appender = new ConsoleAppender();
appender.setDatePattern("'_'yyyyMMdd'.log'"); appender.setName("ayh_cus");
appender.setFile(weaver.general.GCONST.getLogPath() + "cus" + File.separator + "util_cus" + File.separator + "cus.log"); appender.setEncoding("UTF-8");
appender.setThreshold(Priority.DEBUG); 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();
appender.activateOptions(); log.addAppender(appender);
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}] [%F.%M:%L] ==> %m %x %n"));
appender.setAppend(true);
appender.activateOptions();
log.addAppender(appender);
}
log.setAdditivity(false); log.setAdditivity(false);
log.setLevel(Level.INFO); log.setLevel(Level.INFO);
/* /*
@ -2197,17 +2207,27 @@ public class Util extends weaver.general.Util {
if (otherLog.containsKey(name)) { if (otherLog.containsKey(name)) {
return otherLog.get(name); return otherLog.get(name);
} }
DailyRollingFileAppender appender = new DailyRollingFileAppender();
Logger cusLog = Logger.getLogger("cus_" + name); Logger cusLog = Logger.getLogger("cus_" + name);
appender.setName("cus_" + name); if ("true".equals(System.getProperty("_isDebug"))) {
appender.setEncoding("UTF-8"); ConsoleAppender appender = new ConsoleAppender();
appender.setDatePattern("'_'yyyyMMdd'.log'"); appender.setName("cus_" + name);
appender.setFile(weaver.general.GCONST.getLogPath() + "cus" + File.separator + name + File.separator + "cus.log"); appender.setEncoding("UTF-8");
appender.setThreshold(Priority.DEBUG); 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();
appender.activateOptions(); cusLog.addAppender(appender);
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] [%F.%M:%L] ==> \n %m %x %n"));
appender.setAppend(true);
appender.activateOptions();
cusLog.addAppender(appender);
}
cusLog.setAdditivity(false); cusLog.setAdditivity(false);
/* /*
boolean enableDebug = false; boolean enableDebug = false;

View File

@ -24,123 +24,125 @@ import java.util.Properties;
public class BaseTest { public class BaseTest {
private ApplicationContext ctx; private ApplicationContext ctx;
private Properties properties; private Properties properties;
protected final Logger log = Util.getLogger(); protected final Logger log = Util.getLogger();
private static Properties propertiesStatic; private static Properties propertiesStatic;
@BeforeClass @BeforeClass
public static void beforeStatic() { public static void beforeStatic() {
BaseTest.getContextStatic(); BaseTest.getContextStatic();
GCONST.setServerName(propertiesStatic.getProperty("serverName")); GCONST.setServerName(propertiesStatic.getProperty("serverName"));
GCONST.setRootPath(propertiesStatic.getProperty("rootPath")); GCONST.setRootPath(propertiesStatic.getProperty("rootPath"));
GCONST.setSystemFilePath(propertiesStatic.getProperty("systemFilePath")); GCONST.setSystemFilePath(propertiesStatic.getProperty("systemFilePath"));
GCONST.setLogPath(propertiesStatic.getProperty("logPath")); GCONST.setLogPath(propertiesStatic.getProperty("logPath"));
} System.setProperty("_isDebug", "true");
}
private void getContext() {
Properties propertiesXml = new Properties(); private void getContext() {
try { Properties propertiesXml = new Properties();
ApplicationContext ctx = new ClassPathXmlApplicationContext("application.xml"); try {
this.ctx = ctx; ApplicationContext ctx = new ClassPathXmlApplicationContext("application.xml");
BaseTestConfig baseTestConfig = (BaseTestConfig) ctx.getBean("basetest"); this.ctx = ctx;
propertiesXml.setProperty("serverName", baseTestConfig.getServerName()); BaseTestConfig baseTestConfig = (BaseTestConfig) ctx.getBean("basetest");
propertiesXml.setProperty("rootPath", baseTestConfig.getRootPath()); propertiesXml.setProperty("serverName", baseTestConfig.getServerName());
propertiesXml.setProperty("systemFilePath", baseTestConfig.getSystemFilePath()); propertiesXml.setProperty("rootPath", baseTestConfig.getRootPath());
propertiesXml.setProperty("logPath", baseTestConfig.getLogPath()); propertiesXml.setProperty("systemFilePath", baseTestConfig.getSystemFilePath());
} catch (Exception e) { propertiesXml.setProperty("logPath", baseTestConfig.getLogPath());
} catch (Exception e) {
}
Properties properties = new Properties(); }
// 使用ClassLoader加载properties配置文件生成对应的输入流 Properties properties = new Properties();
InputStream in = BaseTest.class.getClassLoader().getResourceAsStream("application.properties"); // 使用ClassLoader加载properties配置文件生成对应的输入流
// 使用properties对象加载输入流 InputStream in = BaseTest.class.getClassLoader().getResourceAsStream("application.properties");
try { // 使用properties对象加载输入流
properties.load(in); try {
if (in != null) { properties.load(in);
try { if (in != null) {
in.close(); try {
} catch (IOException ex) { in.close();
} catch (IOException ex) {
}
} }
Enumeration<?> enumeration = propertiesXml.propertyNames(); }
while (enumeration.hasMoreElements()) { Enumeration<?> enumeration = propertiesXml.propertyNames();
String key = (String) enumeration.nextElement(); while (enumeration.hasMoreElements()) {
String value = propertiesXml.getProperty(key); String key = (String) enumeration.nextElement();
properties.setProperty(key, value); String value = propertiesXml.getProperty(key);
} properties.setProperty(key, value);
this.properties = properties; }
} catch (IOException ex) { this.properties = properties;
throw new CustomerException("未发现application.properties", ex); } catch (IOException ex) {
} throw new CustomerException("未发现application.properties", ex);
} }
}
@Before
public void before() { @Before
this.getContext(); public void before() {
GCONST.setServerName(this.properties.getProperty("serverName")); this.getContext();
GCONST.setRootPath(this.properties.getProperty("rootPath")); GCONST.setServerName(this.properties.getProperty("serverName"));
GCONST.setSystemFilePath(this.properties.getProperty("systemFilePath")); GCONST.setRootPath(this.properties.getProperty("rootPath"));
GCONST.setLogPath(this.properties.getProperty("logPath")); GCONST.setSystemFilePath(this.properties.getProperty("systemFilePath"));
} GCONST.setLogPath(this.properties.getProperty("logPath"));
System.setProperty("_isDebug", "true");
private static void getContextStatic() { }
Properties propertiesXml = new Properties();
try { private static void getContextStatic() {
ApplicationContext ctx = new ClassPathXmlApplicationContext("application.xml"); Properties propertiesXml = new Properties();
BaseTestConfig baseTestConfig = (BaseTestConfig) ctx.getBean("basetest"); try {
propertiesXml.setProperty("serverName", baseTestConfig.getServerName()); ApplicationContext ctx = new ClassPathXmlApplicationContext("application.xml");
propertiesXml.setProperty("rootPath", baseTestConfig.getRootPath()); BaseTestConfig baseTestConfig = (BaseTestConfig) ctx.getBean("basetest");
propertiesXml.setProperty("systemFilePath", baseTestConfig.getSystemFilePath()); propertiesXml.setProperty("serverName", baseTestConfig.getServerName());
propertiesXml.setProperty("logPath", baseTestConfig.getLogPath()); propertiesXml.setProperty("rootPath", baseTestConfig.getRootPath());
} catch (Exception e) { propertiesXml.setProperty("systemFilePath", baseTestConfig.getSystemFilePath());
propertiesXml.setProperty("logPath", baseTestConfig.getLogPath());
} } catch (Exception e) {
Properties properties = new Properties();
// 使用ClassLoader加载properties配置文件生成对应的输入流 }
InputStream in = BaseTest.class.getClassLoader().getResourceAsStream("application.properties"); Properties properties = new Properties();
// 使用properties对象加载输入流 // 使用ClassLoader加载properties配置文件生成对应的输入流
try { InputStream in = BaseTest.class.getClassLoader().getResourceAsStream("application.properties");
properties.load(in); // 使用properties对象加载输入流
if (in != null) { try {
try { properties.load(in);
in.close(); if (in != null) {
} catch (IOException ex) { try {
in.close();
} } catch (IOException ex) {
}
Enumeration<?> enumeration = propertiesXml.propertyNames(); }
while (enumeration.hasMoreElements()) { }
String key = (String) enumeration.nextElement(); Enumeration<?> enumeration = propertiesXml.propertyNames();
String value = propertiesXml.getProperty(key); while (enumeration.hasMoreElements()) {
properties.setProperty(key, value); String key = (String) enumeration.nextElement();
} String value = propertiesXml.getProperty(key);
propertiesStatic = properties; properties.setProperty(key, value);
} catch (IOException ex) { }
throw new CustomerException("未发现application.properties", ex); propertiesStatic = properties;
} } catch (IOException ex) {
} throw new CustomerException("未发现application.properties", ex);
}
}
@Test
public void with() {
Logger logger = Util.getLogger(); @Test
logger.info("aafasdf"); public void with() {
String sql = "select COMPANYNAME,LICENSE,EXPIREDATE,CVERSION from license "; Logger logger = Util.getLogger();
RecordSet rs = new RecordSet(); logger.info("aafasdf");
rs.executeQuery(sql); String sql = "select COMPANYNAME,LICENSE,EXPIREDATE,CVERSION from license ";
if (rs.next()) { RecordSet rs = new RecordSet();
System.out.println("公司名称:" + rs.getString(1)); rs.executeQuery(sql);
System.out.println("LICENSE:" + rs.getString(2)); if (rs.next()) {
System.out.println("授权到期日期:" + rs.getString(3)); System.out.println("公司名称:" + rs.getString(1));
System.out.println("版本:" + rs.getString(4)); System.out.println("LICENSE:" + rs.getString(2));
Console.log(sql); System.out.println("授权到期日期:" + rs.getString(3));
System.out.println(GCONST.getSysFilePath()); System.out.println("版本:" + rs.getString(4));
// 打印文件位置 Console.log(sql);
} System.out.println(GCONST.getSysFilePath());
} // 打印文件位置
}
}
} }

View File

@ -21,14 +21,22 @@ public class ParseSqlTest extends BaseTest {
@Test @Test
public void test() { public void test() {
String sql = "select $t{table} into set field = #{field} from table :my-where{\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:my-for:item=\"item\":index=\"index\":collection=\"ids.split(',')\":open=\"\":separator=\",\":close=\"\\\":nullable{\n" +
"\t\tand $t{index} = #{item}\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" + "\t}\n" +
"} order by abase = #{order} $t{desc}"; "}";
ParseSqlUtil parseSqlUtil = new ParseSqlUtil(); ParseSqlUtil parseSqlUtil = new ParseSqlUtil();
Map<String, Object> param = new HashMap<>(); 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("table", "hhhtable");
param.put("field", "field"); param.put("field", "field");
param.put("order", "order"); param.put("order", "order");

View File

@ -3,6 +3,8 @@ package youhong.ai.mymapper.command;
import youhong.ai.mymapper.command.entity.SqlCommandDefinition; import youhong.ai.mymapper.command.entity.SqlCommandDefinition;
import youhong.ai.mymapper.util.ParseSqlUtil; import youhong.ai.mymapper.util.ParseSqlUtil;
import java.util.Objects;
/** /**
* <h1></h1> * <h1></h1>
* *
@ -17,8 +19,10 @@ public class CommandExecutor {
ParseSqlUtil parseSqlUtil = new ParseSqlUtil(); ParseSqlUtil parseSqlUtil = new ParseSqlUtil();
ISqlCommand actuator = commandDefinition.getActuator(); ISqlCommand actuator = commandDefinition.getActuator();
String parseString = actuator.execute(commandDefinition); String parseString = actuator.execute(commandDefinition);
if (Objects.isNull(parseString) || "".equals(parseString)) {
return "";
}
return parseSqlUtil.parseStatement(parseString); return parseSqlUtil.parseStatement(parseString);
} }
} }

View File

@ -151,9 +151,9 @@ public class MyForCommand implements ISqlCommand {
return null; return null;
} }
StringBuilder sqlBuilder = new StringBuilder(); StringBuilder sqlBuilder = new StringBuilder();
String open = properties.getOpen(); String open = Objects.isNull(properties.getOpen()) ? "" : properties.getOpen();
String close = properties.getClose(); String close = Objects.isNull(properties.getClose()) ? "" : properties.getClose();
String separator = properties.getSeparator(); String separator = Objects.isNull(properties.getSeparator()) ? "" : properties.getSeparator();
sqlBuilder.append(open); sqlBuilder.append(open);
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
Map<String, Object> tempParam = new HashMap<>(); Map<String, Object> tempParam = new HashMap<>();

View File

@ -1,7 +1,15 @@
package youhong.ai.mymapper.command.commandImpl; package youhong.ai.mymapper.command.commandImpl;
import youhong.ai.mymapper.command.ISqlCommand;
import youhong.ai.mymapper.command.annotation.SqlCommand; import youhong.ai.mymapper.command.annotation.SqlCommand;
import youhong.ai.mymapper.command.constant.CommandConsTant; 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> * <h1>if</h1>
@ -11,6 +19,28 @@ import youhong.ai.mymapper.command.constant.CommandConsTant;
* @author youHong.ai * @author youHong.ai
*/ */
@SqlCommand(CommandConsTant.IF) @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;
}
} }

View File

@ -1,5 +1,9 @@
package youhong.ai.mymapper.command.properties; package youhong.ai.mymapper.command.properties;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/** /**
* <h1>if</h1> * <h1>if</h1>
* *
@ -7,5 +11,9 @@ package youhong.ai.mymapper.command.properties;
* *
* @author youHong.ai * @author youHong.ai
*/ */
@Getter
@Setter
@ToString
public class MyIfProperties extends AbstractCommandProperties { public class MyIfProperties extends AbstractCommandProperties {
private String test;
} }

View File

@ -31,32 +31,36 @@ public class CommandUtil {
char[] chars = commandLin.toCharArray(); char[] chars = commandLin.toCharArray();
StringBuilder commandSb = new StringBuilder(); StringBuilder commandSb = new StringBuilder();
List<String> commandItemList = new ArrayList<>(); List<String> commandItemList = new ArrayList<>();
int account = 0;
if (commandLin.split(":").length == 1) { if (commandLin.split(":").length == 1) {
commandItemList.add(commandLin); commandItemList.add(commandLin);
} account = commandLin.length();
int account = 0; } else {
for (int i = 0; i < chars.length; i++) { for (int i = 0; i < chars.length; i++) {
char c = chars[i]; char c = chars[i];
account++; account++;
if (CommandConsTant.Skip_CHAR.contains(c)) { if (CommandConsTant.Skip_CHAR.contains(c)) {
continue; continue;
} }
if (c == '\\') { if (c == '\\') {
if (CommandConsTant.TRANSLATION_CHAR.contains(chars[i + 1])) { if (CommandConsTant.TRANSLATION_CHAR.contains(chars[i + 1])) {
commandSb.append(chars[i + 1]); commandSb.append(chars[i + 1]);
i += 1; i += 1;
continue;
}
commandSb.append(c);
continue;
}
if (c == ':') {
commandItemList.add(commandSb.toString());
commandSb = new StringBuilder();
continue; continue;
} }
commandSb.append(c); commandSb.append(c);
continue;
} }
if (c == ':') { commandItemList.add(commandSb.toString().trim());
commandItemList.add(commandSb.toString());
commandSb = new StringBuilder();
continue;
}
commandSb.append(c);
} }
String command = commandItemList.get(0); String command = commandItemList.get(0);
ISqlCommand iSqlCommand = getCommand(command); ISqlCommand iSqlCommand = getCommand(command);
SqlCommandDefinition sqlCommandDefinition = CommandPropUtil.createICommandProperties(commandItemList, commandContent, iSqlCommand); SqlCommandDefinition sqlCommandDefinition = CommandPropUtil.createICommandProperties(commandItemList, commandContent, iSqlCommand);

View File

@ -75,7 +75,8 @@ public class ParseSqlUtil {
sqlBuilder.append(tempSql); sqlBuilder.append(tempSql);
i += CommandConsTant.COMMAND_PRE_FIX.length + 1; i += CommandConsTant.COMMAND_PRE_FIX.length + 1;
SqlCommandDefinition commandDefinition = parseCommand(chars, i); SqlCommandDefinition commandDefinition = parseCommand(chars, i);
sqlBuilder.append(commandDefinition.getCommandContent()); String commandContent = commandDefinition.getCommandContent();
sqlBuilder.append(Objects.isNull(commandContent) ? "" : commandContent);
i += commandDefinition.getCommandLength(); i += commandDefinition.getCommandLength();
if (i <= chars.length - 1) { if (i <= chars.length - 1) {
sqlBuilder.append(" "); sqlBuilder.append(" ");
@ -114,9 +115,12 @@ public class ParseSqlUtil {
} }
} }
if (c == ' ') { if (c == ' ') {
if (chars[i + 1] == ' ' && eliminate) { if (i + 1 <= chars.length - 1) {
continue; if (chars[i + 1] == ' ' && eliminate) {
continue;
}
} }
} }
sqlBuilder.append(c); sqlBuilder.append(c);

View File

@ -6,6 +6,7 @@ import aiyh.utils.tool.org.apache.commons.jexl3.*;
import basetest.BaseTest; import basetest.BaseTest;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import ebu7common.youhong.ai.bean.Builder; import ebu7common.youhong.ai.bean.Builder;
import org.apache.log4j.Logger;
import org.junit.Test; import org.junit.Test;
import weaver.workflow.msg.MsgPushUtil; import weaver.workflow.msg.MsgPushUtil;
import weaver.workflow.msg.entity.MsgEntity; import weaver.workflow.msg.entity.MsgEntity;
@ -164,6 +165,8 @@ public class UtilTest extends BaseTest {
System.out.println('\n'); System.out.println('\n');
System.out.println('\t'); System.out.println('\t');
System.out.println(' '); System.out.println(' ');
Logger logger = Util.getLogger();
logger.info("哈哈哈哈哈舒服哈我是不是在控制台我擦!");
} }