|
@@ -1,3 +1,8 @@
|
|
|
+<<<<<<< Updated upstream
|
|
|
+=======
|
|
|
+do $$
|
|
|
+begin
|
|
|
+>>>>>>> Stashed changes
|
|
|
create sequence if not exists calc_header_adjustment_seq;
|
|
|
create table if not exists calc_header_adjustment
|
|
|
(
|
|
@@ -18,7 +23,12 @@ 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;
|
|
@@ -61,6 +71,7 @@ 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),
|
|
@@ -73,11 +84,29 @@ values
|
|
|
(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
|
|
|
+(1, array[3, 4, 5, 6, 7, 7, 8, 9, 10, 11, 12, 12], 0),
|
|
|
+(2, array[4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 1),
|
|
|
+(3, array[4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16], 2),
|
|
|
+(4, array[4, 5, 7, 8, 8, 9, 11, 12, 13, 15, 15, 16], 2),
|
|
|
+(5, array[4, 6, 7, 8, 9, 10, 11, 13, 14, 15, 17, 17], 3),
|
|
|
+(6, array[4, 6, 7, 8, 9, 10, 11, 13, 14, 16, 17, 18], 3),
|
|
|
+(7, array[4, 6, 8, 9, 9, 10, 12, 14, 15, 16, 18, 19], 3),
|
|
|
+(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;
|
|
@@ -90,7 +119,14 @@ 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[]
|
|
@@ -156,6 +192,7 @@ 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,
|
|
@@ -213,6 +250,10 @@ begin
|
|
|
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[]
|
|
@@ -222,22 +263,100 @@ 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;
|
|
|
+ var_table integer[];
|
|
|
+ var_dev integer;
|
|
|
+ var_table_row text;
|
|
|
+begin
|
|
|
+ if coalesce(pmt_bullet_speed, -1) < 0 and coalesce(pmt_wind_direction, -1) < 0 then
|
|
|
+ raise exception 'некорректные параметры. pmt_bullet_speed=% или pmt_wind_direction=%', pmt_bullet_speed, pmt_wind_direction;
|
|
|
+ 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;
|
|
|
+
|
|
|
+ raise notice '| высота | скорость | направление |';
|
|
|
+ raise notice '|----------|-----------|-------------|';
|
|
|
+
|
|
|
+ for var_row in
|
|
|
+ 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;
|
|
|
+
|
|
|
+ if pmt_bullet_speed is not null then
|
|
|
+ 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;
|
|
|
+
|
|
|
+ var_header_index := abs(var_index % 10);
|
|
|
+ var_table := var_row.values;
|
|
|
+ var_dev := var_table[var_header_index];
|
|
|
+
|
|
|
+ var_adj.wind_speed_deviation := var_dev;
|
|
|
+ var_adj.wind_deviation := var_row.delta;
|
|
|
+ end if;
|
|
|
+
|
|
|
+ if pmt_wind_direction is not null then
|
|
|
+ var_adj.wind_deviation := var_adj.wind_deviation + (pmt_wind_direction / 10)::integer; -- Примерная логика
|
|
|
+ end if;
|
|
|
+
|
|
|
+ select '|' || lpad(var_row.height::text, 10, ' ') || '|' ||
|
|
|
+ lpad(var_adj.wind_speed_deviation::text, 11, ' ') || '|' ||
|
|
|
+ lpad(var_adj.wind_deviation::text, 13, ' ') || '|'
|
|
|
+ into var_table_row;
|
|
|
+
|
|
|
+ raise notice '%', var_table_row;
|
|
|
+
|
|
|
+ pmt_adjustments := array_append(pmt_adjustments, var_adj);
|
|
|
+ end loop;
|
|
|
+
|
|
|
+ raise notice '|----------|-----------|-------------|';
|
|
|
+end;
|
|
|
+$body$;
|
|
|
+end$$;
|
|
|
+>>>>>>> Stashed changes
|
|
|
do $$
|
|
|
declare
|
|
|
var_temperature_adjustments public.temperature_adjustment[];
|
|
@@ -246,7 +365,11 @@ 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
|
|
@@ -266,7 +389,14 @@ 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[]
|
|
@@ -414,6 +544,10 @@ begin
|
|
|
end loop;
|
|
|
end;
|
|
|
$body$;
|
|
|
+<<<<<<< Updated upstream
|
|
|
+=======
|
|
|
+end$$;
|
|
|
+>>>>>>> Stashed changes
|
|
|
do $$
|
|
|
declare
|
|
|
var_temperature_adjustments public.temperature_adjustment[];
|
|
@@ -422,7 +556,11 @@ 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
|