127 Commits

Author SHA1 Message Date
d8dd0ed95e Merge pull request 'fusion maj parcelle,batiment,ulo et leur enquete' (#194) from features/fiche_refonte into develop
Reviewed-on: #194
2026-03-23 19:54:16 +00:00
5f2686ed7b fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 35s
2026-03-23 20:53:45 +01:00
ada442ffa4 Merge pull request 'fusion maj parcelle,batiment,ulo et leur enquete' (#192) from features/fiche_refonte into develop
Reviewed-on: #192
2026-03-22 18:43:38 +00:00
77671bfb90 fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 34s
2026-03-22 19:41:19 +01:00
5d519855a7 Merge pull request 'fusion maj parcelle,batiment,ulo et leur enquete' (#190) from features/fiche_refonte into develop
Reviewed-on: #190
2026-03-21 20:27:23 +00:00
44827030be fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 33s
2026-03-21 21:26:15 +01:00
8bcae0751a Merge pull request 'fusion maj parcelle,batiment,ulo et leur enquete' (#188) from features/fiche_refonte into develop
Reviewed-on: #188
2026-03-21 14:59:29 +00:00
14ca79d49e fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 27s
2026-03-21 15:58:37 +01:00
34d1502334 Merge pull request 'fusion maj parcelle,batiment,ulo et leur enquete' (#186) from features/fiche_refonte into develop
Reviewed-on: #186
2026-03-21 14:16:31 +00:00
aec566935c fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 28s
2026-03-21 15:15:36 +01:00
e2468328fd Merge pull request 'fusion maj parcelle,batiment,ulo et leur enquete' (#184) from features/fiche_refonte into develop
Reviewed-on: #184
2026-03-21 10:13:37 +00:00
d06d6336de fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-03-21 11:11:28 +01:00
41e55da1df Merge pull request 'fusion maj parcelle,batiment,ulo et leur enquete' (#182) from features/fiche_refonte into develop
Reviewed-on: #182
2026-03-20 13:39:59 +00:00
16dd68c72c fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-03-20 14:39:31 +01:00
705af14b4e Merge pull request 'fusion maj parcelle,batiment,ulo et leur enquete' (#181) from features/fiche_refonte into develop
Reviewed-on: #181
2026-03-20 13:39:00 +00:00
bfe7b319c2 fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 34s
2026-03-20 14:38:30 +01:00
9063162c33 Merge pull request 'fusion maj parcelle,batiment,ulo et leur enquete' (#179) from features/fiche_refonte into develop
Reviewed-on: #179
2026-03-19 18:45:31 +00:00
4997fd32c1 fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 34s
2026-03-19 19:44:52 +01:00
3f9cdcdad3 Merge pull request 'fusion maj parcelle,batiment,ulo et leur enquete' (#177) from features/fiche_refonte into develop
Reviewed-on: #177
2026-03-19 18:00:14 +00:00
d85b622acf fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 28s
2026-03-19 18:59:38 +01:00
e58e338123 Merge pull request 'features/fiche_refonte' (#175) from features/fiche_refonte into develop
Reviewed-on: #175
2026-03-19 16:15:42 +00:00
db8b38b1c0 fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 33s
2026-03-19 17:14:37 +01:00
afc44b95fb fusion maj parcelle,batiment,ulo et leur enquete 2026-03-19 17:13:54 +01:00
253332bbd3 Merge pull request 'fusion maj parcelle,batiment,ulo et leur enquete' (#173) from features/fiche_refonte into develop
Reviewed-on: #173
2026-03-19 10:24:32 +00:00
faf2ccdb8f fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 34s
2026-03-19 11:23:47 +01:00
6dcd549889 Merge pull request 'features/fiche_refonte' (#171) from features/fiche_refonte into develop
Reviewed-on: #171
2026-03-18 17:18:14 +00:00
04ca166db4 fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 2m33s
2026-03-18 18:14:21 +01:00
6ba1365148 fusion maj parcelle,batiment,ulo et leur enquete 2026-03-18 17:49:01 +01:00
0d27aaebac Merge pull request 'fusion maj parcelle,batiment,ulo et leur enquete' (#169) from features/fiche_refonte into develop
Reviewed-on: #169
2026-03-16 13:27:34 +00:00
0d5f7bba1c fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 1m32s
2026-03-16 14:17:45 +01:00
afbf525af5 Merge pull request 'Generation tfu batie et non batie avec ressource de liste de données imposition' (#167) from features/crud_entites into develop
Reviewed-on: #167
2026-03-14 14:47:18 +00:00
81bd7d9034 Generation tfu batie et non batie avec ressource de liste de données imposition
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 33s
2026-03-14 15:40:32 +01:00
8ee2f7c9b0 Merge pull request 'Generation tfu batie et non batie avec ressource de liste de données imposition' (#165) from features/crud_entites into develop
Reviewed-on: #165
2026-03-12 20:01:27 +00:00
cec02e24ae Generation tfu batie et non batie avec ressource de liste de données imposition
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-03-12 21:00:21 +01:00
6bdfa3ad1e Merge pull request 'Generation tfu batie et non batie avec ressource de liste de données imposition' (#163) from features/crud_entites into develop
Reviewed-on: #163
2026-03-12 19:34:04 +00:00
dae64dc079 Generation tfu batie et non batie avec ressource de liste de données imposition
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 32s
2026-03-12 20:33:32 +01:00
b8ba15c6fb Merge pull request 'Generation tfu batie et non batie' (#161) from features/crud_entites into develop
Reviewed-on: #161
2026-03-12 11:27:12 +00:00
9de2564108 Generation tfu batie et non batie
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 28s
2026-03-12 12:26:45 +01:00
698b7e7c99 Merge pull request 'Generation tfu batie et non batie' (#158) from features/crud_entites into develop
Reviewed-on: #158
2026-03-12 11:06:47 +00:00
b3e3e7109f Generation tfu batie et non batie
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 28s
2026-03-12 12:05:36 +01:00
9e597386f8 Merge pull request 'Generation tfu batie et non batie' (#156) from features/crud_entites into develop
Reviewed-on: #156
2026-03-12 00:03:12 +00:00
b22b6c8288 Generation tfu batie et non batie
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 27s
2026-03-12 01:00:03 +01:00
cb2faeea32 Merge pull request 'Generation tfu batie et non batie' (#154) from features/crud_entites into develop
Reviewed-on: #154
2026-03-11 00:10:38 +00:00
d326e227c4 Generation tfu batie et non batie
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 26s
2026-03-11 01:09:42 +01:00
6b3ab8fc43 Merge pull request 'Gestion des barem' (#152) from features/crud_entites into develop
Reviewed-on: #152
2026-03-10 21:37:55 +00:00
85be8a2e24 Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 33s
2026-03-10 22:36:38 +01:00
906a74571f Merge pull request 'features/crud_entites' (#150) from features/crud_entites into develop
Reviewed-on: #150
2026-03-09 20:13:24 +00:00
fcc81e0607 Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 28s
2026-03-09 21:12:09 +01:00
862b917689 Gestion des barem 2026-03-09 21:11:24 +01:00
6494fe235e Merge pull request 'Gestion des barem' (#148) from features/crud_entites into develop
Reviewed-on: #148
2026-03-09 20:00:03 +00:00
9b4edcdcea Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-03-09 20:59:23 +01:00
28da361054 Merge pull request 'features/crud_entites' (#146) from features/crud_entites into develop
Reviewed-on: #146
2026-03-09 19:32:08 +00:00
db1fd2c821 Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-03-09 20:31:09 +01:00
ee07fec0ac Gestion des barem 2026-03-09 20:03:25 +01:00
3993d28d51 Merge pull request 'features/crud_entites' (#144) from features/crud_entites into develop
Reviewed-on: #144
2026-03-09 18:52:33 +00:00
a5cabc8102 Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 28s
2026-03-09 19:52:00 +01:00
443b563d69 Gestion des barem 2026-03-09 19:51:44 +01:00
a799764d16 Gestion des barem 2026-03-09 19:51:40 +01:00
09d8b21909 Merge pull request 'Gestion des barem' (#142) from features/crud_entites into develop
Reviewed-on: #142
2026-03-08 13:54:26 +00:00
eba53a42aa Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 27s
2026-03-08 14:54:00 +01:00
274b47d116 Merge pull request 'Gestion des barem' (#141) from features/crud_entites into develop
Reviewed-on: #141
2026-03-08 13:52:20 +00:00
bd8bd64a2d Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-03-08 14:51:54 +01:00
bdb08b88fd Merge pull request 'Gestion des barem' (#140) from features/crud_entites into develop
Reviewed-on: #140
2026-03-08 13:25:13 +00:00
5dcb2adf30 Gestion des barem
Some checks failed
CI - Build & Test (develop) / build-and-test (pull_request) Failing after 9s
2026-03-08 14:23:14 +01:00
b86c685cd0 Merge pull request 'Gestion cloture' (#138) from features/crud_entites into develop
Reviewed-on: #138
2026-03-06 19:08:53 +00:00
d1c3cb190d Gestion cloture
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-03-06 20:08:05 +01:00
d46a14626e Merge pull request 'Gestion parcelle geom et changement https://gitea.com/actions/checkout@v4 #actions/checkout@v4' (#136) from features/crud_entites into develop
Reviewed-on: #136
2026-03-01 17:33:59 +00:00
4897712e08 Gestion parcelle geom et changement https://gitea.com/actions/checkout@v4 #actions/checkout@v4
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 44s
2026-03-01 18:33:30 +01:00
920c70c877 Merge pull request 'Gestion parcelle geom' (#135) from features/crud_entites into develop
Reviewed-on: #135
2026-03-01 17:29:34 +00:00
dc28d88763 Gestion parcelle geom
Some checks failed
CI - Build & Test (develop) / build-and-test (pull_request) Failing after 31s
2026-03-01 18:29:12 +01:00
2ab5b9299c Merge pull request 'Gestion parcelle geom' (#133) from features/crud_entites into develop
Reviewed-on: #133
2026-03-01 01:40:41 +00:00
35393954c3 Gestion parcelle geom
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 38s
2026-03-01 02:39:38 +01:00
bf19ab6e6a Merge pull request 'features/crud_entites' (#131) from features/crud_entites into develop
Reviewed-on: #131
2026-02-22 23:17:33 +00:00
51845b085a prise en charge des données entrant dans la liquidation
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-23 00:17:01 +01:00
4567074f08 prise en charge des données entrant dans la liquidation 2026-02-23 00:16:43 +01:00
84451d5a15 Merge pull request 'features/crud_entites' (#129) from features/crud_entites into develop
Reviewed-on: #129
2026-02-22 13:53:35 +00:00
933c209f67 prise en charge des données entrant dans la liquidation
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-22 14:52:47 +01:00
dc59006e99 prise en charge des données entrant dans la liquidation 2026-02-22 11:50:39 +01:00
e687a9a904 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#127) from features/crud_entites into develop
Reviewed-on: #127
2026-02-21 12:42:08 +00:00
b0abdee729 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 32s
2026-02-21 13:41:44 +01:00
9685c73513 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#125) from features/crud_entites into develop
Reviewed-on: #125
2026-02-20 19:33:57 +00:00
2a53e653c3 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 31s
2026-02-20 20:33:29 +01:00
650470efff Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#123) from features/crud_entites into develop
Reviewed-on: #123
2026-02-20 18:54:07 +00:00
1ce98edc32 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-20 19:52:44 +01:00
9f5cc61726 Merge pull request 'features/crud_entites' (#121) from features/crud_entites into develop
Reviewed-on: #121
2026-02-19 20:37:58 +00:00
144a6af6f8 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-02-19 21:37:28 +01:00
e0a211d8bd gestion revu de code en utilisant uniquement les DTO 2026-02-19 21:22:46 +01:00
41175d93f0 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#119) from features/crud_entites into develop
Reviewed-on: #119
2026-02-19 19:07:35 +00:00
d1813d7460 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-19 20:06:45 +01:00
1ecaecdee3 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#117) from features/crud_entites into develop
Reviewed-on: #117
2026-02-19 18:33:11 +00:00
95bf4779f7 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 31s
2026-02-19 19:30:28 +01:00
122dfcbead Merge pull request 'features/crud_entites' (#115) from features/crud_entites into develop
Reviewed-on: #115
2026-02-19 12:00:31 +00:00
5e9aae2bc2 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-02-19 11:23:50 +01:00
06fa55fe2a gestion revu de code en utilisant uniquement les DTO 2026-02-19 11:23:28 +01:00
c272257930 gestion revu de code en utilisant uniquement les DTO 2026-02-19 08:50:46 +01:00
d168b68d4b Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#113) from features/crud_entites into develop
Reviewed-on: #113
2026-02-18 23:05:41 +00:00
2c38fa1926 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-19 00:04:41 +01:00
2af14dd4cd Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#111) from features/crud_entites into develop
Reviewed-on: #111
2026-02-18 20:42:05 +00:00
74a00a3856 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 36s
2026-02-18 21:41:28 +01:00
76f0d34e79 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#109) from features/crud_entites into develop
Reviewed-on: #109
2026-02-18 14:01:25 +00:00
558f95869c gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 36s
2026-02-18 15:00:15 +01:00
666779ecce Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#107) from features/crud_entites into develop
Reviewed-on: #107
2026-02-16 22:04:26 +00:00
554277f312 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 28s
2026-02-16 23:03:51 +01:00
7fcd676fc0 Merge pull request 'features/crud_entites' (#105) from features/crud_entites into develop
Reviewed-on: #105
2026-02-16 20:55:25 +00:00
e6e9407940 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-02-16 21:52:48 +01:00
0617d2f383 gestion revu de code en utilisant uniquement les DTO 2026-02-16 21:51:55 +01:00
962af9b48c gestion revu de code en utilisant uniquement les DTO 2026-02-16 14:48:46 +01:00
fffdef7103 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#103) from features/crud_entites into develop
Reviewed-on: #103
2026-02-16 00:15:01 +00:00
14816d9bd0 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-16 01:14:25 +01:00
95c0dacd1e Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#101) from features/crud_entites into develop
Reviewed-on: #101
2026-02-14 14:08:19 +00:00
8efe46fea8 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 27s
2026-02-14 15:07:50 +01:00
7ac6b953d3 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#99) from features/crud_entites into develop
Reviewed-on: #99
2026-02-13 17:54:51 +00:00
8031289509 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-13 18:53:39 +01:00
e010100472 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#97) from features/crud_entites into develop
Reviewed-on: #97
2026-02-12 21:31:24 +00:00
f49e8157e2 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-12 22:30:42 +01:00
177a9c7b56 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#95) from features/crud_entites into develop
Reviewed-on: #95
2026-02-12 02:15:05 +00:00
88f7a7d7af gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 26s
2026-02-12 03:13:58 +01:00
3054930a86 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#93) from features/crud_entites into develop
Reviewed-on: #93
2026-02-11 21:14:57 +00:00
ed73eb3f2e gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 27s
2026-02-11 22:14:15 +01:00
4397abd041 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#91) from features/crud_entites into develop
Reviewed-on: #91
2026-02-11 21:10:08 +00:00
c4389abaf2 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-11 22:09:21 +01:00
a4b403ca20 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#89) from features/crud_entites into develop
Reviewed-on: #89
2026-02-10 00:10:39 +00:00
ccfe1bfb4a gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 26s
2026-02-10 01:10:07 +01:00
ff7b88f9f8 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#87) from features/crud_entites into develop
Reviewed-on: #87
2026-02-09 23:26:42 +00:00
f85191b47c gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 27s
2026-02-10 00:26:14 +01:00
37fdba1d85 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#85) from features/crud_entites into develop
Reviewed-on: #85
2026-02-08 22:23:08 +00:00
c600d50ce4 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 35s
2026-02-08 23:22:09 +01:00
477 changed files with 19598 additions and 1529 deletions

View File

@@ -52,8 +52,10 @@ jobs:
echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV"
# 4) Checkout du dépôt # 4) Checkout du dépôt
#- name: Checkout repository
# uses: https://gitea.com/actions/checkout@v4 #actions/checkout@v4
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 run: git clone ${{ gitea.server_url }}/${{ gitea.repository }} .
# 5) Informations de contexte (sans secrets) # 5) Informations de contexte (sans secrets)
- name: Show context information - name: Show context information

View File

@@ -52,8 +52,10 @@ jobs:
echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV"
# 4) Checkout du dépôt # 4) Checkout du dépôt
#- name: Checkout repository
# uses: https://gitea.com/actions/checkout@v4 #actions/checkout@v4
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 run: git clone ${{ gitea.server_url }}/${{ gitea.repository }} .
# 5) Création des secrets runtime (CI uniquement) # 5) Création des secrets runtime (CI uniquement)
- name: Create runtime secrets - name: Create runtime secrets

1
.gitignore vendored
View File

@@ -5,3 +5,4 @@ target/*
ansible ansible
secrets/ secrets/
.env .env
/uploads/

18
pom.xml
View File

@@ -73,6 +73,7 @@
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sf.jasperreports</groupId> <groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId> <artifactId>jasperreports</artifactId>
@@ -149,7 +150,24 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>com.wildbit.java</groupId>
<artifactId>postmark</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>

View File

@@ -1,9 +1,13 @@
package io.gmss.fiscad.configuration; package io.gmss.fiscad.configuration;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import io.gmss.fiscad.security.CustomUserDetailsService; import io.gmss.fiscad.security.CustomUserDetailsService;
import io.gmss.fiscad.security.JwtAuthenticationFilter; import io.gmss.fiscad.security.JwtAuthenticationFilter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.modelmapper.ModelMapper; import org.modelmapper.ModelMapper;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
@@ -63,4 +67,7 @@ public class ApplicationConfig {
return authenticationManagerBuilder.build(); return authenticationManagerBuilder.build();
} }
} }

View File

@@ -0,0 +1,50 @@
package io.gmss.fiscad.configuration;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.registerModule(new Jdk8Module());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
return mapper;
}
@Bean
public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() {
return builder -> {
builder.modules(new JavaTimeModule(), new Jdk8Module());
builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
};
}
@Bean
public RestTemplate restTemplate(ObjectMapper mapper) {
mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
MappingJackson2HttpMessageConverter converter =
new MappingJackson2HttpMessageConverter(mapper);
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().removeIf(
c -> c instanceof MappingJackson2HttpMessageConverter
);
restTemplate.getMessageConverters().add(converter);
return restTemplate;
}
}

View File

@@ -0,0 +1,120 @@
//package io.gmss.fiscad.configuration;
//
//import com.backend.api.security.CustomUserDetailsService;
//import com.backend.api.security.JwtAuthenticationEntryPoint;
//import com.backend.api.security.JwtAuthenticationFilter;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.http.HttpMethod;
//import org.springframework.security.authentication.AuthenticationManager;
//import org.springframework.security.config.BeanIds;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.config.http.SessionCreationPolicy;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
//
//@Configuration
//@EnableWebSecurity // active la sécurité web sur le projet
//@EnableGlobalMethodSecurity( // est utilisé pour définir la sécurité sur les méthodes
// securedEnabled = true, // est activé pour protéger un controlleur ou un service
// jsr250Enabled = true, // active le role qui doit être utilisé
// prePostEnabled = true // active le controle avant et après l'execution de la requête
//)
//public class SecurityConfig extends WebSecurityConfigurerAdapter {
//
// /**
// * Est utilisé pour authentifier un utlisateur ou pour définir un role
// */
// @Autowired
// CustomUserDetailsService customUserDetailsService;
//
// @Autowired
// private JwtAuthenticationEntryPoint unauthorizedHandler;
//
// @Bean
// public JwtAuthenticationFilter jwtAuthenticationFilter() {
// return new JwtAuthenticationFilter();
// }
//
//
//
// private static final String[] AUTH_WHITELIST = {
//
// // -- swagger ui
// "/swagger-resources/**",
// "/swagger-ui.html",
// "/v3/api-docs",
// "/swagger-ui/**",
// "/webjars/**",
// "/api/**",
//// "/api/synonym/**",
// "/api/auth/**"
// };
// @Override
// public void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
// authenticationManagerBuilder
// .userDetailsService(customUserDetailsService)
// .passwordEncoder(passwordEncoder());
// }
//
// @Bean(BeanIds.AUTHENTICATION_MANAGER)
// @Override
// public AuthenticationManager authenticationManagerBean() throws Exception {
// return super.authenticationManagerBean();
// }
//
// @Bean
// public PasswordEncoder passwordEncoder() {
// return new BCryptPasswordEncoder();
// }
//
// /**
// *
// * @param http
// * @throws Exception
// */
// @Override
// protected void configure(HttpSecurity http) throws Exception {
// http
// .cors()
// .and()
// .csrf()
// .disable()
// .exceptionHandling()
// .authenticationEntryPoint(unauthorizedHandler)
// .and()
// .sessionManagement()
// .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
// .and()
// .authorizeRequests()
// .antMatchers("/",
// "/favicon.ico",
// "/**/*.png",
// "/**/*.gif",
// "/**/*.svg",
// "/**/*.jpg",
// "/**/*.html",
// "/**/*.css",
// "/**/*.js")
// .permitAll()
// .antMatchers(AUTH_WHITELIST).permitAll()
// .antMatchers("/api/auth/**")
// .permitAll()
// .antMatchers("/api/user/checkUsernameAvailability", "/api/user/checkEmailAvailability")
// .permitAll()
// .antMatchers(HttpMethod.GET, "/api/polls/**", "/api/users/**")
// .permitAll()
// .anyRequest()
// .authenticated();
//
// // Add our custom JWT security filter
// http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
//
// }
//}

View File

@@ -1,11 +1,113 @@
package io.gmss.fiscad.configuration; package io.gmss.fiscad.configuration;
import io.gmss.fiscad.security.JwtAuthenticationEntryPoint; import io.gmss.fiscad.security.JwtAuthenticationEntryPoint;
import io.gmss.fiscad.security.JwtAuthenticationFilter; import io.gmss.fiscad.security.JwtAuthenticationFilter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import java.util.List;
@EnableWebSecurity
@Configuration
@EnableMethodSecurity(securedEnabled = true, jsr250Enabled = true, prePostEnabled = true)
@RequiredArgsConstructor
public class SpringSecurityConfig {
private final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
private final AuthenticationProvider authenticationProvider;
private final JwtAuthenticationFilter jwtAuthenticationFilter;
private static final String[] PUBLIC_ENDPOINTS = {
"/api/auth/login",
"/api/open/**",
"/api/synchronisation/references",
"/v3/api-docs/**",
"/swagger-ui/**",
"/swagger-ui.html",
"/error",
"/api/**" // A ENLEVER AVANT LA MISE EN PRODUCTION
};
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
// Désactivation CSRF car JWT stateless
.csrf(AbstractHttpConfigurer::disable)
// CORS configuration propre
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
// Gestion des exceptions dauthentification
.exceptionHandling(exception ->
exception.authenticationEntryPoint(jwtAuthenticationEntryPoint)
)
// Stateless session
.sessionManagement(session ->
session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
)
// Configuration des autorisations
.authorizeHttpRequests(auth -> auth
// Autoriser les requêtes OPTIONS (CORS preflight)
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
// Endpoints publics
.requestMatchers(PUBLIC_ENDPOINTS).permitAll()
// Tout le reste nécessite authentification
.anyRequest().authenticated()
)
// Provider dauthentification
.authenticationProvider(authenticationProvider)
// Ajout du filtre JWT avant UsernamePasswordAuthenticationFilter
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
return http.build();
}
/**
* Configuration CORS centralisée.
* ⚠️ En production, remplacer "*" par ton domaine frontend.
*/
@Bean
public CorsConfigurationSource corsConfigurationSource() {
return request -> {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(List.of("*")); // ⚠️ restreindre en prod
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"));
configuration.setAllowedHeaders(List.of("*"));
configuration.setAllowCredentials(false);
return configuration;
};
}
}
/*
import io.gmss.fiscad.security.JwtAuthenticationEntryPoint;
import io.gmss.fiscad.security.JwtAuthenticationFilter;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
@@ -27,16 +129,15 @@ public class SpringSecurityConfig {
private final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint; private final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
private final AuthenticationProvider authenticationProvider; private final AuthenticationProvider authenticationProvider;
private final JwtAuthenticationFilter jwtAuthenticationFilter; private final JwtAuthenticationFilter jwtAuthenticationFilter;
private static final String[] AUTH_WHITELIST = { private static final String[] AUTH_WHITELIST = {
"/api/**", // "/api/**",
"/api/auth/login", "/api/auth/login",
"/api/open/**", "/api/open/**",
"/api/synchronisation/references", "/api/synchronisation/references",
"/v3/api-docs/**", "/v3/api-docs/**",
"/swagger-ui/**", "/swagger-ui/**",
"/swagger-ui.html" "/swagger-ui.html",
"/error"
}; };
@@ -58,7 +159,7 @@ public class SpringSecurityConfig {
.exceptionHandling(ex -> ex.authenticationEntryPoint(jwtAuthenticationEntryPoint)) .exceptionHandling(ex -> ex.authenticationEntryPoint(jwtAuthenticationEntryPoint))
.authorizeHttpRequests(req -> .authorizeHttpRequests(req ->
req req
//.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll() .requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.requestMatchers(AUTH_WHITELIST).permitAll() .requestMatchers(AUTH_WHITELIST).permitAll()
.anyRequest() .anyRequest()
.authenticated() .authenticated()
@@ -66,11 +167,8 @@ public class SpringSecurityConfig {
.authenticationProvider(authenticationProvider) .authenticationProvider(authenticationProvider)
.sessionManagement(session -> session.sessionCreationPolicy(STATELESS)) .sessionManagement(session -> session.sessionCreationPolicy(STATELESS))
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class) .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
; ;
return http.build(); return http.build();
} }
}*/
}

View File

@@ -7,6 +7,7 @@ import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb; import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb;
import io.gmss.fiscad.paylaods.request.synchronisation.SecteurPayload; import io.gmss.fiscad.paylaods.request.synchronisation.SecteurPayload;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -24,7 +25,7 @@ import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@RequestMapping(value = "api/secteur", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/secteur", produces = MediaType.APPLICATION_JSON_VALUE)
//@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Secteur") @Tag(name = "Secteur")
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')") //@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class SecteurController { public class SecteurController {
@@ -314,5 +315,31 @@ public class SecteurController {
} }
@Operation(
summary = "recuperer tous les secteurs d'un departement",
description = "Permet de récuperer l'ensemble des secteurs du departement dont l'ID est fourni en path"
)
@GetMapping("/by-departement-id/{departementId}")
public ResponseEntity<?> getSecteurByDepartementId(@PathVariable Long departementId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurService.getListSecteurByDepartementId(departementId), "Secteur trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -1,6 +1,7 @@
package io.gmss.fiscad.controllers.decoupage; package io.gmss.fiscad.controllers.decoupage;
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage; import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
import io.gmss.fiscad.enums.StatutEnquete;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService; import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
import io.gmss.fiscad.interfaces.decoupage.SecteurService; import io.gmss.fiscad.interfaces.decoupage.SecteurService;
@@ -248,4 +249,221 @@ public class SecteurDecoupageController {
} }
@GetMapping("/arbre/enquete-en-cours/user-id/{userId}")
public ResponseEntity<?> getArborescenceEnqueteEncoursByUserId(@PathVariable Long userId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteDecoupageByUserId(userId, StatutEnquete.EN_COURS.toString()), "SecteurDecoupage trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
e.printStackTrace();
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/arbre/enquete-valide/user-id/{userId}")
public ResponseEntity<?> getArborescenceEnqueteValideByUserId(@PathVariable Long userId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteDecoupageByUserId(userId, StatutEnquete.VALIDE.toString()), "SecteurDecoupage trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
e.printStackTrace();
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/arbre/enquete-cloture/user-id/{userId}")
public ResponseEntity<?> getArborescenceEnqueteClotureByUserId(@PathVariable Long userId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteDecoupageByUserId(userId, StatutEnquete.CLOTURE.toString()), "SecteurDecoupage trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
e.printStackTrace();
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/arbre/enquete-batiment-en-cours/user-id/{userId}")
public ResponseEntity<?> getArborescenceEnqueteBatimentEncoursByUserId(@PathVariable Long userId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteBatimentDecoupageByUserId(userId, StatutEnquete.EN_COURS.toString()), "SecteurDecoupage trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
e.printStackTrace();
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/arbre/enquete-batiment-valide/user-id/{userId}")
public ResponseEntity<?> getArborescenceEnqueteBatimentValideByUserId(@PathVariable Long userId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteBatimentDecoupageByUserId(userId, StatutEnquete.VALIDE.toString()), "SecteurDecoupage trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
e.printStackTrace();
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/arbre/enquete-batiment-cloture/user-id/{userId}")
public ResponseEntity<?> getArborescenceEnqueteBatimentClotureByUserId(@PathVariable Long userId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteBatimentDecoupageByUserId(userId, StatutEnquete.CLOTURE.toString()), "SecteurDecoupage trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
e.printStackTrace();
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/arbre/enquete-unitlog-en-cours/user-id/{userId}")
public ResponseEntity<?> getArborescenceEnqueteUniteLogEncoursByUserId(@PathVariable Long userId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteUniteLogementDecoupageByUserId(userId, StatutEnquete.EN_COURS.toString()), "SecteurDecoupage trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
e.printStackTrace();
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/arbre/enquete-unitlog-valide/user-id/{userId}")
public ResponseEntity<?> getArborescenceEnqueteUniteLogValideByUserId(@PathVariable Long userId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteUniteLogementDecoupageByUserId(userId, StatutEnquete.VALIDE.toString()), "SecteurDecoupage trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
e.printStackTrace();
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/arbre/enquete-unitlog-cloture/user-id/{userId}")
public ResponseEntity<?> getArborescenceEnqueteUniteLigClotureByUserId(@PathVariable Long userId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteUniteLogementDecoupageByUserId(userId, StatutEnquete.CLOTURE.toString()), "SecteurDecoupage trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
e.printStackTrace();
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -5,6 +5,7 @@ import io.gmss.fiscad.interfaces.decoupage.SectionService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.SectionPaylaodWeb; import io.gmss.fiscad.paylaods.request.crudweb.SectionPaylaodWeb;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -21,7 +22,7 @@ import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@RequestMapping(value = "api/section", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/section", produces = MediaType.APPLICATION_JSON_VALUE)
//@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Section") @Tag(name = "Section")
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')") //@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class SectionController { public class SectionController {

View File

@@ -2,6 +2,8 @@ package io.gmss.fiscad.controllers.infocad.metier;
import io.gmss.fiscad.entities.infocad.metier.Enquete; import io.gmss.fiscad.entities.infocad.metier.Enquete;
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment; import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.StatutEnquete;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService; import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
@@ -10,6 +12,8 @@ import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
import io.gmss.fiscad.paylaods.request.synchronisation.EnquetePayLoad; import io.gmss.fiscad.paylaods.request.synchronisation.EnquetePayLoad;
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad; import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad; import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@@ -48,9 +52,9 @@ public class EnqueteController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createEnquete(@RequestBody @Valid @Validated EnquetePayLoadWeb enquetePayLoadWeb) { public ResponseEntity<?> createEnquete(@RequestBody @Valid @Validated EnquetePayLoadWeb enquetePayLoadWeb) {
try { try {
Enquete enquete = enqueteService.createEnquete(enquetePayLoadWeb); enquetePayLoadWeb = enqueteService.createEnquete(enquetePayLoadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enquete, "Enquete batiment créé avec succès."), new ApiResponse<>(true, enquetePayLoadWeb, "Enquete batiment créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -64,7 +68,8 @@ public class EnqueteController {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getLocalizedMessage()); e.printStackTrace();
// logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
@@ -119,6 +124,7 @@ public class EnqueteController {
@PutMapping("/rejet") @PutMapping("/rejet")
public ResponseEntity<?> rejeterEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) { public ResponseEntity<?> rejeterEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.rejeterEnquete(enqueteTraitementPayLoad), "Rejet effectuée avec succès."), new ApiResponse<>(true, enqueteService.rejeterEnquete(enqueteTraitementPayLoad), "Rejet effectuée avec succès."),
HttpStatus.OK HttpStatus.OK
@@ -212,8 +218,8 @@ public class EnqueteController {
summary = "Récupérer les enquetes d'une parcelle", summary = "Récupérer les enquetes d'une parcelle",
description = "Permet de récuperer les enquêtes déjà réalisées sur une parcelles" description = "Permet de récuperer les enquêtes déjà réalisées sur une parcelles"
) )
@GetMapping("/all/by-parcelle-id/{parcelleId}") @GetMapping("/by-parcelle-id/{parcelleId}")
public ResponseEntity<?> getAllByEnqueteDecoupageAdmin(@PathVariable Long parcelleId) { public ResponseEntity<?> getAllByParcelle(@PathVariable Long parcelleId) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.getEnqueteListByParcelle(parcelleId), "Liste des enquetes chargée avec succès."), new ApiResponse<>(true, enqueteService.getEnqueteListByParcelle(parcelleId), "Liste des enquetes chargée avec succès."),
@@ -236,6 +242,36 @@ public class EnqueteController {
} }
@Operation(
summary = "Récupérer les enquetes d'une parcelle",
description = "Permet de récuperer les enquêtes déjà réalisées sur une parcelles"
)
@GetMapping("/page/by-parcelle-id/{parcelleId}")
public ResponseEntity<?> getAllByParcellePaged(@PathVariable Long parcelleId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.getEnqueteListByParcellePageable(parcelleId,pageable), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all/dgi/decoupage-admin-for-enquete") @GetMapping("/all/dgi/decoupage-admin-for-enquete")
@@ -450,5 +486,65 @@ public class EnqueteController {
@GetMapping("/all-paged/en-cours/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllEnqueteEncoursByQuartierPaged(@CurrentUser UserPrincipal currentUser,@PathVariable Long quartierId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.getEnqueteListByQuartierByStatutPageableToDto(userId,quartierId, StatutEnquete.EN_COURS, pageable), "Liste des enquetes en cours chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/cloture/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllEnqueteClotureByQuartierPaged(@CurrentUser UserPrincipal currentUser,@PathVariable Long quartierId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.getEnqueteListByQuartierByStatutPageableToDto(userId,quartierId, StatutEnquete.CLOTURE, pageable), "Liste des enquetes en cours chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -6,10 +6,13 @@ import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService; import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
import io.gmss.fiscad.interfaces.infocad.metier.ParcelleService; import io.gmss.fiscad.interfaces.infocad.metier.ParcelleService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.FiltreParcelle;
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad; import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad; import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb; import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb; import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -28,7 +31,7 @@ import java.util.List;
@RestController @RestController
@RequestMapping(value = "api/parcelle", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/parcelle", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer") //@SecurityRequirement(name = "bearer")
@Tag(name = "Parcelle") @Tag(name = "Parcelle")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@@ -48,9 +51,9 @@ public class ParcelleController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createParcelle(@RequestBody @Valid @Validated ParcellePayLoadWeb parcellePayLoadWeb) { public ResponseEntity<?> createParcelle(@RequestBody @Valid @Validated ParcellePayLoadWeb parcellePayLoadWeb) {
try { try {
Parcelle parcelle = parcelleService.createParcelle(parcellePayLoadWeb); parcellePayLoadWeb = parcelleService.createParcelle(parcellePayLoadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, parcelle, "parcelle créée avec succès."), new ApiResponse<>(true, parcellePayLoadWeb, "parcelle créée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -88,6 +91,7 @@ public class ParcelleController {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
@@ -118,12 +122,67 @@ public class ParcelleController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
// @GetMapping("/all/by-decoupage")
// public ResponseEntity<?> getAllByDecoupage() {
// try {
// return new ResponseEntity<>(
// new ApiResponse<>(true, enqueteService.getEnqueteCommuneArrondBloc(), "Liste des enquetes chargée avec succès."),
// HttpStatus.OK
// );
// } catch (HttpClientErrorException.MethodNotAllowed e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
// } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
// FileStorageException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
// } catch (NullPointerException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
// } catch (Exception e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
// }
// }
@GetMapping("/id/{id}")
public ResponseEntity<?> getParcelleById(@CurrentUser UserPrincipal currentUser, @PathVariable Long id) {
try {
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleByIdToDto(userId,id), "parcelle trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllParcelle() { public ResponseEntity<?> getAllParcelle(@CurrentUser UserPrincipal currentUser) {
try { try {
if(currentUser==null)
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleList(), "Liste des enquetes chargée avec succès."), new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleListToDto(userId), "Liste des enquetes chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -142,37 +201,19 @@ public class ParcelleController {
} }
} }
@GetMapping("/all/by-decoupage")
public ResponseEntity<?> getAllByDecoupage() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.getEnqueteCommuneArrondBloc(), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllEnquetePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllParcellePaged(@CurrentUser UserPrincipal currentUser,@RequestParam int pageNo, @RequestParam int pageSize) {
try { try {
Pageable pageable = PageRequest.of(pageNo, pageSize); Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleList(pageable), "Liste des enquetes chargée avec succès."), new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleListPageableToDto(userId,pageable), "Liste des enquetes chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -192,38 +233,49 @@ public class ParcelleController {
} }
@PostMapping("/all-paged/multi-criteres")
@GetMapping("/id/{id}") public ResponseEntity<?> getAllParcelleFiltrePaged(@CurrentUser UserPrincipal currentUser, @RequestParam int pageNo, @RequestParam int pageSize, @RequestBody FiltreParcelle filtreParcelle) {
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleById(id), "enquete trouvé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/user-id/{userId}")
public ResponseEntity<?> getParcellesByUserId(@PathVariable Long userId,@RequestParam int pageNo, @RequestParam int pageSize) {
try { try {
Pageable pageable = PageRequest.of(pageNo, pageSize); Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleDataTableListByUserId(userId,pageable), "enquete trouvé avec succès."), new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleByMultiFiltre(userId,filtreParcelle,pageable), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllParcelleByQuartier(@CurrentUser UserPrincipal currentUser,@PathVariable Long quartierId) {
try {
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleListByQuartierToDto(userId,quartierId), "Liste des enquetes chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -242,6 +294,154 @@ public class ParcelleController {
} }
} }
@GetMapping("/all-paged/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllParcelleByQuartierPaged(@CurrentUser UserPrincipal currentUser,@PathVariable Long quartierId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleListByQuartierPageableToDto(userId,quartierId,pageable), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all/by-rue-id/{rueId}")
public ResponseEntity<?> getAllParcelleByRue(@CurrentUser UserPrincipal currentUser,@PathVariable Long rueId) {
try {
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleListByRueToDto(userId,rueId), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/by-rue-id/{rueId}")
public ResponseEntity<?> getAllParcelleByRuePaged(@CurrentUser UserPrincipal currentUser,@PathVariable Long rueId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleListByRuePageableToDto(userId,rueId,pageable), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/syncrhonise-etat-batie-parcelle")
public ResponseEntity<?> putSynchroniseEtatBatieParcelle() {
try {
Integer nombreParcelleSync= parcelleService.majParcelleBatieNonbatie();
return new ResponseEntity<>(
new ApiResponse<>(true,nombreParcelleSync , "Parcelle mise à jour avec succes."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
// @GetMapping("/user-id/{userId}")
// public ResponseEntity<?> getParcellesByUserId(@PathVariable Long userId,@RequestParam int pageNo, @RequestParam int pageSize) {
// try {
// Pageable pageable = PageRequest.of(pageNo, pageSize);
// return new ResponseEntity<>(
// new ApiResponse<>(true, parcelleService.getParcelleDataTableListByUserId(userId,pageable), "enquete trouvé avec succès."),
// HttpStatus.OK
// );
// } catch (HttpClientErrorException.MethodNotAllowed e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
// } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
// FileStorageException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
// } catch (NullPointerException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
// } catch (Exception e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
// }
// }
} }

View File

@@ -20,7 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "ParcelleGeometrie") @Tag(name = "ParcelleGeometrie")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class ParcelleGeomController { public class ParcelleGeomController {
private final ParcelleGeomService parcelleGeomService; private final ParcelleGeomService parcelleGeomService;
@@ -63,6 +63,24 @@ public class ParcelleGeomController {
); );
} }
@GetMapping("/by-quartier-id/{quartierId}")
public ResponseEntity<?> getParcellesGeomsByQuartierId(@PathVariable Long quartierId) {
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomListByQuatierId(quartierId), "Liste des parcelle chargée avec succès."),
HttpStatus.OK
);
}
@GetMapping("/page/by-quartier-id/{quartierId}")
public ResponseEntity<?> getParcellesGeomsByQuartierIdPaged(@PathVariable Long quartierId,@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomListByQuatierIdPaged(quartierId,pageable), "Liste des parcelle chargée avec succès."),
HttpStatus.OK
);
}
@GetMapping("/by-arrondissement/{codeArrondissement}") @GetMapping("/by-arrondissement/{codeArrondissement}")
public ResponseEntity<?> getParcellesGeomsByArrondissement(@PathVariable String codeArrondissement) { public ResponseEntity<?> getParcellesGeomsByArrondissement(@PathVariable String codeArrondissement) {
return new ResponseEntity<>( return new ResponseEntity<>(

View File

@@ -7,12 +7,17 @@ import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.PersonneService; import io.gmss.fiscad.interfaces.infocad.metier.PersonneService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.dto.PersonneCompletDTO; import io.gmss.fiscad.paylaods.dto.PersonneCompletDTO;
import io.gmss.fiscad.paylaods.request.RecherchePersonneResquestBody;
import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb; import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb; import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@@ -36,9 +41,9 @@ public class PersonneController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createPersonne(@RequestBody @Valid @Validated PersonnePayLoadWeb personnePayLoadWeb) { public ResponseEntity<?> createPersonne(@RequestBody @Valid @Validated PersonnePayLoadWeb personnePayLoadWeb) {
try { try {
Personne personne = personneService.createPersonne(personnePayLoadWeb); personnePayLoadWeb = personneService.createPersonne(personnePayLoadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, personne, "Contribuable créé avec succès."), new ApiResponse<>(true, personnePayLoadWeb, "Contribuable créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -99,7 +104,7 @@ public class PersonneController {
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getPersonneById(@PathVariable Long id) { public ResponseEntity<?> getPersonneById(@PathVariable Long id) {
try{ try{
Optional<Personne> optionalPersonne= personneService.getPersonneById(id); Optional<PersonnePayLoadWeb> optionalPersonne= personneService.getPersonneById(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, optionalPersonne.orElse(null), "Personne retrouvée avec succès."), new ApiResponse<>(true, optionalPersonne.orElse(null), "Personne retrouvée avec succès."),
HttpStatus.OK HttpStatus.OK
@@ -111,4 +116,70 @@ public class PersonneController {
); );
} }
} }
@PostMapping("/recherche")
public ResponseEntity<?> rechercherPersonne(@RequestBody RecherchePersonneResquestBody recherchePersonneResquestBody ) {
try{
// personneService.recherchePersonne(recherchePersonneResquestBody);
return new ResponseEntity<>(
new ApiResponse<>(true, personneService.recherchePersonne(recherchePersonneResquestBody), "Personne retrouvée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK
);
}
}
@GetMapping("/all")
public ResponseEntity<?> getAllPersonne() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, personneService.getPersonneList(), "Liste des personnes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged")
public ResponseEntity<?> getAllPersonnePaged(@CurrentUser UserPrincipal currentUser,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, personneService.getPersonneList(pageable), "Liste des personnes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -0,0 +1,272 @@
package io.gmss.fiscad.controllers.infocad.metier;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.PieceService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@AllArgsConstructor
@RestController
@RequestMapping(value = "api/piece", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "Piece")
@CrossOrigin(origins = "*")
public class PieceController {
private final PieceService pieceService;
private static final Logger logger = LoggerFactory.getLogger(PieceController.class);
@PostMapping("/create")
public ResponseEntity<?> createPiece(@RequestBody @Valid @Validated PiecePayLoadWeb piecePayLoadWeb) {
try {
piecePayLoadWeb = pieceService.createPiece(piecePayLoadWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, piecePayLoadWeb, "Piece créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updatePiece(@PathVariable Long id, @RequestBody PiecePayLoadWeb piecePayLoadWeb) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.updatePiece(id,piecePayLoadWeb), "Piece mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@DeleteMapping("/delete/{id}")
public ResponseEntity<?> deletePiece(@PathVariable Long id) {
try {
pieceService.deletePiece(id);
return new ResponseEntity<>(
new ApiResponse<>(true, "Piece supprimée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all")
public ResponseEntity<?> getAllPieceList() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getPieceListToDto(), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged")
public ResponseEntity<?> getAllPiecePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getPieceListToDtoPageable(pageable), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all/by-enquete-id/{enqueteId}")
public ResponseEntity<?> getAllPieceByEnqueteList(@PathVariable Long enqueteId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getAllPieceByEnqueteToDto(enqueteId), "Liste des pieces chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/by-enquete-id/{enqueteId}")
public ResponseEntity<?> getAllPieceByParcellePaged(@PathVariable Long enqueteId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getAllPieceByEnqueteToDtoPageable(enqueteId,pageable), "Liste des pieces chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-enquete-batiment-id/{enqueteBatimentId}")
public ResponseEntity<?> getAllPieceByEnqueteBatiment(@PathVariable Long enqueteBatimentId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getAllPieceByEnqueteBatimentToDto(enqueteBatimentId), "Liste des pieces chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-enquete-unite-logement-id/{enqueteUniteLogementId}")
public ResponseEntity<?> getAllPieceByEnqueteUniteLogement(@PathVariable Long enqueteUniteLogementId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getAllPieceByEnqueteUniteLogementToDto(enqueteUniteLogementId), "Liste des pieces chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}")
public ResponseEntity<?> getPieceById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getPieceByToDto(id), "Piece trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -1,6 +1,7 @@
package io.gmss.fiscad.controllers.infocad.metier; package io.gmss.fiscad.controllers.infocad.metier;
import io.gmss.fiscad.entities.infocad.metier.Upload; import io.gmss.fiscad.entities.infocad.metier.Upload;
import io.gmss.fiscad.interfaces.infocad.metier.UploadService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.JobModels; import io.gmss.fiscad.paylaods.JobModels;
import io.gmss.fiscad.proprietes.ZipStorageProperties; import io.gmss.fiscad.proprietes.ZipStorageProperties;
@@ -8,6 +9,9 @@ import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository;
import io.gmss.fiscad.service.FileStorageService; import io.gmss.fiscad.service.FileStorageService;
import io.gmss.fiscad.service.StringManager; import io.gmss.fiscad.service.StringManager;
import io.gmss.fiscad.service.ZipAsyncService; import io.gmss.fiscad.service.ZipAsyncService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
@@ -45,12 +49,13 @@ import java.util.UUID;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Upload") @Tag(name = "Upload")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class UploadController { public class UploadController {
boolean headIsValid = false; boolean headIsValid = false;
private final ZipAsyncService service; private final ZipAsyncService service;
private final ZipStorageProperties props; private final ZipStorageProperties props;
private final UploadService uploadService;
private static final Logger logger = LoggerFactory.getLogger(UploadController.class); private static final Logger logger = LoggerFactory.getLogger(UploadController.class);
@Autowired @Autowired
@@ -94,7 +99,7 @@ public class UploadController {
try { try {
if (uploadRepository.findById(id).isPresent()) { if (uploadRepository.findById(id).isPresent()) {
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.getOne(id), "File with id {" + id + "} is found."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(true, uploadRepository.findById(id), "File with id {" + id + "} is found."), HttpStatus.OK);
} else { } else {
return new ResponseEntity<>(new ApiResponse(true, null, "The upload with id {" + id + "} you request for is not found."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(true, null, "The upload with id {" + id + "} you request for is not found."), HttpStatus.OK);
} }
@@ -139,30 +144,39 @@ public class UploadController {
.body(resource); .body(resource);
} }
@PostMapping("/save") @PostMapping(
public ResponseEntity<?> save(@RequestPart(required = true) MultipartFile file, @RequestParam String reference, @RequestParam String description /*, @RequestParam Long idTypeUpload*/) { value = "/save",
consumes = MediaType.MULTIPART_FORM_DATA_VALUE
)
public ResponseEntity<?> saveFilePieceId(
@Parameter(
description = "Fichier à uploader",
required = true,
content = @Content(
mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE,
schema = @Schema(type = "string", format = "binary")
)
)
@RequestPart("file") MultipartFile file,
@Parameter(description = "ID de la pièce", required = true)
@RequestParam("pieceId") Long pieceId
) {
try { try {
Upload upload = new Upload(); return ResponseEntity.ok(
String fileName = fileStorageService.storeFile(file); new ApiResponse(true,
upload.setFileName(fileName); uploadService.createUpload(file, pieceId),
upload.setMimeType(file.getContentType()); "File has been created successfully.")
upload.setSize(file.getSize()); );
upload.setOriginalFileName(file.getOriginalFilename());
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.save(upload), "File has been created successfully."), HttpStatus.OK);
} catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NullPointerException e) {
e.printStackTrace();
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getMessage(), e);
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new ApiResponse(false, null, e.getMessage()));
} }
} }
@DeleteMapping("/delete/id/{id}") @DeleteMapping("/delete/id/{id}")
public ResponseEntity<?> delete(@PathVariable Long id) { public ResponseEntity<?> delete(@PathVariable Long id) {
try { try {
@@ -229,4 +243,20 @@ public class UploadController {
.orElse(ResponseEntity.notFound().build()); .orElse(ResponseEntity.notFound().build());
} }
@GetMapping(path = "/by-piece/{pieceId}")
public ResponseEntity<?> getByPiece(@PathVariable("pieceId") Long pieceId) {
try{
return new ResponseEntity<>(new ApiResponse(true, uploadService.getAllUploadByPiece(pieceId), "Liste des fichier de la piece"), HttpStatus.OK);
} catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -28,7 +28,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Bloc") @Tag(name = "Bloc")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class BlocController { public class BlocController {
private final BlocService blocService; private final BlocService blocService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Mode d'acquisition") @Tag(name = "Mode d'acquisition")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class ModeAcquisitionController { public class ModeAcquisitionController {
private final ModeAcquisitionService modeAcquisitionService; private final ModeAcquisitionService modeAcquisitionService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Nature domaine") @Tag(name = "Nature domaine")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class NatureDomaineController { public class NatureDomaineController {
private final NatureDomaineService natureDomaineService; private final NatureDomaineService natureDomaineService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Position représentation") @Tag(name = "Position représentation")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class PositionRepresentationController { public class PositionRepresentationController {
private final PositionRepresentationService positionRepresentationService; private final PositionRepresentationService positionRepresentationService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Profession") @Tag(name = "Profession")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class ProfessionController { public class ProfessionController {
private final ProfessionService professionService; private final ProfessionService professionService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Situation géographique") @Tag(name = "Situation géographique")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class SituationGeographiqueController { public class SituationGeographiqueController {
private final SituationGeographiqueService situationGeographiqueService; private final SituationGeographiqueService situationGeographiqueService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Situation matrimoniale") @Tag(name = "Situation matrimoniale")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class SituationMatrimonialeController { public class SituationMatrimonialeController {
private final SituationMatrimonialeService situationMatrimonialeService; private final SituationMatrimonialeService situationMatrimonialeService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Source de droit") @Tag(name = "Source de droit")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class SourceDroitController { public class SourceDroitController {
private final SourceDroitService sourceDroitService; private final SourceDroitService sourceDroitService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Type de contestation") @Tag(name = "Type de contestation")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class TypeContestationController { public class TypeContestationController {
private final TypeContestationService typeContestationService; private final TypeContestationService typeContestationService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Type de domaine") @Tag(name = "Type de domaine")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class TypeDomaineController { public class TypeDomaineController {
private final TypeDomaineService typeDomaineService; private final TypeDomaineService typeDomaineService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Type de personne") @Tag(name = "Type de personne")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class TypePersonneController { public class TypePersonneController {
private final TypePersonneService typePersonneService; private final TypePersonneService typePersonneService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Type de pièce") @Tag(name = "Type de pièce")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class TypePieceController { public class TypePieceController {
private final TypePieceService typePieceService; private final TypePieceService typePieceService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Type de représentation") @Tag(name = "Type de représentation")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class TypeRepresentationController { public class TypeRepresentationController {
private final TypeRepresentationService typeRepresentationService; private final TypeRepresentationService typeRepresentationService;

View File

@@ -39,9 +39,9 @@ public class BatimentController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createBatiment(@RequestBody @Valid @Validated BatimentPaylaodWeb batimentPaylaodWeb) { public ResponseEntity<?> createBatiment(@RequestBody @Valid @Validated BatimentPaylaodWeb batimentPaylaodWeb) {
try { try {
Batiment batiment = batimentService.createBatiment(batimentPaylaodWeb); batimentPaylaodWeb = batimentService.createBatiment(batimentPaylaodWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, batiment, "Batiment créé avec succès."), new ApiResponse<>(true, batimentPaylaodWeb, "Batiment créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -154,6 +154,53 @@ public class BatimentController {
} }
} }
@GetMapping("/all/by-parcelle-id/{parcelleId}")
public ResponseEntity<?> getAllBatimentByParcelleList(@PathVariable Long parcelleId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, batimentService.getBatimentListByParcelle(parcelleId), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/by-parcelle-id/{parcelleId}")
public ResponseEntity<?> getAllBatimentByParcellePaged(@PathVariable Long parcelleId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, batimentService.getBatimentListByParcellePageable(parcelleId,pageable), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getBatimentById(@PathVariable Long id) { public ResponseEntity<?> getBatimentById(@PathVariable Long id) {
try { try {
@@ -176,4 +223,52 @@ public class BatimentController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all-paged/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllBatimentByQuartierPaged(@PathVariable Long quartierId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, batimentService.getBatimentListByquartierPageable(quartierId,pageable), "Liste des batiments chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllBatimentByQuartier(@PathVariable Long quartierId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, batimentService.getBatimentListByquartier(quartierId), "Liste des batiments chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -5,6 +5,7 @@ import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.CaracteristiqueBatimentPayloadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -21,7 +22,7 @@ import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@RequestMapping(value = "api/caracteristique-caracteristiqueBatiment", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/caracteristique-batiment", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Caractéristique batiment") @Tag(name = "Caractéristique batiment")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@@ -35,34 +36,25 @@ public class CaracteristiqueBatimentController {
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createCaracteristiqueBatiment(@RequestBody @Valid @Validated CaracteristiqueBatiment caracteristiqueBatiment) { public ResponseEntity<?> createCaracteristiqueBatiment(@RequestBody @Valid @Validated CaracteristiqueBatimentPayloadWeb caracteristiqueBatimentPayloadWeb) {
try { try {
caracteristiqueBatiment = caracteristiqueBatimentService.createCaracteristiqueBatiment(caracteristiqueBatiment); caracteristiqueBatimentPayloadWeb = caracteristiqueBatimentService.createCaracteristiqueBatiment(caracteristiqueBatimentPayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatiment, "Caracteristique du batiment créé avec succès."), new ApiResponse<>(true, caracteristiqueBatimentPayloadWeb, "Caracteristique du batiment créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateCaracteristiqueBatiment(@PathVariable Long id, @RequestBody CaracteristiqueBatiment caracteristiqueBatiment) { public ResponseEntity<?> updateCaracteristiqueBatiment(@PathVariable Long id, @RequestBody CaracteristiqueBatimentPayloadWeb caracteristiqueBatimentPayloadWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatimentService.updateCaracteristiqueBatiment(id, caracteristiqueBatiment), "Caracteristique du batiment mise à jour avec succès."), new ApiResponse<>(true, caracteristiqueBatimentService.updateCaracteristiqueBatiment(id, caracteristiqueBatimentPayloadWeb), "Caracteristique du batiment mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -156,7 +148,54 @@ public class CaracteristiqueBatimentController {
public ResponseEntity<?> getCaracteristiqueBatimentById(@PathVariable Long id) { public ResponseEntity<?> getCaracteristiqueBatimentById(@PathVariable Long id) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentById(id), "Caracteristique du batiment trouvée avec succès."), new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentToDto(id), "Caracteristique du batiment trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-enquete-batiment-id/{enqueteBatimentId}")
public ResponseEntity<?> getCaracteristiqueBatimentByBatimentId(@PathVariable Long enqueteBatimentId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentListByEnqueteBatiment(enqueteBatimentId), "Caracteristique du batiment trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-enquete-batiment-id/{enqueteBatimentId}")
public ResponseEntity<?> getCaracteristiqueBatimentByEnqueteBatimentIdPaged(@PathVariable Long enqueteBatimentId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentListByEnqueteBatimentPageable(enqueteBatimentId,pageable), "Caracteristique du batiment trouvée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -5,6 +5,7 @@ import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.CaracteristiqueParcellePayloadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -35,11 +36,11 @@ public class CaracteristiqueParcelleController {
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createCaracteristiqueParcelle(@RequestBody @Valid @Validated CaracteristiqueParcelle caracteristiqueParcelle) { public ResponseEntity<?> createCaracteristiqueParcelle(@RequestBody @Valid @Validated CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb) {
try { try {
caracteristiqueParcelle = caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcelle); caracteristiqueParcellePayloadWeb = caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcellePayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueParcelle, "Caracteristique parcelle créé avec succès."), new ApiResponse<>(true, caracteristiqueParcellePayloadWeb, "Caracteristique parcelle créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -59,10 +60,10 @@ public class CaracteristiqueParcelleController {
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateCaracteristiqueParcelle(@PathVariable Long id, @RequestBody CaracteristiqueParcelle caracteristiqueParcelle) { public ResponseEntity<?> updateCaracteristiqueParcelle(@PathVariable Long id, @RequestBody CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueParcelleService.updateCaracteristiqueParcelle(id, caracteristiqueParcelle), "Caracteristique parcelle mise à jour avec succès."), new ApiResponse<>(true, caracteristiqueParcelleService.updateCaracteristiqueParcelle(id, caracteristiqueParcellePayloadWeb), "Caracteristique parcelle mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -174,4 +175,52 @@ public class CaracteristiqueParcelleController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/by-enquete-id/{enqueteId}")
public ResponseEntity<?> getAllCaracteristiqueParcelleList(@PathVariable Long enqueteId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueParcelleService.getCaracteristiqueParcelleByEnqueteList(enqueteId), "Liste des Caracteristiques parcelles chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-enquete-id/{enqueteId}")
public ResponseEntity<?> getAllCaracteristiqueParcellePaged(@PathVariable Long enqueteId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueParcelleService.getCaracteristiqueParcelleByEnqueteListPageable(enqueteId,pageable), "Liste des Caracteristiques parcelles chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -5,6 +5,7 @@ import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueUniteLogement;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.CaracteristiqueUniteLogementPayloadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -35,11 +36,11 @@ public class CaracteristiqueUniteLogementController {
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createCaracteristiqueUniteLogement(@RequestBody @Valid @Validated CaracteristiqueUniteLogement caracteristiqueUniteLogement) { public ResponseEntity<?> createCaracteristiqueUniteLogement(@RequestBody @Valid @Validated CaracteristiqueUniteLogementPayloadWeb caracteristiqueUniteLogementPayloadWeb) {
try { try {
caracteristiqueUniteLogement = caracteristiqueUniteLogementService.createCaracteristiqueUniteLogement(caracteristiqueUniteLogement); caracteristiqueUniteLogementPayloadWeb = caracteristiqueUniteLogementService.createCaracteristiqueUniteLogement(caracteristiqueUniteLogementPayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueUniteLogement, "Caracteristique Unite Logement créé avec succès."), new ApiResponse<>(true, caracteristiqueUniteLogementPayloadWeb, "Caracteristique Unite Logement créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -59,10 +60,10 @@ public class CaracteristiqueUniteLogementController {
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateCaracteristiqueUniteLogement(@PathVariable Long id, @RequestBody CaracteristiqueUniteLogement caracteristiqueUniteLogement) { public ResponseEntity<?> updateCaracteristiqueUniteLogement(@PathVariable Long id, @RequestBody CaracteristiqueUniteLogementPayloadWeb caracteristiqueUniteLogementPayloadWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueUniteLogementService.updateCaracteristiqueUniteLogement(id, caracteristiqueUniteLogement), "Caracteristique Unite Logement mise à jour avec succès."), new ApiResponse<>(true, caracteristiqueUniteLogementService.updateCaracteristiqueUniteLogement(id, caracteristiqueUniteLogementPayloadWeb), "Caracteristique Unite Logement mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -174,4 +175,51 @@ public class CaracteristiqueUniteLogementController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/by-enquete-ulo-id/{enqueteUloId}")
public ResponseEntity<?> getAllCaracteristiqueUniteLogementListByEul(@PathVariable Long enqueteUloId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueUniteLogementService.getCaracteristiqueUniteLogementListbyEul(enqueteUloId), "Liste des Caracteristiques Unite Logement chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-enquete-ulo-id/{enqueteUloId}")
public ResponseEntity<?> getAllCaracteristiqueUniteLogementByEulPaged(@PathVariable Long enqueteUloId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueUniteLogementService.getCaracteristiqueUniteLogementListByEul(enqueteUloId,pageable), "Liste des Caracteristiques Unite Logement chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -0,0 +1,226 @@
package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.DeclarationNcService;
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteBatimentPayloadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@AllArgsConstructor
@RestController
@RequestMapping(value = "api/declaration-nc", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "Déclaration NC")
@CrossOrigin(origins = "*")
public class DeclarationNcController {
private final DeclarationNcService declarationNcService;
private static final Logger logger = LoggerFactory.getLogger(DeclarationNcController.class);
@PostMapping("/create")
public ResponseEntity<?> createDeclarationNc(@RequestBody @Valid @Validated DeclarationNcPayloadWeb declarationNcPayloadWeb) {
try {
declarationNcPayloadWeb = declarationNcService.createDeclarationNc(declarationNcPayloadWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcPayloadWeb, "Déclaration NC créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateEnqueteBatiment(@PathVariable Long id, @RequestBody DeclarationNcPayloadWeb declarationNcPayloadWeb) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcService.updateDeclarationNc(id, declarationNcPayloadWeb), "Enquete batiment mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteEnqueteBatiment(@PathVariable Long id) {
try {
declarationNcService.deleteDeclarationNc(id);
return new ResponseEntity<>(
new ApiResponse<>(true, "Déclaration Nc supprimée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all")
public ResponseEntity<?> getAllEnqueteBatimentList() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcService.getDeclarationNcList(), "Liste des Enquetes batiments chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged")
public ResponseEntity<?> getAllEnqueteBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcService.getDeclarationNcList(pageable), "Liste des Enquetes batiments chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}")
public ResponseEntity<?> getEnqueteBatimentById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcService.getDeclarationNcById(id), "Enquete batiment trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-personne-id/{personneId}")
public ResponseEntity<?> getDeclarationNcByPersonne(@PathVariable Long personneId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcService.getDeclarationNcByPersonneList(personneId), "Déclarations NC trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-personne-id/{personneId}")
public ResponseEntity<?> getDeclarationNcByPersonnePaged(@PathVariable Long personneId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcService.getDeclarationNcByPersonneList(personneId,pageable), "Déclaration NC trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -7,7 +7,10 @@ import io.gmss.fiscad.enums.StatusAvis;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.DonneesImpositionTfuService; import io.gmss.fiscad.interfaces.rfu.metier.DonneesImpositionTfuService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.ImpositionsTfuPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.rfu.metier.ImpositionsTfuRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.ImpositionsTfuRepository;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@@ -117,7 +120,7 @@ public class DonneesImpositionTfuController {
public ResponseEntity<?> getAllDonneesImpositionTfuList() { public ResponseEntity<?> getAllDonneesImpositionTfuList() {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesImpositionTfuList(), "Liste des caractéristiques chargée avec succès."), new ApiResponse<>(true, donneesImpositionTfuService.getDonneesImpositionTfuList(), "Liste des impositions chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -141,7 +144,105 @@ public class DonneesImpositionTfuController {
try { try {
Pageable pageable = PageRequest.of(pageNo, pageSize); Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesImpositionTfuList(pageable), "Liste des caractéristiques chargée avec succès."), new ApiResponse<>(true, donneesImpositionTfuService.getDonneesImpositionTfuList(pageable), "Liste des impositions chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-page/by-imposition-id/{impositionId}")
public ResponseEntity<?> getAllDonneesImpositionTfuByImpositionIdPaged(@PathVariable Long impositionId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByImpositionTfuIdPageable(impositionId, pageable), "Liste des impositions chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-page/by-imposition-id/non-batie/{impositionId}")
public ResponseEntity<?> getAllDonneesImpositionTfuByImpositionIdNonBatiePaged(@PathVariable Long impositionId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByImpositionTfuIdNonBatiePageable(impositionId, pageable), "Liste des impositions chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-page/by-imposition-id/batie-batiment/{impositionId}")
public ResponseEntity<?> getAllDonneesImpositionTfuByImpositionIdBatieBatimentPaged(@PathVariable Long impositionId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByImpositionTfuIdBatieBatimentPageable(impositionId, pageable), "Liste des impositions chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-page/by-imposition-id/batie-unite-logement/{impositionId}")
public ResponseEntity<?> getAllDonneesImpositionTfuByImpositionIdBatieUniteLogPaged(@PathVariable Long impositionId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByImpositionTfuIdBatieUniteLogPageable(impositionId, pageable), "Liste des impositions chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -182,31 +283,91 @@ public class DonneesImpositionTfuController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@Operation(summary = "Générer les données fiscales TFU") @Operation(summary = "Générer les données fiscales TFU des parcelle baties")
@PostMapping("/generer") @PostMapping("/generer-batie")
public ResponseEntity<?> genererDonneesFiscale(@RequestBody ImpositionsTfu impositionsTfu) { public ResponseEntity<?> genererDonneesFiscaleBatie(@CurrentUser UserPrincipal userPrincipal, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
try { try {
Optional<ImpositionsTfu> optionalImpositionsTfu =impositionsTfuRepository.findById(impositionsTfu.getId()); Optional<ImpositionsTfu> optionalImpositionsTfu =impositionsTfuRepository.findById(impositionsTfuPaylaodWeb.getId());
if(optionalImpositionsTfu.isEmpty()){ if(optionalImpositionsTfu.isEmpty()){
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(false, null, "L'imposition tfu n'est pas trouvée."), new ApiResponse<>(false, null, "L'instance d'imposition n'est pas trouvée."),
HttpStatus.OK HttpStatus.OK
); );
} }
if(!optionalImpositionsTfu.get().getStatusAvis().equals(StatusAvis.CREE)){ if(!optionalImpositionsTfu.get().getStatusAvis().equals(StatusAvis.TFU_FNB_GENERE)){
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(false, null, "le statut actuel ne permet pas cette opération."), new ApiResponse<>(false, null, "l'état actuel : "+optionalImpositionsTfu.get().getStatusAvis()+" ne permet pas cette opération."),
HttpStatus.OK HttpStatus.OK
); );
} }
optionalImpositionsTfu.get().setStatusAvis(StatusAvis.GENERE); if(userPrincipal==null){
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.genererDonneesFiscales(optionalImpositionsTfu.get()), "DonneesImpositionTfu trouvée avec succès."), new ApiResponse<>(false, null, "Vous n'êtes pas autorisé à accéder à cette ressource"),
HttpStatus.OK HttpStatus.OK
); );
}
impositionsTfuPaylaodWeb=donneesImpositionTfuService.genererDonneesFiscalesParcelleBatie(impositionsTfuPaylaodWeb,userPrincipal.getUser().getId());
return new ResponseEntity<>(
new ApiResponse<>(true,impositionsTfuPaylaodWeb, "Données d'imposition des fonciers batis Générées avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@Operation(summary = "Générer les données fiscales TFU des parcelle baties")
@PostMapping("/generer-non-batie")
public ResponseEntity<?> genererDonneesImpositionNonBaties(@CurrentUser UserPrincipal userPrincipal, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
try {
Optional<ImpositionsTfu> optionalImpositionsTfu =impositionsTfuRepository.findById(impositionsTfuPaylaodWeb.getId());
if(optionalImpositionsTfu.isEmpty()){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "L'instance d'imposition n'est pas trouvée."),
HttpStatus.OK
);
}
if(!optionalImpositionsTfu.get().getStatusAvis().equals(StatusAvis.GENERATION_AUTORISE)){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "l'état actuel : "+optionalImpositionsTfu.get().getStatusAvis()+" ne permet pas cette opération."),
HttpStatus.OK
);
}
if(userPrincipal==null){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "Vous n'êtes pas autorisé à accéder à cette ressource"),
HttpStatus.OK
);
}
impositionsTfuPaylaodWeb=donneesImpositionTfuService.genererDonneesFiscalesParcelleNonBatie(impositionsTfuPaylaodWeb,userPrincipal.getUser().getId());
return new ResponseEntity<>(
new ApiResponse<>(true,impositionsTfuPaylaodWeb, "Données d'imposition pour les fonciers non batis Générées avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
@@ -273,4 +434,79 @@ public class DonneesImpositionTfuController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all-page/by-exercice-id/by-structure-id/{exerciceId}/{structureId}")
public ResponseEntity<?> getAllDonneesImpositionTfuByExerciceIdAndStructureIdPaged(@PathVariable Long exerciceId, @PathVariable Long structureId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
System.out.println("NOUS SOMMES ICI");
return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByExerciceAndStructureIdPageable(exerciceId,structureId, pageable), "Liste des impositions chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all/by-exercice-id/by-structure-id/by-quartier-id/{exerciceId}/{structureId}/{quartierId}")
public ResponseEntity<?> getAllDonneesImpositionTfuByExerciceIdAndStructureId(@PathVariable Long exerciceId, @PathVariable Long structureId, @PathVariable Long quartierId) {
try {
System.out.println("NOUS SOMMES ICI");
return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByExerciceAndStructureId(exerciceId,structureId,quartierId), "Liste des imposition chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all/by-personne-id/{personneId}")
public ResponseEntity<?> getAllDonneesImpositionTfuByPersonneId(@PathVariable Long personneId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByPersonneId(personneId), "Liste des impositions chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -2,10 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment; import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
import io.gmss.fiscad.enums.StatutEnquete;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService; import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteBatimentPayloadWeb; import io.gmss.fiscad.paylaods.request.crudweb.EnqueteBatimentPayloadWeb;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -20,6 +24,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import java.util.List;
@RestController @RestController
@RequestMapping(value = "api/enquete-batiment", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/enquete-batiment", produces = MediaType.APPLICATION_JSON_VALUE)
@@ -38,9 +44,9 @@ public class EnqueteBatimentController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createEnqueteBatiment(@RequestBody @Valid @Validated EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) { public ResponseEntity<?> createEnqueteBatiment(@RequestBody @Valid @Validated EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) {
try { try {
EnqueteBatiment enqueteBatiment = enqueteBatimentService.createEnqueteBatiment(enqueteBatimentPayloadWeb); enqueteBatimentPayloadWeb = enqueteBatimentService.createEnqueteBatiment(enqueteBatimentPayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatiment, "Enquete batiment créé avec succès."), new ApiResponse<>(true, enqueteBatimentPayloadWeb, "Enquete batiment créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -51,6 +57,7 @@ public class EnqueteBatimentController {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) { } catch (NullPointerException e) {
e.printStackTrace();
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
@@ -176,4 +183,206 @@ public class EnqueteBatimentController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/by-batiment-id/{batimentId}")
public ResponseEntity<?> getEnqueteBatimentByBatimentId(@PathVariable Long batimentId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentByBatimentList(batimentId), "Enquete batiment trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-batiment-id/{batimentId}")
public ResponseEntity<?> getEnqueteBatimentByBatimentIdPaged(@PathVariable Long batimentId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentByBatimentListPageable(batimentId,pageable), "Enquete batiment trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/en-cours/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllEnqueteBatimentEnCoursByQuartierPaged(@CurrentUser UserPrincipal currentUser, @PathVariable Long quartierId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentListByQuartierByStatutPageableToDto(userId,quartierId, StatutEnquete.EN_COURS, pageable), "Liste des enquetes en cours chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/cloture/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllEnqueteBatimentClotureByQuartierPaged(@CurrentUser UserPrincipal currentUser, @PathVariable Long quartierId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentListByQuartierByStatutPageableToDto(userId,quartierId, StatutEnquete.CLOTURE, pageable), "Liste des enquetes en cours chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/validation")
public ResponseEntity<?> validerEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatimentService.validerEnquete(enqueteTraitementPayLoad), "Validation effectuée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/rejet")
public ResponseEntity<?> rejeterEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatimentService.rejeterEnquete(enqueteTraitementPayLoad), "Rejet effectuée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/validation-lot")
public ResponseEntity<?> validerEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatimentService.validerEnquete(enqueteTraitementPayLoads), "Validation effectuée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/rejet-lot")
public ResponseEntity<?> rejeterEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatimentService.rejeterEnquete(enqueteTraitementPayLoads), "Rejet effectuée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -2,10 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement; import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement;
import io.gmss.fiscad.enums.StatutEnquete;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteUniteLogementService; import io.gmss.fiscad.interfaces.rfu.metier.EnqueteUniteLogementService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteUniteLogementPayloadWeb; import io.gmss.fiscad.paylaods.request.crudweb.EnqueteUniteLogementPayloadWeb;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -20,6 +24,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import java.util.List;
@RestController @RestController
@RequestMapping(value = "api/enquete-unite-logement", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/enquete-unite-logement", produces = MediaType.APPLICATION_JSON_VALUE)
@@ -38,9 +44,9 @@ public class EnqueteUniteLogementController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createEnqueteUniteLogement(@RequestBody @Valid @Validated EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) { public ResponseEntity<?> createEnqueteUniteLogement(@RequestBody @Valid @Validated EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) {
try { try {
EnqueteUniteLogement enqueteUniteLogement = enqueteUniteLogementService.createEnqueteUniteLogement(enqueteUniteLogementPayloadWeb); enqueteUniteLogementPayloadWeb = enqueteUniteLogementService.createEnqueteUniteLogement(enqueteUniteLogementPayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogement, "Enquete unite logement créé avec succès."), new ApiResponse<>(true, enqueteUniteLogementPayloadWeb, "Enquete unite logement créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -176,4 +182,207 @@ public class EnqueteUniteLogementController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/by-unite-logement-id/{uniteLogementId}")
public ResponseEntity<?> getEnqueteUniteLogementByUniteLogement(@PathVariable Long uniteLogementId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementUniteLogementList(uniteLogementId), "Enquete unite de logement trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-unite-logement-id/{uniteLogementId}")
public ResponseEntity<?> getEnqueteUniteLogementByUniteLogementPaged(@PathVariable Long uniteLogementId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementByUniteLogementListPageable(uniteLogementId,pageable), "Enquete unite de logement trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/en-cours/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllEnqueteUniteLogementEncoursByQuartierPaged(@CurrentUser UserPrincipal currentUser, @PathVariable Long quartierId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementListByQuartierByStatutPageableToDto(userId,quartierId, StatutEnquete.EN_COURS, pageable), "Liste des enquetes en cours chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/cloture/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllEnqueteUniteLogementClotureByQuartierPaged(@CurrentUser UserPrincipal currentUser, @PathVariable Long quartierId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementListByQuartierByStatutPageableToDto(userId,quartierId, StatutEnquete.CLOTURE, pageable), "Liste des enquetes en cours chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/validation")
public ResponseEntity<?> validerEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.validerEnquete(enqueteTraitementPayLoad), "Validation effectuée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/rejet")
public ResponseEntity<?> rejeterEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.rejeterEnquete(enqueteTraitementPayLoad), "Rejet effectuée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/validation-lot")
public ResponseEntity<?> validerEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.validerEnquete(enqueteTraitementPayLoads), "Validation effectuée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/rejet-lot")
public ResponseEntity<?> rejeterEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.rejeterEnquete(enqueteTraitementPayLoads), "Rejet effectuée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -2,12 +2,21 @@ package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.ImpositionsTfu; import io.gmss.fiscad.entities.rfu.metier.ImpositionsTfu;
import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.StatusAvis;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
import io.gmss.fiscad.interfaces.rfu.metier.ImpositionsTfuService; import io.gmss.fiscad.interfaces.rfu.metier.ImpositionsTfuService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.ImpositionsTfuPaylaodWeb;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.ws.rs.NotAcceptableException;
import lombok.AllArgsConstructor;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
@@ -21,6 +30,7 @@ import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@AllArgsConstructor
@RequestMapping(value = "api/impositions-tfu", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/impositions-tfu", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Impositions TFU") @Tag(name = "Impositions TFU")
@@ -28,41 +38,32 @@ import org.springframework.web.client.HttpClientErrorException;
public class ImpositionsTfuController { public class ImpositionsTfuController {
private final ImpositionsTfuService impositionsTfuService; private final ImpositionsTfuService impositionsTfuService;
private final EnqueteService enqueteService;
private static final Logger logger = LoggerFactory.getLogger(ImpositionsTfuController.class); private static final Logger logger = LoggerFactory.getLogger(ImpositionsTfuController.class);
public ImpositionsTfuController(ImpositionsTfuService impositionsTfuService) {
this.impositionsTfuService = impositionsTfuService;
}
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createImpositionsTfu(@RequestBody @Valid @Validated ImpositionsTfu impositionsTfu) { public ResponseEntity<?> createImpositionsTfu(@CurrentUser UserPrincipal currentUser,@RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
try { try {
impositionsTfu = impositionsTfuService.createImpositionsTfu(impositionsTfu); if(currentUser==null){
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfu, "Unite de logement créé avec succès."), new ApiResponse<>(false, null, "Vous n'etes pas autorisé à accéder à cette ressource."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
User user=currentUser.getUser();
if(user.getStructure().getId()!=impositionsTfuPaylaodWeb.getStructureId()){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "Vous n'etes pas autorisé à accéder à cette ressource."),
HttpStatus.OK
);
} }
@PutMapping("/update/{id}") impositionsTfuPaylaodWeb = impositionsTfuService.createImpositionsTfu(impositionsTfuPaylaodWeb);
public ResponseEntity<?> updateImpositionsTfu(@PathVariable Long id, @RequestBody ImpositionsTfu impositionsTfu) {
try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.updateImpositionsTfu(id, impositionsTfu), "Unite de logement mise à jour avec succès."), new ApiResponse<>(true, impositionsTfuPaylaodWeb, "Unite de logement créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -82,11 +83,27 @@ public class ImpositionsTfuController {
} }
@PutMapping("/valider/{id}") @PutMapping("/cloturer-enquete")
public ResponseEntity<?> validerImpositionsTfu(@RequestBody ImpositionsTfu impositionsTfu) { public ResponseEntity<?> cloturer(@CurrentUser UserPrincipal userPrincipal, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb ) {
try { try {
if(userPrincipal==null){
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.validerImpositionsTfu(impositionsTfu), "Unite de logement mise à jour avec succès."), new ApiResponse<>(true, null, "Accès non autorisé"),
HttpStatus.NOT_ACCEPTABLE
);
}
User user= userPrincipal.getUser();
if(user.getStructure().getId()!=impositionsTfuPaylaodWeb.getStructureId()){
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous n'êtes pas autorisé à cloturer les enquetes du : "+user.getStructure().getNom()),
HttpStatus.OK
);
}
return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.cloturerImpositionsTfu(impositionsTfuPaylaodWeb), "enquete cloturées avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -105,11 +122,62 @@ public class ImpositionsTfuController {
} }
} }
@PutMapping("/annuler/{id}") // @PutMapping("/update/{id}")
public ResponseEntity<?> annulerImpositionsTfu(@PathVariable Long id, @RequestBody ImpositionsTfu impositionsTfu) { // public ResponseEntity<?> updateImpositionsTfu(@PathVariable Long id, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
// try {
// return new ResponseEntity<>(
// new ApiResponse<>(true, impositionsTfuService.updateImpositionsTfu(id, impositionsTfuPaylaodWeb), "Unite de logement mise à jour avec succès."),
// HttpStatus.OK
// );
// } catch (HttpClientErrorException.MethodNotAllowed e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
// } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
// FileStorageException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
// } catch (NullPointerException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
// } catch (Exception e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
// }
// }
@Operation(
summary = "Autoriser la génération des avis d'un centre",
description = "Permet d'autoriser la génération des avis d'un centre pour un exervice données"
)
@PutMapping("/autoriser-generation-avis")
public ResponseEntity<?> autoriserImpositionsTfu(@RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.annulerImpositionsTfu(impositionsTfu), "Unite de logement mise à jour avec succès."), new ApiResponse<>(true, impositionsTfuService.autoriserGenerationImpositionsTfu(impositionsTfuPaylaodWeb), "Unite de logement mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/rejeter")
public ResponseEntity<?> annulerImpositionsTfu(@RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.rejeterImpositionsTfu(impositionsTfuPaylaodWeb), "Unite de logement mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -152,11 +220,19 @@ public class ImpositionsTfuController {
} }
} }
@GetMapping("/all") @GetMapping("/all/by-user")
public ResponseEntity<?> getAllImpositionsTfuList() { public ResponseEntity<?> getAllImpositionsTfuList(@CurrentUser UserPrincipal userPrincipal) {
try { try {
if(userPrincipal==null){
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.getImpositionsTfuList(), "Liste des Enquetes des unites Logements chargée avec succès."), new ApiResponse<>(true, null, "Vous n'êtes pas autorisé à acceder à cette ressource"),
HttpStatus.OK
);
}
User user= userPrincipal.getUser();
return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.getImpositionsTfuByUserIdIds(user.getId()), "Liste des Enquetes des unites Logements chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -5,6 +5,7 @@ import io.gmss.fiscad.entities.rfu.metier.UniteLogement;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService; import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -35,11 +36,11 @@ public class UniteLogementController {
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createUniteLogement(@RequestBody @Valid @Validated UniteLogement enqueteUniteLogement) { public ResponseEntity<?> createUniteLogement(@RequestBody @Valid @Validated UniteLogementPaylaodWeb enqueteUniteLogementPaylaodWeb) {
try { try {
enqueteUniteLogement = enqueteUniteLogementService.createUniteLogement(enqueteUniteLogement); enqueteUniteLogementPaylaodWeb = enqueteUniteLogementService.createUniteLogement(enqueteUniteLogementPaylaodWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogement, "Unite de logement créé avec succès."), new ApiResponse<>(true, enqueteUniteLogementPaylaodWeb, "Unite de logement créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -59,10 +60,10 @@ public class UniteLogementController {
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateUniteLogement(@PathVariable Long id, @RequestBody UniteLogement enqueteUniteLogement) { public ResponseEntity<?> updateUniteLogement(@PathVariable Long id, @RequestBody UniteLogementPaylaodWeb enqueteUniteLogementPaylaodWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.updateUniteLogement(id, enqueteUniteLogement), "Unite de logement mise à jour avec succès."), new ApiResponse<>(true, enqueteUniteLogementService.updateUniteLogement(id, enqueteUniteLogementPaylaodWeb), "Unite de logement mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -153,6 +154,54 @@ public class UniteLogementController {
} }
} }
@GetMapping("/all/by-batiment-id/{batimentId}")
public ResponseEntity<?> getAllUniteLogementListByBatiment(@PathVariable Long batimentId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementListByBatiment(batimentId), "Liste des Enquetes des unites Logements chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/by-batiment-id/{batimentId}")
public ResponseEntity<?> getAllUniteLogementByBatimentPaged(@PathVariable Long batimentId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementListByBatimentPageable(batimentId,pageable), "Liste des enquetes des unites de logements chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getUniteLogementById(@PathVariable Long id) { public ResponseEntity<?> getUniteLogementById(@PathVariable Long id) {
try { try {
@@ -175,4 +224,77 @@ public class UniteLogementController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/by-parcelle-id/{id}")
public ResponseEntity<?> getUniteLogementByParcelleId(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementListByParcelle(id), "Unite de de logement trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllUniteLogementByQuartierPaged(@PathVariable Long quartierId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementListByQuartierPageable(quartierId,pageable), "Liste des unites de logements chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllUniteLogementByQuartier(@PathVariable Long quartierId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementListByQuartier(quartierId), "Liste des unites de logements chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -2,8 +2,9 @@ package io.gmss.fiscad.controllers.rfu.parametre;
import io.gmss.fiscad.entities.rfu.parametre.BaremRfuBati; import io.gmss.fiscad.entities.rfu.parametre.BaremRfuBati;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuService; import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuBatiService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.BaremRfuBatiPayloadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -24,20 +25,20 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Barem Rfu") @Tag(name = "Barem Rfu")
public class BaremRfuController { public class BaremRfuController {
private final BaremRfuService baremRfuService; private final BaremRfuBatiService baremRfuBatiService;
private static final Logger logger = LoggerFactory.getLogger(BaremRfuController.class); private static final Logger logger = LoggerFactory.getLogger(BaremRfuController.class);
public BaremRfuController(BaremRfuService baremRfuService) { public BaremRfuController(BaremRfuBatiService baremRfuBatiService) {
this.baremRfuService = baremRfuService; this.baremRfuBatiService = baremRfuBatiService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createBaremRfu(@RequestBody @Valid @Validated BaremRfuBati baremRfuBati) { public ResponseEntity<?> createBaremRfu(@RequestBody @Valid @Validated BaremRfuBatiPayloadWeb baremRfuBatiPayloadWeb) {
try { try {
baremRfuBati = baremRfuService.createBaremRfu(baremRfuBati); baremRfuBatiPayloadWeb = baremRfuBatiService.createBaremRfu(baremRfuBatiPayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuBati, "BaremRfuBati créé avec succès."), new ApiResponse<>(true, baremRfuBatiPayloadWeb, "BaremRfuBati créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -57,10 +58,10 @@ public class BaremRfuController {
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateBaremRfu(@PathVariable Long id, @RequestBody BaremRfuBati baremRfuBati) { public ResponseEntity<?> updateBaremRfu(@PathVariable Long id, @RequestBody BaremRfuBatiPayloadWeb baremRfuBatiPayloadWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuService.updateBaremRfu(id, baremRfuBati), "BaremRfuBati mis à jour avec succès."), new ApiResponse<>(true, baremRfuBatiService.updateBaremRfu(id, baremRfuBatiPayloadWeb), "BaremRfuBati mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -82,7 +83,7 @@ public class BaremRfuController {
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteBaremRfur(@PathVariable Long id) { public ResponseEntity<?> deleteBaremRfur(@PathVariable Long id) {
try { try {
baremRfuService.deleteBaremRfu(id); baremRfuBatiService.deleteBaremRfu(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, "BaremRfuBati supprimée avec succès."), new ApiResponse<>(true, "BaremRfuBati supprimée avec succès."),
HttpStatus.OK HttpStatus.OK
@@ -107,7 +108,7 @@ public class BaremRfuController {
public ResponseEntity<?> getAllBaremRfuList() { public ResponseEntity<?> getAllBaremRfuList() {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuService.getBaremRfuList(), "Liste des baremRfus chargée avec succès."), new ApiResponse<>(true, baremRfuBatiService.getBaremRfuList(), "Liste des baremRfus chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -132,7 +133,7 @@ public class BaremRfuController {
Pageable pageable = PageRequest.of(pageNo, pageSize); Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuService.getBaremRfuList(pageable), "Liste des baremRfus chargée avec succès."), new ApiResponse<>(true, baremRfuBatiService.getBaremRfuList(pageable), "Liste des baremRfus chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -155,7 +156,7 @@ public class BaremRfuController {
public ResponseEntity<?> getBaremRfuById(@PathVariable Long id) { public ResponseEntity<?> getBaremRfuById(@PathVariable Long id) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuService.getBaremRfuById(id), "BaremRfuBati trouvée avec succès."), new ApiResponse<>(true, baremRfuBatiService.getBaremRfuById(id), "BaremRfuBati trouvée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -174,13 +175,68 @@ public class BaremRfuController {
} }
} }
@GetMapping("/categorie-batiment/{idCategorieBatiment}") @GetMapping("/by-categorie-batiment-id/{idCategorieBatiment}")
public ResponseEntity<?> getBaremRfuByType( //@Parameter(description = "ID de la catégorie de bâtiment", required = true) public ResponseEntity<?> getBaremRfuByType( //@Parameter(description = "ID de la catégorie de bâtiment", required = true)
@PathVariable Long idCategorieBatiment) { @PathVariable Long idCategorieBatiment) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuService.getBaremRfuByType(idCategorieBatiment), "Liste des baremRfu par categorie de batiments chargée avec succès."), new ApiResponse<>(true, baremRfuBatiService.getBaremRfuByCategorieBatiment(idCategorieBatiment), "Liste des baremRfu par categorie de batiments chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-arrondissement-id/by-categorie-batiment-id/{idArrondissement}/{idCategorieBatiment}")
public ResponseEntity<?> getBaremRfuByArrondisementAndCategorie( //@Parameter(description = "ID de la catégorie de bâtiment", required = true)
@PathVariable Long idArrondissement,
@PathVariable Long idCategorieBatiment
) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuBatiService.getBaremRfuByArrondissementAndCategorieBatiment(idArrondissement,idCategorieBatiment), "Liste des baremRfu par categorie de batiments chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-quartier-id/by-categorie-batiment-id/{idQuartier}/{idCategorieBatiment}")
public ResponseEntity<?> getBaremRfuByQuartierAndCategorie( //@Parameter(description = "ID de la catégorie de bâtiment", required = true)
@PathVariable Long idQuartier,
@PathVariable Long idCategorieBatiment
) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuBatiService.getBaremRfuByQuartierAndCategorieBatiment(idQuartier,idCategorieBatiment), "Liste des baremRfu par categorie de batiments chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -4,6 +4,7 @@ import io.gmss.fiscad.entities.rfu.parametre.BaremRfuNonBati;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuNonBatiService; import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuNonBatiService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.BaremRfuNonBatiPayloadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -34,11 +35,11 @@ public class BaremRfuNonBatiController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createBaremRfuNonBati(@RequestBody @Valid @Validated BaremRfuNonBati baremRfuNonBati) { public ResponseEntity<?> createBaremRfuNonBati(@RequestBody BaremRfuNonBatiPayloadWeb baremRfuNonBatiPayloadWeb) {
try { try {
baremRfuNonBati = baremRfuNonBatiService.createBaremRfuNonBati(baremRfuNonBati); baremRfuNonBatiPayloadWeb = baremRfuNonBatiService.createBaremRfuNonBati(baremRfuNonBatiPayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuNonBati, "BaremRfuNonBati créé avec succès."), new ApiResponse<>(true, baremRfuNonBatiPayloadWeb, "BaremRfuNonBati créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -58,10 +59,10 @@ public class BaremRfuNonBatiController {
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateBaremRfuNonBati(@PathVariable Long id, @RequestBody BaremRfuNonBati baremRfuNonBati) { public ResponseEntity<?> updateBaremRfuNonBati(@PathVariable Long id, @RequestBody BaremRfuNonBatiPayloadWeb baremRfuNonBatiPayloadWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuNonBatiService.updateBaremRfuNonBati(id, baremRfuNonBati), "BaremRfuNonBati mis à jour avec succès."), new ApiResponse<>(true, baremRfuNonBatiService.updateBaremRfuNonBati(id, baremRfuNonBatiPayloadWeb), "BaremRfuNonBati mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -156,7 +157,31 @@ public class BaremRfuNonBatiController {
public ResponseEntity<?> getBaremRfuNonBatiById(@PathVariable Long id) { public ResponseEntity<?> getBaremRfuNonBatiById(@PathVariable Long id) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuNonBatiService.getBaremRfuNonBatiById(id), "BaremRfuNonBati trouvée avec succès."), new ApiResponse<>(true, baremRfuNonBatiService.getBaremRfuNonBatiById(id).orElse(null), "BaremRfuNonBati trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-commune-id/by-zone-id/{communeId}/{zoneId}")
public ResponseEntity<?> getBaremRfuNonBatiByCommineAndZoneId(@PathVariable Long communeId, Long zoneId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuNonBatiService.getBaremRfuNonBatiByCommuneAndZoneId(communeId,zoneId).orElse(null), "BaremRfuNonBati trouvée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -0,0 +1,180 @@
package io.gmss.fiscad.controllers.rfu.parametre;
import io.gmss.fiscad.entities.rfu.parametre.Usage;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.parametre.UsageService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController
@RequestMapping(value = "api/usage", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "Usage")
public class UsageController {
private final UsageService usageService;
private static final Logger logger = LoggerFactory.getLogger(UsageController.class);
public UsageController(UsageService usageService) {
this.usageService = usageService;
}
@PostMapping("/create")
public ResponseEntity<?> createUsage(@RequestBody @Valid @Validated Usage usage) {
try {
usage = usageService.createUsage(usage);
return new ResponseEntity<>(
new ApiResponse<>(true, usage, "Usage créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateUsage(@PathVariable Long id, @RequestBody Usage usage) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, usageService.updateUsage(id, usage), "Usage mis à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteUsager(@PathVariable Long id) {
try {
usageService.deleteUsage(id);
return new ResponseEntity<>(
new ApiResponse<>(true, "Usage supprimée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all")
public ResponseEntity<?> getAllUsageList() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, usageService.getUsageList(), "Liste des usages chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged")
public ResponseEntity<?> getAllUsagePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, usageService.getUsageList(pageable), "Liste des usages chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}")
public ResponseEntity<?> getUsageById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, usageService.getUsageById(id), "Usage trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -1,9 +1,12 @@
package io.gmss.fiscad.controllers.statistique; package io.gmss.fiscad.controllers.statistique;
import io.gmss.fiscad.enums.NiveauDecoupage; import io.gmss.fiscad.enums.NiveauDecoupage;
import io.gmss.fiscad.enums.StatutEnquete;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.statistique.StatistiquesService; import io.gmss.fiscad.interfaces.statistique.StatistiquesService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@@ -174,4 +177,77 @@ public class StatistiqueController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@Operation(
summary = "Statistique des enquetes en cours par object ",
description = "Donnes le nombre d'enquetes en coures par objet"
)
@GetMapping(path = "/nombre-enquete/par-objet/en-cours")
public ResponseEntity<?> getStatistiquesEnqueteEnCoursParObjet(@CurrentUser UserPrincipal currentUser) {
try {
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, statistiquesService.getStatNombreEnqueteParObjetUserConnect(userId,StatutEnquete.EN_COURS.toString()), "Statistique des personne par type."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@Operation(
summary = "Statistique des enquetes en cours par object ",
description = "Donnes le nombre d'enquetes en coures par objet"
)
@GetMapping(path = "/nombre-enquete/par-objet/cloture")
public ResponseEntity<?> getStatistiquesEnqueteClotureParObjet(@CurrentUser UserPrincipal currentUser) {
try {
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, statistiquesService.getStatNombreEnqueteParObjetUserConnect(userId, StatutEnquete.CLOTURE.toString()), "Statistique des personne par type."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -22,7 +22,7 @@ import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@RequestMapping(value = "api/profile", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/profil", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Profile") @Tag(name = "Profile")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")

View File

@@ -94,7 +94,7 @@ public class UserController {
@PostMapping("/reset-password") @PostMapping("/reset-password")
public ResponseEntity<?> resetUserPassword(@RequestBody @Valid @Validated Login login) { public ResponseEntity<?> resetUserPassword(@RequestBody @Valid @Validated Login login) {
try { try {
UserPaylaodWeb userPaylaodWeb= userService.resetPassword(login.getUsername(), login.getPassword()); UserPaylaodWeb userPaylaodWeb= userService.resetPassword(login.getUsername());
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, userPaylaodWeb, "Votre mot de passe à été réinitialisée avec succès."), new ApiResponse<>(true, userPaylaodWeb, "Votre mot de passe à été réinitialisée avec succès."),
HttpStatus.OK HttpStatus.OK
@@ -163,31 +163,37 @@ public class UserController {
} }
} }
@GetMapping("/activate-or-not/{id}") @GetMapping("/activate/{id}")
public ResponseEntity<?> acitvateOrNotUser(@PathVariable Long id) { public ResponseEntity<?> acitvateUser(@PathVariable Long id) {
try { try {
User user = userService.activateUser(id);
User user = userService.getUserById(id);
// if(user.getAvoirFonctions().isEmpty()){
// return new ResponseEntity<>(
// new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."),
// HttpStatus.OK
// );
// }
if(user.isResetPassword()){
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."), new ApiResponse<>(true, user, "Utilisateur activé avec succès"),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
user = userService.activateOrNotUser(id);
String message = "Utilisateur activé avec succès";
if (!user.isActive()) {
message = "Utilisateur désactivé avec succès";
} }
@GetMapping("/desactivate/{id}")
public ResponseEntity<?> disacitvateUser(@PathVariable Long id) {
try {
User user = userService.disactivateUser(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, user, message), new ApiResponse<>(true, user, "Utilisateur désactivé avec succès"),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -330,14 +336,6 @@ public class UserController {
} }
// @GetMapping("/all-paged")
// public ResponseEntity<?> getAllpaged(@RequestParam int pageNo, @RequestParam int pageSize) {
// Pageable pageable = PageRequest.of(pageNo, pageSize);
// return new ResponseEntity<>(
// new ApiResponse<>(true, userService.getUserList(pageable), "Liste des utilisateurs chargée avec succès."),
// HttpStatus.OK
// );
// }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getUserById(@PathVariable Long id) { public ResponseEntity<?> getUserById(@PathVariable Long id) {

View File

@@ -0,0 +1,28 @@
package io.gmss.fiscad.entities;
import io.gmss.fiscad.entities.audit.UserDateAudit;
import io.gmss.fiscad.enums.ParametersType;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Entity
@Getter
@Setter
public class Parameters extends UserDateAudit implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Enumerated(EnumType.STRING)
private ParametersType name;
private String value;
public Parameters() {
}
}

View File

@@ -0,0 +1,43 @@
package io.gmss.fiscad.entities.audit;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.io.Serializable;
import java.time.Instant;
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class DateAudit implements Serializable {
@JsonIgnore
@CreatedDate
// @Column(updatable = false)
private Instant createdAt= Instant.now() ;
@JsonIgnore
@LastModifiedDate
// @Column(nullable = false)
private Instant updatedAt=Instant.now();
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public Instant getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
}

View File

@@ -0,0 +1,37 @@
package io.gmss.fiscad.entities.audit;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.LastModifiedBy;
import java.io.Serializable;
@MappedSuperclass
public abstract class UserDateAudit extends DateAudit implements Serializable {
@JsonIgnore
@CreatedBy
@Column(updatable = false)
private Long createdBy;
@JsonIgnore
@LastModifiedBy
private Long updatedBy;
public Long getCreatedBy() {
return createdBy;
}
public void setCreatedBy(Long createdBy) {
this.createdBy = createdBy;
}
public Long getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(Long updatedBy) {
this.updatedBy = updatedBy;
}
}

View File

@@ -29,6 +29,8 @@ public class Quartier extends BaseEntity implements Serializable {
@ManyToOne @ManyToOne
private Arrondissement arrondissement; private Arrondissement arrondissement;
private String longitude;
private String latitude;
// @JsonIgnore // @JsonIgnore
// @OneToOne(mappedBy = "quartier") // @OneToOne(mappedBy = "quartier")
// private Bloc bloc; // private Bloc bloc;

View File

@@ -8,6 +8,7 @@ import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Arrondissement; import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.infocad.parametre.Bloc; import io.gmss.fiscad.entities.infocad.parametre.Bloc;
import io.gmss.fiscad.entities.infocad.parametre.ModeAcquisition;
import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine; import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
import io.gmss.fiscad.entities.infocad.parametre.Personne; import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle; import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
@@ -54,16 +55,30 @@ public class Enquete extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateEnquete; private LocalDate dateEnquete;
private boolean litige;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDebutExemption;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExemption;
private Boolean litige;
@ManyToOne @ManyToOne
private User user; private User user;
@JsonIgnore //@JsonIgnore
@ManyToOne @ManyToOne
private Exercice exercice; private Exercice exercice;
@JsonIgnore
@ManyToOne
private ModeAcquisition modeAcquisition;
private Long mobileDataId; private Long mobileDataId;
@JsonIgnore @JsonIgnore
@@ -84,9 +99,9 @@ public class Enquete extends BaseEntity implements Serializable {
@ManyToOne @ManyToOne
private Campagne campagne; private Campagne campagne;
@JsonIgnore // @JsonIgnore
@ManyToOne // @ManyToOne
private Equipe equipe; // private Equipe equipe;
// @JsonIgnore // @JsonIgnore
@ManyToOne @ManyToOne
@@ -116,7 +131,7 @@ public class Enquete extends BaseEntity implements Serializable {
@JsonFormat(pattern = "dd-MM-yyyy") @JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateSynchronisation; private LocalDate dateSynchronisation;
private boolean synchronise; private Boolean synchronise;
private String observationParticuliere; private String observationParticuliere;
@Transient @Transient
private String nomPrenomEnqueteur; private String nomPrenomEnqueteur;
@@ -173,6 +188,8 @@ public class Enquete extends BaseEntity implements Serializable {
private Long montantAnnuelleLocation; private Long montantAnnuelleLocation;
private Long valeurParcelleEstime; private Long valeurParcelleEstime;
private Long valeurParcelleReel; private Long valeurParcelleReel;
private Long valeurParcelleCalcule;
private String ncProprietaire;
@JsonFormat(pattern = "dd-MM-yyyy") @JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
@@ -182,15 +199,20 @@ public class Enquete extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExcemption; private LocalDate dateFinExcemption;
@JsonIgnore private String representantNom;
@OneToMany(mappedBy = "enquete") private String representantPrenom;
@JsonManagedReference private String representantTel;
private List<EnqueteUniteLogement> enqueteUniteLogements; private String representantNpi;
//
// @JsonIgnore
// @OneToMany(mappedBy = "enquete")
// @JsonManagedReference
// private List<EnqueteUniteLogement> enqueteUniteLogements;
@JsonIgnore // @JsonIgnore
@JsonManagedReference // @JsonManagedReference
@OneToMany(mappedBy = "enquete") // @OneToMany(mappedBy = "enquete")
private List<EnqueteBatiment> enqueteBatiments; // private List<EnqueteBatiment> enqueteBatiments;
@JsonIgnore @JsonIgnore
@OneToMany(mappedBy = "enquete") @OneToMany(mappedBy = "enquete")

View File

@@ -1,10 +1,15 @@
package io.gmss.fiscad.entities.infocad.metier; package io.gmss.fiscad.entities.infocad.metier;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Quartier; import io.gmss.fiscad.entities.decoupage.Quartier;
import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine; import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
import io.gmss.fiscad.entities.infocad.parametre.TypeDomaine;
import io.gmss.fiscad.entities.rfu.metier.Batiment; import io.gmss.fiscad.entities.rfu.metier.Batiment;
import io.gmss.fiscad.entities.rfu.parametre.Usage;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.*; import lombok.*;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
@@ -12,6 +17,7 @@ import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDate;
import java.util.List; import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@@ -38,22 +44,24 @@ public class Parcelle extends BaseEntity implements Serializable {
private String altitude; private String altitude;
private String situationGeographique; private String situationGeographique;
@ColumnDefault("0.0") @ColumnDefault("0.0")
private float superficie; private Float superficie;
@ManyToOne @ManyToOne
private NatureDomaine natureDomaine; private NatureDomaine natureDomaine;
@ManyToOne
private TypeDomaine typeDomaine;
@JsonIgnore @JsonIgnore
@ManyToOne @ManyToOne
private Quartier quartier; private Quartier quartier;
private String i; private String i;
private String p; private String p;
private String observation; private String observation;
private String numTitreFoncier; private String numeroTitreFoncier;
private LocalDate dateTitreFoncier ;
@JsonIgnore @JsonIgnore
@ManyToOne @ManyToOne
private Tpe terminal; private Tpe terminal;
private String autreNumeroTitreFoncier; private String autreNumeroTitreFoncier;
private Long typeDomaineId; private String numeroProvisoire;
private Long numeroProvisoire;
private Long blocId; private Long blocId;
@ColumnDefault("false") @ColumnDefault("false")
private boolean synchronise; private boolean synchronise;
@@ -64,6 +72,18 @@ public class Parcelle extends BaseEntity implements Serializable {
@ManyToOne @ManyToOne
private Rue rue ; private Rue rue ;
private String numeroRue ; private String numeroRue ;
private Boolean batie;
private Integer nombrePiscine;
@ManyToOne
private Usage usage;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDebutExemption;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExemption;
// private String ncProprietaire ;
// @JsonIgnore // @JsonIgnore
// @OneToMany(mappedBy = "parcelle") // @OneToMany(mappedBy = "parcelle")
// private List<Batiment> batiments; // private List<Batiment> batiments;

View File

@@ -10,6 +10,7 @@ import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.decoupage.Commune; import io.gmss.fiscad.entities.decoupage.Commune;
import io.gmss.fiscad.entities.decoupage.Departement; import io.gmss.fiscad.entities.decoupage.Departement;
import io.gmss.fiscad.entities.decoupage.Quartier; import io.gmss.fiscad.entities.decoupage.Quartier;
import io.gmss.fiscad.enums.SourceDonnee;
import io.gmss.fiscad.enums.StatutParcelle; import io.gmss.fiscad.enums.StatutParcelle;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -24,6 +25,7 @@ import org.n52.jackson.datatype.jts.GeometryDeserializer;
import org.n52.jackson.datatype.jts.GeometrySerializer; import org.n52.jackson.datatype.jts.GeometrySerializer;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDate;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Entity @Entity
@@ -39,27 +41,63 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
private String NomDepartement;
private String NomCommune;
private String NomArrondissement;
private String NomVillageQuartier;
private String codeBloc;
private String q;
private String ilot;
private String zone;
private String p;
@Column(unique = true,nullable = true) @Column(unique = true,nullable = true)
private String nup; private String nup;
@Column(unique = true,nullable = true) @Column(unique = true,nullable = true)
private String nupProvisoire; private String nupProvisoire;
private String longitude; private String longitude;
private String latitude; private String latitude;
private String codeDepartement;
private String nomDepartement;
private String codeCommune;
private String nomCommune;
private String codeArrondissement;
private String nomArrondissement;
private String codeQuartierVillage;
private String nomVillageQuartier;
private String codeBloc;
private String numeroRue;
private String numeroEntreePorte;
private String codeInstad;
private String numeroEtatLieux;
private String numeroTitreFoncier;
private LocalDate dateTitreFoncier;
private Boolean batie ;
private String npi;
private String ifu;
private String nom;
private String prenom;
private String raisonSociale;
private String nomEtPrenoms;
private String telephone;
private String adresse;
private String nomRepresentant;
private String prenomRepresentant;
private String raisonSocialeRepresentant;
private String nomEtPrenomsRepresentant;
private String telephoneRepresentant;
private String adresseRepresentant;
private String q;
private String zone;
private String ilot;
private String p;
private String qLotissement;
private String ilotLotissement;
private String pLotissement;
private String pointsPolygone; private String pointsPolygone;
private Integer superficie; private Integer superficie;
private String nomEtPrenoms;
private String dateCollecte; private String dateCollecte;
private String sourceDonnees; @Enumerated(EnumType.STRING)
private SourceDonnee sourceDonnees;
private String observations; private String observations;
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private StatutParcelle statutParcelle; private StatutParcelle statutParcelle;
private Long uploadId; private Long uploadId;
@@ -77,35 +115,22 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
private Arrondissement arrondissement; private Arrondissement arrondissement;
@ManyToOne //(fetch = FetchType.LAZY) @ManyToOne //(fetch = FetchType.LAZY)
//@JsonBackReference @JsonBackReference
private Quartier quartier ; private Quartier quartier ;
@ColumnDefault("0") @ColumnDefault("0")
private int geomSrid; private Integer geomSrid;
@JsonSerialize(using = GeometrySerializer.class) @JsonSerialize(using = GeometrySerializer.class)
@JsonDeserialize(contentUsing = GeometryDeserializer.class) @JsonDeserialize(contentUsing = GeometryDeserializer.class)
@Column(name = "geometry",columnDefinition = "geometry(Polygon,32631)") @Column(name = "geometry",columnDefinition = "geometry(Polygon,32631)")
private Polygon geometry; private Polygon geometry;
@Column(columnDefinition = "TEXT") @Column(columnDefinition = "TEXT")
private String geometryString; private String geometryString;
private String codeInsae;
private String numeroEtatLieux;
private String numeroTitreFoncier;
private String telephone;
//private String codeParcelle;
//private String codeEquipe;
//private String elLot; @JsonIgnore
//private String elLettreParcelle; @ManyToOne
//private String rfuQuartierOuZone; @JsonBackReference
//private String rfuIlot; private Parcelle parcelle;
//private String rfuLettreParcelle;
//private String nomLotissement;
////////////
// @JsonIgnore
// @OneToOne
// private Parcelle parcelle;
// @JsonSerialize(using = GeometrySerializer.class) // @JsonSerialize(using = GeometrySerializer.class)
// @JsonDeserialize(contentUsing = GeometryDeserializer.class) // @JsonDeserialize(contentUsing = GeometryDeserializer.class)
// @Column(name = "geom",columnDefinition = "geometry(Polygon,4326)") // @Column(name = "geom",columnDefinition = "geometry(Polygon,4326)")

View File

@@ -11,6 +11,8 @@ import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.infocad.parametre.SourceDroit; import io.gmss.fiscad.entities.infocad.parametre.SourceDroit;
import io.gmss.fiscad.entities.infocad.parametre.TypePiece; import io.gmss.fiscad.entities.infocad.parametre.TypePiece;
import io.gmss.fiscad.entities.rfu.metier.DeclarationNc; import io.gmss.fiscad.entities.rfu.metier.DeclarationNc;
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@@ -22,6 +24,7 @@ import org.hibernate.annotations.Where;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@@ -71,12 +74,22 @@ public class Piece extends BaseEntity implements Serializable {
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
private Enquete enquete ; private Enquete enquete ;
@JsonIgnore
@JsonBackReference
@ManyToOne(fetch = FetchType.LAZY)
private EnqueteBatiment enqueteBatiment ;
@JsonIgnore
@JsonBackReference
@ManyToOne(fetch = FetchType.LAZY)
private EnqueteUniteLogement enqueteUniteLogement ;
@ManyToOne @ManyToOne
private ModeAcquisition modeAcquisition; private ModeAcquisition modeAcquisition;
@OneToMany(mappedBy = "piece") @OneToMany(mappedBy = "piece")
private List<Upload> uploads; private List<Upload> uploads=new ArrayList<>();
@JsonIgnore @JsonIgnore
@ManyToOne @ManyToOne
@@ -91,4 +104,9 @@ public class Piece extends BaseEntity implements Serializable {
private boolean synchronise; private boolean synchronise;
private String observation; private String observation;
private Long nombreFichier;
public Long getNombreFichier() {
return uploads==null? 0l:uploads.size() ;
}
} }

View File

@@ -97,17 +97,17 @@ public class Upload extends BaseEntity implements Serializable {
System.out.println("url = " + url); System.out.println("url = " + url);
// return url != null ? url.toLowerCase().startsWith("https") ? url : url.toLowerCase().replaceFirst("http", "https") : null; // return url != null ? url.toLowerCase().startsWith("https") ? url : url.toLowerCase().replaceFirst("http", "https") : null;
return url != null ? url.toLowerCase().startsWith("https") ? url : url.toLowerCase().replaceFirst("http", "https") : null; return url != null ? url.toLowerCase().startsWith("https") ? url : url.toLowerCase().replaceFirst("http", "https") : null;
} }
private String serverContext() { private String serverContext() {
String url= ServletUriComponentsBuilder.fromCurrentContextPath() String url= ServletUriComponentsBuilder.fromCurrentContextPath()
.path("/api/upload/downloadFile/") .path("/api/upload/downloadFile/")
.toUriString(); .toUriString();
if(!url.contains("8282/api")){ //System.out.println(url);
url.replace("/api",":8282/api"); // if(!url.contains("8282/api")){
} // url.replace("/api",":8282/api");
// }
//System.out.println(url);
return url; return url;
} }

View File

@@ -10,6 +10,7 @@ import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.infocad.metier.Upload; import io.gmss.fiscad.entities.infocad.metier.Upload;
import io.gmss.fiscad.entities.metadata.MobileDataPersonne; import io.gmss.fiscad.entities.metadata.MobileDataPersonne;
import io.gmss.fiscad.enums.Categorie; import io.gmss.fiscad.enums.Categorie;
import io.gmss.fiscad.enums.EtatIdentificationPersonne;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@@ -79,7 +80,12 @@ public class Personne extends BaseEntity implements Serializable {
private int mustHaveRepresentant; private int mustHaveRepresentant;
private String filePath; private String filePath;
@Enumerated(EnumType.STRING)
private EtatIdentificationPersonne etatIdentificationPersonne;
private String observation; private String observation;
private String numeroRccm ;
private LocalDate dateRccm ;
private String email ;
@ColumnDefault("false") @ColumnDefault("false")
private boolean synchronise; private boolean synchronise;

View File

@@ -7,11 +7,14 @@ import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.infocad.metier.Parcelle; import io.gmss.fiscad.entities.infocad.metier.Parcelle;
import io.gmss.fiscad.entities.infocad.metier.Tpe; import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment;
import io.gmss.fiscad.entities.rfu.parametre.Usage;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.hibernate.Internal;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import java.io.Serializable; import java.io.Serializable;
@@ -34,16 +37,42 @@ public class Batiment extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateConstruction; private LocalDate dateConstruction;
private Long idDerniereEnquete; private Long idDerniereEnquete;
private Float superficieLouee;
private Float superficieAuSol;
private Integer nombreEtage;
private Integer nombrePiscine;
private Long montantLocatifAnnuelDeclare;
private Long montantLocatifAnnuelCalcule;
private Long montantLocatifAnnuelEstime;
private Long valeurBatimentEstime;
private Long valeurBatimentReel;
private Long valeurBatimentCalcule;
private Long montantMensuelLocation;
private Integer nbreUniteLogement;
private Integer idToitRfu;
@JsonIgnore @JsonIgnore
@ManyToOne @ManyToOne
private Parcelle parcelle; private Parcelle parcelle;
private Long parcelleExternalKey; @ManyToOne
private Usage usage;
@ManyToOne
private CategorieBatiment categorieBatiment ;
@JsonIgnore @JsonIgnore
@ManyToOne @ManyToOne
private Tpe terminal; private Tpe terminal;
private Long enqueteId; // private Long enqueteId;
private Long mobileDataId; private Long mobileDataId;
private Long parcelleExternalKey;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDebutExemption;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExemption;
} }

View File

@@ -37,6 +37,7 @@ public class CaracteristiqueParcelle extends BaseEntity implements Serializable
@ManyToOne @ManyToOne
private Caracteristique caracteristique; private Caracteristique caracteristique;
private String valeur; private String valeur;
private String observation;
@JsonIgnore @JsonIgnore
@ManyToOne @ManyToOne
private Tpe terminal; private Tpe terminal;

View File

@@ -47,3 +47,5 @@ public class CaracteristiqueUniteLogement extends BaseEntity implements Serializ
private Long enqueteId; private Long enqueteId;
private Long mobileDataId; private Long mobileDataId;
} }

View File

@@ -32,18 +32,23 @@ public class DeclarationNc extends BaseEntity implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@JsonFormat(pattern = "dd-MM-yyyy") @JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDerniereDeclaration; private LocalDate dateDerniereDeclaration;
private String nc;
@OneToOne @JsonFormat(pattern = "yyyy-MM-dd")
private Structure structure; @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDeclarationNc;
private String nc;
private String observation;
@JsonIgnore @JsonIgnore
@ManyToOne @ManyToOne
private Enquete enquete; private Structure structure;
private Long enqueteExternalKey; private Long enqueteExternalKey;
@JsonIgnore @JsonIgnore

View File

@@ -8,6 +8,10 @@ import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.infocad.metier.Enquete; import io.gmss.fiscad.entities.infocad.metier.Enquete;
import io.gmss.fiscad.entities.infocad.metier.Parcelle; import io.gmss.fiscad.entities.infocad.metier.Parcelle;
import io.gmss.fiscad.entities.infocad.metier.Tpe; import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.infocad.parametre.Structure;
import io.gmss.fiscad.entities.rfu.parametre.ZoneRfu;
import io.gmss.fiscad.enums.NatureImpot;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@@ -70,16 +74,22 @@ public class DonneesImpositionTfu extends BaseEntity implements Serializable {
private String latitude; private String latitude;
private int superficieParc; private int superficieParc;
private Long superficieAuSolBat; private Long superficieAuSolBat;
private Long superficieAuSolLoue;
private Long superficieAuSolUlog; private Long superficieAuSolUlog;
private String batieOuiNon; private Boolean batie;
private String exhonereOuiNon; private Boolean exonere;
private String batimentExhonereOuiNon; private Boolean batimentExonere;
private String uniteLogementExhonereOuiNon; private Boolean uniteLogementExonere;
private Long valeurLocativeAdm; private Long valeurLocativeAdm;
private Long valeurLocativeAdmTauxPropParc;
private Long valeurLocativeAdmSupReel;
private Long superficieAuSolTauxPropParc;
private Long valeurLocativeAdmMetreCarre;
private Long montantLoyerAnnuel; private Long montantLoyerAnnuel;
private Long tfuMetreCarre; private Long tfuMetreCarre;
private Long tfuMinimum; private Long tfuMinimum;
private String standingBat; private String standingBat;
private String categorieUsage;
private String categorieBat; private String categorieBat;
private Long nombrePiscine; private Long nombrePiscine;
private Long nombreUlog; private Long nombreUlog;
@@ -88,14 +98,53 @@ public class DonneesImpositionTfu extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateEnquete; private LocalDate dateEnquete;
private Long enqueteId; private Long enqueteId;
private Long structureId;
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "structure_id")
private Structure structure ;
private Long secteurId; private Long secteurId;
private Long zoneRfuId; @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "zone_rfu_id")
private ZoneRfu zoneRfu ;
@ColumnDefault("0") @ColumnDefault("0")
private float tauxParcelleNonBati; private Long valeurAdminParcelleNb;
private Long valeurAdministrativeParcelleNonBati; private Float tauxTfu;
private Long tfuPiscine;
private Float montantTaxe;
private Float tfuCalculeTauxPropParc;
private Float tfuSuperficieAuSolReel;
private Long valeurAdminParcelleNbMetreCarre;
@JsonIgnore @JsonIgnore
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "impositions_tfu_id", nullable = false) @JoinColumn(name = "impositions_tfu_id", nullable = false)
private ImpositionsTfu impositionsTfu; private ImpositionsTfu impositionsTfu ;
@Enumerated(EnumType.STRING)
private NatureImpot natureImpot;
private Long valeurBatiment;
private Long valeurParcelle;
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parcelle_id")
private Parcelle parcelleImposee ;
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "batiment_id")
private Batiment batimentImpose ;
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "unite_logement_id")
private UniteLogement uniteLogementImposee ;
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
private Personne personne ;
} }

View File

@@ -62,10 +62,10 @@ public class EnqueteActivite extends BaseEntity implements Serializable {
@ManyToOne @ManyToOne
private Batiment batiment; private Batiment batiment;
private Long batimentExternalKey;
@OneToOne @OneToOne
private Parcelle parcelle; private Parcelle parcelle;
private Long parcelleExternalKey; private Long parcelleExternalKey;
@@ -74,11 +74,12 @@ public class EnqueteActivite extends BaseEntity implements Serializable {
@OneToOne @OneToOne
private UniteLogement uniteLogement ; private UniteLogement uniteLogement ;
private Long uniteLogementExternalKey;
@JsonIgnore
@ManyToOne
private Enquete enquete; // @JsonIgnore
// @ManyToOne
// private Enquete enquete;
@JsonIgnore @JsonIgnore
@ManyToOne @ManyToOne
@@ -90,6 +91,12 @@ public class EnqueteActivite extends BaseEntity implements Serializable {
private Long mobileDataId; private Long mobileDataId;
private Long batimentExternalKey;
private Long uniteLogementExternalKey;
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@JsonIgnore @JsonIgnore
private StatutEnregistrement statutEnregistrement; private StatutEnregistrement statutEnregistrement;

View File

@@ -12,7 +12,11 @@ import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.infocad.metier.Upload; import io.gmss.fiscad.entities.infocad.metier.Upload;
import io.gmss.fiscad.entities.infocad.parametre.Personne; import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.rfu.parametre.Caracteristique; import io.gmss.fiscad.entities.rfu.parametre.Caracteristique;
import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment;
import io.gmss.fiscad.entities.rfu.parametre.Exercice;
import io.gmss.fiscad.entities.rfu.parametre.Usage;
import io.gmss.fiscad.entities.user.User; import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.StatutEnquete;
import io.gmss.fiscad.enums.StatutEnregistrement; import io.gmss.fiscad.enums.StatutEnregistrement;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -42,24 +46,32 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
private float surfaceAuSol; // private Float surfaceAuSol;
private String autreMenuisierie; private String autreMenuisierie;
private String autreMur; private String autreMur;
private boolean sbee; private Boolean sbee;
private String numCompteurSbee; private String numCompteurSbee;
private boolean soneb; private Boolean soneb;
private String numCompteurSoneb; private String numCompteurSoneb;
private int nbreLotUnite; private Integer nbreLotUnite;
private int nbreUniteLocation; private Integer nbreUniteLogement;
private float surfaceLouee; private Integer nbrePiece;
private int nbreMenage; private Integer nbreUniteLocation;
private int nbreHabitant; private Float superficieLouee;
private Float superficieAuSol;
private Integer nbreMenage;
private Integer nbreHabitant;
private Long montantMensuelLocation; private Long montantMensuelLocation;
private Long montantLocatifAnnuelDeclare; private Long montantLocatifAnnuelDeclare;
private Long montantLocatifAnnuelEstime;
private Long montantLocatifAnnuelCalcule;
private Long valeurBatimentEstime; private Long valeurBatimentEstime;
private Long valeurBatimentReel; private Long valeurBatimentReel;
private int nbreMoisLocation; private Long valeurBatimentCalcule;
private Integer nombrePiscine;
private Integer nbreMoisLocation;
private String autreCaracteristiquePhysique; private String autreCaracteristiquePhysique;
private String observation;
@JsonFormat(pattern = "dd-MM-yyyy") @JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDebutExcemption; private LocalDate dateDebutExcemption;
@@ -67,6 +79,21 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExcemption; private LocalDate dateFinExcemption;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateEnquete;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateValidation;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateRejet;
private String descriptionMotifRejet;
@ManyToOne
private Exercice exercice;
//@JsonIgnore //@JsonIgnore
@ManyToOne @ManyToOne
private Personne personne; private Personne personne;
@@ -85,10 +112,15 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
private Long batimentExternalKey; private Long batimentExternalKey;
private Long nbreEtage; private Long nbreEtage;
private String representantNom;
private String representantPrenom;
private String representantTel;
private String representantNpi;
// @JsonIgnore // @JsonIgnore
@ManyToOne(fetch = FetchType.LAZY) // @ManyToOne(fetch = FetchType.LAZY)
@JsonBackReference // @JsonBackReference
private Enquete enquete; // private Enquete enquete;
@@ -107,7 +139,12 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
@OneToMany(mappedBy = "enqueteBatiment") @OneToMany(mappedBy = "enqueteBatiment")
private List<Upload> uploads; private List<Upload> uploads;
//@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
//@JsonIgnore @JsonIgnore
//private StatutEnregistrement statutEnregistrement; private StatutEnquete statutEnquete;
@ManyToOne
private CategorieBatiment categorieBatiment ;
@ManyToOne
private Usage usage ;
} }

View File

@@ -11,7 +11,11 @@ import io.gmss.fiscad.entities.infocad.metier.Enquete;
import io.gmss.fiscad.entities.infocad.metier.Tpe; import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.infocad.metier.Upload; import io.gmss.fiscad.entities.infocad.metier.Upload;
import io.gmss.fiscad.entities.infocad.parametre.Personne; import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment;
import io.gmss.fiscad.entities.rfu.parametre.Exercice;
import io.gmss.fiscad.entities.rfu.parametre.Usage;
import io.gmss.fiscad.entities.user.User; import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.StatutEnquete;
import io.gmss.fiscad.enums.StatutEnregistrement; import io.gmss.fiscad.enums.StatutEnregistrement;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -41,42 +45,74 @@ public class EnqueteUniteLogement extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
private int nbrePiece; private Integer nbrePiece;
private int nbreHabitant; private Integer nbreHabitant;
private int nbreMenage; private Integer nbreMenage;
private boolean enLocation; private Boolean enLocation;
private float montantMensuelLoyer; private Long montantMensuelLocation;
private int nbreMoisLocation; private Integer nbreMoisLocation;
private float montantLocatifAnnuelDeclare; private Long montantLocatifAnnuelDeclare;
private Long montantLocatifAnnuelCalcule;
private Long montantLocatifAnnuelEstime;
private Long valeurUniteLogementEstime; private Long valeurUniteLogementEstime;
private Long valeurUniteLogementReel; private Long valeurUniteLogementReel;
private float surfaceLouee; private Long valeurUniteLogementCalcule;
private float SurfaceAuSol; private Integer nombrePiscine;
private boolean sbee; private Float superficieLouee;
private boolean soneb; private Float superficieAuSol;
private Boolean sbee;
private Boolean soneb;
private String numCompteurSbee; private String numCompteurSbee;
private String numCompteurSoneb; private String numCompteurSoneb;
@JsonFormat(pattern = "dd-MM-yyyy") @JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDebutExcemption; private LocalDate dateDebutExemption;
@JsonFormat(pattern = "dd-MM-yyyy") @JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExcemption; private LocalDate dateFinExemption;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateEnquete;
@JsonIgnore @JsonFormat(pattern = "dd-MM-yyyy")
@ManyToOne(fetch = FetchType.LAZY) @JsonDeserialize(using = LocalDateDeserializer.class)
@JsonBackReference private LocalDate dateValidation;
private Enquete enquete;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateRejet;
private String descriptionMotifRejet;
private String observation;
private Long uniteLogementExternalKey;
private String representantNom;
private String representantPrenom;
private String representantTel;
private String representantNpi;
@ManyToOne
private Exercice exercice;
// @JsonIgnore
// @ManyToOne(fetch = FetchType.LAZY)
// @JsonBackReference
// private Enquete enquete;
@ManyToOne @ManyToOne
private UniteLogement uniteLogement; private UniteLogement uniteLogement;
private Long uniteLogementExternalKey;
@OneToOne @OneToOne
private Personne personne; private Personne personne;
@JsonIgnore
@ManyToOne
private Tpe terminal;
@JsonIgnore
@ManyToOne
private User user;
private Long personneExternalKey; private Long personneExternalKey;
private Long mobileDataId; private Long mobileDataId;
@@ -85,16 +121,16 @@ public class EnqueteUniteLogement extends BaseEntity implements Serializable {
@JsonManagedReference @JsonManagedReference
private List<CaracteristiqueUniteLogement> caracteristiqueUniteLogements; private List<CaracteristiqueUniteLogement> caracteristiqueUniteLogements;
@JsonIgnore
@ManyToOne
private Tpe terminal;
@JsonIgnore
@ManyToOne
private User user;
//@JsonIgnore //@JsonIgnore
@OneToMany(mappedBy = "enqueteUniteLogement") @OneToMany(mappedBy = "enqueteUniteLogement")
private List<Upload> uploads; private List<Upload> uploads;
@JsonIgnore @JsonIgnore
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private StatutEnregistrement statutEnregistrement; private StatutEnquete statutEnquete;
@ManyToOne
private CategorieBatiment categorieBatiment ;
@ManyToOne
private Usage usage ;
} }

View File

@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer; import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Commune; import io.gmss.fiscad.entities.decoupage.Commune;
import io.gmss.fiscad.entities.infocad.parametre.Structure;
import io.gmss.fiscad.entities.rfu.parametre.Exercice; import io.gmss.fiscad.entities.rfu.parametre.Exercice;
import io.gmss.fiscad.entities.rfu.parametre.Participer; import io.gmss.fiscad.entities.rfu.parametre.Participer;
import io.gmss.fiscad.enums.StatusAvis; import io.gmss.fiscad.enums.StatusAvis;
@@ -33,24 +34,39 @@ public class ImpositionsTfu extends BaseEntity implements Serializable {
private Long id; private Long id;
@ManyToOne @ManyToOne
private Exercice exercice; private Exercice exercice;
@ManyToOne @ManyToOne
private Commune commune; private Commune commune;
@ManyToOne
private Structure structure ;
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateGeneration; private LocalDate dateGeneration;
private String ReferencePieceAdmin;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateCloture;
private String referencePieceAdmin;
private String datePieceAdmin; private String datePieceAdmin;
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private StatusAvis statusAvis; private StatusAvis statusAvis;
private Long nombreAvis;
private Integer nombreAvis;
private Integer nombreAvisFnb;
private Integer nombreAvisBatiment;
private Integer nombreAvisUniteLog;
@Column(columnDefinition = "TEXT") @Column(columnDefinition = "TEXT")
private String motif; private String motif;
@JsonIgnore @JsonIgnore
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "impositions_tfu_id") @JoinColumn(name = "impositions_tfu_id")
private List<DonneesImpositionTfu> donneesImpositionTfus; private List<DonneesImpositionTfu> donneesImpositionTfus;
public Long getNombreAvis(){
return donneesImpositionTfus==null?0l:donneesImpositionTfus.size();
}
} }

View File

@@ -0,0 +1,45 @@
package io.gmss.fiscad.entities.rfu.metier;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.rfu.parametre.Exercice;
import io.gmss.fiscad.enums.StatutParcelle;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;
import java.io.Serializable;
import java.time.LocalDate;
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Where(clause = " deleted = false")
public class SituationFiscaleParcelle extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
private Parcelle parcelle ;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDernierPaiement;
@ManyToOne
private Exercice exercice ;
private Long montantDu ;
private Long montantPaye ;
private Long resteAPayer ;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateSync;
}

View File

@@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer; import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.infocad.metier.Tpe; import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment;
import io.gmss.fiscad.entities.rfu.parametre.Usage;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@@ -39,11 +41,34 @@ public class UniteLogement extends BaseEntity implements Serializable {
private List<EnqueteUniteLogement> enqueteUniteLogements; private List<EnqueteUniteLogement> enqueteUniteLogements;
@ManyToOne @ManyToOne
private Batiment batiment; private Batiment batiment;
@ManyToOne
private Usage usage;
private Long batimentExternalKey; private Long batimentExternalKey;
private Long idDerniereEnquete; private Long idDerniereEnquete;
private Float SuperficieLouee;
private Float SuperficieAuSol;
private Long montantMensuelLocation;
private Long montantLocatifAnnuelDeclare;
private Long montantLocatifAnnuelCalcule;
private Long valeurUniteLogementEstime;
private Long montantLocatifAnnuelEstime;
private Long valeurUniteLogementReel;
private Long valeurUniteLogementCalcule;
private Integer nombrePiscine;
@JsonIgnore @JsonIgnore
@ManyToOne @ManyToOne
private Tpe terminal; private Tpe terminal;
private Long enqueteId; private Long enqueteId;
private Long mobileDataId; private Long mobileDataId;
@ManyToOne
private CategorieBatiment categorieBatiment ;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDebutExemption;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExemption;
private Integer idToitRfu;
private Integer nombreEtage;
} }

View File

@@ -2,6 +2,7 @@ package io.gmss.fiscad.entities.rfu.parametre;
import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Arrondissement; import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.decoupage.Quartier;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@@ -28,4 +29,6 @@ public class BaremRfuBati extends BaseEntity implements Serializable {
private CategorieBatiment categorieBatiment; private CategorieBatiment categorieBatiment;
@ManyToOne @ManyToOne
private Arrondissement arrondissement; private Arrondissement arrondissement;
@ManyToOne
private Quartier quartier ;
} }

View File

@@ -23,7 +23,9 @@ public class BaremRfuNonBati extends BaseEntity implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
private Long valeurAdministrative; private Long valeurAdministrative;
private float taux; private Long valeurAdministrativeMetreCarre;
private Boolean auMetreCarre;
private Float taux;
@ManyToOne @ManyToOne
private Commune commune; private Commune commune;
@ManyToOne @ManyToOne

View File

@@ -23,4 +23,5 @@ public class CategorieBatiment extends BaseEntity implements Serializable {
@Column(unique = true) @Column(unique = true)
private String code; private String code;
private String nom; private String nom;
private String standing;
} }

View File

@@ -25,7 +25,7 @@ public class Exercice extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
private int annee; private Integer annee;
private boolean estGenerer; private boolean estGenerer;
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)

View File

@@ -0,0 +1,29 @@
package io.gmss.fiscad.entities.rfu.parametre;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.enums.CategorieUsage;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;
import java.io.Serializable;
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Where(clause = " deleted = false")
public class Usage extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String code;
private String nom;
@Enumerated(EnumType.STRING)
private CategorieUsage categorieUsage;
}

View File

@@ -32,10 +32,17 @@ import java.time.LocalDate;
// "SET deleted = true " + // "SET deleted = true " +
// "WHERE id = ?") // "WHERE id = ?")
//@Where(clause = " deleted = false") //@Where(clause = " deleted = false")
@Table(
name = "fonction",
uniqueConstraints = {
@UniqueConstraint(columnNames = {"code"})
}
)
public class Fonction extends BaseEntity implements Serializable { public class Fonction extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@Column(nullable = false, unique = true)
private String code ; private String code ;
private String nom ; private String nom ;

View File

@@ -0,0 +1,8 @@
package io.gmss.fiscad.enums;
public enum CategorieUsage {
HABITATION,
PROFESSIONNELLE,
MIXTE
}

View File

@@ -0,0 +1,9 @@
package io.gmss.fiscad.enums;
public enum EtatIdentificationPersonne {
IFU,
NPI,
IFU_NPI,
NEANT,
RFU;
}

View File

@@ -0,0 +1,7 @@
package io.gmss.fiscad.enums;
public enum NatureImpot {
TFU,
IRF,
SRTB
}

View File

@@ -0,0 +1,22 @@
package io.gmss.fiscad.enums;
public enum ParametersType {
EMAILS_TO,
EMAIL_FROM,
SMTP_PORT,
SMTP_HOST,
SMTP_USERNAME,
SMTP_PASSWORD,
MESSAGE_STATUT,
OBJET_RESET_PASSWORD,
CORPS_RESET_PASSWORD,
OBJET_CREATE_ACCOUNT,
CORPS_CREATE_ACCOUNT,
TOKEN_IFU_EN_LIGNE,
TAUX_TFU,
TAUX_VALEUR_LOCATIVE_PROFESSIONNELLE,
TAUX_DEFAUT_SUPERFICIE_AU_SOL,
TAUX_IRF,
TAXE_SRTB,
TFU_PAR_PISCINE;
}

View File

@@ -0,0 +1,7 @@
package io.gmss.fiscad.enums;
public enum SourceDonnee {
RFU,
ANDF,
SIGIBE
}

View File

@@ -1,8 +1,13 @@
package io.gmss.fiscad.enums; package io.gmss.fiscad.enums;
public enum StatusAvis { public enum StatusAvis {
CREE, EN_COURS,
GENERE,
ANNULE, CLOTURE,
VALIDE, GENERATION_AUTORISE,
REJETE,
TFU_FNB_GENERE,
GENERE
} }

View File

@@ -5,5 +5,6 @@ public enum StatutEnquete {
FINALISE, FINALISE,
REJETE, REJETE,
VALIDE, VALIDE,
ECHEC ECHEC,
CLOTURE
} }

View File

@@ -1,9 +1,7 @@
package io.gmss.fiscad.enums; package io.gmss.fiscad.enums;
public enum StatutParcelle { public enum StatutParcelle {
NON_ENQUETE,
NON_ENQUETER, AJOUR,
ENQUETER_NON_BATIE, NON_AJOUR;
ENQUETER_BATIE
} }

View File

@@ -2,15 +2,18 @@ package io.gmss.fiscad.implementations.decoupage;
import io.gmss.fiscad.entities.decoupage.Secteur; import io.gmss.fiscad.entities.decoupage.Secteur;
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage; import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
import io.gmss.fiscad.enums.StatutEnquete;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService; import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
import io.gmss.fiscad.interfaces.decoupage.SecteurService; import io.gmss.fiscad.interfaces.decoupage.SecteurService;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb; import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb; import io.gmss.fiscad.paylaods.response.statistique.ParcelleStatsProjectionUnSecteur;
import io.gmss.fiscad.paylaods.response.restoration.ParcelleStatsProjectionUnSecteur;
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurDecoupageRepository; import io.gmss.fiscad.persistence.repositories.decoupage.SecteurDecoupageRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
import io.gmss.fiscad.persistence.repositories.rfu.metier.EnqueteBatimentRepository;
import io.gmss.fiscad.persistence.repositories.rfu.metier.EnqueteUniteLogementRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService; import io.gmss.fiscad.service.EntityFromPayLoadService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
@@ -26,6 +29,9 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
private final SecteurDecoupageRepository secteurDecoupageRepository; private final SecteurDecoupageRepository secteurDecoupageRepository;
private final SecteurService secteurService; private final SecteurService secteurService;
private final ParcelleRepository parcelleRepository; private final ParcelleRepository parcelleRepository;
private final EnqueteRepository enqueteRepository;
private final EnqueteBatimentRepository enqueteBatimentRepository;
private final EnqueteUniteLogementRepository enqueteUniteLogementRepository;
private final EntityFromPayLoadService entityFromPayLoadService; private final EntityFromPayLoadService entityFromPayLoadService;
@@ -112,4 +118,36 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
return parcelleStatsProjectionUnSecteurs ; return parcelleStatsProjectionUnSecteurs ;
} }
@Override
public List<ParcelleStatsProjectionUnSecteur> getStatEnqueteDecoupageByUserId(Long userId, String statutEnquete) {
List<Secteur> secteurs= secteurService.getListSecteurUserId(userId);
List<Long> secteurIds = secteurs.stream()
.map(Secteur::getId)
.toList();
System.out.println(statutEnquete);
return enqueteRepository.findStatsEnqueteBySecteurs(secteurIds,statutEnquete);
}
@Override
public List<ParcelleStatsProjectionUnSecteur> getStatEnqueteBatimentDecoupageByUserId(Long userId, String statutEnquete) {
List<Secteur> secteurs= secteurService.getListSecteurUserId(userId);
List<Long> secteurIds = secteurs.stream()
.map(Secteur::getId)
.toList();
System.out.println(statutEnquete);
System.out.println(secteurIds);
return enqueteBatimentRepository.findStatsEnqueteBatimentBySecteurs(secteurIds,statutEnquete);
}
@Override
public List<ParcelleStatsProjectionUnSecteur> getStatEnqueteUniteLogementDecoupageByUserId(Long userId, String statutEnquete) {
List<Secteur> secteurs= secteurService.getListSecteurUserId(userId);
List<Long> secteurIds = secteurs.stream()
.map(Secteur::getId)
.toList();
return enqueteUniteLogementRepository.findStatsEnqueteBatimentBySecteurs(secteurIds,statutEnquete);
}
} }

View File

@@ -163,8 +163,15 @@ public class SecteurServiceImpl implements SecteurService {
secteurs.addAll(secteurRepository.findDistinctBySection_Id(avoirFonction.getFonction().getSection().getId())); secteurs.addAll(secteurRepository.findDistinctBySection_Id(avoirFonction.getFonction().getSection().getId()));
}else if(avoirFonction.getFonction().getStructure()!=null){ }else if(avoirFonction.getFonction().getStructure()!=null){
secteurs.addAll(secteurRepository.findDistinctBySection_Structure_Id(avoirFonction.getFonction().getStructure().getId())); secteurs.addAll(secteurRepository.findDistinctBySection_Structure_Id(avoirFonction.getFonction().getStructure().getId()));
}else if(avoirFonction.getFonction().getDepartement()!=null){
secteurs.addAll(secteurRepository.findSectionsByDepartement(avoirFonction.getFonction().getDepartement().getId()));
} }
}); });
return secteurs; return secteurs;
} }
@Override
public List<Secteur> getListSecteurByDepartementId(Long departementId) {
return secteurRepository.findSectionsByDepartement(departementId);
}
} }

View File

@@ -1,5 +1,6 @@
package io.gmss.fiscad.implementations.infocad.metier; package io.gmss.fiscad.implementations.infocad.metier;
import io.gmss.fiscad.entities.decoupage.Secteur;
import io.gmss.fiscad.entities.infocad.metier.*; import io.gmss.fiscad.entities.infocad.metier.*;
import io.gmss.fiscad.entities.infocad.parametre.Personne; import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle; import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
@@ -13,7 +14,9 @@ import io.gmss.fiscad.enums.StatutEnquete;
import io.gmss.fiscad.exceptions.ApplicationException; import io.gmss.fiscad.exceptions.ApplicationException;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService; import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
import io.gmss.fiscad.interfaces.infocad.metier.ParcelleService;
import io.gmss.fiscad.interfaces.infocad.metier.PieceService; import io.gmss.fiscad.interfaces.infocad.metier.PieceService;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService;
import io.gmss.fiscad.interfaces.rfu.metier.DeclarationNcService; import io.gmss.fiscad.interfaces.rfu.metier.DeclarationNcService;
@@ -23,6 +26,7 @@ import io.gmss.fiscad.interfaces.user.UserService;
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad; import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad; import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb; import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb;
import io.gmss.fiscad.paylaods.response.* ; import io.gmss.fiscad.paylaods.response.* ;
import io.gmss.fiscad.paylaods.response.FicheResponse.* ; import io.gmss.fiscad.paylaods.response.FicheResponse.* ;
import io.gmss.fiscad.paylaods.response.synchronisation.EnqueteNonSyncResponse; import io.gmss.fiscad.paylaods.response.synchronisation.EnqueteNonSyncResponse;
@@ -43,6 +47,8 @@ import io.gmss.fiscad.service.EntityFromPayLoadService;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext; import jakarta.persistence.PersistenceContext;
import jakarta.persistence.Query; import jakarta.persistence.Query;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.NotAcceptableException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.modelmapper.ModelMapper; import org.modelmapper.ModelMapper;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
@@ -77,13 +83,9 @@ public class EnqueteServiceImpl implements EnqueteService {
private final ParcelleServiceImpl parcelleService; private final ParcelleServiceImpl parcelleService;
private final PersonneRepository personneRepository; private final PersonneRepository personneRepository;
private final ZoneRfuRepository zoneRfuRepository ; private final ZoneRfuRepository zoneRfuRepository ;
private final EquipeRepository equipeRepository ;
private final RueRepository rueRepository ;
private final CaracteristiqueParcelleService caracteristiqueParcelleService ;
private final PieceService pieceService ;
private final UploadRepository uploadRepository ;
private final DeclarationNcService declarationNcService ;
private final EntityFromPayLoadService entityFromPayLoadService ; private final EntityFromPayLoadService entityFromPayLoadService ;
private final SecteurService secteurService ;
;
@PersistenceContext @PersistenceContext
private final EntityManager em; private final EntityManager em;
@@ -91,113 +93,77 @@ public class EnqueteServiceImpl implements EnqueteService {
@Override @Override
public Enquete createEnquete(EnquetePayLoadWeb enquetePayLoadWeb) throws BadRequestException { @Transactional
Parcelle parcelle=new Parcelle(); public EnquetePayLoadWeb createEnquete(EnquetePayLoadWeb enquetePayLoadWeb) throws BadRequestException {
Long rueId;
Optional<User> optionalUser = userRepository.findById(enquetePayLoadWeb.getEnqueteurId()); Optional<User> optionalUser = userRepository.findById(enquetePayLoadWeb.getEnqueteurId());
if (!optionalUser.isPresent()) { if (!optionalUser.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : Enquêteur inexistant"); throw new BadRequestException("Echec de l'enregistrement : Enquêteur inexistant");
} }
Optional<Personne> optionalProprietaire = personneRepository.findById(enquetePayLoadWeb.getProprietaireId());
if (!optionalProprietaire.isPresent()) { Optional<Personne> optionalPersonne = personneRepository.findById(enquetePayLoadWeb.getPersonneId());
if (!optionalPersonne.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : Propriétaire inexistant"); throw new BadRequestException("Echec de l'enregistrement : Propriétaire inexistant");
} }
if(enquetePayLoadWeb.getParcelleId()!=null) {
Optional<Parcelle> optionalParcelle = parcelleRepository.findById(enquetePayLoadWeb.getParcelleId());
if (!optionalParcelle.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : Parcelle inexistante");
}
}
Optional<ZoneRfu> optionalZoneRfu = zoneRfuRepository.findById(enquetePayLoadWeb.getZoneRfuId()); Optional<ZoneRfu> optionalZoneRfu = zoneRfuRepository.findById(enquetePayLoadWeb.getZoneRfuId());
if (!optionalZoneRfu.isPresent()) { if (!optionalZoneRfu.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : zone inexistante"); throw new BadRequestException("Echec de l'enregistrement : zone inexistante");
} }
if(enquetePayLoadWeb.getZoneRfuId()!=null) { ParcellePayLoadWeb parcellePayLoadWeb= getParcellePayloadFromEnquetePl(enquetePayLoadWeb);
Optional<Rue> optionalRue = rueRepository.findById(enquetePayLoadWeb.getZoneRfuId());
if (optionalRue.isPresent()) { if(parcellePayLoadWeb.getId()==null){
rueId = optionalRue.get().getId(); parcellePayLoadWeb=parcelleService.createParcelle(parcellePayLoadWeb);
enquetePayLoadWeb.getParcellePayLoadWeb().setRueId(rueId); }else{
} parcellePayLoadWeb=parcelleService.updateParcelle(parcellePayLoadWeb.getId(),parcellePayLoadWeb);
} }
Optional<Equipe> optionalEquipe = equipeRepository.findById(enquetePayLoadWeb.getEquipeId()); enquetePayLoadWeb.setParcelleId(parcellePayLoadWeb.getId());
///enregistrement de la pacelle Enquete enquete = entityFromPayLoadService.getEnqueteFromPayLoadWeb(enquetePayLoadWeb);
try {
if (enquetePayLoadWeb.getParcellePayLoadWeb().getId() == null) {
parcelle = parcelleService.createParcelle(enquetePayLoadWeb.getParcellePayLoadWeb());
} else {
parcelle = parcelleService.updateParcelle(enquetePayLoadWeb.getParcellePayLoadWeb().getId(),enquetePayLoadWeb.getParcellePayLoadWeb());
}
}catch (Exception e){
e.printStackTrace();
throw new ApplicationException("Echec de l'enregistrement : La parcelle non enregistrée.");
}
////enregistrement de l'enquete ////enregistrement de l'enquete
Enquete enquete = new Enquete(); enquete=enqueteRepository.save(enquete);
enquete.setDateEnquete(LocalDate.now());
//enquete.setBloc(optionalBloc.get());
enquete.setUser(optionalUser.get());
enquete.setParcelle(parcelle);
enquete.setLitige(enquetePayLoadWeb.isLitige());
enquete.setStatutEnquete(StatutEnquete.EN_COURS);
enquete.setObservationParticuliere(enquetePayLoadWeb.getObservation());
enquete.setPersonne(optionalProprietaire.orElse(null));
enquete.setZoneRfu(optionalZoneRfu.orElse(null));
enquete.setAutreAdresse(enquetePayLoadWeb.getAutreAdresse());
enquete.setAutreNumeroTitreFoncier(enquetePayLoadWeb.getAutreNumeroTitreFoncier());
enquete.setNumeroTitreFoncier(enquetePayLoadWeb.getNumeroTitreFoncier());
enquete.setEquipe(optionalEquipe.orElse(null));
enquete.setDateDebutExcemption(enquetePayLoadWeb.getDateDebutExemption());
enquete.setDateFinExcemption(enquetePayLoadWeb.getDateFinExemption());
enquete.setNbreBatiment(enquetePayLoadWeb.getNbreBatiment());
enquete.setNbrePiscine(enquetePayLoadWeb.getNbrePiscine());
enquete.setNbreIndivisiaire(enquetePayLoadWeb.getNbreIndivisiaire());
enquete.setNbreCoProprietaire(enquetePayLoadWeb.getNbreCoProprietaire());
enquete.setNumEntreeParcelle(enquetePayLoadWeb.getNumEntreeParcelle());
enquete.setNomRue(enquetePayLoadWeb.getNomRue());
enquete.setNumRue(enquetePayLoadWeb.getNumRue());
enquete.setSuperficie(enquetePayLoadWeb.getSuperficie());
enquete.setMontantMensuelleLocation(enquetePayLoadWeb.getMontantMensuelleLocation());
enquete.setMontantAnnuelleLocation(enquetePayLoadWeb.getMontantAnnuelleLocation());
enquete.setValeurParcelleEstime(enquetePayLoadWeb.getValeurParcelleEstime());
enquete.setValeurParcelleReel(enquetePayLoadWeb.getValeurParcelleReel());
Enquete finalEnquete=enqueteRepository.save(enquete);
//////Enregistrement des caractéristiques parcelle return enqueteRepository.findEnqueteToDto(enquete.getId()).orElse(null);
enquetePayLoadWeb.getCaracteristiqueParcellePayloadWebs().forEach(caracteristiqueParcellePayloadWeb -> { }
caracteristiqueParcellePayloadWeb.setEnqueteId(finalEnquete.getId());
CaracteristiqueParcelle caracteristiqueParcelle=entityFromPayLoadService.getCaracteristiqueParcelleFromPayLoadWeb(caracteristiqueParcellePayloadWeb);
caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcelle);
});
/////Enregistrement des pièce de parcelles private ParcellePayLoadWeb getParcellePayloadFromEnquetePl(EnquetePayLoadWeb enquetePayLoadWeb) {
enquetePayLoadWeb.getPiecePayLoadWebs().forEach(piecePayLoadWeb -> { ParcellePayLoadWeb parcellePayLoadWeb=new ParcellePayLoadWeb();
piecePayLoadWeb.setEnqueteId(finalEnquete.getId()); parcellePayLoadWeb.setId(enquetePayLoadWeb.getParcelleId());
//Piece piece=entityFromPayLoadService.getPieceFromPayLoadWeb(piecePayLoadWeb); parcellePayLoadWeb.setQ(enquetePayLoadWeb.getParcelleQ());
Piece piecefinal = pieceService.createPiece(entityFromPayLoadService.getPieceFromPayLoadWeb(piecePayLoadWeb)); parcellePayLoadWeb.setI(enquetePayLoadWeb.getParcelleI());
piecePayLoadWeb.getUploadPayLoadWebs().forEach(uploadPayLoadWeb -> { parcellePayLoadWeb.setP(enquetePayLoadWeb.getParcelleP());
uploadPayLoadWeb.setEnqueteId(finalEnquete.getId()); parcellePayLoadWeb.setNup(enquetePayLoadWeb.getParcelleNup());
Upload upload=entityFromPayLoadService.getUploadFromPayLoadWeb(uploadPayLoadWeb); parcellePayLoadWeb.setNupProvisoire(enquetePayLoadWeb.getNupProvisoire());
upload.setPiece(piecefinal); parcellePayLoadWeb.setNumTitreFoncier(enquetePayLoadWeb.getNumeroTitreFoncier());
uploadRepository.save(upload); parcellePayLoadWeb.setLongitude(enquetePayLoadWeb.getLongitude());
}); parcellePayLoadWeb.setLatitude(enquetePayLoadWeb.getLatitude());
}); parcellePayLoadWeb.setAltitude(enquetePayLoadWeb.getAltitude());
parcellePayLoadWeb.setSuperficie(enquetePayLoadWeb.getSuperficie());
/////Enregistrement des pièce de parcelles parcellePayLoadWeb.setObservation(enquetePayLoadWeb.getObservation());
enquetePayLoadWeb.getDeclarationNcPayloadWebs().forEach(declarationNcPayloadWeb -> { parcellePayLoadWeb.setSituationGeographique(enquetePayLoadWeb.getSituationGeographique());
declarationNcPayloadWeb.setEnqueteId(finalEnquete.getId()); parcellePayLoadWeb.setNumEntreeParcelle(enquetePayLoadWeb.getNumEntreeParcelle());
DeclarationNc declarationNcfinal=declarationNcService.createDeclarationNc(entityFromPayLoadService.getDeclarationNcFromPayLoadWeb(declarationNcPayloadWeb)); parcellePayLoadWeb.setQuartierId(enquetePayLoadWeb.getQuartierId());
declarationNcPayloadWeb.getUploadPayLoadWebs().forEach(uploadPayLoadWeb -> { parcellePayLoadWeb.setNatureDomaineId(enquetePayLoadWeb.getNatureDomaineId());
uploadPayLoadWeb.setEnqueteId(finalEnquete.getId()); parcellePayLoadWeb.setTypeDomaineId(enquetePayLoadWeb.getTypeDomaineId());
Upload upload=entityFromPayLoadService.getUploadFromPayLoadWeb(uploadPayLoadWeb); parcellePayLoadWeb.setRueId(enquetePayLoadWeb.getRueId());
upload.setDeclarationNc(declarationNcfinal); parcellePayLoadWeb.setProprietaireId(enquetePayLoadWeb.getPersonneId());
uploadRepository.save(upload); parcellePayLoadWeb.setNatureDomaineId(enquetePayLoadWeb.getNatureDomaineId());
}); parcellePayLoadWeb.setNatureDomaineId(enquetePayLoadWeb.getNatureDomaineId());
}); return parcellePayLoadWeb;
return enquete;
} }
@Override @Override
public Enquete updateEnquete(Long id,EnquetePayLoadWeb enquetePayLoadWeb) throws NotFoundException { public EnquetePayLoadWeb updateEnquete(Long id,EnquetePayLoadWeb enquetePayLoadWeb) throws NotFoundException {
if (enquetePayLoadWeb.getId() == null) { if (enquetePayLoadWeb.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une enquête ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une enquête ayant un id null.");
} }
@@ -205,17 +171,15 @@ public class EnqueteServiceImpl implements EnqueteService {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez modifier."); throw new NotFoundException("Impossible de trouver l'enquête que vous désirez modifier.");
} }
if (enquetePayLoadWeb.getParcellePayLoadWeb()==null) { if (enquetePayLoadWeb.getParcelleId()==null) {
throw new BadRequestException("Impossible d'enregistrer une enquête avec une parcelle inexistante"); throw new BadRequestException("Impossible d'enregistrer une enquête avec une parcelle inexistante");
} }
Parcelle parcelle=new Parcelle();
Long rueId;
Optional<User> optionalUser = userRepository.findById(enquetePayLoadWeb.getEnqueteurId()); Optional<User> optionalUser = userRepository.findById(enquetePayLoadWeb.getEnqueteurId());
if (!optionalUser.isPresent()) { if (!optionalUser.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : Enquêteur inexistant"); throw new BadRequestException("Echec de l'enregistrement : Enquêteur inexistant");
} }
Optional<Personne> optionalProprietaire = personneRepository.findById(enquetePayLoadWeb.getProprietaireId()); Optional<Personne> optionalProprietaire = personneRepository.findById(enquetePayLoadWeb.getPersonneId());
if (!optionalProprietaire.isPresent()) { if (!optionalProprietaire.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : Propriétaire inexistant"); throw new BadRequestException("Echec de l'enregistrement : Propriétaire inexistant");
} }
@@ -225,55 +189,28 @@ public class EnqueteServiceImpl implements EnqueteService {
throw new BadRequestException("Echec de l'enregistrement : zone inexistante"); throw new BadRequestException("Echec de l'enregistrement : zone inexistante");
} }
Optional<Rue> optionalRue = rueRepository.findById(enquetePayLoadWeb.getZoneRfuId()); if(enquetePayLoadWeb.getParcelleId()!=null) {
Optional<Parcelle> optionalParcelle = parcelleRepository.findById(enquetePayLoadWeb.getParcelleId());
if (optionalRue.isPresent()) { if (!optionalParcelle.isPresent()) {
rueId=optionalRue.get().getId(); throw new BadRequestException("Echec de l'enregistrement : Parcelle inexistante");
enquetePayLoadWeb.getParcellePayLoadWeb().setRueId(rueId); }
} }
Optional<Equipe> optionalEquipe = equipeRepository.findById(enquetePayLoadWeb.getEquipeId());
///enregistrement de la pacelle ParcellePayLoadWeb parcellePayLoadWeb= getParcellePayloadFromEnquetePl(enquetePayLoadWeb);
try {
if (enquetePayLoadWeb.getParcellePayLoadWeb().getId() == null) { if(parcellePayLoadWeb.getId()==null){
parcelle = parcelleService.createParcelle(enquetePayLoadWeb.getParcellePayLoadWeb()); parcellePayLoadWeb=parcelleService.createParcelle(parcellePayLoadWeb);
} else { }else{
parcelle = parcelleService.updateParcelle(enquetePayLoadWeb.getParcellePayLoadWeb().getId(),enquetePayLoadWeb.getParcellePayLoadWeb()); parcellePayLoadWeb=parcelleService.updateParcelle(parcellePayLoadWeb.getId(),parcellePayLoadWeb);
} }
}catch (Exception e){
throw new ApplicationException("Echec de l'enregistrement : La parcelle non enregistrée."); enquetePayLoadWeb.setParcelleId(parcellePayLoadWeb.getId());
}
////enregistrement de l'enquete
Enquete enquete = new Enquete(); Enquete enquete = entityFromPayLoadService.getEnqueteFromPayLoadWeb(enquetePayLoadWeb);
enquete.setDateEnquete(LocalDate.now()); enquete=enqueteRepository.save(enquete);
//enquete.setBloc(optionalBloc.get()); return enqueteRepository.findEnqueteToDto(enquete.getId()).orElse(null);
enquete.setUser(optionalUser.get());
enquete.setParcelle(parcelle);
enquete.setLitige(enquetePayLoadWeb.isLitige());
enquete.setStatutEnquete(StatutEnquete.EN_COURS);
enquete.setObservationParticuliere(enquetePayLoadWeb.getObservation());
enquete.setPersonne(optionalProprietaire.orElse(null));
enquete.setZoneRfu(optionalZoneRfu.orElse(null));
enquete.setAutreAdresse(enquetePayLoadWeb.getAutreAdresse());
enquete.setAutreNumeroTitreFoncier(enquetePayLoadWeb.getAutreNumeroTitreFoncier());
enquete.setNumeroTitreFoncier(enquetePayLoadWeb.getNumeroTitreFoncier());
enquete.setEquipe(optionalEquipe.orElse(null));
enquete.setDateDebutExcemption(enquetePayLoadWeb.getDateDebutExemption());
enquete.setDateFinExcemption(enquetePayLoadWeb.getDateFinExemption());
enquete.setNbreBatiment(enquetePayLoadWeb.getNbreBatiment());
enquete.setNbrePiscine(enquetePayLoadWeb.getNbrePiscine());
enquete.setNbreIndivisiaire(enquetePayLoadWeb.getNbreIndivisiaire());
enquete.setNbreCoProprietaire(enquetePayLoadWeb.getNbreCoProprietaire());
enquete.setNumEntreeParcelle(enquetePayLoadWeb.getNumEntreeParcelle());
enquete.setNomRue(enquetePayLoadWeb.getNomRue());
enquete.setNumRue(enquetePayLoadWeb.getNumRue());
enquete.setSuperficie(enquetePayLoadWeb.getSuperficie());
enquete.setMontantMensuelleLocation(enquetePayLoadWeb.getMontantMensuelleLocation());
enquete.setMontantAnnuelleLocation(enquetePayLoadWeb.getMontantAnnuelleLocation());
enquete.setValeurParcelleEstime(enquetePayLoadWeb.getValeurParcelleEstime());
enquete.setValeurParcelleReel(enquetePayLoadWeb.getValeurParcelleReel());
return enqueteRepository.save(enquete);
} }
@@ -390,31 +327,36 @@ public class EnqueteServiceImpl implements EnqueteService {
} }
@Override @Override
public Page<Enquete> getEnqueteList(Pageable pageable) { public Page<EnquetePayLoadWeb> getEnqueteList(Pageable pageable) {
return enqueteRepository.findAll(pageable); return enqueteRepository.findAllEnquetesToDtoPageable(pageable);
} }
@Override @Override
public List<Enquete> getEnqueteList() { public List<EnquetePayLoadWeb> getEnqueteList() {
return enqueteRepository.findAll(); return enqueteRepository.findAllEnquetesToDto();
} }
@Override @Override
public List<Enquete> getEnqueteListByParcelle(Long parcelleId) { public List<EnquetePayLoadWeb> getEnqueteListByParcelle(Long parcelleId) {
return enqueteRepository.findAllByParcelle_Id(parcelleId); return enqueteRepository.findAllEnquetesByParcelleToDto(parcelleId);
} }
@Override @Override
public Optional<Enquete> getEnqueteById(Long id) { public Page<EnquetePayLoadWeb> getEnqueteListByParcellePageable(Long parcelleId, Pageable pageable) {
return enqueteRepository.findAllEnquetesByParcelleToDtoPageable(parcelleId,pageable);
}
@Override
public Optional<EnquetePayLoadWeb> getEnqueteById(Long id) {
if (enqueteRepository.existsById(id)) { if (enqueteRepository.existsById(id)) {
return enqueteRepository.findById(id); return enqueteRepository.findEnqueteToDto(id);
} else { } else {
throw new NotFoundException("Impossible de trouver l'enquête."); throw new NotFoundException("Impossible de trouver l'enquête.");
} }
} }
@Override @Override
public Enquete validerEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) { public EnquetePayLoadWeb validerEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
if (enqueteTraitementPayLoad == null) { if (enqueteTraitementPayLoad == null) {
throw new BadRequestException("Impossible de valider une enquête ayant un id null."); throw new BadRequestException("Impossible de valider une enquête ayant un id null.");
} }
@@ -422,15 +364,22 @@ public class EnqueteServiceImpl implements EnqueteService {
if (!optionalEnquete.isPresent()) { if (!optionalEnquete.isPresent()) {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez valider."); throw new NotFoundException("Impossible de trouver l'enquête que vous désirez valider.");
} }
if(optionalEnquete.get().getStatutEnquete()==StatutEnquete.CLOTURE ||
optionalEnquete.get().getStatutEnquete()==StatutEnquete.REJETE ){
throw new NotAcceptableException("Impossible de valider : Le statut actuel "+optionalEnquete.get().getStatutEnquete()+" ne le permet pas.");
}
Enquete enquete = optionalEnquete.get(); Enquete enquete = optionalEnquete.get();
enquete.setDateValidation(LocalDate.now()); enquete.setDateValidation(LocalDate.now());
enquete.setStatutEnquete(StatutEnquete.VALIDE); enquete.setStatutEnquete(StatutEnquete.VALIDE);
enquete.setSynchronise(false); enquete.setSynchronise(true);
return enqueteRepository.save(enquete);
enquete= enqueteRepository.save(enquete);
return enqueteRepository.findEnqueteToDto(enquete.getId()).orElse(null);
} }
@Override @Override
public Enquete rejeterEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) { public EnquetePayLoadWeb rejeterEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
if (enqueteTraitementPayLoad.getIdBackend() == null) { if (enqueteTraitementPayLoad.getIdBackend() == null) {
throw new BadRequestException("Impossible de rejeter une enquête ayant un id null."); throw new BadRequestException("Impossible de rejeter une enquête ayant un id null.");
} }
@@ -438,38 +387,43 @@ public class EnqueteServiceImpl implements EnqueteService {
if (!optionalEnquete.isPresent()) { if (!optionalEnquete.isPresent()) {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez rejeter."); throw new NotFoundException("Impossible de trouver l'enquête que vous désirez rejeter.");
} }
if(optionalEnquete.get().getStatutEnquete()==StatutEnquete.CLOTURE ||
optionalEnquete.get().getStatutEnquete()==StatutEnquete.VALIDE ){
throw new NotAcceptableException("Impossible de rejeter : Le statut actuel "+optionalEnquete.get().getStatutEnquete()+" ne le permet pas.");
}
Enquete enquete = optionalEnquete.get(); Enquete enquete = optionalEnquete.get();
enquete.setDateRejet(LocalDate.now()); enquete.setDateRejet(LocalDate.now());
enquete.setDescriptionMotifRejet(enqueteTraitementPayLoad.getMotifRejet()); enquete.setDescriptionMotifRejet(enqueteTraitementPayLoad.getMotifRejet());
enquete.setStatutEnquete(StatutEnquete.REJETE); enquete.setStatutEnquete(StatutEnquete.REJETE);
enquete.setSynchronise(false); enquete.setSynchronise(false);
return enqueteRepository.save(enquete); enquete= enqueteRepository.save(enquete);
return enqueteRepository.findEnqueteToDto(enquete.getId()).orElse(null);
} }
@Override @Override
public List<Enquete> validerEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) { public List<EnquetePayLoadWeb> validerEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
List<Enquete> enquetes = new ArrayList<>(); List<EnquetePayLoadWeb> enquetePayLoadWebs = new ArrayList<>();
try { try {
for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) { for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) {
enquetes.add(validerEnquete(enqueteTraitementPayLoad)); enquetePayLoadWebs.add(validerEnquete(enqueteTraitementPayLoad));
} }
} catch (Exception e) { } catch (Exception e) {
enquetes.add(null); enquetePayLoadWebs.add(null);
} }
return enquetes; return enquetePayLoadWebs;
} }
@Override @Override
public List<Enquete> rejeterEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) { public List<EnquetePayLoadWeb> rejeterEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
List<Enquete> enquetes = new ArrayList<>(); List<EnquetePayLoadWeb> enquetePayLoadWebs = new ArrayList<>();
try { try {
for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) { for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) {
enquetes.add(rejeterEnquete(enqueteTraitementPayLoad)); enquetePayLoadWebs.add(rejeterEnquete(enqueteTraitementPayLoad));
} }
} catch (Exception e) { } catch (Exception e) {
enquetes.add(null); enquetePayLoadWebs.add(null);
} }
return enquetes; return enquetePayLoadWebs;
} }
@Override @Override
@@ -599,13 +553,13 @@ public class EnqueteServiceImpl implements EnqueteService {
List<CaracteristiqueParcelle> caracteristiqueParcelles = caracteristiqueParcelleRepository.findAllByEnquete_Id(enqueteId); List<CaracteristiqueParcelle> caracteristiqueParcelles = caracteristiqueParcelleRepository.findAllByEnquete_Id(enqueteId);
List<EnqueteBatiment> enqueteBatiments = enqueteBatimentRepository.findAllByEnquete_Id(enqueteId); //List<EnqueteBatiment> enqueteBatiments = enqueteBatimentRepository.findAllByEnquete_Id(enqueteId);
List<EnqueteUniteLogement> enqueteUniteLogements = enqueteUniteLogementRepository.findAllByEnquete_Id(enqueteId); // List<EnqueteUniteLogement> enqueteUniteLogements = enqueteUniteLogementRepository.findAllByEnquete_Id(enqueteId);
ficheEnquetesResponse.setCaracteristiquesParcelles(caracteristiqueParcelles); ficheEnquetesResponse.setCaracteristiquesParcelles(caracteristiqueParcelles);
ficheEnquetesResponse.setEnquetesBatiments(enqueteBatiments); // ficheEnquetesResponse.setEnquetesBatiments(enqueteBatiments);
ficheEnquetesResponse.setEnquetesUniteLogements(enqueteUniteLogements); // ficheEnquetesResponse.setEnquetesUniteLogements(enqueteUniteLogements);
ficheEnqueteResponse.setEnquete(ficheEnquetesResponse); ficheEnqueteResponse.setEnquete(ficheEnquetesResponse);
ficheEnqueteResponse.setActeurConcernes(acteurConcernes); ficheEnqueteResponse.setActeurConcernes(acteurConcernes);
@@ -618,4 +572,36 @@ public class EnqueteServiceImpl implements EnqueteService {
} }
@Override
@Transactional
public int cloturerEnqueteParcelleBatimentUniteLogementByUserIdAndExerciceId(Long userId,Long exerciceId) {
Optional<User> optionalUser= userRepository.findById(userId);
int nbreEnquete=0;
if(optionalUser.isPresent() && optionalUser.get().getStructure()!=null){
Long structureId=optionalUser.get().getStructure().getId();
nbreEnquete=cloturerEnqueteParcelleBatimentUniteLogementByStructureIdAndExerciceId(structureId,exerciceId);
}
return nbreEnquete;
}
@Override
public Page<EnquetePayLoadWeb> getEnqueteListByQuartierByStatutPageableToDto(Long userId, Long quartierId, StatutEnquete statutEnquete, Pageable pageable) {
List<Secteur> secteurs= secteurService.getListSecteurUserId(userId);
List<Long> secteurIds = secteurs.stream()
.map(Secteur::getId)
.toList();
return enqueteRepository.findAllEnqueteByQuartierByStatutToDtoPageable(quartierId,secteurIds,statutEnquete,pageable);
}
@Override
@Transactional
public int cloturerEnqueteParcelleBatimentUniteLogementByStructureIdAndExerciceId(Long structureId,Long exerciceId) {
Integer nombreParcelleImpacte=enqueteRepository.clotureEnqueteParcelle(structureId,exerciceId);
Integer nombreBatiment=enqueteBatimentRepository.clotureEnqueteBatiment(structureId,exerciceId);
Integer nombreUniteLogement=enqueteUniteLogementRepository.clotureEnqueteUniteLogement(structureId,exerciceId);
return nombreParcelleImpacte;
}
} }

View File

@@ -8,6 +8,7 @@ import io.gmss.fiscad.entities.infocad.metier.Upload;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.infocad.metier.ParcelleGeomService; import io.gmss.fiscad.interfaces.infocad.metier.ParcelleGeomService;
import io.gmss.fiscad.paylaods.request.crudweb.ParcelleGeomPaylaodWeb;
import io.gmss.fiscad.paylaods.response.EnqueteCheckResponse; import io.gmss.fiscad.paylaods.response.EnqueteCheckResponse;
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleGeomRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleGeomRepository;
@@ -79,6 +80,7 @@ public class ParcelleGeomServiceImpl implements ParcelleGeomService {
return n; return n;
} }
private Upload saveGeoJsonUpload(MultipartFile file,String reference,String desc) { private Upload saveGeoJsonUpload(MultipartFile file,String reference,String desc) {
Upload upload = new Upload(); Upload upload = new Upload();
String fileName = fileStorageService.storeFile(file); String fileName = fileStorageService.storeFile(file);
@@ -176,6 +178,16 @@ public class ParcelleGeomServiceImpl implements ParcelleGeomService {
return parcelleGeomRepository.findAllByQuartier_Code(codeQuartier); return parcelleGeomRepository.findAllByQuartier_Code(codeQuartier);
} }
@Override
public List<ParcelleGeomPaylaodWeb> getParcelleGeomListByQuatierId(Long quartierId) {
return parcelleGeomRepository.findAllByQuartierId(quartierId);
}
@Override
public Page<ParcelleGeomPaylaodWeb> getParcelleGeomListByQuatierIdPaged(Long quartierId, Pageable pageable) {
return parcelleGeomRepository.findAllByQuartierIdPageable(quartierId,pageable);
}
@Override @Override
public List<ParcelleGeom> getParcelleGeomListUnArrondissement(String codeArrondissement) { public List<ParcelleGeom> getParcelleGeomListUnArrondissement(String codeArrondissement) {
return parcelleGeomRepository.findAllByQuartier_Arrondissement_Code(codeArrondissement); return parcelleGeomRepository.findAllByQuartier_Arrondissement_Code(codeArrondissement);
@@ -262,4 +274,9 @@ public class ParcelleGeomServiceImpl implements ParcelleGeomService {
} }
@Override
public int createParcelleGeomFromGeoJsonApi() throws BadRequestException {
return 0;
}
} }

View File

@@ -2,14 +2,17 @@ package io.gmss.fiscad.implementations.infocad.metier;
import io.gmss.fiscad.entities.decoupage.Quartier; import io.gmss.fiscad.entities.decoupage.Quartier;
import io.gmss.fiscad.entities.decoupage.Secteur; import io.gmss.fiscad.entities.decoupage.Secteur;
import io.gmss.fiscad.entities.infocad.metier.Enquete;
import io.gmss.fiscad.entities.infocad.metier.EnqueteFiltreResponse; import io.gmss.fiscad.entities.infocad.metier.EnqueteFiltreResponse;
import io.gmss.fiscad.entities.infocad.metier.Parcelle; import io.gmss.fiscad.entities.infocad.metier.Parcelle;
import io.gmss.fiscad.entities.infocad.metier.Rue; import io.gmss.fiscad.entities.infocad.metier.Rue;
import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine; import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
import io.gmss.fiscad.entities.infocad.parametre.TypeDomaine;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.SecteurService; import io.gmss.fiscad.interfaces.decoupage.SecteurService;
import io.gmss.fiscad.interfaces.infocad.metier.ParcelleService; import io.gmss.fiscad.interfaces.infocad.metier.ParcelleService;
import io.gmss.fiscad.paylaods.FiltreParcelle;
import io.gmss.fiscad.paylaods.request.FiltreParcellePayLoad; import io.gmss.fiscad.paylaods.request.FiltreParcellePayLoad;
import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb; import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb;
import io.gmss.fiscad.paylaods.response.dataTableResponse.ParcelleDataTableResponse; import io.gmss.fiscad.paylaods.response.dataTableResponse.ParcelleDataTableResponse;
@@ -18,9 +21,12 @@ import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository
import io.gmss.fiscad.persistence.repositories.infocad.metier.RueRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.RueRepository;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.NatureDomaineRepository; import io.gmss.fiscad.persistence.repositories.infocad.parametre.NatureDomaineRepository;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.SituationGeographiqueRepository; import io.gmss.fiscad.persistence.repositories.infocad.parametre.SituationGeographiqueRepository;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.TypeDomaineRepository;
import io.gmss.fiscad.persistence.specification.ParcelleSpecification; import io.gmss.fiscad.persistence.specification.ParcelleSpecification;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import io.gmss.fiscad.service.GeometryService; import io.gmss.fiscad.service.GeometryService;
import jakarta.persistence.Query; import jakarta.persistence.Query;
import jakarta.transaction.Transactional;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.data.domain.*; import org.springframework.data.domain.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -37,6 +43,8 @@ public class ParcelleServiceImpl implements ParcelleService {
private final RueRepository rueRepository; private final RueRepository rueRepository;
private final GeometryService geometryService; private final GeometryService geometryService;
private final SecteurService secteurService; private final SecteurService secteurService;
private final TypeDomaineRepository typeDomaineRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
// @Value("${infocad.geom.srid}") // @Value("${infocad.geom.srid}")
// private String defaultSrid32631; // private String defaultSrid32631;
@@ -47,7 +55,7 @@ public class ParcelleServiceImpl implements ParcelleService {
@Override @Override
public Parcelle createParcelle(ParcellePayLoadWeb parcellePayLoadWeb) throws BadRequestException { public ParcellePayLoadWeb createParcelle(ParcellePayLoadWeb parcellePayLoadWeb) throws BadRequestException {
Optional<NatureDomaine> optionalNatureDomaine = natureDomaineRepository.findById(parcellePayLoadWeb.getNatureDomaineId()); Optional<NatureDomaine> optionalNatureDomaine = natureDomaineRepository.findById(parcellePayLoadWeb.getNatureDomaineId());
if (!optionalNatureDomaine.isPresent()) { if (!optionalNatureDomaine.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une parcelle avec une nature de domaine inexistant"); throw new BadRequestException("Impossible d'enregistrer une parcelle avec une nature de domaine inexistant");
@@ -56,36 +64,31 @@ public class ParcelleServiceImpl implements ParcelleService {
if (!optionalQuartier.isPresent()) { if (!optionalQuartier.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une parcelle avec un quartier/village inexistant"); throw new BadRequestException("Impossible d'enregistrer une parcelle avec un quartier/village inexistant");
} }
Optional<TypeDomaine> optionalTypeDomaine = typeDomaineRepository.findById(parcellePayLoadWeb.getTypeDomaineId());
if (!optionalTypeDomaine.isPresent()) {
throw new BadRequestException("Veuillez préciser le type de domaine");
}
Parcelle parcelle = new Parcelle(); Parcelle parcelle = new Parcelle();
parcelle.setNatureDomaine(optionalNatureDomaine.orElse(null)); parcelle = entityFromPayLoadService.getParcelleFromPayload(parcellePayLoadWeb);
parcelle.setQuartier(optionalQuartier.orElse(null)); parcelle= parcelleRepository.save(parcelle);
parcelle = getParcelleFromPayload(parcelle, parcellePayLoadWeb); return parcelleRepository.findParcelleToDtoById(parcelle.getId()).orElse(null);
return parcelleRepository.save(parcelle);
} }
@Override @Override
public Parcelle updateParcelle(Long id, ParcellePayLoadWeb parcellePayLoadWeb) throws NotFoundException { public ParcellePayLoadWeb updateParcelle(Long id, ParcellePayLoadWeb parcellePayLoadWeb) throws NotFoundException {
if(parcellePayLoadWeb.getId()!=null) {
Optional<Parcelle> optionalParcelle = parcelleRepository.findById(parcellePayLoadWeb.getId()); Optional<Parcelle> optionalParcelle = parcelleRepository.findById(parcellePayLoadWeb.getId());
if (!optionalParcelle.isPresent()) { if (!optionalParcelle.isPresent()) {
throw new NotFoundException("Impossible de trouver la parcelle que vous désirer modifier"); throw new NotFoundException("Impossible de trouver la parcelle que vous désirer modifier");
} }
Optional<NatureDomaine> optionalNatureDomaine = natureDomaineRepository.findById(parcellePayLoadWeb.getNatureDomaineId());
if (!optionalNatureDomaine.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une parcelle avec une nature de domaine inexistante");
} }
Optional<Quartier> optionalQuartier = quartierRepository.findById(parcellePayLoadWeb.getQuartierId());
if (!optionalQuartier.isPresent()) { Parcelle parcelle = new Parcelle();
throw new BadRequestException("Impossible d'enregistrer une parcelle avec un quartier/village inexistant"); parcelle = entityFromPayLoadService.getParcelleFromPayload(parcellePayLoadWeb);
} parcelle= parcelleRepository.save(parcelle);
// Optional<SituationGeographique> optionalSituationGeographique = situationGeographiqueRepository.findById(parcellePayLoadWeb.getSituationGeographiqueId()); return parcelleRepository.findParcelleToDtoById(parcelle.getId()).orElse(null);
// if (!optionalSituationGeographique.isPresent()) {
// throw new BadRequestException("Impossible d'enregistrer une parcelle avec une situation géographique inexistant");
// }
Parcelle parcelle=optionalParcelle.get();
parcelle.setNatureDomaine(optionalNatureDomaine.orElse(null));
parcelle.setQuartier(optionalQuartier.orElse(null));
parcelle = getParcelleFromPayload(optionalParcelle.get(), parcellePayLoadWeb);
return parcelleRepository.save(parcelle);
} }
@Override @Override
@@ -117,6 +120,54 @@ public class ParcelleServiceImpl implements ParcelleService {
return parcelleRepository.findAll(); return parcelleRepository.findAll();
} }
@Override
public Optional<ParcellePayLoadWeb> getParcelleByIdToDto(Long userId, Long parcelleId) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
return parcelleRepository.findParcelleToDtoById(secteurIds,parcelleId);
}
@Override
public List<ParcellePayLoadWeb> getParcelleListToDto(Long userId) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
return parcelleRepository.findAllParcelleToDto(secteurIds);
}
@Override
public Page<ParcellePayLoadWeb> getParcelleListPageableToDto(Long userId, Pageable pageable) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
return parcelleRepository.findAllParcelleToDtoPageable(secteurIds,pageable);
}
@Override
public List<ParcellePayLoadWeb> getParcelleListByQuartierToDto(Long userId, Long quartierId) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
return parcelleRepository.findAllParcelleByQuartierToDto(quartierId,secteurIds);
}
@Override
public Page<ParcellePayLoadWeb> getParcelleListByQuartierPageableToDto(Long userId, Long quartierId, Pageable pageable) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
return parcelleRepository.findAllParcelleByQuartierToDtoPageable(quartierId,secteurIds,pageable);
}
@Override
public List<ParcellePayLoadWeb> getParcelleListByRueToDto(Long userId, Long rueId) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
return parcelleRepository.findAllParcelleByRueToDto(rueId,secteurIds);
}
@Override
public Page<ParcellePayLoadWeb> getParcelleListByRuePageableToDto(Long userId, Long rueId, Pageable pageable) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
System.out.println(rueId);
secteurIds.forEach(aLong -> {
System.out.println(aLong);
});
return parcelleRepository.findAllParcelleByRueToDtoPageable(rueId,secteurIds,pageable);
}
@Override @Override
public Optional<Parcelle> getParcelleById(Long id) { public Optional<Parcelle> getParcelleById(Long id) {
if (parcelleRepository.existsById(id)) { if (parcelleRepository.existsById(id)) {
@@ -126,57 +177,37 @@ public class ParcelleServiceImpl implements ParcelleService {
} }
} }
@Override
public Page<ParcelleDataTableResponse> getParcelleDataTableListByUserId(Long userId, Pageable pageable) {
@Override
public Page<ParcellePayLoadWeb> getParcelleByMultiFiltre(Long userId, FiltreParcelle filtreParcelle, Pageable pageable) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
System.out.println(secteurIds.size());
if (secteurIds == null || secteurIds.isEmpty()) {
throw new IllegalArgumentException("Vous n'êtes pas autorisés à consulter ces parcelles");
}
return parcelleRepository.filtrerParcellesNative(
filtreParcelle,
secteurIds,
pageable
);
}
@Override
@Transactional
public Integer majParcelleBatieNonbatie() {
return parcelleRepository.updateParcelleBatieTrue()+parcelleRepository.updateParcelleBatieFalse();
}
private List<Long> getSecteurIdListForUser(Long userId) {
List<Secteur> secteurs = secteurService.getListSecteurUserId(userId); List<Secteur> secteurs = secteurService.getListSecteurUserId(userId);
List<Long> secteurIds = secteurs.stream() List<Long> secteurIds = secteurs.stream()
.map(Secteur::getId) .map(Secteur::getId)
.toList(); .toList();
Page<ParcelleDataTableResponse> parcelleDataTableResponses=parcelleRepository.getParcelleDataTableResponse(secteurIds,pageable); return secteurIds;
return parcelleDataTableResponses ;
} }
@Override
public Page<ParcelleDataTableResponse> getParcelleDataTableListByMultiFiltre(Long userId, FiltreParcellePayLoad filtreParcellePayLoad, Pageable pageable) {
List<Secteur> secteurs = secteurService.getListSecteurUserId(userId);
List<Long> secteurIds = secteurs.stream()
.map(Secteur::getId)
.toList();
//
// return parcelleRepository.findAll(
// ParcelleSpecification.filtre(filtreParcellePayLoad, secteurIds),
// pageable
// );
Page<ParcelleDataTableResponse> parcelleDataTableResponses=parcelleRepository.getParcelleDataTableResponse(secteurIds,pageable);
return parcelleDataTableResponses ;
}
private Parcelle getParcelleFromPayload(Parcelle parcelle, ParcellePayLoadWeb parcellePayLoadWeb) {
if(parcellePayLoadWeb.getRueId()!=null) {
Optional<Rue> optionalRue = rueRepository.findById(parcellePayLoadWeb.getRueId());
parcelle.setRue(optionalRue.orElse(null));
}
parcelle.setP(parcellePayLoadWeb.getP());
parcelle.setI(parcellePayLoadWeb.getI());
parcelle.setQ(parcellePayLoadWeb.getQ());
parcelle.setNup(parcellePayLoadWeb.getNup());
parcelle.setLatitude(parcellePayLoadWeb.getLatitude());
parcelle.setLongitude(parcellePayLoadWeb.getLongitude());
parcelle.setAltitude(parcellePayLoadWeb.getAltitude());
parcelle.setSituationGeographique(parcellePayLoadWeb.getSituationGeographique());
parcelle.setNupProvisoire(parcellePayLoadWeb.getNupProvisoire());
parcelle.setAutreNumeroTitreFoncier(parcellePayLoadWeb.getNumTitreFoncier());
parcelle.setObservation(parcellePayLoadWeb.getObservation());
parcelle.setSuperficie(parcellePayLoadWeb.getSuperficie());
return parcelle;
}
// private Parcelle getParcelle(Parcelle parcelle, ParcellePayLoadWeb parcellePayLoadWeb, Optional<SituationGeographique> optionalSituationGeographique, Optional<NatureDomaine> optionalNatureDomaine) { // private Parcelle getParcelle(Parcelle parcelle, ParcellePayLoadWeb parcellePayLoadWeb, Optional<SituationGeographique> optionalSituationGeographique, Optional<NatureDomaine> optionalNatureDomaine) {
// StringBuilder coordonnees = new StringBuilder(); // StringBuilder coordonnees = new StringBuilder();

View File

@@ -2,12 +2,17 @@ package io.gmss.fiscad.implementations.infocad.metier;
import io.gmss.fiscad.entities.infocad.parametre.*; import io.gmss.fiscad.entities.infocad.parametre.*;
import io.gmss.fiscad.enums.EtatIdentificationPersonne;
import io.gmss.fiscad.enums.Origine;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.infocad.metier.PersonneService; import io.gmss.fiscad.interfaces.infocad.metier.PersonneService;
import io.gmss.fiscad.paylaods.dto.*; import io.gmss.fiscad.paylaods.dto.*;
import io.gmss.fiscad.paylaods.request.IfuEnLigneRechercheBody;
import io.gmss.fiscad.paylaods.request.RecherchePersonneResquestBody;
import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb; import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb;
import io.gmss.fiscad.paylaods.response.ifuenligne.IfuEnLigneContribuableResponse;
import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository; import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository;
import io.gmss.fiscad.persistence.repositories.decoupage.NationaliteRepository; import io.gmss.fiscad.persistence.repositories.decoupage.NationaliteRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.MembreGroupeRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.MembreGroupeRepository;
@@ -17,6 +22,7 @@ import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneReposit
import io.gmss.fiscad.persistence.repositories.infocad.parametre.ProfessionRepository; import io.gmss.fiscad.persistence.repositories.infocad.parametre.ProfessionRepository;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.SituationMatrimonialeRepository; import io.gmss.fiscad.persistence.repositories.infocad.parametre.SituationMatrimonialeRepository;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.TypePersonneRepository; import io.gmss.fiscad.persistence.repositories.infocad.parametre.TypePersonneRepository;
import io.gmss.fiscad.service.CallAPIService;
import io.gmss.fiscad.service.EntityFromPayLoadService; import io.gmss.fiscad.service.EntityFromPayLoadService;
import jakarta.persistence.EntityNotFoundException; import jakarta.persistence.EntityNotFoundException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -24,9 +30,13 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.time.ZoneId;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class PersonneServiceImpl implements PersonneService { public class PersonneServiceImpl implements PersonneService {
@@ -41,26 +51,19 @@ public class PersonneServiceImpl implements PersonneService {
private final ProfessionRepository professionRepository; private final ProfessionRepository professionRepository;
private final SituationMatrimonialeRepository situationMatrimonialeRepository; private final SituationMatrimonialeRepository situationMatrimonialeRepository;
private final EntityFromPayLoadService entityFromPayLoadService; private final EntityFromPayLoadService entityFromPayLoadService;
private final CallAPIService callAPIService;
@Override @Override
public Personne createPersonne(PersonnePayLoadWeb personnePayLoadWeb) throws BadRequestException { public PersonnePayLoadWeb createPersonne(PersonnePayLoadWeb personnePayLoadWeb) throws BadRequestException {
// Optional<TypePersonne> optionalTypePersonne = typePersonneRepository.findById(personnePayLoadWeb.getTypePersonneId());
//
// Optional<Commune> optionalCommune = communeRepository.findById(personnePayLoadWeb.getCommuneId());
//
//
// Optional<Nationalite> optionalNationalite = nationaliteRepository.findById(personnePayLoadWeb.getNationaliteId());
//
// Optional<SituationMatrimoniale> optionalQuartier = situationMatrimonialeRepository.findById(personnePayLoadWeb.getSituationMatrimonialeId());
//
// Optional<Profession> optionalProfession = professionRepository.findById(personnePayLoadWeb.getProfessionId());
//
Personne personne = entityFromPayLoadService.getPersonneFromPayLoadWeb(personnePayLoadWeb); Personne personne = entityFromPayLoadService.getPersonneFromPayLoadWeb(personnePayLoadWeb);
return personneRepository.save(personne); personne =personneRepository.save(personne);
return personneRepository.findBypersonneId(personne.getId()).orElse(null);
} }
@Override @Override
public Personne updatePersonne(Long id, PersonnePayLoadWeb personnePayLoadWeb) throws NotFoundException { public PersonnePayLoadWeb updatePersonne(Long id, PersonnePayLoadWeb personnePayLoadWeb) throws NotFoundException {
if (personnePayLoadWeb.getId() == null) { if (personnePayLoadWeb.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une enquête ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une enquête ayant un id null.");
} }
@@ -69,7 +72,8 @@ public class PersonneServiceImpl implements PersonneService {
} }
Personne personne = entityFromPayLoadService.getPersonneFromPayLoadWeb(personnePayLoadWeb); Personne personne = entityFromPayLoadService.getPersonneFromPayLoadWeb(personnePayLoadWeb);
return personneRepository.save(personne); personne =personneRepository.save(personne);
return personneRepository.findBypersonneId(personne.getId()).orElse(null);
} }
@Override @Override
@@ -78,18 +82,18 @@ public class PersonneServiceImpl implements PersonneService {
} }
@Override @Override
public Page<Personne> getPersonneList(Pageable pageable) { public Page<PersonnePayLoadWeb> getPersonneList(Pageable pageable) {
return null; return null;
} }
@Override @Override
public List<Personne> getPersonneList() { public List<PersonnePayLoadWeb> getPersonneList() {
return null; return null;
} }
@Override @Override
public Optional<Personne> getPersonneById(Long id) { public Optional<PersonnePayLoadWeb> getPersonneById(Long id) {
return personneRepository.findById(id); return personneRepository.findBypersonneId(id);
} }
@Override @Override
@@ -189,5 +193,200 @@ public class PersonneServiceImpl implements PersonneService {
membres membres
); );
} }
// @Override
// public List<PersonnePayLoadWeb> recherchePersonne(RecherchePersonneResquestBody recherchePersonneResquestBody) {
//
//
//
// List<PersonnePayLoadWeb> personnePayLoadWebsRfuLoggil = new ArrayList<>();
// personnePayLoadWebsRfuLoggil = recherchePersonneLocal(recherchePersonneResquestBody);
//
// try{
//
// LocalDate date = recherchePersonneResquestBody.getDateNaissance();
// String dateNaissance = date != null
// ? date.format(DateTimeFormatter.ISO_LOCAL_DATE)
// : null;
//
// IfuEnLigneRechercheBody ifuEnLigneRechercheBody =new IfuEnLigneRechercheBody();
// // ifuEnLigneRechercheBody.setIfu(recherchePersonneResquestBody.getIfu());
// ifuEnLigneRechercheBody.setNom(recherchePersonneResquestBody.getNom());
// ifuEnLigneRechercheBody.setPrenom(recherchePersonneResquestBody.getPrenom());
// ifuEnLigneRechercheBody.setDateNaissance(dateNaissance);
//
// List<IfuEnLigneContribuableResponse> ifuEnLigneContribuableResponses =callAPIService.callApiRechercheContribIfuEnLigne(ifuEnLigneRechercheBody);
// System.out.println(ifuEnLigneContribuableResponses);
// if(ifuEnLigneContribuableResponses!=null && !ifuEnLigneContribuableResponses.isEmpty()){
// //List<PersonnePayLoadWeb> finalPersonnePayLoadWebsRfuLoggil = personnePayLoadWebsRfuLoggil;
// ifuEnLigneContribuableResponses.forEach(ifuEnLigneContribuableResponse -> {
// PersonnePayLoadWeb personnePayLoadWeb=new PersonnePayLoadWeb();
// personnePayLoadWeb.setSource(Origine.SIGIBE);
// personnePayLoadWeb.setNpi(ifuEnLigneContribuableResponse.getNpi());
// personnePayLoadWeb.setIfu(ifuEnLigneContribuableResponse.getIfu());
// personnePayLoadWeb.setNomMere(ifuEnLigneContribuableResponse.getMotherlastname());
// personnePayLoadWeb.setNom(ifuEnLigneContribuableResponse.getLastname());
// personnePayLoadWeb.setPrenom(ifuEnLigneContribuableResponse.getFirstname());
// personnePayLoadWeb.setPrenomMere(ifuEnLigneContribuableResponse.getBjmotherfirstname());
//
// Date birthdate = ifuEnLigneContribuableResponse.getBirthdate();
// LocalDate localDate = birthdate != null
// ? birthdate.toInstant()
// .atZone(ZoneId.systemDefault())
// .toLocalDate()
// : null;
// personnePayLoadWeb.setDateNaissanceOuConsti(localDate);
// personnePayLoadWeb.setTel1(ifuEnLigneContribuableResponse.getPhonenumber());
// personnePayLoadWeb.setLieuNaissance(ifuEnLigneContribuableResponse.getBirthplace());
// personnePayLoadWeb.setSexe(ifuEnLigneContribuableResponse.getSexe());
//
// personnePayLoadWebsRfuLoggil.add(personnePayLoadWeb);
// });
// }
// }catch (Exception e){
// e.printStackTrace();
// }
//
// return personnePayLoadWebsRfuLoggil;
// }
@Override
public List<PersonnePayLoadWeb> recherchePersonne(RecherchePersonneResquestBody request) {
try {
if(request.getIfu()!=null && !request.getIfu().equals("")){
List<PersonnePayLoadWeb> personnePayLoadWebs =personneRepository.findAllPersonneByIfuToDto(request.getIfu());
if(!personnePayLoadWebs.isEmpty())
return personnePayLoadWebs;
}
if(request.getNpi()!=null && !request.getNpi().equals("")){
List<PersonnePayLoadWeb> personnePayLoadWebs = personneRepository.findAllPersonneByNpiToDto(request.getNpi());
if(!personnePayLoadWebs.isEmpty())
return personnePayLoadWebs;
}
List<PersonnePayLoadWeb> result=new ArrayList<>();
result = recherchePersonneLocal(request);
if (result != null && !result.isEmpty()) {
return result;
}
// Conversion date en String format yyyy-MM-dd
String dateNaissance = Optional.ofNullable(request.getDateNaissance())
.map(d -> d.format(DateTimeFormatter.ISO_LOCAL_DATE))
.orElse(null);
// Construction du body IFU
IfuEnLigneRechercheBody ifuRequest = new IfuEnLigneRechercheBody();
ifuRequest.setNom(request.getNom());
ifuRequest.setPrenom(request.getPrenom());
ifuRequest.setDateNaissance(dateNaissance);
List<IfuEnLigneContribuableResponse> responses =
callAPIService.callApiRechercheContribIfuEnLigne(ifuRequest);
if (responses == null || responses.isEmpty()) {
return result;
}
for (IfuEnLigneContribuableResponse r : responses) {
PersonnePayLoadWeb personne = new PersonnePayLoadWeb();
personne.setEtatIdentificationPersonne(EtatIdentificationPersonne.IFU);
personne.setNpi(r.getNpi());
personne.setIfu(r.getIfu());
personne.setNomMere(r.getMotherlastname());
personne.setNom(r.getLastname());
personne.setPrenom(r.getFirstname());
personne.setPrenomMere(r.getBjmotherfirstname());
personne.setTel1(r.getPhonenumber());
personne.setLieuNaissance(r.getBirthplace());
personne.setSexe(r.getSexe());
// Conversion Date → LocalDate
Date birthdate = r.getBirthdate();
LocalDate localDate = birthdate != null
? birthdate.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate()
: null;
personne.setDateNaissanceOuConsti(localDate);
personne.setEtatIdentificationPersonne(EtatIdentificationPersonne.IFU);
result.add(personne);
}
return result;
} catch (Exception e) {
return new ArrayList<>();
}
}
// private List<PersonnePayLoadWeb> recherchePersonneLocal(RecherchePersonneResquestBody recherchePersonneResquestBody) {
// System.out.println("NOUS SOMMES DANS RECHERCHE NOM ET PRENOM :"+recherchePersonneResquestBody.getNom()+" "+recherchePersonneResquestBody.getPrenom());
// List<PersonnePayLoadWeb> personnePayLoadWebs=
// personneRepository.findByFiltersInBaseIfuNpiCorrecte(
// recherchePersonneResquestBody.getNom()==null?null: "%"+recherchePersonneResquestBody.getNom().trim().toUpperCase()+"%",
// recherchePersonneResquestBody.getPrenom()==null?null: "%"+recherchePersonneResquestBody.getPrenom().trim().toUpperCase()+"%",
// recherchePersonneResquestBody.getRaisonSociale()==null?null: "%"+recherchePersonneResquestBody.getRaisonSociale().trim().toUpperCase()+"%",
// recherchePersonneResquestBody.getNomMere()==null?null: "%"+recherchePersonneResquestBody.getNomMere().trim().toUpperCase()+"%"
// );
// return personnePayLoadWebs ;
// }
private List<PersonnePayLoadWeb> recherchePersonneLocal(RecherchePersonneResquestBody request) {
String nom = normalizeLikeParam(request.getNom());
String prenom = normalizeLikeParam(request.getPrenom());
String raisonSociale = normalizeLikeParam(request.getRaisonSociale());
String nomMere = normalizeLikeParam(request.getNomMere());
return personneRepository.findByFiltersInBaseIfuNpiCorrecte(
nom,
prenom,
raisonSociale,
nomMere
);
}
private String normalizeLikeParam(String value) {
if (value == null) return null;
String cleaned = value.trim();
if (cleaned.isEmpty()) return null;
return "%" + cleaned.toUpperCase() + "%";
}
private List<PersonnePayLoadWeb> recherchePersonneSigibe(RecherchePersonneResquestBody recherchePersonneResquestBody) {
// callAPIService.callGetIfuEnLigneToken();
return null;
}
private List<PersonnePayLoadWeb> recherchePersonneAnip(RecherchePersonneResquestBody recherchePersonneResquestBody) {
// callAPIService.callGetIfuEnLigneToken();
return null;
}
private String like(String value) {
if (value == null) {
return null;
}
value = value.trim();
if (value.isEmpty()) {
return null;
}
return "%" + value + "%";
}
} }

View File

@@ -1,44 +1,138 @@
package io.gmss.fiscad.implementations.infocad.metier; package io.gmss.fiscad.implementations.infocad.metier;
import lombok.AllArgsConstructor;
import io.gmss.fiscad.entities.infocad.metier.Piece; import io.gmss.fiscad.entities.infocad.metier.Piece;
import io.gmss.fiscad.entities.rfu.metier.DeclarationNc;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.infocad.metier.PieceService; import io.gmss.fiscad.interfaces.infocad.metier.PieceService;
import io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb;
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.PieceRepository;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@AllArgsConstructor
@Service @Service
public class PieceServiceImpl implements PieceService { public class PieceServiceImpl implements PieceService {
private final PieceRepository pieceRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
private final EnqueteRepository enqueteRepository;
private final PersonneRepository personneRepository;
@Override @Override
public Piece createPiece(Piece piece) throws BadRequestException { public PiecePayLoadWeb createPiece(PiecePayLoadWeb piecePayLoadWeb) throws BadRequestException {
return null; if (piecePayLoadWeb.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle déclaration NC ayant un id non null.");
}
Piece piece= entityFromPayLoadService.getPieceFromPayLoadWeb(piecePayLoadWeb);
piece =pieceRepository.save(piece);
return pieceRepository.findPieceToDto(piece.getId()).orElse(null);
} }
@Override @Override
public Piece updatePiece(Long id, Piece piece) throws NotFoundException { public PiecePayLoadWeb updatePiece(Long id, PiecePayLoadWeb piecePayLoadWeb) throws NotFoundException {
return null; if (piecePayLoadWeb.getId() == null) {
throw new BadRequestException("La piece n'existe pas.");
}
if (!pieceRepository.existsById(piecePayLoadWeb.getId())) {
throw new NotFoundException("La piece n'existe pas");
}
Piece piece= entityFromPayLoadService.getPieceFromPayLoadWeb(piecePayLoadWeb);
piece =pieceRepository.save(piece);
return pieceRepository.findPieceToDto(piece.getId()).orElse(null);
} }
@Override @Override
public void deletePiece(Long id) throws NotFoundException { public void deletePiece(Long id) throws NotFoundException {
Optional<Piece> pieceOptional = pieceRepository.findById(id);
if (pieceOptional.isPresent()) {
pieceRepository.deleteById(pieceOptional.get().getId());
} else {
throw new NotFoundException("Impossible de trouver la piece à supprimer .");
}
} }
@Override @Override
public Page<Piece> getPieceList(Pageable pageable) { public Page<PiecePayLoadWeb> getPieceListToDtoPageable(Pageable pageable) {
return null; return pieceRepository.findAllToDtoPageable(pageable);
} }
@Override @Override
public List<Piece> getPieceList() { public List<PiecePayLoadWeb> getPieceListToDto() {
return null; return pieceRepository.findAllPieceToDto();
} }
@Override @Override
public Optional<Piece> getPieceById(Long id) { public Optional<PiecePayLoadWeb> getPieceByToDto(Long id) {
return Optional.empty(); return pieceRepository.findPieceToDto(id);
}
@Override
public List<PiecePayLoadWeb> getAllPieceByEnqueteToDto(Long id) {
return pieceRepository.findByFilters(
null,
null,
null,
null,
id,
null,
null,
null,
null);
}
@Override
public Page<PiecePayLoadWeb> getAllPieceByEnqueteToDtoPageable(Long id,Pageable pageable) {
return pieceRepository.findByFiltersPageable(
null,
null,
null,
null,
id,
null,
null,
null,
null,
pageable);
}
@Override
public List<PiecePayLoadWeb> getAllPieceByEnqueteBatimentToDto(Long id) {
return pieceRepository.findByFilters(
null,
null,
null,
null,
null,
null,
null,
id,
null);
}
@Override
public List<PiecePayLoadWeb> getAllPieceByEnqueteUniteLogementToDto(Long id) {
return pieceRepository.findByFilters(
null,
null,
null,
null,
null,
null,
null,
null,
id);
} }
} }

View File

@@ -0,0 +1,103 @@
package io.gmss.fiscad.implementations.infocad.metier;
import io.gmss.fiscad.entities.infocad.metier.Piece;
import io.gmss.fiscad.entities.infocad.metier.Upload;
import io.gmss.fiscad.entities.rfu.metier.Batiment;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.infocad.metier.UploadService;
import io.gmss.fiscad.paylaods.request.crudweb.UploadPayLoadWeb;
import io.gmss.fiscad.persistence.repositories.infocad.metier.PieceRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import io.gmss.fiscad.service.FileStorageService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Optional;
@AllArgsConstructor
@Service
public class UploadServiceImpl implements UploadService {
private final EntityFromPayLoadService entityFromPayLoadService;
private final UploadRepository uploadRepository;
private final PieceRepository pieceRepository;
private final FileStorageService fileStorageService;
@Override
public UploadPayLoadWeb createUpload(UploadPayLoadWeb uploadPayLoadWeb) throws BadRequestException {
if (uploadPayLoadWeb.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau upload ayant un id non null.");
}
Upload upload= entityFromPayLoadService.getUploadFromPayLoadWeb(uploadPayLoadWeb);
upload= uploadRepository.save(upload);
return uploadRepository.findByIdToDto(upload.getId()).orElse(null);
}
@Override
public Upload createUpload(MultipartFile file, @RequestParam Long pieceId) throws BadRequestException {
Upload upload = new Upload();
if(pieceId!=null && !pieceRepository.existsById(pieceId)) {
throw new NotFoundException("La piece n'existe pas");
}
Optional<Piece> optionalPiece = pieceRepository.findById(pieceId);
String fileName = fileStorageService.storeFile(file);
upload.setPiece(optionalPiece.orElse(null));
upload.setFileName(fileName);
upload.setRename(fileName);
upload.setMimeType(file.getContentType());
upload.setSize(file.getSize());
upload.setOriginalFileName(file.getOriginalFilename());
upload = uploadRepository.save(upload) ;
return upload;
}
@Override
public UploadPayLoadWeb updateUpload(Long id, UploadPayLoadWeb uploadPayLoadWeb) throws NotFoundException {
return null;
}
@Override
public void deleteUpload(Long id) throws NotFoundException {
Optional<Upload> optionalUpload = uploadRepository.findById(id);
if (optionalUpload.isPresent()) {
uploadRepository.deleteById(optionalUpload.get().getId());
} else {
throw new NotFoundException("Impossible de trouver le fichier spécifié dans notre base de données.");
}
}
@Override
public Page<UploadPayLoadWeb> getUploadListToDtoPageable(Pageable pageable) {
return null;
}
@Override
public List<UploadPayLoadWeb> getUploadListToDto() {
return null;
}
@Override
public Optional<UploadPayLoadWeb> getUploadByToDto(Long id) {
return Optional.empty();
}
@Override
public List<UploadPayLoadWeb> getAllUploadByPieceToDto(Long id) {
return uploadRepository.findByPieceId(id);
}
@Override
public Page<UploadPayLoadWeb> getAllUploadByPieceDtoPageable(Long id, Pageable pageable) {
return null;
}
@Override
public List<Upload> getAllUploadByPiece(Long id) {
return uploadRepository.findAllByPiece_Id(id);
}
}

View File

@@ -1,20 +1,25 @@
package io.gmss.fiscad.implementations.infocad.parametre; package io.gmss.fiscad.implementations.infocad.parametre;
import io.gmss.fiscad.entities.decoupage.Commune; import io.gmss.fiscad.entities.decoupage.Commune;
import io.gmss.fiscad.entities.decoupage.Secteur;
import io.gmss.fiscad.entities.decoupage.Section; import io.gmss.fiscad.entities.decoupage.Section;
import io.gmss.fiscad.entities.infocad.parametre.Structure; import io.gmss.fiscad.entities.infocad.parametre.Structure;
import io.gmss.fiscad.entities.user.AvoirFonction;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService; import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
import io.gmss.fiscad.paylaods.request.crudweb.StructurePaylaodWeb; import io.gmss.fiscad.paylaods.request.crudweb.StructurePaylaodWeb;
import io.gmss.fiscad.paylaods.response.StructureResponse; import io.gmss.fiscad.paylaods.response.StructureResponse;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.StructureRepository; import io.gmss.fiscad.persistence.repositories.infocad.parametre.StructureRepository;
import io.gmss.fiscad.persistence.repositories.user.AvoirFonctionRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService; import io.gmss.fiscad.service.EntityFromPayLoadService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@AllArgsConstructor @AllArgsConstructor
@@ -23,6 +28,7 @@ public class StructureServiceImpl implements StructureService {
private final StructureRepository structureRepository; private final StructureRepository structureRepository;
private final EntityFromPayLoadService entityFromPayLoadService; private final EntityFromPayLoadService entityFromPayLoadService;
private final AvoirFonctionRepository avoirFonctionRepository;
@Override @Override
public StructurePaylaodWeb createStructure(StructurePaylaodWeb structurePaylaodWeb) throws BadRequestException { public StructurePaylaodWeb createStructure(StructurePaylaodWeb structurePaylaodWeb) throws BadRequestException {
@@ -89,5 +95,29 @@ public class StructureServiceImpl implements StructureService {
return structureRepository.findStructureToDtoById(id); return structureRepository.findStructureToDtoById(id);
} }
@Override
public List<Structure> getListStructureUserId(Long userId) {
List<AvoirFonction> avoirFonctions= avoirFonctionRepository.findAvoirFonctionByUser_Id(userId);
List<Structure> structures = new ArrayList<>();
avoirFonctions.stream()
.filter(af -> af.getDateFin() == null || af.getDateFin().isAfter(LocalDate.now()))
.forEach(avoirFonction -> {
if(avoirFonction.getFonction().getStructure()!=null){
structures.addAll(List.of(avoirFonction.getFonction().getStructure()));
}else if (avoirFonction.getFonction().getDepartement()!=null){
structures.addAll(structureRepository.findDistinctByCommune_Departement_Id(avoirFonction.getFonction().getDepartement().getId()));
}
});
return structures;
}
// public List<Long> getStructureIdListForUser(Long userId) {
// List<Structure> structures = secteurService.getListSecteurUserId(userId);
// List<Long> secteurIds = secteurs.stream()
// .map(Secteur::getId)
// .toList();
// return secteurIds;
// }
} }

View File

@@ -1,11 +1,15 @@
package io.gmss.fiscad.implementations.rfu.metier; package io.gmss.fiscad.implementations.rfu.metier;
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
import io.gmss.fiscad.entities.rfu.metier.Batiment; import io.gmss.fiscad.entities.rfu.metier.Batiment;
import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.rfu.metier.BatimentService; import io.gmss.fiscad.interfaces.rfu.metier.BatimentService;
import io.gmss.fiscad.paylaods.request.crudweb.BatimentPaylaodWeb; import io.gmss.fiscad.paylaods.request.crudweb.BatimentPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
import io.gmss.fiscad.persistence.repositories.rfu.metier.BatimentRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.BatimentRepository;
import io.gmss.fiscad.persistence.repositories.rfu.parametre.CategorieBatimentRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService; import io.gmss.fiscad.service.EntityFromPayLoadService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
@@ -19,30 +23,59 @@ import java.util.Optional;
public class BatimentServiceImpl implements BatimentService { public class BatimentServiceImpl implements BatimentService {
private final BatimentRepository batimentRepository; private final BatimentRepository batimentRepository;
private final ParcelleRepository parcelleRepository;
private final CategorieBatimentRepository categorieBatimentRepository;
private final EntityFromPayLoadService entityFromPayLoadService; private final EntityFromPayLoadService entityFromPayLoadService;
@Override @Override
public Batiment createBatiment(BatimentPaylaodWeb batimentPaylaodWeb) throws BadRequestException { public BatimentPaylaodWeb createBatiment(BatimentPaylaodWeb batimentPaylaodWeb) throws BadRequestException {
if (batimentPaylaodWeb.getId() != null) { if (batimentPaylaodWeb.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau batiment ayant un id non null."); throw new BadRequestException("Impossible de créer un nouveau batiment ayant un id non null.");
} }
Batiment batiment= entityFromPayLoadService.getBatimentFromPayLoadWeb(batimentPaylaodWeb); if (batimentPaylaodWeb.getParcelleId() == null) {
throw new BadRequestException("Impossible de créer un nouveau batiment: La parcelle doit être précisée.");
}else {
if(!parcelleRepository.existsById(batimentPaylaodWeb.getParcelleId()))
throw new BadRequestException("Impossible de créer un nouveau batiment: La parcelle doit être précisée.");
}
return batimentRepository.save(batiment); if (batimentPaylaodWeb.getCategorieBatimentId() == null) {
throw new BadRequestException("Impossible de créer un nouveau batiment: La catégorie doit être précisée.");
}else {
if(!categorieBatimentRepository.existsById(batimentPaylaodWeb.getCategorieBatimentId()))
throw new BadRequestException("Impossible de créer un nouveau batiment: La catégorie doit être précisée.");
}
Batiment batiment= entityFromPayLoadService.getBatimentFromPayLoadWeb(batimentPaylaodWeb);
batiment= batimentRepository.save(batiment);
System.out.println(batiment.getId());
return batimentRepository.findBatimentAvecOccupantCourantToDto(batiment.getId()).orElse(null);
} }
@Override @Override
public Batiment updateBatiment(Long id,BatimentPaylaodWeb batimentPaylaodWeb) throws NotFoundException { public BatimentPaylaodWeb updateBatiment(Long id,BatimentPaylaodWeb batimentPaylaodWeb) throws NotFoundException {
if (batimentPaylaodWeb.getId() == null) { if (batimentPaylaodWeb.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouveau batiment ayant un id null."); throw new BadRequestException("Impossible de mettre à jour un nouveau batiment ayant un id null.");
} }
if (!batimentRepository.existsById(batimentPaylaodWeb.getId())) { if (!batimentRepository.existsById(batimentPaylaodWeb.getId())) {
throw new NotFoundException("Impossible de trouver le batiment spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le batiment spécifié dans notre base de données.");
} }
Batiment batiment= entityFromPayLoadService.getBatimentFromPayLoadWeb(batimentPaylaodWeb); if (batimentPaylaodWeb.getParcelleId() == null) {
throw new BadRequestException("Impossible de créer un nouveau batiment: La parcelle doit être précisée.");
}else {
if(!parcelleRepository.existsById(batimentPaylaodWeb.getParcelleId()))
throw new BadRequestException("Impossible de créer un nouveau batiment: La parcelle doit être précisée.");
}
return batimentRepository.save(batiment); if (batimentPaylaodWeb.getCategorieBatimentId() == null) {
throw new BadRequestException("Impossible de créer un nouveau batiment: La catégorie doit être précisée.");
}else {
if(!categorieBatimentRepository.existsById(batimentPaylaodWeb.getCategorieBatimentId()))
throw new BadRequestException("Impossible de créer un nouveau batiment: La catégorie doit être précisée.");
}
Batiment batiment= entityFromPayLoadService.getBatimentFromPayLoadWeb(batimentPaylaodWeb);
batiment= batimentRepository.save(batiment);
return batimentRepository.findBatimentAvecOccupantCourantToDto(batiment.getId()).orElse(null);
} }
@Override @Override
@@ -56,23 +89,43 @@ public class BatimentServiceImpl implements BatimentService {
} }
@Override @Override
public Page<Batiment> getBatimentList(Pageable pageable) { public Page<BatimentPaylaodWeb> getBatimentList(Pageable pageable) {
return batimentRepository.findAll(pageable); return batimentRepository.findAllBatimentsAvecOccupantCourantToDtoPageble(pageable);
} }
@Override @Override
public List<Batiment> getBatimentList() { public List<BatimentPaylaodWeb> getBatimentList() {
return batimentRepository.findAll(); return batimentRepository.findAllBatimentsAvecOccupantCourantToDto();
}
@Override
public Page<BatimentPaylaodWeb> getBatimentListByParcellePageable(Long parcelleId, Pageable pageable) {
return batimentRepository.findAllBatimentsAvecOccupantCourantByParcelleToDtoPageble(parcelleId,pageable);
}
@Override
public List<BatimentPaylaodWeb> getBatimentListByParcelle(Long parcelleId) {
return batimentRepository.findAllBatimentsAvecOccupantCourantByParcelleToDto(parcelleId);
} }
@Override @Override
public Optional<Batiment> getBatimentById(Long id) { public Optional<BatimentPaylaodWeb> getBatimentById(Long id) {
if (batimentRepository.existsById(id)) { if (batimentRepository.existsById(id)) {
return batimentRepository.findById(id); return batimentRepository.findBatimentAvecOccupantCourantToDto(id);
} else { } else {
throw new NotFoundException("Impossible de trouver la caractéristique spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la caractéristique spécifiée dans la base de données.");
} }
} }
@Override
public Page<BatimentPaylaodWeb> getBatimentListByquartierPageable(Long quartierId, Pageable pageable) {
return batimentRepository.findAllBatimentsAvecOccupantCourantByQuartierToDtoPageble(quartierId,pageable);
}
@Override
public List<BatimentPaylaodWeb> getBatimentListByquartier(Long quartierId) {
return batimentRepository.findAllBatimentsAvecOccupantCourantByQuartierToDto(quartierId);
}
} }

View File

@@ -1,43 +1,56 @@
package io.gmss.fiscad.implementations.rfu.metier; package io.gmss.fiscad.implementations.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment; import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment;
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService;
import io.gmss.fiscad.paylaods.request.crudweb.CaracteristiqueBatimentPayloadWeb;
import io.gmss.fiscad.persistence.repositories.rfu.metier.CaracteristiqueBatimentRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.CaracteristiqueBatimentRepository;
import io.gmss.fiscad.persistence.repositories.rfu.metier.EnqueteBatimentRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@AllArgsConstructor
@Service @Service
public class CaracteristiqueBatimentServiceImpl implements CaracteristiqueBatimentService { public class CaracteristiqueBatimentServiceImpl implements CaracteristiqueBatimentService {
private final CaracteristiqueBatimentRepository caracteristiqueBatimentRepository; private final CaracteristiqueBatimentRepository caracteristiqueBatimentRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
private final EnqueteBatimentRepository enqueteBatimentRepository;
public CaracteristiqueBatimentServiceImpl(CaracteristiqueBatimentRepository caracteristiqueBatimentRepository) {
this.caracteristiqueBatimentRepository = caracteristiqueBatimentRepository;
}
@Override @Override
public CaracteristiqueBatiment createCaracteristiqueBatiment(CaracteristiqueBatiment caracteristiqueBatiment) throws BadRequestException { public CaracteristiqueBatimentPayloadWeb createCaracteristiqueBatiment(CaracteristiqueBatimentPayloadWeb caracteristiqueBatimentPayloadWeb) throws BadRequestException {
if (caracteristiqueBatiment.getId() != null) { if (caracteristiqueBatimentPayloadWeb.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle caracteristique de batiment ayant un id non null."); throw new BadRequestException("Impossible de créer une nouvelle caracteristique de batiment ayant un id non null.");
} }
return caracteristiqueBatimentRepository.save(caracteristiqueBatiment); if (!enqueteBatimentRepository.existsById(caracteristiqueBatimentPayloadWeb.getEnqueteBatimentId())) {
throw new BadRequestException("Veuillez préciser l'enquete");
}
CaracteristiqueBatiment caracteristiqueBatiment= entityFromPayLoadService.getCaracteristiqueBatimentFromPayLoadWeb(caracteristiqueBatimentPayloadWeb);
caracteristiqueBatiment =caracteristiqueBatimentRepository.save(caracteristiqueBatiment);
return caracteristiqueBatimentRepository.findCaracteristiqueBatimentToDto(caracteristiqueBatiment.getId()).orElse(null);
} }
@Override @Override
public CaracteristiqueBatiment updateCaracteristiqueBatiment(Long id, CaracteristiqueBatiment caracteristiqueBatiment) throws NotFoundException { public CaracteristiqueBatimentPayloadWeb updateCaracteristiqueBatiment(Long id, CaracteristiqueBatimentPayloadWeb caracteristiqueBatimentPayloadWeb) throws NotFoundException {
if (caracteristiqueBatiment.getId() == null) { if (caracteristiqueBatimentPayloadWeb.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle caracteristique de batiment ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle caracteristique de batiment ayant un id null.");
} }
if (!caracteristiqueBatimentRepository.existsById(caracteristiqueBatiment.getId())) { if (!caracteristiqueBatimentRepository.existsById(caracteristiqueBatimentPayloadWeb.getId())) {
throw new NotFoundException("Impossible de trouver la nouvelle caracteristique de batiment spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver la nouvelle caracteristique de batiment spécifié dans notre base de données.");
} }
return caracteristiqueBatimentRepository.save(caracteristiqueBatiment); CaracteristiqueBatiment caracteristiqueBatiment= entityFromPayLoadService.getCaracteristiqueBatimentFromPayLoadWeb(caracteristiqueBatimentPayloadWeb);
caracteristiqueBatiment =caracteristiqueBatimentRepository.save(caracteristiqueBatiment);
return caracteristiqueBatimentRepository.findCaracteristiqueBatimentToDto(caracteristiqueBatiment.getId()).orElse(null);
} }
@Override @Override
@@ -51,23 +64,33 @@ public class CaracteristiqueBatimentServiceImpl implements CaracteristiqueBatime
} }
@Override @Override
public Page<CaracteristiqueBatiment> getCaracteristiqueBatimentList(Pageable pageable) { public Page<CaracteristiqueBatimentPayloadWeb> getCaracteristiqueBatimentList(Pageable pageable) {
return caracteristiqueBatimentRepository.findAll(pageable); return caracteristiqueBatimentRepository.findAllCaracteristiqueBatimentToDtoPageable(pageable);
} }
@Override @Override
public List<CaracteristiqueBatiment> getCaracteristiqueBatimentList() { public List<CaracteristiqueBatimentPayloadWeb> getCaracteristiqueBatimentList() {
return caracteristiqueBatimentRepository.findAll(); return caracteristiqueBatimentRepository.findAllCaracteristiqueBatimentToDto();
} }
@Override @Override
public Optional<CaracteristiqueBatiment> getCaracteristiqueBatimentById(Long id) { public Optional<CaracteristiqueBatimentPayloadWeb> getCaracteristiqueBatimentToDto(Long id) {
if (caracteristiqueBatimentRepository.existsById(id)) { if (caracteristiqueBatimentRepository.existsById(id)) {
return caracteristiqueBatimentRepository.findById(id); return caracteristiqueBatimentRepository.findCaracteristiqueBatimentToDto(id);
} else { } else {
throw new NotFoundException("Impossible de trouver la caractéristique spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la caractéristique spécifiée dans la base de données.");
} }
} }
@Override
public Page<CaracteristiqueBatimentPayloadWeb> getCaracteristiqueBatimentListByEnqueteBatimentPageable(Long enqueteBatimentId, Pageable pageable) {
return caracteristiqueBatimentRepository.findAllCaracteristiqueBatimentByEnqueteBatimentToDtoPageable(enqueteBatimentId,pageable);
}
@Override
public List<CaracteristiqueBatimentPayloadWeb> getCaracteristiqueBatimentListByEnqueteBatiment(Long enqueteBatimentId) {
return caracteristiqueBatimentRepository.findAllCaracteristiqueBatimentByEnqueteBatimentToDto(enqueteBatimentId);
}
} }

View File

@@ -4,40 +4,46 @@ import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService;
import io.gmss.fiscad.paylaods.request.crudweb.CaracteristiqueParcellePayloadWeb;
import io.gmss.fiscad.persistence.repositories.rfu.metier.CaracteristiqueParcelleRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.CaracteristiqueParcelleRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@AllArgsConstructor
@Service @Service
public class CaracteristiqueParcelleServiceImpl implements CaracteristiqueParcelleService { public class CaracteristiqueParcelleServiceImpl implements CaracteristiqueParcelleService {
private final CaracteristiqueParcelleRepository caracteristiqueParcelleRepository; private final CaracteristiqueParcelleRepository caracteristiqueParcelleRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
public CaracteristiqueParcelleServiceImpl(CaracteristiqueParcelleRepository caracteristiqueParcelleRepository) {
this.caracteristiqueParcelleRepository = caracteristiqueParcelleRepository;
}
@Override @Override
public CaracteristiqueParcelle createCaracteristiqueParcelle(CaracteristiqueParcelle caracteristiqueParcelle) throws BadRequestException { public CaracteristiqueParcellePayloadWeb createCaracteristiqueParcelle(CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb) throws BadRequestException {
if (caracteristiqueParcelle.getId() != null) { if (caracteristiqueParcellePayloadWeb.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle caracteristique de parcelle ayant un id non null."); throw new BadRequestException("Impossible de créer une nouvelle caracteristique de parcelle ayant un id non null.");
} }
return caracteristiqueParcelleRepository.save(caracteristiqueParcelle); CaracteristiqueParcelle caracteristiqueParcelle= entityFromPayLoadService.getCaracteristiqueParcelleFromPayLoadWeb(caracteristiqueParcellePayloadWeb);
caracteristiqueParcelle =caracteristiqueParcelleRepository.save(caracteristiqueParcelle);
return caracteristiqueParcelleRepository.findCaracteristiqueParcelleToDto(caracteristiqueParcelle.getId()).orElse(null);
} }
@Override @Override
public CaracteristiqueParcelle updateCaracteristiqueParcelle(Long id, CaracteristiqueParcelle caracteristiqueParcelle) throws NotFoundException { public CaracteristiqueParcellePayloadWeb updateCaracteristiqueParcelle(Long id, CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb) throws NotFoundException {
if (caracteristiqueParcelle.getId() == null) { if (caracteristiqueParcellePayloadWeb.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle caracteristique de parcelle ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle caracteristique de parcelle ayant un id null.");
} }
if (!caracteristiqueParcelleRepository.existsById(caracteristiqueParcelle.getId())) { if (!caracteristiqueParcelleRepository.existsById(caracteristiqueParcellePayloadWeb.getId())) {
throw new NotFoundException("Impossible de trouver la nouvelle caracteristique de parcelle spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver la nouvelle caracteristique de parcelle spécifié dans notre base de données.");
} }
return caracteristiqueParcelleRepository.save(caracteristiqueParcelle); CaracteristiqueParcelle caracteristiqueParcelle= entityFromPayLoadService.getCaracteristiqueParcelleFromPayLoadWeb(caracteristiqueParcellePayloadWeb);
caracteristiqueParcelle =caracteristiqueParcelleRepository.save(caracteristiqueParcelle);
return caracteristiqueParcelleRepository.findCaracteristiqueParcelleToDto(caracteristiqueParcelle.getId()).orElse(null);
} }
@Override @Override
@@ -62,12 +68,22 @@ public class CaracteristiqueParcelleServiceImpl implements CaracteristiqueParcel
@Override @Override
public Optional<CaracteristiqueParcelle> getCaracteristiqueParcelleById(Long id) { public Optional<CaracteristiqueParcellePayloadWeb> getCaracteristiqueParcelleById(Long id) {
if (caracteristiqueParcelleRepository.existsById(id)) { if (caracteristiqueParcelleRepository.existsById(id)) {
return caracteristiqueParcelleRepository.findById(id); return caracteristiqueParcelleRepository.findCaracteristiqueParcelleToDto(id);
} else { } else {
throw new NotFoundException("Impossible de trouver la caractéristique spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la caractéristique spécifiée dans la base de données.");
} }
} }
@Override
public Page<CaracteristiqueParcellePayloadWeb> getCaracteristiqueParcelleByEnqueteListPageable(Long id,Pageable pageable) {
return caracteristiqueParcelleRepository.findAllCaracteristiqueParcelleByEnqueteToDtoPageable(id,pageable);
}
@Override
public List<CaracteristiqueParcellePayloadWeb> getCaracteristiqueParcelleByEnqueteList(Long enqueteId) {
return caracteristiqueParcelleRepository.findAllCaracteristiqueParcelleByEnqueteToDto(enqueteId);
}
} }

View File

@@ -1,43 +1,56 @@
package io.gmss.fiscad.implementations.rfu.metier; package io.gmss.fiscad.implementations.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment;
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueUniteLogement; import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueUniteLogement;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService;
import io.gmss.fiscad.paylaods.request.crudweb.CaracteristiqueUniteLogementPayloadWeb;
import io.gmss.fiscad.persistence.repositories.rfu.metier.CaracteristiqueUniteLogementRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.CaracteristiqueUniteLogementRepository;
import io.gmss.fiscad.persistence.repositories.rfu.metier.EnqueteUniteLogementRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@AllArgsConstructor
@Service @Service
public class CaracteristiqueUniteLogementServiceImpl implements CaracteristiqueUniteLogementService { public class CaracteristiqueUniteLogementServiceImpl implements CaracteristiqueUniteLogementService {
private final CaracteristiqueUniteLogementRepository caracteristiqueUniteLogementRepository; private final CaracteristiqueUniteLogementRepository caracteristiqueUniteLogementRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
private final EnqueteUniteLogementRepository enqueteUniteLogementRepository;
public CaracteristiqueUniteLogementServiceImpl(CaracteristiqueUniteLogementRepository caracteristiqueUniteLogementRepository) {
this.caracteristiqueUniteLogementRepository = caracteristiqueUniteLogementRepository;
}
@Override @Override
public CaracteristiqueUniteLogement createCaracteristiqueUniteLogement(CaracteristiqueUniteLogement caracteristiqueUniteLogement) throws BadRequestException { public CaracteristiqueUniteLogementPayloadWeb createCaracteristiqueUniteLogement(CaracteristiqueUniteLogementPayloadWeb caracteristiqueUniteLogementPayloadWeb) throws BadRequestException {
if (caracteristiqueUniteLogement.getId() != null) { if (caracteristiqueUniteLogementPayloadWeb.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle caracteristique d'unité de logement ayant un id non null."); throw new BadRequestException("Impossible de créer une nouvelle caracteristique d'unité de logement ayant un id non null.");
} }
return caracteristiqueUniteLogementRepository.save(caracteristiqueUniteLogement); if (!enqueteUniteLogementRepository.existsById(caracteristiqueUniteLogementPayloadWeb.getEnqueteUniteLogementId())) {
throw new BadRequestException("Veuillez préciser l'enquete.");
}
CaracteristiqueUniteLogement caracteristiqueUniteLogement= entityFromPayLoadService.getCaracteristiqueUniteLogementFromPayLoadWeb(caracteristiqueUniteLogementPayloadWeb);
caracteristiqueUniteLogement =caracteristiqueUniteLogementRepository.save(caracteristiqueUniteLogement);
return caracteristiqueUniteLogementRepository.findCaracteristiqueUniteLogementToDto(caracteristiqueUniteLogement.getId()).orElse(null);
} }
@Override @Override
public CaracteristiqueUniteLogement updateCaracteristiqueUniteLogement(Long id, CaracteristiqueUniteLogement caracteristiqueUniteLogement) throws NotFoundException { public CaracteristiqueUniteLogementPayloadWeb updateCaracteristiqueUniteLogement(Long id, CaracteristiqueUniteLogementPayloadWeb caracteristiqueUniteLogementPayloadWeb) throws NotFoundException {
if (caracteristiqueUniteLogement.getId() == null) { if (caracteristiqueUniteLogementPayloadWeb.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle caracteristique d'unité de logement ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle caracteristique d'unité de logement ayant un id null.");
} }
if (!caracteristiqueUniteLogementRepository.existsById(caracteristiqueUniteLogement.getId())) { if (!caracteristiqueUniteLogementRepository.existsById(caracteristiqueUniteLogementPayloadWeb.getId())) {
throw new NotFoundException("Impossible de trouver la nouvelle caracteristique d'unité de logement spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la nouvelle caracteristique d'unité de logement spécifiée dans notre base de données.");
} }
return caracteristiqueUniteLogementRepository.save(caracteristiqueUniteLogement); CaracteristiqueUniteLogement caracteristiqueUniteLogement= entityFromPayLoadService.getCaracteristiqueUniteLogementFromPayLoadWeb(caracteristiqueUniteLogementPayloadWeb);
caracteristiqueUniteLogement =caracteristiqueUniteLogementRepository.save(caracteristiqueUniteLogement);
return caracteristiqueUniteLogementRepository.findCaracteristiqueUniteLogementToDto(caracteristiqueUniteLogement.getId()).orElse(null);
} }
@Override @Override
@@ -51,23 +64,33 @@ public class CaracteristiqueUniteLogementServiceImpl implements CaracteristiqueU
} }
@Override @Override
public Page<CaracteristiqueUniteLogement> getCaracteristiqueUniteLogementList(Pageable pageable) { public Page<CaracteristiqueUniteLogementPayloadWeb> getCaracteristiqueUniteLogementList(Pageable pageable) {
return caracteristiqueUniteLogementRepository.findAll(pageable); return caracteristiqueUniteLogementRepository.findAllCaracteristiqueUniteLogementToDtoPageable(pageable);
} }
@Override @Override
public List<CaracteristiqueUniteLogement> getCaracteristiqueUniteLogementList() { public List<CaracteristiqueUniteLogementPayloadWeb> getCaracteristiqueUniteLogementList() {
return caracteristiqueUniteLogementRepository.findAll(); return caracteristiqueUniteLogementRepository.findAllCaracteristiqueUniteLogementToDto();
} }
@Override @Override
public Optional<CaracteristiqueUniteLogement> getCaracteristiqueUniteLogementById(Long id) { public Optional<CaracteristiqueUniteLogementPayloadWeb> getCaracteristiqueUniteLogementById(Long id) {
if (caracteristiqueUniteLogementRepository.existsById(id)) { if (caracteristiqueUniteLogementRepository.existsById(id)) {
return caracteristiqueUniteLogementRepository.findById(id); return caracteristiqueUniteLogementRepository.findCaracteristiqueUniteLogementToDto(id);
} else { } else {
throw new NotFoundException("Impossible de trouver la caracteristique d'unité de logement spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la caracteristique d'unité de logement spécifiée dans la base de données.");
} }
} }
@Override
public Page<CaracteristiqueUniteLogementPayloadWeb> getCaracteristiqueUniteLogementListByEul(Long eul, Pageable pageable) {
return caracteristiqueUniteLogementRepository.findAllCaracteristiqueUniteLogementByEnqueteUloToDtoPageable(eul,pageable);
}
@Override
public List<CaracteristiqueUniteLogementPayloadWeb> getCaracteristiqueUniteLogementListbyEul(Long eul) {
return caracteristiqueUniteLogementRepository.findAllCaracteristiqueUniteLogementByEnqueteUloToDto(eul);
}
} }

View File

@@ -1,43 +1,66 @@
package io.gmss.fiscad.implementations.rfu.metier; package io.gmss.fiscad.implementations.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueUniteLogement;
import io.gmss.fiscad.entities.rfu.metier.DeclarationNc; import io.gmss.fiscad.entities.rfu.metier.DeclarationNc;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.rfu.metier.DeclarationNcService; import io.gmss.fiscad.interfaces.rfu.metier.DeclarationNcService;
import io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.StructureRepository;
import io.gmss.fiscad.persistence.repositories.rfu.metier.DeclarationNcRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.DeclarationNcRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@AllArgsConstructor
@Service @Service
public class DeclarationNcServiceImpl implements DeclarationNcService { public class DeclarationNcServiceImpl implements DeclarationNcService {
private final DeclarationNcRepository declarationNcRepository; private final DeclarationNcRepository declarationNcRepository;
private final StructureRepository structureRepository;
private final PersonneRepository personneRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
public DeclarationNcServiceImpl(DeclarationNcRepository declarationNcRepository) {
this.declarationNcRepository = declarationNcRepository; @Override
public DeclarationNcPayloadWeb createDeclarationNc(DeclarationNcPayloadWeb declarationNcPayloadWeb) throws BadRequestException {
if (declarationNcPayloadWeb.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle déclaration NC ayant un id non null.");
}
if (!personneRepository.existsById(declarationNcPayloadWeb.getPersonneId())) {
throw new BadRequestException("Veuillez préciser le contribuable.");
}
if (!structureRepository.existsById(declarationNcPayloadWeb.getStructureId())) {
throw new BadRequestException("Veuillez préciser le centre.");
}
DeclarationNc declarationNc= entityFromPayLoadService.getDeclarationNcFromPayLoadWeb(declarationNcPayloadWeb);
declarationNc =declarationNcRepository.save(declarationNc);
return declarationNcRepository.findDeclarationNcToDto(declarationNc.getId()).orElse(null);
} }
@Override @Override
public DeclarationNc createDeclarationNc(DeclarationNc declarationNc) throws BadRequestException { public DeclarationNcPayloadWeb updateDeclarationNc(Long id, DeclarationNcPayloadWeb declarationNcPayloadWeb) throws NotFoundException {
if (declarationNc.getId() != null) { if (declarationNcPayloadWeb.getId() == null) {
throw new BadRequestException("Impossible de créer une nouvelle enquete de batiment ayant un id non null.");
}
return declarationNcRepository.save(declarationNc);
}
@Override
public DeclarationNc updateDeclarationNc(Long id, DeclarationNc declarationNc) throws NotFoundException {
if (declarationNc.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle enquete de batiment ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle enquete de batiment ayant un id null.");
} }
if (!declarationNcRepository.existsById(declarationNc.getId())) { if (!declarationNcRepository.existsById(declarationNcPayloadWeb.getId())) {
throw new NotFoundException("Impossible de trouver la nouvelle enquete de batiment spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la nouvelle enquete de batiment spécifiée dans notre base de données.");
} }
return declarationNcRepository.save(declarationNc); if (!personneRepository.existsById(declarationNcPayloadWeb.getPersonneId())) {
throw new BadRequestException("Veuillez préciser le contribuable.");
}
if (!structureRepository.existsById(declarationNcPayloadWeb.getStructureId())) {
throw new BadRequestException("Veuillez préciser le centre.");
}
DeclarationNc declarationNc= entityFromPayLoadService.getDeclarationNcFromPayLoadWeb(declarationNcPayloadWeb);
declarationNc =declarationNcRepository.save(declarationNc);
return declarationNcRepository.findDeclarationNcToDto(declarationNc.getId()).orElse(null);
} }
@Override @Override
@@ -51,23 +74,36 @@ public class DeclarationNcServiceImpl implements DeclarationNcService {
} }
@Override @Override
public Page<DeclarationNc> getDeclarationNcList(Pageable pageable) { public Page<DeclarationNcPayloadWeb> getDeclarationNcList(Pageable pageable) {
return declarationNcRepository.findAll(pageable); return declarationNcRepository.findAllDeclarationNcToDtoPageable(pageable);
} }
@Override @Override
public List<DeclarationNc> getDeclarationNcList() { public List<DeclarationNcPayloadWeb> getDeclarationNcList() {
return declarationNcRepository.findAll(); return declarationNcRepository.findAllDeclarationNcToDto();
} }
@Override @Override
public Optional<DeclarationNc> getDeclarationNcById(Long id) { public Optional<DeclarationNcPayloadWeb> getDeclarationNcById(Long id) {
if (declarationNcRepository.existsById(id)) { if (declarationNcRepository.existsById(id)) {
return declarationNcRepository.findById(id); return declarationNcRepository.findDeclarationNcToDto(id);
} else { } else {
throw new NotFoundException("Impossible de trouver la nouvelle enquete de batiment spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la nouvelle enquete de batiment spécifiée dans la base de données.");
} }
} }
@Override
public Page<DeclarationNcPayloadWeb> getDeclarationNcByPersonneList(Long personneId, Pageable pageable) {
return declarationNcRepository.findAllDeclarationNcByPersonneToDtoPageable(personneId,pageable);
}
@Override
public List<DeclarationNcPayloadWeb> getDeclarationNcByPersonneList(Long personneId) {
return declarationNcRepository.findAllDeclarationNcByPersonneToDto(personneId);
}
} }

View File

@@ -4,9 +4,12 @@ import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.rfu.metier.DonneesImpositionTfu; import io.gmss.fiscad.entities.rfu.metier.DonneesImpositionTfu;
import io.gmss.fiscad.entities.rfu.metier.ImpositionsTfu; import io.gmss.fiscad.entities.rfu.metier.ImpositionsTfu;
import io.gmss.fiscad.entities.rfu.parametre.BaremRfuNonBati; import io.gmss.fiscad.entities.rfu.parametre.BaremRfuNonBati;
import io.gmss.fiscad.enums.StatusAvis;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.rfu.metier.DonneesImpositionTfuService; import io.gmss.fiscad.interfaces.rfu.metier.DonneesImpositionTfuService;
import io.gmss.fiscad.paylaods.request.crudweb.DonneesImpositionPaylaodWeb;
import io.gmss.fiscad.paylaods.request.crudweb.ImpositionsTfuPaylaodWeb;
import io.gmss.fiscad.paylaods.response.DonneesImpositionTfuResponse; import io.gmss.fiscad.paylaods.response.DonneesImpositionTfuResponse;
import io.gmss.fiscad.persistence.repositories.decoupage.ArrondissementRepository; import io.gmss.fiscad.persistence.repositories.decoupage.ArrondissementRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
@@ -15,6 +18,7 @@ import io.gmss.fiscad.persistence.repositories.rfu.metier.DonneesImpositionTfuRe
import io.gmss.fiscad.persistence.repositories.rfu.metier.ImpositionsTfuRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.ImpositionsTfuRepository;
import io.gmss.fiscad.persistence.repositories.rfu.parametre.BaremRfuNonBatiRepository; import io.gmss.fiscad.persistence.repositories.rfu.parametre.BaremRfuNonBatiRepository;
import io.gmss.fiscad.persistence.repositories.rfu.parametre.ExerciceRepository; import io.gmss.fiscad.persistence.repositories.rfu.parametre.ExerciceRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import jakarta.transaction.Transactional; import jakarta.transaction.Transactional;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
@@ -36,6 +40,7 @@ public class DonneesImpositionTfuServiceImpl implements DonneesImpositionTfuServ
private final BaremRfuNonBatiRepository baremRfuNonBatiRepository; private final BaremRfuNonBatiRepository baremRfuNonBatiRepository;
private final ExerciceRepository exerciceRepository; private final ExerciceRepository exerciceRepository;
private final ArrondissementRepository arrondissementRepository; private final ArrondissementRepository arrondissementRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
@@ -91,91 +96,51 @@ public class DonneesImpositionTfuServiceImpl implements DonneesImpositionTfuServ
@Override @Override
@Transactional @Transactional
public Long genererDonneesFiscales(ImpositionsTfu impositionsTfu) { public ImpositionsTfuPaylaodWeb genererDonneesFiscalesParcelleNonBatie(ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb, Long userId) {
List<DonneesImpositionTfuResponse> donneesImpositionTfuResponses= donneesImpositionTfuRepository.findAllDonneesImpositionTfu(impositionsTfu.getCommune().getId(),impositionsTfu.getExercice().getAnnee()); Integer nb= donneesImpositionTfuRepository.genererDonneesTfuNonBatie(impositionsTfuPaylaodWeb.getId(),userId);
Long n=0l;
for (DonneesImpositionTfuResponse donneesImpositionTfuResponse: donneesImpositionTfuResponses){
DonneesImpositionTfu donneesImpositionTfu=new DonneesImpositionTfu();
donneesImpositionTfu.setImpositionsTfu(impositionsTfu);
donneesImpositionTfu.setZoneRfuId(donneesImpositionTfuResponse.getZoneRfuId());
donneesImpositionTfu.setCodeQuartierVillage(donneesImpositionTfuResponse.getCodeQuartierVillage());
donneesImpositionTfu.setNomQuartierVillage(donneesImpositionTfuResponse.getNomQuartierVillage());
donneesImpositionTfu.setCodeArrondissement(donneesImpositionTfuResponse.getCodeArrondissement());
donneesImpositionTfu.setNomArrondissement(donneesImpositionTfuResponse.getNomArrondissement());
donneesImpositionTfu.setCodeCommune(donneesImpositionTfuResponse.getCodeCommune());
donneesImpositionTfu.setNomCommune(donneesImpositionTfuResponse.getNomCommune());
donneesImpositionTfu.setCodeDepartement(donneesImpositionTfuResponse.getCodeDepartement());
donneesImpositionTfu.setNomDepartement(donneesImpositionTfuResponse.getNomDepartement());
donneesImpositionTfu.setQ(donneesImpositionTfuResponse.getQ());
donneesImpositionTfu.setIlot(donneesImpositionTfuResponse.getIlot());
donneesImpositionTfu.setParcelle(donneesImpositionTfuResponse.getParcelle());
donneesImpositionTfu.setLatitude(donneesImpositionTfuResponse.getLatitude());
donneesImpositionTfu.setLongitude(donneesImpositionTfuResponse.getLongitude());
donneesImpositionTfu.setNup(donneesImpositionTfuResponse.getNup());
donneesImpositionTfu.setNupProvisoire(donneesImpositionTfuResponse.getNupProvisoire());
donneesImpositionTfu.setSuperficieParc(donneesImpositionTfuResponse.getSuperficieParc());
donneesImpositionTfu.setAdresseProp(donneesImpositionTfuResponse.getAdresseProp());
donneesImpositionTfu.setAnnee(donneesImpositionTfuResponse.getAnnee());
donneesImpositionTfu.setAdresseSc(donneesImpositionTfuResponse.getAdresseSc());
donneesImpositionTfu.setBatieOuiNon(donneesImpositionTfuResponse.getBatieOuiNon());
donneesImpositionTfu.setTfuMinimum(donneesImpositionTfuResponse.getTfuMinimum());
donneesImpositionTfu.setCategorieBat(donneesImpositionTfuResponse.getCategorieBat());
donneesImpositionTfu.setDateEnquete(donneesImpositionTfuResponse.getDateEnquete());
donneesImpositionTfu.setEmailProp(donneesImpositionTfuResponse.getEmailProp());
donneesImpositionTfu.setEmailSc(donneesImpositionTfuResponse.getEmailSc());
donneesImpositionTfu.setMontantLoyerAnnuel(donneesImpositionTfuResponse.getMontantLoyerAnnuel());
donneesImpositionTfu.setEnqueteId(donneesImpositionTfuResponse.getEnqueteId());
donneesImpositionTfu.setExhonereOuiNon(donneesImpositionTfuResponse.getExhonereOuiNon());
donneesImpositionTfu.setIfu(donneesImpositionTfuResponse.getIfu());
donneesImpositionTfu.setNombreBat(donneesImpositionTfuResponse.getNombreBat());
donneesImpositionTfu.setNombrePiscine(donneesImpositionTfuResponse.getNombrePiscine());
donneesImpositionTfu.setNombreUlog(donneesImpositionTfuResponse.getNombreUlog());
donneesImpositionTfu.setNomProp(donneesImpositionTfuResponse.getNomProp());
donneesImpositionTfu.setNomSc(donneesImpositionTfuResponse.getNomSc());
donneesImpositionTfu.setNpi(donneesImpositionTfuResponse.getNpi());
donneesImpositionTfu.setNumBatiment(donneesImpositionTfuResponse.getNumBatiment()==null?"":donneesImpositionTfuResponse.getNumBatiment());
donneesImpositionTfu.setNumUniteLogement(donneesImpositionTfuResponse.getNumUniteLogement()==null?"":donneesImpositionTfuResponse.getNumUniteLogement());
donneesImpositionTfu.setPrenomProp(donneesImpositionTfuResponse.getPrenomProp());
donneesImpositionTfu.setPrenomSc(donneesImpositionTfuResponse.getPrenomSc());
donneesImpositionTfu.setRaisonSociale(donneesImpositionTfuResponse.getRaisonSociale());
donneesImpositionTfu.setSecteurId(donneesImpositionTfuResponse.getSecteurId());
donneesImpositionTfu.setStandingBat(donneesImpositionTfuResponse.getStandingBat());
donneesImpositionTfu.setStructureId(donneesImpositionTfuResponse.getStructureId());
donneesImpositionTfu.setSuperficieAuSolBat(donneesImpositionTfuResponse.getSuperficieAuSolBat());
donneesImpositionTfu.setSuperficieAuSolUlog(donneesImpositionTfuResponse.getSuperficieAuSolUlog());
donneesImpositionTfu.setTelProp(donneesImpositionTfuResponse.getTelProp());
donneesImpositionTfu.setTelSc(donneesImpositionTfuResponse.getTelSc());
donneesImpositionTfu.setTfuMetreCarre(donneesImpositionTfuResponse.getTfuMetreCarre());
donneesImpositionTfu.setTitreFoncier(donneesImpositionTfuResponse.getTitreFoncier());
donneesImpositionTfu.setValeurLocativeAdm(donneesImpositionTfuResponse.getValeurLocativeAdm());
donneesImpositionTfu.setBatimentExhonereOuiNon(donneesImpositionTfuResponse.getBatimentExhonereOuiNon());
donneesImpositionTfu.setUniteLogementExhonereOuiNon(donneesImpositionTfuResponse.getUniteLogementExhonereOuiNon());
try {
Optional<BaremRfuNonBati> baremRfuNonBatiOptional=baremRfuNonBatiRepository.findAllByCommune_IdAndZoneRfu_Id(impositionsTfu.getCommune().getId(),donneesImpositionTfu.getZoneRfuId());
if(baremRfuNonBatiOptional.isPresent()){
donneesImpositionTfu.setValeurAdministrativeParcelleNonBati(baremRfuNonBatiOptional.get().getValeurAdministrative());
donneesImpositionTfu.setTauxParcelleNonBati(baremRfuNonBatiOptional.get().getTaux());
}
ImpositionsTfu impositionsTfu = entityFromPayLoadService.getImpositionsTfuFromPayLoadWeb(impositionsTfuPaylaodWeb);
impositionsTfu.setStatusAvis(StatusAvis.TFU_FNB_GENERE);
impositionsTfu.setNombreAvisFnb(nb);
donneesImpositionTfuRepository.save(donneesImpositionTfu);
n++;
}catch (DataIntegrityViolationException e) {
if (e.getCause() instanceof org.hibernate.exception.ConstraintViolationException constraintEx &&
constraintEx.getSQLException().getSQLState().equals("23505")) {
System.out.println("Doublon détecté (clé unique) !");
} else {
throw e;
}
}
}
impositionsTfuRepository.save(impositionsTfu); impositionsTfuRepository.save(impositionsTfu);
return n;
return impositionsTfuRepository.findByIdToDto(impositionsTfu.getId()).orElse(null);
} }
@Override @Override
public List<DonneesImpositionTfu> getDonneesFiscalesByImposition(Long impositionsId) { @Transactional
return donneesImpositionTfuRepository.findAllByImpositionsTfu_Id(impositionsId); public ImpositionsTfuPaylaodWeb genererDonneesFiscalesParcelleBatie(ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb, Long userId) {
Integer nbb= donneesImpositionTfuRepository.genererDonneesTfuBatie(impositionsTfuPaylaodWeb.getId(),userId);
Integer nbulo= donneesImpositionTfuRepository.genererDonneesTfuBatieUniteLogement(impositionsTfuPaylaodWeb.getId(),userId);
// Integer nbirfbt= donneesImpositionTfuRepository.genererDonneesIrfBatie(impositionsTfuPaylaodWeb.getId(),userId);
//
// Integer nbirfulo= donneesImpositionTfuRepository.genererDonneesIrfBatieUniteLogement(impositionsTfuPaylaodWeb.getId(),userId);
//
// Integer nbsrtbbt= donneesImpositionTfuRepository.genererDonneesSrtbBatie(impositionsTfuPaylaodWeb.getId(),userId);
//
// Integer nbsrtbulo= donneesImpositionTfuRepository.genererDonneesSrtbBatieUniteLogement(impositionsTfuPaylaodWeb.getId(),userId);
ImpositionsTfu impositionsTfu = entityFromPayLoadService.getImpositionsTfuFromPayLoadWeb(impositionsTfuPaylaodWeb);
impositionsTfu.setStatusAvis(StatusAvis.GENERE);
impositionsTfu.setNombreAvis(nbb+nbulo+ (impositionsTfu.getNombreAvisFnb()==null?0:impositionsTfu.getNombreAvisFnb()));
impositionsTfu.setNombreAvisBatiment(nbb);
impositionsTfu.setNombreAvisUniteLog(nbulo);
impositionsTfuRepository.save(impositionsTfu);
return impositionsTfuRepository.findByIdToDto(impositionsTfu.getId()).orElse(null);
}
@Override
public List<DonneesImpositionPaylaodWeb> getDonneesFiscalesByImposition(Long impositionsId) {
return donneesImpositionTfuRepository.findAllByImpositionTfuId(impositionsId);
} }
@Override @Override
@@ -187,4 +152,59 @@ public class DonneesImpositionTfuServiceImpl implements DonneesImpositionTfuServ
return null; return null;
} }
} }
@Override
public Page<DonneesImpositionPaylaodWeb> getDonneesFiscalesByImpositionTfuIdPageable(Long impositionsTfuId, Pageable pageable) {
return donneesImpositionTfuRepository.findAllByImpositionTfuIdPageable(impositionsTfuId,pageable);
}
@Override
public Page<DonneesImpositionPaylaodWeb> getDonneesFiscalesByImpositionTfuIdNonBatiePageable(Long impositionsTfuId, Pageable pageable) {
return donneesImpositionTfuRepository.findAllByImpositionTfuIdNonBatiePageable(impositionsTfuId,pageable);
}
@Override
public Page<DonneesImpositionPaylaodWeb> getDonneesFiscalesByImpositionTfuIdBatieBatimentPageable(Long impositionsTfuId, Pageable pageable) {
return donneesImpositionTfuRepository.findAllByImpositionTfuIdBatieBatimentPageable(impositionsTfuId,pageable);
}
@Override
public Page<DonneesImpositionPaylaodWeb> getDonneesFiscalesByImpositionTfuIdBatieUniteLogPageable(Long impositionsTfuId, Pageable pageable) {
return donneesImpositionTfuRepository.findAllByImpositionTfuIdBatieUniteLogPageable(impositionsTfuId,pageable);
}
@Override
public Page<DonneesImpositionPaylaodWeb> getDonneesFiscalesByImpositionIrfIdBatieBatimentPageable(Long impositionsTfuId, Pageable pageable) {
return null;
}
@Override
public Page<DonneesImpositionPaylaodWeb> getDonneesFiscalesByImpositionIrfIdBatieUniteLogPageable(Long impositionsTfuId, Pageable pageable) {
return null;
}
@Override
public Page<DonneesImpositionPaylaodWeb> getDonneesFiscalesByImpositionSrtbIdBatieBatimentPageable(Long impositionsTfuId, Pageable pageable) {
return null;
}
@Override
public Page<DonneesImpositionPaylaodWeb> getDonneesFiscalesByImpositionSrtbIdBatieUniteLogPageable(Long impositionsTfuId, Pageable pageable) {
return null;
}
@Override
public Page<DonneesImpositionPaylaodWeb> getDonneesFiscalesByExerciceAndStructureIdPageable(Long exerciceId, Long structureId, Pageable pageable) {
return donneesImpositionTfuRepository.findAllByExericeIdStructureIdPageable(exerciceId,structureId,pageable);
}
@Override
public List<DonneesImpositionPaylaodWeb> getDonneesFiscalesByExerciceAndStructureId(Long exerciceId, Long structureId,Long quartierId) {
return donneesImpositionTfuRepository.findAllByExericeIdStructureId(exerciceId,structureId,quartierId);
}
@Override
public List<DonneesImpositionPaylaodWeb> getDonneesFiscalesByPersonneId(Long personneId) {
return donneesImpositionTfuRepository.findAllByPersonneId(personneId);
}
} }

View File

@@ -1,161 +1,129 @@
package io.gmss.fiscad.implementations.rfu.metier; package io.gmss.fiscad.implementations.rfu.metier;
import io.gmss.fiscad.entities.decoupage.Secteur;
import io.gmss.fiscad.entities.infocad.metier.Enquete; import io.gmss.fiscad.entities.infocad.metier.Enquete;
import io.gmss.fiscad.entities.infocad.metier.Upload; import io.gmss.fiscad.entities.infocad.metier.Upload;
import io.gmss.fiscad.entities.infocad.parametre.Personne; import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.rfu.metier.Batiment; import io.gmss.fiscad.entities.rfu.metier.Batiment;
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment; import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment;
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment; import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
import io.gmss.fiscad.enums.StatutEnquete;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
import io.gmss.fiscad.interfaces.rfu.metier.BatimentService; import io.gmss.fiscad.interfaces.rfu.metier.BatimentService;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService;
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService; import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService;
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
import io.gmss.fiscad.paylaods.request.crudweb.BaremRfuNonBatiPayloadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.BatimentPaylaodWeb;
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteBatimentPayloadWeb; import io.gmss.fiscad.paylaods.request.crudweb.EnqueteBatimentPayloadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository; import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository;
import io.gmss.fiscad.persistence.repositories.rfu.metier.BatimentRepository;
import io.gmss.fiscad.persistence.repositories.rfu.metier.EnqueteBatimentRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.EnqueteBatimentRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService; import io.gmss.fiscad.service.EntityFromPayLoadService;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.NotAcceptableException;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@AllArgsConstructor @AllArgsConstructor
@Service @Service
public class EnqueteBatimentServiceImpl implements EnqueteBatimentService { public class EnqueteBatimentServiceImpl implements EnqueteBatimentService {
private final EnqueteBatimentRepository enqueteBatimentRepository; private final EnqueteBatimentRepository enqueteBatimentRepository;
private final BatimentService batimentService;
private final EnqueteRepository enqueteRepository;
private final PersonneRepository personneRepository;
private final EntityFromPayLoadService entityFromPayLoadService; private final EntityFromPayLoadService entityFromPayLoadService;
private final CaracteristiqueBatimentService caracteristiqueBatimentService; private final BatimentRepository batimentRepository;
private final UploadRepository uploadRepository; private final BatimentService batimentService;
private final SecteurService secteurService;
@Override @Override
public EnqueteBatiment createEnqueteBatiment(EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) throws BadRequestException { @Transactional
public EnqueteBatimentPayloadWeb createEnqueteBatiment(EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) throws BadRequestException {
EnqueteBatiment enqueteBatiment=new EnqueteBatiment(); EnqueteBatiment enqueteBatiment=new EnqueteBatiment();
Batiment batiment=new Batiment();
Enquete enquete=new Enquete(); if(enqueteBatimentPayloadWeb.getBatimentId()!=null) {
if(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb().getId()==null){ if (!batimentRepository.existsById(enqueteBatimentPayloadWeb.getBatimentId())) {
batiment= batimentService.createBatiment(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb());//entityFromPayLoadService.getBatimentFromPayLoadWeb(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb())); throw new NotFoundException("Impossible d'enregistrer sans le batiment.");
}
}
BatimentPaylaodWeb batimentPaylaodWeb= getBatimentPayloadFromEnqueteBat(enqueteBatimentPayloadWeb);
if(batimentPaylaodWeb.getId()==null){
batimentPaylaodWeb=batimentService.createBatiment(batimentPaylaodWeb);
}else{ }else{
batiment= batimentService.updateBatiment(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb().getId(),enqueteBatimentPayloadWeb.getBatimentPaylaodWeb());//entityFromPayLoadService.getBatimentFromPayLoadWeb(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb())); batimentPaylaodWeb=batimentService.updateBatiment(batimentPaylaodWeb.getId(),batimentPaylaodWeb);
} }
if(enqueteBatimentPayloadWeb.getEnqueteId()==null){ enqueteBatimentPayloadWeb.setBatimentId(batimentPaylaodWeb.getId());
throw new BadRequestException("Impossible de poursuivre l'enregistrement sans la précision de l'enquête");
}
Optional<Personne> optionalPersonne=Optional.empty();
if(enqueteBatimentPayloadWeb.getPersonneId()!=null){
optionalPersonne=personneRepository.findById(enqueteBatimentPayloadWeb.getPersonneId());
}
enqueteBatiment = entityFromPayLoadService.getEnqueteBatimentFromPayLoadWeb(enqueteBatimentPayloadWeb);
Optional<Enquete> optionalEnquete = enqueteRepository.findById(enqueteBatimentPayloadWeb.getEnqueteId());
enqueteBatiment.setEnquete(optionalEnquete.orElse(null));
enqueteBatiment.setBatiment(batiment);
enqueteBatiment.setPersonne(optionalPersonne.orElse(null));
enqueteBatiment.setAutreCaracteristiquePhysique(enqueteBatimentPayloadWeb.getAutreCaracteristiquePhysique());
enqueteBatiment.setAutreMur(enqueteBatimentPayloadWeb.getAutreMur());
enqueteBatiment.setAutreMenuisierie(enqueteBatimentPayloadWeb.getAutreMenuisierie());
enqueteBatiment.setDateDebutExcemption(enqueteBatimentPayloadWeb.getDateDebutExcemption());
enqueteBatiment.setDateFinExcemption(enqueteBatimentPayloadWeb.getDateFinExcemption());
enqueteBatiment.setNbreHabitant(enqueteBatimentPayloadWeb.getNbreHabitant());
enqueteBatiment.setNbreLotUnite(enqueteBatimentPayloadWeb.getNbreLotUnite());
enqueteBatiment.setNbreMenage(enqueteBatimentPayloadWeb.getNbreMenage());
enqueteBatiment.setNbreMoisLocation(enqueteBatimentPayloadWeb.getNbreMoisLocation());
enqueteBatiment.setNbreUniteLocation(enqueteBatimentPayloadWeb.getNbreUniteLocation());
enqueteBatiment.setNumCompteurSbee(enqueteBatimentPayloadWeb.getNumCompteurSbee());
enqueteBatiment.setNumCompteurSoneb(enqueteBatimentPayloadWeb.getNumCompteurSoneb());
enqueteBatiment.setSbee(enqueteBatimentPayloadWeb.isSbee());
enqueteBatiment.setSoneb(enqueteBatimentPayloadWeb.isSoneb());
enqueteBatiment.setSurfaceAuSol(enqueteBatimentPayloadWeb.getSurfaceAuSol());
enqueteBatiment.setSurfaceLouee(enqueteBatimentPayloadWeb.getSurfaceLouee());
enqueteBatiment.setMontantMensuelLocation(enqueteBatimentPayloadWeb.getMontantMensuelLocation());
enqueteBatiment.setValeurBatimentReel(enqueteBatimentPayloadWeb.getValeurBatimentReel());
enqueteBatiment.setValeurBatimentEstime(enqueteBatimentPayloadWeb.getValeurBatimentEstime());
enqueteBatiment.setMontantLocatifAnnuelDeclare(enqueteBatimentPayloadWeb.getMontantLocatifAnnuelDeclare());
enqueteBatiment.setNbreEtage(enqueteBatimentPayloadWeb.getNbreEtage());
enqueteBatiment= enqueteBatimentRepository.save(enqueteBatiment); enqueteBatiment= enqueteBatimentRepository.save(enqueteBatiment);
enqueteBatimentPayloadWeb= enqueteBatimentRepository.findEnqueteBatimentByIdToDto(enqueteBatiment.getId()).orElse(null);
return enqueteBatimentPayloadWeb ;
}
//////Enregistrement des caractéristiques batiment private BatimentPaylaodWeb getBatimentPayloadFromEnqueteBat(EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) {
Long enqueteBatimentId = enqueteBatiment.getId(); BatimentPaylaodWeb batimentPaylaodWeb= new BatimentPaylaodWeb();
enqueteBatimentPayloadWeb.getCaracteristiqueBatimentPayloadWebs().forEach(caracteristiqueBatimentPayloadWeb -> { batimentPaylaodWeb.setId(enqueteBatimentPayloadWeb.getBatimentId());
caracteristiqueBatimentPayloadWeb.setEnqueteBatimentId(enqueteBatimentId); batimentPaylaodWeb.setNub(enqueteBatimentPayloadWeb.getNub());
CaracteristiqueBatiment caracteristiqueBatiment=entityFromPayLoadService.getCaracteristiqueBatimentFromPayLoadWeb(caracteristiqueBatimentPayloadWeb); batimentPaylaodWeb.setCode(enqueteBatimentPayloadWeb.getCode());
caracteristiqueBatimentService.createCaracteristiqueBatiment(caracteristiqueBatiment); batimentPaylaodWeb.setDateConstruction(enqueteBatimentPayloadWeb.getDateConstruction());
}); batimentPaylaodWeb.setParcelleId(enqueteBatimentPayloadWeb.getParcelleId());
batimentPaylaodWeb.setPersonneId(enqueteBatimentPayloadWeb.getPersonneId());
EnqueteBatiment finalEnqueteBatiment = enqueteBatiment; batimentPaylaodWeb.setSuperficieAuSol(enqueteBatimentPayloadWeb.getSuperficieAuSol());
enqueteBatimentPayloadWeb.getUploadPayLoadWebs().forEach(uploadPayLoadWeb -> { batimentPaylaodWeb.setSuperficieLouee(enqueteBatimentPayloadWeb.getSuperficieLouee());
optionalEnquete.ifPresent(value -> uploadPayLoadWeb.setEnqueteId(value.getId())); batimentPaylaodWeb.setCategorieBatimentId(enqueteBatimentPayloadWeb.getCategorieBatimentId());
Upload upload=entityFromPayLoadService.getUploadFromPayLoadWeb(uploadPayLoadWeb); batimentPaylaodWeb.setNombrePiscine(enqueteBatimentPayloadWeb.getNombrePiscine());
upload.setEnqueteBatiment(finalEnqueteBatiment); batimentPaylaodWeb.setMontantLocatifAnnuelDeclare(enqueteBatimentPayloadWeb.getMontantLocatifAnnuelDeclare());
uploadRepository.save(upload); batimentPaylaodWeb.setMontantLocatifAnnuelEstime(enqueteBatimentPayloadWeb.getMontantLocatifAnnuelEstime());
}); batimentPaylaodWeb.setValeurBatimentEstime(enqueteBatimentPayloadWeb.getValeurBatimentEstime());
batimentPaylaodWeb.setValeurBatimentReel(enqueteBatimentPayloadWeb.getValeurBatimentReel());
return enqueteBatiment ; batimentPaylaodWeb.setMontantMensuelLocation(enqueteBatimentPayloadWeb.getMontantMensuelLocation());
batimentPaylaodWeb.setUsageId(enqueteBatimentPayloadWeb.getUsageId());
batimentPaylaodWeb.setNbreUniteLogement(enqueteBatimentPayloadWeb.getNbreUniteLogement());
return batimentPaylaodWeb;
} }
@Override @Override
public EnqueteBatiment updateEnqueteBatiment(Long id, EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) throws NotFoundException { @Transactional
public EnqueteBatimentPayloadWeb updateEnqueteBatiment(Long id, EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) throws NotFoundException {
if (enqueteBatimentPayloadWeb.getId() == null) { if (enqueteBatimentPayloadWeb.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle enquete de batiment ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle enquete de batiment ayant un id null.");
} }
if (!enqueteBatimentRepository.existsById(enqueteBatimentPayloadWeb.getId())) { if (!enqueteBatimentRepository.existsById(enqueteBatimentPayloadWeb.getId())) {
throw new NotFoundException("Impossible de trouver la nouvelle enquete de batiment spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la nouvelle enquete de batiment spécifiée dans notre base de données.");
} }
if(enqueteBatimentPayloadWeb.getEnqueteId()==null){ if (!batimentRepository.existsById(enqueteBatimentPayloadWeb.getBatimentId())) {
throw new BadRequestException("Impossible de poursuivre l'enregistrement sans la précision de l'enquête"); throw new NotFoundException("Impossible d'enregistrer sans le batiment.");
} }
Optional<Enquete> optionalEnquete = enqueteRepository.findById(enqueteBatimentPayloadWeb.getEnqueteId());
EnqueteBatiment enqueteBatiment=new EnqueteBatiment(); BatimentPaylaodWeb batimentPaylaodWeb= getBatimentPayloadFromEnqueteBat(enqueteBatimentPayloadWeb);
Batiment batiment=new Batiment();
if(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb().getId()==null){ if(batimentPaylaodWeb.getId()==null){
batiment= batimentService.createBatiment(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb());//entityFromPayLoadService.getBatimentFromPayLoadWeb(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb())); batimentPaylaodWeb=batimentService.createBatiment(batimentPaylaodWeb);
}else{ }else{
batiment= batimentService.updateBatiment(id,enqueteBatimentPayloadWeb.getBatimentPaylaodWeb());//entityFromPayLoadService.getBatimentFromPayLoadWeb(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb())); batimentPaylaodWeb=batimentService.updateBatiment(batimentPaylaodWeb.getId(),batimentPaylaodWeb);
} }
enqueteBatimentPayloadWeb.setBatimentId(batimentPaylaodWeb.getId());
Optional<Personne> optionalPersonne=Optional.empty();
if(enqueteBatimentPayloadWeb.getPersonneId()!=null){ EnqueteBatiment enqueteBatiment = entityFromPayLoadService.getEnqueteBatimentFromPayLoadWeb(enqueteBatimentPayloadWeb);
optionalPersonne=personneRepository.findById(enqueteBatimentPayloadWeb.getPersonneId());
}
enqueteBatiment.setEnquete(optionalEnquete.orElse(null));
enqueteBatiment.setBatiment(batiment);
enqueteBatiment.setPersonne(optionalPersonne.orElse(null));
enqueteBatiment.setAutreCaracteristiquePhysique(enqueteBatimentPayloadWeb.getAutreCaracteristiquePhysique());
enqueteBatiment.setAutreMur(enqueteBatimentPayloadWeb.getAutreMur());
enqueteBatiment.setAutreMenuisierie(enqueteBatimentPayloadWeb.getAutreMenuisierie());
enqueteBatiment.setDateDebutExcemption(enqueteBatimentPayloadWeb.getDateDebutExcemption());
enqueteBatiment.setDateFinExcemption(enqueteBatimentPayloadWeb.getDateFinExcemption());
enqueteBatiment.setNbreHabitant(enqueteBatimentPayloadWeb.getNbreHabitant());
enqueteBatiment.setNbreLotUnite(enqueteBatimentPayloadWeb.getNbreLotUnite());
enqueteBatiment.setNbreMenage(enqueteBatimentPayloadWeb.getNbreMenage());
enqueteBatiment.setNbreMoisLocation(enqueteBatimentPayloadWeb.getNbreMoisLocation());
enqueteBatiment.setNbreUniteLocation(enqueteBatimentPayloadWeb.getNbreUniteLocation());
enqueteBatiment.setNumCompteurSbee(enqueteBatimentPayloadWeb.getNumCompteurSbee());
enqueteBatiment.setNumCompteurSoneb(enqueteBatimentPayloadWeb.getNumCompteurSoneb());
enqueteBatiment.setSbee(enqueteBatimentPayloadWeb.isSbee());
enqueteBatiment.setSoneb(enqueteBatimentPayloadWeb.isSoneb());
enqueteBatiment.setSurfaceAuSol(enqueteBatimentPayloadWeb.getSurfaceAuSol());
enqueteBatiment.setSurfaceLouee(enqueteBatimentPayloadWeb.getSurfaceLouee());
enqueteBatiment.setMontantMensuelLocation(enqueteBatimentPayloadWeb.getMontantMensuelLocation());
enqueteBatiment.setValeurBatimentReel(enqueteBatimentPayloadWeb.getValeurBatimentReel());
enqueteBatiment.setValeurBatimentEstime(enqueteBatimentPayloadWeb.getValeurBatimentEstime());
enqueteBatiment.setMontantLocatifAnnuelDeclare(enqueteBatimentPayloadWeb.getMontantLocatifAnnuelDeclare());
enqueteBatiment= enqueteBatimentRepository.save(enqueteBatiment); enqueteBatiment= enqueteBatimentRepository.save(enqueteBatiment);
return enqueteBatimentRepository.save(enqueteBatiment); enqueteBatimentPayloadWeb= enqueteBatimentRepository.findEnqueteBatimentByIdToDto(enqueteBatiment.getId()).orElse(null);
return enqueteBatimentPayloadWeb ;
} }
@Override @Override
@@ -169,23 +137,113 @@ public class EnqueteBatimentServiceImpl implements EnqueteBatimentService {
} }
@Override @Override
public Page<EnqueteBatiment> getEnqueteBatimentList(Pageable pageable) { public Page<EnqueteBatimentPayloadWeb> getEnqueteBatimentList(Pageable pageable) {
return enqueteBatimentRepository.findAll(pageable); return enqueteBatimentRepository.findAllEnqueteBatimentToDtoPageable(pageable);
} }
@Override @Override
public List<EnqueteBatiment> getEnqueteBatimentList() { public List<EnqueteBatimentPayloadWeb> getEnqueteBatimentList() {
return enqueteBatimentRepository.findAll(); return enqueteBatimentRepository.findAllEnqueteBatimentToDto();
} }
@Override @Override
public Optional<EnqueteBatiment> getEnqueteBatimentById(Long id) { public Optional<EnqueteBatimentPayloadWeb> getEnqueteBatimentById(Long id) {
if (enqueteBatimentRepository.existsById(id)) { if (enqueteBatimentRepository.existsById(id)) {
return enqueteBatimentRepository.findById(id); return enqueteBatimentRepository.findEnqueteBatimentByIdToDto(id);
} else { } else {
throw new NotFoundException("Impossible de trouver la nouvelle enquete de batiment spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la nouvelle enquete de batiment spécifiée dans la base de données.");
} }
} }
@Override
public Page<EnqueteBatimentPayloadWeb> getEnqueteBatimentByBatimentListPageable(Long batimentId, Pageable pageable) {
return enqueteBatimentRepository.findAllByBatimentToDtoPageable(batimentId,pageable);
}
@Override
public List<EnqueteBatimentPayloadWeb> getEnqueteBatimentByBatimentList(Long batimentId) {
return enqueteBatimentRepository.findAllByBatimentToDto(batimentId);
}
@Override
public Page<EnqueteBatimentPayloadWeb> getEnqueteBatimentListByQuartierByStatutPageableToDto(Long userId, Long quartierId, StatutEnquete statutEnquete, Pageable pageable) {
List<Secteur> secteurs= secteurService.getListSecteurUserId(userId);
List<Long> secteurIds = secteurs.stream()
.map(Secteur::getId)
.toList();
return enqueteBatimentRepository.findAllEnqueteBatimentByQuartierByStatutToDtoPageable(quartierId,secteurIds,statutEnquete,pageable);
}
@Override
public EnqueteBatimentPayloadWeb validerEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
if (enqueteTraitementPayLoad == null || enqueteTraitementPayLoad.getIdBackend()==null) {
throw new BadRequestException("Impossible de valider une enquête ayant un id null.");
}
Optional<EnqueteBatiment> optionalEnqueteBatiment = enqueteBatimentRepository.findById(enqueteTraitementPayLoad.getIdBackend());
if (!optionalEnqueteBatiment.isPresent()) {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez valider.");
}
if(optionalEnqueteBatiment.get().getStatutEnquete()==StatutEnquete.CLOTURE ||
optionalEnqueteBatiment.get().getStatutEnquete()==StatutEnquete.REJETE ){
throw new NotAcceptableException("Impossible de valider : Le statut actuel "+optionalEnqueteBatiment.get().getStatutEnquete()+" ne le permet pas.");
}
EnqueteBatiment enqueteBatiment = optionalEnqueteBatiment.get();
enqueteBatiment.setDateValidation(LocalDate.now());
enqueteBatiment.setStatutEnquete(StatutEnquete.VALIDE);
enqueteBatiment= enqueteBatimentRepository.save(enqueteBatiment);
return enqueteBatimentRepository.findEnqueteBatimentByIdToDto(enqueteBatiment.getId()).orElse(null);
}
@Override
public EnqueteBatimentPayloadWeb rejeterEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
if (enqueteTraitementPayLoad == null || enqueteTraitementPayLoad.getIdBackend()==null) {
throw new BadRequestException("Impossible de rejeter une enquête ayant un id null.");
}
Optional<EnqueteBatiment> optionalEnqueteBatiment = enqueteBatimentRepository.findById(enqueteTraitementPayLoad.getIdBackend());
if (!optionalEnqueteBatiment.isPresent()) {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez rejeter.");
}
if(optionalEnqueteBatiment.get().getStatutEnquete()==StatutEnquete.CLOTURE ||
optionalEnqueteBatiment.get().getStatutEnquete()==StatutEnquete.VALIDE ){
throw new NotAcceptableException("Impossible de rejeter : Le statut actuel "+optionalEnqueteBatiment.get().getStatutEnquete()+" ne le permet pas.");
}
EnqueteBatiment enqueteBatiment = optionalEnqueteBatiment.get();
enqueteBatiment.setDateRejet(LocalDate.now());
enqueteBatiment.setDescriptionMotifRejet(enqueteTraitementPayLoad.getMotifRejet());
enqueteBatiment.setStatutEnquete(StatutEnquete.REJETE);
enqueteBatiment= enqueteBatimentRepository.save(enqueteBatiment);
return enqueteBatimentRepository.findEnqueteBatimentByIdToDto(enqueteBatiment.getId()).orElse(null);
}
@Override
public List<EnqueteBatimentPayloadWeb> validerEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
List<EnqueteBatimentPayloadWeb> enqueteBatimentPayloadWebs = new ArrayList<>();
try {
for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) {
enqueteBatimentPayloadWebs.add(validerEnquete(enqueteTraitementPayLoad));
}
} catch (Exception e) {
enqueteBatimentPayloadWebs.add(null);
}
return enqueteBatimentPayloadWebs;
}
@Override
public List<EnqueteBatimentPayloadWeb> rejeterEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
List<EnqueteBatimentPayloadWeb> enqueteBatimentPayloadWebs = new ArrayList<>();
try {
for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) {
enqueteBatimentPayloadWebs.add(rejeterEnquete(enqueteTraitementPayLoad));
}
} catch (Exception e) {
enqueteBatimentPayloadWebs.add(null);
}
return enqueteBatimentPayloadWebs;
}
} }

View File

@@ -1,25 +1,36 @@
package io.gmss.fiscad.implementations.rfu.metier; package io.gmss.fiscad.implementations.rfu.metier;
import io.gmss.fiscad.entities.decoupage.Secteur;
import io.gmss.fiscad.entities.infocad.metier.Enquete; import io.gmss.fiscad.entities.infocad.metier.Enquete;
import io.gmss.fiscad.entities.infocad.metier.Upload; import io.gmss.fiscad.entities.infocad.metier.Upload;
import io.gmss.fiscad.entities.infocad.parametre.Personne; import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.rfu.metier.*; import io.gmss.fiscad.entities.rfu.metier.*;
import io.gmss.fiscad.enums.StatutEnquete;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService;
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteUniteLogementService; import io.gmss.fiscad.interfaces.rfu.metier.EnqueteUniteLogementService;
import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService; import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService;
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteBatimentPayloadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteUniteLogementPayloadWeb; import io.gmss.fiscad.paylaods.request.crudweb.EnqueteUniteLogementPayloadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository; import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository;
import io.gmss.fiscad.persistence.repositories.rfu.metier.EnqueteUniteLogementRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.EnqueteUniteLogementRepository;
import io.gmss.fiscad.persistence.repositories.rfu.metier.UniteLogementRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService; import io.gmss.fiscad.service.EntityFromPayLoadService;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.NotAcceptableException;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@AllArgsConstructor @AllArgsConstructor
@@ -27,80 +38,66 @@ import java.util.Optional;
public class EnqueteUniteLogementServiceImpl implements EnqueteUniteLogementService { public class EnqueteUniteLogementServiceImpl implements EnqueteUniteLogementService {
private final EnqueteUniteLogementRepository enqueteUniteLogementRepository; private final EnqueteUniteLogementRepository enqueteUniteLogementRepository;
private final UniteLogementService uniteLogementService;
private final EntityFromPayLoadService entityFromPayLoadService ; private final EntityFromPayLoadService entityFromPayLoadService ;
private final PersonneRepository personneRepository ; private final UniteLogementRepository uniteLogementRepository ;
private final EnqueteRepository enqueteRepository ; private final UniteLogementService uniteLogementService ;
private final UploadRepository uploadRepository ; private final SecteurService secteurService ;
private final CaracteristiqueUniteLogementService caracteristiqueUniteLogementService ;
@Transactional
@Override @Override
public EnqueteUniteLogement createEnqueteUniteLogement(EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) throws BadRequestException { public EnqueteUniteLogementPayloadWeb createEnqueteUniteLogement(EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) throws BadRequestException {
EnqueteUniteLogement enqueteUniteLogement=new EnqueteUniteLogement(); EnqueteUniteLogement enqueteUniteLogement=new EnqueteUniteLogement();
UniteLogement uniteLogement=new UniteLogement(); Optional<UniteLogement> optionalUniteLogement= Optional.empty();
Enquete enquete=new Enquete();
if(enqueteUniteLogementPayloadWeb.getUniteLogementPaylaodWeb().getId()==null){ if(enqueteUniteLogementPayloadWeb.getUniteLogementId()!=null) {
uniteLogement = uniteLogementService.createUniteLogement(entityFromPayLoadService.getUniteLogementFromPayLoadWeb(enqueteUniteLogementPayloadWeb.getUniteLogementPaylaodWeb())); if (!uniteLogementRepository.existsById(enqueteUniteLogementPayloadWeb.getUniteLogementId())) {
throw new NotFoundException("Unité de logement inexistant.");
}
}
UniteLogementPaylaodWeb uniteLogementPaylaodWeb=getUniteLogementPayloadFromEnqueteUl(enqueteUniteLogementPayloadWeb);
if(uniteLogementPaylaodWeb.getId()==null){
uniteLogementPaylaodWeb= uniteLogementService.createUniteLogement(uniteLogementPaylaodWeb);
}else{ }else{
uniteLogement = uniteLogementService.updateUniteLogement(enqueteUniteLogementPayloadWeb.getUniteLogementPaylaodWeb().getId(),entityFromPayLoadService.getUniteLogementFromPayLoadWeb(enqueteUniteLogementPayloadWeb.getUniteLogementPaylaodWeb())); uniteLogementPaylaodWeb= uniteLogementService.updateUniteLogement(uniteLogementPaylaodWeb.getId(),uniteLogementPaylaodWeb);
} }
enqueteUniteLogementPayloadWeb.setUniteLogementId(uniteLogementPaylaodWeb.getId());
if(enqueteUniteLogementPayloadWeb.getEnqueteId()==null){ enqueteUniteLogement = entityFromPayLoadService.getEnqueteUniteLogementFromPayLoadWeb(enqueteUniteLogementPayloadWeb);
throw new BadRequestException("Impossible de poursuivre l'enregistrement sans la précision de l'enquête");
}
Optional<Personne> optionalPersonne=Optional.empty();
if(enqueteUniteLogementPayloadWeb.getPersonneId()!=null){
optionalPersonne=personneRepository.findById(enqueteUniteLogementPayloadWeb.getPersonneId());
}
Optional<Enquete> optionalEnquete = enqueteRepository.findById(enqueteUniteLogementPayloadWeb.getEnqueteId());
enqueteUniteLogement.setEnquete(optionalEnquete.orElse(null));
enqueteUniteLogement.setUniteLogement(uniteLogement);
enqueteUniteLogement.setPersonne(optionalPersonne.orElse(null));
enqueteUniteLogement.setEnLocation(enqueteUniteLogementPayloadWeb.isEnLocation());
enqueteUniteLogement.setDateDebutExcemption(enqueteUniteLogementPayloadWeb.getDateDebutExcemption());
enqueteUniteLogement.setDateFinExcemption(enqueteUniteLogementPayloadWeb.getDateFinExcemption());
enqueteUniteLogement.setNbreHabitant(enqueteUniteLogementPayloadWeb.getNbreHabitant());
enqueteUniteLogement.setNbreMenage(enqueteUniteLogementPayloadWeb.getNbreMenage());
enqueteUniteLogement.setNbreMoisLocation(enqueteUniteLogementPayloadWeb.getNbreMoisLocation());
enqueteUniteLogement.setNumCompteurSbee(enqueteUniteLogementPayloadWeb.getNumCompteurSbee());
enqueteUniteLogement.setNumCompteurSoneb(enqueteUniteLogementPayloadWeb.getNumCompteurSoneb());
enqueteUniteLogement.setSbee(enqueteUniteLogementPayloadWeb.isSbee());
enqueteUniteLogement.setSoneb(enqueteUniteLogementPayloadWeb.isSoneb());
enqueteUniteLogement.setSurfaceAuSol(enqueteUniteLogementPayloadWeb.getSurfaceAuSol());
enqueteUniteLogement.setSurfaceLouee(enqueteUniteLogementPayloadWeb.getSurfaceLouee());
enqueteUniteLogement.setValeurUniteLogementEstime(enqueteUniteLogementPayloadWeb.getValeurUniteLogementEstime());
enqueteUniteLogement.setValeurUniteLogementReel(enqueteUniteLogementPayloadWeb.getValeurUniteLogementReel());
enqueteUniteLogement.setMontantLocatifAnnuelDeclare(enqueteUniteLogementPayloadWeb.getMontantLocatifAnnuelDeclare());
enqueteUniteLogement.setMontantMensuelLoyer(enqueteUniteLogementPayloadWeb.getMontantMensuelLoyer());
enqueteUniteLogement= enqueteUniteLogementRepository.save(enqueteUniteLogement); enqueteUniteLogement= enqueteUniteLogementRepository.save(enqueteUniteLogement);
enqueteUniteLogementPayloadWeb = enqueteUniteLogementRepository.findEnqueteUniteLogementToDto(enqueteUniteLogement.getId()).orElse(null);
return enqueteUniteLogementPayloadWeb ;
}
//////Enregistrement des caractéristiques batiment private UniteLogementPaylaodWeb getUniteLogementPayloadFromEnqueteUl(EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) {
Long enqueteUniteLogementId = enqueteUniteLogement.getId(); UniteLogementPaylaodWeb uniteLogementPaylaodWeb=new UniteLogementPaylaodWeb();
enqueteUniteLogementPayloadWeb.getCaracteristiqueUniteLogementPayloadWebs().forEach(caracteristiqueUniteLogementPayloadWeb -> { uniteLogementPaylaodWeb.setId(enqueteUniteLogementPayloadWeb.getUniteLogementId());
caracteristiqueUniteLogementPayloadWeb.setEnqueteUniteLogementId(enqueteUniteLogementId); uniteLogementPaylaodWeb.setNul(enqueteUniteLogementPayloadWeb.getNul());
CaracteristiqueUniteLogement caracteristiqueUniteLogement=entityFromPayLoadService.getCaracteristiqueUniteLogementFromPayLoadWeb(caracteristiqueUniteLogementPayloadWeb); uniteLogementPaylaodWeb.setNumeroEtage(enqueteUniteLogementPayloadWeb.getNumeroEtage());
caracteristiqueUniteLogementService.createCaracteristiqueUniteLogement(caracteristiqueUniteLogement); uniteLogementPaylaodWeb.setCode(enqueteUniteLogementPayloadWeb.getCode());
}); uniteLogementPaylaodWeb.setBatimentId(enqueteUniteLogementPayloadWeb.getBatimentId());
uniteLogementPaylaodWeb.setSuperficieAuSol(enqueteUniteLogementPayloadWeb.getSuperficieAuSol());
///////Enregistrement des pieces uniteLogementPaylaodWeb.setSuperficieLouee(enqueteUniteLogementPayloadWeb.getSuperficieLouee());
EnqueteUniteLogement finalEnqueteUniteLogement = enqueteUniteLogement; uniteLogementPaylaodWeb.setObservation(enqueteUniteLogementPayloadWeb.getObservation());
enqueteUniteLogementPayloadWeb.getUploadPayLoadWebs().forEach(uploadPayLoadWeb -> { uniteLogementPaylaodWeb.setDateConstruction(enqueteUniteLogementPayloadWeb.getDateConstruction());
optionalEnquete.ifPresent(value -> uploadPayLoadWeb.setEnqueteId(value.getId())); uniteLogementPaylaodWeb.setPersonneId(enqueteUniteLogementPayloadWeb.getPersonneId());
Upload upload=entityFromPayLoadService.getUploadFromPayLoadWeb(uploadPayLoadWeb); uniteLogementPaylaodWeb.setCategorieBatimentId(enqueteUniteLogementPayloadWeb.getCategorieBatimentId());
upload.setEnqueteUniteLogement(finalEnqueteUniteLogement); uniteLogementPaylaodWeb.setMontantLocatifAnnuelDeclare(enqueteUniteLogementPayloadWeb.getMontantLocatifAnnuelDeclare());
uploadRepository.save(upload); uniteLogementPaylaodWeb.setMontantLocatifAnnuelEstime(enqueteUniteLogementPayloadWeb.getMontantLocatifAnnuelEstime());
}); uniteLogementPaylaodWeb.setMontantMensuelLocation(enqueteUniteLogementPayloadWeb.getMontantMensuelLocation());
uniteLogementPaylaodWeb.setValeurUniteLogementReel(enqueteUniteLogementPayloadWeb.getValeurUniteLogementReel());
return enqueteUniteLogement ; uniteLogementPaylaodWeb.setValeurUniteLogementEstime(enqueteUniteLogementPayloadWeb.getValeurUniteLogementEstime());
uniteLogementPaylaodWeb.setNombrePiscine(enqueteUniteLogementPayloadWeb.getNombrePiscine());
uniteLogementPaylaodWeb.setUsageId(enqueteUniteLogementPayloadWeb.getUsageId());
return uniteLogementPaylaodWeb;
} }
@Override @Override
public EnqueteUniteLogement updateEnqueteUniteLogement(Long id, EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) throws NotFoundException { @Transactional
public EnqueteUniteLogementPayloadWeb updateEnqueteUniteLogement(Long id, EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) throws NotFoundException {
if (enqueteUniteLogementPayloadWeb.getId() == null) { if (enqueteUniteLogementPayloadWeb.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle enquete d'unité de logement ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle enquete d'unité de logement ayant un id null.");
} }
@@ -108,46 +105,27 @@ public class EnqueteUniteLogementServiceImpl implements EnqueteUniteLogementServ
if (!enqueteUniteLogementRepository.existsById(enqueteUniteLogementPayloadWeb.getId())) { if (!enqueteUniteLogementRepository.existsById(enqueteUniteLogementPayloadWeb.getId())) {
throw new NotFoundException("Impossible de trouver la nouvelle enquete d'unité de logement spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la nouvelle enquete d'unité de logement spécifiée dans notre base de données.");
} }
if (!uniteLogementRepository.existsById(enqueteUniteLogementPayloadWeb.getUniteLogementId())) {
throw new NotFoundException("Impossible de poursuivre l'enregistement, unite de logement nom précisée");
}
EnqueteUniteLogement enqueteUniteLogement= new EnqueteUniteLogement(); EnqueteUniteLogement enqueteUniteLogement= new EnqueteUniteLogement();
UniteLogement uniteLogement= new UniteLogement();
if(enqueteUniteLogementPayloadWeb.getUniteLogementPaylaodWeb().getId()==null){ UniteLogementPaylaodWeb uniteLogementPaylaodWeb=getUniteLogementPayloadFromEnqueteUl(enqueteUniteLogementPayloadWeb);
uniteLogement = uniteLogementService.createUniteLogement(entityFromPayLoadService.getUniteLogementFromPayLoadWeb(enqueteUniteLogementPayloadWeb.getUniteLogementPaylaodWeb()));
if(uniteLogementPaylaodWeb.getId()==null){
uniteLogementPaylaodWeb= uniteLogementService.createUniteLogement(uniteLogementPaylaodWeb);
}else{ }else{
uniteLogement = uniteLogementService.updateUniteLogement(enqueteUniteLogementPayloadWeb.getUniteLogementPaylaodWeb().getId(),entityFromPayLoadService.getUniteLogementFromPayLoadWeb(enqueteUniteLogementPayloadWeb.getUniteLogementPaylaodWeb())); uniteLogementPaylaodWeb= uniteLogementService.updateUniteLogement(uniteLogementPaylaodWeb.getId(),uniteLogementPaylaodWeb);
} }
enqueteUniteLogementPayloadWeb.setUniteLogementId(uniteLogementPaylaodWeb.getId());
if(enqueteUniteLogementPayloadWeb.getEnqueteId()==null){
throw new BadRequestException("Impossible de poursuivre l'enregistrement sans la précision de l'enquête");
}
Optional<Personne> optionalPersonne=Optional.empty(); enqueteUniteLogement = entityFromPayLoadService.getEnqueteUniteLogementFromPayLoadWeb(enqueteUniteLogementPayloadWeb);
if(enqueteUniteLogementPayloadWeb.getPersonneId()!=null){
optionalPersonne=personneRepository.findById(enqueteUniteLogementPayloadWeb.getPersonneId());
}
Optional<Enquete> optionalEnquete = enqueteRepository.findById(enqueteUniteLogementPayloadWeb.getEnqueteId());
enqueteUniteLogement.setEnquete(optionalEnquete.orElse(null));
enqueteUniteLogement.setUniteLogement(uniteLogement);
enqueteUniteLogement.setPersonne(optionalPersonne.orElse(null));
enqueteUniteLogement.setEnLocation(enqueteUniteLogementPayloadWeb.isEnLocation());
enqueteUniteLogement.setDateDebutExcemption(enqueteUniteLogementPayloadWeb.getDateDebutExcemption());
enqueteUniteLogement.setDateFinExcemption(enqueteUniteLogementPayloadWeb.getDateFinExcemption());
enqueteUniteLogement.setNbreHabitant(enqueteUniteLogementPayloadWeb.getNbreHabitant());
enqueteUniteLogement.setNbreMenage(enqueteUniteLogementPayloadWeb.getNbreMenage());
enqueteUniteLogement.setNbreMoisLocation(enqueteUniteLogementPayloadWeb.getNbreMoisLocation());
enqueteUniteLogement.setNumCompteurSbee(enqueteUniteLogementPayloadWeb.getNumCompteurSbee());
enqueteUniteLogement.setNumCompteurSoneb(enqueteUniteLogementPayloadWeb.getNumCompteurSoneb());
enqueteUniteLogement.setSbee(enqueteUniteLogementPayloadWeb.isSbee());
enqueteUniteLogement.setSoneb(enqueteUniteLogementPayloadWeb.isSoneb());
enqueteUniteLogement.setSurfaceAuSol(enqueteUniteLogementPayloadWeb.getSurfaceAuSol());
enqueteUniteLogement.setSurfaceLouee(enqueteUniteLogementPayloadWeb.getSurfaceLouee());
enqueteUniteLogement.setValeurUniteLogementEstime(enqueteUniteLogementPayloadWeb.getValeurUniteLogementEstime());
enqueteUniteLogement.setValeurUniteLogementReel(enqueteUniteLogementPayloadWeb.getValeurUniteLogementReel());
enqueteUniteLogement.setMontantLocatifAnnuelDeclare(enqueteUniteLogementPayloadWeb.getMontantLocatifAnnuelDeclare());
enqueteUniteLogement.setMontantMensuelLoyer(enqueteUniteLogementPayloadWeb.getMontantMensuelLoyer());
enqueteUniteLogement= enqueteUniteLogementRepository.save(enqueteUniteLogement); enqueteUniteLogement= enqueteUniteLogementRepository.save(enqueteUniteLogement);
return enqueteUniteLogement; enqueteUniteLogementPayloadWeb = enqueteUniteLogementRepository.findEnqueteUniteLogementToDto(enqueteUniteLogement.getId()).orElse(null);
return enqueteUniteLogementPayloadWeb ;
} }
@Override @Override
@@ -161,23 +139,113 @@ public class EnqueteUniteLogementServiceImpl implements EnqueteUniteLogementServ
} }
@Override @Override
public Page<EnqueteUniteLogement> getEnqueteUniteLogementList(Pageable pageable) { public Page<EnqueteUniteLogementPayloadWeb> getEnqueteUniteLogementList(Pageable pageable) {
return enqueteUniteLogementRepository.findAll(pageable); return enqueteUniteLogementRepository.findAllEnqueteUniteLogementToDtoPageable(pageable);
} }
@Override @Override
public List<EnqueteUniteLogement> getEnqueteUniteLogementList() { public List<EnqueteUniteLogementPayloadWeb> getEnqueteUniteLogementList() {
return enqueteUniteLogementRepository.findAll(); return enqueteUniteLogementRepository.findAllEnqueteUniteLogementToDto();
}
@Override
public Page<EnqueteUniteLogementPayloadWeb> getEnqueteUniteLogementByUniteLogementListPageable(Long uniteLogementId, Pageable pageable) {
return enqueteUniteLogementRepository.findByAllByUniteLogementToDtoPageable(uniteLogementId,pageable);
}
@Override
public List<EnqueteUniteLogementPayloadWeb> getEnqueteUniteLogementUniteLogementList(Long uniteLogementId) {
return enqueteUniteLogementRepository.findAllByUniteLogementToDto(uniteLogementId);
} }
@Override @Override
public Optional<EnqueteUniteLogement> getEnqueteUniteLogementById(Long id) { public Optional<EnqueteUniteLogementPayloadWeb> getEnqueteUniteLogementById(Long id) {
if (enqueteUniteLogementRepository.existsById(id)) { if (enqueteUniteLogementRepository.existsById(id)) {
return enqueteUniteLogementRepository.findById(id); return enqueteUniteLogementRepository.findEnqueteUniteLogementToDto(id);
} else { } else {
throw new NotFoundException("Impossible de trouver la nouvelle enquete d'unité de logement spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la nouvelle enquete d'unité de logement spécifiée dans la base de données.");
} }
} }
@Override
public Page<EnqueteUniteLogementPayloadWeb> getEnqueteUniteLogementListByQuartierByStatutPageableToDto(Long userId, Long quartierId, StatutEnquete statutEnquete, Pageable pageable) {
List<Secteur> secteurs= secteurService.getListSecteurUserId(userId);
List<Long> secteurIds = secteurs.stream()
.map(Secteur::getId)
.toList();
return enqueteUniteLogementRepository.findAllEnqueteUniteLogementByQuartierByStatutToDtoPageable(quartierId,secteurIds,statutEnquete,pageable);
}
@Override
public EnqueteUniteLogementPayloadWeb validerEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
if (enqueteTraitementPayLoad == null || enqueteTraitementPayLoad.getIdBackend()==null) {
throw new BadRequestException("Impossible de valider une enquête ayant un id null.");
}
Optional<EnqueteUniteLogement> optionalEnqueteUniteLogement = enqueteUniteLogementRepository.findById(enqueteTraitementPayLoad.getIdBackend());
if (!optionalEnqueteUniteLogement.isPresent()) {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez valider.");
}
if(optionalEnqueteUniteLogement.get().getStatutEnquete()==StatutEnquete.CLOTURE ||
optionalEnqueteUniteLogement.get().getStatutEnquete()==StatutEnquete.REJETE ){
throw new NotAcceptableException("Impossible de valider : Le statut actuel "+optionalEnqueteUniteLogement.get().getStatutEnquete()+" ne le permet pas.");
}
EnqueteUniteLogement enqueteUniteLogement = optionalEnqueteUniteLogement.get();
enqueteUniteLogement.setDateValidation(LocalDate.now());
enqueteUniteLogement.setStatutEnquete(StatutEnquete.VALIDE);
enqueteUniteLogement= enqueteUniteLogementRepository.save(enqueteUniteLogement);
return enqueteUniteLogementRepository.findEnqueteUniteLogementToDto(enqueteUniteLogement.getId()).orElse(null);
}
@Override
public EnqueteUniteLogementPayloadWeb rejeterEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
if (enqueteTraitementPayLoad == null || enqueteTraitementPayLoad.getIdBackend()==null) {
throw new BadRequestException("Impossible de rejeter une enquête ayant un id null.");
}
Optional<EnqueteUniteLogement> optionalEnqueteUniteLogement = enqueteUniteLogementRepository.findById(enqueteTraitementPayLoad.getIdBackend());
if (!optionalEnqueteUniteLogement.isPresent()) {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez rejeter.");
}
if(optionalEnqueteUniteLogement.get().getStatutEnquete()==StatutEnquete.CLOTURE ||
optionalEnqueteUniteLogement.get().getStatutEnquete()==StatutEnquete.VALIDE ){
throw new NotAcceptableException("Impossible de rejeter : Le statut actuel "+optionalEnqueteUniteLogement.get().getStatutEnquete()+" ne le permet pas.");
}
EnqueteUniteLogement enqueteUniteLogement = optionalEnqueteUniteLogement.get();
enqueteUniteLogement.setDateRejet(LocalDate.now());
enqueteUniteLogement.setDescriptionMotifRejet(enqueteTraitementPayLoad.getMotifRejet());
enqueteUniteLogement.setStatutEnquete(StatutEnquete.REJETE);
enqueteUniteLogement= enqueteUniteLogementRepository.save(enqueteUniteLogement);
return enqueteUniteLogementRepository.findEnqueteUniteLogementToDto(enqueteUniteLogement.getId()).orElse(null);
}
@Override
public List<EnqueteUniteLogementPayloadWeb> validerEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
List<EnqueteUniteLogementPayloadWeb> enqueteUniteLogementPayloadWebs = new ArrayList<>();
try {
for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) {
enqueteUniteLogementPayloadWebs.add(validerEnquete(enqueteTraitementPayLoad));
}
} catch (Exception e) {
enqueteUniteLogementPayloadWebs.add(null);
}
return enqueteUniteLogementPayloadWebs;
}
@Override
public List<EnqueteUniteLogementPayloadWeb> rejeterEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
List<EnqueteUniteLogementPayloadWeb> enqueteUniteLogementPayloadWebs = new ArrayList<>();
try {
for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) {
enqueteUniteLogementPayloadWebs.add(rejeterEnquete(enqueteTraitementPayLoad));
}
} catch (Exception e) {
enqueteUniteLogementPayloadWebs.add(null);
}
return enqueteUniteLogementPayloadWebs;
}
} }

View File

@@ -1,81 +1,154 @@
package io.gmss.fiscad.implementations.rfu.metier; package io.gmss.fiscad.implementations.rfu.metier;
import io.gmss.fiscad.entities.infocad.parametre.Structure;
import io.gmss.fiscad.entities.rfu.metier.ImpositionsTfu; import io.gmss.fiscad.entities.rfu.metier.ImpositionsTfu;
import io.gmss.fiscad.enums.StatusAvis; import io.gmss.fiscad.enums.StatusAvis;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
import io.gmss.fiscad.interfaces.rfu.metier.ImpositionsTfuService; import io.gmss.fiscad.interfaces.rfu.metier.ImpositionsTfuService;
import io.gmss.fiscad.paylaods.request.crudweb.ImpositionsTfuPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.rfu.metier.ImpositionsTfuRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.ImpositionsTfuRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.NotAcceptableException;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@AllArgsConstructor
@Service @Service
public class ImpositionsTfuServiceImpl implements ImpositionsTfuService { public class ImpositionsTfuServiceImpl implements ImpositionsTfuService {
private final ImpositionsTfuRepository impositionsTfuRepository; private final ImpositionsTfuRepository impositionsTfuRepository;
private final StructureService structureService;
private final EntityFromPayLoadService entityFromPayLoadService;
private final EnqueteService enqueteService;
public ImpositionsTfuServiceImpl(ImpositionsTfuRepository impositionsTfuRepository) {
this.impositionsTfuRepository = impositionsTfuRepository;
}
/**
* Permet de créer pour un centre la synthèse de l'imposition de l'année en prélude de la
* génération des avis d'imposition
* @param impositionsTfuPaylaodWeb
* @return
* @throws BadRequestException
*/
@Override @Override
public ImpositionsTfu createImpositionsTfu(ImpositionsTfu impositionsTfu) throws BadRequestException { @Transactional
if (impositionsTfu.getId() != null) { public ImpositionsTfuPaylaodWeb createImpositionsTfu(ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) throws BadRequestException {
if (impositionsTfuPaylaodWeb.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle unité de logement ayant un id non null."); throw new BadRequestException("Impossible de créer une nouvelle unité de logement ayant un id non null.");
} }
List<ImpositionsTfu> impositionsTfus=impositionsTfuRepository.getImpositionsTfuByCommuneAndExercice(impositionsTfu.getCommune().getCode(),impositionsTfu.getExercice().getAnnee()); List<ImpositionsTfu> impositionsTfus=impositionsTfuRepository.getImpositionsTfuByStructureAndExercice(impositionsTfuPaylaodWeb.getStructureId(), impositionsTfuPaylaodWeb.getExerciceId());
if (!impositionsTfus.isEmpty()) { if (!impositionsTfus.isEmpty()) {
throw new BadRequestException("Une Imposition non annulée existe déjà"); throw new BadRequestException("Une Imposition non annulée existe déjà");
} }
impositionsTfu.setStatusAvis(StatusAvis.CREE); List<StatusAvis> statusAvis= new ArrayList<>();
impositionsTfu.setDateGeneration(LocalDate.now()); statusAvis.add(StatusAvis.EN_COURS);
return impositionsTfuRepository.save(impositionsTfu); statusAvis.add(StatusAvis.CLOTURE);
statusAvis.add(StatusAvis.GENERATION_AUTORISE);
Optional<ImpositionsTfu> optionalImpositionsTfu= impositionsTfuRepository.findDistinctByStructure_IdAndExercice_IdAndStatusAvisIn(impositionsTfuPaylaodWeb.getStructureId(),impositionsTfuPaylaodWeb.getExerciceId(),statusAvis);
if(optionalImpositionsTfu.isPresent()){
throw new BadRequestException("Une Imposition est déjà dans le workflow");
}
ImpositionsTfu impositionsTfu=entityFromPayLoadService.getImpositionsTfuFromPayLoadWeb(impositionsTfuPaylaodWeb);
impositionsTfu.setStatusAvis(StatusAvis.EN_COURS);
impositionsTfu =impositionsTfuRepository.save(impositionsTfu);
return impositionsTfuRepository.findByIdToDto(impositionsTfu.getId()).orElse(null);
} }
@Override @Override
public ImpositionsTfu annulerImpositionsTfu(ImpositionsTfu impositionsTfu) throws BadRequestException { public ImpositionsTfuPaylaodWeb rejeterImpositionsTfu(ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) throws BadRequestException {
if (impositionsTfu.getId() == null) { if (impositionsTfuPaylaodWeb.getId() == null) {
throw new BadRequestException("Impossible d'annuler une imposition ayant un id null."); throw new BadRequestException("Impossible d'annuler une imposition ayant un id null.");
} }
if (!impositionsTfuRepository.existsById(impositionsTfu.getId())) { if (!impositionsTfuRepository.existsById(impositionsTfuPaylaodWeb.getId())) {
throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans notre base de données.");
} }
impositionsTfu.setStatusAvis(StatusAvis.ANNULE); ImpositionsTfu impositionsTfu= entityFromPayLoadService.getImpositionsTfuFromPayLoadWeb(impositionsTfuPaylaodWeb);
return impositionsTfuRepository.save(impositionsTfu); if(!impositionsTfu.getStatusAvis().equals(StatusAvis.CLOTURE)){
throw new NotAcceptableException("L'état actuel :"+impositionsTfu.getStatusAvis()+"Ne permet pas de passer au l'état rejete");
}
impositionsTfu.setStatusAvis(StatusAvis.REJETE);
impositionsTfu =impositionsTfuRepository.save(impositionsTfu);
return impositionsTfuRepository.findByIdToDto(impositionsTfu.getId()).orElse(null);
}
@Override
@Transactional
public ImpositionsTfuPaylaodWeb cloturerImpositionsTfu(ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) throws BadRequestException {
if (impositionsTfuPaylaodWeb.getId() == null) {
throw new BadRequestException("Impossible de cloturer une imposition ayant un id null.");
}
if (!impositionsTfuRepository.existsById(impositionsTfuPaylaodWeb.getId())) {
throw new NotFoundException("Impossible de trouver l'imposition spécifiée dans notre base de données.");
}
ImpositionsTfu impositionsTfu= entityFromPayLoadService.getImpositionsTfuFromPayLoadWeb(impositionsTfuPaylaodWeb);
if(!impositionsTfu.getStatusAvis().equals(StatusAvis.EN_COURS) && !impositionsTfu.getStatusAvis().equals(StatusAvis.REJETE)){
throw new NotAcceptableException("L'état actuel :"+impositionsTfu.getStatusAvis()+"Ne permet pas de passer au l'état rejete");
}
impositionsTfu.setDateCloture(LocalDate.now());
enqueteService.cloturerEnqueteParcelleBatimentUniteLogementByStructureIdAndExerciceId(impositionsTfu.getStructure().getId(),impositionsTfu.getExercice().getId());
impositionsTfu.setStatusAvis(StatusAvis.CLOTURE);
impositionsTfu =impositionsTfuRepository.save(impositionsTfu);
return impositionsTfuRepository.findByIdToDto(impositionsTfu.getId()).orElse(null);
} }
@Override @Override
public ImpositionsTfu validerImpositionsTfu(ImpositionsTfu impositionsTfu) throws BadRequestException { public ImpositionsTfuPaylaodWeb autoriserGenerationImpositionsTfu(ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) throws BadRequestException {
if (impositionsTfu.getId() == null) { if (impositionsTfuPaylaodWeb.getId() == null) {
throw new BadRequestException("Impossible de valider une imposition ayant un id null."); throw new BadRequestException("Impossible de valider une imposition ayant un id null.");
} }
if (!impositionsTfuRepository.existsById(impositionsTfu.getId())) { if (!impositionsTfuRepository.existsById(impositionsTfuPaylaodWeb.getId())) {
throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver l'imposition spécifiée dans notre base de données.");
} }
impositionsTfu.setStatusAvis(StatusAvis.VALIDE);
return impositionsTfuRepository.save(impositionsTfu); ImpositionsTfu impositionsTfu= entityFromPayLoadService.getImpositionsTfuFromPayLoadWeb(impositionsTfuPaylaodWeb);
if(!impositionsTfu.getStatusAvis().equals(StatusAvis.CLOTURE)){
throw new NotFoundException("L'état actuel : "+impositionsTfu.getStatusAvis()+ " ne permet pas de passer à l'état Autorisé");
}
impositionsTfu.setDateGeneration(LocalDate.now());
impositionsTfu.setStatusAvis(StatusAvis.GENERATION_AUTORISE);
impositionsTfu =impositionsTfuRepository.save(impositionsTfu);
return impositionsTfuRepository.findByIdToDto(impositionsTfu.getId()).orElse(null);
} }
@Override @Override
public ImpositionsTfu updateImpositionsTfu(Long id, ImpositionsTfu impositionsTfu) throws NotFoundException { public ImpositionsTfuPaylaodWeb updateImpositionsTfu(Long id, ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) throws NotFoundException {
if (impositionsTfu.getId() == null) { // if (impositionsTfu.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle unité de logement ayant un id null."); // throw new BadRequestException("Impossible de mettre à jour une nouvelle unité de logement ayant un id null.");
} // }
if (!impositionsTfuRepository.existsById(impositionsTfu.getId())) { // if (!impositionsTfuRepository.existsById(impositionsTfu.getId())) {
throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans notre base de données."); // throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans notre base de données.");
} // }
return impositionsTfuRepository.save(impositionsTfu); return null; // impositionsTfuRepository.save(impositionsTfu);
} }
@Override @Override
public void deleteImpositionsTfu(Long id) throws NotFoundException { public void deleteImpositionsTfu(Long id) throws NotFoundException {
Optional<ImpositionsTfu> impositionsTfuOptional = impositionsTfuRepository.findById(id); Optional<ImpositionsTfu> impositionsTfuOptional = impositionsTfuRepository.findById(id);
if (impositionsTfuOptional.isPresent()) { if (impositionsTfuOptional.isPresent()) {
if(!impositionsTfuOptional.get().getStatusAvis().equals(StatusAvis.EN_COURS)){
throw new NotFoundException("L'état actuel : "+impositionsTfuOptional.get().getStatusAvis()+ " ne permet pas de supprimer");
}
impositionsTfuRepository.deleteById(impositionsTfuOptional.get().getId()); impositionsTfuRepository.deleteById(impositionsTfuOptional.get().getId());
} else { } else {
throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans notre base de données.");
@@ -94,11 +167,22 @@ public class ImpositionsTfuServiceImpl implements ImpositionsTfuService {
@Override @Override
public Optional<ImpositionsTfu> getImpositionsTfuById(Long id) { public Optional<ImpositionsTfuPaylaodWeb> getImpositionsTfuById(Long id) {
if (impositionsTfuRepository.existsById(id)) { if (impositionsTfuRepository.existsById(id)) {
return impositionsTfuRepository.findById(id); return impositionsTfuRepository.findByIdToDto(id);
} else { } else {
throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans la base de données.");
} }
} }
@Override
public List<ImpositionsTfuPaylaodWeb> getImpositionsTfuByUserIdIds(Long userId) {
System.out.println(userId);
List<Structure> structures = structureService.getListStructureUserId(userId);
List<Long> structureIds = structures.stream()
.map(Structure::getId)
.toList();
System.out.println(structureIds.get(0));
return impositionsTfuRepository.findByStructureIdsToDto(structureIds);
}
} }

View File

@@ -4,40 +4,66 @@ import io.gmss.fiscad.entities.rfu.metier.UniteLogement;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService; import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService;
import io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.rfu.metier.BatimentRepository;
import io.gmss.fiscad.persistence.repositories.rfu.metier.UniteLogementRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.UniteLogementRepository;
import io.gmss.fiscad.persistence.repositories.rfu.parametre.BaremRfuNonBatiRepository;
import io.gmss.fiscad.persistence.repositories.rfu.parametre.CategorieBatimentRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@AllArgsConstructor
@Service @Service
public class UniteLogementServiceImpl implements UniteLogementService { public class UniteLogementServiceImpl implements UniteLogementService {
private final UniteLogementRepository uniteLogementRepository; private final UniteLogementRepository uniteLogementRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
private final BatimentRepository batimentRepository;
private final CategorieBatimentRepository categorieBatimentRepository;
public UniteLogementServiceImpl(UniteLogementRepository uniteLogementRepository) {
this.uniteLogementRepository = uniteLogementRepository;
}
@Override @Override
public UniteLogement createUniteLogement(UniteLogement uniteLogement) throws BadRequestException { public UniteLogementPaylaodWeb createUniteLogement(UniteLogementPaylaodWeb uniteLogementPaylaodWeb) throws BadRequestException {
if (uniteLogement.getId() != null) { if (uniteLogementPaylaodWeb.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle unité de logement ayant un id non null."); throw new BadRequestException("Impossible de créer une nouvelle unité de logement ayant un id non null.");
} }
return uniteLogementRepository.save(uniteLogement);
if (uniteLogementPaylaodWeb.getBatimentId() == null) {
throw new BadRequestException("Impossible de créer l'unité de logement: Le batiment doit être précisé.");
}else {
if(!batimentRepository.existsById(uniteLogementPaylaodWeb.getBatimentId()))
throw new BadRequestException("Impossible de créer l'unite de logement: L'unité de logement doit être précisée.");
}
if (uniteLogementPaylaodWeb.getCategorieBatimentId() == null) {
throw new BadRequestException("Impossible de créer l'unite de logement: La catégorie doit être précisée.");
}else {
if(!categorieBatimentRepository.existsById(uniteLogementPaylaodWeb.getCategorieBatimentId()))
throw new BadRequestException("Impossible de créer l'unite de logement: La catégorie doit être précisée.");
}
UniteLogement uniteLogement = entityFromPayLoadService.getUniteLogementFromPayLoadWeb(uniteLogementPaylaodWeb);
uniteLogement = uniteLogementRepository.save(uniteLogement);
return uniteLogementRepository.findUniteLogementAvecOccupantCourantToDto(uniteLogement.getId()).orElse(null);
} }
@Override @Override
public UniteLogement updateUniteLogement(Long id, UniteLogement uniteLogement) throws NotFoundException { public UniteLogementPaylaodWeb updateUniteLogement(Long id, UniteLogementPaylaodWeb uniteLogementPaylaodWeb) throws NotFoundException {
if (uniteLogement.getId() == null) { if (uniteLogementPaylaodWeb.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle unité de logement ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle unité de logement ayant un id null.");
} }
if (!uniteLogementRepository.existsById(uniteLogement.getId())) { if (!uniteLogementRepository.existsById(uniteLogementPaylaodWeb.getId())) {
throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans notre base de données.");
} }
return uniteLogementRepository.save(uniteLogement); UniteLogement uniteLogement = entityFromPayLoadService.getUniteLogementFromPayLoadWeb(uniteLogementPaylaodWeb);
uniteLogement = uniteLogementRepository.save(uniteLogement);
return uniteLogementRepository.findUniteLogementAvecOccupantCourantToDto(uniteLogement.getId()).orElse(null);
} }
@Override @Override
@@ -51,23 +77,48 @@ public class UniteLogementServiceImpl implements UniteLogementService {
} }
@Override @Override
public Page<UniteLogement> getUniteLogementList(Pageable pageable) { public Page<UniteLogementPaylaodWeb> getUniteLogementList(Pageable pageable) {
return uniteLogementRepository.findAll(pageable); return uniteLogementRepository.findAllUnitesLogementAvecOccupantCourantToDtoPageable(pageable);
} }
@Override @Override
public List<UniteLogement> getUniteLogementList() { public List<UniteLogementPaylaodWeb> getUniteLogementList() {
return uniteLogementRepository.findAll(); return uniteLogementRepository.findAllUnitesLogementAvecOccupantCourantToDto();
} }
@Override @Override
public Optional<UniteLogement> getUniteLogementById(Long id) { public Optional<UniteLogementPaylaodWeb> getUniteLogementById(Long id) {
if (uniteLogementRepository.existsById(id)) { if (uniteLogementRepository.existsById(id)) {
return uniteLogementRepository.findById(id); return uniteLogementRepository.findUniteLogementAvecOccupantCourantToDto(id);
} else { } else {
throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans la base de données.");
} }
} }
@Override
public Page<UniteLogementPaylaodWeb> getUniteLogementListByBatimentPageable(Long batimentId, Pageable pageable) {
return uniteLogementRepository.findUnitesLogementAvecOccupantCourantByBatimentToDtoPageable(batimentId,pageable);
}
@Override
public List<UniteLogementPaylaodWeb> getUniteLogementListByBatiment(Long batimentId) {
return uniteLogementRepository.findUnitesLogementAvecOccupantCourantByBatimentToDto(batimentId);
}
@Override
public List<UniteLogementPaylaodWeb> getUniteLogementListByParcelle(Long parcelleId) {
return uniteLogementRepository.findAllUnitesLogementAvecOccupantCourantByParcelleToDto(parcelleId);
}
@Override
public Page<UniteLogementPaylaodWeb> getUniteLogementListByQuartierPageable(Long quartierId, Pageable pageable) {
return uniteLogementRepository.findUnitesLogementAvecOccupantCourantByQuartierToDtoPageable(quartierId,pageable);
}
@Override
public List<UniteLogementPaylaodWeb> getUniteLogementListByQuartier(Long quartierId) {
return uniteLogementRepository.findUnitesLogementAvecOccupantCourantByQuartierToDto(quartierId);
}
} }

Some files were not shown because too many files have changed in this diff Show More