This commit is contained in:
nheron 2025-05-30 11:39:57 +02:00
commit f592787ab7
29 changed files with 173 additions and 451 deletions

View file

@ -14,11 +14,15 @@
<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<artifactId>drools-engine-classic</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<groupId>org.drools</groupId>
<artifactId>drools-model-compiler</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-ecj</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
@ -42,14 +46,10 @@
</dependencies>
<build>
<plugins>
<!--plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin-->
<version>${maven.compiler.version}</version>
</plugin>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
@ -58,4 +58,4 @@
</plugin>
</plugins>
</build>
</project>
</project>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://www.drools.org/xsd/kmodule">
<kbase name="rules" packages="rules">
<kbase packages="rules">
<ksession name="ksession-rules"/>
</kbase>

View file

@ -121,10 +121,10 @@ end
rule "GetSmallestHeight"
ruleflow-group "distribution"
when
accumulate( Product( $h : height ,transportType==Product.transportType_pallet );
$min : min( $h );
true )
when
$min : Number( )
from accumulate( Product( $h : height ,transportType==Product.transportType_pallet);
min( $h ))
then
CalculatedElement elt = new CalculatedElement();

View file

@ -22,45 +22,24 @@ ruleflow-group "total"
$totalBoatTransport : Number( doubleValue > 100 )
from accumulate( $s : Step(transportType ==Step.Ship_TransportType) &&
TransportCostElement(step ==$s, $value : amount ),
init( double total = 0; ),
action( total += $value; ),
reverse( total -= $value; ),
result( total ) )
sum($value) )
$totalTrainTransport : Number( doubleValue > 100 )
from accumulate( $s : Step(transportType ==Step.train_TransportType) &&
TransportCostElement(step ==$s, $value : amount ),
init( double total = 0; ),
action( total += $value; ),
reverse( total -= $value; ),
result( total ) )
sum($value) )
$totalTruckTransport : Number( doubleValue > 100 )
from accumulate( $s : Step(transportType ==Step.truck_TransportType) &&
TransportCostElement(step ==$s, $value : amount ),
init( double total = 0; ),
action( total += $value; ),
reverse( total -= $value; ),
result( total ) )
sum($value) )
$totalTransport : Number( doubleValue > 100 )
from accumulate( TransportCostElement( $value : amount ),
init( double total = 0; ),
action( total += $value; ),
reverse( total -= $value; ),
result( total ) )
sum($value))
$totalTaxes : Number( doubleValue > 100 )
from accumulate( TaxesCostElement( $value : amount ),
init( double total = 0; ),
action( total += $value; ),
reverse( total -= $value; ),
result( total ) )
sum($value) )
$totalHandling : Number( doubleValue > 100 )
from accumulate( HandlingCostElement( $value : amount ),
init( double total = 0; ),
action( total += $value; ),
reverse( total -= $value; ),
result( total ) )
sum($value))
then
System.out.println("NumberOfPallets="+$c.getPallets().size());
System.out.println("TotalShipTransport="+$totalBoatTransport);
@ -69,4 +48,4 @@ ruleflow-group "total"
System.out.println("TotalTransport="+$totalTransport);
System.out.println("TotalTaxes="+$totalTaxes);
System.out.println("TotalHandling="+$totalHandling);
end;
end;

View file

@ -8,6 +8,7 @@ import org.junit.Test;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.StatelessKieSession;
import org.kie.api.runtime.process.ProcessInstance;
import util.KnowledgeSessionHelper;
@SuppressWarnings("restriction")
@ -83,13 +84,13 @@ public class TestExecercice {
long before = System.currentTimeMillis();
this.insertIntoSession(sessionStatefull, request);
sessionStatefull.startProcess("P1");
int i = sessionStatefull.fireAllRules();
ProcessInstance processInstance = sessionStatefull.startProcess("P1");
long after = System.currentTimeMillis();
System.out.println("NumberRules Executed " + i);
// System.out.println("NumberRules Executed " + i);
System.out.println("Rules executed in " + (after - before) + " ms");
Double dd = new Double(i) / (after - before) * 1000;
System.out.println("NbreRules/seconde=" + dd);
// Double dd = new Double(i) / (after - before) * 1000;
// System.out.println("NbreRules/seconde=" + dd);
}