From 5036b87ffbc48ff47abaaf9667ab96e4fe13e802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20GRENOT?= Date: Wed, 17 Jan 2024 12:19:46 +0100 Subject: [PATCH] =?UTF-8?q?[SDIS=2061]=20Ajoute=20des=20champs=20=C3=A0=20?= =?UTF-8?q?la=20vue=20remocrArtemis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: #202805 Change-Id: Ic66f69b8c1bc63935840a069687cb334b0b7e7a6 --- .../remocra_db/patches/sdis/61/195_001.sql | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 server/sdis-remocra/home/postgres/remocra_db/patches/sdis/61/195_001.sql diff --git a/server/sdis-remocra/home/postgres/remocra_db/patches/sdis/61/195_001.sql b/server/sdis-remocra/home/postgres/remocra_db/patches/sdis/61/195_001.sql new file mode 100644 index 000000000..57cc44e6a --- /dev/null +++ b/server/sdis-remocra/home/postgres/remocra_db/patches/sdis/61/195_001.sql @@ -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; \ No newline at end of file