10 changed files with 138 additions and 133 deletions
@ -1,39 +0,0 @@
@@ -1,39 +0,0 @@
|
||||
package vip.xumy.drools.service; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
import org.kie.api.KieServices; |
||||
import org.kie.api.runtime.KieContainer; |
||||
import org.kie.api.runtime.KieSession; |
||||
import org.kie.api.runtime.KieSessionConfiguration; |
||||
import org.kie.api.runtime.conf.ClockTypeOption; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import vip.xumy.drools.conf.DroolsConfig; |
||||
|
||||
/** |
||||
* Ownership belongs to the company |
||||
* |
||||
* @author:mengyxu |
||||
* @date:2023年9月20日 |
||||
*/ |
||||
|
||||
@Service |
||||
public class DroolsApiService { |
||||
private static final KieSessionConfiguration sessConf; |
||||
static { |
||||
sessConf = KieServices.Factory.get().newKieSessionConfiguration(); |
||||
sessConf.setOption(ClockTypeOption.get("pseudo")); |
||||
} |
||||
@Autowired |
||||
private KieContainer kieContainer; |
||||
private DroolsConfig config = new DroolsConfig(); |
||||
|
||||
public KieSession createSession(boolean reBuild) throws IOException { |
||||
if(reBuild) |
||||
config.build(); |
||||
return kieContainer.newKieSession(sessConf); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
package rules.hello |
||||
import vip.xumy.drools.pojo.CDR |
||||
import vip.xumy.drools.pojo.RuleSink |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.LinkedList; |
||||
|
||||
|
||||
declare CDR |
||||
@role(event) |
||||
@timestamp(createTime) |
||||
@expires(15s) |
||||
//@duration(duration) |
||||
end |
||||
|
||||
//在10s内,出现不同国家发起的两次位置更新并在此之后有短信行为 |
||||
rule "test007" |
||||
no-loop true |
||||
lock-on-active true |
||||
when |
||||
$b : CDR(msgType==44||msgType==45||msgType==46) |
||||
//accumulate(CDR(msgType==2, imsi==$b.imsi, this before[0ms, 10s] $b, $this:this, $cn:callerCN), $cnt:count($cn), $al:collectList($this)) |
||||
accumulate(CDR(msgType==2, imsi==$b.imsi, this before[1ms, 15s] $b, $this:this, $cn:callerCN, $id:id), $cnt:count($cn), $al:collectList($this), $ids:collectList($id)) |
||||
eval($cnt > 1) |
||||
then |
||||
//System.out.println("match rule " + drools.getRule().getName() + " count = " + $al.size() + " event: " + $b); |
||||
//for(int i=0; i<$al.size(); i++) |
||||
// System.out.println($al.get(i)); |
||||
//sink.sink(drools.getRule().getName(), "has many updatelocation from other CN before sm in 20s", $ids); |
||||
|
||||
//RuleSink ri = new RuleSink($b.getId(), drools.getRule().getName(), "has many updatelocation from other CN before sm in 10s", $ids); |
||||
//sink.add(ri); |
||||
end |
Loading…
Reference in new issue