|
@@ -1,8 +1,5 @@
|
|
|
-<<<<<<< Updated upstream
|
|
|
-=======
|
|
|
do $$
|
|
|
begin
|
|
|
->>>>>>> Stashed changes
|
|
|
create sequence if not exists calc_header_adjustment_seq;
|
|
|
create table if not exists calc_header_adjustment
|
|
|
(
|
|
@@ -23,12 +20,8 @@ create table if not exists calc_height_adjustment
|
|
|
id integer primary key not null default nextval('public.calc_height_adjustment_seq'),
|
|
|
height integer not null,
|
|
|
measurment_type_id integer not null
|
|
|
-<<<<<<< Updated upstream
|
|
|
-);insert into calc_height_adjustment(height, measurment_type_id)
|
|
|
-=======
|
|
|
);
|
|
|
insert into calc_height_adjustment(height, measurment_type_id)
|
|
|
->>>>>>> Stashed changes
|
|
|
values(200,1),(400,1),(800,1),(1200,1),(1600,1),(2000,1),(2400,1),(3000,1),(4000,1),
|
|
|
(200,2),(400,2),(800,2),(1200,2),(1600,2),(2000,2),(2400,2),(3000,2),(4000,2);
|
|
|
create sequence if not exists calc_temperature_height_adjustment_seq;
|
|
@@ -71,20 +64,6 @@ create table calc_wind_speed_height_adjustment
|
|
|
values integer[] not null,
|
|
|
delta integer not null
|
|
|
);
|
|
|
-<<<<<<< Updated upstream
|
|
|
-insert into calc_wind_speed_height_adjustment(calc_height_id, values, delta)
|
|
|
-values
|
|
|
-(10, array[3, 4, 5, 6, 7, 7, 8, 9, 10, 11, 12, 12], 0),
|
|
|
-(11, array[4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 1),
|
|
|
-(12, array[4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16], 2),
|
|
|
-(13, array[4, 5, 7, 8, 8, 9, 11, 12, 13, 15, 15, 16], 2),
|
|
|
-(14, array[4, 6, 7, 8, 9, 10, 11, 13, 14, 15, 17, 17], 3),
|
|
|
-(15, array[4, 6, 7, 8, 9, 10, 11, 13, 14, 16, 17, 18], 3),
|
|
|
-(16, array[4, 6, 8, 9, 9, 10, 12, 14, 15, 16, 18, 19], 3),
|
|
|
-(17, array[5, 6, 8, 9, 10, 11, 12, 14, 15, 17, 18, 19], 4),
|
|
|
-(18, array[5, 6, 8, 9, 10, 11, 12, 14, 16, 18, 19, 20],4)
|
|
|
-;drop type if exists temperature_adjustment cascade;
|
|
|
-=======
|
|
|
truncate table calc_wind_speed_height_adjustment;
|
|
|
insert into calc_wind_speed_height_adjustment(calc_height_id, values, delta)
|
|
|
values
|
|
@@ -98,15 +77,10 @@ values
|
|
|
(8, array[5, 6, 8, 9, 10, 11, 12, 14, 15, 17, 18, 19], 4),
|
|
|
(9, array[5, 6, 8, 9, 10, 11, 12, 14, 16, 18, 19, 20], 4);
|
|
|
drop type if exists temperature_adjustment cascade;
|
|
|
->>>>>>> Stashed changes
|
|
|
create type temperature_adjustment as
|
|
|
(
|
|
|
calc_height_id integer,
|
|
|
height integer,
|
|
|
-<<<<<<< Updated upstream
|
|
|
-
|
|
|
-=======
|
|
|
->>>>>>> Stashed changes
|
|
|
temperature_deviation integer
|
|
|
);
|
|
|
drop type if exists wind_direction_adjustment cascade;
|
|
@@ -119,14 +93,10 @@ create type wind_direction_adjustment as
|
|
|
|
|
|
wind_deviation integer
|
|
|
);
|
|
|
-<<<<<<< Updated upstream
|
|
|
-create or replace procedure public.temp_dev_calc(
|
|
|
-=======
|
|
|
end$$;
|
|
|
do $$
|
|
|
begin
|
|
|
create or replace procedure public.calculate_temperature_deviation(
|
|
|
->>>>>>> Stashed changes
|
|
|
in pmt_measurement_type_id integer,
|
|
|
in pmt_temperature numeric(8,2),
|
|
|
inout pmt_adjustments public.temperature_adjustment[]
|
|
@@ -192,68 +162,8 @@ begin
|
|
|
end loop; raise notice '|----------|-----------|';
|
|
|
end;
|
|
|
$body$;
|
|
|
-<<<<<<< Updated upstream
|
|
|
-create or replace procedure public.calculate_wind_speed_deviation(
|
|
|
- in pmt_bullet_speed numeric,
|
|
|
- in pmt_measurement_type_id integer,
|
|
|
- inout pmt_adjustments public.wind_direction_adjustment[]
|
|
|
-)
|
|
|
-language 'plpgsql'
|
|
|
-as $body$
|
|
|
-declare
|
|
|
- var_row record;
|
|
|
- var_index integer;
|
|
|
- var_adj public.wind_direction_adjustment;
|
|
|
- var_header_adj integer[];
|
|
|
- var_header_index integer;
|
|
|
- var_table integer[];
|
|
|
- var_dev integer;
|
|
|
- var_table_row text;
|
|
|
-begin
|
|
|
- if coalesce(pmt_bullet_speed, -1) < 0 then
|
|
|
- raise exception 'некорректные параметры. pmt_bullet_speed=%', pmt_bullet_speed;
|
|
|
- end if; if not exists (
|
|
|
- select 1 from public.calc_height_adjustment
|
|
|
- where measurment_type_id = pmt_measurement_type_id
|
|
|
- ) then
|
|
|
- raise exception '% отсутствуют значения высот', pmt_measurement_type_id;
|
|
|
- end if;
|
|
|
- var_index := (pmt_bullet_speed / 10)::integer - 4;
|
|
|
- if var_index < 0 then
|
|
|
- var_index := 1;
|
|
|
- end if;
|
|
|
- var_header_adj := (select values from public.calc_header_adjustment
|
|
|
- where header = 'table3'
|
|
|
- and measurment_type_id = pmt_measurement_type_id);
|
|
|
- if array_length(var_header_adj, 1) = 0 then
|
|
|
- raise exception 'некорректные данные';
|
|
|
- end if; if array_length(var_header_adj, 1) < var_index then
|
|
|
- raise exception 'некорректные данные';
|
|
|
- end if; raise notice '| высота | поправка |';
|
|
|
- raise notice '|----------|-----------|'; for var_row in
|
|
|
- select t1.height, t2.*
|
|
|
- from calc_height_adjustment as t1
|
|
|
- inner join public.calc_wind_speed_height_adjustment as t2
|
|
|
- on t2.calc_height_id = t1.id
|
|
|
- where t1.measurment_type_id = pmt_measurement_type_id
|
|
|
- loop
|
|
|
-
|
|
|
- var_header_index := abs(var_index % 10);
|
|
|
- var_table := var_row.values;
|
|
|
- var_dev := var_table[var_header_index]; select '|' || lpad(var_row.height::text, 10, ' ') || '|' || lpad(var_dev::text, 11, ' ') || '|'
|
|
|
- into var_table_row; raise notice '%', var_table_row; var_adj.calc_height_id := var_row.calc_height_id;
|
|
|
- var_adj.height := var_row.height;
|
|
|
- var_adj.wind_speed_deviation := var_dev;
|
|
|
- var_adj.wind_deviation := var_row.delta;
|
|
|
- pmt_adjustments := array_append(pmt_adjustments, var_adj);
|
|
|
- end loop; raise notice '|----------|-----------|';
|
|
|
-end;
|
|
|
-$body$;
|
|
|
-create or replace procedure public.calculate_wind_direction_deviation(
|
|
|
-=======
|
|
|
create or replace procedure public.calculate_wind_deviation(
|
|
|
in pmt_bullet_speed numeric,
|
|
|
->>>>>>> Stashed changes
|
|
|
in pmt_wind_direction numeric,
|
|
|
in pmt_measurement_type_id integer,
|
|
|
inout pmt_adjustments public.wind_direction_adjustment[]
|
|
@@ -263,13 +173,6 @@ as $body$
|
|
|
declare
|
|
|
var_row record;
|
|
|
var_adj public.wind_direction_adjustment;
|
|
|
-<<<<<<< Updated upstream
|
|
|
-begin
|
|
|
- for var_row in
|
|
|
- select t1.height, t2.*
|
|
|
- from calc_height_adjustment as t1
|
|
|
- inner join public.calc_wind_speed_height_adjustment as t2
|
|
|
-=======
|
|
|
var_header_adj integer[];
|
|
|
var_index integer;
|
|
|
var_header_index integer;
|
|
@@ -295,20 +198,11 @@ begin
|
|
|
select t1.height, t2.*
|
|
|
from calc_height_adjustment as t1
|
|
|
left join public.calc_wind_speed_height_adjustment as t2
|
|
|
->>>>>>> Stashed changes
|
|
|
on t2.calc_height_id = t1.id
|
|
|
where t1.measurment_type_id = pmt_measurement_type_id
|
|
|
loop
|
|
|
var_adj.calc_height_id := var_row.calc_height_id;
|
|
|
var_adj.height := var_row.height;
|
|
|
-<<<<<<< Updated upstream
|
|
|
- var_adj.wind_speed_deviation := var_row.delta;
|
|
|
- var_adj.wind_deviation := pmt_wind_direction + var_row.delta;
|
|
|
- pmt_adjustments := array_append(pmt_adjustments, var_adj);
|
|
|
- end loop;
|
|
|
-end;
|
|
|
-$body$;
|
|
|
-=======
|
|
|
var_adj.wind_speed_deviation := 0;
|
|
|
var_adj.wind_deviation := 0;
|
|
|
|
|
@@ -356,7 +250,6 @@ $body$;
|
|
|
end;
|
|
|
$body$;
|
|
|
end$$;
|
|
|
->>>>>>> Stashed changes
|
|
|
do $$
|
|
|
declare
|
|
|
var_temperature_adjustments public.temperature_adjustment[];
|
|
@@ -365,11 +258,7 @@ declare
|
|
|
begin
|
|
|
|
|
|
raise notice 'расчет отклонений температуры для ветрового ружья';
|
|
|
-<<<<<<< Updated upstream
|
|
|
- call public.temp_dev_calc(
|
|
|
-=======
|
|
|
call public.calculate_temperature_deviation(
|
|
|
->>>>>>> Stashed changes
|
|
|
pmt_measurement_type_id => 2,
|
|
|
pmt_temperature => 3.0,
|
|
|
pmt_adjustments => var_temperature_adjustments
|
|
@@ -389,14 +278,10 @@ begin
|
|
|
pmt_adjustments => var_wind_direction_adjustments
|
|
|
);
|
|
|
raise notice 'среднее направление ветра: %', var_wind_direction_adjustments;
|
|
|
-<<<<<<< Updated upstream
|
|
|
-end $$;create or replace procedure public.temp_dev_calc_dmk(
|
|
|
-=======
|
|
|
end $$;
|
|
|
do $$
|
|
|
begin
|
|
|
create or replace procedure public.calculate_temperature_deviation_dmk(
|
|
|
->>>>>>> Stashed changes
|
|
|
in pmt_measurement_type_id integer,
|
|
|
in pmt_temperature numeric(8,2),
|
|
|
inout pmt_adjustments public.temperature_adjustment[]
|
|
@@ -544,10 +429,7 @@ begin
|
|
|
end loop;
|
|
|
end;
|
|
|
$body$;
|
|
|
-<<<<<<< Updated upstream
|
|
|
-=======
|
|
|
end$$;
|
|
|
->>>>>>> Stashed changes
|
|
|
do $$
|
|
|
declare
|
|
|
var_temperature_adjustments public.temperature_adjustment[];
|
|
@@ -556,11 +438,7 @@ declare
|
|
|
begin
|
|
|
|
|
|
raise notice 'расчет отклонений температуры для дмк';
|
|
|
-<<<<<<< Updated upstream
|
|
|
- call public.temp_dev_calc_dmk(
|
|
|
-=======
|
|
|
call public.calculate_temperature_deviation_dmk(
|
|
|
->>>>>>> Stashed changes
|
|
|
pmt_measurement_type_id => 1,
|
|
|
pmt_temperature => 3.0,
|
|
|
pmt_adjustments => var_temperature_adjustments
|