1.提交利润中心测试用例
This commit is contained in:
parent
d9d93137f7
commit
cd739fbbb1
|
@ -0,0 +1,31 @@
|
||||||
|
package com.wezone.drools.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 陈韦龙
|
||||||
|
* @date 2022/07/01/ 15:41
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ProfitCenter {
|
||||||
|
/**
|
||||||
|
* 业务类型
|
||||||
|
*/
|
||||||
|
private String businessType;
|
||||||
|
/**
|
||||||
|
* 业务员
|
||||||
|
*/
|
||||||
|
private String salesman;
|
||||||
|
/**
|
||||||
|
* 业务类别
|
||||||
|
*/
|
||||||
|
private String businessCategory;
|
||||||
|
/**
|
||||||
|
* 科目分类
|
||||||
|
*/
|
||||||
|
private String sectionClassification;
|
||||||
|
/**
|
||||||
|
* 是否校验通过
|
||||||
|
*/
|
||||||
|
private boolean checkPass = false;
|
||||||
|
}
|
|
@ -4,13 +4,16 @@ import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.wezone.drools.model.*
|
import com.wezone.drools.model.*
|
||||||
|
|
||||||
|
global java.util.List businessTypeList;
|
||||||
|
global java.util.List salesmanList;
|
||||||
|
global java.util.List businessCategoryList;
|
||||||
|
global java.util.List sectionClassificationList;
|
||||||
rule "测试map"
|
rule "测试map"
|
||||||
no-loop true
|
no-loop true
|
||||||
when
|
when
|
||||||
$first:Map(["first"] != null);
|
$first:Map(["first"] != null);
|
||||||
$second:Map(["amount"] != null) from $first.get("first")
|
$second:Map(["amount"] != null) from $first.get("first")
|
||||||
$map:Map(["amount"] != null) from $second.get("second")
|
$map:Map(["amount"] != null) from $second.get("second")
|
||||||
|
|
||||||
then
|
then
|
||||||
System.out.println("测试map");
|
System.out.println("测试map");
|
||||||
$map.put("score", "100");
|
$map.put("score", "100");
|
||||||
|
@ -32,3 +35,29 @@ when
|
||||||
then
|
then
|
||||||
System.out.println("触发规则-测试memberOf");
|
System.out.println("触发规则-测试memberOf");
|
||||||
end
|
end
|
||||||
|
|
||||||
|
/*
|
||||||
|
(
|
||||||
|
业务类型 IN (货代;船代;散杂货)
|
||||||
|
AND 业务员 IN 仓干配物流部(物流)
|
||||||
|
AND 业务类别(GHWL) IN (运输业务;全货船业务;进出岛仓干配)
|
||||||
|
)
|
||||||
|
OR (业务类型 IN 货代;船代;散杂货 AND 科目分类 IN 银行科目;预付科目;预收科目)
|
||||||
|
*/
|
||||||
|
rule "profitCenter"
|
||||||
|
when
|
||||||
|
$profitCenter:ProfitCenter
|
||||||
|
(
|
||||||
|
(
|
||||||
|
businessType memberOf businessTypeList
|
||||||
|
&& salesman memberOf salesmanList
|
||||||
|
&& businessCategory memberOf businessCategoryList
|
||||||
|
)
|
||||||
|
|| (
|
||||||
|
businessType memberOf businessTypeList
|
||||||
|
&& sectionClassification memberOf sectionClassificationList
|
||||||
|
)
|
||||||
|
)
|
||||||
|
then
|
||||||
|
$profitCenter.setCheckPass(true);
|
||||||
|
end
|
||||||
|
|
|
@ -151,4 +151,38 @@ public class ConditionTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProfitCenter() {
|
||||||
|
// 事实对象
|
||||||
|
ProfitCenter profitCenter = new ProfitCenter();
|
||||||
|
profitCenter.setBusinessType("货代");
|
||||||
|
profitCenter.setSalesman("仓干配物流部(物流)");
|
||||||
|
// profitCenter.setBusinessCategory("运输业务");
|
||||||
|
// profitCenter.setSectionClassification("银行科目");
|
||||||
|
|
||||||
|
List<String> businessTypeList = Lists.newArrayList("货代", "船代", "散杂货");
|
||||||
|
List<String> salesmanList = Lists.newArrayList("仓干配物流部(物流)");
|
||||||
|
List<String> businessCategoryList = Lists.newArrayList("运输业务", "全货船业务", "进出岛仓干配");
|
||||||
|
List<String> sectionClassificationList = Lists.newArrayList("银行科目", "预付科目", "预收科目");
|
||||||
|
//第一步:获取服务
|
||||||
|
KieServices kieServices = KieServices.Factory.get();
|
||||||
|
// 第二步:通过服务获取容器
|
||||||
|
KieContainer container = kieServices.getKieClasspathContainer();
|
||||||
|
// 第三步:通过容器获取KieSession,由KieSession去和规则引擎交互
|
||||||
|
KieSession kieSession = container.newKieSession();
|
||||||
|
// 第四步:将数据交给规则引擎,规则引擎会根据提供的数据进行规则匹配
|
||||||
|
kieSession.insert(profitCenter);
|
||||||
|
kieSession.setGlobal("businessTypeList", businessTypeList);
|
||||||
|
kieSession.setGlobal("salesmanList", salesmanList);
|
||||||
|
kieSession.setGlobal("businessCategoryList", businessCategoryList);
|
||||||
|
kieSession.setGlobal("sectionClassificationList", sectionClassificationList);
|
||||||
|
|
||||||
|
// 第五步:执行规则引擎,触发规则
|
||||||
|
// kieSession.fireAllRules();
|
||||||
|
kieSession.fireAllRules(new RuleNameEqualsAgendaFilter("profitCenter"));
|
||||||
|
// 第六步:关闭容器
|
||||||
|
kieSession.dispose();
|
||||||
|
System.out.println("校验结果" + profitCenter.isCheckPass());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue