From f5de27565cfb7c1bc4667fe7168f1aa15ea2f4d2 Mon Sep 17 00:00:00 2001 From: Eduard Carreras Date: Wed, 17 Apr 2024 17:37:51 +0200 Subject: [PATCH 1/2] Si no trobem tram BT anem a buscar AT --- libcnmc/utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libcnmc/utils.py b/libcnmc/utils.py index b6098dca..09f59e90 100644 --- a/libcnmc/utils.py +++ b/libcnmc/utils.py @@ -596,6 +596,18 @@ def get_tipus_connexio(o, id_escomesa): ) if tram_bt['tipus_linia']: tipus = tram_bt['tipus_linia'][1][0] + else: + tram_at = o.GiscedataAtTram.search( + [('edge_id', '=', edge_id[0])] + ) + if tram_at: + tram_at = o.GiscedataAtTram.read( + tram_at[0], ['tipus'] + ) + if tram_at['tipus'] and tram_at['tipus'] == 1: + tipus = 'A' + else: + tipus = 'S' else: bloc = o.GiscegisBlocsEscomeses.search( [('escomesa', '=', id_escomesa)] From 675dbf19aa8dbdcf99241c5c686e68cf9d88fe41 Mon Sep 17 00:00:00 2001 From: Eduard Carreras Date: Thu, 18 Apr 2024 10:02:13 +0200 Subject: [PATCH 2/2] Only use edge_id and node_id --- libcnmc/utils.py | 93 +++++++++++++++--------------------------------- 1 file changed, 29 insertions(+), 64 deletions(-) diff --git a/libcnmc/utils.py b/libcnmc/utils.py index 09f59e90..20ddf6cc 100644 --- a/libcnmc/utils.py +++ b/libcnmc/utils.py @@ -574,74 +574,39 @@ def get_tipus_connexio(o, id_escomesa): """ tipus = 'A' - if 'node_id' in o.GiscedataCupsEscomesa.fields_get().keys() and 'edge_id' in o.GiscedataBtElement.fields_get().keys(): - node_id = o.GiscedataCupsEscomesa.read( - id_escomesa, ['node_id'] - )['node_id'] - if node_id: - edge_id = o.GiscegisEdge.search( - [ - '|', - ('start_node', '=', node_id[0]), - ('end_node', '=', node_id[0]) - ] - ) - if edge_id: - tram_bt = o.GiscedataBtElement.search( - [('edge_id', '=', edge_id[0])] - ) - if tram_bt: - tram_bt = o.GiscedataBtElement.read( - tram_bt[0], ['tipus_linia'] - ) - if tram_bt['tipus_linia']: - tipus = tram_bt['tipus_linia'][1][0] - else: - tram_at = o.GiscedataAtTram.search( - [('edge_id', '=', edge_id[0])] - ) - if tram_at: - tram_at = o.GiscedataAtTram.read( - tram_at[0], ['tipus'] - ) - if tram_at['tipus'] and tram_at['tipus'] == 1: - tipus = 'A' - else: - tipus = 'S' - else: - bloc = o.GiscegisBlocsEscomeses.search( - [('escomesa', '=', id_escomesa)] + node_id = o.GiscedataCupsEscomesa.read( + id_escomesa, ['node_id'] + )['node_id'] + if node_id: + edge_id = o.GiscegisEdge.search( + [ + '|', + ('start_node', '=', node_id[0]), + ('end_node', '=', node_id[0]) + ] ) - if bloc: - bloc = o.GiscegisBlocsEscomeses.read(bloc[0], ['node']) - if bloc['node']: - node = bloc['node'][0] - edge_bt = o.GiscegisEdge.search( - [ - '|', - ('start_node', '=', node), - ('end_node', '=', node), - '|', - ('layer', 'ilike', self.layer), - ('layer', 'ilike', 'EMBARRA%BT%') - ] + if edge_id: + tram_bt = o.GiscedataBtElement.search( + [('edge_id', '=', edge_id[0])] + ) + if tram_bt: + tram_bt = o.GiscedataBtElement.read( + tram_bt[0], ['tipus_linia'] ) - edge = o.GiscegisEdge.read( - edge_bt[0], ['id_linktemplate'] + if tram_bt['tipus_linia']: + tipus = tram_bt['tipus_linia'][1][0] + else: + tram_at = o.GiscedataAtTram.search( + [('edge_id', '=', edge_id[0])] ) - if edge['id_linktemplate']: - tram_bt = o.GiscedataBtElement.search( - [ - ('name', '=', edge['id_linktemplate']) - ] + if tram_at: + tram_at = o.GiscedataAtTram.read( + tram_at[0], ['tipus'] ) - if tram_bt: - tram_bt = o.GiscedataBtElement.read( - tram_bt[0], ['tipus_linia'] - ) - if tram_bt: - if tram_bt['tipus_linia']: - tipus = tram_bt['tipus_linia'][1][0] + if tram_at['tipus'] and tram_at['tipus'] == 1: + tipus = 'A' + else: + tipus = 'S' return tipus