diff --git a/pom.xml b/pom.xml
index f58b9a9..fd1aafe 100755
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,7 @@
fiscad
Application de collecte des données socio-foncières
- 11
+ 17
2020.0.3
@@ -97,14 +97,12 @@
2.3.0
-
org.locationtech.jts
jts-core
- 1.19.0
+ 1.16.1
-
org.hibernate
hibernate-spatial
@@ -116,6 +114,7 @@
jackson-datatype-jts
1.2.4
+
org.teiid
teiid-optional-geo
@@ -142,6 +141,14 @@
org.springframework.boot
spring-boot-maven-plugin
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ 17
+
+
diff --git a/src/main/java/io/gmss/fiscad/controllers/infocad/metier/ParcelleGeomController.java b/src/main/java/io/gmss/fiscad/controllers/infocad/metier/ParcelleGeomController.java
index e5e03c3..ec9a99b 100644
--- a/src/main/java/io/gmss/fiscad/controllers/infocad/metier/ParcelleGeomController.java
+++ b/src/main/java/io/gmss/fiscad/controllers/infocad/metier/ParcelleGeomController.java
@@ -19,7 +19,7 @@ import org.springframework.web.multipart.MultipartFile;
@RestController
-@RequestMapping(value = "api/parcelleGeom", produces = MediaType.APPLICATION_JSON_VALUE)
+@RequestMapping(value = "api/parcelle-geom", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "ParcelleGeometrie")
@CrossOrigin(origins = "*")
@@ -32,7 +32,7 @@ public class ParcelleGeomController {
}
- @PostMapping("/create")
+ @PostMapping(value = "/create-from-geojsonfile",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity> createTpe(@RequestPart(required = true) MultipartFile file) {
try{
int n = parcelleGeomService.createParcelleFromGeoJsonFile(file);
@@ -53,7 +53,15 @@ public class ParcelleGeomController {
@GetMapping("/all")
public ResponseEntity> getAllTpeList() {
return new ResponseEntity<>(
- new ApiResponse<>(true, parcelleGeomService.getParcelleGeomList(), "Liste des tpe chargée avec succès."),
+ new ApiResponse<>(true, parcelleGeomService.getParcelleGeomList(), "Liste des parcelle chargée avec succès."),
+ HttpStatus.OK
+ );
+ }
+
+ @GetMapping("/by-quartier/{codeQuartier}")
+ public ResponseEntity> getAllTpeList(@PathVariable String codeQuartier) {
+ return new ResponseEntity<>(
+ new ApiResponse<>(true, parcelleGeomService.getParcelleGeomListUnQuatier(codeQuartier), "Liste des parcelle chargée avec succès."),
HttpStatus.OK
);
}
@@ -63,18 +71,23 @@ public class ParcelleGeomController {
public ResponseEntity> getAllTpePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
- new ApiResponse<>(true, parcelleGeomService.getParcelleGeomList(pageable), "Liste des tpe chargée avec succès."),
+ new ApiResponse<>(true, parcelleGeomService.getParcelleGeomList(pageable), "Liste des parcelle chargée avec succès."),
HttpStatus.OK
);
}
@GetMapping("/id/{id}")
- public ResponseEntity> getTpeById(@PathVariable Long id) {
- return new ResponseEntity<>(
- new ApiResponse<>(true, parcelleGeomService.getParcelleGeomById(id), "Tpe trouvé avec succès."),
- HttpStatus.OK
- );
+ public ResponseEntity> getParcelleGeomById(@PathVariable Long id) {
+ try {
+ return new ResponseEntity<>(
+ new ApiResponse<>(true, parcelleGeomService.getParcelleGeomById(id).orElse(null), "parcelle trouvé avec succès."),
+ HttpStatus.OK
+ );
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
+ }
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/io/gmss/fiscad/entities/decoupage/Arrondissement.java b/src/main/java/io/gmss/fiscad/entities/decoupage/Arrondissement.java
index 8e1a7d2..12e4f33 100644
--- a/src/main/java/io/gmss/fiscad/entities/decoupage/Arrondissement.java
+++ b/src/main/java/io/gmss/fiscad/entities/decoupage/Arrondissement.java
@@ -26,6 +26,8 @@ public class Arrondissement extends BaseEntity implements Serializable {
private Long id;
private String code;
private String nom;
+ private String longitude;
+ private String latitude;
@ManyToOne
private Commune commune;
@JsonIgnore
diff --git a/src/main/java/io/gmss/fiscad/entities/decoupage/Commune.java b/src/main/java/io/gmss/fiscad/entities/decoupage/Commune.java
index b12696b..4b98397 100644
--- a/src/main/java/io/gmss/fiscad/entities/decoupage/Commune.java
+++ b/src/main/java/io/gmss/fiscad/entities/decoupage/Commune.java
@@ -26,6 +26,8 @@ public class Commune extends BaseEntity implements Serializable {
private Long id;
private String code;
private String nom;
+ private String longitude;
+ private String latitude;
@ManyToOne
private Departement departement;
@JsonIgnore
diff --git a/src/main/java/io/gmss/fiscad/entities/decoupage/Secteur.java b/src/main/java/io/gmss/fiscad/entities/decoupage/Secteur.java
index 40b2dc3..b6c3ff9 100644
--- a/src/main/java/io/gmss/fiscad/entities/decoupage/Secteur.java
+++ b/src/main/java/io/gmss/fiscad/entities/decoupage/Secteur.java
@@ -30,9 +30,7 @@ public class Secteur extends BaseEntity implements Serializable {
private User chefSecteur;
@ManyToOne
private Structure structure;
- //@JsonIgnore
- //@OneToMany(mappedBy = "secteur")
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "secteur_id")
private List secteurDecoupages;
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/gmss/fiscad/entities/infocad/metier/ParcelleGeom.java b/src/main/java/io/gmss/fiscad/entities/infocad/metier/ParcelleGeom.java
index f7aa4d4..747791a 100644
--- a/src/main/java/io/gmss/fiscad/entities/infocad/metier/ParcelleGeom.java
+++ b/src/main/java/io/gmss/fiscad/entities/infocad/metier/ParcelleGeom.java
@@ -1,12 +1,8 @@
package io.gmss.fiscad.entities.infocad.metier;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Quartier;
-import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
-import io.gmss.fiscad.entities.rfu.metier.Batiment;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -15,15 +11,14 @@ import lombok.NoArgsConstructor;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.MultiPolygon;
-import org.locationtech.jts.geom.Point;
import org.locationtech.jts.geom.Polygon;
import org.n52.jackson.datatype.jts.GeometryDeserializer;
import org.n52.jackson.datatype.jts.GeometrySerializer;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
import java.io.Serializable;
-import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Entity
@@ -77,6 +72,9 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
@OneToOne
private Parcelle parcelle;
+ @ManyToOne
+ private Quartier quartier;
+
@ColumnDefault("0")
private int geomSrid;
@@ -87,8 +85,8 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
@JsonSerialize(using = GeometrySerializer.class)
@JsonDeserialize(contentUsing = GeometryDeserializer.class)
- // @Column(name = "geom_32631",columnDefinition = "geometry(Polygon,32631)")
+ @Column(name = "geometry",columnDefinition = "geometry(Polygon,32631)")
//private Polygon geometry32631 ;
- @Column(columnDefinition = "geometry")
- private Geometry geometry;
-}
\ No newline at end of file
+ //@Column(columnDefinition = "geometry")
+ private Polygon geometry;
+}
diff --git a/src/main/java/io/gmss/fiscad/entities/infocad/parametre/Structure.java b/src/main/java/io/gmss/fiscad/entities/infocad/parametre/Structure.java
index 59a13d5..d7c6c98 100644
--- a/src/main/java/io/gmss/fiscad/entities/infocad/parametre/Structure.java
+++ b/src/main/java/io/gmss/fiscad/entities/infocad/parametre/Structure.java
@@ -3,6 +3,7 @@ package io.gmss.fiscad.entities.infocad.parametre;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Arrondissement;
+import io.gmss.fiscad.entities.decoupage.Commune;
import io.gmss.fiscad.entities.user.User;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
@@ -43,6 +44,8 @@ public class Structure extends BaseEntity implements Serializable {
private String tel;
private String email;
private String adresse;
+ @ManyToOne
+ private Commune commune;
//@JsonIgnore
@ManyToMany
@JoinTable(name = "arrondissements_structures",
diff --git a/src/main/java/io/gmss/fiscad/implementations/infocad/metier/ParcelleGeomServiceImpl.java b/src/main/java/io/gmss/fiscad/implementations/infocad/metier/ParcelleGeomServiceImpl.java
index ec1d93b..b24047e 100644
--- a/src/main/java/io/gmss/fiscad/implementations/infocad/metier/ParcelleGeomServiceImpl.java
+++ b/src/main/java/io/gmss/fiscad/implementations/infocad/metier/ParcelleGeomServiceImpl.java
@@ -10,8 +10,11 @@ import io.gmss.fiscad.interfaces.infocad.metier.ParcelleGeomService;
import io.gmss.fiscad.paylaods.request.ParcelleGeomPayload;
import io.gmss.fiscad.repositories.infocad.metier.ParcelleGeomRepository;
import lombok.RequiredArgsConstructor;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Polygon;
import org.locationtech.jts.io.ParseException;
+import org.locationtech.jts.io.WKTWriter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;
@@ -57,6 +60,10 @@ public class ParcelleGeomServiceImpl implements ParcelleGeomService {
JsonNode feature = features.next();
createOnParcelleFromGeoJson(feature);
}
+ try {
+ parcelleGeomRepository.majIdQuartier();
+ }catch (Exception e){
+ }
return n;
}
@@ -66,40 +73,43 @@ public class ParcelleGeomServiceImpl implements ParcelleGeomService {
JsonNode propertiesNode = feature.get("properties");
WKTReader wktReader = new WKTReader();
if (geometryNode != null) {
- ObjectMapper objectMapper = new ObjectMapper();
- ParcelleGeomPayload parcelleGeomPayload =new ParcelleGeomPayload();
+ Polygon geometry = null;
try {
- parcelleGeomPayload = objectMapper.readValue(propertiesNode.toString(), ParcelleGeomPayload.class);
- } catch (JsonProcessingException e) {
- throw new RuntimeException(e);
- }
- Geometry geometry = null;
- try {
- String wkt = convertGeoJsonToWKT(geometryNode);
- geometry = wktReader.read(wkt);
+ geometry = convertGeoJsonToPolygon(geometryNode.toString());
} catch (ParseException e) {
- throw new RuntimeException(e);
+ e.printStackTrace();
+ //throw new RuntimeException(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ // throw new RuntimeException(e);
}
ParcelleGeom parcelleGeom = new ParcelleGeom();
parcelleGeom.setGeometry(geometry);
- parcelleGeom.setCommune(parcelleGeomPayload.getDepartement());
- parcelleGeom.setArrondissement(parcelleGeomPayload.getArrondissement());
- parcelleGeom.setVillageQuartier(parcelleGeomPayload.getVillageQuartier());
- parcelleGeom.setCodeBloc(parcelleGeomPayload.getCodeBloc());
- parcelleGeom.setCodeParcelle(parcelleGeomPayload.getCodeParcelle());
- parcelleGeom.setCodeEquipe(parcelleGeomPayload.getCodeEquipe());
- parcelleGeom.setSuperficie(parcelleGeomPayload.getSuperficie());
- parcelleGeom.setElNumeroEtatLieux(parcelleGeomPayload.getElNumeroEtatLieux());
- parcelleGeom.setElLot(parcelleGeomPayload.getElLot());
- parcelleGeom.setRfuQuartierOuZone(parcelleGeomPayload.getRfuQuartierOuZone());
- parcelleGeom.setElLettreParcelle(parcelleGeomPayload.getElLettreParcelle());
- parcelleGeom.setRfuIlot(parcelleGeomPayload.getRfuIlot());
- parcelleGeom.setRfuLettreParcelle(parcelleGeomPayload.getRfuLettreParcelle());
- parcelleGeom.setDateCollecte(parcelleGeomPayload.getDateCollecte());
- parcelleGeom.setNomLotissement(parcelleGeomPayload.getNomLotissement());
- parcelleGeom.setNomEtPrenoms(parcelleGeomPayload.getNomEtPrenoms());
- parcelleGeom.setSourceCollecte(parcelleGeomPayload.getSourceCollecte());
- parcelleGeom.setObservations(parcelleGeomPayload.getObservations());
+ parcelleGeom.setDepartement(propertiesNode.get("DEPARTEMENT").textValue());
+ parcelleGeom.setCommune(propertiesNode.get("COMMUNE").textValue());
+ parcelleGeom.setArrondissement(propertiesNode.get("ARRONDISSEMENT").textValue());
+ parcelleGeom.setVillageQuartier(propertiesNode.get("VILLAGE_QUARTIER").textValue());
+ parcelleGeom.setCodeBloc(propertiesNode.get("CODE_BLOC").textValue());
+ parcelleGeom.setCodeParcelle(propertiesNode.get("CODE_PARCELLE").textValue());
+ parcelleGeom.setCodeEquipe(propertiesNode.get("CODE_EQUIPE").textValue());
+
+
+ try {
+ parcelleGeom.setSuperficie(Integer.parseInt(propertiesNode.get("SUPERFICIE").textValue()));
+ }catch (Exception e){
+
+ }
+ parcelleGeom.setElNumeroEtatLieux(propertiesNode.get("EL_NUMERO_ETAT_LIEUX").textValue());
+ parcelleGeom.setElLot(propertiesNode.get("EL_LOT").textValue());
+ parcelleGeom.setRfuQuartierOuZone(propertiesNode.get("RFU_QUARTIER_OU_ZONE").textValue());
+ parcelleGeom.setElLettreParcelle(propertiesNode.get("EL_LETTRE_PARCELLE").textValue());
+ parcelleGeom.setRfuIlot(propertiesNode.get("RFU_ILOT").textValue());
+ parcelleGeom.setRfuLettreParcelle(propertiesNode.get("RFU_LETTRE_PARCELLE").textValue());
+ parcelleGeom.setDateCollecte(propertiesNode.get("DATE_COLLECTE").textValue());
+ parcelleGeom.setNomLotissement(propertiesNode.get("NOM_LOTISSEMENT").textValue());
+ parcelleGeom.setNomEtPrenoms(propertiesNode.get("NOM_ET_PRENOMS").textValue());
+ parcelleGeom.setSourceCollecte(propertiesNode.get("SOURCE_COLLECTE").textValue());
+ parcelleGeom.setObservations(propertiesNode.get("OBSERVATIONS").textValue());
return parcelleGeomRepository.save(parcelleGeom);
}else {
return null;
@@ -118,37 +128,53 @@ public class ParcelleGeomServiceImpl implements ParcelleGeomService {
@Override
public Page getParcelleGeomList(Pageable pageable) {
- return null;
+ return parcelleGeomRepository.findAll(pageable);
}
@Override
public List getParcelleGeomList() {
- return null;
+ return parcelleGeomRepository.findAll();
}
+ @Override
+ public List getParcelleGeomListUnQuatier(String codeQuartier) {
+ return parcelleGeomRepository.findAllByQuartier_Code(codeQuartier);
+ }
+
+
+
@Override
public Optional getParcelleGeomById(Long id) {
- return Optional.empty();
+ return parcelleGeomRepository.findById(id);
}
- private String convertGeoJsonToWKT(JsonNode geometryNode) {
- String type = geometryNode.get("type").asText();
- String coordinates = geometryNode.get("coordinates").toString();
- switch (type) {
- case "Point":
- return "POINT " + formatCoordinates(coordinates);
- case "LineString":
- return "LINESTRING " + formatCoordinates(coordinates);
- case "Polygon":
- return "POLYGON " + formatCoordinates(coordinates);
- default:
- throw new RuntimeException("Type géométrique non pris en charge : " + type);
+ public Polygon convertGeoJsonToPolygon(String geoJson) throws Exception {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode rootNode = mapper.readTree(geoJson);
+
+ if (!rootNode.has("type") || !rootNode.has("coordinates")) {
+ throw new IllegalArgumentException("GeoJSON invalide");
}
+
+ String type = rootNode.get("type").asText();
+ JsonNode coordinatesNode = rootNode.get("coordinates");
+
+ GeometryFactory geometryFactory = new GeometryFactory();
+
+ if ("Polygon".equals(type) || "geometry".equals(type)) {
+ JsonNode firstRing = coordinatesNode.get(0);
+ Coordinate[] coordinates = new Coordinate[firstRing.size()];
+ for (int i = 0; i < firstRing.size(); i++) {
+ JsonNode point = firstRing.get(i);
+ double x = point.get(0).asDouble();
+ double y = point.get(1).asDouble();
+ coordinates[i] = new Coordinate(x, y);
+ }
+ return geometryFactory.createPolygon(coordinates);
+ }
+ throw new UnsupportedOperationException("Type GeoJSON non supporté: " + type);
}
- private String formatCoordinates(String jsonCoords) {
- return jsonCoords.replace("[", "(").replace("]", ")").replace(",", " ");
- }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/ParcelleGeomService.java b/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/ParcelleGeomService.java
index ae369eb..44b16b4 100644
--- a/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/ParcelleGeomService.java
+++ b/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/ParcelleGeomService.java
@@ -20,5 +20,7 @@ public interface ParcelleGeomService {
void deleteParcelle(Long id) throws NotFoundException;
Page getParcelleGeomList(Pageable pageable);
List getParcelleGeomList();
+ List getParcelleGeomListUnQuatier(String codeQuartier);
+
Optional getParcelleGeomById(Long id);
}
diff --git a/src/main/java/io/gmss/fiscad/paylaods/response/ArrondissementEnqResponse.java b/src/main/java/io/gmss/fiscad/paylaods/response/ArrondissementEnqResponse.java
index a0bbd47..afbe764 100644
--- a/src/main/java/io/gmss/fiscad/paylaods/response/ArrondissementEnqResponse.java
+++ b/src/main/java/io/gmss/fiscad/paylaods/response/ArrondissementEnqResponse.java
@@ -6,6 +6,8 @@ public interface ArrondissementEnqResponse {
public String getCode();
public String getLibelle();
+ public String getLongitude();
+ public String getLatitude();
public Long getCommuneId();
diff --git a/src/main/java/io/gmss/fiscad/paylaods/response/ArrondissementSyncResponse.java b/src/main/java/io/gmss/fiscad/paylaods/response/ArrondissementSyncResponse.java
index a5b9e0f..8145aca 100644
--- a/src/main/java/io/gmss/fiscad/paylaods/response/ArrondissementSyncResponse.java
+++ b/src/main/java/io/gmss/fiscad/paylaods/response/ArrondissementSyncResponse.java
@@ -6,6 +6,8 @@ public interface ArrondissementSyncResponse {
public String getCode();
public String getNom();
+ public String getLongitude();
+ public String getLatitude();
public Long getCommuneId();
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/gmss/fiscad/paylaods/response/CommuneEnqResponse.java b/src/main/java/io/gmss/fiscad/paylaods/response/CommuneEnqResponse.java
index a35ef33..1371248 100644
--- a/src/main/java/io/gmss/fiscad/paylaods/response/CommuneEnqResponse.java
+++ b/src/main/java/io/gmss/fiscad/paylaods/response/CommuneEnqResponse.java
@@ -6,7 +6,8 @@ public interface CommuneEnqResponse {
public String getCode();
public String getLibelle();
+ public String getLongitude();
+ public String getLatitude();
public Long getNombreEnquete();
}
-
diff --git a/src/main/java/io/gmss/fiscad/paylaods/response/CommuneSyncResponse.java b/src/main/java/io/gmss/fiscad/paylaods/response/CommuneSyncResponse.java
index b212e60..e7d4df6 100644
--- a/src/main/java/io/gmss/fiscad/paylaods/response/CommuneSyncResponse.java
+++ b/src/main/java/io/gmss/fiscad/paylaods/response/CommuneSyncResponse.java
@@ -4,8 +4,9 @@ public interface CommuneSyncResponse {
public Long getId();
public String getCode();
-
+ public String getLongitude();
+ public String getLatitude();
public String getNom();
public Long getDepartementId();
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/gmss/fiscad/repositories/decoupage/ArrondissementRepository.java b/src/main/java/io/gmss/fiscad/repositories/decoupage/ArrondissementRepository.java
index 8d9c6b7..4e96e85 100755
--- a/src/main/java/io/gmss/fiscad/repositories/decoupage/ArrondissementRepository.java
+++ b/src/main/java/io/gmss/fiscad/repositories/decoupage/ArrondissementRepository.java
@@ -12,25 +12,25 @@ import java.util.List;
public interface ArrondissementRepository extends JpaRepository {
List findAllByCommune(Commune commune);
- @Query(value = "select a.id,code, nom, a.commune_id as communeId from arrondissement a" +
+ @Query(value = "select a.id,code, nom,longitude,latitude, a.commune_id as communeId from arrondissement a" +
" inner join arrondissements_structures sa on sa.arrondissement_id=a.id" +
" where a.deleted is false and sa.structure_id = ?1 ", nativeQuery = true)
List getArrondissementResponse(Long structure_id);
- @Query(value = "Select distinct T.id,T.code, T.libelle, T.communeId, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
- " From (select a.id,a.code, a.nom as libelle, a.commune_id as communeId, e.id as enqueteId from arrondissement a" +
+ @Query(value = "Select distinct T.id,T.code, T.libelle,T.longitude,T.latitude, T.communeId, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
+ " From (select a.id,a.code, a.nom as libelle,a.longitude,a.latitude, a.commune_id as communeId, e.id as enqueteId from arrondissement a" +
" left join bloc b on b.arrondissement_id=a.id " +
" left join enquete e on e.bloc_id=b.id )T " +
- " group by T.id,T.code, T.libelle, T.communeId ", nativeQuery = true)
+ " group by T.id,T.code, T.libelle,T.longitude,T.latitude, T.communeId ", nativeQuery = true)
List getAdminArrondissementEnqResponse();
- @Query(value = "Select T.id,T.code, T.libelle, T.communeId, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
- " From (select distinct a.id,a.code, a.nom as libelle, a.commune_id as communeId, e.id as enqueteId from arrondissement a" +
+ @Query(value = "Select T.id,T.code, T.libelle,T.longitude,T.latitude, T.communeId, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
+ " From (select distinct a.id,a.code, a.nom as libelle,a.longitude,a.latitude, a.commune_id as communeId, e.id as enqueteId from arrondissement a" +
" inner join arrondissements_structures sa on sa.arrondissement_id=a.id " +
" left join bloc b on b.arrondissement_id=a.id " +
" left join enquete e on e.bloc_id=b.id" +
" where sa.structure_id = ?1 )T " +
- " group by T.id,T.code, T.libelle, T.communeId ", nativeQuery = true)
+ " group by T.id,T.code, T.libelle,T.longitude,T.latitude, T.communeId ", nativeQuery = true)
List getArrondissementEnqResponse(Long structure_id);
}
diff --git a/src/main/java/io/gmss/fiscad/repositories/decoupage/CommuneRepository.java b/src/main/java/io/gmss/fiscad/repositories/decoupage/CommuneRepository.java
index 7c3d78d..999d376 100755
--- a/src/main/java/io/gmss/fiscad/repositories/decoupage/CommuneRepository.java
+++ b/src/main/java/io/gmss/fiscad/repositories/decoupage/CommuneRepository.java
@@ -11,28 +11,28 @@ import java.util.List;
public interface CommuneRepository extends JpaRepository {
- @Query(value = "select id, code, nom, departement_id as departementid from commune ", nativeQuery = true)
+ @Query(value = "select id, code, nom,longitude,latitude, departement_id as departementid from commune ", nativeQuery = true)
List getCommuneResponse();
List findAllByDepartement(Departement departement);
- @Query(value = " Select T.id,T.code, T.libelle, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
- " From (select distinct c.id as id,c.code as code, c.nom as libelle, e.id as enqueteId from arrondissement a" +
+ @Query(value = " Select T.id,T.code, T.libelle,T.longitude,T.latitude, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
+ " From (select distinct c.id as id,c.code as code, c.nom as libelle,c.longitude,c.latitude, e.id as enqueteId from arrondissement a" +
" inner join arrondissements_structures sa on sa.arrondissement_id=a.id " +
" inner join commune c on c.id= a.commune_id " +
" left join bloc b on b.arrondissement_id=a.id " +
" left join enquete e on e.bloc_id=b.id " +
" where sa.structure_id = ?1 )T" +
- " group by T.id,T.code, T.libelle", nativeQuery = true)
+ " group by T.id,T.code, T.libelle,T.longitude,T.latitude", nativeQuery = true)
List getCommuneEnqResponse(Long structure_id);
- @Query(value = " Select T.id,T.code, T.libelle, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
- " From (select distinct c.id as id,c.code as code, c.nom as libelle, e.id as enqueteId from arrondissement a" +
+ @Query(value = " Select T.id,T.code, T.libelle,T.longitude,T.latitude, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
+ " From (select distinct c.id as id,c.code as code,c.longitude,c.latitude, c.nom as libelle, e.id as enqueteId from arrondissement a" +
" left join arrondissements_structures sa on sa.arrondissement_id=a.id " +
" left join commune c on c.id= a.commune_id " +
" left join bloc b on b.arrondissement_id=a.id " +
" left join enquete e on e.bloc_id=b.id)T " +
- " group by T.id,T.code, T.libelle", nativeQuery = true)
+ " group by T.id,T.code, T.libelle,T.longitude,T.latitude", nativeQuery = true)
List getAdminCommuneEnqResponse();
}
diff --git a/src/main/java/io/gmss/fiscad/repositories/decoupage/QuartierRepository.java b/src/main/java/io/gmss/fiscad/repositories/decoupage/QuartierRepository.java
index 805c30d..74eef73 100755
--- a/src/main/java/io/gmss/fiscad/repositories/decoupage/QuartierRepository.java
+++ b/src/main/java/io/gmss/fiscad/repositories/decoupage/QuartierRepository.java
@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
+import java.util.Optional;
public interface QuartierRepository extends JpaRepository {
List getAllByArrondissement(Arrondissement arrondissement);
@@ -23,5 +24,5 @@ public interface QuartierRepository extends JpaRepository {
" where q.deleted is false ", nativeQuery = true)
List getAdminQuartierResponse();
-
}
+
diff --git a/src/main/java/io/gmss/fiscad/repositories/infocad/metier/ParcelleGeomRepository.java b/src/main/java/io/gmss/fiscad/repositories/infocad/metier/ParcelleGeomRepository.java
index 2c4bf4d..f631930 100644
--- a/src/main/java/io/gmss/fiscad/repositories/infocad/metier/ParcelleGeomRepository.java
+++ b/src/main/java/io/gmss/fiscad/repositories/infocad/metier/ParcelleGeomRepository.java
@@ -11,6 +11,16 @@ import java.util.Optional;
public interface ParcelleGeomRepository extends JpaRepository {
+ List findAllByQuartier_Code(String code);
+ @Query(value = "update parcelle_geom " +
+ "set quartier_id=T.quartier_id " +
+ "from " +
+ "(select quartier.id as quartier_id,upper(quartier.nom) as nom_quartier,c.nom as nom_commune " +
+ "from quartier inner join public.arrondissement a on a.id = quartier.arrondissement_id " +
+ "inner join public.commune c on c.id = a.commune_id)T " +
+ "where parcelle_geom.village_quartier=T.nom_quartier " +
+ "and upper(parcelle_geom.commune)=upper(T.nom_commune) ",nativeQuery = true)
+ void majIdQuartier();
}