diff --git a/ud/fct/ud_gw_fct_pg2epa_check_result.sql b/ud/fct/ud_gw_fct_pg2epa_check_result.sql index 086d81615..4437a3761 100644 --- a/ud/fct/ud_gw_fct_pg2epa_check_result.sql +++ b/ud/fct/ud_gw_fct_pg2epa_check_result.sql @@ -149,29 +149,29 @@ BEGIN v_psectorused = (SELECT count(psector_id) FROM selector_psector WHERE cur_user = current_user); -- Header - INSERT INTO temp_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-10, v_fid, v_result_id, 4, + INSERT INTO t_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-10, v_fid, v_result_id, 4, concat('CHECK RESULT WITH CURRENT USER-OPTIONS ACORDING EPA RULES')); - INSERT INTO temp_audit_check_data (id, fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-9, v_fid, v_result_id, 4, '--------------------------------------------------------------------------------------'); - INSERT INTO temp_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-8, v_fid, v_result_id, 3, 'CRITICAL ERRORS'); - INSERT INTO temp_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-7, v_fid, v_result_id, 3, '----------------------'); + INSERT INTO t_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-8, v_fid, v_result_id, 3, 'CRITICAL ERRORS'); + INSERT INTO t_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-7, v_fid, v_result_id, 3, '----------------------'); - INSERT INTO temp_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-6, v_fid, v_result_id, 2, 'WARNINGS'); - INSERT INTO temp_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-5, v_fid, v_result_id, 2, '--------------'); + INSERT INTO t_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-6, v_fid, v_result_id, 2, 'WARNINGS'); + INSERT INTO t_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-5, v_fid, v_result_id, 2, '--------------'); - INSERT INTO temp_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-4, v_fid, v_result_id, 1, 'INFO'); - INSERT INTO temp_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-3, v_fid, v_result_id, 1, '-------'); + INSERT INTO t_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-4, v_fid, v_result_id, 1, 'INFO'); + INSERT INTO t_audit_check_data (id, fid, result_id, criticity, error_message) VALUES (-3, v_fid, v_result_id, 1, '-------'); - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Result id: ', v_result_id)); - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Created by: ', current_user, ', on ', to_char(now(),'YYYY-MM-DD HH-MM-SS'))); - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Export mode: ',v_exportmodeval)); - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Hidrology scenario: ', v_hydroscenarioval)); - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('DWF scenario: ',v_dwfscenarioval)); - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Dump subcatchments: ',v_dumpsubc::text)); - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Active Workspace: ', v_workspace)); - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Number of dscenarios used: ', v_dscenarioused)); - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Number of psectors used: ', v_psectorused)); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Result id: ', v_result_id)); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Created by: ', current_user, ', on ', to_char(now(),'YYYY-MM-DD HH-MM-SS'))); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Export mode: ',v_exportmodeval)); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Hidrology scenario: ', v_hydroscenarioval)); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('DWF scenario: ',v_dwfscenarioval)); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Dump subcatchments: ',v_dumpsubc::text)); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Active Workspace: ', v_workspace)); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Number of dscenarios used: ', v_dscenarioused)); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Number of psectors used: ', v_psectorused)); UPDATE rpt_cat_result SET export_options = concat('{"Hydrology scenario": "', v_hydroscenarioval,'", "DWF scenario":"',v_dwfscenarioval,'"}')::json @@ -180,169 +180,169 @@ BEGIN IF v_checkresult THEN IF v_default::boolean THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Default values: ', v_defaultval)); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Default values: ', v_defaultval)); ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Default values: No default values used')); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Default values: No default values used')); END IF; IF v_advanced::boolean THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Advanced settings: ', v_advancedval)); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Advanced settings: ', v_advancedval)); ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Advanced settings: No advanced settings used')); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Advanced settings: No advanced settings used')); END IF; IF v_debug::boolean THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Debug: ', v_defaultval)); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Debug: ', v_defaultval)); END IF; IF v_setallraingages IS NOT NULL THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Enabled set all raingages with ONLY ONE timeseries: ', v_setallraingages)); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, concat('Enabled set all raingages with ONLY ONE timeseries: ', v_setallraingages)); END IF; RAISE NOTICE '1- Check subcatchments'; SELECT count(*) INTO v_count FROM v_edit_inp_subcatchment WHERE outlet_id is null; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count,' subcatchment(s) with null values on mandatory column outlet_id column.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Column oulet_id on subcatchment table have been checked without any values missed.')); END IF; -- check area SELECT (sum(st_area(the_geom)/10000))::integer, (sum(area))::integer INTO v_count, v_count_2 FROM v_edit_inp_subcatchment WHERE area IS NOT NULL; IF v_count > v_count_2*2 AND v_count < v_count_2*10 OR (v_count_2 > v_count*2 AND v_count_2 < v_count*10) THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 2, concat('WARNING-369: Total area informed (',v_count_2,' ha.) has important difference from total shape area (',v_count,' ha.).')); v_count=0; ELSIF v_count > v_count_2*10 OR v_count_2 > v_count*10 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: Total area informed (',v_count_2,' ha.) has big difference from total shape area (',v_count,' ha.).')); ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Total area informed (',v_count_2,' ha.) is similar than total shape area (',v_count,' ha.).')); END IF; SELECT count(*) INTO v_count FROM v_edit_inp_subcatchment where rg_id is null; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count,' inp_subcatchment(s) with null values on mandatory column rg_id column.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Column rg_id on scenario subcatchments have been checked without any values missed.')); END IF; SELECT count(*) INTO v_count FROM v_edit_inp_subcatchment where area is null; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count,' subcatchment(s) with null values on mandatory column area column.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Column area on scenario subcatchments have been checked without any values missed.')); END IF; SELECT count(*) INTO v_count FROM v_edit_inp_subcatchment where width is null; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count,' subcatchment(s) with null values on mandatory column width column.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Column width on scenario subcatchments have been checked without any values missed.')); END IF; SELECT count(*) INTO v_count FROM v_edit_inp_subcatchment where slope is null; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count,' subcatchment(s) with null values on mandatory column slope column.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Column slope on scenario subcatchments have been checked without any values missed.')); END IF; SELECT count(*) INTO v_count FROM v_edit_inp_subcatchment where clength is null; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count,' subcatchment(s) with null values on mandatory column clength column.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Column clength on scenario subcatchments have been checked without any values missed.')); END IF; SELECT count(*) INTO v_count FROM v_edit_inp_subcatchment where nimp is null; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count,' subcatchment(s) with null values on mandatory column nimp column.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Column nimp on scenario subcatchments have been checked without any values missed.')); END IF; SELECT count(*) INTO v_count FROM v_edit_inp_subcatchment where nperv is null; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count,' subcatchment(s) with null values on mandatory column nperv column.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Column nperv on scenario subcatchments have been checked without any values missed.')); END IF; SELECT count(*) INTO v_count FROM v_edit_inp_subcatchment where simp is null; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count,' subcatchment(s) with null values on mandatory column simp column.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Column simp on scenario subcatchments have been checked without any values missed.')); END IF; SELECT count(*) INTO v_count FROM v_edit_inp_subcatchment where sperv is null; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count,' subcatchment(s) with null values on mandatory column sperv column.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Column sperv on scenario subcatchments have been checked without any values missed.')); END IF; SELECT count(*) INTO v_count FROM v_edit_inp_subcatchment where zero is null; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count,' subcatchment(s) with null values on mandatory column zero column.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Column zero on scenario subcatchments have been checked without any values missed.')); END IF; SELECT count(*) INTO v_count FROM v_edit_inp_subcatchment where routeto is null; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count,' subcatchment(s) with null values on mandatory column routeto column.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Column routeto on scenario subcatchments have been checked without any values missed.')); END IF; SELECT count(*) INTO v_count FROM v_edit_inp_subcatchment where rted is null; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count,' subcatchment(s) with null values on mandatory column rted column.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Column rted on scenario subcatchments have been checked without any values missed.')); END IF; @@ -354,13 +354,13 @@ BEGIN OR (conduct_2 is null) OR (drytime_2 is null); IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count, ' subcatchment(s) with null values on mandatory columns of curve number infiltartion method (curveno, conduct_2, drytime_2).', 'Acording EPA SWMM user''s manual, conduct_2 is deprecated, but is mandatory to fill it. Any value is valid because it will be ignored by SWMM.')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Mandatory columns for ''CURVE_NUMBER'' infitration method (curveno, drytime_2) have been checked without any values missed.')); END IF; @@ -371,12 +371,12 @@ BEGIN OR (conduct_ยก is null) OR (initdef is null); IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ', v_count,' subcatchment(s) with null values on mandatory columns of Green-Apt infiltartion method (suction, conduct, initdef).')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Mandatory columns for ''GREEN_AMPT'' infitration method (suction, conduct, initdef) have been checked without any values missed.')); END IF; @@ -388,12 +388,12 @@ BEGIN OR (minrate is null) OR (decay is null) OR (drytime is null) OR (maxinfil is null); IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-369: There is/are ',v_count, ' subcatchment(s) with null values on mandatory columns of Horton/Horton modified infiltartion method (maxrate, minrate, decay, drytime, maxinfil).')); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: Mandatory columns for ''MODIFIED_HORTON'' infitration method (maxrate, minrate, decay, drytime, maxinfil) have been checked without any values missed.')); END IF; @@ -413,18 +413,18 @@ BEGIN EXECUTE 'SELECT count FROM ('||v_querytext||')b WHERE feature = ''ARC'';' INTO v_count; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-370: There is/are ', v_count, ' arcs with sector_id = 0 that didn''t take part in the simulation')); END IF; EXECUTE 'SELECT count FROM ('||v_querytext||')b WHERE feature = ''NODE'';' INTO v_count; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-370: There is/are ', v_count, ' nodes with sector_id = 0 that didn''t take part in the simulation')); END IF; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: All features have sector_id different than 0.')); v_count=0; END IF; @@ -447,7 +447,7 @@ BEGIN SELECT '||object_rec.colname||', 396, concat(''Present on '',count(*),'' enabled dscenarios''), the_geom FROM v_edit_inp_dscenario_'||object_rec.tabname|| ' GROUP BY '||object_rec.colname||', the_geom having count(*) > 1'; - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-396 (',object_rec.tablename,'): There is/are ', v_count, ' ', object_rec.colname,'(s) for ',upper(object_rec.tabname),' used on more than one enabled dscenarios.')); @@ -457,7 +457,7 @@ BEGIN SELECT '||object_rec.colname||', 396, concat(''Present on '',count(*),'' enabled dscenarios''), the_geom FROM v_edit_inp_dscenario_'||object_rec.tabname|| ' GROUP BY '||object_rec.colname||', the_geom having count(*) > 1'; - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-396 (anl_arc): There is/are ', v_count, ' ', object_rec.colname,'(s) for ',upper(object_rec.tabname),' used on more than one enabled dscenarios.')); @@ -467,22 +467,22 @@ BEGIN SELECT '||object_rec.colname||', 396, concat(''Present on '',count(*),'' enabled dscenarios''), the_geom FROM v_edit_inp_dscenario_'||object_rec.tabname|| ' GROUP BY '||object_rec.colname||', the_geom having count(*) > 1'; - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-396 (',object_rec.tablename,'): There is/are ', v_count, ' ', object_rec.colname,'(s) for ',upper(object_rec.tabname),' used on more than one enabled dscenarios.')); ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-396: There is/are ', v_count, ' ', object_rec.colname,'(s) for ',upper(object_rec.tabname),' used on more than one enabled dscenarios.')); END IF; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: There is not confict on enabled dscenarios for ',upper(object_rec.tabname),'.')); END IF; END LOOP; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: There are not dscenarios selected.')); END IF; @@ -490,10 +490,10 @@ BEGIN RAISE NOTICE '4 - Check if y0 is higger than ymax on nodes (401)'; v_count = (SELECT count(*) FROM temp_t_node WHERE y0 > ymax); IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-401: There is/are ', v_count, ' nodes with y0 higger then ymax.')); ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: All nodes has y0 lower than ymax.')); END IF; @@ -513,13 +513,13 @@ BEGIN IF v_count > 0 THEN i = i+1; EXECUTE concat ('SELECT array_agg(id) FROM ',v_querytext) INTO v_querytext; - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-402: There is/are ', v_count, ' CONTROLS with ',lower(object_rec.tabname),' not present on this result. Controls id''s:',v_querytext)); END IF; END LOOP; IF v_count = 0 AND i = 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: All CONTROLS has correct node id values.')); END IF; @@ -537,13 +537,13 @@ BEGIN IF v_count > 0 THEN i = i+1; EXECUTE concat ('SELECT array_agg(id) FROM ',v_querytext) INTO v_querytext; - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, concat('ERROR-402: There is/are ', v_count, ' CONTROLS with ',lower(object_rec.tabname),' not present on this result. Controls id''s:',v_querytext)); END IF; END LOOP; IF v_count = 0 AND i = 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, concat('INFO: All CONTROLS has correct arc id values.')); END IF; @@ -554,12 +554,12 @@ BEGIN WHERE g.sector_id = s.sector_id AND cur_user=current_user AND arc_id IS NULL) a1; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) + INSERT INTO t_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) VALUES (v_fid, v_result_id, 3, '455',concat( 'ERROR-455: There is/are ',v_count,' gullies with missed information on arc_id (outlet) values.'),v_count); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) + INSERT INTO t_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) VALUES (v_fid, v_result_id , 1, '455','INFO: No gullies found without arc_id (outlet) values.', v_count); END IF; @@ -567,12 +567,12 @@ BEGIN SELECT count(*) INTO v_count FROM (SELECT * FROM temp_t_gully WHERE top_elev IS NULL) a1; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) + INSERT INTO t_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) VALUES (v_fid, v_result_id, 3, '456',concat( 'ERROR-456: There is/are ',v_count,' gullies with null values on top_elev/custom_top_elev columns.'),v_count); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) + INSERT INTO t_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) VALUES (v_fid, v_result_id , 1, '456','INFO: No gullies found with null values on top_elev.', v_count); END IF; @@ -580,12 +580,12 @@ BEGIN SELECT count(*) INTO v_count FROM (SELECT * FROM temp_t_gully WHERE width IS NULL) a1; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) + INSERT INTO t_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) VALUES (v_fid, v_result_id, 3, '457',concat( 'ERROR-457: There is/are ',v_count,' gullies with null values on width/custom_width columns.'),v_count); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) + INSERT INTO t_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) VALUES (v_fid, v_result_id , 1, '457','INFO: No gullies found with null values on width.', v_count); END IF; @@ -593,26 +593,26 @@ BEGIN SELECT count(*) INTO v_count FROM (SELECT * FROM temp_t_gully WHERE length IS NULL) a1; IF v_count > 0 THEN - INSERT INTO temp_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) + INSERT INTO t_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) VALUES (v_fid, v_result_id, 3, '458',concat( 'ERROR-458: There is/are ',v_count,' gullies with null values on length/custom_length columns.'),v_count); v_count=0; ELSE - INSERT INTO temp_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) + INSERT INTO t_audit_check_data (fid, result_id, criticity, table_id, error_message, fcount) VALUES (v_fid, v_result_id , 1, '458','INFO: No gullies found with null values on length.', v_count); END IF; END IF; -- insert spacers for log - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, ''); - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, ''); - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 2, ''); - INSERT INTO temp_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, ''); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 4, ''); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 3, ''); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 2, ''); + INSERT INTO t_audit_check_data (fid, result_id, criticity, error_message) VALUES (v_fid, v_result_id, 1, ''); -- get results -- info SELECT array_to_json(array_agg(row_to_json(row))) INTO v_result - FROM (SELECT error_message as message FROM temp_audit_check_data WHERE cur_user="current_user"() AND fid = v_fid + FROM (SELECT error_message as message FROM t_audit_check_data WHERE cur_user="current_user"() AND fid = v_fid order by criticity desc, id asc) row; v_result := COALESCE(v_result, '{}'); v_result_info = concat ('{"geometryType":"", "values":',v_result, '}'); @@ -628,9 +628,9 @@ BEGIN 'geometry', ST_AsGeoJSON(the_geom)::jsonb, 'properties', to_jsonb(row) - 'the_geom' ) AS feature FROM - (SELECT node_id as id, 228 as fid, 'ERROR-228: Orphan node' as descript, the_geom FROM temp_anl_node WHERE cur_user="current_user"() AND fid IN (228,107) + (SELECT node_id as id, 228 as fid, 'ERROR-228: Orphan node' as descript, the_geom FROM t_anl_node WHERE cur_user="current_user"() AND fid IN (228,107) UNION - SELECT node_id as id, 396 as fid, 'ERROR-396: Node used on more than one scenario' as descript, the_geom FROM temp_anl_node WHERE cur_user="current_user"() AND fid = 396) + SELECT node_id as id, 396 as fid, 'ERROR-396: Node used on more than one scenario' as descript, the_geom FROM t_anl_node WHERE cur_user="current_user"() AND fid = 396) row) features; v_result := COALESCE(v_result, '[]'); @@ -645,11 +645,11 @@ BEGIN 'geometry', ST_AsGeoJSON(the_geom)::jsonb, 'properties', to_jsonb(row) - 'the_geom' ) AS feature - FROM (SELECT arc_id as id, fid, 'ERROR: Disconnected arc'::text as descript, the_geom FROM temp_anl_arc WHERE cur_user="current_user"() AND fid = 139 + FROM (SELECT arc_id as id, fid, 'ERROR: Disconnected arc'::text as descript, the_geom FROM t_anl_arc WHERE cur_user="current_user"() AND fid = 139 UNION - SELECT arc_id as id, fid, 'ERROR-427: Flow regulator length do not fits with target arc', the_geom FROM temp_anl_arc WHERE cur_user="current_user"() AND fid = 427 + SELECT arc_id as id, fid, 'ERROR-427: Flow regulator length do not fits with target arc', the_geom FROM t_anl_arc WHERE cur_user="current_user"() AND fid = 427 UNION - SELECT arc_id as id, fid, 'ERROR-396: Arc used on more than one scenario', the_geom FROM temp_anl_arc WHERE cur_user="current_user"() AND fid = 396 + SELECT arc_id as id, fid, 'ERROR-396: Arc used on more than one scenario', the_geom FROM t_anl_arc WHERE cur_user="current_user"() AND fid = 396 ) row) features; v_result := COALESCE(v_result, '{}'); diff --git a/ud/fct/ud_gw_fct_pg2epa_export_inp.sql b/ud/fct/ud_gw_fct_pg2epa_export_inp.sql index d33870e2f..893285a4b 100644 --- a/ud/fct/ud_gw_fct_pg2epa_export_inp.sql +++ b/ud/fct/ud_gw_fct_pg2epa_export_inp.sql @@ -780,7 +780,7 @@ BEGIN NULL::character varying AS other2, NULL::character varying AS other3 FROM selector_inp_result s, - temp_rpt_inp_raingage r + t_rpt_inp_raingage r LEFT JOIN inp_typevalue ON inp_typevalue.id::text = r.rgage_type::text WHERE inp_typevalue.typevalue::text = 'inp_typevalue_raingage'::text AND r.rgage_type::text = 'TIMESERIES'::text AND s.result_id::text = r.result_id::text AND s.cur_user = CURRENT_USER UNION @@ -793,7 +793,7 @@ BEGIN r.sta AS other2, r.units AS other3 FROM selector_inp_result s, - temp_rpt_inp_raingage r + t_rpt_inp_raingage r LEFT JOIN inp_typevalue ON inp_typevalue.id::text = r.rgage_type::text WHERE inp_typevalue.typevalue::text = 'inp_typevalue_raingage'::text AND r.rgage_type::text = 'FILE'::text AND s.result_id::text = r.result_id::text AND s.cur_user = CURRENT_USER; @@ -1224,7 +1224,7 @@ BEGIN WHERE t.expl_id is NULL) b ORDER BY b.id) c JOIN inp_timeseries ON id = timser_id - WHERE (timser_type = 'Rainfall' and timser_id IN (SELECT timser_id FROM temp_rpt_inp_raingage)) or timser_type != 'Rainfall'::text + WHERE (timser_type = 'Rainfall' and timser_id IN (SELECT timser_id FROM t_rpt_inp_raingage)) or timser_type != 'Rainfall'::text ORDER BY timser_id, other2; diff --git a/ud/fct/ud_gw_fct_pg2epa_fill_data.sql b/ud/fct/ud_gw_fct_pg2epa_fill_data.sql index 4bc826059..5237547d3 100644 --- a/ud/fct/ud_gw_fct_pg2epa_fill_data.sql +++ b/ud/fct/ud_gw_fct_pg2epa_fill_data.sql @@ -43,7 +43,7 @@ BEGIN TRUNCATE temp_t_arc; TRUNCATE temp_t_arc_flowregulator; TRUNCATE temp_t_gully; - TRUNCATE temp_rpt_inp_raingage; + TRUNCATE t_rpt_inp_raingage; DELETE FROM rpt_inp_raingage WHERE result_id = result_id_var; TRUNCATE temp_t_lid_usage; @@ -229,7 +229,7 @@ BEGIN LEFT JOIN arc a USING (arc_id) LEFT JOIN value_state_type ON id=g.state_type WHERE arc_id IS NOT NULL AND g.sector_id > 0 '||v_statetype||' AND s.cur_user = current_user and s.sector_id = g.sector_id;'; - + END IF; -- orifice @@ -283,12 +283,12 @@ BEGIN UPDATE temp_t_arc SET q0=0 where q0 IS NULL; -- rpt_inp_raingage - INSERT INTO temp_rpt_inp_raingage + INSERT INTO t_rpt_inp_raingage SELECT result_id_var, * FROM v_edit_raingage; -- setting same rainfall for all raingage IF v_rainfall IS NOT NULL THEN - UPDATE temp_rpt_inp_raingage SET timser_id=v_rainfall, rgage_type='TIMESERIES'; + UPDATE t_rpt_inp_raingage SET timser_id=v_rainfall, rgage_type='TIMESERIES'; END IF; -- setting for date-time parameters if rainfall has addparam values) diff --git a/ud/fct/ud_gw_fct_pg2epa_main.sql b/ud/fct/ud_gw_fct_pg2epa_main.sql index 30494b4e5..3516a9df5 100644 --- a/ud/fct/ud_gw_fct_pg2epa_main.sql +++ b/ud/fct/ud_gw_fct_pg2epa_main.sql @@ -58,7 +58,7 @@ BEGIN v_result = (p_data->>'data')::json->>'resultId'; v_dumpsubcatch = (p_data->>'data')::json->>'dumpSubcatch'; v_step = (p_data->>'data')::json->>'step'; - v_input = concat('{"data":{"parameters":{"resultId":"',v_result,'", "dumpSubcatch":"',v_dumpsubcatch,'", "fid":227}}}')::json; + v_input = concat('{"data":{"parameters":{"isEmbebed":true, "resultId":"',v_result,'", "dumpSubcatch":"',v_dumpsubcatch,'", "fid":227}}}')::json; -- get user parameters @@ -156,8 +156,8 @@ BEGIN END IF; RAISE NOTICE '4.8 - Update values for temp table'; - UPDATE t_arc SET result_id = v_result; - UPDATE t_node SET result_id = v_result; + UPDATE temp_t_arc SET result_id = v_result; + UPDATE temp_t_node SET result_id = v_result; v_return = '{"status": "Accepted", "message":{"level":1, "text":"Export INP file 4/7 - Structure data...... done succesfully"}}'::json; RETURN v_return; @@ -176,17 +176,17 @@ BEGIN PERFORM gw_fct_pg2epa_check_result(v_input); -- deleting arcs without nodes - UPDATE t_arc t SET epa_type = 'TODELETE' FROM (SELECT a.id FROM t_arc a LEFT JOIN t_node ON node_1=node_id WHERE t_node.node_id is null) a WHERE t.id = a.id; - UPDATE t_arc t SET epa_type = 'TODELETE' FROM (SELECT a.id FROM t_arc a LEFT JOIN t_node ON node_2=node_id WHERE t_node.node_id is null) a WHERE t.id = a.id; - DELETE FROM t_arc WHERE epa_type = 'TODELETE'; - UPDATE t_arc SET result_id = v_result WHERE result_id IS NULL; - UPDATE t_node SET result_id = v_result WHERE result_id IS NULL; + UPDATE temp_t_arc t SET epa_type = 'TODELETE' FROM (SELECT a.id FROM temp_t_arc a LEFT JOIN temp_t_node ON node_1=node_id WHERE temp_t_node.node_id is null) a WHERE t.id = a.id; + UPDATE temp_t_arc t SET epa_type = 'TODELETE' FROM (SELECT a.id FROM temp_t_arc a LEFT JOIN temp_t_node ON node_2=node_id WHERE temp_t_node.node_id is null) a WHERE t.id = a.id; + DELETE FROM temp_t_arc WHERE epa_type = 'TODELETE'; + UPDATE temp_t_arc SET result_id = v_result WHERE result_id IS NULL; + UPDATE temp_t_node SET result_id = v_result WHERE result_id IS NULL; -- deleting nodes without arcs - UPDATE t_node t SET epa_type = 'TODELETE' FROM - (SELECT id FROM t_node LEFT JOIN (SELECT node_1 as node_id FROM t_arc UNION SELECT node_2 FROM t_arc) a USING (node_id) WHERE a.node_id IS NULL) a + UPDATE temp_t_node t SET epa_type = 'TODELETE' FROM + (SELECT id FROM temp_t_node LEFT JOIN (SELECT node_1 as node_id FROM temp_t_arc UNION SELECT node_2 FROM temp_t_arc) a USING (node_id) WHERE a.node_id IS NULL) a WHERE t.id = a.id; - DELETE FROM t_node WHERE epa_type = 'TODELETE'; + DELETE FROM temp_t_node WHERE epa_type = 'TODELETE'; -- create return EXECUTE 'SELECT gw_fct_create_return($${"data":{"parameters":{"functionId":2646, "isEmbebed":false}}}$$::json)' INTO v_return; @@ -207,14 +207,14 @@ BEGIN SELECT result_id, arc_id, node_1, node_2, elevmax1, elevmax2, arc_type, arccat_id, epa_type, sector_id, state, state_type, annotation, length, n, the_geom, expl_id, addparam, arcparent, q0, qmax, barrels, slope, culvert, kentry, kexit, kavg, flap, seepage - FROM t_arc; + FROM temp_t_arc; -- move nodes data INSERT INTO rpt_inp_node (result_id, node_id, top_elev, ymax, elev, node_type, nodecat_id, epa_type, sector_id, state, state_type, annotation, y0, ysur, apond, the_geom, expl_id, addparam, parent, arcposition, fusioned_node) SELECT result_id, node_id, top_elev, ymax, elev, node_type, nodecat_id, epa_type, sector_id, state, state_type, annotation, y0, ysur, apond, the_geom, expl_id, addparam, parent, arcposition, fusioned_node - FROM t_node; + FROM temp_t_node; -- move result data UPDATE rpt_cat_result r set network_stats = t.network_stats FROM t_rpt_cat_result t WHERE r.result_id = t.result_id; diff --git a/updates/40/40000/utils/dml_issue_30.sql b/updates/40/40000/utils/dml_issue_30.sql index b9e9c0ad1..b7e5eb4d4 100644 --- a/updates/40/40000/utils/dml_issue_30.sql +++ b/updates/40/40000/utils/dml_issue_30.sql @@ -935,7 +935,7 @@ function_name = '[gw_fct_pg2epa_check_result]', active = true WHERE fid = 377; - +-- TODO: Activate this process once 'top_elev' is added to 'ws.node'. UPDATE sys_fprocess SET fprocess_name = 'Connec/node with outlayer value on elevation', except_level = 3, @@ -945,12 +945,12 @@ query_text = ' WITH outlayer AS (SELECT ((value::json->>''elevation'')::json->>''max'')::numeric as max_elev, ((value::json->>''elevation'')::json->>''min'')::numeric as min_elev FROM config_param_system WHERE parameter = ''epa_outlayer_values'') - select node_id, nodecat_id from outlayer, node where elevation < min_elev or elevation > max_elev + select node_id, nodecat_id from outlayer, node where top_elev < min_elev or top_elev > max_elev union - select connec_id, conneccat_id from outlayer, connec where elevation < min_elev or elevation > max_elev', + select connec_id, conneccat_id from outlayer, connec where top_elev < min_elev or top_elev > max_elev', except_table = null, function_name = '[gw_fct_pg2epa_check_result]', -active = true +active = false WHERE fid = 407; diff --git a/utils/fct/gw_fct_manage_temp_tables.sql b/utils/fct/gw_fct_manage_temp_tables.sql index 1fe15dbfe..0fa24753c 100644 --- a/utils/fct/gw_fct_manage_temp_tables.sql +++ b/utils/fct/gw_fct_manage_temp_tables.sql @@ -230,7 +230,6 @@ BEGIN CREATE TEMP TABLE temp_t_pgr_go2epa_node (LIKE temp_node INCLUDING ALL); CREATE TEMP TABLE t_rpt_inp_pattern_value (LIKE rpt_inp_pattern_value INCLUDING ALL); - CREATE TEMP TABLE t_rpt_cat_result (LIKE rpt_cat_result INCLUDING ALL); ELSIF v_project_type = 'UD' THEN CREATE TEMP TABLE temp_t_arc_flowregulator (LIKE temp_arc_flowregulator INCLUDING ALL); @@ -244,6 +243,8 @@ BEGIN CREATE TEMP TABLE t_rpt_inp_arc (LIKE rpt_inp_arc INCLUDING ALL); END IF; + CREATE TEMP TABLE t_rpt_cat_result (LIKE rpt_cat_result INCLUDING ALL); + CREATE TEMP TABLE temp_t_csv (LIKE temp_csv INCLUDING ALL); CREATE TEMP TABLE temp_t_table (LIKE temp_table INCLUDING ALL); CREATE TEMP TABLE temp_t_node (LIKE temp_node INCLUDING ALL);