110 Commits

Author SHA1 Message Date
6595e003ae Merge pull request 'gestion enum profile' (#212) from features/fiche_refonte into develop
Reviewed-on: #212
2026-06-01 17:22:37 +00:00
a2283a835b Merge pull request 'features/fiche_refonte' (#210) from features/fiche_refonte into develop
Reviewed-on: #210
2026-05-15 12:08:11 +00:00
ea7e693759 Merge pull request 'liquidation pour une parcelle' (#208) from features/fiche_refonte into develop
Reviewed-on: #208
2026-04-30 16:04:27 +00:00
6b954c7467 Merge pull request 'liquidation pour une parcelle' (#206) from features/fiche_refonte into develop
Reviewed-on: #206
2026-04-30 10:32:29 +00:00
2b2805a125 Merge pull request 'liquidation pour une parcelle' (#204) from features/fiche_refonte into develop
Reviewed-on: #204
2026-04-24 15:46:11 +00:00
49aea6e50a Merge pull request 'liquidation pour une parcelle' (#202) from features/fiche_refonte into develop
Reviewed-on: #202
2026-04-24 13:53:38 +00:00
3e105855f0 Merge pull request 'centre assignation et parcelle de contact' (#200) from features/fiche_refonte into develop
Reviewed-on: #200
2026-04-10 14:08:13 +00:00
5b73474192 Merge pull request 'centre assignation' (#198) from features/fiche_refonte into develop
Reviewed-on: #198
2026-04-01 20:03:57 +00:00
13ce1f31e2 Merge pull request 'version finale avec imposition TFU, IRF et SRTB' (#196) from features/fiche_refonte into develop
Reviewed-on: #196
2026-03-24 21:17:26 +00:00
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
b86c685cd0 Merge pull request 'Gestion cloture' (#138) from features/crud_entites into develop
Reviewed-on: #138
2026-03-06 19:08:53 +00: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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
f50ed9aa5f Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#83) from features/crud_entites into develop
Reviewed-on: #83
2026-02-04 01:33:32 +00:00
966fd2ca7a Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#81) from features/crud_entites into develop
Reviewed-on: #81
2026-02-03 19:32:06 +00:00
a10253b2e8 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#79) from features/crud_entites into develop
Reviewed-on: #79
2026-02-03 15:08:48 +00:00
08b68f9e08 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#77) from features/crud_entites into develop
Reviewed-on: #77
2026-02-02 23:03:26 +00:00
be487d6a03 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#75) from features/crud_entites into develop
Reviewed-on: #75
2026-02-01 22:49:00 +00:00
3be64e7f44 Merge pull request 'gestion de profil, secteur, section et arbre decoupage' (#73) from features/crud_entites into develop
Reviewed-on: #73
2026-01-27 08:58:32 +00:00
03a661cdc0 Merge pull request 'gestion de profil, secteur, section et arbre decoupage' (#72) from features/crud_entites into develop
Reviewed-on: #72
2026-01-27 08:37:52 +00:00
a68ec444cc Merge pull request 'features/crud_entites' (#70) from features/crud_entites into develop
Reviewed-on: #70
2026-01-13 20:33:17 +00:00
58f517bf31 Merge pull request 'correction creation user par defaut' (#68) from features/crud_entites into develop
Reviewed-on: #68
2025-12-20 19:03:51 +00:00
7f18f22efb Merge pull request 'correction creation user par defaut' (#66) from features/crud_entites into develop
Reviewed-on: #66
2025-12-20 18:55:42 +00:00
af3218412f Merge pull request 'correction creation user par defaut' (#64) from features/crud_entites into develop
Reviewed-on: #64
2025-12-20 17:06:19 +00:00
f35670c72e Merge pull request 'correction creation user par defaut' (#62) from features/crud_entites into develop
Reviewed-on: #62
2025-12-20 15:03:45 +00:00
a77c0e854d Merge pull request 'correction creation user par defaut' (#60) from features/crud_entites into develop
Reviewed-on: #60
2025-12-20 14:48:47 +00:00
e75eff4e20 Merge pull request 'correction lecture de secret chargement' (#58) from features/crud_entites into develop
Reviewed-on: #58
2025-12-20 14:33:59 +00:00
40d078c653 Merge pull request 'correction lecture de secret chargement' (#56) from features/crud_entites into develop
Reviewed-on: #56
2025-12-20 14:14:02 +00:00
31dd11d017 Merge pull request 'correction lecture de secret chargement' (#54) from features/crud_entites into develop
Reviewed-on: #54
2025-12-20 13:10:40 +00:00
6dfd12fae8 Merge pull request 'correction lecture de secret chargement' (#52) from features/crud_entites into develop
Reviewed-on: #52
2025-12-20 12:57:46 +00:00
a4ad0a4556 Merge pull request 'correction lecture de secret chargement' (#50) from features/crud_entites into develop
Reviewed-on: #50
2025-12-20 12:41:09 +00:00
411a6c0c2d Merge pull request 'correction lecture de secret' (#48) from features/crud_entites into develop
Reviewed-on: #48
2025-12-20 12:21:25 +00:00
bed73b2b16 Merge pull request 'correction lecture de secret' (#46) from features/crud_entites into develop
Reviewed-on: #46
2025-12-20 12:10:00 +00:00
5a0814a0ba Merge pull request 'correction lecture de secret' (#44) from features/crud_entites into develop
Reviewed-on: #44
2025-12-20 12:00:12 +00:00
126254ea94 Merge pull request 'correction lecture de secret' (#42) from features/crud_entites into develop
Reviewed-on: #42
2025-12-20 11:43:55 +00:00
f9e4681af4 Merge pull request 'correction lecture de secret' (#40) from features/crud_entites into develop
Reviewed-on: #40
2025-12-20 11:39:40 +00:00
84089d3639 Merge pull request 'correction profil actif' (#38) from features/crud_entites into develop
Reviewed-on: #38
2025-12-20 10:48:01 +00:00
02b0a937b4 Merge pull request 'correction profil actif' (#36) from features/crud_entites into develop
Reviewed-on: #36
2025-12-20 10:02:19 +00:00
c0096457fb Merge pull request 'nouvelle verson ci-cd avec gitea runner natif intallé sur hote' (#34) from features/crud_entites into develop
Reviewed-on: #34
2025-12-19 19:14:24 +00:00
b6062ba4d1 Merge pull request 'nouvelle verson ci-cd avec gitea runner natif intallé sur hote' (#33) from features/crud_entites into develop
Reviewed-on: #33
2025-12-19 10:50:02 +00:00
8dc8c974d3 Merge pull request 'correction docker composer avec les secrets' (#32) from features/crud_entites into develop
Reviewed-on: #32
2025-12-19 10:39:57 +00:00
957416df9e Merge pull request 'correction docker composer avec les secrets' (#30) from features/crud_entites into develop
Reviewed-on: #30
2025-12-18 15:47:21 +00:00
8d8af75108 Merge pull request 'correction docker composer avec les secrets' (#28) from features/crud_entites into develop
Reviewed-on: #28
2025-12-18 15:46:02 +00:00
555f13508e Merge pull request 'correction docker composer avec les secrets' (#26) from features/crud_entites into develop
Reviewed-on: #26
2025-12-18 10:36:10 +00:00
d92a2b2503 Merge pull request 'correction docker composer avec les secrets' (#24) from features/crud_entites into develop
Reviewed-on: #24
2025-12-17 17:13:46 +00:00
5ccfdb6a3f Merge pull request 'correction docker composer avec les secrets' (#22) from features/crud_entites into develop
Reviewed-on: #22
2025-12-17 16:58:50 +00:00
87b3bfbe83 Merge pull request 'correction docker composer avec les secrets' (#20) from features/crud_entites into develop
Reviewed-on: #20
2025-12-17 16:49:15 +00:00
62f25ea726 Merge pull request 'correction docker composer avec les secrets' (#18) from features/crud_entites into develop
Reviewed-on: #18
2025-12-17 16:41:46 +00:00
6125fcbd0b Merge pull request 'correction docker composer' (#16) from features/crud_entites into develop
Reviewed-on: #16
2025-12-17 16:26:17 +00:00
211af6103a Merge pull request 'features/crud_entites' (#14) from features/crud_entites into develop
Reviewed-on: #14
2025-12-17 14:12:53 +00:00
d27b622db8 Merge pull request 'Changement en DB du nom de la colonne personne_id en proprietaire_id dans la table enquete' (#12) from features/crud_entites into develop
All checks were successful
CD - Deploy on main / deploy (pull_request) Successful in 35s
Reviewed-on: #12
2025-12-16 18:22:48 +00:00
c80b40082c Merge pull request 'Changement en DB du nom de la colonne personne_id en proprietaire_id dans la table enquete' (#10) from features/crud_entites into develop
All checks were successful
CD - Deploy on main / deploy (pull_request) Successful in 44s
Reviewed-on: #10
2025-12-16 18:06:52 +00:00
4a88af6487 Merge pull request 'Changement en DB du nom de la colonne personne_id en proprietaire_id dans la table enquete' (#8) from features/crud_entites into develop
All checks were successful
CD - Deploy on main / deploy (pull_request) Successful in 34s
Reviewed-on: #8
2025-12-05 19:24:00 +00:00
966b0af1c2 Merge pull request 'Changement en DB du nom de la colonne personne_id en proprietaire_id dans la table enquete' (#6) from features/crud_entites into develop
All checks were successful
CD - Deploy on main / deploy (pull_request) Successful in 36s
Reviewed-on: #6
2025-12-05 19:20:57 +00:00
58aa088ac3 Merge pull request 'ajout de ci-cd' (#4) from features/crud_entites into develop
All checks were successful
CD - Deploy on main / deploy (pull_request) Successful in 39s
Reviewed-on: #4
2025-12-05 19:10:37 +00:00
033b430051 Merge pull request 'ajout de ci-cd' (#2) from features/crud_entites into develop
Some checks failed
CD - Deploy on main / deploy (pull_request) Failing after 39s
Reviewed-on: #2
2025-12-05 19:06:43 +00:00
b8dbc7f625 Merge pull request 'ajout de ci-cd' (#1) from features/crud_entites into develop
Reviewed-on: #1
2025-12-05 17:53:30 +00:00
73 changed files with 64 additions and 6937 deletions

View File

@@ -1,183 +0,0 @@
package io.gmss.fiscad.controllers.frontend;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.frontend.FonctionnaliteService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb;
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.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@AllArgsConstructor
@RestController
@RequestMapping(value = "api/fonctionnalite", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "Fonctionnalite")
@CrossOrigin(origins = "*")
public class FonctionnaliteController {
private final FonctionnaliteService fonctionnaliteService;
private static final Logger logger = LoggerFactory.getLogger(FonctionnaliteController.class);
@PostMapping("/create")
@PreAuthorize("hasAuthority('CREATE_FONCTIONNALITE')")
public ResponseEntity<?> createFonctionnalite(@RequestBody @Valid @Validated FonctionnalitePayloadWeb fonctionnalitePayLoadWeb) {
try {
fonctionnalitePayLoadWeb = fonctionnaliteService.createFonctionnalite(fonctionnalitePayLoadWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, fonctionnalitePayLoadWeb, "Fonctionnalite 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}")
@PreAuthorize("hasAuthority('UPDATE_FONCTIONNALITE')")
public ResponseEntity<?> updateFonctionnalite(@PathVariable Long id, @RequestBody FonctionnalitePayloadWeb fonctionnalitePayLoadWeb) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, fonctionnaliteService.updateFonctionnalite(id,fonctionnalitePayLoadWeb), "Fonctionnalite 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}")
@PreAuthorize("hasAuthority('DELETE_FONCTIONNALITE')")
public ResponseEntity<?> deleteFonctionnalite(@PathVariable Long id) {
try {
fonctionnaliteService.deleteFonctionnalite(id);
return new ResponseEntity<>(
new ApiResponse<>(true, "Fonctionnalite 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")
@PreAuthorize("hasAuthority('READ_FONCTIONNALITE')")
public ResponseEntity<?> getAllFonctionnaliteList() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, fonctionnaliteService.getFonctionnaliteListToDto(), "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-profil-id/{profilId}")
@PreAuthorize("hasAuthority('READ_FONCTIONNALITE')")
public ResponseEntity<?> getAllFonctionnaliteByProfilList(@PathVariable Long profilId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, fonctionnaliteService.getAllFonctionnaliteByProfilIdToDto(profilId), "Liste des fonctionnalites 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}")
@PreAuthorize("hasAuthority('READ_FONCTIONNALITE')")
public ResponseEntity<?> getFonctionnaliteById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, fonctionnaliteService.getFonctionnaliteByIdToDto(id), "Fonctionnalite 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,185 +0,0 @@
package io.gmss.fiscad.controllers.frontend;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.frontend.ModuleService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb;
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.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@AllArgsConstructor
@RestController
@RequestMapping(value = "api/module", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "Module")
@CrossOrigin(origins = "*")
public class ModuleController {
private final ModuleService moduleService;
private static final Logger logger = LoggerFactory.getLogger(ModuleController.class);
@PostMapping("/create")
@PreAuthorize("hasAuthority('CREATE_MODULE')")
public ResponseEntity<?> createModule(@RequestBody @Valid @Validated ModulePayloadWeb modulePayLoadWeb) {
try {
modulePayLoadWeb = moduleService.createModule(modulePayLoadWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, modulePayLoadWeb, "Module 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}")
@PreAuthorize("hasAuthority('UPDATE_MODULE')")
public ResponseEntity<?> updateModule(@PathVariable Long id, @RequestBody ModulePayloadWeb modulePayLoadWeb) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, moduleService.updateModule(id,modulePayLoadWeb), "Module 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}")
@PreAuthorize("hasAuthority('DELETE_MODULE')")
public ResponseEntity<?> deleteModule(@PathVariable Long id) {
try {
moduleService.deleteModule(id);
return new ResponseEntity<>(
new ApiResponse<>(true, "Module 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")
@PreAuthorize("hasAuthority('READ_MODULE')")
public ResponseEntity<?> getAllModuleList() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, moduleService.getModuleListToDto(), "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-profil-id/{profilId}")
@PreAuthorize("hasAuthority('READ_MODULE')")
public ResponseEntity<?> getAllModuleByProfilList(@PathVariable Long profilId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, moduleService.getAllModuleByProfilIdToDto(profilId), "Liste des modules 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}")
@PreAuthorize("hasAuthority('READ_MODULE')")
public ResponseEntity<?> getModuleById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, moduleService.getModuleByIdToDto(id), "Module 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,184 +0,0 @@
package io.gmss.fiscad.controllers.user;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.user.ProfileModuleFonctionnaliteService;
import io.gmss.fiscad.interfaces.user.ProfileModuleFonctionnaliteService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb;
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.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@AllArgsConstructor
@RestController
@RequestMapping(value = "api/profile-module-fonctionnalite", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "ProfileModuleFonctionnalite")
@CrossOrigin(origins = "*")
public class ProfileModuleFonctionnaliteController {
private final ProfileModuleFonctionnaliteService profileModuleFonctionnaliteService;
private static final Logger logger = LoggerFactory.getLogger(ProfileModuleFonctionnaliteController.class);
@PostMapping("/create")
@PreAuthorize("hasAuthority('CREATE_PROFILEMODULEFONCTIONNALITE')")
public ResponseEntity<?> createProfileModuleFonctionnalite(@RequestBody @Valid @Validated ProfileModuleFonctionnalitePayloadWeb modulePayLoadWeb) {
try {
modulePayLoadWeb = profileModuleFonctionnaliteService.createProfileModuleFonctionnalite(modulePayLoadWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, modulePayLoadWeb, "ProfileModuleFonctionnalite 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}")
@PreAuthorize("hasAuthority('UPDATE_PROFILEMODULEFONCTIONNALITE')")
public ResponseEntity<?> updateProfileModuleFonctionnalite(@PathVariable Long id, @RequestBody ProfileModuleFonctionnalitePayloadWeb modulePayLoadWeb) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, profileModuleFonctionnaliteService.updateProfileModuleFonctionnalite(id,modulePayLoadWeb), "ProfileModuleFonctionnalite 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}")
@PreAuthorize("hasAuthority('DELETE_PROFILEMODULEFONCTIONNALITE')")
public ResponseEntity<?> deleteProfileModuleFonctionnalite(@PathVariable Long id) {
try {
profileModuleFonctionnaliteService.deleteProfileModuleFonctionnalite(id);
return new ResponseEntity<>(
new ApiResponse<>(true, "ProfileModuleFonctionnalite 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")
@PreAuthorize("hasAuthority('READ_PROFILEMODULEFONCTIONNALITE')")
public ResponseEntity<?> getAllProfileModuleFonctionnaliteList() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, profileModuleFonctionnaliteService.getProfileModuleFonctionnaliteListToDto(), "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-profil-id/{profilId}")
@PreAuthorize("hasAuthority('READ_PROFILEMODULEFONCTIONNALITE')")
public ResponseEntity<?> getAllProfileModuleFonctionnaliteByProfilList(@PathVariable Long profilId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, profileModuleFonctionnaliteService.getAllProfileModuleFonctionnaliteByProfilIdToDto(profilId), "Liste des modules 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}")
@PreAuthorize("hasAuthority('READ_PROFILEMODULEFONCTIONNALITE')")
public ResponseEntity<?> getProfileModuleFonctionnaliteById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, profileModuleFonctionnaliteService.getProfileModuleFonctionnaliteByIdToDto(id), "ProfileModuleFonctionnalite 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,28 +0,0 @@
package io.gmss.fiscad.entities.frontend;
import io.gmss.fiscad.entities.BaseEntity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Fonctionnalite extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String code;
private String nom;
private String lien;
@Column(nullable = false, columnDefinition = "BOOLEAN DEFAULT true")
private Boolean actif;
@ManyToOne
private ModuleApp moduleApp;
}

View File

@@ -1,31 +0,0 @@
package io.gmss.fiscad.entities.frontend;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.gmss.fiscad.entities.BaseEntity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ModuleApp extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String code;
private String nom;
private String lien;
@Column(nullable = false, columnDefinition = "BOOLEAN DEFAULT true")
private Boolean actif;
@JsonIgnore
@OneToMany(mappedBy = "moduleApp")
private List<Fonctionnalite> fonctionnalites;
}

View File

@@ -33,15 +33,15 @@ public class EpaiementAcompte extends BaseEntity implements Serializable {
private String rDoc; private String rDoc;
private String rImpot; private String rImpot;
private String idImpotType; private String idImpotType;
private String idImpotNature; /// participe unicité private String idImpotNature;
private String ifu; /// participe unicité private String ifu;
private String rCommune; private String rCommune;
private String rQuartier; /// participe unicité private String rQuartier;
private String qipQuartier; private String qipQuartier;
private String qipIlot; /// participe unicité private String qipIlot;
private String qipParcelle; /// participe unicité private String qipParcelle;
private String nup; private String nup;
private Long exercice; /// participe unicité private Long exercice;
@JsonFormat(pattern = "dd-MM-yyyy") @JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateValidation; private LocalDate dateValidation;

View File

@@ -1,29 +0,0 @@
package io.gmss.fiscad.entities.user;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.frontend.Fonctionnalite;
import io.gmss.fiscad.entities.frontend.ModuleApp;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
//@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class ProfileModuleFonctionnalite extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
private Profile profile;
@ManyToOne
private ModuleApp moduleApp;
@ManyToOne
private Fonctionnalite fonctionnalite ;
private Boolean actif;
}

View File

@@ -259,23 +259,7 @@ public enum UserRole {
DELETE_USER, DELETE_USER,
CREATE_PARAMETERS, CREATE_PARAMETERS,
READ_PARAMETERS, READ_PARAMETERS,
UPDATE_PARAMETERS, UPDATE_PARAMETERS
DELETE_PARAMETERS,
CREATE_SECTEUR_DECOUPAGE,
READ_SECTEUR_DECOUPAGE,
UPDATE_SECTEUR_DECOUPAGE,
DELETE_SECTEUR_DECOUPAGE,
CREATE_MODULE,
READ_MODULE,
UPDATE_MODULE,
DELETE_MODULE,
CREATE_FONCTIONNALITE,
READ_FONCTIONNALITE,
UPDATE_FONCTIONNALITE,
DELETE_FONCTIONNALITE,
CREATE_PROFILEMODULEFONCTIONNALITE,
READ_PROFILEMODULEFONCTIONNALITE,
UPDATE_PROFILEMODULEFONCTIONNALITE,
DELETE_PROFILEMODULEFONCTIONNALITE
} }

View File

@@ -1,74 +0,0 @@
package io.gmss.fiscad.implementations.frontend;
import io.gmss.fiscad.entities.frontend.Fonctionnalite;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.frontend.FonctionnaliteService;
import io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb;
import io.gmss.fiscad.persistence.repositories.frontend.FonctionnaliteRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@AllArgsConstructor
@Service
public class FonctionnaliteServiceImpl implements FonctionnaliteService {
private final FonctionnaliteRepository fonctionnaliteRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
@Override
public FonctionnalitePayloadWeb createFonctionnalite(FonctionnalitePayloadWeb fonctionnalitePayloadWeb) throws BadRequestException {
if (fonctionnalitePayloadWeb.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle déclaration NC ayant un id non null.");
}
Fonctionnalite fonctionnalite= entityFromPayLoadService.getFonctionnaliteFromPayloadWeb(fonctionnalitePayloadWeb);
fonctionnalite = fonctionnaliteRepository.save(fonctionnalite);
return fonctionnaliteRepository.findPayloadById(fonctionnalite.getId()).orElse(null);
}
@Override
public FonctionnalitePayloadWeb updateFonctionnalite(Long id, FonctionnalitePayloadWeb fonctionnalitePayloadWeb) throws NotFoundException {
if (fonctionnalitePayloadWeb.getId() == null) {
throw new BadRequestException("La fonctionnaliteApp n'existe pas.");
}
if (!fonctionnaliteRepository.existsById(fonctionnalitePayloadWeb.getId())) {
throw new NotFoundException("La fonctionnaliteApp n'existe pas");
}
Fonctionnalite fonctionnaliteApp = entityFromPayLoadService.getFonctionnaliteFromPayloadWeb(fonctionnalitePayloadWeb);
fonctionnaliteApp =fonctionnaliteRepository.save(fonctionnaliteApp);
return fonctionnaliteRepository.findPayloadById(fonctionnaliteApp.getId()).orElse(null);
}
@Override
public void deleteFonctionnalite(Long id) throws NotFoundException {
Optional<Fonctionnalite> fonctionnaliteOptional = fonctionnaliteRepository.findById(id);
if (fonctionnaliteOptional.isPresent()) {
fonctionnaliteRepository.deleteById(fonctionnaliteOptional.get().getId());
} else {
throw new NotFoundException("Impossible de trouver la fonctionnalite à supprimer .");
}
}
@Override
public List<FonctionnalitePayloadWeb> getFonctionnaliteListToDto() {
return fonctionnaliteRepository.findAllPayload();
}
@Override
public Optional<FonctionnalitePayloadWeb> getFonctionnaliteByIdToDto(Long id) {
return fonctionnaliteRepository.findPayloadById(id);
}
@Override
public List<FonctionnalitePayloadWeb> getAllFonctionnaliteByProfilIdToDto(Long id) {
return fonctionnaliteRepository.findByProfileId(id);
}
}

View File

@@ -1,75 +0,0 @@
package io.gmss.fiscad.implementations.frontend;
import io.gmss.fiscad.entities.frontend.ModuleApp;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.frontend.ModuleService;
import io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb;
import io.gmss.fiscad.persistence.repositories.frontend.ModuleRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@AllArgsConstructor
@Service
public class ModuleServiceImpl implements ModuleService {
private final ModuleRepository moduleRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
@Override
public ModulePayloadWeb createModule(ModulePayloadWeb modulePayloadWeb) throws BadRequestException {
if (modulePayloadWeb.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle déclaration NC ayant un id non null.");
}
ModuleApp module= entityFromPayLoadService.getModuleFromPayloadWeb(modulePayloadWeb);
module = moduleRepository.save(module);
return moduleRepository.findPayloadById(module.getId()).orElse(null);
}
@Override
public ModulePayloadWeb updateModule(Long id, ModulePayloadWeb modulePayloadWeb) throws NotFoundException {
if (modulePayloadWeb.getId() == null) {
throw new BadRequestException("La moduleApp n'existe pas.");
}
if (!moduleRepository.existsById(modulePayloadWeb.getId())) {
throw new NotFoundException("La moduleApp n'existe pas");
}
ModuleApp moduleApp = entityFromPayLoadService.getModuleFromPayloadWeb(modulePayloadWeb);
moduleApp =moduleRepository.save(moduleApp);
return moduleRepository.findPayloadById(moduleApp.getId()).orElse(null);
}
@Override
public void deleteModule(Long id) throws NotFoundException {
Optional<ModuleApp> moduleOptional = moduleRepository.findById(id);
if (moduleOptional.isPresent()) {
moduleRepository.deleteById(moduleOptional.get().getId());
} else {
throw new NotFoundException("Impossible de trouver la module à supprimer .");
}
}
@Override
public List<ModulePayloadWeb> getModuleListToDto() {
return moduleRepository.findAllPayload();
}
@Override
public Optional<ModulePayloadWeb> getModuleByIdToDto(Long id) {
return moduleRepository.findPayloadById(id);
}
@Override
public List<ModulePayloadWeb> getAllModuleByProfilIdToDto(Long id) {
return moduleRepository.findPayloadByProfilId(id);
}
}

View File

@@ -1,77 +0,0 @@
package io.gmss.fiscad.implementations.user;
import io.gmss.fiscad.entities.frontend.Fonctionnalite;
import io.gmss.fiscad.entities.user.ProfileModuleFonctionnalite;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.frontend.FonctionnaliteService;
import io.gmss.fiscad.interfaces.user.ProfileModuleFonctionnaliteService;
import io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb;
import io.gmss.fiscad.persistence.repositories.frontend.FonctionnaliteRepository;
import io.gmss.fiscad.persistence.repositories.user.ProfileModuleFonctionnaliteRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@AllArgsConstructor
@Service
public class ProfileModuleFonctionnaliteServiceImpl implements ProfileModuleFonctionnaliteService {
private final ProfileModuleFonctionnaliteRepository profileModuleFonctionnaliteRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
@Override
public ProfileModuleFonctionnalitePayloadWeb createProfileModuleFonctionnalite(ProfileModuleFonctionnalitePayloadWeb profileModuleFonctionnalitePayloadWeb) throws BadRequestException {
if (profileModuleFonctionnalitePayloadWeb.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle déclaration NC ayant un id non null.");
}
ProfileModuleFonctionnalite profileModuleFonctionnalite= entityFromPayLoadService.getProfileModuleFonctionnaliteFromPayloadWeb(profileModuleFonctionnalitePayloadWeb);
profileModuleFonctionnalite = profileModuleFonctionnaliteRepository.save(profileModuleFonctionnalite);
return profileModuleFonctionnaliteRepository.findPayloadById(profileModuleFonctionnalite.getId()).orElse(null);
}
@Override
public ProfileModuleFonctionnalitePayloadWeb updateProfileModuleFonctionnalite(Long id, ProfileModuleFonctionnalitePayloadWeb profileModuleFonctionnalitePayloadWeb) throws NotFoundException {
if (profileModuleFonctionnalitePayloadWeb.getId() == null) {
throw new BadRequestException("La fonctionnaliteApp n'existe pas.");
}
if (!profileModuleFonctionnaliteRepository.existsById(profileModuleFonctionnalitePayloadWeb.getId())) {
throw new NotFoundException("La fonctionnaliteApp n'existe pas");
}
ProfileModuleFonctionnalite profileModuleFonctionnalite = entityFromPayLoadService.getProfileModuleFonctionnaliteFromPayloadWeb(profileModuleFonctionnalitePayloadWeb);
profileModuleFonctionnalite =profileModuleFonctionnaliteRepository.save(profileModuleFonctionnalite);
return profileModuleFonctionnaliteRepository.findPayloadById(profileModuleFonctionnalite.getId()).orElse(null);
}
@Override
public void deleteProfileModuleFonctionnalite(Long id) throws NotFoundException {
Optional<ProfileModuleFonctionnalite> profileModuleFonctionnaliteOptional = profileModuleFonctionnaliteRepository.findById(id);
if (profileModuleFonctionnaliteOptional.isPresent()) {
profileModuleFonctionnaliteRepository.deleteById(profileModuleFonctionnaliteOptional.get().getId());
} else {
throw new NotFoundException("Impossible de trouver la fonctionnalite à supprimer .");
}
}
@Override
public List<ProfileModuleFonctionnalitePayloadWeb> getProfileModuleFonctionnaliteListToDto() {
return profileModuleFonctionnaliteRepository.findAllPayload();
}
@Override
public Optional<ProfileModuleFonctionnalitePayloadWeb> getProfileModuleFonctionnaliteByIdToDto(Long id) {
return profileModuleFonctionnaliteRepository.findPayloadById(id);
}
@Override
public List<ProfileModuleFonctionnalitePayloadWeb> getAllProfileModuleFonctionnaliteByProfilIdToDto(Long id) {
return profileModuleFonctionnaliteRepository.findByProfileId(id);
}
}

View File

@@ -1,32 +0,0 @@
package io.gmss.fiscad.interfaces.frontend;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Optional;
public interface FonctionnaliteService {
FonctionnalitePayloadWeb createFonctionnalite(FonctionnalitePayloadWeb fonctionnalitePayLoadWeb) throws BadRequestException;
FonctionnalitePayloadWeb updateFonctionnalite(Long id, FonctionnalitePayloadWeb fonctionnalitePayLoadWeb) throws NotFoundException;
void deleteFonctionnalite(Long id) throws NotFoundException;
//Page<FonctionnalitePayloadWeb> getFonctionnaliteListToDtoPageable(Pageable pageable);
List<FonctionnalitePayloadWeb> getFonctionnaliteListToDto();
Optional<FonctionnalitePayloadWeb> getFonctionnaliteByIdToDto(Long id);
//List<FonctionnalitePayloadWeb> getAllFonctionnaliteByEnqueteToDto(Long id);
//Page<FonctionnalitePayloadWeb> getAllFonctionnaliteByEnqueteToDtoPageable(Long id,Pageable pageable);
//List<FonctionnalitePayloadWeb> getAllFonctionnaliteByEnqueteBatimentToDto(Long id);
List<FonctionnalitePayloadWeb> getAllFonctionnaliteByProfilIdToDto(Long id);
}

View File

@@ -1,30 +0,0 @@
package io.gmss.fiscad.interfaces.frontend;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Optional;
public interface ModuleService {
ModulePayloadWeb createModule(ModulePayloadWeb modulePayLoadWeb) throws BadRequestException;
ModulePayloadWeb updateModule(Long id, ModulePayloadWeb modulePayLoadWeb) throws NotFoundException;
void deleteModule(Long id) throws NotFoundException;
//Page<ModulePayloadWeb> getModuleListToDtoPageable(Pageable pageable);
List<ModulePayloadWeb> getModuleListToDto();
Optional<ModulePayloadWeb> getModuleByIdToDto(Long id);
List<ModulePayloadWeb> getAllModuleByProfilIdToDto(Long id);
}

View File

@@ -1,32 +0,0 @@
package io.gmss.fiscad.interfaces.user;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Optional;
public interface ProfileModuleFonctionnaliteService {
ProfileModuleFonctionnalitePayloadWeb createProfileModuleFonctionnalite(ProfileModuleFonctionnalitePayloadWeb profileModuleFonctionnalitePayloadWeb) throws BadRequestException;
ProfileModuleFonctionnalitePayloadWeb updateProfileModuleFonctionnalite(Long id, ProfileModuleFonctionnalitePayloadWeb profileModuleFonctionnalitePayloadWeb) throws NotFoundException;
void deleteProfileModuleFonctionnalite(Long id) throws NotFoundException;
//Page<ProfileModuleFonctionnalitePayloadWeb> getProfileModuleFonctionnaliteListToDtoPageable(Pageable pageable);
List<ProfileModuleFonctionnalitePayloadWeb> getProfileModuleFonctionnaliteListToDto();
Optional<ProfileModuleFonctionnalitePayloadWeb> getProfileModuleFonctionnaliteByIdToDto(Long id);
//List<ProfileModuleFonctionnalitePayloadWeb> getAllProfileModuleFonctionnaliteByEnqueteToDto(Long id);
//Page<ProfileModuleFonctionnalitePayloadWeb> getAllProfileModuleFonctionnaliteByEnqueteToDtoPageable(Long id,Pageable pageable);
//List<ProfileModuleFonctionnalitePayloadWeb> getAllProfileModuleFonctionnaliteByEnqueteBatimentToDto(Long id);
List<ProfileModuleFonctionnalitePayloadWeb> getAllProfileModuleFonctionnaliteByProfilIdToDto(Long id);
}

View File

@@ -1,28 +0,0 @@
package io.gmss.fiscad.paylaods.request.crudweb;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
public class FonctionnalitePayloadWeb {
private Long id;
private String code;
private String nom;
private Long moduleId;
private String moduleCode;
private String moduleNom;
private Boolean actif;
private String lien;
public FonctionnalitePayloadWeb(Long id, String code, String nom, Long moduleId, String moduleCode, String moduleNom, Boolean actif, String lien) {
this.id = id;
this.code = code;
this.nom = nom;
this.moduleId = moduleId;
this.moduleCode = moduleCode;
this.moduleNom = moduleNom;
this.actif = actif;
this.lien = lien;
}
}

View File

@@ -1,22 +0,0 @@
package io.gmss.fiscad.paylaods.request.crudweb;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
public class ModulePayloadWeb {
private Long id;
private String code;
private String nom;
private Boolean actif;
private String lien;
public ModulePayloadWeb(Long id, String code, String nom, Boolean actif, String lien) {
this.id = id;
this.code = code;
this.nom = nom;
this.actif = actif;
this.lien = lien;
}
}

View File

@@ -1,41 +0,0 @@
package io.gmss.fiscad.paylaods.request.crudweb;
import io.gmss.fiscad.enums.ProfileApp;
import io.gmss.fiscad.enums.UserProfile;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
public class ProfileModuleFonctionnalitePayloadWeb {
private Long id;
private Long profileId;
@Enumerated(EnumType.STRING)
private UserProfile profileNom;
private String profileDescription;
private Long moduleId;
private String moduleCode;
private String moduleNom;
private Long fonctionnaliteId;
private String fonctionnaliteCode;
private String fonctionnaliteNom;
private String fonctionnaliteLien;
private Boolean actif;
public ProfileModuleFonctionnalitePayloadWeb(Long id, Long profileId, UserProfile profileNom, String profileDescription, Long moduleId, String moduleCode, String moduleNom, Long fonctionnaliteId, String fonctionnaliteCode, String fonctionnaliteNom, String fonctionnaliteLien, Boolean actif) {
this.id = id;
this.profileId = profileId;
this.profileNom = profileNom;
this.profileDescription = profileDescription;
this.moduleId = moduleId;
this.moduleCode = moduleCode;
this.moduleNom = moduleNom;
this.fonctionnaliteId = fonctionnaliteId;
this.fonctionnaliteCode = fonctionnaliteCode;
this.fonctionnaliteNom = fonctionnaliteNom;
this.fonctionnaliteLien = fonctionnaliteLien;
this.actif = actif;
}
}

View File

@@ -103,7 +103,7 @@ SELECT distinct on (exo.annee,dimp.parcelle_id,dimp.nature_impot)
end as montant_base_imposition, end as montant_base_imposition,
dimp.valeur_locative_adm as montant_valeur_locative, dimp.valeur_locative_adm as montant_valeur_locative,
dimp.taux_tfu as taux, dimp.taux_tfu as taux,
dimp.montant_taxe-coalesce(dimp.acompte,0)-coalesce(dimp.retenu_irf,0) as montant_du, dimp.montant_taxe as montant_du,
case case
when cca.parcelle_id is not null then true when cca.parcelle_id is not null then true
else false else false
@@ -123,8 +123,6 @@ FROM impositions_tfu imp
LEFT JOIN structure st LEFT JOIN structure st
ON st.id = cca.structure_id ON st.id = cca.structure_id
where dimp.personne_id is not null where dimp.personne_id is not null
order by exo.annee,dimp.parcelle_id,dimp.nature_impot, dimp.montant_taxe-coalesce(dimp.acompte,0)-coalesce(dimp.retenu_irf,0) desc ;
and dimp.ifu='208558';

View File

@@ -410,12 +410,10 @@ BEGIN
batiment_id, batiment_id,
unite_logement_id, unite_logement_id,
superficie_au_sol_loue, superficie_au_sol_loue,
personne_id, personne_id
acompte,
retenu_irf
) )
SELECT SELECT
v_annee-1, v_annee,
d.code, d.code,
d.nom, d.nom,
c.code, c.code,
@@ -530,9 +528,7 @@ BEGIN
b.id, b.id,
NULL, NULL,
eb.superficie_louee, eb.superficie_louee,
ep.personne_id, ep.personne_id
tac.montant_acompte,
trirf.montant_rirf
FROM parcelle p FROM parcelle p
-- Dernière enquête parcelle -- Dernière enquête parcelle
@@ -618,46 +614,10 @@ BEGIN
ORDER BY br.quartier_id DESC NULLS LAST ORDER BY br.quartier_id DESC NULLS LAST
LIMIT 1 LIMIT 1
) brb ON TRUE ) brb ON TRUE
LEFT JOIN ( ----------Calcul cumul acompte
select epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice,
sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa
where epa.exercice=v_annee-1
and epa.id_impot_nature='IRF'
group by epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice
)tac on tac.ifu=pers.ifu and tac.r_quartier=q.code and tac.qip_ilot=p.i and tac.qip_parcelle=p.p
LEFT JOIN ( ----------Calcul cumul retenu irf
select epr.ifu_retenue,
epr.r_quartier,
epr.qip_ilot,
epr.qip_parcelle,
epr.exercice,
sum(epr.montant_payer) as montant_rirf
from epaiement_retenu epr
where epr.exercice=v_annee-1
group by epr.ifu_retenue,
epr.r_quartier,
epr.qip_ilot,
epr.qip_parcelle,
epr.exercice
)trirf on trirf.ifu_retenue=pers.ifu and trirf.r_quartier=q.code and trirf.qip_ilot=p.i and trirf.qip_parcelle=p.p
WHERE p.batie = TRUE WHERE p.batie = TRUE
AND ul_filter.batiment_id IS NULL -- anti-join : pas d'unité logement AND ul_filter.batiment_id IS NULL -- anti-join : pas d'unité logement
AND st.id = v_structure_id AND st.id = v_structure_id
AND NOT EXISTS(select 1 from donnees_imposition_tfu dimptfu
where dimptfu.annee=v_annee-1
AND dimptfu.nature_impot='IRF'
AND dimptfu.batiment_id=b.id)
ON CONFLICT DO NOTHING; ON CONFLICT DO NOTHING;
@@ -667,5 +627,3 @@ BEGIN
END; END;
$$; $$;

View File

@@ -125,12 +125,10 @@ BEGIN
batiment_id, batiment_id,
unite_logement_id, unite_logement_id,
superficie_au_sol_loue, superficie_au_sol_loue,
personne_id, personne_id
acompte,
retenu_irf
) )
SELECT SELECT
v_annee-1, v_annee,
d.code, d.code,
d.nom, d.nom,
c.code, c.code,
@@ -245,10 +243,9 @@ BEGIN
b.id, b.id,
NULL, NULL,
eb.superficie_louee, eb.superficie_louee,
ep.personne_id, ep.personne_id
tac.montant_acompte,
trirf.montant_rirf
FROM parcelle p FROM parcelle p
-- Dernière enquête parcelle -- Dernière enquête parcelle
LEFT JOIN LATERAL ( LEFT JOIN LATERAL (
SELECT SELECT
@@ -332,46 +329,14 @@ BEGIN
ORDER BY br.quartier_id DESC NULLS LAST ORDER BY br.quartier_id DESC NULLS LAST
LIMIT 1 LIMIT 1
) brb ON TRUE ) brb ON TRUE
LEFT JOIN ( ----------Calcul cumul acompte
select epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice,
sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa
where epa.exercice=v_annee-1
and epa.id_impot_nature='IRF'
group by epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice
)tac on tac.ifu=pers.ifu and tac.r_quartier=q.code and tac.qip_ilot=p.i and tac.qip_parcelle=p.p
LEFT JOIN ( ----------Calcul cumul retenu irf
select epr.ifu_retenue,
epr.r_quartier,
epr.qip_ilot,
epr.qip_parcelle,
epr.exercice,
sum(epr.montant_payer) as montant_rirf
from epaiement_retenu epr
where epr.exercice=v_annee-1
group by epr.ifu_retenue,
epr.r_quartier,
epr.qip_ilot,
epr.qip_parcelle,
epr.exercice
)trirf on trirf.ifu_retenue=pers.ifu and trirf.r_quartier=q.code and trirf.qip_ilot=p.i and trirf.qip_parcelle=p.p
WHERE p.batie = TRUE WHERE p.batie = TRUE
AND ul_filter.batiment_id IS NULL -- anti-join : pas d'unité logement AND ul_filter.batiment_id IS NULL -- anti-join : pas d'unité logement
AND st.id = v_structure_id AND st.id = v_structure_id
AND p.id=p_parcelle_id AND p.id=p_parcelle_id
AND NOT EXISTS(select 1 from donnees_imposition_tfu dimptfu AND NOT EXISTS(select 1 from donnees_imposition_tfu dimptfu
where dimptfu.parcelle_id=p_parcelle_id where dimptfu.parcelle_id=p_parcelle_id
AND dimptfu.annee=v_annee-1 AND dimptfu.annee=v_annee
AND dimptfu.nature_impot='IRF' AND dimptfu.nature_impot='IRF'
AND dimptfu.batiment_id=b.id) AND dimptfu.batiment_id=b.id)

View File

@@ -447,9 +447,7 @@ BEGIN
batiment_id, batiment_id,
unite_logement_id, unite_logement_id,
superficie_au_sol_loue, superficie_au_sol_loue,
personne_id, personne_id
acompte,
retenu_irf
) )
SELECT SELECT
v_annee, v_annee,
@@ -541,9 +539,8 @@ BEGIN
b.id, b.id,
ul.id, ul.id,
eul.superficie_louee, eul.superficie_louee,
eul.personne_id, eul.personne_id
tac.montant_acompte,
trirf.montant_rirf
FROM parcelle p FROM parcelle p
LEFT JOIN LATERAL ( LEFT JOIN LATERAL (
@@ -631,39 +628,7 @@ BEGIN
ORDER BY br.quartier_id DESC NULLS LAST ORDER BY br.quartier_id DESC NULLS LAST
LIMIT 1 LIMIT 1
) brb ON TRUE ) brb ON TRUE
LEFT JOIN ( ----------Calcul cumul acompte
select epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice,
sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa
where epa.exercice=v_annee-1
and epa.id_impot_nature='IRF'
group by epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice
)tac on tac.ifu=eul.ifu and tac.r_quartier=q.code and tac.qip_ilot=p.i and tac.qip_parcelle=p.p
LEFT JOIN ( ----------Calcul cumul retenu irf
select epr.ifu_retenue,
epr.r_quartier,
epr.qip_ilot,
epr.qip_parcelle,
epr.exercice,
sum(epr.montant_payer) as montant_rirf
from epaiement_retenu epr
where epr.exercice=v_annee-1
group by epr.ifu_retenue,
epr.r_quartier,
epr.qip_ilot,
epr.qip_parcelle,
epr.exercice
)trirf on trirf.ifu_retenue=eul.ifu and trirf.r_quartier=q.code and trirf.qip_ilot=p.i and trirf.qip_parcelle=p.p
WHERE p.batie = TRUE WHERE p.batie = TRUE
AND st.id = v_structure_id AND st.id = v_structure_id

View File

@@ -104,9 +104,7 @@ BEGIN
batiment_id, batiment_id,
unite_logement_id, unite_logement_id,
superficie_au_sol_loue, superficie_au_sol_loue,
personne_id, personne_id
acompte,
retenu_irf
) )
SELECT SELECT
v_annee, v_annee,
@@ -198,9 +196,8 @@ BEGIN
b.id, b.id,
ul.id, ul.id,
eul.superficie_louee, eul.superficie_louee,
eul.personne_id, eul.personne_id
tac.montant_acompte,
trirf.montant_rirf
FROM parcelle p FROM parcelle p
LEFT JOIN LATERAL ( LEFT JOIN LATERAL (
@@ -288,39 +285,7 @@ BEGIN
ORDER BY br.quartier_id DESC NULLS LAST ORDER BY br.quartier_id DESC NULLS LAST
LIMIT 1 LIMIT 1
) brb ON TRUE ) brb ON TRUE
LEFT JOIN ( ----------Calcul cumul acompte
select epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice,
sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa
where epa.exercice=v_annee-1
and epa.id_impot_nature='IRF'
group by epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice
)tac on tac.ifu=eul.ifu and tac.r_quartier=q.code and tac.qip_ilot=p.i and tac.qip_parcelle=p.p
LEFT JOIN ( ----------Calcul cumul retenu irf
select epr.ifu_retenue,
epr.r_quartier,
epr.qip_ilot,
epr.qip_parcelle,
epr.exercice,
sum(epr.montant_payer) as montant_rirf
from epaiement_retenu epr
where epr.exercice=v_annee-1
group by epr.ifu_retenue,
epr.r_quartier,
epr.qip_ilot,
epr.qip_parcelle,
epr.exercice
)trirf on trirf.ifu_retenue=eul.ifu and trirf.r_quartier=q.code and trirf.qip_ilot=p.i and trirf.qip_parcelle=p.p
WHERE p.batie = TRUE WHERE p.batie = TRUE
AND st.id = v_structure_id AND st.id = v_structure_id
AND p.id=p_parcelle_id AND p.id=p_parcelle_id

View File

@@ -128,8 +128,7 @@ BEGIN
unite_logement_id, unite_logement_id,
personne_id, personne_id,
nombre_ulog, nombre_ulog,
nombre_bat, nombre_bat
acompte
) )
SELECT SELECT
v_annee, v_annee,
@@ -363,8 +362,7 @@ BEGIN
where ulog.batiment_id= b.id), where ulog.batiment_id= b.id),
(select count(*) (select count(*)
from batiment bat from batiment bat
where bat.parcelle_id= p.id), where bat.parcelle_id= p.id)
tac.montant_acompte
FROM parcelle p FROM parcelle p
-- Dernière enquête parcelle -- Dernière enquête parcelle
LEFT JOIN LATERAL ( LEFT JOIN LATERAL (
@@ -446,24 +444,7 @@ BEGIN
ORDER BY br.quartier_id DESC NULLS LAST ORDER BY br.quartier_id DESC NULLS LAST
LIMIT 1 LIMIT 1
) brb ON TRUE ) brb ON TRUE
LEFT JOIN ( ----------Calcul cumul acompte
select epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice,
sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa
where epa.exercice=v_annee
and epa.id_impot_nature='FB'
group by epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice
)tac on tac.ifu=pers.ifu and tac.r_quartier=q.code and tac.qip_ilot=p.i and tac.qip_parcelle=p.p
WHERE p.batie = TRUE WHERE p.batie = TRUE
--AND ul_filter.batiment_id IS NULL -- anti-join : pas d'unité logement --AND ul_filter.batiment_id IS NULL -- anti-join : pas d'unité logement
AND st.id = v_structure_id ; AND st.id = v_structure_id ;

View File

@@ -129,8 +129,7 @@ BEGIN
unite_logement_id, unite_logement_id,
personne_id, personne_id,
nombre_ulog, nombre_ulog,
nombre_bat, nombre_bat
acompte
) )
SELECT SELECT
v_annee, v_annee,
@@ -364,8 +363,7 @@ BEGIN
where ulog.batiment_id= b.id), where ulog.batiment_id= b.id),
(select count(*) (select count(*)
from batiment bat from batiment bat
where bat.parcelle_id= p.id), where bat.parcelle_id= p.id)
tac.montant_acompte
FROM parcelle p FROM parcelle p
-- Dernière enquête parcelle -- Dernière enquête parcelle
LEFT JOIN LATERAL ( LEFT JOIN LATERAL (
@@ -447,24 +445,7 @@ BEGIN
ORDER BY br.quartier_id DESC NULLS LAST ORDER BY br.quartier_id DESC NULLS LAST
LIMIT 1 LIMIT 1
) brb ON TRUE ) brb ON TRUE
LEFT JOIN ( ----------Calcul cumul acompte
select epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice,
sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa
where epa.exercice=v_annee
and epa.id_impot_nature='FB'
group by epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice
)tac on tac.ifu=pers.ifu and tac.r_quartier=q.code and tac.qip_ilot=p.i and tac.qip_parcelle=p.p
WHERE p.batie = TRUE WHERE p.batie = TRUE
--AND ul_filter.batiment_id IS NULL -- anti-join : pas d'unité logement --AND ul_filter.batiment_id IS NULL -- anti-join : pas d'unité logement
AND st.id = v_structure_id AND st.id = v_structure_id

View File

@@ -150,8 +150,7 @@ BEGIN
taux_tfu, taux_tfu,
parcelle_id, parcelle_id,
batiment_id, batiment_id,
unite_logement_id, unite_logement_id
acompte
) )
SELECT SELECT
v_annee, v_annee,
@@ -301,8 +300,8 @@ BEGIN
v_taux_tfu, v_taux_tfu,
p.id, p.id,
b.id, b.id,
ul.id, ul.id
tac.montant_acompte
FROM parcelle p FROM parcelle p
-- Dernière enquête parcelle -- Dernière enquête parcelle
LEFT JOIN LATERAL ( LEFT JOIN LATERAL (
@@ -424,24 +423,7 @@ BEGIN
ORDER BY br.quartier_id DESC NULLS LAST ORDER BY br.quartier_id DESC NULLS LAST
LIMIT 1 LIMIT 1
) brb ON TRUE ) brb ON TRUE
LEFT JOIN ( ----------Calcul cumul acompte
select epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice,
sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa
where epa.exercice=v_annee
and epa.id_impot_nature='FB'
group by epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice
)tac on tac.ifu=eul.ifu and tac.r_quartier=q.code and tac.qip_ilot=p.i and tac.qip_parcelle=p.p
WHERE p.batie = TRUE WHERE p.batie = TRUE
AND EXISTS ( AND EXISTS (
SELECT 1 SELECT 1

View File

@@ -151,8 +151,7 @@ BEGIN
taux_tfu, taux_tfu,
parcelle_id, parcelle_id,
batiment_id, batiment_id,
unite_logement_id, unite_logement_id
acompte
) )
SELECT SELECT
v_annee, v_annee,
@@ -302,8 +301,8 @@ BEGIN
v_taux_tfu, v_taux_tfu,
p.id, p.id,
b.id, b.id,
ul.id, ul.id
tac.montant_acompte
FROM parcelle p FROM parcelle p
-- Dernière enquête parcelle -- Dernière enquête parcelle
LEFT JOIN LATERAL ( LEFT JOIN LATERAL (
@@ -425,24 +424,7 @@ BEGIN
ORDER BY br.quartier_id DESC NULLS LAST ORDER BY br.quartier_id DESC NULLS LAST
LIMIT 1 LIMIT 1
) brb ON TRUE ) brb ON TRUE
LEFT JOIN ( ----------Calcul cumul acompte
select epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice,
sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa
where epa.exercice=v_annee
and epa.id_impot_nature='FB'
group by epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice
)tac on tac.ifu=eul.ifu and tac.r_quartier=q.code and tac.qip_ilot=p.i and tac.qip_parcelle=p.p
WHERE p.batie = TRUE WHERE p.batie = TRUE
AND EXISTS ( AND EXISTS (
SELECT 1 SELECT 1

View File

@@ -230,8 +230,7 @@ BEGIN
valeur_admin_parcelle_nb_metre_carre, valeur_admin_parcelle_nb_metre_carre,
montant_taxe, montant_taxe,
parcelle_id, parcelle_id,
personne_id, personne_id
acompte
) )
SELECT SELECT
v_annee, v_annee,
@@ -291,8 +290,7 @@ BEGIN
ELSE brnb.valeur_administrative * brnb.taux / 100 ELSE brnb.valeur_administrative * brnb.taux / 100
END, END,
p.id, p.id,
ep.personne_id, ep.personne_id
tac.montant_acompte
FROM parcelle p FROM parcelle p
LEFT JOIN ( LEFT JOIN (
SELECT DISTINCT ON (parcelle_id) SELECT DISTINCT ON (parcelle_id)
@@ -334,24 +332,7 @@ BEGIN
LEFT JOIN barem_rfu_non_bati brnb LEFT JOIN barem_rfu_non_bati brnb
ON (brnb.commune_id = c.id AND brnb.zone_rfu_id = ep.zone_rfu_id) ON (brnb.commune_id = c.id AND brnb.zone_rfu_id = ep.zone_rfu_id)
LEFT JOIN ( ----------Calcul cumul acompte
select epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice,
sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa
where epa.exercice=v_annee
and epa.id_impot_nature='FNB'
group by epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice
)tac on tac.ifu=pers.ifu and tac.r_quartier=q.code and tac.qip_ilot=p.i and tac.qip_parcelle=p.p
WHERE p.batie = false WHERE p.batie = false
AND st.id = v_structure_id AND st.id = v_structure_id

View File

@@ -68,8 +68,7 @@ BEGIN
valeur_admin_parcelle_nb_metre_carre, valeur_admin_parcelle_nb_metre_carre,
montant_taxe, montant_taxe,
parcelle_id, parcelle_id,
personne_id, personne_id
acompte ---champ pour cumul acompte
) )
SELECT SELECT
v_annee, v_annee,
@@ -129,8 +128,7 @@ BEGIN
ELSE brnb.valeur_administrative * brnb.taux / 100 ELSE brnb.valeur_administrative * brnb.taux / 100
END, END,
p.id, p.id,
ep.personne_id, ep.personne_id
tac.montant_acompte ---valeur pour cumul acompte
FROM parcelle p FROM parcelle p
LEFT JOIN ( LEFT JOIN (
SELECT DISTINCT ON (parcelle_id) SELECT DISTINCT ON (parcelle_id)
@@ -172,24 +170,7 @@ BEGIN
LEFT JOIN barem_rfu_non_bati brnb LEFT JOIN barem_rfu_non_bati brnb
ON (brnb.commune_id = c.id AND brnb.zone_rfu_id = ep.zone_rfu_id) ON (brnb.commune_id = c.id AND brnb.zone_rfu_id = ep.zone_rfu_id)
LEFT JOIN ( ----------Calcul cumul acompte
select epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice,
sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa
where epa.exercice=v_annee
and epa.id_impot_nature='FNB'
group by epa.ifu,
epa.r_quartier,
epa.qip_ilot,
epa.qip_parcelle,
epa.id_impot_nature,
epa.exercice
)tac on tac.ifu=pers.ifu and tac.r_quartier=q.code and tac.qip_ilot=p.i and tac.qip_parcelle=p.p
WHERE p.batie = false WHERE p.batie = false
AND st.id = v_structure_id AND st.id = v_structure_id
AND p.id=p_parcelle_id AND p.id=p_parcelle_id
@@ -207,4 +188,3 @@ BEGIN
END; END;
$$; $$;

View File

@@ -1,95 +0,0 @@
SELECT dblink_connect(
'connexion_rfu',
'host=10.4.6.103 port=5432 dbname=rfu user=postgres password=Rfu@dm1N2@25TeMp0'
);
--SELECT dblink_disconnect('connexion_rfu');
--SELECT pg_size_pretty(pg_database_size('rfu'));
CREATE OR REPLACE PROCEDURE public.import_assignation_centre_personne_from_rfu_cotonou()
LANGUAGE plpgsql
AS $procedure$
BEGIN
INSERT INTO public.commune_centre_assignation (
nc,
ifu,
commune_id,
structure_id,
personne_id,
parcelle_id,
created_at,
created_by,
deleted,
updated_at,
updated_by,
source
)
SELECT
c.n0_contrib,
c.ifu,
70,
case rcdi
when 'A' then 61
when 'B' then 62
when 'C' then 63
when 'D' then 64
else null
end,
pers.id,
parc.id,
now(),
NULL::bigint,
false,
now(),
NULL::bigint,
'RFU'
FROM dblink(
'connexion_rfu',
$db$
SELECT distinct on (ifu,rcdi)
trim(ifu),
trim(n0_contrib),
trim(rcdi),
trim(quartier_c),
trim(ilot_c),
trim(parcel_c)
FROM stemichel.contrib
order by ifu,rcdi
$db$
) AS c (
ifu varchar,
n0_contrib varchar,
rcdi varchar,
quartier_c varchar,
ilot_c varchar,
parcel_c varchar
)
LEFT JOIN personne pers on trim(pers.ifu)=trim(c.ifu)
LEFT JOIN parcelle parc on (trim(parc.q) = trim(c.quartier_c)
and trim(parc.i) = trim(c.ilot_c)
and trim(parc.p) = trim(c.parcel_c))
WHERE NOT EXISTS (
SELECT 1
FROM public.commune_centre_assignation cca
WHERE cca.personne_id = pers.id
and cca.structure_id = case trim(c.rcdi)
when 'A' then 61
when 'B' then 62
when 'C' then 63
when 'D' then 64
else null
end
and cca.commune_id = 70
)
ON CONFLICT (structure_id, commune_id, personne_id) DO NOTHING;
END;
$procedure$;
call import_assignation_centre_personne_from_rfu_cotonou();
--delete from commune_centre_assignation;
--select * from commune_centre_assignation;

View File

@@ -1,287 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_batiment_and_enquetebati_from_rfu(nombreLimit integer)
LANGUAGE plpgsql
AS $$
DECLARE
l_count numeric := 0;
batiment_rfu record;
l_batiment_id_parent bigint;
l_parcelle_id_parent bigint ;
BEGIN
FOR batiment_rfu IN (
SELECT
c.n0bat,
--dtconst,
CASE
WHEN c.dtconst IS NULL OR c.dtconst = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.dtconst !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.dtconst, 'YYYYMMDD'), 'YYYYMMDD') <> c.dtconst THEN NULL
ELSE to_date(c.dtconst, 'YYYYMMDD')
end as dtconst,
c.quartier,
c.n0_ilot,
c.n0_parcel,
--c.surfsol,
CASE
WHEN replace(trim(c.surfsol), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.surfsol, ',', '.')::numeric
end as surfsol,
--c.surfacelo,
CASE
WHEN replace(trim(c.surfacelo), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.surfacelo, ',', '.')::numeric
end as surfacelo,
--c.vllcalcule,
CASE
WHEN replace(trim(c.vllcalcule), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.vllcalcule, ',', '.')::numeric
end as vllcalcule,
--c.bail,
CASE
WHEN replace(trim(c.bail), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.bail, ',', '.')::numeric
end as bail,
--c.valloest,
CASE
WHEN replace(trim(c.valloest), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.valloest, ',', '.')::numeric
end as valloest,
--c.nbetage,
CASE
WHEN replace(trim(c.nbetage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbetage, ',', '.')::numeric
end as nbetage,
--c.vlcalcule,
CASE
WHEN replace(trim(c.vlcalcule), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.vlcalcule, ',', '.')::numeric
end as vlcalcule,
--c.utilisat,
CASE
WHEN replace(trim(c.utilisat), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.utilisat, ',', '.')::numeric
end as utilisat,
--c.finexempt,
CASE
WHEN c.finexempt IS NULL OR c.finexempt = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.finexempt !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.finexempt, 'YYYYMMDD'), 'YYYYMMDD') <> c.finexempt THEN NULL
ELSE to_date(c.finexempt, 'YYYYMMDD')
end as finexempt,
--c.nbunitlo,
CASE
WHEN replace(trim(c.nbunitlo), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbunitlo, ',', '.')::numeric
end as nbunitlo,
--c.toit
CASE
WHEN replace(trim(c.toit), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.toit, ',', '.')::numeric
end as toit,
--nbhabit,
CASE
WHEN replace(trim(c.nbhabit), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbhabit, ',', '.')::numeric
end as nbhabit,
--nbmenage,
CASE
WHEN replace(trim(c.nbmenage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbmenage, ',', '.')::numeric
end as nbmenage,
--nbmois,
CASE
WHEN replace(trim(c.nbmois), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbmois, ',', '.')::numeric
end as nbmois,
--electric,
CASE
WHEN trim(c.electric)='Non'
THEN false
else
true
end as electric,
--eau,
CASE
WHEN trim(c.eau)='Non'
THEN false
else
true
end as eau,
--nbpiece,
CASE
WHEN replace(trim(c.nbpiece), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbpiece, ',', '.')::numeric
end as nbpiece,
--nbunite
CASE
WHEN replace(trim(c.nbunite), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbunite, ',', '.')::numeric
end as nbunite,
CASE
WHEN c.mdate IS NULL OR c.mdate = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.mdate !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.mdate, 'YYYYMMDD'), 'YYYYMMDD') <> c.mdate THEN NULL
ELSE to_date(c.mdate, 'YYYYMMDD')
end as mdate,
--c.murs,
CASE
WHEN replace(trim(c.murs), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.murs, ',', '.')::numeric
end as murs,
--standing
CASE
WHEN replace(trim(c.standing), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.standing, ',', '.')::numeric
end as standing
FROM dblink(
'connexion_rfu',
$db$
SELECT
b.n0bat,
b.dtconst,
b.quartier,
b.n0_ilot,
b.n0_parcel,
b.surfsol,
b.surfacelo,
b.vllcalcule,
b.bail,
b.valloest,
b.nbetage,
b.vlcalcule,
b.utilisat,
b.finexempt,
b.nbunitlo,
b.toit,
b.nbhabit,
b.nbmenage,
b.nbmois,
b.electric,
b.eau,
b.nbpiece,
b.nbunite,
b.mdate,
b.murs,
b.standing
FROM stemichel.batiment b
$db$
) AS c (
n0bat varchar,
dtconst varchar,
quartier varchar,
n0_ilot varchar,
n0_parcel varchar,
surfsol varchar,
surfacelo varchar,
vllcalcule varchar,
bail varchar,
valloest varchar,
nbetage varchar,
vlcalcule varchar,
utilisat varchar,
finexempt varchar,
nbunitlo varchar,
toit varchar,
nbhabit varchar,
nbmenage varchar,
nbmois varchar,
electric varchar,
eau varchar,
nbpiece varchar,
nbunite varchar,
mdate varchar,
murs varchar,
standing varchar
)
WHERE NOT EXISTS (
SELECT 1
FROM public.batiment b
WHERE b.code =
trim(c.quartier)||'-'||trim(c.n0_ilot)||'-'||trim(c.n0_parcel)||'-'||trim(c.n0bat)
)
limit nombreLimit
)
LOOP
-- Récupération ID parcelle locale
SELECT p.id
INTO l_parcelle_id_parent
FROM public.parcelle p
WHERE p.numero_parcelle =
trim(batiment_rfu.quartier)||'-'||trim(batiment_rfu.n0_ilot)||'-'||trim(batiment_rfu.n0_parcel)
LIMIT 1;
-- Insertion bâtiment local
INSERT INTO public.batiment (
created_at,
created_by,
deleted,
updated_at,
updated_by,
code,
nub,
date_construction,
parcelle_id,
source,
superficie_au_sol,
superficie_louee,
categorie_batiment_id,
montant_locatif_annuel_calcule,
montant_locatif_annuel_declare,
montant_locatif_annuel_estime,
nombre_etage,
valeur_batiment_calcule,
usage_id,
date_fin_exemption,
nbre_unite_logement,
id_toit_rfu
)
VALUES (
now(),
35,
false,
now(),
35,
trim(batiment_rfu.quartier)||'-'||trim(batiment_rfu.n0_ilot)||'-'||trim(batiment_rfu.n0_parcel)||'-'||trim(batiment_rfu.n0bat),
batiment_rfu.n0bat,
batiment_rfu.dtconst,
l_parcelle_id_parent,
'RFU',
batiment_rfu.surfsol,
batiment_rfu.surfacelo,
ProcedureRecupCategorieRFU(batiment_rfu.nbetage::integer,batiment_rfu.toit::integer),
batiment_rfu.vllcalcule,
batiment_rfu.bail,
batiment_rfu.valloest,
batiment_rfu.nbetage,
batiment_rfu.vlcalcule,
--------- batiment_rfu.utilisat,
CASE batiment_rfu.utilisat
WHEN 1 THEN 8
WHEN 2 THEN 14
WHEN 3 THEN 9
END,
batiment_rfu.finexempt,
batiment_rfu.nbunitlo,
batiment_rfu.toit
)
RETURNING id INTO l_batiment_id_parent ;
call public.import_enquetebati_from_rfu_cipe(batiment_rfu,l_batiment_id_parent);
l_count := l_count + 1;
END LOOP;
RAISE NOTICE 'Nombre de bâtiments insérés : %', l_count;
END;
$$;

View File

@@ -1,158 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_enquetebati_from_rfu_cipe(
IN batiment_rfu record,
IN batiment_id_param numeric
)
LANGUAGE plpgsql
AS $procedure$
DECLARE
enquete_batiment_id_parent bigint;
BEGIN
INSERT INTO enquete_batiment (
created_at,
created_by,
deleted,
updated_at,
updated_by,
date_fin_excemption,
nbre_habitant,
nbre_menage,
nbre_mois_location,
nbre_unite_location,
sbee,
soneb,
batiment_id,
personne_id,
user_id,
montant_locatif_annuel_declare,
nbre_etage,
source,
date_enquete,
observation,
superficie_au_sol,
superficie_louee,
statut_enquete,
categorie_batiment_id,
montant_locatif_annuel_calcule,
usage_id,
montant_locatif_annuel_estime,
nbre_piece,
nbre_unite_logement,
valeur_batiment_calcule,
nbre_lot_unite
) select
now(),
35,
false,
now(),
35,
batiment_rfu.finexempt,
batiment_rfu.nbhabit,
batiment_rfu.nbmenage,
batiment_rfu.nbmois,
batiment_rfu.nbunitlo,
batiment_rfu.electric,
batiment_rfu.eau,
batiment_id_param,
e.personne_id,
35,
batiment_rfu.bail,
batiment_rfu.nbetage,
'RFU',
batiment_rfu.mdate,
'MIGRATION',
batiment_rfu.surfsol,
batiment_rfu.surfacelo,
'CLOTURE',
ProcedureRecupCategorieRFU(batiment_rfu.nbetage::integer,batiment_rfu.toit::integer),
batiment_rfu.vllcalcule,
--batiment_rfu.utilisat,
CASE batiment_rfu.utilisat
WHEN 1 THEN 8
WHEN 2 THEN 14
WHEN 3 THEN 9
end,
batiment_rfu.valloest,
batiment_rfu.nbpiece,
batiment_rfu.nbunite,
batiment_rfu.vlcalcule,
batiment_rfu.nbunitlo
from batiment b
left join parcelle p on p.id=b.parcelle_id
left join enquete e on e.parcelle_id=p.id
where b.id = batiment_id_param
and not exists (
select 1
from enquete_batiment eb
where eb.batiment_id = b.id
)
RETURNING id INTO enquete_batiment_id_parent ;
----------MAJ Caractéristique parcelle
INSERT INTO caracteristique_batiment (
created_by,
created_at,
updated_by,
updated_at,
deleted,
caracteristique_id,
enquete_batiment_id
)
SELECT 35, now(), 35, now(),false,
CASE batiment_rfu.toit
WHEN 1 THEN 55
WHEN 2 THEN 56
WHEN 3 THEN 57
WHEN 4 THEN 58
WHEN 5 THEN 59
WHEN 6 THEN 60
END,
enquete_batiment_id_parent
WHERE batiment_rfu.toit IS NOT NULL
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE batiment_rfu.murs
WHEN 1 THEN 49
WHEN 2 THEN 50
WHEN 3 THEN 51
WHEN 4 THEN 52
WHEN 5 THEN 53
else
54
END,
enquete_batiment_id_parent
WHERE batiment_rfu.murs IS NOT null
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE batiment_rfu.standing
WHEN 1 THEN 81
WHEN 2 THEN 82
WHEN 3 THEN 83
WHEN 4 THEN 84
END,
enquete_batiment_id_parent
WHERE batiment_rfu.standing IS NOT null
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE batiment_rfu.utilisat
WHEN 1 THEN 35
WHEN 2 THEN 36
WHEN 3 THEN 37
END,
enquete_batiment_id_parent
WHERE batiment_rfu.utilisat IS NOT null;
------MAJ Exercice
UPDATE enquete_batiment eb
SET exercice_id = e.id
FROM exercice e
WHERE e.annee = 2025
AND eb.id = enquete_batiment_id_parent;
END;
$procedure$;

View File

@@ -1,153 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_enqueteparc_from_rfu_cipe(
IN parcelle_rfu record,
IN p_parcelle_id numeric
)
LANGUAGE plpgsql
AS $procedure$
DECLARE
enquete_id_parent bigint;
BEGIN
INSERT INTO enquete (
created_at,
created_by,
deleted,
updated_at,
updated_by,
date_enquete,
litige,
parcelle_id,
user_id,
date_finalisation,
date_synchronisation,
date_validation,
status_enquete,
synchronise,
code_parcelle,
nbre_batiment,
nbre_co_proprietaire,
nom_rue,
num_enter_parcelle,
num_rue,
superficie,
equipe_id,
zone_rfu_id,
campagne_id,
origine_enquete,
nc_proprietaire,
source
) select
now(),
35,
false,
now(),
35,
now(),
false,
p_parcelle_id,
35,
now(),
now(),
now(),
'CLOTURE',
true,
parcelle_rfu.numero_parcelle,
CASE
WHEN trim(parcelle_rfu.nb_bat) ~ '^[0-9]+$'
THEN parcelle_rfu.nb_bat::integer
ELSE NULL
END,
CASE
WHEN trim(parcelle_rfu.nb_prop) ~ '^[0-9]+$'
THEN parcelle_rfu.nb_prop::integer
ELSE NULL
END,
parcelle_rfu.numero_rue,
parcelle_rfu.num_entree_parcelle,
parcelle_rfu.numero_rue,
CASE
WHEN trim(parcelle_rfu.surface) ~ '^[0-9]+$'
THEN parcelle_rfu.surface::float
ELSE NULL
END,
1,
CASE parcelle_rfu.zones
WHEN '1' THEN 1
WHEN '2' THEN 2
WHEN '3' THEN 3
WHEN '4' THEN 4
ELSE NULL
END,
1,
'RFU',
parcelle_rfu.n0_contrib,
'RFU'
--from parcelle p
where not exists (
select 1
from enquete e
where e.parcelle_id= p_parcelle_id
)
RETURNING id INTO enquete_id_parent ;
----------MAJ Caractéristique parcelle
INSERT INTO caracteristique_parcelle (
created_by,
created_at,
updated_by,
updated_at,
deleted,
caracteristique_id,
enquete_id
)
SELECT 35, now(), 35, now(), false,
CASE parcelle_rfu.acces
WHEN '1' THEN 31
WHEN '2' THEN 32
WHEN '3' THEN 33
WHEN '4' THEN 34
END,
enquete_id_parent
WHERE parcelle_rfu.acces IS NOT NULL
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE parcelle_rfu.cloture
WHEN '1' THEN 28
WHEN '2' THEN 29
WHEN '3' THEN 30
END,
enquete_id_parent
WHERE parcelle_rfu.cloture IS NOT NULL;
------MAJ Exercice
UPDATE enquete q
SET exercice_id = e.id
FROM exercice e
WHERE e.annee = 2025
AND q.id = enquete_id_parent;
------MAJ prietaire
UPDATE enquete q
SET personne_id = p.id,
proprietaire_id = p.id,
nom_proprietaire_parcelle = coalesce (trim(p.raison_sociale), trim(p.nom) || ' '|| trim(p.prenom) )
FROM personne p
WHERE p.nc = parcelle_rfu.n0_contrib
AND q.id = enquete_id_parent;
--quartier_id --commune_id --departement_id --arrondissement_id
UPDATE enquete e
SET quartier_id = q.id,
commune_id=c.id,
departement_id=c.departement_id,
arrondissement_id= a.id
FROM parcelle p
inner join quartier q on q.id = p.quartier_id
inner join arrondissement a on a.id = q.arrondissement_id
inner join commune c on c.id = a.commune_id
WHERE p.id = p_parcelle_id
AND e.id = enquete_id_parent;
END;
$procedure$;

View File

@@ -1,156 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_enqueteUnitLog_from_rfu_cipe(
IN uniteLogement_rfu record,
IN uniteLogement_id_param numeric,
IN l_personne_id_parent numeric
)
LANGUAGE plpgsql
AS $procedure$
DECLARE
enquete_uniteLogement_id_parent bigint;
BEGIN
INSERT INTO enquete_unite_logement (
created_at,
created_by,
deleted,
updated_at,
updated_by,
en_location,
montant_locatif_annuel_declare,
nbre_habitant,
nbre_menage,
nbre_piece,
sbee,
soneb,
personne_id,
unite_logement_id,
user_id,
nbre_mois_location,
valeur_unite_logement_estime,
source,
date_enquete,
observation,
date_fin_exemption,
superficie_au_sol,
superficie_louee,
statut_enquete,
categorie_batiment_id,
montant_locatif_annuel_calcule,
montant_mensuel_location,
usage_id,
valeur_unite_logement_calcule
)select
now(),
35,
false,
now(),
35,
case
when uniteLogement_rfu.nbmois=0 then false
else true
end,
uniteLogement_rfu.montmenl*12,
uniteLogement_rfu.nbhabit,
uniteLogement_rfu.nbmenage,
uniteLogement_rfu.nbpiece,
uniteLogement_rfu.electric,
uniteLogement_rfu.eau,
l_personne_id_parent,
uniteLogement_id_param,
35,
uniteLogement_rfu.nbmois,
uniteLogement_rfu.vlcalcule,
'RFU',
uniteLogement_rfu.mdate,
'MIGRATION',
uniteLogement_rfu.finexempt,
uniteLogement_rfu.surfsol,
uniteLogement_rfu.surfacelo,
'CLOTURE',
ProcedureRecupCategorieRFU(uniteLogement_rfu.n0etage::integer,uniteLogement_rfu.toit::integer),
uniteLogement_rfu.vllcalcule,
uniteLogement_rfu.montmenl,
CASE uniteLogement_rfu.utilisat
WHEN 1 THEN 8
WHEN 2 THEN 14
WHEN 3 THEN 9
END,
uniteLogement_rfu.vlcalcule
from unite_logement ul
where ul.id = uniteLogement_id_param
and not exists (
select 1
from enquete_unite_logement eul
where eul.unite_logement_id = ul.id
)
RETURNING id INTO enquete_uniteLogement_id_parent ;
----------MAJ Caractéristique Unite de logement
INSERT INTO caracteristique_unite_logement (
created_by,
created_at,
updated_by,
updated_at,
deleted,
caracteristique_id,
enquete_unite_logement_id
)
SELECT 35, now(), 35, now(),false,
CASE uniteLogement_rfu.toit
WHEN 1 THEN 55
WHEN 2 THEN 56
WHEN 3 THEN 57
WHEN 4 THEN 58
WHEN 5 THEN 59
WHEN 6 THEN 60
END,
enquete_uniteLogement_id_parent
WHERE uniteLogement_rfu.toit IS NOT NULL
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE uniteLogement_rfu.murs
WHEN 1 THEN 49
WHEN 2 THEN 50
WHEN 3 THEN 51
WHEN 4 THEN 52
WHEN 5 THEN 53
else
54
END,
enquete_uniteLogement_id_parent
WHERE uniteLogement_rfu.murs IS NOT null
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE uniteLogement_rfu.standing
WHEN 1 THEN 81
WHEN 2 THEN 82
WHEN 3 THEN 83
WHEN 4 THEN 84
END,
enquete_uniteLogement_id_parent
WHERE uniteLogement_rfu.standing IS NOT null
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE uniteLogement_rfu.utilisat
WHEN 1 THEN 35
WHEN 2 THEN 36
WHEN 3 THEN 37
END,
enquete_uniteLogement_id_parent
WHERE uniteLogement_rfu.standing IS NOT null;
------MAJ Exercice
UPDATE enquete_unite_logement eul
SET exercice_id = e.id
FROM exercice e
WHERE e.annee = 2025
AND eul.id = enquete_uniteLogement_id_parent;
END;
$procedure$;

View File

@@ -1,99 +0,0 @@
SELECT dblink_connect(
'connexion_rfu',
'host=10.4.6.103 port=5432 dbname=rfu user=postgres password=Rfu@dm1N2@25TeMp0'
);
CREATE OR REPLACE PROCEDURE public.import_imposition_rfu_cotonou(in exercice varchar(10), in nombreLimit numeric)
LANGUAGE plpgsql
AS $procedure$
DECLARE
l_count numeric := 0;
imposition_rfu record;
l_parcelle_id_parent bigint;
l_code_quartier varchar(20);
BEGIN
FOR imposition_rfu IN (
SELECT FROM dblink(
'connexion_rfu',
$db$
SELECT
i.article ,
i.ifu ,
i.n0_contrib ,
i.denome ,
i.annees ,
i.nature ,
n.libnature ,
i.quartier,
q.libquart ,
i.n0_ilot ,
i.n0_parcel ,
i.nn,
COALESCE(i.montant,0) droit_simple,
COALESCE(i.penalite,0) penalite,
COALESCE(i.majorat,0) majoration,
COALESCE(i.montant,0)+COALESCE(i.penalite,0)+COALESCE(i.majorat,0) total_imposition
FROM stemichel.impotsra i
join agla.nature n on n.nature=i.nature
left join (select distinct
n0_ilot,
quartier,
libquart
from agla.quartier)q on (q.n0_ilot=i.n0_ilot and q.quartier=i.quartier)
-- WHERE i.annees = '2025' or (i.annees ='2024' and trim(i.nature) in ('3N', '4N', 'YN'))
limit 100
$db$
) AS c (
terrain varchar,
n0_ilot varchar,
n0_parcel varchar,
quartier varchar,
hauteur varchar,
rue varchar,
entree varchar,
vlcalcule varchar,
vllcalcule varchar,
)
WHERE NOT EXISTS (
SELECT 1
FROM public.parcelle p
WHERE p.numero_parcelle =
trim(c.quartier)||'-'||trim(c.n0_ilot)||'-'||trim(c.n0_parcel)
) and exists (
select 1
from public.ref_rfu_q_quartier_cotonou rq
where rq.rfu_q = trim(c.quartier)
)
limit nombreLimit
) LOOP
BEGIN
INSERT INTO parcelle (
created_at,
created_by,
deleted,
updated_at,
updated_by,
parcelle_id,
source
)
SELECT
now(),
35,
false,
now(),
35,
parcelle_id,
'RFU'
FROM ref_rfu_q_quartier_cotonou rq
WHERE rq.rfu_q = parcelle_rfu.q
RETURNING id, code_quartier
INTO l_parcelle_id_parent, l_code_quartier;
RAISE NOTICE 'Nombre impositions migrées : %', l_count;
END ;
END LOOP ;
END;
$procedure$;

View File

@@ -1,250 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_parcelle_and_enqueteparc_from_rfu_cipe(in nombreLimit numeric)
LANGUAGE plpgsql
AS $procedure$
DECLARE
l_count numeric := 0;
parcelle_rfu record;
l_parcelle_id_parent bigint;
l_code_quartier varchar(20);
BEGIN
FOR parcelle_rfu IN (
SELECT
trim(quartier)||'-'||trim(n0_ilot)||'-'||trim(n0_parcel) AS numero_parcelle,
terrain,
trim(n0_ilot) AS i,
trim(n0_parcel) AS p,
trim(quartier) AS q,
hauteur,
rue AS numero_rue,
entree AS num_entree_parcelle,
surface,
vlcalcule,
vllcalcule,
loue,
zones,
acces,
cloture,
inonde,
finexempt,
habite,
ordures,
"usage",
wc,
choix,
occupant,
nb_bat,
nb_prop,
nb_log,
nb_unit,
nb_mena,
nb_habit,
nb_act,
nb_contrib,
typeparc,
prixm2ne,
ifu,
n0_contrib,
secteur,
cipe
FROM dblink(
'connexion_rfu',
$db$
SELECT
terrain,
n0_ilot,
n0_parcel,
quartier,
hauteur,
rue,
entree,
vlcalcule,
vllcalcule,
loue,
zones,
acces,
cloture,
inonde,
finexempt,
habite,
ordures,
surface,
"usage",
wc,
choix,
occupant,
nb_bat,
nb_prop,
nb_log,
nb_unit,
nb_mena,
nb_habit,
nb_act,
nb_contrib,
typeparc,
prixm2ne,
ifu,
n0_contrib,
secteur,
cipe
FROM stemichel.parcelle
$db$
) AS c (
terrain varchar,
n0_ilot varchar,
n0_parcel varchar,
quartier varchar,
hauteur varchar,
rue varchar,
entree varchar,
vlcalcule varchar,
vllcalcule varchar,
loue varchar,
zones varchar,
acces varchar,
cloture varchar,
inonde varchar,
finexempt varchar,
habite varchar,
ordures varchar,
surface varchar,
"usage" varchar,
wc varchar,
choix varchar,
occupant varchar,
nb_bat varchar,
nb_prop varchar,
nb_log varchar,
nb_unit varchar,
nb_mena varchar,
nb_habit varchar,
nb_act varchar,
nb_contrib varchar,
typeparc varchar,
prixm2ne varchar,
ifu varchar,
n0_contrib varchar,
secteur varchar,
cipe varchar
)
WHERE NOT EXISTS (
SELECT 1
FROM public.parcelle p
WHERE p.numero_parcelle =
trim(c.quartier)||'-'||trim(c.n0_ilot)||'-'||trim(c.n0_parcel)
) and exists (
select 1
from public.ref_rfu_q_quartier_cotonou rq
where rq.rfu_q = trim(c.quartier)
)
limit nombreLimit
) LOOP
BEGIN
INSERT INTO parcelle (
created_at,
created_by,
deleted,
updated_at,
updated_by,
numero_parcelle,
qip,
type_domaine_id,
i,
p,
q,
code_quartier,
nature_domaine_id,
superficie,
altitude,
num_entree_parcelle,
numero_rue,
usage_id,
source
)
SELECT
now(),
35,
false,
now(),
35,
parcelle_rfu.numero_parcelle,
parcelle_rfu.numero_parcelle,
CASE parcelle_rfu.terrain
WHEN '1' THEN 2
WHEN '2' THEN 5
WHEN '3' THEN 4
END,
parcelle_rfu.i,
parcelle_rfu.p,
parcelle_rfu.q,
rq.code_quartier,
CASE parcelle_rfu.typeparc
WHEN '1' THEN 23
WHEN '2' THEN 27
WHEN '3' THEN 28
WHEN '4' THEN 29
END,
CASE
WHEN replace(trim(parcelle_rfu.surface), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(parcelle_rfu.surface, ',', '.')::numeric
END,
CASE
WHEN replace(trim(parcelle_rfu.hauteur), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(parcelle_rfu.hauteur, ',', '.')::numeric
END,
parcelle_rfu.num_entree_parcelle,
parcelle_rfu.numero_rue,
case parcelle_rfu.usage
WHEN '01' THEN 3
WHEN '02' THEN 4
WHEN '03' THEN 5
WHEN '04' THEN 6
WHEN '05' THEN 7
WHEN '11' THEN 8
WHEN '12' THEN 9
WHEN '13' THEN 10
WHEN '14' THEN 11
WHEN '21' THEN 12
WHEN '22' THEN 13
WHEN '23' THEN 14
WHEN '24' THEN 15
WHEN '25' THEN 16
END,
'RFU'
FROM ref_rfu_q_quartier_cotonou rq
WHERE rq.rfu_q = parcelle_rfu.q
RETURNING id, code_quartier
INTO l_parcelle_id_parent, l_code_quartier;
EXCEPTION WHEN NO_DATA_FOUND THEN
RAISE NOTICE 'Quartier RFU non trouvé pour %', parcelle_rfu.q;
CONTINUE;
--RAISE NOTICE 'Parcelle insérée : %, %', l_parcelle_id_parent, parcelle_rfu.q;
END;
------------------------------appel de enquete_parcelle------------------
CALL import_enqueteparc_from_rfu_cipe(parcelle_rfu, l_parcelle_id_parent);
INSERT INTO secteur_decoupage (
created_at, created_by, deleted, updated_at, updated_by,
date_debut, quartier_id, secteur_id, arrondissement_id, source
)
SELECT
now(), 35, false, now(), 35,
now(), q.id, s.id,a.id, 'RFU'
FROM ref_cipe_secteur_rfu_cotonou rcs
JOIN secteur s ON s.code= rcs.code_secteur
JOIN quartier q ON q.code = l_code_quartier
left join arrondissement a on a.id=q.arrondissement_id
WHERE rcs.cipe = parcelle_rfu.cipe
AND rcs.secteur = parcelle_rfu.secteur
ON CONFLICT (quartier_id, secteur_id) DO NOTHING;
l_count := l_count + 1;
END LOOP;
UPDATE parcelle p
SET quartier_id = q.id
FROM quartier q
WHERE q.code = p.code_quartier;
RAISE NOTICE 'Nombre de parcelles migrées : %', l_count;
END;
$procedure$;

View File

@@ -1,128 +0,0 @@
SELECT dblink_connect(
'connexion_rfu',
'host=10.4.6.103 port=5432 dbname=rfu user=postgres password=Rfu@dm1N2@25TeMp0'
);
--SELECT dblink_disconnect('connexion_rfu');
CREATE OR REPLACE PROCEDURE public.import_personne_from_rfu()
LANGUAGE plpgsql
AS $procedure$
BEGIN
INSERT INTO public.personne (
date_naissance_ou_consti,
ifu,
lieu_naissance,
nom,
prenom,
raison_sociale,
npi,
num_ravip,
tel1,
tel2,
adresse,
created_at,
created_by,
deleted,
updated_at,
updated_by,
nc,
sexe,
profession,
source
)
SELECT
CASE
WHEN c.date_nais IS NULL OR c.date_nais = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.date_nais !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.date_nais, 'YYYYMMDD'), 'YYYYMMDD') <> c.date_nais THEN NULL
ELSE to_date(c.date_nais, 'YYYYMMDD')
END,
c.ifu,
c.lieu_nais,
case
when (trim(c.nom_c)<>'' and trim(c.prenoms_c)<>'') then c.nom_c
when (trim(c.nom_c)='' and trim(c.prenoms_c)='' and trim(c.prenoms)<>'') then c.nom
end as nom,
case
when (trim(c.nom_c)<>'' and trim(c.prenoms_c)<>'') then c.prenoms_c
when (trim(c.nom_c)='' and trim(c.prenoms_c)='' and trim(c.prenoms)<>'') then c.prenoms
end as prenom,
case
when (trim(c.nom_c)='' and trim(c.prenoms_c)='' and trim(c.prenoms)='') then c.nom
when (trim(c.nom_c)<>'' and trim(c.prenoms_c)<>'' and trim(c.prenoms)='') then c.nom
end as raison_sociale,
--c.nom,
NULL::varchar,
NULL::varchar,
--c.prenoms,
c.autradr1,
c.autradr2,
COALESCE(c.quartier_c, '') || '_' ||
COALESCE(c.ilot_c, '') || '_' ||
COALESCE(c.parcel_c, ''),
now(),
NULL::bigint,
false,
now(),
NULL::bigint,
c.n0_contrib,
CASE c.sexe
WHEN '1' THEN 'MASCULIN'
WHEN '2' THEN 'FEMININ'
ELSE NULL
END,
c.profession,
'RFU'
FROM dblink(
'connexion_rfu',
$db$
SELECT
date_nais,
ifu,
lieu_nais,
nom,
prenoms,
nom_c,
prenoms_c,
autradr1,
autradr2,
quartier_c,
ilot_c,
parcel_c,
n0_contrib,
sexe,
profession
FROM stemichel.contrib
-- WHERE ifu IS NOT NULL
$db$
) AS c (
date_nais varchar,
ifu varchar,
lieu_nais varchar,
nom varchar,
prenoms varchar,
nom_c varchar,
prenoms_c varchar,
autradr1 varchar,
autradr2 varchar,
quartier_c varchar,
ilot_c varchar,
parcel_c varchar,
n0_contrib varchar,
sexe varchar,
profession varchar
)
WHERE NOT EXISTS (
SELECT 1
FROM public.personne p
WHERE p.nc = c.n0_contrib
);
END;
$procedure$;

View File

@@ -1,82 +0,0 @@
SELECT dblink_connect(
'connexion_rfu',
'host=10.4.6.103 port=5432 dbname=rfu user=postgres password=Rfu@dm1N2@25TeMp0'
);
--SELECT dblink_disconnect('connexion_rfu');
SELECT dblink_connect(
'connexion_sigibe_lecture',
'host=10.4.80.71 port=5433 dbname=sigibe user=sigibe_lecture password=lec243R6Khsg'
);
CREATE OR REPLACE PROCEDURE public.maj_personne_from_sigibe()
LANGUAGE plpgsql
AS $procedure$
DECLARE
BEGIN
UPDATE personne p
SET
nom = CASE
WHEN s.nom IS NOT NULL THEN s.nom
ELSE p.nom
END,
prenom = CASE
WHEN s.prenom IS NOT NULL THEN s.prenom
ELSE p.prenom
END,
raison_sociale = CASE
WHEN s.id_tiers_type = 'PM'
AND s.l_contribuable IS NOT NULL
THEN s.l_contribuable
ELSE p.raison_sociale
END,
tel1 = s.telephone,
numero_rccm = s.numero_rccm,
date_rccm = CASE
WHEN s.date_rccm IS NOT NULL
AND trim(s.date_rccm) <> ''
THEN s.date_rccm::date
ELSE p.date_rccm
END,
email = s.email,
npi = s.numero_piece_identite,
etat_identification_personne = 'IFU'
FROM (
SELECT *
FROM dblink(
'connexion_sigibe_lecture',
'
SELECT
c.r_contribuable,
t.nom,
t.prenom,
t.id_tiers_type,
t.telephone,
t.numero_rccm,
t.date_rccm,
t.email,
t.numero_piece_identite,
c.l_contribuable
FROM t_contribuable c
JOIN t_tiers t ON t.id_tiers = c.id_tiers
'
)
AS s(
r_contribuable varchar,
nom varchar,
prenom varchar,
id_tiers_type varchar,
telephone varchar,
numero_rccm varchar,
date_rccm varchar,
email varchar,
numero_piece_identite varchar,
l_contribuable varchar
)
) s
WHERE trim(p.ifu) = s.r_contribuable;
END;
$procedure$;

View File

@@ -1,297 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_uniteLogement_and_enqueteUnitLog_from_rfu(nombreLimit integer)
LANGUAGE plpgsql
AS $procedure$
DECLARE
l_count numeric := 0;
uniteLogement_rfu record;
l_uniteLogement_id_parent bigint;
l_batiment_id_parent bigint ;
l_personne_id_parent bigint ;
BEGIN
FOR uniteLogement_rfu IN (
SELECT
c.n0bat,
c.n0ul,
--c.n0etage,
CASE
WHEN replace(trim(c.n0etage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.n0etage, ',', '.')::numeric
end as n0etage,
c.quartier,
c.n0_ilot,
c.n0_parcel,
c.n0_contrib,
--c.montmenl,
CASE
WHEN replace(trim(c.montmenl), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.montmenl, ',', '.')::numeric
end as montmenl,
--c.surfsol,
CASE
WHEN replace(trim(c.surfsol), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.surfsol, ',', '.')::numeric
end as surfsol,
--c.surfacelo,
CASE
WHEN replace(trim(c.surfacelo), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.surfacelo, ',', '.')::numeric
end as surfacelo,
--c.vllcalcule,
CASE
WHEN replace(trim(c.vllcalcule), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.vllcalcule, ',', '.')::numeric
end as vllcalcule,
--c.bail,
CASE
WHEN replace(trim(c.bail), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.bail, ',', '.')::numeric
end as bail,
--c.nbetage,
CASE
WHEN replace(trim(c.nbetage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbetage, ',', '.')::numeric
end as nbetage,
--c.vlcalcule,
CASE
WHEN replace(trim(c.vlcalcule), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.vlcalcule, ',', '.')::numeric
end as vlcalcule,
--c.utilisat,
CASE
WHEN replace(trim(c.utilisat), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.utilisat, ',', '.')::numeric
end as utilisat,
--c.finexempt,
CASE
WHEN c.finexempt IS NULL OR c.finexempt = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.finexempt !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.finexempt, 'YYYYMMDD'), 'YYYYMMDD') <> c.finexempt THEN NULL
ELSE to_date(c.finexempt, 'YYYYMMDD')
end as finexempt,
--c.toit
CASE
WHEN replace(trim(c.toit), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.toit, ',', '.')::numeric
end as toit,
--nbhabit,
CASE
WHEN replace(trim(c.nbhabit), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbhabit, ',', '.')::numeric
end as nbhabit,
--nbmenage,
CASE
WHEN replace(trim(c.nbmenage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbmenage, ',', '.')::numeric
end as nbmenage,
--nbmois,
CASE
WHEN replace(trim(c.nbmois), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbmois, ',', '.')::numeric
end as nbmois,
--electric,
CASE
WHEN trim(c.electric)='Non'
THEN false
else
true
end as electric,
--eau,
CASE
WHEN trim(c.eau)='Non'
THEN false
else
true
end as eau,
--nbpiece,
CASE
WHEN replace(trim(c.nbpiece), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbpiece, ',', '.')::numeric
end as nbpiece,
--nbunite
CASE
WHEN replace(trim(c.nbunite), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbunite, ',', '.')::numeric
end as nbunite,
CASE
WHEN c.mdate IS NULL OR c.mdate = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.mdate !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.mdate, 'YYYYMMDD'), 'YYYYMMDD') <> c.mdate THEN NULL
ELSE to_date(c.mdate, 'YYYYMMDD')
end as mdate,
--c.murs,
CASE
WHEN replace(trim(c.murs), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.murs, ',', '.')::numeric
end as murs,
--standing
CASE
WHEN replace(trim(c.standing), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.standing, ',', '.')::numeric
end as standing
FROM dblink(
'connexion_rfu',
$db$
select distinct
ul.n0bat,
ul.n0ul,
ul.n0etage,
ul.quartier,
ul.n0_ilot,
ul.n0_parcel,
ul.n0_contrib,
ul.montmenl,
ul.surfsol,
ul.surfacelo,
ul.vllcalcule,
ul.bail,
--ul.valloest,
ul.nbetage,
ul.vlcalcule,
ul.utilisat,
ul.finexempt,
ul.nbunitlo,
ul.toit,
ul.nbhabit,
ul.nbmenage,
ul.nbmois,
ul.electric,
ul.eau,
ul.nbpiece,
ul.nbunite,
ul.mdate,
ul.murs,
ul.standing
FROM akpakpa.unitlog ul
$db$
) AS c (
n0bat varchar,
n0ul varchar,
n0etage varchar,
quartier varchar,
n0_ilot varchar,
n0_parcel varchar,
n0_contrib varchar,
montmenl varchar,
surfsol varchar,
surfacelo varchar,
vllcalcule varchar,
bail varchar,
--valloest varchar,
nbetage varchar,
vlcalcule varchar,
utilisat varchar,
finexempt varchar,
nbunitlo varchar,
toit varchar,
nbhabit varchar,
nbmenage varchar,
nbmois varchar,
electric varchar,
eau varchar,
nbpiece varchar,
nbunite varchar,
mdate varchar,
murs varchar,
standing varchar
)
WHERE NOT EXISTS (
SELECT 1
FROM public.unite_logement ul
WHERE ul.code =
trim(c.quartier)||'-'||trim(c.n0_ilot)||'-'||trim(c.n0_parcel)||'-'||trim(c.n0bat)||'-'||trim(c.n0ul)
)
limit nombreLimit
)
LOOP
-- Récupération ID batiment locale
SELECT b.id
INTO l_batiment_id_parent
FROM public.batiment b
WHERE b.code =
trim(uniteLogement_rfu.quartier)||'-'||trim(uniteLogement_rfu.n0_ilot)||'-'||trim(uniteLogement_rfu.n0_parcel)||'-'||trim(uniteLogement_rfu.n0bat)
LIMIT 1;
-- Récupération ID personne locale
SELECT p.id
INTO l_personne_id_parent
FROM public.personne p
WHERE p.nc =trim(uniteLogement_rfu.n0_contrib)
LIMIT 1;
-- Insertion unite logement local
INSERT INTO public.unite_logement(
created_at,
created_by,
deleted,
updated_at,
updated_by,
code,
nul,
numero_etage,
batiment_id,
--personne_id,
source,
superficie_au_sol,
superficie_louee,
categorie_batiment_id,
montant_locatif_annuel_calcule,
montant_locatif_annuel_declare,
montant_mensuel_location,
valeur_unite_logement_estime,
usage_id,
date_fin_exemption,
id_toit_rfu,
valeur_unite_logement_calcule,
nombre_etage
)
VALUES (
now(),
35,
false,
now(),
35,
trim(uniteLogement_rfu.quartier)||'-'||trim(uniteLogement_rfu.n0_ilot)||'-'||trim(uniteLogement_rfu.n0_parcel)||'-'||trim(uniteLogement_rfu.n0bat)||'-'||trim(uniteLogement_rfu.n0ul),
uniteLogement_rfu.n0ul,
uniteLogement_rfu.n0etage,
l_batiment_id_parent,
-- l_personne_id_parent,
'RFU',
uniteLogement_rfu.surfsol,
uniteLogement_rfu.surfacelo,
ProcedureRecupCategorieRFU(uniteLogement_rfu.nbetage::integer,uniteLogement_rfu.toit::integer),
uniteLogement_rfu.vllcalcule,
uniteLogement_rfu.bail,
uniteLogement_rfu.montmenl,
uniteLogement_rfu.vlcalcule,
CASE uniteLogement_rfu.utilisat
WHEN 1 THEN 8
WHEN 2 THEN 14
WHEN 3 THEN 9
END,
uniteLogement_rfu.finexempt,
uniteLogement_rfu.toit,
uniteLogement_rfu.vlcalcule,
uniteLogement_rfu.nbetage
)
RETURNING id INTO l_uniteLogement_id_parent;
call public.import_enqueteUnitLog_from_rfu_cipe(
uniteLogement_rfu,
l_uniteLogement_id_parent,
l_personne_id_parent
);
l_count := l_count + 1;
END LOOP;
RAISE NOTICE 'Nombre de unité de logement insérés : %', l_count;
END;
$procedure$;

View File

@@ -1,95 +0,0 @@
SELECT dblink_connect(
'connexion_rfu',
'host=10.4.6.103 port=5432 dbname=rfu user=postgres password=Rfu@dm1N2@25TeMp0'
);
--SELECT dblink_disconnect('connexion_rfu');
--SELECT pg_size_pretty(pg_database_size('rfu'));
CREATE OR REPLACE PROCEDURE public.import_assignation_centre_personne_from_rfu_cotonou()
LANGUAGE plpgsql
AS $procedure$
BEGIN
INSERT INTO public.commune_centre_assignation (
nc,
ifu,
commune_id,
structure_id,
personne_id,
parcelle_id,
created_at,
created_by,
deleted,
updated_at,
updated_by,
source
)
SELECT
c.n0_contrib,
c.ifu,
70,
case rcdi
when 'A' then 61
when 'B' then 62
when 'C' then 63
when 'D' then 64
else null
end,
pers.id,
parc.id,
now(),
NULL::bigint,
false,
now(),
NULL::bigint,
'RFU'
FROM dblink(
'connexion_rfu',
$db$
SELECT distinct on (ifu,rcdi)
trim(ifu),
trim(n0_contrib),
trim(rcdi),
trim(quartier_c),
trim(ilot_c),
trim(parcel_c)
FROM stemichel.contrib
order by ifu,rcdi
$db$
) AS c (
ifu varchar,
n0_contrib varchar,
rcdi varchar,
quartier_c varchar,
ilot_c varchar,
parcel_c varchar
)
LEFT JOIN personne pers on trim(pers.ifu)=trim(c.ifu)
LEFT JOIN parcelle parc on (trim(parc.q) = trim(c.quartier_c)
and trim(parc.i) = trim(c.ilot_c)
and trim(parc.p) = trim(c.parcel_c))
WHERE NOT EXISTS (
SELECT 1
FROM public.commune_centre_assignation cca
WHERE cca.personne_id = pers.id
and cca.structure_id = case trim(c.rcdi)
when 'A' then 61
when 'B' then 62
when 'C' then 63
when 'D' then 64
else null
end
and cca.commune_id = 70
)
ON CONFLICT (structure_id, commune_id, personne_id) DO NOTHING;
END;
$procedure$;
call import_assignation_centre_personne_from_rfu_cotonou();
--delete from commune_centre_assignation;
--select * from commune_centre_assignation;

View File

@@ -1,287 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_batiment_and_enquetebati_from_rfu(nombreLimit integer)
LANGUAGE plpgsql
AS $$
DECLARE
l_count numeric := 0;
batiment_rfu record;
l_batiment_id_parent bigint;
l_parcelle_id_parent bigint ;
BEGIN
FOR batiment_rfu IN (
SELECT
c.n0bat,
--dtconst,
CASE
WHEN c.dtconst IS NULL OR c.dtconst = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.dtconst !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.dtconst, 'YYYYMMDD'), 'YYYYMMDD') <> c.dtconst THEN NULL
ELSE to_date(c.dtconst, 'YYYYMMDD')
end as dtconst,
c.quartier,
c.n0_ilot,
c.n0_parcel,
--c.surfsol,
CASE
WHEN replace(trim(c.surfsol), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.surfsol, ',', '.')::numeric
end as surfsol,
--c.surfacelo,
CASE
WHEN replace(trim(c.surfacelo), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.surfacelo, ',', '.')::numeric
end as surfacelo,
--c.vllcalcule,
CASE
WHEN replace(trim(c.vllcalcule), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.vllcalcule, ',', '.')::numeric
end as vllcalcule,
--c.bail,
CASE
WHEN replace(trim(c.bail), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.bail, ',', '.')::numeric
end as bail,
--c.valloest,
CASE
WHEN replace(trim(c.valloest), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.valloest, ',', '.')::numeric
end as valloest,
--c.nbetage,
CASE
WHEN replace(trim(c.nbetage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbetage, ',', '.')::numeric
end as nbetage,
--c.vlcalcule,
CASE
WHEN replace(trim(c.vlcalcule), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.vlcalcule, ',', '.')::numeric
end as vlcalcule,
--c.utilisat,
CASE
WHEN replace(trim(c.utilisat), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.utilisat, ',', '.')::numeric
end as utilisat,
--c.finexempt,
CASE
WHEN c.finexempt IS NULL OR c.finexempt = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.finexempt !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.finexempt, 'YYYYMMDD'), 'YYYYMMDD') <> c.finexempt THEN NULL
ELSE to_date(c.finexempt, 'YYYYMMDD')
end as finexempt,
--c.nbunitlo,
CASE
WHEN replace(trim(c.nbunitlo), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbunitlo, ',', '.')::numeric
end as nbunitlo,
--c.toit
CASE
WHEN replace(trim(c.toit), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.toit, ',', '.')::numeric
end as toit,
--nbhabit,
CASE
WHEN replace(trim(c.nbhabit), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbhabit, ',', '.')::numeric
end as nbhabit,
--nbmenage,
CASE
WHEN replace(trim(c.nbmenage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbmenage, ',', '.')::numeric
end as nbmenage,
--nbmois,
CASE
WHEN replace(trim(c.nbmois), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbmois, ',', '.')::numeric
end as nbmois,
--electric,
CASE
WHEN trim(c.electric)='Non'
THEN false
else
true
end as electric,
--eau,
CASE
WHEN trim(c.eau)='Non'
THEN false
else
true
end as eau,
--nbpiece,
CASE
WHEN replace(trim(c.nbpiece), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbpiece, ',', '.')::numeric
end as nbpiece,
--nbunite
CASE
WHEN replace(trim(c.nbunite), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbunite, ',', '.')::numeric
end as nbunite,
CASE
WHEN c.mdate IS NULL OR c.mdate = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.mdate !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.mdate, 'YYYYMMDD'), 'YYYYMMDD') <> c.mdate THEN NULL
ELSE to_date(c.mdate, 'YYYYMMDD')
end as mdate,
--c.murs,
CASE
WHEN replace(trim(c.murs), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.murs, ',', '.')::numeric
end as murs,
--standing
CASE
WHEN replace(trim(c.standing), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.standing, ',', '.')::numeric
end as standing
FROM dblink(
'connexion_rfu',
$db$
SELECT
b.n0bat,
b.dtconst,
b.quartier,
b.n0_ilot,
b.n0_parcel,
b.surfsol,
b.surfacelo,
b.vllcalcule,
b.bail,
b.valloest,
b.nbetage,
b.vlcalcule,
b.utilisat,
b.finexempt,
b.nbunitlo,
b.toit,
b.nbhabit,
b.nbmenage,
b.nbmois,
b.electric,
b.eau,
b.nbpiece,
b.nbunite,
b.mdate,
b.murs,
b.standing
FROM stemichel.batiment b
$db$
) AS c (
n0bat varchar,
dtconst varchar,
quartier varchar,
n0_ilot varchar,
n0_parcel varchar,
surfsol varchar,
surfacelo varchar,
vllcalcule varchar,
bail varchar,
valloest varchar,
nbetage varchar,
vlcalcule varchar,
utilisat varchar,
finexempt varchar,
nbunitlo varchar,
toit varchar,
nbhabit varchar,
nbmenage varchar,
nbmois varchar,
electric varchar,
eau varchar,
nbpiece varchar,
nbunite varchar,
mdate varchar,
murs varchar,
standing varchar
)
WHERE NOT EXISTS (
SELECT 1
FROM public.batiment b
WHERE b.code =
trim(c.quartier)||'-'||trim(c.n0_ilot)||'-'||trim(c.n0_parcel)||'-'||trim(c.n0bat)
)
limit nombreLimit
)
LOOP
-- Récupération ID parcelle locale
SELECT p.id
INTO l_parcelle_id_parent
FROM public.parcelle p
WHERE p.numero_parcelle =
trim(batiment_rfu.quartier)||'-'||trim(batiment_rfu.n0_ilot)||'-'||trim(batiment_rfu.n0_parcel)
LIMIT 1;
-- Insertion bâtiment local
INSERT INTO public.batiment (
created_at,
created_by,
deleted,
updated_at,
updated_by,
code,
nub,
date_construction,
parcelle_id,
source,
superficie_au_sol,
superficie_louee,
categorie_batiment_id,
montant_locatif_annuel_calcule,
montant_locatif_annuel_declare,
montant_locatif_annuel_estime,
nombre_etage,
valeur_batiment_calcule,
usage_id,
date_fin_exemption,
nbre_unite_logement,
id_toit_rfu
)
VALUES (
now(),
35,
false,
now(),
35,
trim(batiment_rfu.quartier)||'-'||trim(batiment_rfu.n0_ilot)||'-'||trim(batiment_rfu.n0_parcel)||'-'||trim(batiment_rfu.n0bat),
batiment_rfu.n0bat,
batiment_rfu.dtconst,
l_parcelle_id_parent,
'RFU',
batiment_rfu.surfsol,
batiment_rfu.surfacelo,
ProcedureRecupCategorieRFU(batiment_rfu.nbetage::integer,batiment_rfu.toit::integer),
batiment_rfu.vllcalcule,
batiment_rfu.bail,
batiment_rfu.valloest,
batiment_rfu.nbetage,
batiment_rfu.vlcalcule,
--------- batiment_rfu.utilisat,
CASE batiment_rfu.utilisat
WHEN 1 THEN 8
WHEN 2 THEN 14
WHEN 3 THEN 9
END,
batiment_rfu.finexempt,
batiment_rfu.nbunitlo,
batiment_rfu.toit
)
RETURNING id INTO l_batiment_id_parent ;
call public.import_enquetebati_from_rfu_cipe(batiment_rfu,l_batiment_id_parent);
l_count := l_count + 1;
END LOOP;
RAISE NOTICE 'Nombre de bâtiments insérés : %', l_count;
END;
$$;

View File

@@ -1,158 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_enquetebati_from_rfu_cipe(
IN batiment_rfu record,
IN batiment_id_param numeric
)
LANGUAGE plpgsql
AS $procedure$
DECLARE
enquete_batiment_id_parent bigint;
BEGIN
INSERT INTO enquete_batiment (
created_at,
created_by,
deleted,
updated_at,
updated_by,
date_fin_excemption,
nbre_habitant,
nbre_menage,
nbre_mois_location,
nbre_unite_location,
sbee,
soneb,
batiment_id,
personne_id,
user_id,
montant_locatif_annuel_declare,
nbre_etage,
source,
date_enquete,
observation,
superficie_au_sol,
superficie_louee,
statut_enquete,
categorie_batiment_id,
montant_locatif_annuel_calcule,
usage_id,
montant_locatif_annuel_estime,
nbre_piece,
nbre_unite_logement,
valeur_batiment_calcule,
nbre_lot_unite
) select
now(),
35,
false,
now(),
35,
batiment_rfu.finexempt,
batiment_rfu.nbhabit,
batiment_rfu.nbmenage,
batiment_rfu.nbmois,
batiment_rfu.nbunitlo,
batiment_rfu.electric,
batiment_rfu.eau,
batiment_id_param,
e.personne_id,
35,
batiment_rfu.bail,
batiment_rfu.nbetage,
'RFU',
batiment_rfu.mdate,
'MIGRATION',
batiment_rfu.surfsol,
batiment_rfu.surfacelo,
'CLOTURE',
ProcedureRecupCategorieRFU(batiment_rfu.nbetage::integer,batiment_rfu.toit::integer),
batiment_rfu.vllcalcule,
--batiment_rfu.utilisat,
CASE batiment_rfu.utilisat
WHEN 1 THEN 8
WHEN 2 THEN 14
WHEN 3 THEN 9
end,
batiment_rfu.valloest,
batiment_rfu.nbpiece,
batiment_rfu.nbunite,
batiment_rfu.vlcalcule,
batiment_rfu.nbunitlo
from batiment b
left join parcelle p on p.id=b.parcelle_id
left join enquete e on e.parcelle_id=p.id
where b.id = batiment_id_param
and not exists (
select 1
from enquete_batiment eb
where eb.batiment_id = b.id
)
RETURNING id INTO enquete_batiment_id_parent ;
----------MAJ Caractéristique parcelle
INSERT INTO caracteristique_batiment (
created_by,
created_at,
updated_by,
updated_at,
deleted,
caracteristique_id,
enquete_batiment_id
)
SELECT 35, now(), 35, now(),false,
CASE batiment_rfu.toit
WHEN 1 THEN 55
WHEN 2 THEN 56
WHEN 3 THEN 57
WHEN 4 THEN 58
WHEN 5 THEN 59
WHEN 6 THEN 60
END,
enquete_batiment_id_parent
WHERE batiment_rfu.toit IS NOT NULL
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE batiment_rfu.murs
WHEN 1 THEN 49
WHEN 2 THEN 50
WHEN 3 THEN 51
WHEN 4 THEN 52
WHEN 5 THEN 53
else
54
END,
enquete_batiment_id_parent
WHERE batiment_rfu.murs IS NOT null
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE batiment_rfu.standing
WHEN 1 THEN 81
WHEN 2 THEN 82
WHEN 3 THEN 83
WHEN 4 THEN 84
END,
enquete_batiment_id_parent
WHERE batiment_rfu.standing IS NOT null
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE batiment_rfu.utilisat
WHEN 1 THEN 35
WHEN 2 THEN 36
WHEN 3 THEN 37
END,
enquete_batiment_id_parent
WHERE batiment_rfu.utilisat IS NOT null;
------MAJ Exercice
UPDATE enquete_batiment eb
SET exercice_id = e.id
FROM exercice e
WHERE e.annee = 2025
AND eb.id = enquete_batiment_id_parent;
END;
$procedure$;

View File

@@ -1,153 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_enqueteparc_from_rfu_cipe(
IN parcelle_rfu record,
IN p_parcelle_id numeric
)
LANGUAGE plpgsql
AS $procedure$
DECLARE
enquete_id_parent bigint;
BEGIN
INSERT INTO enquete (
created_at,
created_by,
deleted,
updated_at,
updated_by,
date_enquete,
litige,
parcelle_id,
user_id,
date_finalisation,
date_synchronisation,
date_validation,
status_enquete,
synchronise,
code_parcelle,
nbre_batiment,
nbre_co_proprietaire,
nom_rue,
num_enter_parcelle,
num_rue,
superficie,
equipe_id,
zone_rfu_id,
campagne_id,
origine_enquete,
nc_proprietaire,
source
) select
now(),
35,
false,
now(),
35,
now(),
false,
p_parcelle_id,
35,
now(),
now(),
now(),
'CLOTURE',
true,
parcelle_rfu.numero_parcelle,
CASE
WHEN trim(parcelle_rfu.nb_bat) ~ '^[0-9]+$'
THEN parcelle_rfu.nb_bat::integer
ELSE NULL
END,
CASE
WHEN trim(parcelle_rfu.nb_prop) ~ '^[0-9]+$'
THEN parcelle_rfu.nb_prop::integer
ELSE NULL
END,
parcelle_rfu.numero_rue,
parcelle_rfu.num_entree_parcelle,
parcelle_rfu.numero_rue,
CASE
WHEN trim(parcelle_rfu.surface) ~ '^[0-9]+$'
THEN parcelle_rfu.surface::float
ELSE NULL
END,
1,
CASE parcelle_rfu.zones
WHEN '1' THEN 1
WHEN '2' THEN 2
WHEN '3' THEN 3
WHEN '4' THEN 4
ELSE NULL
END,
1,
'RFU',
parcelle_rfu.n0_contrib,
'RFU'
--from parcelle p
where not exists (
select 1
from enquete e
where e.parcelle_id= p_parcelle_id
)
RETURNING id INTO enquete_id_parent ;
----------MAJ Caractéristique parcelle
INSERT INTO caracteristique_parcelle (
created_by,
created_at,
updated_by,
updated_at,
deleted,
caracteristique_id,
enquete_id
)
SELECT 35, now(), 35, now(), false,
CASE parcelle_rfu.acces
WHEN '1' THEN 31
WHEN '2' THEN 32
WHEN '3' THEN 33
WHEN '4' THEN 34
END,
enquete_id_parent
WHERE parcelle_rfu.acces IS NOT NULL
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE parcelle_rfu.cloture
WHEN '1' THEN 28
WHEN '2' THEN 29
WHEN '3' THEN 30
END,
enquete_id_parent
WHERE parcelle_rfu.cloture IS NOT NULL;
------MAJ Exercice
UPDATE enquete q
SET exercice_id = e.id
FROM exercice e
WHERE e.annee = 2025
AND q.id = enquete_id_parent;
------MAJ prietaire
UPDATE enquete q
SET personne_id = p.id,
proprietaire_id = p.id,
nom_proprietaire_parcelle = coalesce (trim(p.raison_sociale), trim(p.nom) || ' '|| trim(p.prenom) )
FROM personne p
WHERE p.nc = parcelle_rfu.n0_contrib
AND q.id = enquete_id_parent;
--quartier_id --commune_id --departement_id --arrondissement_id
UPDATE enquete e
SET quartier_id = q.id,
commune_id=c.id,
departement_id=c.departement_id,
arrondissement_id= a.id
FROM parcelle p
inner join quartier q on q.id = p.quartier_id
inner join arrondissement a on a.id = q.arrondissement_id
inner join commune c on c.id = a.commune_id
WHERE p.id = p_parcelle_id
AND e.id = enquete_id_parent;
END;
$procedure$;

View File

@@ -1,156 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_enqueteUnitLog_from_rfu_cipe(
IN uniteLogement_rfu record,
IN uniteLogement_id_param numeric,
IN l_personne_id_parent numeric
)
LANGUAGE plpgsql
AS $procedure$
DECLARE
enquete_uniteLogement_id_parent bigint;
BEGIN
INSERT INTO enquete_unite_logement (
created_at,
created_by,
deleted,
updated_at,
updated_by,
en_location,
montant_locatif_annuel_declare,
nbre_habitant,
nbre_menage,
nbre_piece,
sbee,
soneb,
personne_id,
unite_logement_id,
user_id,
nbre_mois_location,
valeur_unite_logement_estime,
source,
date_enquete,
observation,
date_fin_exemption,
superficie_au_sol,
superficie_louee,
statut_enquete,
categorie_batiment_id,
montant_locatif_annuel_calcule,
montant_mensuel_location,
usage_id,
valeur_unite_logement_calcule
)select
now(),
35,
false,
now(),
35,
case
when uniteLogement_rfu.nbmois=0 then false
else true
end,
uniteLogement_rfu.montmenl*12,
uniteLogement_rfu.nbhabit,
uniteLogement_rfu.nbmenage,
uniteLogement_rfu.nbpiece,
uniteLogement_rfu.electric,
uniteLogement_rfu.eau,
l_personne_id_parent,
uniteLogement_id_param,
35,
uniteLogement_rfu.nbmois,
uniteLogement_rfu.vlcalcule,
'RFU',
uniteLogement_rfu.mdate,
'MIGRATION',
uniteLogement_rfu.finexempt,
uniteLogement_rfu.surfsol,
uniteLogement_rfu.surfacelo,
'CLOTURE',
ProcedureRecupCategorieRFU(uniteLogement_rfu.n0etage::integer,uniteLogement_rfu.toit::integer),
uniteLogement_rfu.vllcalcule,
uniteLogement_rfu.montmenl,
CASE uniteLogement_rfu.utilisat
WHEN 1 THEN 8
WHEN 2 THEN 14
WHEN 3 THEN 9
END,
uniteLogement_rfu.vlcalcule
from unite_logement ul
where ul.id = uniteLogement_id_param
and not exists (
select 1
from enquete_unite_logement eul
where eul.unite_logement_id = ul.id
)
RETURNING id INTO enquete_uniteLogement_id_parent ;
----------MAJ Caractéristique Unite de logement
INSERT INTO caracteristique_unite_logement (
created_by,
created_at,
updated_by,
updated_at,
deleted,
caracteristique_id,
enquete_unite_logement_id
)
SELECT 35, now(), 35, now(),false,
CASE uniteLogement_rfu.toit
WHEN 1 THEN 55
WHEN 2 THEN 56
WHEN 3 THEN 57
WHEN 4 THEN 58
WHEN 5 THEN 59
WHEN 6 THEN 60
END,
enquete_uniteLogement_id_parent
WHERE uniteLogement_rfu.toit IS NOT NULL
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE uniteLogement_rfu.murs
WHEN 1 THEN 49
WHEN 2 THEN 50
WHEN 3 THEN 51
WHEN 4 THEN 52
WHEN 5 THEN 53
else
54
END,
enquete_uniteLogement_id_parent
WHERE uniteLogement_rfu.murs IS NOT null
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE uniteLogement_rfu.standing
WHEN 1 THEN 81
WHEN 2 THEN 82
WHEN 3 THEN 83
WHEN 4 THEN 84
END,
enquete_uniteLogement_id_parent
WHERE uniteLogement_rfu.standing IS NOT null
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE uniteLogement_rfu.utilisat
WHEN 1 THEN 35
WHEN 2 THEN 36
WHEN 3 THEN 37
END,
enquete_uniteLogement_id_parent
WHERE uniteLogement_rfu.standing IS NOT null;
------MAJ Exercice
UPDATE enquete_unite_logement eul
SET exercice_id = e.id
FROM exercice e
WHERE e.annee = 2025
AND eul.id = enquete_uniteLogement_id_parent;
END;
$procedure$;

View File

@@ -1,99 +0,0 @@
SELECT dblink_connect(
'connexion_rfu',
'host=10.4.6.103 port=5432 dbname=rfu user=postgres password=Rfu@dm1N2@25TeMp0'
);
CREATE OR REPLACE PROCEDURE public.import_imposition_rfu_cotonou(in exercice varchar(10), in nombreLimit numeric)
LANGUAGE plpgsql
AS $procedure$
DECLARE
l_count numeric := 0;
imposition_rfu record;
l_parcelle_id_parent bigint;
l_code_quartier varchar(20);
BEGIN
FOR imposition_rfu IN (
SELECT FROM dblink(
'connexion_rfu',
$db$
SELECT
i.article ,
i.ifu ,
i.n0_contrib ,
i.denome ,
i.annees ,
i.nature ,
n.libnature ,
i.quartier,
q.libquart ,
i.n0_ilot ,
i.n0_parcel ,
i.nn,
COALESCE(i.montant,0) droit_simple,
COALESCE(i.penalite,0) penalite,
COALESCE(i.majorat,0) majoration,
COALESCE(i.montant,0)+COALESCE(i.penalite,0)+COALESCE(i.majorat,0) total_imposition
FROM stemichel.impotsra i
join agla.nature n on n.nature=i.nature
left join (select distinct
n0_ilot,
quartier,
libquart
from agla.quartier)q on (q.n0_ilot=i.n0_ilot and q.quartier=i.quartier)
-- WHERE i.annees = '2025' or (i.annees ='2024' and trim(i.nature) in ('3N', '4N', 'YN'))
limit 100
$db$
) AS c (
terrain varchar,
n0_ilot varchar,
n0_parcel varchar,
quartier varchar,
hauteur varchar,
rue varchar,
entree varchar,
vlcalcule varchar,
vllcalcule varchar,
)
WHERE NOT EXISTS (
SELECT 1
FROM public.parcelle p
WHERE p.numero_parcelle =
trim(c.quartier)||'-'||trim(c.n0_ilot)||'-'||trim(c.n0_parcel)
) and exists (
select 1
from public.ref_rfu_q_quartier_cotonou rq
where rq.rfu_q = trim(c.quartier)
)
limit nombreLimit
) LOOP
BEGIN
INSERT INTO parcelle (
created_at,
created_by,
deleted,
updated_at,
updated_by,
parcelle_id,
source
)
SELECT
now(),
35,
false,
now(),
35,
parcelle_id,
'RFU'
FROM ref_rfu_q_quartier_cotonou rq
WHERE rq.rfu_q = parcelle_rfu.q
RETURNING id, code_quartier
INTO l_parcelle_id_parent, l_code_quartier;
RAISE NOTICE 'Nombre impositions migrées : %', l_count;
END ;
END LOOP ;
END;
$procedure$;

View File

@@ -1,250 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_parcelle_and_enqueteparc_from_rfu_cipe(in nombreLimit numeric)
LANGUAGE plpgsql
AS $procedure$
DECLARE
l_count numeric := 0;
parcelle_rfu record;
l_parcelle_id_parent bigint;
l_code_quartier varchar(20);
BEGIN
FOR parcelle_rfu IN (
SELECT
trim(quartier)||'-'||trim(n0_ilot)||'-'||trim(n0_parcel) AS numero_parcelle,
terrain,
trim(n0_ilot) AS i,
trim(n0_parcel) AS p,
trim(quartier) AS q,
hauteur,
rue AS numero_rue,
entree AS num_entree_parcelle,
surface,
vlcalcule,
vllcalcule,
loue,
zones,
acces,
cloture,
inonde,
finexempt,
habite,
ordures,
"usage",
wc,
choix,
occupant,
nb_bat,
nb_prop,
nb_log,
nb_unit,
nb_mena,
nb_habit,
nb_act,
nb_contrib,
typeparc,
prixm2ne,
ifu,
n0_contrib,
secteur,
cipe
FROM dblink(
'connexion_rfu',
$db$
SELECT
terrain,
n0_ilot,
n0_parcel,
quartier,
hauteur,
rue,
entree,
vlcalcule,
vllcalcule,
loue,
zones,
acces,
cloture,
inonde,
finexempt,
habite,
ordures,
surface,
"usage",
wc,
choix,
occupant,
nb_bat,
nb_prop,
nb_log,
nb_unit,
nb_mena,
nb_habit,
nb_act,
nb_contrib,
typeparc,
prixm2ne,
ifu,
n0_contrib,
secteur,
cipe
FROM stemichel.parcelle
$db$
) AS c (
terrain varchar,
n0_ilot varchar,
n0_parcel varchar,
quartier varchar,
hauteur varchar,
rue varchar,
entree varchar,
vlcalcule varchar,
vllcalcule varchar,
loue varchar,
zones varchar,
acces varchar,
cloture varchar,
inonde varchar,
finexempt varchar,
habite varchar,
ordures varchar,
surface varchar,
"usage" varchar,
wc varchar,
choix varchar,
occupant varchar,
nb_bat varchar,
nb_prop varchar,
nb_log varchar,
nb_unit varchar,
nb_mena varchar,
nb_habit varchar,
nb_act varchar,
nb_contrib varchar,
typeparc varchar,
prixm2ne varchar,
ifu varchar,
n0_contrib varchar,
secteur varchar,
cipe varchar
)
WHERE NOT EXISTS (
SELECT 1
FROM public.parcelle p
WHERE p.numero_parcelle =
trim(c.quartier)||'-'||trim(c.n0_ilot)||'-'||trim(c.n0_parcel)
) and exists (
select 1
from public.ref_rfu_q_quartier_cotonou rq
where rq.rfu_q = trim(c.quartier)
)
limit nombreLimit
) LOOP
BEGIN
INSERT INTO parcelle (
created_at,
created_by,
deleted,
updated_at,
updated_by,
numero_parcelle,
qip,
type_domaine_id,
i,
p,
q,
code_quartier,
nature_domaine_id,
superficie,
altitude,
num_entree_parcelle,
numero_rue,
usage_id,
source
)
SELECT
now(),
35,
false,
now(),
35,
parcelle_rfu.numero_parcelle,
parcelle_rfu.numero_parcelle,
CASE parcelle_rfu.terrain
WHEN '1' THEN 2
WHEN '2' THEN 5
WHEN '3' THEN 4
END,
parcelle_rfu.i,
parcelle_rfu.p,
parcelle_rfu.q,
rq.code_quartier,
CASE parcelle_rfu.typeparc
WHEN '1' THEN 23
WHEN '2' THEN 27
WHEN '3' THEN 28
WHEN '4' THEN 29
END,
CASE
WHEN replace(trim(parcelle_rfu.surface), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(parcelle_rfu.surface, ',', '.')::numeric
END,
CASE
WHEN replace(trim(parcelle_rfu.hauteur), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(parcelle_rfu.hauteur, ',', '.')::numeric
END,
parcelle_rfu.num_entree_parcelle,
parcelle_rfu.numero_rue,
case parcelle_rfu.usage
WHEN '01' THEN 3
WHEN '02' THEN 4
WHEN '03' THEN 5
WHEN '04' THEN 6
WHEN '05' THEN 7
WHEN '11' THEN 8
WHEN '12' THEN 9
WHEN '13' THEN 10
WHEN '14' THEN 11
WHEN '21' THEN 12
WHEN '22' THEN 13
WHEN '23' THEN 14
WHEN '24' THEN 15
WHEN '25' THEN 16
END,
'RFU'
FROM ref_rfu_q_quartier_cotonou rq
WHERE rq.rfu_q = parcelle_rfu.q
RETURNING id, code_quartier
INTO l_parcelle_id_parent, l_code_quartier;
EXCEPTION WHEN NO_DATA_FOUND THEN
RAISE NOTICE 'Quartier RFU non trouvé pour %', parcelle_rfu.q;
CONTINUE;
--RAISE NOTICE 'Parcelle insérée : %, %', l_parcelle_id_parent, parcelle_rfu.q;
END;
------------------------------appel de enquete_parcelle------------------
CALL import_enqueteparc_from_rfu_cipe(parcelle_rfu, l_parcelle_id_parent);
INSERT INTO secteur_decoupage (
created_at, created_by, deleted, updated_at, updated_by,
date_debut, quartier_id, secteur_id, arrondissement_id, source
)
SELECT
now(), 35, false, now(), 35,
now(), q.id, s.id,a.id, 'RFU'
FROM ref_cipe_secteur_rfu_cotonou rcs
JOIN secteur s ON s.code= rcs.code_secteur
JOIN quartier q ON q.code = l_code_quartier
left join arrondissement a on a.id=q.arrondissement_id
WHERE rcs.cipe = parcelle_rfu.cipe
AND rcs.secteur = parcelle_rfu.secteur
ON CONFLICT (quartier_id, secteur_id) DO NOTHING;
l_count := l_count + 1;
END LOOP;
UPDATE parcelle p
SET quartier_id = q.id
FROM quartier q
WHERE q.code = p.code_quartier;
RAISE NOTICE 'Nombre de parcelles migrées : %', l_count;
END;
$procedure$;

View File

@@ -1,128 +0,0 @@
SELECT dblink_connect(
'connexion_rfu',
'host=10.4.6.103 port=5432 dbname=rfu user=postgres password=Rfu@dm1N2@25TeMp0'
);
--SELECT dblink_disconnect('connexion_rfu');
CREATE OR REPLACE PROCEDURE public.import_personne_from_rfu()
LANGUAGE plpgsql
AS $procedure$
BEGIN
INSERT INTO public.personne (
date_naissance_ou_consti,
ifu,
lieu_naissance,
nom,
prenom,
raison_sociale,
npi,
num_ravip,
tel1,
tel2,
adresse,
created_at,
created_by,
deleted,
updated_at,
updated_by,
nc,
sexe,
profession,
source
)
SELECT
CASE
WHEN c.date_nais IS NULL OR c.date_nais = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.date_nais !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.date_nais, 'YYYYMMDD'), 'YYYYMMDD') <> c.date_nais THEN NULL
ELSE to_date(c.date_nais, 'YYYYMMDD')
END,
c.ifu,
c.lieu_nais,
case
when (trim(c.nom_c)<>'' and trim(c.prenoms_c)<>'') then c.nom_c
when (trim(c.nom_c)='' and trim(c.prenoms_c)='' and trim(c.prenoms)<>'') then c.nom
end as nom,
case
when (trim(c.nom_c)<>'' and trim(c.prenoms_c)<>'') then c.prenoms_c
when (trim(c.nom_c)='' and trim(c.prenoms_c)='' and trim(c.prenoms)<>'') then c.prenoms
end as prenom,
case
when (trim(c.nom_c)='' and trim(c.prenoms_c)='' and trim(c.prenoms)='') then c.nom
when (trim(c.nom_c)<>'' and trim(c.prenoms_c)<>'' and trim(c.prenoms)='') then c.nom
end as raison_sociale,
--c.nom,
NULL::varchar,
NULL::varchar,
--c.prenoms,
c.autradr1,
c.autradr2,
COALESCE(c.quartier_c, '') || '_' ||
COALESCE(c.ilot_c, '') || '_' ||
COALESCE(c.parcel_c, ''),
now(),
NULL::bigint,
false,
now(),
NULL::bigint,
c.n0_contrib,
CASE c.sexe
WHEN '1' THEN 'MASCULIN'
WHEN '2' THEN 'FEMININ'
ELSE NULL
END,
c.profession,
'RFU'
FROM dblink(
'connexion_rfu',
$db$
SELECT
date_nais,
ifu,
lieu_nais,
nom,
prenoms,
nom_c,
prenoms_c,
autradr1,
autradr2,
quartier_c,
ilot_c,
parcel_c,
n0_contrib,
sexe,
profession
FROM stemichel.contrib
-- WHERE ifu IS NOT NULL
$db$
) AS c (
date_nais varchar,
ifu varchar,
lieu_nais varchar,
nom varchar,
prenoms varchar,
nom_c varchar,
prenoms_c varchar,
autradr1 varchar,
autradr2 varchar,
quartier_c varchar,
ilot_c varchar,
parcel_c varchar,
n0_contrib varchar,
sexe varchar,
profession varchar
)
WHERE NOT EXISTS (
SELECT 1
FROM public.personne p
WHERE p.nc = c.n0_contrib
);
END;
$procedure$;

View File

@@ -1,82 +0,0 @@
SELECT dblink_connect(
'connexion_rfu',
'host=10.4.6.103 port=5432 dbname=rfu user=postgres password=Rfu@dm1N2@25TeMp0'
);
--SELECT dblink_disconnect('connexion_rfu');
SELECT dblink_connect(
'connexion_sigibe_lecture',
'host=10.4.80.71 port=5433 dbname=sigibe user=sigibe_lecture password=lec243R6Khsg'
);
CREATE OR REPLACE PROCEDURE public.maj_personne_from_sigibe()
LANGUAGE plpgsql
AS $procedure$
DECLARE
BEGIN
UPDATE personne p
SET
nom = CASE
WHEN s.nom IS NOT NULL THEN s.nom
ELSE p.nom
END,
prenom = CASE
WHEN s.prenom IS NOT NULL THEN s.prenom
ELSE p.prenom
END,
raison_sociale = CASE
WHEN s.id_tiers_type = 'PM'
AND s.l_contribuable IS NOT NULL
THEN s.l_contribuable
ELSE p.raison_sociale
END,
tel1 = s.telephone,
numero_rccm = s.numero_rccm,
date_rccm = CASE
WHEN s.date_rccm IS NOT NULL
AND trim(s.date_rccm) <> ''
THEN s.date_rccm::date
ELSE p.date_rccm
END,
email = s.email,
npi = s.numero_piece_identite,
etat_identification_personne = 'IFU'
FROM (
SELECT *
FROM dblink(
'connexion_sigibe_lecture',
'
SELECT
c.r_contribuable,
t.nom,
t.prenom,
t.id_tiers_type,
t.telephone,
t.numero_rccm,
t.date_rccm,
t.email,
t.numero_piece_identite,
c.l_contribuable
FROM t_contribuable c
JOIN t_tiers t ON t.id_tiers = c.id_tiers
'
)
AS s(
r_contribuable varchar,
nom varchar,
prenom varchar,
id_tiers_type varchar,
telephone varchar,
numero_rccm varchar,
date_rccm varchar,
email varchar,
numero_piece_identite varchar,
l_contribuable varchar
)
) s
WHERE trim(p.ifu) = s.r_contribuable;
END;
$procedure$;

View File

@@ -1,297 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_uniteLogement_and_enqueteUnitLog_from_rfu(nombreLimit integer)
LANGUAGE plpgsql
AS $procedure$
DECLARE
l_count numeric := 0;
uniteLogement_rfu record;
l_uniteLogement_id_parent bigint;
l_batiment_id_parent bigint ;
l_personne_id_parent bigint ;
BEGIN
FOR uniteLogement_rfu IN (
SELECT
c.n0bat,
c.n0ul,
--c.n0etage,
CASE
WHEN replace(trim(c.n0etage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.n0etage, ',', '.')::numeric
end as n0etage,
c.quartier,
c.n0_ilot,
c.n0_parcel,
c.n0_contrib,
--c.montmenl,
CASE
WHEN replace(trim(c.montmenl), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.montmenl, ',', '.')::numeric
end as montmenl,
--c.surfsol,
CASE
WHEN replace(trim(c.surfsol), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.surfsol, ',', '.')::numeric
end as surfsol,
--c.surfacelo,
CASE
WHEN replace(trim(c.surfacelo), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.surfacelo, ',', '.')::numeric
end as surfacelo,
--c.vllcalcule,
CASE
WHEN replace(trim(c.vllcalcule), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.vllcalcule, ',', '.')::numeric
end as vllcalcule,
--c.bail,
CASE
WHEN replace(trim(c.bail), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.bail, ',', '.')::numeric
end as bail,
--c.nbetage,
CASE
WHEN replace(trim(c.nbetage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbetage, ',', '.')::numeric
end as nbetage,
--c.vlcalcule,
CASE
WHEN replace(trim(c.vlcalcule), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.vlcalcule, ',', '.')::numeric
end as vlcalcule,
--c.utilisat,
CASE
WHEN replace(trim(c.utilisat), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.utilisat, ',', '.')::numeric
end as utilisat,
--c.finexempt,
CASE
WHEN c.finexempt IS NULL OR c.finexempt = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.finexempt !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.finexempt, 'YYYYMMDD'), 'YYYYMMDD') <> c.finexempt THEN NULL
ELSE to_date(c.finexempt, 'YYYYMMDD')
end as finexempt,
--c.toit
CASE
WHEN replace(trim(c.toit), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.toit, ',', '.')::numeric
end as toit,
--nbhabit,
CASE
WHEN replace(trim(c.nbhabit), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbhabit, ',', '.')::numeric
end as nbhabit,
--nbmenage,
CASE
WHEN replace(trim(c.nbmenage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbmenage, ',', '.')::numeric
end as nbmenage,
--nbmois,
CASE
WHEN replace(trim(c.nbmois), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbmois, ',', '.')::numeric
end as nbmois,
--electric,
CASE
WHEN trim(c.electric)='Non'
THEN false
else
true
end as electric,
--eau,
CASE
WHEN trim(c.eau)='Non'
THEN false
else
true
end as eau,
--nbpiece,
CASE
WHEN replace(trim(c.nbpiece), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbpiece, ',', '.')::numeric
end as nbpiece,
--nbunite
CASE
WHEN replace(trim(c.nbunite), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbunite, ',', '.')::numeric
end as nbunite,
CASE
WHEN c.mdate IS NULL OR c.mdate = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.mdate !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.mdate, 'YYYYMMDD'), 'YYYYMMDD') <> c.mdate THEN NULL
ELSE to_date(c.mdate, 'YYYYMMDD')
end as mdate,
--c.murs,
CASE
WHEN replace(trim(c.murs), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.murs, ',', '.')::numeric
end as murs,
--standing
CASE
WHEN replace(trim(c.standing), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.standing, ',', '.')::numeric
end as standing
FROM dblink(
'connexion_rfu',
$db$
select distinct
ul.n0bat,
ul.n0ul,
ul.n0etage,
ul.quartier,
ul.n0_ilot,
ul.n0_parcel,
ul.n0_contrib,
ul.montmenl,
ul.surfsol,
ul.surfacelo,
ul.vllcalcule,
ul.bail,
--ul.valloest,
ul.nbetage,
ul.vlcalcule,
ul.utilisat,
ul.finexempt,
ul.nbunitlo,
ul.toit,
ul.nbhabit,
ul.nbmenage,
ul.nbmois,
ul.electric,
ul.eau,
ul.nbpiece,
ul.nbunite,
ul.mdate,
ul.murs,
ul.standing
FROM akpakpa.unitlog ul
$db$
) AS c (
n0bat varchar,
n0ul varchar,
n0etage varchar,
quartier varchar,
n0_ilot varchar,
n0_parcel varchar,
n0_contrib varchar,
montmenl varchar,
surfsol varchar,
surfacelo varchar,
vllcalcule varchar,
bail varchar,
--valloest varchar,
nbetage varchar,
vlcalcule varchar,
utilisat varchar,
finexempt varchar,
nbunitlo varchar,
toit varchar,
nbhabit varchar,
nbmenage varchar,
nbmois varchar,
electric varchar,
eau varchar,
nbpiece varchar,
nbunite varchar,
mdate varchar,
murs varchar,
standing varchar
)
WHERE NOT EXISTS (
SELECT 1
FROM public.unite_logement ul
WHERE ul.code =
trim(c.quartier)||'-'||trim(c.n0_ilot)||'-'||trim(c.n0_parcel)||'-'||trim(c.n0bat)||'-'||trim(c.n0ul)
)
limit nombreLimit
)
LOOP
-- Récupération ID batiment locale
SELECT b.id
INTO l_batiment_id_parent
FROM public.batiment b
WHERE b.code =
trim(uniteLogement_rfu.quartier)||'-'||trim(uniteLogement_rfu.n0_ilot)||'-'||trim(uniteLogement_rfu.n0_parcel)||'-'||trim(uniteLogement_rfu.n0bat)
LIMIT 1;
-- Récupération ID personne locale
SELECT p.id
INTO l_personne_id_parent
FROM public.personne p
WHERE p.nc =trim(uniteLogement_rfu.n0_contrib)
LIMIT 1;
-- Insertion unite logement local
INSERT INTO public.unite_logement(
created_at,
created_by,
deleted,
updated_at,
updated_by,
code,
nul,
numero_etage,
batiment_id,
--personne_id,
source,
superficie_au_sol,
superficie_louee,
categorie_batiment_id,
montant_locatif_annuel_calcule,
montant_locatif_annuel_declare,
montant_mensuel_location,
valeur_unite_logement_estime,
usage_id,
date_fin_exemption,
id_toit_rfu,
valeur_unite_logement_calcule,
nombre_etage
)
VALUES (
now(),
35,
false,
now(),
35,
trim(uniteLogement_rfu.quartier)||'-'||trim(uniteLogement_rfu.n0_ilot)||'-'||trim(uniteLogement_rfu.n0_parcel)||'-'||trim(uniteLogement_rfu.n0bat)||'-'||trim(uniteLogement_rfu.n0ul),
uniteLogement_rfu.n0ul,
uniteLogement_rfu.n0etage,
l_batiment_id_parent,
-- l_personne_id_parent,
'RFU',
uniteLogement_rfu.surfsol,
uniteLogement_rfu.surfacelo,
ProcedureRecupCategorieRFU(uniteLogement_rfu.nbetage::integer,uniteLogement_rfu.toit::integer),
uniteLogement_rfu.vllcalcule,
uniteLogement_rfu.bail,
uniteLogement_rfu.montmenl,
uniteLogement_rfu.vlcalcule,
CASE uniteLogement_rfu.utilisat
WHEN 1 THEN 8
WHEN 2 THEN 14
WHEN 3 THEN 9
END,
uniteLogement_rfu.finexempt,
uniteLogement_rfu.toit,
uniteLogement_rfu.vlcalcule,
uniteLogement_rfu.nbetage
)
RETURNING id INTO l_uniteLogement_id_parent;
call public.import_enqueteUnitLog_from_rfu_cipe(
uniteLogement_rfu,
l_uniteLogement_id_parent,
l_personne_id_parent
);
l_count := l_count + 1;
END LOOP;
RAISE NOTICE 'Nombre de unité de logement insérés : %', l_count;
END;
$procedure$;

View File

@@ -1,95 +0,0 @@
SELECT dblink_connect(
'connexion_rfu',
'host=10.4.6.103 port=5432 dbname=rfu user=postgres password=Rfu@dm1N2@25TeMp0'
);
--SELECT dblink_disconnect('connexion_rfu');
--SELECT pg_size_pretty(pg_database_size('rfu'));
CREATE OR REPLACE PROCEDURE public.import_assignation_centre_personne_from_rfu_cotonou()
LANGUAGE plpgsql
AS $procedure$
BEGIN
INSERT INTO public.commune_centre_assignation (
nc,
ifu,
commune_id,
structure_id,
personne_id,
parcelle_id,
created_at,
created_by,
deleted,
updated_at,
updated_by,
source
)
SELECT
c.n0_contrib,
c.ifu,
70,
case rcdi
when 'A' then 61
when 'B' then 62
when 'C' then 63
when 'D' then 64
else null
end,
pers.id,
parc.id,
now(),
NULL::bigint,
false,
now(),
NULL::bigint,
'RFU'
FROM dblink(
'connexion_rfu',
$db$
SELECT distinct on (ifu,rcdi)
trim(ifu),
trim(n0_contrib),
trim(rcdi),
trim(quartier_c),
trim(ilot_c),
trim(parcel_c)
FROM stemichel.contrib
order by ifu,rcdi
$db$
) AS c (
ifu varchar,
n0_contrib varchar,
rcdi varchar,
quartier_c varchar,
ilot_c varchar,
parcel_c varchar
)
LEFT JOIN personne pers on trim(pers.ifu)=trim(c.ifu)
LEFT JOIN parcelle parc on (trim(parc.q) = trim(c.quartier_c)
and trim(parc.i) = trim(c.ilot_c)
and trim(parc.p) = trim(c.parcel_c))
WHERE NOT EXISTS (
SELECT 1
FROM public.commune_centre_assignation cca
WHERE cca.personne_id = pers.id
and cca.structure_id = case trim(c.rcdi)
when 'A' then 61
when 'B' then 62
when 'C' then 63
when 'D' then 64
else null
end
and cca.commune_id = 70
)
ON CONFLICT (structure_id, commune_id, personne_id) DO NOTHING;
END;
$procedure$;
call import_assignation_centre_personne_from_rfu_cotonou();
--delete from commune_centre_assignation;
--select * from commune_centre_assignation;

View File

@@ -1,287 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_batiment_and_enquetebati_from_rfu(nombreLimit integer)
LANGUAGE plpgsql
AS $$
DECLARE
l_count numeric := 0;
batiment_rfu record;
l_batiment_id_parent bigint;
l_parcelle_id_parent bigint ;
BEGIN
FOR batiment_rfu IN (
SELECT
c.n0bat,
--dtconst,
CASE
WHEN c.dtconst IS NULL OR c.dtconst = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.dtconst !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.dtconst, 'YYYYMMDD'), 'YYYYMMDD') <> c.dtconst THEN NULL
ELSE to_date(c.dtconst, 'YYYYMMDD')
end as dtconst,
c.quartier,
c.n0_ilot,
c.n0_parcel,
--c.surfsol,
CASE
WHEN replace(trim(c.surfsol), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.surfsol, ',', '.')::numeric
end as surfsol,
--c.surfacelo,
CASE
WHEN replace(trim(c.surfacelo), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.surfacelo, ',', '.')::numeric
end as surfacelo,
--c.vllcalcule,
CASE
WHEN replace(trim(c.vllcalcule), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.vllcalcule, ',', '.')::numeric
end as vllcalcule,
--c.bail,
CASE
WHEN replace(trim(c.bail), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.bail, ',', '.')::numeric
end as bail,
--c.valloest,
CASE
WHEN replace(trim(c.valloest), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.valloest, ',', '.')::numeric
end as valloest,
--c.nbetage,
CASE
WHEN replace(trim(c.nbetage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbetage, ',', '.')::numeric
end as nbetage,
--c.vlcalcule,
CASE
WHEN replace(trim(c.vlcalcule), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.vlcalcule, ',', '.')::numeric
end as vlcalcule,
--c.utilisat,
CASE
WHEN replace(trim(c.utilisat), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.utilisat, ',', '.')::numeric
end as utilisat,
--c.finexempt,
CASE
WHEN c.finexempt IS NULL OR c.finexempt = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.finexempt !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.finexempt, 'YYYYMMDD'), 'YYYYMMDD') <> c.finexempt THEN NULL
ELSE to_date(c.finexempt, 'YYYYMMDD')
end as finexempt,
--c.nbunitlo,
CASE
WHEN replace(trim(c.nbunitlo), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbunitlo, ',', '.')::numeric
end as nbunitlo,
--c.toit
CASE
WHEN replace(trim(c.toit), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.toit, ',', '.')::numeric
end as toit,
--nbhabit,
CASE
WHEN replace(trim(c.nbhabit), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbhabit, ',', '.')::numeric
end as nbhabit,
--nbmenage,
CASE
WHEN replace(trim(c.nbmenage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbmenage, ',', '.')::numeric
end as nbmenage,
--nbmois,
CASE
WHEN replace(trim(c.nbmois), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbmois, ',', '.')::numeric
end as nbmois,
--electric,
CASE
WHEN trim(c.electric)='Non'
THEN false
else
true
end as electric,
--eau,
CASE
WHEN trim(c.eau)='Non'
THEN false
else
true
end as eau,
--nbpiece,
CASE
WHEN replace(trim(c.nbpiece), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbpiece, ',', '.')::numeric
end as nbpiece,
--nbunite
CASE
WHEN replace(trim(c.nbunite), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbunite, ',', '.')::numeric
end as nbunite,
CASE
WHEN c.mdate IS NULL OR c.mdate = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.mdate !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.mdate, 'YYYYMMDD'), 'YYYYMMDD') <> c.mdate THEN NULL
ELSE to_date(c.mdate, 'YYYYMMDD')
end as mdate,
--c.murs,
CASE
WHEN replace(trim(c.murs), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.murs, ',', '.')::numeric
end as murs,
--standing
CASE
WHEN replace(trim(c.standing), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.standing, ',', '.')::numeric
end as standing
FROM dblink(
'connexion_rfu',
$db$
SELECT
b.n0bat,
b.dtconst,
b.quartier,
b.n0_ilot,
b.n0_parcel,
b.surfsol,
b.surfacelo,
b.vllcalcule,
b.bail,
b.valloest,
b.nbetage,
b.vlcalcule,
b.utilisat,
b.finexempt,
b.nbunitlo,
b.toit,
b.nbhabit,
b.nbmenage,
b.nbmois,
b.electric,
b.eau,
b.nbpiece,
b.nbunite,
b.mdate,
b.murs,
b.standing
FROM stemichel.batiment b
$db$
) AS c (
n0bat varchar,
dtconst varchar,
quartier varchar,
n0_ilot varchar,
n0_parcel varchar,
surfsol varchar,
surfacelo varchar,
vllcalcule varchar,
bail varchar,
valloest varchar,
nbetage varchar,
vlcalcule varchar,
utilisat varchar,
finexempt varchar,
nbunitlo varchar,
toit varchar,
nbhabit varchar,
nbmenage varchar,
nbmois varchar,
electric varchar,
eau varchar,
nbpiece varchar,
nbunite varchar,
mdate varchar,
murs varchar,
standing varchar
)
WHERE NOT EXISTS (
SELECT 1
FROM public.batiment b
WHERE b.code =
trim(c.quartier)||'-'||trim(c.n0_ilot)||'-'||trim(c.n0_parcel)||'-'||trim(c.n0bat)
)
limit nombreLimit
)
LOOP
-- Récupération ID parcelle locale
SELECT p.id
INTO l_parcelle_id_parent
FROM public.parcelle p
WHERE p.numero_parcelle =
trim(batiment_rfu.quartier)||'-'||trim(batiment_rfu.n0_ilot)||'-'||trim(batiment_rfu.n0_parcel)
LIMIT 1;
-- Insertion bâtiment local
INSERT INTO public.batiment (
created_at,
created_by,
deleted,
updated_at,
updated_by,
code,
nub,
date_construction,
parcelle_id,
source,
superficie_au_sol,
superficie_louee,
categorie_batiment_id,
montant_locatif_annuel_calcule,
montant_locatif_annuel_declare,
montant_locatif_annuel_estime,
nombre_etage,
valeur_batiment_calcule,
usage_id,
date_fin_exemption,
nbre_unite_logement,
id_toit_rfu
)
VALUES (
now(),
35,
false,
now(),
35,
trim(batiment_rfu.quartier)||'-'||trim(batiment_rfu.n0_ilot)||'-'||trim(batiment_rfu.n0_parcel)||'-'||trim(batiment_rfu.n0bat),
batiment_rfu.n0bat,
batiment_rfu.dtconst,
l_parcelle_id_parent,
'RFU',
batiment_rfu.surfsol,
batiment_rfu.surfacelo,
ProcedureRecupCategorieRFU(batiment_rfu.nbetage::integer,batiment_rfu.toit::integer),
batiment_rfu.vllcalcule,
batiment_rfu.bail,
batiment_rfu.valloest,
batiment_rfu.nbetage,
batiment_rfu.vlcalcule,
--------- batiment_rfu.utilisat,
CASE batiment_rfu.utilisat
WHEN 1 THEN 8
WHEN 2 THEN 14
WHEN 3 THEN 9
END,
batiment_rfu.finexempt,
batiment_rfu.nbunitlo,
batiment_rfu.toit
)
RETURNING id INTO l_batiment_id_parent ;
call public.import_enquetebati_from_rfu_cipe(batiment_rfu,l_batiment_id_parent);
l_count := l_count + 1;
END LOOP;
RAISE NOTICE 'Nombre de bâtiments insérés : %', l_count;
END;
$$;

View File

@@ -1,158 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_enquetebati_from_rfu_cipe(
IN batiment_rfu record,
IN batiment_id_param numeric
)
LANGUAGE plpgsql
AS $procedure$
DECLARE
enquete_batiment_id_parent bigint;
BEGIN
INSERT INTO enquete_batiment (
created_at,
created_by,
deleted,
updated_at,
updated_by,
date_fin_excemption,
nbre_habitant,
nbre_menage,
nbre_mois_location,
nbre_unite_location,
sbee,
soneb,
batiment_id,
personne_id,
user_id,
montant_locatif_annuel_declare,
nbre_etage,
source,
date_enquete,
observation,
superficie_au_sol,
superficie_louee,
statut_enquete,
categorie_batiment_id,
montant_locatif_annuel_calcule,
usage_id,
montant_locatif_annuel_estime,
nbre_piece,
nbre_unite_logement,
valeur_batiment_calcule,
nbre_lot_unite
) select
now(),
35,
false,
now(),
35,
batiment_rfu.finexempt,
batiment_rfu.nbhabit,
batiment_rfu.nbmenage,
batiment_rfu.nbmois,
batiment_rfu.nbunitlo,
batiment_rfu.electric,
batiment_rfu.eau,
batiment_id_param,
e.personne_id,
35,
batiment_rfu.bail,
batiment_rfu.nbetage,
'RFU',
batiment_rfu.mdate,
'MIGRATION',
batiment_rfu.surfsol,
batiment_rfu.surfacelo,
'CLOTURE',
ProcedureRecupCategorieRFU(batiment_rfu.nbetage::integer,batiment_rfu.toit::integer),
batiment_rfu.vllcalcule,
--batiment_rfu.utilisat,
CASE batiment_rfu.utilisat
WHEN 1 THEN 8
WHEN 2 THEN 14
WHEN 3 THEN 9
end,
batiment_rfu.valloest,
batiment_rfu.nbpiece,
batiment_rfu.nbunite,
batiment_rfu.vlcalcule,
batiment_rfu.nbunitlo
from batiment b
left join parcelle p on p.id=b.parcelle_id
left join enquete e on e.parcelle_id=p.id
where b.id = batiment_id_param
and not exists (
select 1
from enquete_batiment eb
where eb.batiment_id = b.id
)
RETURNING id INTO enquete_batiment_id_parent ;
----------MAJ Caractéristique parcelle
INSERT INTO caracteristique_batiment (
created_by,
created_at,
updated_by,
updated_at,
deleted,
caracteristique_id,
enquete_batiment_id
)
SELECT 35, now(), 35, now(),false,
CASE batiment_rfu.toit
WHEN 1 THEN 55
WHEN 2 THEN 56
WHEN 3 THEN 57
WHEN 4 THEN 58
WHEN 5 THEN 59
WHEN 6 THEN 60
END,
enquete_batiment_id_parent
WHERE batiment_rfu.toit IS NOT NULL
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE batiment_rfu.murs
WHEN 1 THEN 49
WHEN 2 THEN 50
WHEN 3 THEN 51
WHEN 4 THEN 52
WHEN 5 THEN 53
else
54
END,
enquete_batiment_id_parent
WHERE batiment_rfu.murs IS NOT null
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE batiment_rfu.standing
WHEN 1 THEN 81
WHEN 2 THEN 82
WHEN 3 THEN 83
WHEN 4 THEN 84
END,
enquete_batiment_id_parent
WHERE batiment_rfu.standing IS NOT null
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE batiment_rfu.utilisat
WHEN 1 THEN 35
WHEN 2 THEN 36
WHEN 3 THEN 37
END,
enquete_batiment_id_parent
WHERE batiment_rfu.utilisat IS NOT null;
------MAJ Exercice
UPDATE enquete_batiment eb
SET exercice_id = e.id
FROM exercice e
WHERE e.annee = 2025
AND eb.id = enquete_batiment_id_parent;
END;
$procedure$;

View File

@@ -1,153 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_enqueteparc_from_rfu_cipe(
IN parcelle_rfu record,
IN p_parcelle_id numeric
)
LANGUAGE plpgsql
AS $procedure$
DECLARE
enquete_id_parent bigint;
BEGIN
INSERT INTO enquete (
created_at,
created_by,
deleted,
updated_at,
updated_by,
date_enquete,
litige,
parcelle_id,
user_id,
date_finalisation,
date_synchronisation,
date_validation,
status_enquete,
synchronise,
code_parcelle,
nbre_batiment,
nbre_co_proprietaire,
nom_rue,
num_enter_parcelle,
num_rue,
superficie,
equipe_id,
zone_rfu_id,
campagne_id,
origine_enquete,
nc_proprietaire,
source
) select
now(),
35,
false,
now(),
35,
now(),
false,
p_parcelle_id,
35,
now(),
now(),
now(),
'CLOTURE',
true,
parcelle_rfu.numero_parcelle,
CASE
WHEN trim(parcelle_rfu.nb_bat) ~ '^[0-9]+$'
THEN parcelle_rfu.nb_bat::integer
ELSE NULL
END,
CASE
WHEN trim(parcelle_rfu.nb_prop) ~ '^[0-9]+$'
THEN parcelle_rfu.nb_prop::integer
ELSE NULL
END,
parcelle_rfu.numero_rue,
parcelle_rfu.num_entree_parcelle,
parcelle_rfu.numero_rue,
CASE
WHEN trim(parcelle_rfu.surface) ~ '^[0-9]+$'
THEN parcelle_rfu.surface::float
ELSE NULL
END,
1,
CASE parcelle_rfu.zones
WHEN '1' THEN 1
WHEN '2' THEN 2
WHEN '3' THEN 3
WHEN '4' THEN 4
ELSE NULL
END,
1,
'RFU',
parcelle_rfu.n0_contrib,
'RFU'
--from parcelle p
where not exists (
select 1
from enquete e
where e.parcelle_id= p_parcelle_id
)
RETURNING id INTO enquete_id_parent ;
----------MAJ Caractéristique parcelle
INSERT INTO caracteristique_parcelle (
created_by,
created_at,
updated_by,
updated_at,
deleted,
caracteristique_id,
enquete_id
)
SELECT 35, now(), 35, now(), false,
CASE parcelle_rfu.acces
WHEN '1' THEN 31
WHEN '2' THEN 32
WHEN '3' THEN 33
WHEN '4' THEN 34
END,
enquete_id_parent
WHERE parcelle_rfu.acces IS NOT NULL
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE parcelle_rfu.cloture
WHEN '1' THEN 28
WHEN '2' THEN 29
WHEN '3' THEN 30
END,
enquete_id_parent
WHERE parcelle_rfu.cloture IS NOT NULL;
------MAJ Exercice
UPDATE enquete q
SET exercice_id = e.id
FROM exercice e
WHERE e.annee = 2025
AND q.id = enquete_id_parent;
------MAJ prietaire
UPDATE enquete q
SET personne_id = p.id,
proprietaire_id = p.id,
nom_proprietaire_parcelle = coalesce (trim(p.raison_sociale), trim(p.nom) || ' '|| trim(p.prenom) )
FROM personne p
WHERE p.nc = parcelle_rfu.n0_contrib
AND q.id = enquete_id_parent;
--quartier_id --commune_id --departement_id --arrondissement_id
UPDATE enquete e
SET quartier_id = q.id,
commune_id=c.id,
departement_id=c.departement_id,
arrondissement_id= a.id
FROM parcelle p
inner join quartier q on q.id = p.quartier_id
inner join arrondissement a on a.id = q.arrondissement_id
inner join commune c on c.id = a.commune_id
WHERE p.id = p_parcelle_id
AND e.id = enquete_id_parent;
END;
$procedure$;

View File

@@ -1,156 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_enqueteUnitLog_from_rfu_cipe(
IN uniteLogement_rfu record,
IN uniteLogement_id_param numeric,
IN l_personne_id_parent numeric
)
LANGUAGE plpgsql
AS $procedure$
DECLARE
enquete_uniteLogement_id_parent bigint;
BEGIN
INSERT INTO enquete_unite_logement (
created_at,
created_by,
deleted,
updated_at,
updated_by,
en_location,
montant_locatif_annuel_declare,
nbre_habitant,
nbre_menage,
nbre_piece,
sbee,
soneb,
personne_id,
unite_logement_id,
user_id,
nbre_mois_location,
valeur_unite_logement_estime,
source,
date_enquete,
observation,
date_fin_exemption,
superficie_au_sol,
superficie_louee,
statut_enquete,
categorie_batiment_id,
montant_locatif_annuel_calcule,
montant_mensuel_location,
usage_id,
valeur_unite_logement_calcule
)select
now(),
35,
false,
now(),
35,
case
when uniteLogement_rfu.nbmois=0 then false
else true
end,
uniteLogement_rfu.montmenl*12,
uniteLogement_rfu.nbhabit,
uniteLogement_rfu.nbmenage,
uniteLogement_rfu.nbpiece,
uniteLogement_rfu.electric,
uniteLogement_rfu.eau,
l_personne_id_parent,
uniteLogement_id_param,
35,
uniteLogement_rfu.nbmois,
uniteLogement_rfu.vlcalcule,
'RFU',
uniteLogement_rfu.mdate,
'MIGRATION',
uniteLogement_rfu.finexempt,
uniteLogement_rfu.surfsol,
uniteLogement_rfu.surfacelo,
'CLOTURE',
ProcedureRecupCategorieRFU(uniteLogement_rfu.n0etage::integer,uniteLogement_rfu.toit::integer),
uniteLogement_rfu.vllcalcule,
uniteLogement_rfu.montmenl,
CASE uniteLogement_rfu.utilisat
WHEN 1 THEN 8
WHEN 2 THEN 14
WHEN 3 THEN 9
END,
uniteLogement_rfu.vlcalcule
from unite_logement ul
where ul.id = uniteLogement_id_param
and not exists (
select 1
from enquete_unite_logement eul
where eul.unite_logement_id = ul.id
)
RETURNING id INTO enquete_uniteLogement_id_parent ;
----------MAJ Caractéristique Unite de logement
INSERT INTO caracteristique_unite_logement (
created_by,
created_at,
updated_by,
updated_at,
deleted,
caracteristique_id,
enquete_unite_logement_id
)
SELECT 35, now(), 35, now(),false,
CASE uniteLogement_rfu.toit
WHEN 1 THEN 55
WHEN 2 THEN 56
WHEN 3 THEN 57
WHEN 4 THEN 58
WHEN 5 THEN 59
WHEN 6 THEN 60
END,
enquete_uniteLogement_id_parent
WHERE uniteLogement_rfu.toit IS NOT NULL
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE uniteLogement_rfu.murs
WHEN 1 THEN 49
WHEN 2 THEN 50
WHEN 3 THEN 51
WHEN 4 THEN 52
WHEN 5 THEN 53
else
54
END,
enquete_uniteLogement_id_parent
WHERE uniteLogement_rfu.murs IS NOT null
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE uniteLogement_rfu.standing
WHEN 1 THEN 81
WHEN 2 THEN 82
WHEN 3 THEN 83
WHEN 4 THEN 84
END,
enquete_uniteLogement_id_parent
WHERE uniteLogement_rfu.standing IS NOT null
UNION ALL
SELECT 35, now(), 35, now(),false,
CASE uniteLogement_rfu.utilisat
WHEN 1 THEN 35
WHEN 2 THEN 36
WHEN 3 THEN 37
END,
enquete_uniteLogement_id_parent
WHERE uniteLogement_rfu.standing IS NOT null;
------MAJ Exercice
UPDATE enquete_unite_logement eul
SET exercice_id = e.id
FROM exercice e
WHERE e.annee = 2025
AND eul.id = enquete_uniteLogement_id_parent;
END;
$procedure$;

View File

@@ -1,99 +0,0 @@
SELECT dblink_connect(
'connexion_rfu',
'host=10.4.6.103 port=5432 dbname=rfu user=postgres password=Rfu@dm1N2@25TeMp0'
);
CREATE OR REPLACE PROCEDURE public.import_imposition_rfu_cotonou(in exercice varchar(10), in nombreLimit numeric)
LANGUAGE plpgsql
AS $procedure$
DECLARE
l_count numeric := 0;
imposition_rfu record;
l_parcelle_id_parent bigint;
l_code_quartier varchar(20);
BEGIN
FOR imposition_rfu IN (
SELECT FROM dblink(
'connexion_rfu',
$db$
SELECT
i.article ,
i.ifu ,
i.n0_contrib ,
i.denome ,
i.annees ,
i.nature ,
n.libnature ,
i.quartier,
q.libquart ,
i.n0_ilot ,
i.n0_parcel ,
i.nn,
COALESCE(i.montant,0) droit_simple,
COALESCE(i.penalite,0) penalite,
COALESCE(i.majorat,0) majoration,
COALESCE(i.montant,0)+COALESCE(i.penalite,0)+COALESCE(i.majorat,0) total_imposition
FROM stemichel.impotsra i
join agla.nature n on n.nature=i.nature
left join (select distinct
n0_ilot,
quartier,
libquart
from agla.quartier)q on (q.n0_ilot=i.n0_ilot and q.quartier=i.quartier)
-- WHERE i.annees = '2025' or (i.annees ='2024' and trim(i.nature) in ('3N', '4N', 'YN'))
limit 100
$db$
) AS c (
terrain varchar,
n0_ilot varchar,
n0_parcel varchar,
quartier varchar,
hauteur varchar,
rue varchar,
entree varchar,
vlcalcule varchar,
vllcalcule varchar,
)
WHERE NOT EXISTS (
SELECT 1
FROM public.parcelle p
WHERE p.numero_parcelle =
trim(c.quartier)||'-'||trim(c.n0_ilot)||'-'||trim(c.n0_parcel)
) and exists (
select 1
from public.ref_rfu_q_quartier_cotonou rq
where rq.rfu_q = trim(c.quartier)
)
limit nombreLimit
) LOOP
BEGIN
INSERT INTO parcelle (
created_at,
created_by,
deleted,
updated_at,
updated_by,
parcelle_id,
source
)
SELECT
now(),
35,
false,
now(),
35,
parcelle_id,
'RFU'
FROM ref_rfu_q_quartier_cotonou rq
WHERE rq.rfu_q = parcelle_rfu.q
RETURNING id, code_quartier
INTO l_parcelle_id_parent, l_code_quartier;
RAISE NOTICE 'Nombre impositions migrées : %', l_count;
END ;
END LOOP ;
END;
$procedure$;

View File

@@ -1,250 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_parcelle_and_enqueteparc_from_rfu_cipe(in nombreLimit numeric)
LANGUAGE plpgsql
AS $procedure$
DECLARE
l_count numeric := 0;
parcelle_rfu record;
l_parcelle_id_parent bigint;
l_code_quartier varchar(20);
BEGIN
FOR parcelle_rfu IN (
SELECT
trim(quartier)||'-'||trim(n0_ilot)||'-'||trim(n0_parcel) AS numero_parcelle,
terrain,
trim(n0_ilot) AS i,
trim(n0_parcel) AS p,
trim(quartier) AS q,
hauteur,
rue AS numero_rue,
entree AS num_entree_parcelle,
surface,
vlcalcule,
vllcalcule,
loue,
zones,
acces,
cloture,
inonde,
finexempt,
habite,
ordures,
"usage",
wc,
choix,
occupant,
nb_bat,
nb_prop,
nb_log,
nb_unit,
nb_mena,
nb_habit,
nb_act,
nb_contrib,
typeparc,
prixm2ne,
ifu,
n0_contrib,
secteur,
cipe
FROM dblink(
'connexion_rfu',
$db$
SELECT
terrain,
n0_ilot,
n0_parcel,
quartier,
hauteur,
rue,
entree,
vlcalcule,
vllcalcule,
loue,
zones,
acces,
cloture,
inonde,
finexempt,
habite,
ordures,
surface,
"usage",
wc,
choix,
occupant,
nb_bat,
nb_prop,
nb_log,
nb_unit,
nb_mena,
nb_habit,
nb_act,
nb_contrib,
typeparc,
prixm2ne,
ifu,
n0_contrib,
secteur,
cipe
FROM stemichel.parcelle
$db$
) AS c (
terrain varchar,
n0_ilot varchar,
n0_parcel varchar,
quartier varchar,
hauteur varchar,
rue varchar,
entree varchar,
vlcalcule varchar,
vllcalcule varchar,
loue varchar,
zones varchar,
acces varchar,
cloture varchar,
inonde varchar,
finexempt varchar,
habite varchar,
ordures varchar,
surface varchar,
"usage" varchar,
wc varchar,
choix varchar,
occupant varchar,
nb_bat varchar,
nb_prop varchar,
nb_log varchar,
nb_unit varchar,
nb_mena varchar,
nb_habit varchar,
nb_act varchar,
nb_contrib varchar,
typeparc varchar,
prixm2ne varchar,
ifu varchar,
n0_contrib varchar,
secteur varchar,
cipe varchar
)
WHERE NOT EXISTS (
SELECT 1
FROM public.parcelle p
WHERE p.numero_parcelle =
trim(c.quartier)||'-'||trim(c.n0_ilot)||'-'||trim(c.n0_parcel)
) and exists (
select 1
from public.ref_rfu_q_quartier_cotonou rq
where rq.rfu_q = trim(c.quartier)
)
limit nombreLimit
) LOOP
BEGIN
INSERT INTO parcelle (
created_at,
created_by,
deleted,
updated_at,
updated_by,
numero_parcelle,
qip,
type_domaine_id,
i,
p,
q,
code_quartier,
nature_domaine_id,
superficie,
altitude,
num_entree_parcelle,
numero_rue,
usage_id,
source
)
SELECT
now(),
35,
false,
now(),
35,
parcelle_rfu.numero_parcelle,
parcelle_rfu.numero_parcelle,
CASE parcelle_rfu.terrain
WHEN '1' THEN 2
WHEN '2' THEN 5
WHEN '3' THEN 4
END,
parcelle_rfu.i,
parcelle_rfu.p,
parcelle_rfu.q,
rq.code_quartier,
CASE parcelle_rfu.typeparc
WHEN '1' THEN 23
WHEN '2' THEN 27
WHEN '3' THEN 28
WHEN '4' THEN 29
END,
CASE
WHEN replace(trim(parcelle_rfu.surface), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(parcelle_rfu.surface, ',', '.')::numeric
END,
CASE
WHEN replace(trim(parcelle_rfu.hauteur), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(parcelle_rfu.hauteur, ',', '.')::numeric
END,
parcelle_rfu.num_entree_parcelle,
parcelle_rfu.numero_rue,
case parcelle_rfu.usage
WHEN '01' THEN 3
WHEN '02' THEN 4
WHEN '03' THEN 5
WHEN '04' THEN 6
WHEN '05' THEN 7
WHEN '11' THEN 8
WHEN '12' THEN 9
WHEN '13' THEN 10
WHEN '14' THEN 11
WHEN '21' THEN 12
WHEN '22' THEN 13
WHEN '23' THEN 14
WHEN '24' THEN 15
WHEN '25' THEN 16
END,
'RFU'
FROM ref_rfu_q_quartier_cotonou rq
WHERE rq.rfu_q = parcelle_rfu.q
RETURNING id, code_quartier
INTO l_parcelle_id_parent, l_code_quartier;
EXCEPTION WHEN NO_DATA_FOUND THEN
RAISE NOTICE 'Quartier RFU non trouvé pour %', parcelle_rfu.q;
CONTINUE;
--RAISE NOTICE 'Parcelle insérée : %, %', l_parcelle_id_parent, parcelle_rfu.q;
END;
------------------------------appel de enquete_parcelle------------------
CALL import_enqueteparc_from_rfu_cipe(parcelle_rfu, l_parcelle_id_parent);
INSERT INTO secteur_decoupage (
created_at, created_by, deleted, updated_at, updated_by,
date_debut, quartier_id, secteur_id, arrondissement_id, source
)
SELECT
now(), 35, false, now(), 35,
now(), q.id, s.id,a.id, 'RFU'
FROM ref_cipe_secteur_rfu_cotonou rcs
JOIN secteur s ON s.code= rcs.code_secteur
JOIN quartier q ON q.code = l_code_quartier
left join arrondissement a on a.id=q.arrondissement_id
WHERE rcs.cipe = parcelle_rfu.cipe
AND rcs.secteur = parcelle_rfu.secteur
ON CONFLICT (quartier_id, secteur_id) DO NOTHING;
l_count := l_count + 1;
END LOOP;
UPDATE parcelle p
SET quartier_id = q.id
FROM quartier q
WHERE q.code = p.code_quartier;
RAISE NOTICE 'Nombre de parcelles migrées : %', l_count;
END;
$procedure$;

View File

@@ -1,128 +0,0 @@
SELECT dblink_connect(
'connexion_rfu',
'host=10.4.6.103 port=5432 dbname=rfu user=postgres password=Rfu@dm1N2@25TeMp0'
);
--SELECT dblink_disconnect('connexion_rfu');
CREATE OR REPLACE PROCEDURE public.import_personne_from_rfu()
LANGUAGE plpgsql
AS $procedure$
BEGIN
INSERT INTO public.personne (
date_naissance_ou_consti,
ifu,
lieu_naissance,
nom,
prenom,
raison_sociale,
npi,
num_ravip,
tel1,
tel2,
adresse,
created_at,
created_by,
deleted,
updated_at,
updated_by,
nc,
sexe,
profession,
source
)
SELECT
CASE
WHEN c.date_nais IS NULL OR c.date_nais = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.date_nais !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.date_nais, 'YYYYMMDD'), 'YYYYMMDD') <> c.date_nais THEN NULL
ELSE to_date(c.date_nais, 'YYYYMMDD')
END,
c.ifu,
c.lieu_nais,
case
when (trim(c.nom_c)<>'' and trim(c.prenoms_c)<>'') then c.nom_c
when (trim(c.nom_c)='' and trim(c.prenoms_c)='' and trim(c.prenoms)<>'') then c.nom
end as nom,
case
when (trim(c.nom_c)<>'' and trim(c.prenoms_c)<>'') then c.prenoms_c
when (trim(c.nom_c)='' and trim(c.prenoms_c)='' and trim(c.prenoms)<>'') then c.prenoms
end as prenom,
case
when (trim(c.nom_c)='' and trim(c.prenoms_c)='' and trim(c.prenoms)='') then c.nom
when (trim(c.nom_c)<>'' and trim(c.prenoms_c)<>'' and trim(c.prenoms)='') then c.nom
end as raison_sociale,
--c.nom,
NULL::varchar,
NULL::varchar,
--c.prenoms,
c.autradr1,
c.autradr2,
COALESCE(c.quartier_c, '') || '_' ||
COALESCE(c.ilot_c, '') || '_' ||
COALESCE(c.parcel_c, ''),
now(),
NULL::bigint,
false,
now(),
NULL::bigint,
c.n0_contrib,
CASE c.sexe
WHEN '1' THEN 'MASCULIN'
WHEN '2' THEN 'FEMININ'
ELSE NULL
END,
c.profession,
'RFU'
FROM dblink(
'connexion_rfu',
$db$
SELECT
date_nais,
ifu,
lieu_nais,
nom,
prenoms,
nom_c,
prenoms_c,
autradr1,
autradr2,
quartier_c,
ilot_c,
parcel_c,
n0_contrib,
sexe,
profession
FROM stemichel.contrib
-- WHERE ifu IS NOT NULL
$db$
) AS c (
date_nais varchar,
ifu varchar,
lieu_nais varchar,
nom varchar,
prenoms varchar,
nom_c varchar,
prenoms_c varchar,
autradr1 varchar,
autradr2 varchar,
quartier_c varchar,
ilot_c varchar,
parcel_c varchar,
n0_contrib varchar,
sexe varchar,
profession varchar
)
WHERE NOT EXISTS (
SELECT 1
FROM public.personne p
WHERE p.nc = c.n0_contrib
);
END;
$procedure$;

View File

@@ -1,82 +0,0 @@
SELECT dblink_connect(
'connexion_rfu',
'host=10.4.6.103 port=5432 dbname=rfu user=postgres password=Rfu@dm1N2@25TeMp0'
);
--SELECT dblink_disconnect('connexion_rfu');
SELECT dblink_connect(
'connexion_sigibe_lecture',
'host=10.4.80.71 port=5433 dbname=sigibe user=sigibe_lecture password=lec243R6Khsg'
);
CREATE OR REPLACE PROCEDURE public.maj_personne_from_sigibe()
LANGUAGE plpgsql
AS $procedure$
DECLARE
BEGIN
UPDATE personne p
SET
nom = CASE
WHEN s.nom IS NOT NULL THEN s.nom
ELSE p.nom
END,
prenom = CASE
WHEN s.prenom IS NOT NULL THEN s.prenom
ELSE p.prenom
END,
raison_sociale = CASE
WHEN s.id_tiers_type = 'PM'
AND s.l_contribuable IS NOT NULL
THEN s.l_contribuable
ELSE p.raison_sociale
END,
tel1 = s.telephone,
numero_rccm = s.numero_rccm,
date_rccm = CASE
WHEN s.date_rccm IS NOT NULL
AND trim(s.date_rccm) <> ''
THEN s.date_rccm::date
ELSE p.date_rccm
END,
email = s.email,
npi = s.numero_piece_identite,
etat_identification_personne = 'IFU'
FROM (
SELECT *
FROM dblink(
'connexion_sigibe_lecture',
'
SELECT
c.r_contribuable,
t.nom,
t.prenom,
t.id_tiers_type,
t.telephone,
t.numero_rccm,
t.date_rccm,
t.email,
t.numero_piece_identite,
c.l_contribuable
FROM t_contribuable c
JOIN t_tiers t ON t.id_tiers = c.id_tiers
'
)
AS s(
r_contribuable varchar,
nom varchar,
prenom varchar,
id_tiers_type varchar,
telephone varchar,
numero_rccm varchar,
date_rccm varchar,
email varchar,
numero_piece_identite varchar,
l_contribuable varchar
)
) s
WHERE trim(p.ifu) = s.r_contribuable;
END;
$procedure$;

View File

@@ -1,297 +0,0 @@
CREATE OR REPLACE PROCEDURE public.import_uniteLogement_and_enqueteUnitLog_from_rfu(nombreLimit integer)
LANGUAGE plpgsql
AS $procedure$
DECLARE
l_count numeric := 0;
uniteLogement_rfu record;
l_uniteLogement_id_parent bigint;
l_batiment_id_parent bigint ;
l_personne_id_parent bigint ;
BEGIN
FOR uniteLogement_rfu IN (
SELECT
c.n0bat,
c.n0ul,
--c.n0etage,
CASE
WHEN replace(trim(c.n0etage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.n0etage, ',', '.')::numeric
end as n0etage,
c.quartier,
c.n0_ilot,
c.n0_parcel,
c.n0_contrib,
--c.montmenl,
CASE
WHEN replace(trim(c.montmenl), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.montmenl, ',', '.')::numeric
end as montmenl,
--c.surfsol,
CASE
WHEN replace(trim(c.surfsol), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.surfsol, ',', '.')::numeric
end as surfsol,
--c.surfacelo,
CASE
WHEN replace(trim(c.surfacelo), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.surfacelo, ',', '.')::numeric
end as surfacelo,
--c.vllcalcule,
CASE
WHEN replace(trim(c.vllcalcule), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.vllcalcule, ',', '.')::numeric
end as vllcalcule,
--c.bail,
CASE
WHEN replace(trim(c.bail), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.bail, ',', '.')::numeric
end as bail,
--c.nbetage,
CASE
WHEN replace(trim(c.nbetage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbetage, ',', '.')::numeric
end as nbetage,
--c.vlcalcule,
CASE
WHEN replace(trim(c.vlcalcule), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.vlcalcule, ',', '.')::numeric
end as vlcalcule,
--c.utilisat,
CASE
WHEN replace(trim(c.utilisat), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.utilisat, ',', '.')::numeric
end as utilisat,
--c.finexempt,
CASE
WHEN c.finexempt IS NULL OR c.finexempt = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.finexempt !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.finexempt, 'YYYYMMDD'), 'YYYYMMDD') <> c.finexempt THEN NULL
ELSE to_date(c.finexempt, 'YYYYMMDD')
end as finexempt,
--c.toit
CASE
WHEN replace(trim(c.toit), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.toit, ',', '.')::numeric
end as toit,
--nbhabit,
CASE
WHEN replace(trim(c.nbhabit), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbhabit, ',', '.')::numeric
end as nbhabit,
--nbmenage,
CASE
WHEN replace(trim(c.nbmenage), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbmenage, ',', '.')::numeric
end as nbmenage,
--nbmois,
CASE
WHEN replace(trim(c.nbmois), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbmois, ',', '.')::numeric
end as nbmois,
--electric,
CASE
WHEN trim(c.electric)='Non'
THEN false
else
true
end as electric,
--eau,
CASE
WHEN trim(c.eau)='Non'
THEN false
else
true
end as eau,
--nbpiece,
CASE
WHEN replace(trim(c.nbpiece), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbpiece, ',', '.')::numeric
end as nbpiece,
--nbunite
CASE
WHEN replace(trim(c.nbunite), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.nbunite, ',', '.')::numeric
end as nbunite,
CASE
WHEN c.mdate IS NULL OR c.mdate = '' THEN NULL
-- format incorrect (pas exactement 8 chiffres)
WHEN c.mdate !~ '^[0-9]{8}$' THEN NULL
-- date invalide réelle
WHEN to_char(to_date(c.mdate, 'YYYYMMDD'), 'YYYYMMDD') <> c.mdate THEN NULL
ELSE to_date(c.mdate, 'YYYYMMDD')
end as mdate,
--c.murs,
CASE
WHEN replace(trim(c.murs), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.murs, ',', '.')::numeric
end as murs,
--standing
CASE
WHEN replace(trim(c.standing), ',', '.') ~ '^[0-9]+(\.[0-9]+)?$'
THEN replace(c.standing, ',', '.')::numeric
end as standing
FROM dblink(
'connexion_rfu',
$db$
select distinct
ul.n0bat,
ul.n0ul,
ul.n0etage,
ul.quartier,
ul.n0_ilot,
ul.n0_parcel,
ul.n0_contrib,
ul.montmenl,
ul.surfsol,
ul.surfacelo,
ul.vllcalcule,
ul.bail,
--ul.valloest,
ul.nbetage,
ul.vlcalcule,
ul.utilisat,
ul.finexempt,
ul.nbunitlo,
ul.toit,
ul.nbhabit,
ul.nbmenage,
ul.nbmois,
ul.electric,
ul.eau,
ul.nbpiece,
ul.nbunite,
ul.mdate,
ul.murs,
ul.standing
FROM akpakpa.unitlog ul
$db$
) AS c (
n0bat varchar,
n0ul varchar,
n0etage varchar,
quartier varchar,
n0_ilot varchar,
n0_parcel varchar,
n0_contrib varchar,
montmenl varchar,
surfsol varchar,
surfacelo varchar,
vllcalcule varchar,
bail varchar,
--valloest varchar,
nbetage varchar,
vlcalcule varchar,
utilisat varchar,
finexempt varchar,
nbunitlo varchar,
toit varchar,
nbhabit varchar,
nbmenage varchar,
nbmois varchar,
electric varchar,
eau varchar,
nbpiece varchar,
nbunite varchar,
mdate varchar,
murs varchar,
standing varchar
)
WHERE NOT EXISTS (
SELECT 1
FROM public.unite_logement ul
WHERE ul.code =
trim(c.quartier)||'-'||trim(c.n0_ilot)||'-'||trim(c.n0_parcel)||'-'||trim(c.n0bat)||'-'||trim(c.n0ul)
)
limit nombreLimit
)
LOOP
-- Récupération ID batiment locale
SELECT b.id
INTO l_batiment_id_parent
FROM public.batiment b
WHERE b.code =
trim(uniteLogement_rfu.quartier)||'-'||trim(uniteLogement_rfu.n0_ilot)||'-'||trim(uniteLogement_rfu.n0_parcel)||'-'||trim(uniteLogement_rfu.n0bat)
LIMIT 1;
-- Récupération ID personne locale
SELECT p.id
INTO l_personne_id_parent
FROM public.personne p
WHERE p.nc =trim(uniteLogement_rfu.n0_contrib)
LIMIT 1;
-- Insertion unite logement local
INSERT INTO public.unite_logement(
created_at,
created_by,
deleted,
updated_at,
updated_by,
code,
nul,
numero_etage,
batiment_id,
--personne_id,
source,
superficie_au_sol,
superficie_louee,
categorie_batiment_id,
montant_locatif_annuel_calcule,
montant_locatif_annuel_declare,
montant_mensuel_location,
valeur_unite_logement_estime,
usage_id,
date_fin_exemption,
id_toit_rfu,
valeur_unite_logement_calcule,
nombre_etage
)
VALUES (
now(),
35,
false,
now(),
35,
trim(uniteLogement_rfu.quartier)||'-'||trim(uniteLogement_rfu.n0_ilot)||'-'||trim(uniteLogement_rfu.n0_parcel)||'-'||trim(uniteLogement_rfu.n0bat)||'-'||trim(uniteLogement_rfu.n0ul),
uniteLogement_rfu.n0ul,
uniteLogement_rfu.n0etage,
l_batiment_id_parent,
-- l_personne_id_parent,
'RFU',
uniteLogement_rfu.surfsol,
uniteLogement_rfu.surfacelo,
ProcedureRecupCategorieRFU(uniteLogement_rfu.nbetage::integer,uniteLogement_rfu.toit::integer),
uniteLogement_rfu.vllcalcule,
uniteLogement_rfu.bail,
uniteLogement_rfu.montmenl,
uniteLogement_rfu.vlcalcule,
CASE uniteLogement_rfu.utilisat
WHEN 1 THEN 8
WHEN 2 THEN 14
WHEN 3 THEN 9
END,
uniteLogement_rfu.finexempt,
uniteLogement_rfu.toit,
uniteLogement_rfu.vlcalcule,
uniteLogement_rfu.nbetage
)
RETURNING id INTO l_uniteLogement_id_parent;
call public.import_enqueteUnitLog_from_rfu_cipe(
uniteLogement_rfu,
l_uniteLogement_id_parent,
l_personne_id_parent
);
l_count := l_count + 1;
END LOOP;
RAISE NOTICE 'Nombre de unité de logement insérés : %', l_count;
END;
$procedure$;

View File

@@ -1,128 +0,0 @@
package io.gmss.fiscad.persistence.repositories.frontend;
import io.gmss.fiscad.entities.frontend.Fonctionnalite;
import io.gmss.fiscad.entities.infocad.metier.Piece;
import io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
public interface FonctionnaliteRepository extends JpaRepository<Fonctionnalite, Long> {
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb(
f.id,
f.code,
f.nom,
m.id,
m.code,
m.nom,
f.actif,
f.lien
)
from Fonctionnalite f
join f.moduleApp m
where f.id = :id
""")
Optional<FonctionnalitePayloadWeb> findPayloadById(@Param("id") Long id);
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb(
f.id,
f.code,
f.nom,
m.id,
m.code,
m.nom,
f.actif,
f.lien
)
from Fonctionnalite f
join f.moduleApp m
""")
List<FonctionnalitePayloadWeb> findAllPayload();
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb(
f.id,
f.code,
f.nom,
m.id,
m.code,
m.nom,
f.actif,
f.lien
)
from Fonctionnalite f
join f.moduleApp m
where m.id = :moduleId
""")
List<FonctionnalitePayloadWeb> findByModuleId(
@Param("moduleId") Long moduleId);
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb(
f.id,
f.code,
f.nom,
m.id,
m.code,
m.nom,
f.actif,
f.lien
)
from Fonctionnalite f
join f.moduleApp m
where m.id = :moduleId
and f.actif = :actif
""")
List<FonctionnalitePayloadWeb> findByModuleIdAndActif(
@Param("moduleId") Long moduleId,
@Param("actif") Boolean actif);
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb(
f.id,
f.code,
f.nom,
m.id,
m.code,
m.nom,
f.actif,
f.lien
)
from Fonctionnalite f
join f.moduleApp m
where f.code = :code
""")
Optional<FonctionnalitePayloadWeb> findByCode(
@Param("code") String code);
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb(
f.id,
f.code,
f.nom,
pmf.moduleApp.id,
pmf.moduleApp.code,
pmf.moduleApp.nom,
f.actif,
f.lien
)
from Fonctionnalite f
join ProfileModuleFonctionnalite pmf on pmf.fonctionnalite=f
where pmf.profile.id = :profilId
""")
List<FonctionnalitePayloadWeb> findByProfileId(
@Param("profilId") Long moduleId
);
}

View File

@@ -1,73 +0,0 @@
package io.gmss.fiscad.persistence.repositories.frontend;
import io.gmss.fiscad.entities.frontend.ModuleApp;
import io.gmss.fiscad.entities.infocad.metier.Piece;
import io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb;
import io.gmss.fiscad.paylaods.response.restoration.PiecePayLoadRestor;
import jakarta.transaction.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
public interface ModuleRepository extends JpaRepository<ModuleApp, Long> {
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb(
m.id,
m.code,
m.nom,
m.actif,
m.lien
)
from ModuleApp m
where m.id = :id
""")
Optional<ModulePayloadWeb> findPayloadById(@Param("id") Long id);
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb(
m.id,
m.code,
m.nom,
m.actif,
m.lien
)
from ModuleApp m
""")
List<ModulePayloadWeb> findAllPayload();
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb(
m.id,
m.code,
m.nom,
m.actif,
m.lien
)
from ModuleApp m
where m.actif = :actif
""")
List<ModulePayloadWeb> findByActif(@Param("actif") Boolean actif);
@Query("""
select distinct new io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb(
m.id,
m.code,
m.nom,
m.actif,
m.lien
)
from ModuleApp m
join ProfileModuleFonctionnalite pf on pf.moduleApp=m
where pf.profile.id = :Profilid
""")
List<ModulePayloadWeb> findPayloadByProfilId(@Param("Profilid") Long id);
}

View File

@@ -1,167 +0,0 @@
package io.gmss.fiscad.persistence.repositories.user;
import io.gmss.fiscad.entities.infocad.metier.Piece;
import io.gmss.fiscad.entities.user.ProfileModuleFonctionnalite;
import io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
public interface ProfileModuleFonctionnaliteRepository extends JpaRepository<ProfileModuleFonctionnalite, Long> {
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb(
pmf.id,
p.id,
p.nom,
p.description,
m.id,
m.code,
m.nom,
f.id,
f.code,
f.nom,
f.lien,
pmf.actif
)
from ProfileModuleFonctionnalite pmf
join pmf.profile p
join pmf.moduleApp m
join pmf.fonctionnalite f
where pmf.id = :id
""")
Optional<ProfileModuleFonctionnalitePayloadWeb> findPayloadById(
@Param("id") Long id);
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb(
pmf.id,
p.id,
p.nom,
p.description,
m.id,
m.code,
m.nom,
f.id,
f.code,
f.nom,
f.lien,
pmf.actif
)
from ProfileModuleFonctionnalite pmf
join pmf.profile p
join pmf.moduleApp m
join pmf.fonctionnalite f
order by p.nom, m.nom, f.nom
""")
List<ProfileModuleFonctionnalitePayloadWeb> findAllPayload();
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb(
pmf.id,
p.id,
p.nom,
p.description,
m.id,
m.code,
m.nom,
f.id,
f.code,
f.nom,
f.lien,
pmf.actif
)
from ProfileModuleFonctionnalite pmf
join pmf.profile p
join pmf.moduleApp m
join pmf.fonctionnalite f
""")
Page<ProfileModuleFonctionnalitePayloadWeb> findAllPayload(
Pageable pageable);
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb(
pmf.id,
p.id,
p.nom,
p.description,
m.id,
m.code,
m.nom,
f.id,
f.code,
f.nom,
f.lien,
pmf.actif
)
from ProfileModuleFonctionnalite pmf
join pmf.profile p
join pmf.moduleApp m
join pmf.fonctionnalite f
where p.id = :profileId
order by m.nom, f.nom
""")
List<ProfileModuleFonctionnalitePayloadWeb> findByProfileId(
@Param("profileId") Long profileId);
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb(
pmf.id,
p.id,
p.nom,
p.description,
m.id,
m.code,
m.nom,
f.id,
f.code,
f.nom,
f.lien,
pmf.actif
)
from ProfileModuleFonctionnalite pmf
join pmf.profile p
join pmf.moduleApp m
join pmf.fonctionnalite f
where m.id = :moduleId
order by p.nom, f.nom
""")
List<ProfileModuleFonctionnalitePayloadWeb> findByModuleId(
@Param("moduleId") Long moduleId);
@Query("""
select new io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb(
pmf.id,
p.id,
p.nom,
p.description,
m.id,
m.code,
m.nom,
f.id,
f.code,
f.nom,
f.lien,
pmf.actif
)
from ProfileModuleFonctionnalite pmf
join pmf.profile p
join pmf.moduleApp m
join pmf.fonctionnalite f
where p.id = :profileId
and pmf.actif = :actif
order by m.nom, f.nom
""")
List<ProfileModuleFonctionnalitePayloadWeb> findByProfileIdAndActif(
@Param("profileId") Long profileId,
@Param("actif") Boolean actif);
}

View File

@@ -46,7 +46,6 @@ public class TokenAuthentificationProvider {
//userDetails.getAuthorities().forEach(role -> roles.add(role.getAuthority())); //userDetails.getAuthorities().forEach(role -> roles.add(role.getAuthority()));
//claims.put("roles", roles); //claims.put("roles", roles);
User user = userRepository.findByUsername(userDetails.getUsername()).get(); User user = userRepository.findByUsername(userDetails.getUsername()).get();
user.setAvoirFonctions(null);
claims.put("user", getUserResponseFromUser(user)); claims.put("user", getUserResponseFromUser(user));
// JWT for authentication // JWT for authentication
String token = Jwts.builder() String token = Jwts.builder()

View File

@@ -2,20 +2,19 @@ package io.gmss.fiscad.service;
import io.gmss.fiscad.controllers.rfu.metier.ImpositionsTfuController; import io.gmss.fiscad.controllers.rfu.metier.ImpositionsTfuController;
import io.gmss.fiscad.entities.decoupage.*; import io.gmss.fiscad.entities.decoupage.*;
import io.gmss.fiscad.entities.frontend.Fonctionnalite;
import io.gmss.fiscad.entities.frontend.ModuleApp;
import io.gmss.fiscad.entities.infocad.metier.*; import io.gmss.fiscad.entities.infocad.metier.*;
import io.gmss.fiscad.entities.infocad.parametre.*; import io.gmss.fiscad.entities.infocad.parametre.*;
import io.gmss.fiscad.entities.rfu.metier.*; import io.gmss.fiscad.entities.rfu.metier.*;
import io.gmss.fiscad.entities.rfu.parametre.*; import io.gmss.fiscad.entities.rfu.parametre.*;
import io.gmss.fiscad.entities.user.*; import io.gmss.fiscad.entities.user.AvoirFonction;
import io.gmss.fiscad.entities.user.Fonction;
import io.gmss.fiscad.entities.user.Profile;
import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.StatutEnquete; 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.paylaods.request.crudweb.*; import io.gmss.fiscad.paylaods.request.crudweb.*;
import io.gmss.fiscad.persistence.repositories.decoupage.*; import io.gmss.fiscad.persistence.repositories.decoupage.*;
import io.gmss.fiscad.persistence.repositories.frontend.FonctionnaliteRepository;
import io.gmss.fiscad.persistence.repositories.frontend.ModuleRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.*; import io.gmss.fiscad.persistence.repositories.infocad.metier.*;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.*; import io.gmss.fiscad.persistence.repositories.infocad.parametre.*;
import io.gmss.fiscad.persistence.repositories.rfu.metier.*; import io.gmss.fiscad.persistence.repositories.rfu.metier.*;
@@ -24,7 +23,6 @@ import io.gmss.fiscad.persistence.repositories.rfu.parametre.BaremRfuRepository;
import io.gmss.fiscad.persistence.repositories.rfu.parametre.CaracteristiqueRepository; import io.gmss.fiscad.persistence.repositories.rfu.parametre.CaracteristiqueRepository;
import io.gmss.fiscad.persistence.repositories.rfu.parametre.ExerciceRepository; import io.gmss.fiscad.persistence.repositories.rfu.parametre.ExerciceRepository;
import io.gmss.fiscad.persistence.repositories.user.AvoirFonctionRepository; import io.gmss.fiscad.persistence.repositories.user.AvoirFonctionRepository;
import io.gmss.fiscad.persistence.repositories.user.ProfileModuleFonctionnaliteRepository;
import io.gmss.fiscad.persistence.repositories.user.ProfileRepository; import io.gmss.fiscad.persistence.repositories.user.ProfileRepository;
import io.gmss.fiscad.persistence.repositories.user.UserRepository; import io.gmss.fiscad.persistence.repositories.user.UserRepository;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -77,9 +75,6 @@ public class EntityFromPayLoadService {
private final NatureDomaineRepository natureDomaineRepository ; private final NatureDomaineRepository natureDomaineRepository ;
private final TypeDomaineRepository typeDomaineRepository ; private final TypeDomaineRepository typeDomaineRepository ;
private final CommuneCentreAssignationRepository communeCentreAssignationRepository ; private final CommuneCentreAssignationRepository communeCentreAssignationRepository ;
private final ModuleRepository moduleRepository ;
private final FonctionnaliteRepository fonctionnaliteRepository ;
private final ProfileModuleFonctionnaliteRepository profileModuleFonctionnaliteRepository ;
public CaracteristiqueParcelle getCaracteristiqueParcelleFromPayLoadWeb(CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb){ public CaracteristiqueParcelle getCaracteristiqueParcelleFromPayLoadWeb(CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb){
@@ -450,10 +445,10 @@ public class EntityFromPayLoadService {
avoirFonction.setFonction(optionalFonction.orElse(null)); avoirFonction.setFonction(optionalFonction.orElse(null));
avoirFonction.setUser(optionalUser.orElse(null)); avoirFonction.setUser(optionalUser.orElse(null));
avoirFonction.setTitre(avoirFonctionPaylaodWeb.getTitre()); avoirFonction.setTitre(avoirFonction.getTitre());
avoirFonction.setId(avoirFonctionPaylaodWeb.getId()); avoirFonction.setId(avoirFonction.getId());
avoirFonction.setDateDebut(avoirFonctionPaylaodWeb.getDateDebut()); avoirFonction.setDateDebut(avoirFonction.getDateDebut());
avoirFonction.setDateFin(avoirFonctionPaylaodWeb.getDateFin()); avoirFonction.setDateFin(avoirFonction.getDateFin());
return avoirFonction; return avoirFonction;
} }
@@ -1042,59 +1037,4 @@ public class EntityFromPayLoadService {
return communeCentreAssignation; return communeCentreAssignation;
} }
public ModuleApp getModuleFromPayloadWeb(ModulePayloadWeb modulePayloadWeb) {
ModuleApp moduleApp =new ModuleApp();
if(modulePayloadWeb.getId()!=null)
moduleApp = moduleRepository.findById(modulePayloadWeb.getId()).orElse(new ModuleApp());
moduleApp.setId(modulePayloadWeb.getId());
moduleApp.setCode(modulePayloadWeb.getCode());
moduleApp.setNom(modulePayloadWeb.getNom());
moduleApp.setActif(modulePayloadWeb.getActif());
return moduleApp ;
}
public Fonctionnalite getFonctionnaliteFromPayloadWeb(FonctionnalitePayloadWeb fonctionnalitePayloadWeb) {
Fonctionnalite fonctionnalite =new Fonctionnalite();
if(fonctionnalitePayloadWeb.getId()!=null)
fonctionnalite = fonctionnaliteRepository.findById(fonctionnalitePayloadWeb.getId()).orElse(new Fonctionnalite());
if (fonctionnalitePayloadWeb.getModuleId() != null) {
ModuleApp moduleApp = new ModuleApp();
moduleApp.setId(fonctionnalitePayloadWeb.getModuleId());
fonctionnalite.setModuleApp(moduleApp);
}
fonctionnalite.setId(fonctionnalitePayloadWeb.getId());
fonctionnalite.setCode(fonctionnalitePayloadWeb.getCode());
fonctionnalite.setNom(fonctionnalitePayloadWeb.getNom());
fonctionnalite.setActif(fonctionnalitePayloadWeb.getActif());
return fonctionnalite ;
}
public ProfileModuleFonctionnalite getProfileModuleFonctionnaliteFromPayloadWeb(ProfileModuleFonctionnalitePayloadWeb profileModuleFonctionnalitePayloadWeb) {
ProfileModuleFonctionnalite profileModuleFonctionnalite =new ProfileModuleFonctionnalite();
if(profileModuleFonctionnalitePayloadWeb.getId()!=null)
profileModuleFonctionnalite = profileModuleFonctionnaliteRepository.findById(profileModuleFonctionnalitePayloadWeb.getId()).orElse(new ProfileModuleFonctionnalite());
if (profileModuleFonctionnalitePayloadWeb.getModuleId() != null) {
ModuleApp moduleApp = new ModuleApp();
moduleApp.setId(profileModuleFonctionnalitePayloadWeb.getModuleId());
profileModuleFonctionnalite.setModuleApp(moduleApp);
}
if (profileModuleFonctionnalitePayloadWeb.getProfileId() != null) {
Profile profile = new Profile();
profile.setId(profileModuleFonctionnalitePayloadWeb.getProfileId());
profileModuleFonctionnalite.setProfile(profile);
}
if (profileModuleFonctionnalitePayloadWeb.getFonctionnaliteId() != null) {
Fonctionnalite fonctionnalite = new Fonctionnalite();
fonctionnalite.setId(profileModuleFonctionnalitePayloadWeb.getFonctionnaliteId());
profileModuleFonctionnalite.setFonctionnalite(fonctionnalite);
}
profileModuleFonctionnalite.setActif(profileModuleFonctionnalitePayloadWeb.getActif());
return profileModuleFonctionnalite ;
}
} }