Compare commits
104 Commits
develop
...
816bff63bd
| Author | SHA1 | Date | |
|---|---|---|---|
| 816bff63bd | |||
| 07dc4630db | |||
| 752f01cfc4 | |||
| 7911903bd8 | |||
| 953deff41c | |||
| aa8a24f81e | |||
| ad28588b0a | |||
| 1775c19c0a | |||
| dda6262b23 | |||
| 5094b1a945 | |||
| 0bedbf0764 | |||
| e333b82e96 | |||
| a192520b30 | |||
| 4cd6e7cbae | |||
| 6c0fa1ca27 | |||
| 1e4e8f9ff6 | |||
| d4d4a7be44 | |||
| 5ea1c93d2b | |||
| e325b12546 | |||
| 47bcda41fd | |||
| 3438da3880 | |||
| ebb91f8318 | |||
| 767756acfc | |||
| 84ede82428 | |||
| 5beddc7c1b | |||
| a6f7f3d465 | |||
| 43b060371a | |||
| 71f0aa6cd0 | |||
| 87f8ad7a61 | |||
| 6a29a3f43c | |||
| 3e871a31e6 | |||
| 9c62c99305 | |||
| 8fb0088010 | |||
| 1e810f0ddb | |||
| a54adcdcb8 | |||
| 6b63ae2f52 | |||
| 6851270bd5 | |||
| 739cc89872 | |||
| dffd6a54a3 | |||
| 267c09c064 | |||
| be4524ed67 | |||
| 06ea9474f1 | |||
| c0267fca5e | |||
| 55b97936ab | |||
| adcd51e32b | |||
| 666519df84 | |||
| beb41af562 | |||
| 57dfdaf64f | |||
| f7e3c118e2 | |||
| 2b4adc0db2 | |||
| a0baf985d4 | |||
| 85e9a41fe2 | |||
| 3102dbc053 | |||
| a21be6aef3 | |||
| 4d708ff4ca | |||
| ea1f92c7e2 | |||
| 9e5e8551f0 | |||
| b8b28a673b | |||
| 70c8c26367 | |||
| e1459d85ea | |||
| f927db064a | |||
| 0589883f8e | |||
| d73e64dbac | |||
| cf7c3aaeb2 | |||
| cd4fcb7aa0 | |||
| 1e0cfead5b | |||
| 0837d0ce08 | |||
| b58316bb88 | |||
| 209d1cd777 | |||
| 1eb3aeeda0 | |||
| b3c288628c | |||
| d45e01ac85 | |||
| 9bb0cc5c75 | |||
| 3a68fd2ce4 | |||
| fa7421c35b | |||
| 5cb9497163 | |||
| 15cac660bc | |||
| 0feec2982f | |||
| b5ab0772a0 | |||
| f293f65650 | |||
| cfd1104c28 | |||
| 7d64390bae | |||
| 4876d8ab14 | |||
| 2bfb298054 | |||
| 54ef33d1ab | |||
| 3fd779854f | |||
| de2928414b | |||
| 9d6d278d78 | |||
| c8b0457195 | |||
| 9cc74a9a38 | |||
| 8e6168d4ee | |||
| c1a8ce86a6 | |||
| 14feb49dcd | |||
| 39de1c48c0 | |||
| f9e2b32118 | |||
| 3ebb1cf165 | |||
| c84176b8d3 | |||
| 61f4dd513f | |||
| 5e9f437497 | |||
| 69af57f876 | |||
| 56f78e77f3 | |||
| 0c7dc082fd | |||
| 3f5d7e980c | |||
| 87be4e4483 |
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -33,15 +33,15 @@ public class EpaiementAcompte extends BaseEntity implements Serializable {
|
||||
private String rDoc;
|
||||
private String rImpot;
|
||||
private String idImpotType;
|
||||
private String idImpotNature; /// participe unicité
|
||||
private String ifu; /// participe unicité
|
||||
private String idImpotNature;
|
||||
private String ifu;
|
||||
private String rCommune;
|
||||
private String rQuartier; /// participe unicité
|
||||
private String rQuartier;
|
||||
private String qipQuartier;
|
||||
private String qipIlot; /// participe unicité
|
||||
private String qipParcelle; /// participe unicité
|
||||
private String qipIlot;
|
||||
private String qipParcelle;
|
||||
private String nup;
|
||||
private Long exercice; /// participe unicité
|
||||
private Long exercice;
|
||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
private LocalDate dateValidation;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -260,22 +260,6 @@ public enum UserRole {
|
||||
CREATE_PARAMETERS,
|
||||
READ_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
|
||||
DELETE_PARAMETERS
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ SELECT distinct on (exo.annee,dimp.parcelle_id,dimp.nature_impot)
|
||||
end as montant_base_imposition,
|
||||
dimp.valeur_locative_adm as montant_valeur_locative,
|
||||
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
|
||||
when cca.parcelle_id is not null then true
|
||||
else false
|
||||
@@ -123,8 +123,6 @@ FROM impositions_tfu imp
|
||||
LEFT JOIN structure st
|
||||
ON st.id = cca.structure_id
|
||||
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';
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -410,12 +410,10 @@ BEGIN
|
||||
batiment_id,
|
||||
unite_logement_id,
|
||||
superficie_au_sol_loue,
|
||||
personne_id,
|
||||
acompte,
|
||||
retenu_irf
|
||||
personne_id
|
||||
)
|
||||
SELECT
|
||||
v_annee-1,
|
||||
v_annee,
|
||||
d.code,
|
||||
d.nom,
|
||||
c.code,
|
||||
@@ -530,9 +528,7 @@ BEGIN
|
||||
b.id,
|
||||
NULL,
|
||||
eb.superficie_louee,
|
||||
ep.personne_id,
|
||||
tac.montant_acompte,
|
||||
trirf.montant_rirf
|
||||
ep.personne_id
|
||||
FROM parcelle p
|
||||
|
||||
-- Dernière enquête parcelle
|
||||
@@ -618,46 +614,10 @@ BEGIN
|
||||
ORDER BY br.quartier_id DESC NULLS LAST
|
||||
LIMIT 1
|
||||
) 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
|
||||
AND ul_filter.batiment_id IS NULL -- anti-join : pas d'unité logement
|
||||
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;
|
||||
|
||||
@@ -667,5 +627,3 @@ BEGIN
|
||||
END;
|
||||
$$;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -125,12 +125,10 @@ BEGIN
|
||||
batiment_id,
|
||||
unite_logement_id,
|
||||
superficie_au_sol_loue,
|
||||
personne_id,
|
||||
acompte,
|
||||
retenu_irf
|
||||
personne_id
|
||||
)
|
||||
SELECT
|
||||
v_annee-1,
|
||||
v_annee,
|
||||
d.code,
|
||||
d.nom,
|
||||
c.code,
|
||||
@@ -245,10 +243,9 @@ BEGIN
|
||||
b.id,
|
||||
NULL,
|
||||
eb.superficie_louee,
|
||||
ep.personne_id,
|
||||
tac.montant_acompte,
|
||||
trirf.montant_rirf
|
||||
ep.personne_id
|
||||
FROM parcelle p
|
||||
|
||||
-- Dernière enquête parcelle
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT
|
||||
@@ -332,46 +329,14 @@ BEGIN
|
||||
ORDER BY br.quartier_id DESC NULLS LAST
|
||||
LIMIT 1
|
||||
) 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
|
||||
AND ul_filter.batiment_id IS NULL -- anti-join : pas d'unité logement
|
||||
AND st.id = v_structure_id
|
||||
AND p.id=p_parcelle_id
|
||||
AND NOT EXISTS(select 1 from donnees_imposition_tfu dimptfu
|
||||
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.batiment_id=b.id)
|
||||
|
||||
|
||||
@@ -447,9 +447,7 @@ BEGIN
|
||||
batiment_id,
|
||||
unite_logement_id,
|
||||
superficie_au_sol_loue,
|
||||
personne_id,
|
||||
acompte,
|
||||
retenu_irf
|
||||
personne_id
|
||||
)
|
||||
SELECT
|
||||
v_annee,
|
||||
@@ -541,9 +539,8 @@ BEGIN
|
||||
b.id,
|
||||
ul.id,
|
||||
eul.superficie_louee,
|
||||
eul.personne_id,
|
||||
tac.montant_acompte,
|
||||
trirf.montant_rirf
|
||||
eul.personne_id
|
||||
|
||||
FROM parcelle p
|
||||
|
||||
LEFT JOIN LATERAL (
|
||||
@@ -631,39 +628,7 @@ BEGIN
|
||||
ORDER BY br.quartier_id DESC NULLS LAST
|
||||
LIMIT 1
|
||||
) 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
|
||||
AND st.id = v_structure_id
|
||||
|
||||
|
||||
@@ -104,9 +104,7 @@ BEGIN
|
||||
batiment_id,
|
||||
unite_logement_id,
|
||||
superficie_au_sol_loue,
|
||||
personne_id,
|
||||
acompte,
|
||||
retenu_irf
|
||||
personne_id
|
||||
)
|
||||
SELECT
|
||||
v_annee,
|
||||
@@ -198,9 +196,8 @@ BEGIN
|
||||
b.id,
|
||||
ul.id,
|
||||
eul.superficie_louee,
|
||||
eul.personne_id,
|
||||
tac.montant_acompte,
|
||||
trirf.montant_rirf
|
||||
eul.personne_id
|
||||
|
||||
FROM parcelle p
|
||||
|
||||
LEFT JOIN LATERAL (
|
||||
@@ -288,39 +285,7 @@ BEGIN
|
||||
ORDER BY br.quartier_id DESC NULLS LAST
|
||||
LIMIT 1
|
||||
) 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
|
||||
AND st.id = v_structure_id
|
||||
AND p.id=p_parcelle_id
|
||||
|
||||
@@ -128,8 +128,7 @@ BEGIN
|
||||
unite_logement_id,
|
||||
personne_id,
|
||||
nombre_ulog,
|
||||
nombre_bat,
|
||||
acompte
|
||||
nombre_bat
|
||||
)
|
||||
SELECT
|
||||
v_annee,
|
||||
@@ -363,8 +362,7 @@ BEGIN
|
||||
where ulog.batiment_id= b.id),
|
||||
(select count(*)
|
||||
from batiment bat
|
||||
where bat.parcelle_id= p.id),
|
||||
tac.montant_acompte
|
||||
where bat.parcelle_id= p.id)
|
||||
FROM parcelle p
|
||||
-- Dernière enquête parcelle
|
||||
LEFT JOIN LATERAL (
|
||||
@@ -446,24 +444,7 @@ BEGIN
|
||||
ORDER BY br.quartier_id DESC NULLS LAST
|
||||
LIMIT 1
|
||||
) 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
|
||||
--AND ul_filter.batiment_id IS NULL -- anti-join : pas d'unité logement
|
||||
AND st.id = v_structure_id ;
|
||||
|
||||
@@ -129,8 +129,7 @@ BEGIN
|
||||
unite_logement_id,
|
||||
personne_id,
|
||||
nombre_ulog,
|
||||
nombre_bat,
|
||||
acompte
|
||||
nombre_bat
|
||||
)
|
||||
SELECT
|
||||
v_annee,
|
||||
@@ -364,8 +363,7 @@ BEGIN
|
||||
where ulog.batiment_id= b.id),
|
||||
(select count(*)
|
||||
from batiment bat
|
||||
where bat.parcelle_id= p.id),
|
||||
tac.montant_acompte
|
||||
where bat.parcelle_id= p.id)
|
||||
FROM parcelle p
|
||||
-- Dernière enquête parcelle
|
||||
LEFT JOIN LATERAL (
|
||||
@@ -447,24 +445,7 @@ BEGIN
|
||||
ORDER BY br.quartier_id DESC NULLS LAST
|
||||
LIMIT 1
|
||||
) 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
|
||||
--AND ul_filter.batiment_id IS NULL -- anti-join : pas d'unité logement
|
||||
AND st.id = v_structure_id
|
||||
|
||||
@@ -150,8 +150,7 @@ BEGIN
|
||||
taux_tfu,
|
||||
parcelle_id,
|
||||
batiment_id,
|
||||
unite_logement_id,
|
||||
acompte
|
||||
unite_logement_id
|
||||
)
|
||||
SELECT
|
||||
v_annee,
|
||||
@@ -301,8 +300,8 @@ BEGIN
|
||||
v_taux_tfu,
|
||||
p.id,
|
||||
b.id,
|
||||
ul.id,
|
||||
tac.montant_acompte
|
||||
ul.id
|
||||
|
||||
FROM parcelle p
|
||||
-- Dernière enquête parcelle
|
||||
LEFT JOIN LATERAL (
|
||||
@@ -424,24 +423,7 @@ BEGIN
|
||||
ORDER BY br.quartier_id DESC NULLS LAST
|
||||
LIMIT 1
|
||||
) 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
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
|
||||
@@ -151,8 +151,7 @@ BEGIN
|
||||
taux_tfu,
|
||||
parcelle_id,
|
||||
batiment_id,
|
||||
unite_logement_id,
|
||||
acompte
|
||||
unite_logement_id
|
||||
)
|
||||
SELECT
|
||||
v_annee,
|
||||
@@ -302,8 +301,8 @@ BEGIN
|
||||
v_taux_tfu,
|
||||
p.id,
|
||||
b.id,
|
||||
ul.id,
|
||||
tac.montant_acompte
|
||||
ul.id
|
||||
|
||||
FROM parcelle p
|
||||
-- Dernière enquête parcelle
|
||||
LEFT JOIN LATERAL (
|
||||
@@ -425,24 +424,7 @@ BEGIN
|
||||
ORDER BY br.quartier_id DESC NULLS LAST
|
||||
LIMIT 1
|
||||
) 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
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
|
||||
@@ -230,8 +230,7 @@ BEGIN
|
||||
valeur_admin_parcelle_nb_metre_carre,
|
||||
montant_taxe,
|
||||
parcelle_id,
|
||||
personne_id,
|
||||
acompte
|
||||
personne_id
|
||||
)
|
||||
SELECT
|
||||
v_annee,
|
||||
@@ -291,8 +290,7 @@ BEGIN
|
||||
ELSE brnb.valeur_administrative * brnb.taux / 100
|
||||
END,
|
||||
p.id,
|
||||
ep.personne_id,
|
||||
tac.montant_acompte
|
||||
ep.personne_id
|
||||
FROM parcelle p
|
||||
LEFT JOIN (
|
||||
SELECT DISTINCT ON (parcelle_id)
|
||||
@@ -334,24 +332,7 @@ BEGIN
|
||||
|
||||
LEFT JOIN barem_rfu_non_bati brnb
|
||||
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
|
||||
AND st.id = v_structure_id
|
||||
|
||||
|
||||
@@ -68,8 +68,7 @@ BEGIN
|
||||
valeur_admin_parcelle_nb_metre_carre,
|
||||
montant_taxe,
|
||||
parcelle_id,
|
||||
personne_id,
|
||||
acompte ---champ pour cumul acompte
|
||||
personne_id
|
||||
)
|
||||
SELECT
|
||||
v_annee,
|
||||
@@ -129,8 +128,7 @@ BEGIN
|
||||
ELSE brnb.valeur_administrative * brnb.taux / 100
|
||||
END,
|
||||
p.id,
|
||||
ep.personne_id,
|
||||
tac.montant_acompte ---valeur pour cumul acompte
|
||||
ep.personne_id
|
||||
FROM parcelle p
|
||||
LEFT JOIN (
|
||||
SELECT DISTINCT ON (parcelle_id)
|
||||
@@ -172,24 +170,7 @@ BEGIN
|
||||
|
||||
LEFT JOIN barem_rfu_non_bati brnb
|
||||
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
|
||||
AND st.id = v_structure_id
|
||||
AND p.id=p_parcelle_id
|
||||
@@ -207,4 +188,3 @@ BEGIN
|
||||
END;
|
||||
$$;
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
$$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
$$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
$$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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$;
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,20 +2,19 @@ package io.gmss.fiscad.service;
|
||||
|
||||
import io.gmss.fiscad.controllers.rfu.metier.ImpositionsTfuController;
|
||||
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.parametre.*;
|
||||
import io.gmss.fiscad.entities.rfu.metier.*;
|
||||
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.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.*;
|
||||
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.parametre.*;
|
||||
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.ExerciceRepository;
|
||||
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.UserRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -77,9 +75,6 @@ public class EntityFromPayLoadService {
|
||||
private final NatureDomaineRepository natureDomaineRepository ;
|
||||
private final TypeDomaineRepository typeDomaineRepository ;
|
||||
private final CommuneCentreAssignationRepository communeCentreAssignationRepository ;
|
||||
private final ModuleRepository moduleRepository ;
|
||||
private final FonctionnaliteRepository fonctionnaliteRepository ;
|
||||
private final ProfileModuleFonctionnaliteRepository profileModuleFonctionnaliteRepository ;
|
||||
|
||||
|
||||
public CaracteristiqueParcelle getCaracteristiqueParcelleFromPayLoadWeb(CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb){
|
||||
@@ -450,10 +445,10 @@ public class EntityFromPayLoadService {
|
||||
|
||||
avoirFonction.setFonction(optionalFonction.orElse(null));
|
||||
avoirFonction.setUser(optionalUser.orElse(null));
|
||||
avoirFonction.setTitre(avoirFonctionPaylaodWeb.getTitre());
|
||||
avoirFonction.setId(avoirFonctionPaylaodWeb.getId());
|
||||
avoirFonction.setDateDebut(avoirFonctionPaylaodWeb.getDateDebut());
|
||||
avoirFonction.setDateFin(avoirFonctionPaylaodWeb.getDateFin());
|
||||
avoirFonction.setTitre(avoirFonction.getTitre());
|
||||
avoirFonction.setId(avoirFonction.getId());
|
||||
avoirFonction.setDateDebut(avoirFonction.getDateDebut());
|
||||
avoirFonction.setDateFin(avoirFonction.getDateFin());
|
||||
|
||||
return avoirFonction;
|
||||
}
|
||||
@@ -1042,59 +1037,4 @@ public class EntityFromPayLoadService {
|
||||
|
||||
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 ;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user