|  | @@ -110,7 +110,8 @@ create table measurment_input_params
 | 
											
												
													
														|  |  	temperature numeric(8,2) default 0,
 |  |  	temperature numeric(8,2) default 0,
 | 
											
												
													
														|  |  	pressure numeric(8,2) default 0,
 |  |  	pressure numeric(8,2) default 0,
 | 
											
												
													
														|  |  	wind_direction numeric(8,2) default 0,
 |  |  	wind_direction numeric(8,2) default 0,
 | 
											
												
													
														|  | -	wind_speed numeric(8,2) default 0
 |  | 
 | 
											
												
													
														|  | 
 |  | +	wind_speed numeric(8,2) default 0,
 | 
											
												
													
														|  | 
 |  | +	bullet_demolition_range numeric(8,2) default 0
 | 
											
												
													
														|  |  );
 |  |  );
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  insert into measurment_input_params(id, measurment_type_id, height, temperature, pressure, wind_direction,wind_speed )
 |  |  insert into measurment_input_params(id, measurment_type_id, height, temperature, pressure, wind_direction,wind_speed )
 | 
											
										
											
												
													
														|  | @@ -192,7 +193,8 @@ create type input_params as
 | 
											
												
													
														|  |  	temperature numeric(8,2),
 |  |  	temperature numeric(8,2),
 | 
											
												
													
														|  |  	pressure numeric(8,2),
 |  |  	pressure numeric(8,2),
 | 
											
												
													
														|  |  	wind_direction numeric(8,2),
 |  |  	wind_direction numeric(8,2),
 | 
											
												
													
														|  | -	wind_speed numeric(8,2)
 |  | 
 | 
											
												
													
														|  | 
 |  | +	wind_speed numeric(8,2),
 | 
											
												
													
														|  | 
 |  | +	bullet_demolition_range numeric(8,2)
 | 
											
												
													
														|  |  );
 |  |  );
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  raise notice 'Расчетные структуры сформированы';
 |  |  raise notice 'Расчетные структуры сформированы';
 | 
											
										
											
												
													
														|  | @@ -319,7 +321,7 @@ $body$;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  -- Функция для проверки входных параметров
 |  |  -- Функция для проверки входных параметров
 | 
											
												
													
														|  | -drop function if exists public.fn_check_input_params;
 |  | 
 | 
											
												
													
														|  | 
 |  | +drop function if exists public.fn_check_input_params(numeric(8,2), numeric(8,2),   numeric(8,2), numeric(8,2), numeric(8,2), numeric(8,2));
 | 
											
												
													
														|  |  create function public.fn_check_input_params(
 |  |  create function public.fn_check_input_params(
 | 
											
												
													
														|  |  	par_height numeric(8,2),
 |  |  	par_height numeric(8,2),
 | 
											
												
													
														|  |  	par_temperature numeric(8,2),
 |  |  	par_temperature numeric(8,2),
 | 
											
										
											
												
													
														|  | @@ -431,8 +433,28 @@ begin
 | 
											
												
													
														|  |  end;
 |  |  end;
 | 
											
												
													
														|  |  $body$;
 |  |  $body$;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +-- Функция для проверки параметров
 | 
											
												
													
														|  | 
 |  | +drop function if exists public.fn_check_input_params(input_params);
 | 
											
												
													
														|  | 
 |  | +create function public.fn_check_input_params(
 | 
											
												
													
														|  | 
 |  | +	par_param input_params
 | 
											
												
													
														|  | 
 |  | +)
 | 
											
												
													
														|  | 
 |  | +returns public.input_params
 | 
											
												
													
														|  | 
 |  | +language 'plpgsql'
 | 
											
												
													
														|  | 
 |  | +as $body$
 | 
											
												
													
														|  | 
 |  | +declare
 | 
											
												
													
														|  | 
 |  | +	var_result input_params;
 | 
											
												
													
														|  | 
 |  | +begin
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +	var_result := fn_check_input_params(
 | 
											
												
													
														|  | 
 |  | +		par_param.height, par_param.temperature, par_param.pressure, par_param.wind_direction,
 | 
											
												
													
														|  | 
 |  | +		par_param.wind_speed, par_param.bullet_demolition_range
 | 
											
												
													
														|  | 
 |  | +	);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +	return var_result;
 | 
											
												
													
														|  | 
 |  | +	
 | 
											
												
													
														|  | 
 |  | +end ;
 | 
											
												
													
														|  | 
 |  | +$body$;
 | 
											
												
													
														|  | 
 |  | +		
 | 
											
												
													
														|  |  -- Функция для расчета интерполяции
 |  |  -- Функция для расчета интерполяции
 | 
											
												
													
														|  |  drop function if exists public.fn_calc_temperature_interpolation;
 |  |  drop function if exists public.fn_calc_temperature_interpolation;
 | 
											
												
													
														|  |  create function public.fn_calc_temperature_interpolation(
 |  |  create function public.fn_calc_temperature_interpolation(
 | 
											
										
											
												
													
														|  | @@ -575,9 +597,56 @@ end;
 | 
											
												
													
														|  |  $body$;
 |  |  $body$;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +-- Функция для расчета метео приближенный
 | 
											
												
													
														|  | 
 |  | +drop function if exists fn_calc_header_meteo_avg;
 | 
											
												
													
														|  | 
 |  | +create function fn_calc_header_meteo_avg(
 | 
											
												
													
														|  | 
 |  | +	par_params input_params
 | 
											
												
													
														|  | 
 |  | +)
 | 
											
												
													
														|  | 
 |  | +returns text
 | 
											
												
													
														|  | 
 |  | +language 'plpgsql'
 | 
											
												
													
														|  | 
 |  | +as $body$
 | 
											
												
													
														|  | 
 |  | +declare
 | 
											
												
													
														|  | 
 |  | +	var_result text;
 | 
											
												
													
														|  | 
 |  | +	var_params input_params;
 | 
											
												
													
														|  | 
 |  | +begin
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	-- Проверяю аргументы
 | 
											
												
													
														|  | 
 |  | +	var_params := public.fn_check_input_params(par_params);
 | 
											
												
													
														|  | 
 |  | +	
 | 
											
												
													
														|  | 
 |  | +	select
 | 
											
												
													
														|  | 
 |  | +		-- Дата
 | 
											
												
													
														|  | 
 |  | +		public.fn_calc_header_period(now()) ||
 | 
											
												
													
														|  | 
 |  | +		--Высота расположения метеопоста над уровнем моря.
 | 
											
												
													
														|  | 
 |  | +	    lpad( 340::text, 4, '0' ) ||
 | 
											
												
													
														|  | 
 |  | +		-- Отклонение наземного давления атмосферы
 | 
											
												
													
														|  | 
 |  | +		lpad(
 | 
											
												
													
														|  | 
 |  | +				case when coalesce(var_params.pressure,0) < 0 then
 | 
											
												
													
														|  | 
 |  | +					'5' 
 | 
											
												
													
														|  | 
 |  | +				else ''
 | 
											
												
													
														|  | 
 |  | +				end ||
 | 
											
												
													
														|  | 
 |  | +				lpad ( abs(( coalesce(var_params.pressure, 0) )::int)::text,2,'0')
 | 
											
												
													
														|  | 
 |  | +			, 3, '0') as "БББ",
 | 
											
												
													
														|  | 
 |  | +		-- Отклонение приземной виртуальной температуры	
 | 
											
												
													
														|  | 
 |  | +		lpad( 
 | 
											
												
													
														|  | 
 |  | +				case when coalesce( var_params.temperature, 0) < 0 then
 | 
											
												
													
														|  | 
 |  | +					'5'
 | 
											
												
													
														|  | 
 |  | +				else
 | 
											
												
													
														|  | 
 |  | +					''
 | 
											
												
													
														|  | 
 |  | +				end ||
 | 
											
												
													
														|  | 
 |  | +				( coalesce(var_params.temperature,0)::int)::text
 | 
											
												
													
														|  | 
 |  | +			, 2,'0')
 | 
											
												
													
														|  | 
 |  | +		into 	var_result;
 | 
											
												
													
														|  | 
 |  | +	return 	var_result;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +end;
 | 
											
												
													
														|  | 
 |  | +$body$;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  raise notice 'Структура сформирована успешно';
 |  |  raise notice 'Структура сформирована успешно';
 | 
											
												
													
														|  |  end $$;
 |  |  end $$;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  -- Проверка расчета
 |  |  -- Проверка расчета
 | 
											
												
													
														|  |  do $$
 |  |  do $$
 | 
											
												
													
														|  |  declare
 |  |  declare
 | 
											
										
											
												
													
														|  | @@ -692,7 +761,3 @@ begin
 | 
											
												
													
														|  |  	
 |  |  	
 | 
											
												
													
														|  |  end $$;
 |  |  end $$;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | --- Проверки
 |  | 
 | 
											
												
													
														|  | -select * from public.measurment_input_params;
 |  | 
 | 
											
												
													
														|  | -select public.fn_check_input_params(
 |  | 
 | 
											
												
													
														|  | -0, 0, 0, 0, 0, 0);
 |  | 
 |