From 14816d9bd0c8be6fd2e6e78b3d03eca617a0d230 Mon Sep 17 00:00:00 2001 From: Aurince AKAKPO Date: Mon, 16 Feb 2026 01:14:25 +0100 Subject: [PATCH] gestion revu de code en utilisant uniquement les DTO --- .../infocad/metier/EnqueteController.java | 34 ++- .../infocad/metier/PersonneController.java | 18 ++ .../infocad/metier/PieceController.java | 224 +++++++++++++++++ .../rfu/metier/DeclarationNcController.java | 226 ++++++++++++++++++ .../entities/infocad/metier/Enquete.java | 5 + .../entities/rfu/metier/DeclarationNc.java | 16 +- .../infocad/metier/EnqueteServiceImpl.java | 21 +- .../infocad/metier/PersonneServiceImpl.java | 9 + .../infocad/metier/PieceServiceImpl.java | 84 ++++++- .../rfu/metier/DeclarationNcServiceImpl.java | 72 ++++-- .../infocad/metier/EnqueteService.java | 9 +- .../infocad/metier/PersonneService.java | 2 + .../infocad/metier/PieceService.java | 13 +- .../rfu/metier/DeclarationNcService.java | 15 +- .../paylaods/request/IfuEnLigneLoginBoby.java | 9 + .../request/IfuEnLigneRechercheBody.java | 8 + .../RecherchePersonneResquestBody.java | 12 + .../crudweb/DeclarationNcPayloadWeb.java | 26 +- .../request/crudweb/EnquetePayLoadWeb.java | 7 +- .../request/crudweb/PiecePayLoadWeb.java | 26 ++ .../infocad/metier/EnqueteRepository.java | 39 ++- .../infocad/metier/PieceRepository.java | 211 ++++++++++++++++ .../infocad/parametre/PersonneRepository.java | 4 + .../rfu/metier/DeclarationNcRepository.java | 124 ++++++++++ .../gmss/fiscad/service/CallAPIService.java | 138 +++++++++++ .../service/EntityFromPayLoadService.java | 15 +- src/main/resources/application-dgi.properties | 6 +- .../resources/application-test.properties | 5 + 28 files changed, 1301 insertions(+), 77 deletions(-) create mode 100644 src/main/java/io/gmss/fiscad/controllers/infocad/metier/PieceController.java create mode 100644 src/main/java/io/gmss/fiscad/controllers/rfu/metier/DeclarationNcController.java create mode 100644 src/main/java/io/gmss/fiscad/paylaods/request/IfuEnLigneLoginBoby.java create mode 100644 src/main/java/io/gmss/fiscad/paylaods/request/IfuEnLigneRechercheBody.java create mode 100644 src/main/java/io/gmss/fiscad/paylaods/request/RecherchePersonneResquestBody.java create mode 100755 src/main/java/io/gmss/fiscad/service/CallAPIService.java diff --git a/src/main/java/io/gmss/fiscad/controllers/infocad/metier/EnqueteController.java b/src/main/java/io/gmss/fiscad/controllers/infocad/metier/EnqueteController.java index b808e9f..a423df3 100644 --- a/src/main/java/io/gmss/fiscad/controllers/infocad/metier/EnqueteController.java +++ b/src/main/java/io/gmss/fiscad/controllers/infocad/metier/EnqueteController.java @@ -212,8 +212,8 @@ public class EnqueteController { summary = "Récupérer les enquetes d'une parcelle", description = "Permet de récuperer les enquêtes déjà réalisées sur une parcelles" ) - @GetMapping("/all/by-parcelle-id/{parcelleId}") - public ResponseEntity getAllByEnqueteDecoupageAdmin(@PathVariable Long parcelleId) { + @GetMapping("/by-parcelle-id/{parcelleId}") + public ResponseEntity getAllByParcelle(@PathVariable Long parcelleId) { try { return new ResponseEntity<>( new ApiResponse<>(true, enqueteService.getEnqueteListByParcelle(parcelleId), "Liste des enquetes chargée avec succès."), @@ -236,6 +236,36 @@ public class EnqueteController { } + @Operation( + summary = "Récupérer les enquetes d'une parcelle", + description = "Permet de récuperer les enquêtes déjà réalisées sur une parcelles" + ) + @GetMapping("/page/by-parcelle-id/{parcelleId}") + public ResponseEntity getAllByParcellePaged(@PathVariable Long parcelleId,@RequestParam int pageNo, @RequestParam int pageSize) { + try { + Pageable pageable = PageRequest.of(pageNo, pageSize); + return new ResponseEntity<>( + new ApiResponse<>(true, enqueteService.getEnqueteListByParcellePageable(parcelleId,pageable), "Liste des enquetes chargée avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + + @GetMapping("/all/dgi/decoupage-admin-for-enquete") diff --git a/src/main/java/io/gmss/fiscad/controllers/infocad/metier/PersonneController.java b/src/main/java/io/gmss/fiscad/controllers/infocad/metier/PersonneController.java index 0331d7c..9fdd9bd 100644 --- a/src/main/java/io/gmss/fiscad/controllers/infocad/metier/PersonneController.java +++ b/src/main/java/io/gmss/fiscad/controllers/infocad/metier/PersonneController.java @@ -7,6 +7,7 @@ import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.interfaces.infocad.metier.PersonneService; import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.dto.PersonneCompletDTO; +import io.gmss.fiscad.paylaods.request.RecherchePersonneResquestBody; import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb; import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb; import jakarta.validation.Valid; @@ -111,4 +112,21 @@ public class PersonneController { ); } } + + @PostMapping("/recherche") + public ResponseEntity rechercherPersonne(@RequestBody RecherchePersonneResquestBody recherchePersonneResquestBody ) { + try{ + personneService.recherchePersonne(recherchePersonneResquestBody); + + return new ResponseEntity<>( + new ApiResponse<>(true, null, "Personne retrouvée avec succès."), + HttpStatus.OK + ); + }catch (Exception e){ + return new ResponseEntity<>( + new ApiResponse<>(false, e.getMessage()), + HttpStatus.OK + ); + } + } } diff --git a/src/main/java/io/gmss/fiscad/controllers/infocad/metier/PieceController.java b/src/main/java/io/gmss/fiscad/controllers/infocad/metier/PieceController.java new file mode 100644 index 0000000..48117b2 --- /dev/null +++ b/src/main/java/io/gmss/fiscad/controllers/infocad/metier/PieceController.java @@ -0,0 +1,224 @@ +package io.gmss.fiscad.controllers.infocad.metier; + + +import io.gmss.fiscad.exceptions.*; +import io.gmss.fiscad.interfaces.infocad.metier.PieceService; +import io.gmss.fiscad.paylaods.ApiResponse; +import io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.client.HttpClientErrorException; + +@AllArgsConstructor +@RestController +@RequestMapping(value = "api/piece", produces = MediaType.APPLICATION_JSON_VALUE) +@SecurityRequirement(name = "bearer") +@Tag(name = "Piece") +@CrossOrigin(origins = "*") +public class PieceController { + + private final PieceService pieceService; + + private static final Logger logger = LoggerFactory.getLogger(PieceController.class); + + + + @PostMapping("/create") + public ResponseEntity createPiece(@RequestBody @Valid @Validated PiecePayLoadWeb piecePayLoadWeb) { + try { + piecePayLoadWeb = pieceService.createPiece(piecePayLoadWeb); + return new ResponseEntity<>( + new ApiResponse<>(true, piecePayLoadWeb, "Piece créé avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @PutMapping("/update/{id}") + public ResponseEntity updatePiece(@PathVariable Long id, @RequestBody PiecePayLoadWeb piecePayLoadWeb) { + try { + return new ResponseEntity<>( + new ApiResponse<>(true, pieceService.updatePiece(id,piecePayLoadWeb), "Piece mise à jour avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @DeleteMapping("/delete/{id}") + public ResponseEntity deletePiece(@PathVariable Long id) { + try { + pieceService.deletePiece(id); + return new ResponseEntity<>( + new ApiResponse<>(true, "Piece supprimée avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @GetMapping("/all") + public ResponseEntity getAllPieceList() { + try { + return new ResponseEntity<>( + new ApiResponse<>(true, pieceService.getPieceListToDto(), "Liste des caractéristiques chargée avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @GetMapping("/all-paged") + public ResponseEntity getAllPiecePaged(@RequestParam int pageNo, @RequestParam int pageSize) { + try { + Pageable pageable = PageRequest.of(pageNo, pageSize); + return new ResponseEntity<>( + new ApiResponse<>(true, pieceService.getPieceListToDtoPageable(pageable), "Liste des caractéristiques chargée avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @GetMapping("/all/by-enquete-id/{enqueteId}") + public ResponseEntity getAllPieceByEnqueteList(@PathVariable Long enqueteId) { + try { + return new ResponseEntity<>( + new ApiResponse<>(true, pieceService.getAllPieceByEnqueteToDto(enqueteId), "Liste des pieces chargée avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @GetMapping("/all-paged/by-enquete-id/{enqueteId}") + public ResponseEntity getAllPieceByParcellePaged(@PathVariable Long enqueteId, @RequestParam int pageNo, @RequestParam int pageSize) { + try { + Pageable pageable = PageRequest.of(pageNo, pageSize); + return new ResponseEntity<>( + new ApiResponse<>(true, pieceService.getAllPieceByEnqueteToDtoPageable(enqueteId,pageable), "Liste des pieces chargée avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @GetMapping("/id/{id}") + public ResponseEntity getPieceById(@PathVariable Long id) { + try { + return new ResponseEntity<>( + new ApiResponse<>(true, pieceService.getPieceByToDto(id), "Piece trouvée avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } +} diff --git a/src/main/java/io/gmss/fiscad/controllers/rfu/metier/DeclarationNcController.java b/src/main/java/io/gmss/fiscad/controllers/rfu/metier/DeclarationNcController.java new file mode 100644 index 0000000..aa5ea84 --- /dev/null +++ b/src/main/java/io/gmss/fiscad/controllers/rfu/metier/DeclarationNcController.java @@ -0,0 +1,226 @@ +package io.gmss.fiscad.controllers.rfu.metier; + + +import io.gmss.fiscad.exceptions.*; +import io.gmss.fiscad.interfaces.rfu.metier.DeclarationNcService; +import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService; +import io.gmss.fiscad.paylaods.ApiResponse; +import io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb; +import io.gmss.fiscad.paylaods.request.crudweb.EnqueteBatimentPayloadWeb; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.client.HttpClientErrorException; + +@AllArgsConstructor +@RestController +@RequestMapping(value = "api/declaration-nc", produces = MediaType.APPLICATION_JSON_VALUE) +@SecurityRequirement(name = "bearer") +@Tag(name = "Déclaration NC") +@CrossOrigin(origins = "*") +public class DeclarationNcController { + + private final DeclarationNcService declarationNcService; + private static final Logger logger = LoggerFactory.getLogger(DeclarationNcController.class); + + + + @PostMapping("/create") + public ResponseEntity createDeclarationNc(@RequestBody @Valid @Validated DeclarationNcPayloadWeb declarationNcPayloadWeb) { + try { + declarationNcPayloadWeb = declarationNcService.createDeclarationNc(declarationNcPayloadWeb); + return new ResponseEntity<>( + new ApiResponse<>(true, declarationNcPayloadWeb, "Déclaration NC créé avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @PutMapping("/update/{id}") + public ResponseEntity updateEnqueteBatiment(@PathVariable Long id, @RequestBody DeclarationNcPayloadWeb declarationNcPayloadWeb) { + try { + return new ResponseEntity<>( + new ApiResponse<>(true, declarationNcService.updateDeclarationNc(id, declarationNcPayloadWeb), "Enquete batiment mise à jour avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @DeleteMapping("/delete/{id}") + public ResponseEntity deleteEnqueteBatiment(@PathVariable Long id) { + try { + declarationNcService.deleteDeclarationNc(id); + return new ResponseEntity<>( + new ApiResponse<>(true, "Déclaration Nc supprimée avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @GetMapping("/all") + public ResponseEntity getAllEnqueteBatimentList() { + try { + return new ResponseEntity<>( + new ApiResponse<>(true, declarationNcService.getDeclarationNcList(), "Liste des Enquetes batiments chargée avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @GetMapping("/all-paged") + public ResponseEntity getAllEnqueteBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) { + try { + Pageable pageable = PageRequest.of(pageNo, pageSize); + + return new ResponseEntity<>( + new ApiResponse<>(true, declarationNcService.getDeclarationNcList(pageable), "Liste des Enquetes batiments chargée avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @GetMapping("/id/{id}") + public ResponseEntity getEnqueteBatimentById(@PathVariable Long id) { + try { + return new ResponseEntity<>( + new ApiResponse<>(true, declarationNcService.getDeclarationNcById(id), "Enquete batiment trouvée avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @GetMapping("/by-personne-id/{personneId}") + public ResponseEntity getDeclarationNcByPersonne(@PathVariable Long personneId) { + try { + return new ResponseEntity<>( + new ApiResponse<>(true, declarationNcService.getDeclarationNcByPersonneList(personneId), "Déclarations NC trouvée avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } + + @GetMapping("/page/by-personne-id/{personneId}") + public ResponseEntity getDeclarationNcByPersonnePaged(@PathVariable Long personneId,@RequestParam int pageNo, @RequestParam int pageSize) { + try { + Pageable pageable = PageRequest.of(pageNo, pageSize); + return new ResponseEntity<>( + new ApiResponse<>(true, declarationNcService.getDeclarationNcByPersonneList(personneId,pageable), "Déclaration NC trouvée avec succès."), + HttpStatus.OK + ); + } catch (HttpClientErrorException.MethodNotAllowed e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); + } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException | + FileStorageException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK); + } catch (NullPointerException e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); + } + } +} diff --git a/src/main/java/io/gmss/fiscad/entities/infocad/metier/Enquete.java b/src/main/java/io/gmss/fiscad/entities/infocad/metier/Enquete.java index 6fdebdf..ee88018 100644 --- a/src/main/java/io/gmss/fiscad/entities/infocad/metier/Enquete.java +++ b/src/main/java/io/gmss/fiscad/entities/infocad/metier/Enquete.java @@ -8,6 +8,7 @@ import io.gmss.fiscad.deserializer.LocalDateDeserializer; import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.decoupage.Arrondissement; import io.gmss.fiscad.entities.infocad.parametre.Bloc; +import io.gmss.fiscad.entities.infocad.parametre.ModeAcquisition; import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine; import io.gmss.fiscad.entities.infocad.parametre.Personne; import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle; @@ -74,6 +75,10 @@ public class Enquete extends BaseEntity implements Serializable { @ManyToOne private Exercice exercice; + @JsonIgnore + @ManyToOne + private ModeAcquisition modeAcquisition; + private Long mobileDataId; @JsonIgnore diff --git a/src/main/java/io/gmss/fiscad/entities/rfu/metier/DeclarationNc.java b/src/main/java/io/gmss/fiscad/entities/rfu/metier/DeclarationNc.java index 473e73d..22d8047 100644 --- a/src/main/java/io/gmss/fiscad/entities/rfu/metier/DeclarationNc.java +++ b/src/main/java/io/gmss/fiscad/entities/rfu/metier/DeclarationNc.java @@ -32,18 +32,22 @@ public class DeclarationNc extends BaseEntity implements Serializable { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @JsonFormat(pattern = "dd-MM-yyyy") + @JsonFormat(pattern = "yyyy-MM-dd") @JsonDeserialize(using = LocalDateDeserializer.class) private LocalDate dateDerniereDeclaration; - private String nc; - @OneToOne + @JsonFormat(pattern = "yyyy-MM-dd") + @JsonDeserialize(using = LocalDateDeserializer.class) + private LocalDate dateDeclarationNc; + + private String nc; + private String observation; + + @JsonIgnore + @ManyToOne private Structure structure; -// @JsonIgnore -// @ManyToOne -// private Enquete enquete; private Long enqueteExternalKey; diff --git a/src/main/java/io/gmss/fiscad/implementations/infocad/metier/EnqueteServiceImpl.java b/src/main/java/io/gmss/fiscad/implementations/infocad/metier/EnqueteServiceImpl.java index 366e3e0..58be9ea 100644 --- a/src/main/java/io/gmss/fiscad/implementations/infocad/metier/EnqueteServiceImpl.java +++ b/src/main/java/io/gmss/fiscad/implementations/infocad/metier/EnqueteServiceImpl.java @@ -308,24 +308,29 @@ public class EnqueteServiceImpl implements EnqueteService { } @Override - public Page getEnqueteList(Pageable pageable) { - return enqueteRepository.findAll(pageable); + public Page getEnqueteList(Pageable pageable) { + return enqueteRepository.findAllEnquetesToDtoPageable(pageable); } @Override - public List getEnqueteList() { - return enqueteRepository.findAll(); + public List getEnqueteList() { + return enqueteRepository.findAllEnquetesToDto(); } @Override - public List getEnqueteListByParcelle(Long parcelleId) { - return enqueteRepository.findAllByParcelle_Id(parcelleId); + public List getEnqueteListByParcelle(Long parcelleId) { + return enqueteRepository.findAllEnquetesByParcelleToDto(parcelleId); } @Override - public Optional getEnqueteById(Long id) { + public Page getEnqueteListByParcellePageable(Long parcelleId, Pageable pageable) { + return enqueteRepository.findAllEnquetesByParcelleToDtoPageable(parcelleId,pageable); + } + + @Override + public Optional getEnqueteById(Long id) { if (enqueteRepository.existsById(id)) { - return enqueteRepository.findById(id); + return enqueteRepository.findEnqueteToDto(id); } else { throw new NotFoundException("Impossible de trouver l'enquête."); } diff --git a/src/main/java/io/gmss/fiscad/implementations/infocad/metier/PersonneServiceImpl.java b/src/main/java/io/gmss/fiscad/implementations/infocad/metier/PersonneServiceImpl.java index bbcb784..0ce9cc8 100644 --- a/src/main/java/io/gmss/fiscad/implementations/infocad/metier/PersonneServiceImpl.java +++ b/src/main/java/io/gmss/fiscad/implementations/infocad/metier/PersonneServiceImpl.java @@ -7,6 +7,7 @@ import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.interfaces.infocad.metier.PersonneService; import io.gmss.fiscad.paylaods.dto.*; +import io.gmss.fiscad.paylaods.request.RecherchePersonneResquestBody; import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb; import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository; import io.gmss.fiscad.persistence.repositories.decoupage.NationaliteRepository; @@ -17,6 +18,7 @@ import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneReposit import io.gmss.fiscad.persistence.repositories.infocad.parametre.ProfessionRepository; import io.gmss.fiscad.persistence.repositories.infocad.parametre.SituationMatrimonialeRepository; import io.gmss.fiscad.persistence.repositories.infocad.parametre.TypePersonneRepository; +import io.gmss.fiscad.service.CallAPIService; import io.gmss.fiscad.service.EntityFromPayLoadService; import jakarta.persistence.EntityNotFoundException; import lombok.RequiredArgsConstructor; @@ -41,6 +43,7 @@ public class PersonneServiceImpl implements PersonneService { private final ProfessionRepository professionRepository; private final SituationMatrimonialeRepository situationMatrimonialeRepository; private final EntityFromPayLoadService entityFromPayLoadService; + private final CallAPIService callAPIService; @Override public Personne createPersonne(PersonnePayLoadWeb personnePayLoadWeb) throws BadRequestException { @@ -189,5 +192,11 @@ public class PersonneServiceImpl implements PersonneService { membres ); } + + @Override + public List recherchePersonne(RecherchePersonneResquestBody recherchePersonneResquestBody) { + callAPIService.callGetIfuEnLigneToken(); + return null; + } } diff --git a/src/main/java/io/gmss/fiscad/implementations/infocad/metier/PieceServiceImpl.java b/src/main/java/io/gmss/fiscad/implementations/infocad/metier/PieceServiceImpl.java index a019f02..3754cf3 100644 --- a/src/main/java/io/gmss/fiscad/implementations/infocad/metier/PieceServiceImpl.java +++ b/src/main/java/io/gmss/fiscad/implementations/infocad/metier/PieceServiceImpl.java @@ -1,44 +1,106 @@ package io.gmss.fiscad.implementations.infocad.metier; +import lombok.AllArgsConstructor; + + import io.gmss.fiscad.entities.infocad.metier.Piece; +import io.gmss.fiscad.entities.rfu.metier.DeclarationNc; import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.interfaces.infocad.metier.PieceService; +import io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb; +import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository; +import io.gmss.fiscad.persistence.repositories.infocad.metier.PieceRepository; +import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository; +import io.gmss.fiscad.service.EntityFromPayLoadService; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Service; +import java.time.LocalDate; import java.util.List; import java.util.Optional; +@AllArgsConstructor @Service public class PieceServiceImpl implements PieceService { + private final PieceRepository pieceRepository; + private final EntityFromPayLoadService entityFromPayLoadService; + private final EnqueteRepository enqueteRepository; + private final PersonneRepository personneRepository; @Override - public Piece createPiece(Piece piece) throws BadRequestException { - return null; + public PiecePayLoadWeb createPiece(PiecePayLoadWeb piecePayLoadWeb) throws BadRequestException { + if (piecePayLoadWeb.getId() != null) { + throw new BadRequestException("Impossible de créer une nouvelle déclaration NC ayant un id non null."); + } + + Piece piece= entityFromPayLoadService.getPieceFromPayLoadWeb(piecePayLoadWeb); + piece =pieceRepository.save(piece); + return pieceRepository.findPieceToDto(piece.getId()).orElse(null); } @Override - public Piece updatePiece(Long id, Piece piece) throws NotFoundException { - return null; + public PiecePayLoadWeb updatePiece(Long id, PiecePayLoadWeb piecePayLoadWeb) throws NotFoundException { + if (piecePayLoadWeb.getId() == null) { + throw new BadRequestException("La piece n'existe pas."); + } + + if (!pieceRepository.existsById(piecePayLoadWeb.getId())) { + throw new NotFoundException("La piece n'existe pas"); + } + + Piece piece= entityFromPayLoadService.getPieceFromPayLoadWeb(piecePayLoadWeb); + piece =pieceRepository.save(piece); + return pieceRepository.findPieceToDto(piece.getId()).orElse(null); } @Override public void deletePiece(Long id) throws NotFoundException { - + Optional pieceOptional = pieceRepository.findById(id); + if (pieceOptional.isPresent()) { + pieceRepository.deleteById(pieceOptional.get().getId()); + } else { + throw new NotFoundException("Impossible de trouver la piece à supprimer ."); + } } @Override - public Page getPieceList(Pageable pageable) { - return null; + public Page getPieceListToDtoPageable(Pageable pageable) { + return pieceRepository.findAllToDtoPageable(pageable); } @Override - public List getPieceList() { - return null; + public List getPieceListToDto() { + return pieceRepository.findAllPieceToDto(); } @Override - public Optional getPieceById(Long id) { - return Optional.empty(); + public Optional getPieceByToDto(Long id) { + return pieceRepository.findPieceToDto(id); + } + + @Override + public List getAllPieceByEnqueteToDto(Long id) { + return pieceRepository.findByFilters( + null, + null, + null, + null, + id, + null, + null); + } + + @Override + public Page getAllPieceByEnqueteToDtoPageable(Long id,Pageable pageable) { + return pieceRepository.findByFiltersPageable( + null, + null, + null, + null, + id, + null, + null, + pageable); } } diff --git a/src/main/java/io/gmss/fiscad/implementations/rfu/metier/DeclarationNcServiceImpl.java b/src/main/java/io/gmss/fiscad/implementations/rfu/metier/DeclarationNcServiceImpl.java index 47535a0..2e96984 100644 --- a/src/main/java/io/gmss/fiscad/implementations/rfu/metier/DeclarationNcServiceImpl.java +++ b/src/main/java/io/gmss/fiscad/implementations/rfu/metier/DeclarationNcServiceImpl.java @@ -1,43 +1,66 @@ package io.gmss.fiscad.implementations.rfu.metier; +import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueUniteLogement; import io.gmss.fiscad.entities.rfu.metier.DeclarationNc; import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.interfaces.rfu.metier.DeclarationNcService; +import io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb; +import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository; +import io.gmss.fiscad.persistence.repositories.infocad.parametre.StructureRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.DeclarationNcRepository; +import io.gmss.fiscad.service.EntityFromPayLoadService; +import lombok.AllArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; import java.util.Optional; - +@AllArgsConstructor @Service public class DeclarationNcServiceImpl implements DeclarationNcService { private final DeclarationNcRepository declarationNcRepository; + private final StructureRepository structureRepository; + private final PersonneRepository personneRepository; + private final EntityFromPayLoadService entityFromPayLoadService; - public DeclarationNcServiceImpl(DeclarationNcRepository declarationNcRepository) { - this.declarationNcRepository = declarationNcRepository; - } @Override - public DeclarationNc createDeclarationNc(DeclarationNc declarationNc) throws BadRequestException { - if (declarationNc.getId() != null) { - throw new BadRequestException("Impossible de créer une nouvelle enquete de batiment ayant un id non null."); + public DeclarationNcPayloadWeb createDeclarationNc(DeclarationNcPayloadWeb declarationNcPayloadWeb) throws BadRequestException { + if (declarationNcPayloadWeb.getId() != null) { + throw new BadRequestException("Impossible de créer une nouvelle déclaration NC ayant un id non null."); } - return declarationNcRepository.save(declarationNc); + if (!personneRepository.existsById(declarationNcPayloadWeb.getPersonneId())) { + throw new BadRequestException("Veuillez préciser le contribuable."); + } + if (!structureRepository.existsById(declarationNcPayloadWeb.getStructureId())) { + throw new BadRequestException("Veuillez préciser le centre."); + } + + DeclarationNc declarationNc= entityFromPayLoadService.getDeclarationNcFromPayLoadWeb(declarationNcPayloadWeb); + declarationNc =declarationNcRepository.save(declarationNc); + return declarationNcRepository.findDeclarationNcToDto(declarationNc.getId()).orElse(null); } @Override - public DeclarationNc updateDeclarationNc(Long id, DeclarationNc declarationNc) throws NotFoundException { - if (declarationNc.getId() == null) { + public DeclarationNcPayloadWeb updateDeclarationNc(Long id, DeclarationNcPayloadWeb declarationNcPayloadWeb) throws NotFoundException { + if (declarationNcPayloadWeb.getId() == null) { throw new BadRequestException("Impossible de mettre à jour une nouvelle enquete de batiment ayant un id null."); } - if (!declarationNcRepository.existsById(declarationNc.getId())) { + if (!declarationNcRepository.existsById(declarationNcPayloadWeb.getId())) { throw new NotFoundException("Impossible de trouver la nouvelle enquete de batiment spécifiée dans notre base de données."); } - return declarationNcRepository.save(declarationNc); + if (!personneRepository.existsById(declarationNcPayloadWeb.getPersonneId())) { + throw new BadRequestException("Veuillez préciser le contribuable."); + } + if (!structureRepository.existsById(declarationNcPayloadWeb.getStructureId())) { + throw new BadRequestException("Veuillez préciser le centre."); + } + DeclarationNc declarationNc= entityFromPayLoadService.getDeclarationNcFromPayLoadWeb(declarationNcPayloadWeb); + declarationNc =declarationNcRepository.save(declarationNc); + return declarationNcRepository.findDeclarationNcToDto(declarationNc.getId()).orElse(null); } @Override @@ -51,23 +74,36 @@ public class DeclarationNcServiceImpl implements DeclarationNcService { } @Override - public Page getDeclarationNcList(Pageable pageable) { - return declarationNcRepository.findAll(pageable); + public Page getDeclarationNcList(Pageable pageable) { + return declarationNcRepository.findAllDeclarationNcToDtoPageable(pageable); } @Override - public List getDeclarationNcList() { - return declarationNcRepository.findAll(); + public List getDeclarationNcList() { + return declarationNcRepository.findAllDeclarationNcToDto(); } + + + @Override - public Optional getDeclarationNcById(Long id) { + public Optional getDeclarationNcById(Long id) { if (declarationNcRepository.existsById(id)) { - return declarationNcRepository.findById(id); + return declarationNcRepository.findDeclarationNcToDto(id); } else { throw new NotFoundException("Impossible de trouver la nouvelle enquete de batiment spécifiée dans la base de données."); } } + + @Override + public Page getDeclarationNcByPersonneList(Long personneId, Pageable pageable) { + return declarationNcRepository.findAllDeclarationNcByPersonneToDtoPageable(personneId,pageable); + } + + @Override + public List getDeclarationNcByPersonneList(Long personneId) { + return declarationNcRepository.findAllDeclarationNcByPersonneToDto(personneId); + } } diff --git a/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/EnqueteService.java b/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/EnqueteService.java index 475a8c2..71b9e0c 100755 --- a/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/EnqueteService.java +++ b/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/EnqueteService.java @@ -25,17 +25,18 @@ public interface EnqueteService { void deleteEnquete(Long id) throws NotFoundException; - Page getEnqueteList(Pageable pageable); + Page getEnqueteList(Pageable pageable); - List getEnqueteList(); + List getEnqueteList(); - List getEnqueteListByParcelle(Long parcelleId); + List getEnqueteListByParcelle(Long parcelleId); + Page getEnqueteListByParcellePageable(Long parcelleId,Pageable pageable); List getEnqueteCommuneArrondBloc(); List getEnqueteCommuneArrondBlocFiltre(FiltreEnquetePayLoad filtreEnquetePayLoad); - Optional getEnqueteById(Long id); + Optional getEnqueteById(Long id); Enquete validerEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad); diff --git a/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/PersonneService.java b/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/PersonneService.java index 33dacd0..b1e22be 100755 --- a/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/PersonneService.java +++ b/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/PersonneService.java @@ -4,6 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.Personne; import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.paylaods.dto.PersonneCompletDTO; +import io.gmss.fiscad.paylaods.request.RecherchePersonneResquestBody; import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -25,4 +26,5 @@ public interface PersonneService { Optional getPersonneById(Long id); PersonneCompletDTO getPersonneComplete(Long id); + List recherchePersonne(RecherchePersonneResquestBody recherchePersonneResquestBody); } diff --git a/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/PieceService.java b/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/PieceService.java index 8e4c116..a0ab5ff 100755 --- a/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/PieceService.java +++ b/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/PieceService.java @@ -3,6 +3,7 @@ package io.gmss.fiscad.interfaces.infocad.metier; import io.gmss.fiscad.entities.infocad.metier.Piece; import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.NotFoundException; +import io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -11,15 +12,17 @@ import java.util.Optional; public interface PieceService { - Piece createPiece(Piece piece) throws BadRequestException; + PiecePayLoadWeb createPiece(PiecePayLoadWeb piecePayLoadWeb) throws BadRequestException; - Piece updatePiece(Long id, Piece piece) throws NotFoundException; + PiecePayLoadWeb updatePiece(Long id, PiecePayLoadWeb piecePayLoadWeb) throws NotFoundException; void deletePiece(Long id) throws NotFoundException; - Page getPieceList(Pageable pageable); + Page getPieceListToDtoPageable(Pageable pageable); - List getPieceList(); + List getPieceListToDto(); - Optional getPieceById(Long id); + Optional getPieceByToDto(Long id); + List getAllPieceByEnqueteToDto(Long id); + Page getAllPieceByEnqueteToDtoPageable(Long id,Pageable pageable); } diff --git a/src/main/java/io/gmss/fiscad/interfaces/rfu/metier/DeclarationNcService.java b/src/main/java/io/gmss/fiscad/interfaces/rfu/metier/DeclarationNcService.java index 29f75ef..94ef1ba 100755 --- a/src/main/java/io/gmss/fiscad/interfaces/rfu/metier/DeclarationNcService.java +++ b/src/main/java/io/gmss/fiscad/interfaces/rfu/metier/DeclarationNcService.java @@ -3,6 +3,7 @@ package io.gmss.fiscad.interfaces.rfu.metier; import io.gmss.fiscad.entities.rfu.metier.DeclarationNc; import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.NotFoundException; +import io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -11,15 +12,19 @@ import java.util.Optional; public interface DeclarationNcService { - DeclarationNc createDeclarationNc(DeclarationNc declarationNc) throws BadRequestException; + DeclarationNcPayloadWeb createDeclarationNc(DeclarationNcPayloadWeb declarationNcPayloadWeb) throws BadRequestException; - DeclarationNc updateDeclarationNc(Long id, DeclarationNc declarationNc) throws NotFoundException; + DeclarationNcPayloadWeb updateDeclarationNc(Long id, DeclarationNcPayloadWeb declarationNcPayloadWeb) throws NotFoundException; void deleteDeclarationNc(Long id) throws NotFoundException; - Page getDeclarationNcList(Pageable pageable); + Page getDeclarationNcList(Pageable pageable); - List getDeclarationNcList(); + List getDeclarationNcList(); - Optional getDeclarationNcById(Long id); + Optional getDeclarationNcById(Long id); + + Page getDeclarationNcByPersonneList(Long personneId,Pageable pageable); + + List getDeclarationNcByPersonneList(Long personneId); } diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/IfuEnLigneLoginBoby.java b/src/main/java/io/gmss/fiscad/paylaods/request/IfuEnLigneLoginBoby.java new file mode 100644 index 0000000..84aa09a --- /dev/null +++ b/src/main/java/io/gmss/fiscad/paylaods/request/IfuEnLigneLoginBoby.java @@ -0,0 +1,9 @@ +package io.gmss.fiscad.paylaods.request; + +import lombok.Data; + +@Data +public class IfuEnLigneLoginBoby { + private String password; + private String usernameOrEmail; +} diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/IfuEnLigneRechercheBody.java b/src/main/java/io/gmss/fiscad/paylaods/request/IfuEnLigneRechercheBody.java new file mode 100644 index 0000000..4b928ae --- /dev/null +++ b/src/main/java/io/gmss/fiscad/paylaods/request/IfuEnLigneRechercheBody.java @@ -0,0 +1,8 @@ +package io.gmss.fiscad.paylaods.request; + +public class IfuEnLigneRechercheBody { + private String ifu; + private String nom; + private String prenom; + private String dateNaissance; +} diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/RecherchePersonneResquestBody.java b/src/main/java/io/gmss/fiscad/paylaods/request/RecherchePersonneResquestBody.java new file mode 100644 index 0000000..ad968fd --- /dev/null +++ b/src/main/java/io/gmss/fiscad/paylaods/request/RecherchePersonneResquestBody.java @@ -0,0 +1,12 @@ +package io.gmss.fiscad.paylaods.request; + +import lombok.Data; + +@Data +public class RecherchePersonneResquestBody { + private String ifu; + private String nom; + private String nomMere; + private String prenom; + private String dateNaissance; +} diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/DeclarationNcPayloadWeb.java b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/DeclarationNcPayloadWeb.java index e3dd882..4ead394 100644 --- a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/DeclarationNcPayloadWeb.java +++ b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/DeclarationNcPayloadWeb.java @@ -1,5 +1,8 @@ package io.gmss.fiscad.paylaods.request.crudweb; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import io.gmss.fiscad.deserializer.LocalDateDeserializer; import lombok.Data; import java.time.LocalDate; @@ -9,10 +12,29 @@ import java.util.List; public class DeclarationNcPayloadWeb { private Long id; private LocalDate dateDerniereDeclaration; + private LocalDate dateDeclarationNc; private String nc; private Long structureId; - private Long enqueteId; + private String structureCode; + private String structureNom; private Long personneId; + private String personneNom; + private String personnePrenom; + private String personneRaisonSociale; private String observation; - private List uploadPayLoadWebs; + + public DeclarationNcPayloadWeb(Long id, LocalDate dateDerniereDeclaration, LocalDate dateDeclarationNc, String nc, Long structureId, String structureCode, String structureNom, Long personneId, String personneNom, String personnePrenom, String personneRaisonSociale, String observation) { + this.id = id; + this.dateDerniereDeclaration = dateDerniereDeclaration; + this.dateDeclarationNc = dateDeclarationNc; + this.nc = nc; + this.structureId = structureId; + this.structureCode = structureCode; + this.structureNom = structureNom; + this.personneId = personneId; + this.personneNom = personneNom; + this.personnePrenom = personnePrenom; + this.personneRaisonSociale = personneRaisonSociale; + this.observation = observation; + } } diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnquetePayLoadWeb.java b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnquetePayLoadWeb.java index 00b82dc..93616a6 100644 --- a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnquetePayLoadWeb.java +++ b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnquetePayLoadWeb.java @@ -57,8 +57,11 @@ public class EnquetePayLoadWeb { private String parcelleP; private Long exerviceId; private Integer exerviceAnnee; + private Long modeAcquisitionId; + private String modeAcquisitionLibelle; - public EnquetePayLoadWeb(Long id, LocalDate dateEnquete, LocalDate dateFinalisation, Boolean litige, StatutEnquete statutEnquete, String descriptionMotifRejet, String observation, String numeroTitreFoncier, LocalDate dateTitreFoncier, String numEntreeParcelle, String numRue, String nomRue, Float precision, Integer nbreCoProprietaire, Integer nbreIndivisiaire, String autreAdresse, Float superficie, Integer nbreBatiment, Integer nbrePiscine, LocalDate dateDebutExemption, LocalDate dateFinExemption, String autreNumeroTitreFoncier, Long montantMensuelleLocation, Long montantAnnuelleLocation, Long valeurParcelleEstime, Long valeurParcelleReel, Long zoneRfuId, String zoneRfuNom, Long personneId, String personneNom, String personnePrenom, String personneRaisonSociale, Long enqueteurId, String enqueteurNom, String enqueteurPrenom,Long parcelleId, String parcelleNup, String parcelleQ, String parcelleI, String parcelleP, Long exerviceId, Integer exerviceAnnee) { + public EnquetePayLoadWeb(Long id, LocalDate dateEnquete, LocalDate dateFinalisation, Boolean litige, StatutEnquete statutEnquete, String descriptionMotifRejet, String observation, String numeroTitreFoncier, LocalDate dateTitreFoncier, String numEntreeParcelle, String numRue, String nomRue, Float precision, Integer nbreCoProprietaire, Integer nbreIndivisiaire, String autreAdresse, Float superficie, Integer nbreBatiment, Integer nbrePiscine, LocalDate dateDebutExemption, LocalDate dateFinExemption, String autreNumeroTitreFoncier, Long montantMensuelleLocation, Long montantAnnuelleLocation, Long valeurParcelleEstime, Long valeurParcelleReel, Long zoneRfuId, String zoneRfuNom, Long personneId, String personneNom, String personnePrenom, String personneRaisonSociale, Long enqueteurId, String enqueteurNom, String enqueteurPrenom,Long parcelleId, String parcelleNup, String parcelleQ, String parcelleI, String parcelleP, Long exerviceId, Integer exerviceAnnee, + Long modeAcquisitionId,String modeAcquisitionLibelle) { this.id = id; this.dateEnquete = dateEnquete; this.dateFinalisation = dateFinalisation; @@ -101,5 +104,7 @@ public class EnquetePayLoadWeb { this.parcelleP = parcelleP; this.exerviceId = exerviceId; this.exerviceAnnee = exerviceAnnee; + this.modeAcquisitionId = modeAcquisitionId; + this.modeAcquisitionLibelle = modeAcquisitionLibelle; } } diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/PiecePayLoadWeb.java b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/PiecePayLoadWeb.java index 4b96c71..022f5a9 100644 --- a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/PiecePayLoadWeb.java +++ b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/PiecePayLoadWeb.java @@ -13,11 +13,37 @@ public class PiecePayLoadWeb { private String numeroPiece; private String url; private Long typePieceId; + private String typePieceLibelle; private Long personneId; + private String personneNom; + private String personnePrenom; + private String personneRaisonSociale; private Long sourceDroitId; + private String sourceDroitLibelle; private Long modeAcquisitionId; + private String modeAcquisitionLibelle; private String observation; private Long enqueteId; private List uploadPayLoadWebs; + + public PiecePayLoadWeb(Long id, LocalDate dateExpiration, LocalDate dateEtablissement, String numeroPiece, String url, Long typePieceId, String typePieceLibelle, Long personneId, String personneNom, String personnePrenom, String personneRaisonSociale, Long sourceDroitId, String sourceDroitLibelle, Long modeAcquisitionId, String modeAcquisitionLibelle, String observation, Long enqueteId) { + this.id = id; + this.dateExpiration = dateExpiration; + this.dateEtablissement = dateEtablissement; + this.numeroPiece = numeroPiece; + this.url = url; + this.typePieceId = typePieceId; + this.typePieceLibelle = typePieceLibelle; + this.personneId = personneId; + this.personneNom = personneNom; + this.personnePrenom = personnePrenom; + this.personneRaisonSociale = personneRaisonSociale; + this.sourceDroitId = sourceDroitId; + this.sourceDroitLibelle = sourceDroitLibelle; + this.modeAcquisitionId = modeAcquisitionId; + this.modeAcquisitionLibelle = modeAcquisitionLibelle; + this.observation = observation; + this.enqueteId = enqueteId; + } } diff --git a/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/metier/EnqueteRepository.java b/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/metier/EnqueteRepository.java index ffd0630..5dac39a 100755 --- a/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/metier/EnqueteRepository.java +++ b/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/metier/EnqueteRepository.java @@ -276,7 +276,9 @@ public interface EnqueteRepository extends JpaRepository { pa.i, pa.p, ex.id, - ex.annee + ex.annee, + ma.id, + ma.libelle ) FROM Enquete e LEFT JOIN e.zoneRfu zr @@ -284,6 +286,7 @@ public interface EnqueteRepository extends JpaRepository { LEFT JOIN e.user u LEFT JOIN e.parcelle pa LEFT JOIN e.exercice ex + LEFT JOIN e.modeAcquisition ma """) List findAllEnquetesToDto(); @@ -330,7 +333,9 @@ public interface EnqueteRepository extends JpaRepository { pa.i, pa.p, ex.id, - ex.annee + ex.annee, + ma.id, + ma.libelle ) FROM Enquete e LEFT JOIN e.zoneRfu zr @@ -338,6 +343,7 @@ public interface EnqueteRepository extends JpaRepository { LEFT JOIN e.user u LEFT JOIN e.parcelle pa LEFT JOIN e.exercice ex + LEFT JOIN e.modeAcquisition ma WHERE e.id = :enqueteId """) Optional findEnqueteToDto(@Param("enqueteId") Long enqueteId); @@ -386,7 +392,9 @@ public interface EnqueteRepository extends JpaRepository { pa.i, pa.p, ex.id, - ex.annee + ex.annee, + ma.id, + ma.libelle ) FROM Enquete e LEFT JOIN e.zoneRfu zr @@ -394,6 +402,7 @@ public interface EnqueteRepository extends JpaRepository { LEFT JOIN e.user u LEFT JOIN e.parcelle pa LEFT JOIN e.exercice ex + LEFT JOIN e.modeAcquisition ma """, countQuery = """ SELECT COUNT(e) @@ -445,7 +454,9 @@ public interface EnqueteRepository extends JpaRepository { pa.i, pa.p, ex.id, - ex.annee + ex.annee, + ma.id, + ma.libelle ) FROM Enquete e LEFT JOIN e.zoneRfu zr @@ -453,6 +464,7 @@ public interface EnqueteRepository extends JpaRepository { LEFT JOIN e.user u LEFT JOIN e.parcelle pa LEFT JOIN e.exercice ex + LEFT JOIN e.modeAcquisition ma WHERE ex.id = :exerciceId """) List findEnquetesByExerciceToDto( @@ -504,7 +516,9 @@ public interface EnqueteRepository extends JpaRepository { pa.i, pa.p, ex.id, - ex.annee + ex.annee, + ma.id, + ma.libelle ) FROM Enquete e LEFT JOIN e.zoneRfu zr @@ -512,6 +526,7 @@ public interface EnqueteRepository extends JpaRepository { LEFT JOIN e.user u LEFT JOIN e.parcelle pa LEFT JOIN e.exercice ex + LEFT JOIN e.modeAcquisition ma WHERE ex.id = :exerciceId """, countQuery = """ @@ -569,7 +584,9 @@ public interface EnqueteRepository extends JpaRepository { pa.i, pa.p, ex.id, - ex.annee + ex.annee, + ma.id, + ma.libelle ) FROM Enquete e LEFT JOIN e.zoneRfu zr @@ -577,9 +594,10 @@ public interface EnqueteRepository extends JpaRepository { LEFT JOIN e.user u LEFT JOIN e.parcelle pa LEFT JOIN e.exercice ex + LEFT JOIN e.modeAcquisition ma WHERE pa.id = :parcelleId """) - List findEnquetesByParcelleToDto( + List findAllEnquetesByParcelleToDto( @Param("parcelleId") Long parcelleId ); @@ -627,7 +645,9 @@ public interface EnqueteRepository extends JpaRepository { pa.i, pa.p, ex.id, - ex.annee + ex.annee, + ma.id, + ma.libelle ) FROM Enquete e LEFT JOIN e.zoneRfu zr @@ -635,6 +655,7 @@ public interface EnqueteRepository extends JpaRepository { LEFT JOIN e.user u LEFT JOIN e.parcelle pa LEFT JOIN e.exercice ex + LEFT JOIN e.modeAcquisition ma WHERE pa.id = :parcelleId """, countQuery = """ @@ -643,7 +664,7 @@ public interface EnqueteRepository extends JpaRepository { WHERE e.parcelle.id = :parcelleId """ ) - Page findEnquetesByParcelleToDtoPageable( + Page findAllEnquetesByParcelleToDtoPageable( @Param("parcelleId") Long parcelleId, Pageable pageable ); diff --git a/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/metier/PieceRepository.java b/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/metier/PieceRepository.java index e2edebf..062a010 100755 --- a/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/metier/PieceRepository.java +++ b/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/metier/PieceRepository.java @@ -1,12 +1,17 @@ package io.gmss.fiscad.persistence.repositories.infocad.metier; import io.gmss.fiscad.entities.infocad.metier.Piece; +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; @@ -51,5 +56,211 @@ public interface PieceRepository extends JpaRepository { List findByPersonne_IdAndEnqueteIsNull(Long id); + @Query(""" + SELECT new io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb( + p.id, + p.dateExpiration, + p.dateEtablissement, + p.numeroPiece, + p.url, + tp.id, + tp.libelle, + per.id, + per.nom, + per.prenom, + per.raisonSociale, + sd.id, + sd.libelle, + ma.id, + ma.libelle, + p.observation, + e.id + ) + FROM Piece p + LEFT JOIN p.typePiece tp + LEFT JOIN p.personne per + LEFT JOIN p.sourceDroit sd + LEFT JOIN p.modeAcquisition ma + LEFT JOIN p.enquete e + WHERE p.id = :pieceId + """) + Optional findPieceToDto(@Param("pieceId") Long pieceId); + + + @Query(""" + SELECT new io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb( + p.id, + p.dateExpiration, + p.dateEtablissement, + p.numeroPiece, + p.url, + tp.id, + tp.libelle, + per.id, + per.nom, + per.prenom, + per.raisonSociale, + sd.id, + sd.libelle, + ma.id, + ma.libelle, + p.observation, + e.id + ) + FROM Piece p + LEFT JOIN p.typePiece tp + LEFT JOIN p.personne per + LEFT JOIN p.sourceDroit sd + LEFT JOIN p.modeAcquisition ma + LEFT JOIN p.enquete e + """) + List findAllPieceToDto(); + + @Query( + value = """ + SELECT new io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb( + p.id, + p.dateExpiration, + p.dateEtablissement, + p.numeroPiece, + p.url, + tp.id, + tp.libelle, + per.id, + per.nom, + per.prenom, + per.raisonSociale, + sd.id, + sd.libelle, + ma.id, + ma.libelle, + p.observation, + e.id + ) + FROM Piece p + LEFT JOIN p.typePiece tp + LEFT JOIN p.personne per + LEFT JOIN p.sourceDroit sd + LEFT JOIN p.modeAcquisition ma + LEFT JOIN p.enquete e + """, + countQuery = """ + SELECT COUNT(p) + FROM Piece p + """ + ) + Page findAllToDtoPageable(Pageable pageable); + + + + @Query( + value = """ + SELECT new io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb( + p.id, + p.dateExpiration, + p.dateEtablissement, + p.numeroPiece, + p.url, + tp.id, + tp.libelle, + per.id, + per.nom, + per.prenom, + per.raisonSociale, + sd.id, + sd.libelle, + ma.id, + ma.libelle, + p.observation, + e.id + ) + FROM Piece p + LEFT JOIN p.typePiece tp + LEFT JOIN p.personne per + LEFT JOIN p.sourceDroit sd + LEFT JOIN p.modeAcquisition ma + LEFT JOIN p.enquete e + WHERE (:typePieceId IS NULL OR tp.id = :typePieceId) + AND (:personneId IS NULL OR per.id = :personneId) + AND (:sourceDroitId IS NULL OR sd.id = :sourceDroitId) + AND (:modeAcquisitionId IS NULL OR ma.id = :modeAcquisitionId) + AND (:enqueteId IS NULL OR e.id = :enqueteId) + AND (:dateDebut IS NULL OR p.dateEtablissement >= :dateDebut) + AND (:dateFin IS NULL OR p.dateEtablissement <= :dateFin) + """, + countQuery = """ + SELECT COUNT(p) + FROM Piece p + LEFT JOIN p.typePiece tp + LEFT JOIN p.personne per + LEFT JOIN p.sourceDroit sd + LEFT JOIN p.modeAcquisition ma + LEFT JOIN p.enquete e + WHERE (:typePieceId IS NULL OR tp.id = :typePieceId) + AND (:personneId IS NULL OR per.id = :personneId) + AND (:sourceDroitId IS NULL OR sd.id = :sourceDroitId) + AND (:modeAcquisitionId IS NULL OR ma.id = :modeAcquisitionId) + AND (:enqueteId IS NULL OR e.id = :enqueteId) + AND (:dateDebut IS NULL OR p.dateEtablissement >= :dateDebut) + AND (:dateFin IS NULL OR p.dateEtablissement <= :dateFin) + """ + ) + Page findByFiltersPageable( + @Param("typePieceId") Long typePieceId, + @Param("personneId") Long personneId, + @Param("sourceDroitId") Long sourceDroitId, + @Param("modeAcquisitionId") Long modeAcquisitionId, + @Param("enqueteId") Long enqueteId, + @Param("dateDebut") LocalDate dateDebut, + @Param("dateFin") LocalDate dateFin, + Pageable pageable + ); + + + @Query(""" + SELECT new io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb( + p.id, + p.dateExpiration, + p.dateEtablissement, + p.numeroPiece, + p.url, + tp.id, + tp.libelle, + per.id, + per.nom, + per.prenom, + per.raisonSociale, + sd.id, + sd.libelle, + ma.id, + ma.libelle, + p.observation, + e.id + ) + FROM Piece p + LEFT JOIN p.typePiece tp + LEFT JOIN p.personne per + LEFT JOIN p.sourceDroit sd + LEFT JOIN p.modeAcquisition ma + LEFT JOIN p.enquete e + WHERE (:typePieceId IS NULL OR tp.id = :typePieceId) + AND (:personneId IS NULL OR per.id = :personneId) + AND (:sourceDroitId IS NULL OR sd.id = :sourceDroitId) + AND (:modeAcquisitionId IS NULL OR ma.id = :modeAcquisitionId) + AND (:enqueteId IS NULL OR e.id = :enqueteId) + AND (:dateDebut IS NULL OR p.dateEtablissement >= :dateDebut) + AND (:dateFin IS NULL OR p.dateEtablissement <= :dateFin) + """ + ) + List findByFilters( + @Param("typePieceId") Long typePieceId, + @Param("personneId") Long personneId, + @Param("sourceDroitId") Long sourceDroitId, + @Param("modeAcquisitionId") Long modeAcquisitionId, + @Param("enqueteId") Long enqueteId, + @Param("dateDebut") LocalDate dateDebut, + @Param("dateFin") LocalDate dateFin + ); + } diff --git a/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/parametre/PersonneRepository.java b/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/parametre/PersonneRepository.java index ea70fff..b56f224 100755 --- a/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/parametre/PersonneRepository.java +++ b/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/parametre/PersonneRepository.java @@ -1,6 +1,7 @@ package io.gmss.fiscad.persistence.repositories.infocad.parametre; import io.gmss.fiscad.entities.infocad.parametre.Personne; +import io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb; import io.gmss.fiscad.paylaods.response.statistique.StatistiqueTypeNombreResponse; import io.gmss.fiscad.paylaods.response.restoration.PersonnePayLoad; import org.springframework.data.jpa.repository.JpaRepository; @@ -60,4 +61,7 @@ public interface PersonneRepository extends JpaRepository { group by tp.libelle """,nativeQuery = true) List getNombrePersonnesResponse(); + + + } diff --git a/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/DeclarationNcRepository.java b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/DeclarationNcRepository.java index 7da3692..88bffb9 100755 --- a/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/DeclarationNcRepository.java +++ b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/DeclarationNcRepository.java @@ -1,7 +1,12 @@ package io.gmss.fiscad.persistence.repositories.rfu.metier; import io.gmss.fiscad.entities.rfu.metier.DeclarationNc; +import io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb; +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.util.List; import java.util.Optional; @@ -10,5 +15,124 @@ import java.util.Optional; public interface DeclarationNcRepository extends JpaRepository { Optional findByMobileDataId(Long id); Optional findFirstByExternalKeyAndTerminal_Id(Long externalKey, Long TerminalId); + @Query(""" + SELECT new io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb( + d.id, + d.dateDerniereDeclaration, + d.dateDeclarationNc, + d.nc, + s.id, + s.code, + s.nom, + p.id, + p.nom, + p.prenom, + p.raisonSociale, + d.observation + ) + FROM DeclarationNc d + LEFT JOIN d.structure s + LEFT JOIN d.personne p + WHERE d.id = :declarationNcId + """) + Optional findDeclarationNcToDto(@Param("declarationNcId") Long declarationNcId); + + @Query(""" + SELECT new io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb( + d.id, + d.dateDerniereDeclaration, + d.dateDeclarationNc, + d.nc, + s.id, + s.code, + s.nom, + p.id, + p.nom, + p.prenom, + p.raisonSociale, + d.observation + ) + FROM DeclarationNc d + LEFT JOIN d.structure s + LEFT JOIN d.personne p + """) + List findAllDeclarationNcToDto(); + + @Query(""" + SELECT new io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb( + d.id, + d.dateDerniereDeclaration, + d.dateDeclarationNc, + d.nc, + s.id, + s.code, + s.nom, + p.id, + p.nom, + p.prenom, + p.raisonSociale, + d.observation + ) + FROM DeclarationNc d + LEFT JOIN d.structure s + LEFT JOIN d.personne p + """) + Page findAllDeclarationNcToDtoPageable(Pageable pageable); + + + @Query(""" + SELECT new io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb( + d.id, + d.dateDerniereDeclaration, + d.dateDeclarationNc, + d.nc, + s.id, + s.code, + s.nom, + p.id, + p.nom, + p.prenom, + p.raisonSociale, + d.observation + ) + FROM DeclarationNc d + LEFT JOIN d.structure s + LEFT JOIN d.personne p + WHERE p.id = :personneId + """) + List findAllDeclarationNcByPersonneToDto(@Param("personneId") Long personneId); + + @Query( + value = """ + SELECT new io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb( + d.id, + d.dateDerniereDeclaration, + d.dateDeclarationNc, + d.nc, + s.id, + s.code, + s.nom, + p.id, + p.nom, + p.prenom, + p.raisonSociale, + d.observation + ) + FROM DeclarationNc d + LEFT JOIN d.structure s + LEFT JOIN d.personne p + WHERE p.id = :personneId + """, + countQuery = """ + SELECT COUNT(d) + FROM DeclarationNc d + LEFT JOIN d.personne p + WHERE p.id = :personneId + """ + ) + Page findAllDeclarationNcByPersonneToDtoPageable( + @Param("personneId") Long personneId, + Pageable pageable + ); } diff --git a/src/main/java/io/gmss/fiscad/service/CallAPIService.java b/src/main/java/io/gmss/fiscad/service/CallAPIService.java new file mode 100755 index 0000000..212bdd0 --- /dev/null +++ b/src/main/java/io/gmss/fiscad/service/CallAPIService.java @@ -0,0 +1,138 @@ +package io.gmss.fiscad.service; + + +import io.gmss.fiscad.interfaces.ParametersRepository; +import io.gmss.fiscad.paylaods.request.IfuEnLigneLoginBoby; +import io.gmss.fiscad.paylaods.request.IfuEnLigneRechercheBody; +import jakarta.annotation.PostConstruct; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.server.MethodNotAllowedException; + +import java.util.List; + +@Service +public class CallAPIService { + + + private static final Logger logger = LoggerFactory.getLogger(CallAPIService.class); + + @Autowired + private ParametersRepository parametersRepository; + @Value("${ifu-en-ligne.api.base-url}") + private String ifuEnLigneBaseUrl; + + @Value("${ifu-en-ligne.api.username}") + private String ifuEnLigneUserName; + @Value("${ifu-en-ligne.api.password}") + private String ifuEnLignePassWord; + private String ifuEnLigneToken ; + + public RestTemplate executeRestemplate(String localTokenName,String accessToken){ + RestTemplate restTemplate = new RestTemplateBuilder(rt-> rt.getInterceptors().add((request, body, execution) -> { + if(localTokenName!=null) { + request.getHeaders().add(localTokenName, accessToken); + } + request.getHeaders().add("Accept", "application/json"); + request.getHeaders().add("Content-Type", "application/json"); + return execution.execute(request, body); + })).build(); + return restTemplate; + } + + public String callGetIfuEnLigneToken(){ + + try { + String url = ifuEnLigneBaseUrl+"/api/auth/signin" ; + IfuEnLigneLoginBoby ifuEnLigneLoginBoby=new IfuEnLigneLoginBoby(); + ifuEnLigneLoginBoby.setUsernameOrEmail(ifuEnLigneUserName); + ifuEnLigneLoginBoby.setPassword(ifuEnLignePassWord); + System.out.println("JE SUIS DANS LE CALL API : "+url); + HttpEntity request = new HttpEntity<>(ifuEnLigneLoginBoby); + RestTemplate restTemplate = executeRestemplate(null, null); + ResponseEntity response = restTemplate.postForEntity(url, request, String.class); + + if(response.getStatusCodeValue()==200){ + return response.getBody() ; + }else{ + System.out.println(response.getStatusCodeValue()); + + // sygmApiResponse.setStatut(false); + +// sygmApiResponse.setMessage("HttpStatus "+response.getStatusCodeValue()+" --- " +// +response.getBody().toString()); +// return sygmApiResponse; + return null; + } + }catch (Exception e ){ + System.out.println("IFU EN LIGNE : "+e.getMessage()) ; + e.printStackTrace(); + //throw new Exception(e.getMessage()) ; + return null; + } + } + + + +// public SygmApiResponse callPostSygmefCentre(String url, String tokenName, String accessToken, +// +// SygmApiResponse sygmApiResponse = new SygmApiResponse() ; +// try { +// HttpEntity request = new HttpEntity<>(centre); +// RestTemplate restTemplate = executeRestemplate(tokenName, accessToken); +// ResponseEntity response = restTemplate.postForEntity(url, request, SygmApiResponse.class); +// +// if(response.getStatusCodeValue()==200){ +// return response.getBody() ; +// }else{ +// sygmApiResponse.setStatut(false); +// +// sygmApiResponse.setMessage("HttpStatus "+response.getStatusCodeValue()+" --- " +// +response.getBody().toString()); +// return sygmApiResponse; +// } +// }catch (Exception e ){ +// System.out.println("SYGMEF : "+e.getMessage()) ; +// e.printStackTrace(); +// throw new Exception(e.getMessage()) ; +// } +// } + + + public void callApiRechercheContribIfuEnLigne(IfuEnLigneRechercheBody ifuEnLigneRechercheBody) { + try { + String url = ifuEnLigneBaseUrl+"/api/contribuable/fiscad"; + String token = callGetIfuEnLigneToken(); + RestTemplate restTemplate = executeRestemplate(null,null); + ResponseEntity response = restTemplate.getForEntity(url, String.class); + if(response.getStatusCode().value()==200){ + System.out.println(response.getBody()); + } + } catch ( + MethodNotAllowedException ex) { + logger.error(ex.toString()); + //return new ResponseEntity(null, HttpStatus.METHOD_NOT_ALLOWED); + } catch (Exception e) { + logger.error(e.toString()); + // return new ResponseEntity(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + + + + @PostConstruct + public void init(){ + + } + + +} diff --git a/src/main/java/io/gmss/fiscad/service/EntityFromPayLoadService.java b/src/main/java/io/gmss/fiscad/service/EntityFromPayLoadService.java index 40f6c98..51b32b4 100644 --- a/src/main/java/io/gmss/fiscad/service/EntityFromPayLoadService.java +++ b/src/main/java/io/gmss/fiscad/service/EntityFromPayLoadService.java @@ -169,6 +169,7 @@ public class EntityFromPayLoadService { if(piecePayLoadWeb.getPersonneId()!=null) optionalPersonne=personneRepository.findById(piecePayLoadWeb.getPersonneId()); + piece.setId(piecePayLoadWeb.getId()); piece.setEnquete(optionalEnquete.orElse(null)); piece.setTypePiece(optionalTypePiece.orElse(null)); @@ -184,25 +185,22 @@ public class EntityFromPayLoadService { public DeclarationNc getDeclarationNcFromPayLoadWeb(DeclarationNcPayloadWeb declarationNcPayloadWeb){ DeclarationNc declarationNc=new DeclarationNc(); - Optional optionalEnquete=Optional.empty(); Optional optionalPersonne=Optional.empty(); Optional optionalStructure=Optional.empty(); if(declarationNcPayloadWeb.getId()!=null) declarationNc = declarationNcRepository.findById(declarationNcPayloadWeb.getId()).orElse(new DeclarationNc()); -// if(declarationNcPayloadWeb.getEnqueteId()!=null) -// optionalEnquete=enqueteRepository.findById(declarationNcPayloadWeb.getEnqueteId()); - if(declarationNcPayloadWeb.getPersonneId()!=null) + if(declarationNcPayloadWeb.getPersonneId()!=null) optionalPersonne=personneRepository.findById(declarationNcPayloadWeb.getPersonneId()); if(declarationNcPayloadWeb.getStructureId()!=null) optionalStructure=structureRepository.findById(declarationNcPayloadWeb.getStructureId()); declarationNc.setId(declarationNcPayloadWeb.getId()); - //declarationNc.setEnquete(optionalEnquete.orElse(null)); declarationNc.setStructure(optionalStructure.orElse(null)); declarationNc.setPersonne(optionalPersonne.orElse(null)); declarationNc.setNc(declarationNcPayloadWeb.getNc()); declarationNc.setDateDerniereDeclaration(declarationNcPayloadWeb.getDateDerniereDeclaration()); + declarationNc.setDateDeclarationNc(declarationNcPayloadWeb.getDateDeclarationNc()); return declarationNc ; } @@ -733,6 +731,13 @@ public class EntityFromPayLoadService { } + if (enquetePayLoadWeb.getModeAcquisitionId() != null) { + ModeAcquisition modeAcquisition = new ModeAcquisition(); + modeAcquisition.setId(enquetePayLoadWeb.getModeAcquisitionId()); + enquete.setModeAcquisition(modeAcquisition); + } + + // ====================== // Champs simples diff --git a/src/main/resources/application-dgi.properties b/src/main/resources/application-dgi.properties index 9bf51db..1e2c50e 100755 --- a/src/main/resources/application-dgi.properties +++ b/src/main/resources/application-dgi.properties @@ -8,4 +8,8 @@ app.default-user.password=${DEFAULT_USER_PASSWORD} # PROD ENVIRONNEMENT spring.datasource.url=${SPRING_DATASOURCE_URL} spring.datasource.username=${SPRING_DATASOURCE_USERNAME} -spring.datasource.password=${SPRING_DATASOURCE_PASSWORD} \ No newline at end of file +spring.datasource.password=${SPRING_DATASOURCE_PASSWORD} + +ifu-en-ligne.api.base-url=https://ifubackend.impots.bj/ +ifu-en-ligne.api.username=cakpona +ifu-en-ligne.api.password=try \ No newline at end of file diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties index 005fca2..816fcbb 100755 --- a/src/main/resources/application-test.properties +++ b/src/main/resources/application-test.properties @@ -8,3 +8,8 @@ spring.datasource.password=W5fwD({9*q53 app.default-user.username=fiscad_admin app.default-user.password=1234567890 + + +ifu-en-ligne.api.base-url=https://ifubackend.impots.bj/ +ifu-en-ligne.api.username=cakpona +ifu-en-ligne.api.password=try -- 2.49.1