0

我有两个事实要插入到我的流口水会话中。我想检查以下内容:

(shipment1 != null && shipping1.shipToCustomerNo == waypoint1.shipToNumber) || 装运1 == null

如何在基于 web 的 guvnor 决策表中添加此条件?我尝试过使用谓词,waypoint1 和 shipping1 是成功插入会话的绑定变量。如果我使用谓词并添加上面的内容,我的测试用例工作正常,但是当我在我的 java 应用程序中实际运行这些规则时,即使数据是等价的,条件也永远不会评估为真。我尝试了许多不同的方法来构造这个查询。下面是生成的源码:

//from row number: 1
rule "Row 1 Arrive Destination"
    salience 3
    activation-group "arrive-destination"
    dialect "mvel"
    when
        waypoint1 : Waypoint( type == "Destination" )
        clm1 : CarLocationMessage( sightCode == "Z" , loaded == true )
        shipment1 : Shipment( eval( (shipment1 != null && shipment1.shipToCustomerNo == waypoint1.shipToNumber) || shipment1 == null ))
    then
        TripEventRuleResult tripEventRuleResult1 = new TripEventRuleResult();
        tripEventRuleResult1.setEventType( "Arrive" );
        insert( tripEventRuleResult1 );
end
4

1 回答 1

1

如果我正确理解了您的域和问题描述,您应该能够执行这样的规则。

//from row number: 1
rule "Row 1 Arrive Destination"
    salience 3
    activation-group "arrive-destination"
    dialect "mvel"
    when
        waypoint1 : Waypoint( type == "Destination" )
        clm1 : CarLocationMessage( sightCode == "Z" , loaded == true )
        Shipment( shipToCustomerNo == waypoint1.shipToNumber) or
        not Shipment()
    then
        TripEventRuleResult tripEventRuleResult1 = new TripEventRuleResult();
        tripEventRuleResult1.setEventType( "Arrive" );
        insert( tripEventRuleResult1 );
end

简而言之,您不需要对 Shipment 对象进行空检查。它要么在工作记忆中,要么不在工作记忆中

于 2013-11-22T04:33:16.920 回答