Volovikov Alexander 1 month ago
parent
commit
769f431bc1

+ 33 - 0
_Infra/scripts/CalcResult20240311.sql

@@ -0,0 +1,33 @@
+do $$
+declare
+	par_input_params public.input_params_type;
+	par_results public.calc_result_type[];
+	rec record;
+begin
+
+	par_input_params.height := 430;
+	par_input_params.temperature := 15;
+	par_input_params.pressure := 780;
+	par_input_params.wind_direction := 2;
+	par_input_params.wind_speed := 10;
+	par_input_params.bullet_demolition_range := 0;
+
+	
+	call public.sp_calc_corrections(par_input_params => par_input_params, par_measurement_type_id => 2,
+		par_results => par_results);
+
+	raise notice '| measurement_type_id  | height | deltapressure | deltatemperature | deviationtemperature | deviationwind | deviationwinddirection |';
+	raise notice '|----------------------|--------|---------------|------------------|----------------------|---------------|------------------------|';
+
+	foreach rec in ARRAY par_results LOOP
+		raise notice '| % | % | % | % | % | % | % |' ,
+			lpad(rec.measurement_type_id::text, 20, ' '), 
+			lpad(rec.height::text, 6, ' '), 
+			lpad(rec.deltapressure::text, 13, ' '), 
+			lpad(rec.deltatemperature::text, 16, ' '), 
+			lpad(rec.deviationtemperature::text, 20, ' '),
+			lpad(rec.deviationwind::text, 13, ' '),
+			lpad(rec.deviationwinddirection::text, 22, ' ');
+	end loop;
+	
+end $$

+ 45 - 0
_Infra/scripts/fn_tr_temp_input_params.sql

@@ -0,0 +1,45 @@
+create or replace function fn_tr_temp_input_params()
+returns trigger as
+$$
+declare 
+	var_check_result public.check_result_type;
+	var_input_params public.input_params_type;
+	var_response public.calc_result_response_type;
+	var_calc_result public.calc_result_type[];
+begin
+
+	-- Проверяем параметры
+	var_check_result := fn_check_input_params(  
+				NEW.height,
+				NEW.temperature,
+				NEW.pressure,
+				NEW.wind_direction,
+				NEW.wind_speed,
+				NEW.bullet_demolition_range
+			);
+
+	if var_check_result.is_check = False then
+		raise notice 'error %',  var_check_result.error_message;
+		NEW.error_message := var_check_result.error_message;
+		return NEW;
+	
+	end if;
+
+	var_input_params := var_check_result.params;
+
+	-- Формируем заговок
+	var_response.header := public.fn_calc_header_meteo_avg(var_input_params);
+
+	-- Формируем расчет
+	call public.sp_calc_corrections(par_input_params => var_input_params, 
+		par_measurement_type_id => NEW.measurment_type_id, 
+		par_results => var_calc_result);
+		
+	var_response.calc_result := var_calc_result;
+	
+	-- Запоминаем результат
+	NEW.calc_result = row_to_json(var_response);
+	return NEW;
+end;
+$$
+LANGUAGE plpgsql;

+ 17 - 0
_Infra/scripts/temp_input_params.sql

@@ -0,0 +1,17 @@
+create sequence temp_input_params_seq;
+create table temp_input_params
+(
+	id integer not null primary key default nextval('public.temp_input_params_seq'),
+	emploee_name varchar(100),
+	measurment_type_id integer NOT NULL,
+    height numeric(8,2) DEFAULT 0,
+    temperature numeric(8,2) DEFAULT 0,
+    pressure numeric(8,2) DEFAULT 0,
+    wind_direction numeric(8,2) DEFAULT 0,
+    wind_speed numeric(8,2) DEFAULT 0,
+    bullet_demolition_range numeric(8,2) DEFAULT 0,
+	measurment_input_params_id integer,
+	error_message text,
+	calc_result jsonb
+);
+