This commit is contained in:
Nicolas Héron 2016-06-03 15:58:31 +02:00
commit 471f730d67
10 changed files with 149 additions and 23 deletions

View file

@ -1,6 +0,0 @@
package cost;
public class CostItem {
}

View file

@ -0,0 +1,42 @@
# Cost Calculation Data model
The first thing to do when using drools is to build the java class model on which the rules will apply.
![](diagram.jpg)
* CostCalculationRequest
This is the top entity that will contain the trip description as well as the order the customer did and witch trip has to be calculated.
And in the same object, we shall put the final result in a list of costs and the complete list of pallets where we will put the products.
* Trip
Contains the list of steps of the trip.
* Step
A step happens between two cities and a unique transport type : train, truck or boat
* City
A city which can ne a harbour, a train station or a a final destination by truck.
* Order
The detail of the customer order.
* OrderLine
It contains the product as well as the number of items.
* LeftToDistribute
As we have to distribute all products in the pallets, we shall store here during the distribution what is left to be distributed.
* Product
The product that is bought and has to be in the transport.
* Pallet
Here is a picture of a pallet.
![](pallet.jpg)
* HandlingCostElement, TaxesCostElement and TransportCostElement
they represent the different costs that we have to calculate.
* CalculatedElement
We shall use this class to store intermediate values.

View file

@ -4,7 +4,7 @@ public class TaxesCostElement implements CostElement {
private double amount;
private City city;
private Pallet pallet;
public double getAmount() {
return amount;
@ -22,18 +22,10 @@ public class TaxesCostElement implements CostElement {
this.city = city;
}
public Pallet getPallet() {
return pallet;
}
public void setPallet(Pallet pallet) {
this.pallet = pallet;
}
@Override
public String toString() {
return "TaxesCostElement [amount=" + amount + ", city=" + city + ", pallet="
+ pallet + "]";
return "TaxesCostElement [amount=" + amount + ", city=" + city + "]";
}
}

View file

@ -1,5 +0,0 @@
package cost;
public class TotalAmount {
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -0,0 +1,19 @@
# Rules
We shall use a Ruleflow and implement the rules in 3 steps :
* Distribute the products in the pallet
* Calculate the costs
* Calculate and Display the results
This is done in the P1.bpmn2.
![](ruleflow.png)
## Distribute the products in the pallet
## Calculate the costs
## Sum the results

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB