java - 以下决策表可能有什么问题?-LMLPHP

public class TestDecisionTable {
    public static void main(String[] args)
    {
     try{
         KieServices ks = KieServices.Factory.get();
         KieContainer kContainer = ks.getKieClasspathContainer();
         KieSession kSession = kContainer.newKieSession("ksession-dtables");

         Screens s1 = new Screens();
         s1.setDeliveryChannel("Y");
         s1.setUsePointsAppl("Y");
         s1.setContactDetails("Y");
         s1.setRiskScore("Y");
         s1.setReasonCode(100);
         s1.setCurrentScreen(303);
         kSession.insert(s1);

         Screens s2 = new Screens();
         s2.setDeliveryChannel("Y");
         s2.setUsePointsAppl("Y");
         s2.setContactDetails("Y");
         s2.setRiskScore("Y");
         s2.setReasonCode(101);
         s2.setCurrentScreen(303);
         kSession.insert(s2);

         Screens s3 = new Screens();
         s3.setDeliveryChannel("Y");
         s3.setUsePointsAppl("Y");
         s3.setContactDetails("Y");
         s3.setRiskScore("Y");
         s3.setReasonCode(102);
         s3.setCurrentScreen(303);
         kSession.insert(s3);

         kSession.fireAllRules();

     }
     catch (Throwable t) {
         t.printStackTrace();
     }
     }
}


我现在仅用一条规则来实现此决策表。我在规则“ Screens_11”]中收到“不匹配输入'==',text = parser返回了空的Package]]“错误。这是堆栈跟踪:

java.lang.RuntimeException: Error while creating KieBase[Message [id=1, level=ERROR, path=Sample.xls, line=8, column=0
   text=[ERR 102] Line 8:16 mismatched input '==' in rule "Screens_11"], Message [id=2, level=ERROR, path=Sample.xls, line=0, column=0
   text=Parser returned a null Package]]
    at org.drools.compiler.kie.builder.impl.KieContainerImpl.getKieBase(KieContainerImpl.java:450)
    at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:604)
    at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:575)
    at com.sample.TestDecisionTable.main(TestDecisionTable.java:15)


任何帮助,将不胜感激。

编辑:添加了从电子表格生成的文本

=== Begin generated DRL ===
package com.sample;
//generated from Decision Table
import com.sample.Screens;
// rule values at C11, header at C6
rule "Screens_11"
    when
        var:Screens(deliveryChannel == "Y")
        usePointsAppl == "Y"
        contactDetails == "Y"
        riskScore == "Y"
        reasonCode == 100
        currentScreen == 303
    then
        var.setNextScreen(306);
        System.out.println(var.getNextScreen());
end

// rule values at C12, header at C6
rule "Screens_12"
    when
        var:Screens(deliveryChannel == "Y")
        usePointsAppl == "Y"
        contactDetails == "Y"
        riskScore == "Y"
        reasonCode == 100
        currentScreen == 303
    then
        var.setNextScreen(306);
    System.out.println(var.getNextScreen());
end


=== End generated DRL ===

最佳答案

第8行已加入单元格。不要加入约束列之外。

尝试使用此代码,并报告完整的输出。

private void testSpreadsheet(){
  File dtf = new File( dtPath );
  InputStream is;
  try {
    is = new FileInputStream( dtf );
    SpreadsheetCompiler ssComp = new SpreadsheetCompiler();
    String s = ssComp.compile( is, InputType.XLS );
    System.out.println( "=== Begin generated DRL ===" );
    System.out.println( s );
    System.out.println( "=== End generated DRL ===" );
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
}

09-12 03:11