0

我有以下 DMN,它具有文本值作为输入,并且具有仅使用特定值作为枚举约束的约束。

<?xml version="1.0" encoding="UTF-8"?>
<semantic:definitions xmlns:semantic="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:triso="http://www.trisotech.com/2015/triso/modeling" xmlns:trisodmn="http://www.trisotech.com/2016/triso/dmn" xmlns:feel="https://www.omg.org/spec/DMN/20191111/FEEL/" xmlns:tc="http://www.omg.org/spec/DMN/20160719/testcase" xmlns:drools="http://www.drools.org/kie/dmn/1.1" xmlns:openapi="https://openapis.org/omg/extension/1.0" xmlns:boxedext="https://www.trisotech.com/spec/DMN/20191111/EXT/" xmlns:i18n="http://www.omg.org/spec/BPMN/non-normative/extensions/i18n/1.0" xmlns:rss="http://purl.org/rss/2.0/" xmlns:trisofeed="http://trisotech.com/feed" xmlns:kie="http://www.drools.org/kie/dmn/1.2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="https://kiegroup.org/dmn/_BB262EB7-6657-4120-9DB1-2AEB663750A3" id="_98D1D9BB-A096-4D57-9BF1-1AD1D2D72719" name="RoundOffTax" namespace="https://kiegroup.org/dmn/_BB262EB7-6657-4120-9DB1-2AEB663750A3" exporter="Decision Modeler" exporterVersion="7.11.1" triso:translationLanguages="" triso:logoChoice="Default">
  <semantic:extensionElements />
  <semantic:itemDefinition id="_5584EF47-9227-47A7-A879-512B81063E87" label="income" name="income" isCollection="false">
    <semantic:itemComponent id="_F4B5BE6A-CADD-4BD8-8469-B0D58D37FBB1" name="creditRating" isCollection="false">
      <semantic:typeRef>creditRating</semantic:typeRef>
    </semantic:itemComponent>
  </semantic:itemDefinition>
  <semantic:itemDefinition id="_10A58E93-234F-43AA-B53B-D80596CFB853" label="creditRating" name="creditRating" isCollection="false">
    <semantic:typeRef>string</semantic:typeRef>
    <semantic:allowedValues id="_D53F2095-E2F5-4E6C-8386-C6D94370EC71" kie:constraintType="enumeration" triso:constraintsType="enumeration">
      <semantic:extensionElements>
        <triso:constraintDetails>
          <triso:display>"EXCELLENT", "GOOD", "BAD", "POOR"</triso:display>
          <triso:choices>
            <triso:value>"EXCELLENT"</triso:value>
            <triso:display>"EXCELLENT"</triso:display>
          </triso:choices>
          <triso:choices>
            <triso:value>"GOOD"</triso:value>
            <triso:display>"GOOD"</triso:display>
          </triso:choices>
          <triso:choices>
            <triso:value>"BAD"</triso:value>
            <triso:display>"BAD"</triso:display>
          </triso:choices>
          <triso:choices>
            <triso:value>"POOR"</triso:value>
            <triso:display>"POOR"</triso:display>
          </triso:choices>
        </triso:constraintDetails>
      </semantic:extensionElements>
      <semantic:text>"EXCELLENT", "GOOD", "BAD", "POOR"</semantic:text>
    </semantic:allowedValues>
  </semantic:itemDefinition>
  <semantic:itemDefinition id="_B8583894-DC3B-426C-BF11-6903BD0E8258" label="loanQualification" name="loanQualification" isCollection="false">
    <semantic:typeRef>string</semantic:typeRef>
    <semantic:allowedValues id="_BF9D6514-2016-460E-843F-7F80014BE81B" kie:constraintType="enumeration" triso:constraintsType="enumeration">
      <semantic:extensionElements>
        <triso:constraintDetails>
          <triso:display>"QUALIFIED", "DISQUALIFIED"</triso:display>
          <triso:choices>
            <triso:value>"QUALIFIED"</triso:value>
            <triso:display>"QUALIFIED"</triso:display>
          </triso:choices>
          <triso:choices>
            <triso:value>"DISQUALIFIED"</triso:value>
            <triso:display>"DISQUALIFIED"</triso:display>
          </triso:choices>
        </triso:constraintDetails>
      </semantic:extensionElements>
      <semantic:text>"QUALIFIED", "DISQUALIFIED"</semantic:text>
    </semantic:allowedValues>
  </semantic:itemDefinition>
  <semantic:decisionService id="_98D1D9BB-A096-4D57-9BF1-1AD1D2D72719_DS" name="Whole Model Decision Service" triso:dynamicDecisionService="true" triso:wholeModelService="true">
    <semantic:variable id="_98D1D9BB-A096-4D57-9BF1-1AD1D2D72719_DS_VAR" name="Whole Model Decision Service" typeRef="Any" />
    <semantic:outputDecision href="#_34A43DC3-8C75-4086-BB6E-92FF452816DF" />
    <semantic:inputData href="#_E31C6DD8-5B9D-4B64-965A-3C2617455441" />
  </semantic:decisionService>
  <semantic:decisionService id="_D0D3E0DE-8B13-43BD-861D-ED71DE946AFF_DS" name="Diagram DRG" triso:dynamicDecisionService="true">
    <semantic:variable id="_D0D3E0DE-8B13-43BD-861D-ED71DE946AFF_DS_VAR" name="Diagram DRG" typeRef="Any" />
    <semantic:outputDecision href="#_34A43DC3-8C75-4086-BB6E-92FF452816DF" />
    <semantic:inputData href="#_E31C6DD8-5B9D-4B64-965A-3C2617455441" />
  </semantic:decisionService>
  <semantic:inputData id="_E31C6DD8-5B9D-4B64-965A-3C2617455441" name="income">
    <semantic:variable id="_350BFB47-AC97-4849-BC92-523F08758BAF" name="income" typeRef="income" />
  </semantic:inputData>
  <semantic:decision id="_34A43DC3-8C75-4086-BB6E-92FF452816DF" name="ActionableDecision" triso:useOutputTypeAsAnswer="false">
    <semantic:variable id="_7C0BC007-B74F-44E4-9C86-20DF025B5118" name="ActionableDecision" typeRef="Any" />
    <semantic:informationRequirement id="_9BA92A1F-CB9C-4E6B-9103-EA8DA6AF26DB">
      <semantic:requiredInput href="#_E31C6DD8-5B9D-4B64-965A-3C2617455441" />
    </semantic:informationRequirement>
    <semantic:decisionTable id="_C8CC4E93-90A7-40AF-99F9-EB83930C05A6" typeRef="Any" outputLabel="ActionableDecision" triso:descriptionVisible="false" triso:expressionId="_745442c9-b5b3-4dcd-821f-e0c16ac5dcf3">
      <semantic:input id="_89815BA9-91F5-47D2-9CFF-64491676F72C" label="income.creditRating">
        <semantic:inputExpression id="LiteralExpression_1fb8mb4" typeRef="creditRating">
          <semantic:text>income.creditRating</semantic:text>
        </semantic:inputExpression>
        <semantic:inputValues id="UnaryTests_0nl8r4o" triso:constraintsType="enumeration">
          <semantic:text>"EXCELLENT", "GOOD", "BAD", "POOR"</semantic:text>
        </semantic:inputValues>
      </semantic:input>
      <semantic:output id="_E18626D3-6BE9-4719-B87B-CB61F97DA26E" name="action" typeRef="string" />
      <semantic:output id="_4CB7D793-79CB-4B34-9FC4-42E9D09EA110" name="loanQualification" typeRef="loanQualification">
        <semantic:outputValues id="UnaryTests_0xe8kad" triso:constraintsType="enumeration">
          <semantic:text>"QUALIFIED", "DISQUALIFIED"</semantic:text>
        </semantic:outputValues>
      </semantic:output>
      <semantic:annotation name="annotation-1" />
      <semantic:rule id="_AB9F6F1E-4586-427C-B328-EB9E935CDEF8">
        <semantic:inputEntry id="_29D9C278-B794-47DB-B898-292244377500">
          <semantic:text>"EXCELLENT"</semantic:text>
        </semantic:inputEntry>
        <semantic:outputEntry id="_6C6E32F9-0B86-4BBD-806D-2B633DCF078C">
          <semantic:text>"loan_qualification"</semantic:text>
        </semantic:outputEntry>
        <semantic:outputEntry id="_26F433BA-CE54-4575-B9A4-088BF7C1977C">
          <semantic:text>"QUALIFIED"</semantic:text>
        </semantic:outputEntry>
        <semantic:annotationEntry>
          <semantic:text></semantic:text>
        </semantic:annotationEntry>
      </semantic:rule>
      <semantic:rule id="_35B43044-13A4-4D75-AB1C-B004E4103508">
        <semantic:inputEntry id="_4B3851A4-9C20-457B-92BB-E98D164D2EF3">
          <semantic:text>"GOOD"</semantic:text>
        </semantic:inputEntry>
        <semantic:outputEntry id="_AFEC591A-E0CA-4CE3-85B9-D295DE137198">
          <semantic:text>"loan_qualification"</semantic:text>
        </semantic:outputEntry>
        <semantic:outputEntry id="_0C484B49-7407-45F6-A519-7A49A80D713F">
          <semantic:text>"QUALIFIED"</semantic:text>
        </semantic:outputEntry>
        <semantic:annotationEntry>
          <semantic:text></semantic:text>
        </semantic:annotationEntry>
      </semantic:rule>
      <semantic:rule id="_701E4453-3CF2-45DE-9F5D-451B418287C3">
        <semantic:inputEntry id="_52DDDDFA-A2E3-4E56-9117-7B49291104A3">
          <semantic:text>"BAD"</semantic:text>
        </semantic:inputEntry>
        <semantic:outputEntry id="_15EB382E-0607-435A-B2EF-74DA2CB441EA">
          <semantic:text>"loan_qualification"</semantic:text>
        </semantic:outputEntry>
        <semantic:outputEntry id="_EDC7AE5A-FECE-48FB-B674-39AA7DE23B76">
          <semantic:text>"DISQUALIFIED"</semantic:text>
        </semantic:outputEntry>
        <semantic:annotationEntry>
          <semantic:text></semantic:text>
        </semantic:annotationEntry>
      </semantic:rule>
      <semantic:rule id="_B16CD70F-F03D-4EE1-8960-D7B5939BD759">
        <semantic:inputEntry id="_18A6636C-1115-4494-B5E7-83F90FBC549D">
          <semantic:text>"POOR"</semantic:text>
        </semantic:inputEntry>
        <semantic:outputEntry id="_06508A1E-F30A-46FD-A1A2-BF62383CF688">
          <semantic:text>"loan_qualification"</semantic:text>
        </semantic:outputEntry>
        <semantic:outputEntry id="_46DBD47B-5E20-47B6-856E-C722D96AE9BB">
          <semantic:text>"DISQUALIFIED"</semantic:text>
        </semantic:outputEntry>
        <semantic:annotationEntry>
          <semantic:text></semantic:text>
        </semantic:annotationEntry>
      </semantic:rule>
    </semantic:decisionTable>
  </semantic:decision>
  <dmndi:DMNDI>
    <dmndi:DMNDiagram id="_D0D3E0DE-8B13-43BD-861D-ED71DE946AFF" name="DRG" triso:modelElementRef="_5e579375-23fb-4af7-a1ce-a9a67376ac77">
      <dmndi:Size width="1485" height="1050" />
      <dmndi:DMNShape id="dmnshape-drg-_E31C6DD8-5B9D-4B64-965A-3C2617455441" dmnElementRef="_E31C6DD8-5B9D-4B64-965A-3C2617455441">
        <dc:Bounds height="50" width="100" x="380" y="253" />
        <dmndi:DMNLabel trisodmn:defaultBounds="true" />
      </dmndi:DMNShape>
      <dmndi:DMNShape id="dmnshape-drg-_34A43DC3-8C75-4086-BB6E-92FF452816DF" dmnElementRef="_34A43DC3-8C75-4086-BB6E-92FF452816DF">
        <dc:Bounds height="50" width="100" x="380" y="117" />
        <dmndi:DMNLabel trisodmn:defaultBounds="true" />
      </dmndi:DMNShape>
      <dmndi:DMNEdge id="dmnedge-drg-_9BA92A1F-CB9C-4E6B-9103-EA8DA6AF26DB" dmnElementRef="_9BA92A1F-CB9C-4E6B-9103-EA8DA6AF26DB" sourceElement="dmnshape-drg-_E31C6DD8-5B9D-4B64-965A-3C2617455441" targetElement="dmnshape-drg-_34A43DC3-8C75-4086-BB6E-92FF452816DF">
        <di:waypoint x="430" y="253" />
        <di:waypoint x="430" y="167" />
        <dmndi:DMNLabel />
      </dmndi:DMNEdge>
    </dmndi:DMNDiagram>
    <dmndi:DMNStyle id="LS_98D1D9BB-A096-4D57-9BF1-1AD1D2D72719_0" fontSize="11" fontFamily="arial,helvetica,sans-serif" fontItalic="false" fontBold="false" fontUnderline="false" fontStrikeThrough="false" />
  </dmndi:DMNDI>
</semantic:definitions>

这在 Trisotech 中测试时工作正常。但是当与服务集成时,它会抛出如下所述的错误。

2021-09-20 19:07:48.943 ERROR --- [ main] o.k.d.core.ast.DMNDTExpressionEvaluator : income.creditRating='EXCELLENT' does not match any of the valid values "EXCELLENT", "GOOD", "BAD", "POOR" for decision table 'ActionableDecision'.

我在服务中使用以下版本的 kie。有人可以提出问题的原因吗?

<dependency>
      <groupId>org.kie</groupId>
      <artifactId>kie-dmn-core</artifactId>
      <version>7.57.0.Final</version>
</dependency>

示例项目可以在这里找到

4

1 回答 1

0

您需要分享有关如何调用 Drools DMN 引擎的更多详细信息;是通过 Kogito 还是 Kie 服务器?您是否使用 Drools 作为嵌入式 modre 中的库,您是否使用 Kogito API、Kie v7 API、Kie Server Client (Java) API 等。

这是因为如下图所示,它基于 Kogito 并利用 Drools DMN 引擎,一切正常且符合预期: 演示

因此,您与引擎交互的特定方式一定出了问题。

于 2021-09-21T15:05:01.727 回答