2.4. 交通違反 DMN デシジョン論理の定義
罰金を計算し、ドライバーが免許停止になるかどうかを判定するために、DMN デシジョンテーブルとコンテキストボックス式を使用した交通違反 DMN デシジョン論理を定義します。
図2.7 罰金のデシジョンテーブル
図2.8 Should the driver be suspended? コンテキストのボックス式
前提条件
- Business Central の交通違反 DRD で、DMN カスタムデータタイプが適切なデシジョンおよび入力ノードに割り当てられている。
手順
- 罰金を計算するには、DMN デザイナーキャンバスで Fine デシジョンノードを選択し、Edit をクリックして DMN ボックス式デザイナーを開きます。
-
Select expression
Decision Table をクリックします。 - Violation.Date、Violation.Code、および Violation.Speed Limit パラメーターフィールドで右クリックして、それぞれで Delete Input Clause を選択します。
-
Violation.Actual Speed 列ヘッダーをクリックし、Name フィールドに
Violation.Actual Speed - Violation.Speed Limit式を入力します。 -
Fine パラメーターフィールドを右クリックして、
Insert Output Clause leftまたはInsert Output Clause rightを選択します。 -
output-2 コラムサブヘッダーをクリックし、Nameフィールドに
Amountを入力し、Data Type フィールドからnumberを選択します。 -
同様に output-1 列サブヘッダーをクリックして Name フィールドに
Pointsと入力し、Data Type フィールドからnumberを選択します。 次に、デシジョンテーブルの一行目に以下の値を入力します。
-
Violation.Type:
"speed" -
Violation.Actual Speed - Violation.Speed Limit:
[10..30] -
Amount:
500 Points:
3一行目を右クリックし、
Insert rule belowを選択して新たな行を追加します。
-
Violation.Type:
デシジョンテーブルの 2 行目に以下の値を入力します。
-
Violation.Type:
"speed" -
Violation.Actual Speed - Violation.Speed Limit:
> 30 -
Amount:
1000 Points:
7二行目を右クリックし、
Insert rule belowを選択して新たな行を追加します。
-
Violation.Type:
デシジョンテーブルの 3 行目に以下の値を入力します。
-
Violation.Type:
"parking" -
Violation.Actual Speed - Violation.Speed Limit:
- -
Amount:
100 Points:
1三行目を右クリックし、
Insert rule belowを選択して新たな行を追加します。
-
Violation.Type:
デシジョンテーブルの 4 行目に以下の値を入力します。
-
Violation.Type:
"driving under the influence" -
Violation.Actual Speed - Violation.Speed Limit:
- -
Amount:
1000 -
Points:
5
-
Violation.Type:
- Save をクリックし、Confirm Save ダイアログボックスで Save を再度クリックします。
- ドライバーの免許停止ルールを定義するには DMN デザイナーキャンバスに戻って Should the driver be suspended? デシジョンノードを選択し、Edit をクリックして DMN ボックス式デザイナーを開きます。
-
Select expression
Context をクリックします。 -
ContextEntry-1 をクリックして Name に
Total Pointsと入力し、Data Type でnumberを選択します。 -
Total Points の横のセルをクリックしてコンテキストメニューから
Literal Expressionを選択し、Driver.Points + Fine.Pointsの式を入力します。 -
Driver.Points + Fine.Points の下のセルのコンテキストメニューから
Literal Expressionを選択し、if Total Points >= 20 then "Yes" else "No"と入力します。 Save をクリックし、Confirm Save ダイアログボックスで Save を再度クリックします。
これで罰金の計算方法とドライバーをいつ免許停止にするかを決定するコンテキストが定義されました。traffic-violation プロジェクトページに移動して Build をクリックすると、用例のプロジェクトがビルドされ、Alerts パネルのエラー (ある場合) が対処されます。