drools中使用excel
??规则区域所支持的关键字KeywordValueUsageRuleSetThe package name for the generated DRL file. Optional, the default is?
- RuleSet关键字是必须的,名字是可选的
- Import语句非常像java的import,如果有多个import,用逗号隔开
- RuleTable关键字也是必须的,它指示了后面将会有一批rule,ruletable的名称将会作为以后生成rule的前缀
- 条件如果不写的话默认就是==, 比如上面的contract.get("productLine"),其实就是contract.get("productLine") == $param, 如果有多个参数可以使用$1,$2,比如我们经常用到的一个区间数据,这个占位符就派上用场了
- 所有的关键字都是忽略大小写的
- 默认情况下规则引擎只解析第一个sheet的规则
rule_table
.(默认值是rule_table)Must be First entry.Sequential"true" or "false". If "true", then salience is used to ensure that rules fire from the top down.(规则触发是从上朝下,如果是false就是乱序)Optional, at most once. If omitted, no firing order is imposed.ImportA comma-separated list of Java classes to import.(逗号隔开)Optional, may be used repeatedly.VariablesDeclarations of DRL globals, i.e., a type followed by a variable name. Multiple global definitions must be separated with a comma.?全局变量定义,多个用逗号隔开Optional, may be used repeatedly.FunctionsOne or more function definitions, according to DRL syntax.Optional, may be used repeatedly.QueriesOne or more query definitions, according to DRL syntax.Optional, may be used repeatedly.? ? ? ? 需要特别注意的是这些关键字只能出现一次!?
? ?
? ? ? ? 编译后的结果如下:
? ? ? ??
? ? ?// "John".equals(person.getFirstName())? ? ?Person( firstName == "John" )?? ? ?The != operator has null-safe !equals() semantics:? ? ?// Similar to: !java.util.Objects.equals(person.getFirstName(), "John")? ? ? Person( firstName != "John" )?
??????