Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IntegrationProjet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abbenhoumi
IntegrationProjet
Commits
e8291549
Commit
e8291549
authored
Mar 31, 2020
by
Bane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip simulation remplissage poubelle
parent
efe24365
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
2 deletions
+56
-2
src/main/java/isima/f2/RamassagePoubleDepotApplication.java
src/main/java/isima/f2/RamassagePoubleDepotApplication.java
+4
-0
src/main/java/isima/f2/contrats/IPoubelle.java
src/main/java/isima/f2/contrats/IPoubelle.java
+1
-0
src/main/java/isima/f2/dao/IPoubelleDAO.java
src/main/java/isima/f2/dao/IPoubelleDAO.java
+6
-0
src/main/java/isima/f2/services/ImpPoubelle.java
src/main/java/isima/f2/services/ImpPoubelle.java
+11
-2
src/main/java/isima/f2/services/ThreadSimulation.java
src/main/java/isima/f2/services/ThreadSimulation.java
+34
-0
No files found.
src/main/java/isima/f2/RamassagePoubleDepotApplication.java
View file @
e8291549
package
isima.f2
;
import
isima.f2.services.ThreadSimulation
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
...
...
@@ -8,6 +9,9 @@ public class RamassagePoubleDepotApplication {
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
RamassagePoubleDepotApplication
.
class
,
args
);
System
.
out
.
println
(
"=======================>Le nom du thread principal est "
+
Thread
.
currentThread
().
getName
());
ThreadSimulation
t
=
new
ThreadSimulation
();
t
.
start
();
}
}
src/main/java/isima/f2/contrats/IPoubelle.java
View file @
e8291549
...
...
@@ -12,4 +12,5 @@ public interface IPoubelle {
public
Optional
<
Poubelle
>
getPoubelle
(
Long
id
);
public
List
<
Poubelle
>
getPoubelles
();
public
void
viderPoubelle
(
long
id
);
public
void
updateContenuPoubelle
(
long
id
,
double
contenu
);
}
src/main/java/isima/f2/dao/IPoubelleDAO.java
View file @
e8291549
...
...
@@ -15,4 +15,10 @@ public interface IPoubelleDAO extends JpaRepository<Poubelle, Long> {
@Query
(
"UPDATE Poubelle p SET p.contenu = 0 WHERE p.id = :id"
)
int
updatePoubelleSetCapacityZero
(
@Param
(
"id"
)
long
id
);
@Modifying
@Transactional
@Query
(
"UPDATE Poubelle p SET p.contenu = :contenu WHERE p.id = :id"
)
int
updatePoubelleSetCapacity
(
@Param
(
"id"
)
long
id
,
@Param
(
"contenu"
)
double
contenu
);
}
src/main/java/isima/f2/services/ImpPoubelle.java
View file @
e8291549
...
...
@@ -14,7 +14,11 @@ import isima.f2.model.Poubelle;
public
class
ImpPoubelle
implements
IPoubelle
{
@Autowired
IPoubelleDAO
poubelleDAO
;
IPoubelleDAO
poubelleDAO
;
public
ImpPoubelle
(){
}
@Override
public
Poubelle
ajouterPoubelle
(
Poubelle
poubelle
)
{
...
...
@@ -33,7 +37,7 @@ public class ImpPoubelle implements IPoubelle{
@Override
public
Optional
<
Poubelle
>
getPoubelle
(
Long
id
)
{
return
null
;
return
poubelleDAO
.
findById
(
id
)
;
}
@Override
...
...
@@ -46,4 +50,9 @@ public class ImpPoubelle implements IPoubelle{
poubelleDAO
.
updatePoubelleSetCapacityZero
(
id
);
}
@Override
public
void
updateContenuPoubelle
(
long
id
,
double
contenu
)
{
poubelleDAO
.
updatePoubelleSetCapacity
(
id
,
contenu
);
}
}
src/main/java/isima/f2/services/ThreadSimulation.java
0 → 100644
View file @
e8291549
package
isima.f2.services
;
import
isima.f2.model.Poubelle
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.Optional
;
public
class
ThreadSimulation
extends
Thread
{
@Autowired
ImpPoubelle
poubelleService
;
public
ThreadSimulation
()
{
super
();
}
public
void
run
()
{
long
nbGenere
;
/*int nbPoubelles = poubelleService.getPoubelles().size();
System.out.println("Le nombre de poubelle dans la base est : " + nbPoubelles);*/
while
(
true
){
//Generation du nombre aléatoire
nbGenere
=
(
long
)(
Math
.
random
()
*
((
5
-
1
)
+
1
))
+
1
;
//Optional<Poubelle> p = poubelleService.getPoubelle(nbGenere);
//System.out.println("Poubelle : " + p.toString());
System
.
out
.
println
(
"=================================> Nombrre generé : "
+
nbGenere
);
//poubelleService.updateContenuPoubelle();
try
{
Thread
.
sleep
(
2000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment