-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDIS 61] Ajoute des champs à la vue remocrArtemis
Issue: #202805 Change-Id: Ic66f69b8c1bc63935840a069687cb334b0b7e7a6
- Loading branch information
Clément GRENOT
authored and
Emilie Genton
committed
Jan 17, 2024
1 parent
92d3b21
commit 5036b87
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
server/sdis-remocra/home/postgres/remocra_db/patches/sdis/61/195_001.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
DROP VIEW remocra_sgo.remocrartemis | ||
|
||
|
||
|
||
CREATE OR REPLACE VIEW remocra_sgo.remocrartemis | ||
AS WITH anomalie AS ( | ||
SELECT h_1.id, | ||
array_to_string(array_agg(tha.code), ' | '::text) AS liste_anomalie_code, | ||
array_to_string(array_agg(tha.nom), ' | '::text) AS liste_anomalie_nom | ||
FROM hydrant h_1 | ||
LEFT JOIN hydrant_anomalies ha ON h_1.id = ha.hydrant | ||
LEFT JOIN type_hydrant_anomalie tha ON ha.anomalies = tha.id | ||
GROUP BY h_1.id | ||
) | ||
SELECT h.numero AS num, | ||
thn.code AS nature, | ||
thnd.code AS type_deci, | ||
h.complement AS complt, | ||
h.numero_voie AS num_v, | ||
h.suffixe_voie AS num_v_su, | ||
h.voie, h.voie2, h.en_face, | ||
dom.code AS domaine, | ||
o.code AS code_organisme_rattachement_commune, | ||
o.nom AS nom_organisme_rattachement_commune, | ||
pibi.debit, | ||
pibi.pression, | ||
pena.capacite, | ||
thd.code AS diametre, | ||
h.dispo_terrestre AS disponibilite, | ||
anomalie.liste_anomalie_code, | ||
anomalie.liste_anomalie_nom, | ||
h.geometrie, | ||
st_x(h.geometrie) AS coord_x, | ||
st_y(h.geometrie) AS coord_y, | ||
o_tournee.code AS code_organisme_tournee, | ||
o_tournee.nom AS nom_organisme_tournee | ||
FROM hydrant h | ||
JOIN type_hydrant_nature thn ON h.nature = thn.id | ||
JOIN type_hydrant_nature_deci thnd ON h.nature_deci = thnd.id | ||
LEFT JOIN type_hydrant_domaine dom ON h.domaine = dom.id | ||
LEFT JOIN hydrant_pibi pibi ON h.id = pibi.id | ||
LEFT JOIN hydrant_pena pena ON h.id = pena.id | ||
LEFT JOIN type_hydrant_diametre thd ON pibi.diametre = thd.id | ||
LEFT JOIN anomalie ON anomalie.id = h.id | ||
JOIN commune c ON h.commune = c.id | ||
JOIN organisme o_transi ON c.nom::text = o_transi.nom::text | ||
JOIN organisme o ON o.id = o_transi.organisme_parent | ||
LEFT JOIN hydrant_tournees ht ON h.id = ht.hydrant | ||
LEFT JOIN tournee t ON ht.tournees = t.id | ||
LEFT JOIN organisme o_tournee ON t.affectation = o_tournee.id; |