This commit is contained in:
dheepa
2021-10-28 09:12:13 +00:00
parent f3cf5e1d2d
commit 8402c9b738
74 changed files with 3883 additions and 908 deletions

View File

View File

@@ -125,8 +125,8 @@ perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
'IHTEMT_STD_RAW_Data_Block',__file_mnemonic,__file_sheet_mnemonic,1);
err_block:='IHTEMT_STD_RAW_Data_Block';
insert into staging2.IHTEMT_STD_RAW_Data_Block (Steering_Angle,Effort,block_row_number)
select a.column1,column2,block_row_number from staging2.stg_process_table_IHTEMT_STD a
insert into staging2.IHTEMT_STD_RAW_Data_Block (time_s,Steering_Angle,Effort,block_row_number)
select a.column1,column2,column3,block_row_number from staging2.stg_process_table_IHTEMT_STD a
where block_tag='IHTEMT_STD_RAW_Data';

View File

@@ -272,7 +272,7 @@ file_syspk='||p_file_syspk||',
file_mnemonic='''||p_file_mnemonic||''',
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHLS_HLS_H1_Block');
perform fw_core.fn_jobctl_block_end(__file_syspk,'IHTHLS_HLS_H1_BLOCK');
insert into staging2.IHTHLS_HLS_Weight_Tyre_Int

View File

@@ -1,7 +1,7 @@
CREATE OR REPLACE FUNCTION fw_ods.fn_fw_ods_budni_load(p_client_id int,p_function_id int, p_file_mnemonic text,
p_file_sheet_mnemonic text, p_file_syspk int)
CREATE OR REPLACE FUNCTION fw_ods.fn_fw_ods_budni_load(p_client_id integer, p_function_id integer, p_file_mnemonic text, p_file_sheet_mnemonic text, p_file_syspk integer)
RETURNS void
AS $$
LANGUAGE plpgsql
AS $function$
declare
f record;
@@ -20,7 +20,7 @@ AS $$
begin
-- Adding data to file fw_ods_field:
for f in select distinct file_mnemonic from fw_core.fw_jobctl_file_runschedule
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed'
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed' and file_syspk = __file_syspk
loop
if f.file_mnemonic = 'BUDNI'
then
@@ -54,6 +54,8 @@ then
test_type,
--subtype, condition hierarchy
location_name,
test_sub_type,
gear_used,
test_condition,
-- location name
engine_speed_var,
@@ -107,9 +109,11 @@ then
b.test_tractor_yn,
d.test_type,
d.test_location_name ,
a.test_condtion,
a.gear_used,
case split_part(a.test_condtion,' ',6)
when 'ballasted)' then 'ballasted'
when 'Unballasted)' then 'Unballasted'
when 'ballasted)' then 'Ballasted'
when 'Unballasted)' then 'Un-ballasted'
end,
-- test specific dimensions
-- test specific measures
@@ -223,6 +227,594 @@ then
AND a.file_syspk = __file_syspk
and b.tractor_model = a.tractor_model
and b.file_sheet_mnemonic in ('BUDNI_PTO') and d.file_mnemonic =('BUDNI') and d.file_sheet_mnemonic in ('BUDNI_PTO');
insert into fw_ods.fw_ods
(
-- File Identifier: Test_Mnemonic, Sheet_Mnemonic, file_syspk(id), test_instance_id, test_file_name,
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_name,
test_file_id,
test_file_name,
test_instance_id,
-- Tractor Identifier: tractor make,tractor model,tractor engine hp,wheel drive type,configuration,Test insance tractor id
tractor_make,
tractor_model,
mahindra_model_yn,
test_tractor_yn,
tractor_engine_hp,
wheel_drive_type,
"configuration",
test_instance_tractor_id,
--test specific: date & test dimensions
test_date,
test_date_year,
test_date_quarter,
test_date_month,
test_date_dayofmonth,
test_date_dayofweek,
season,
--test specific: condition
--test specific: location
location_name,
----test specific: Implement details(name, type and Weight_kg)
name_of_implement,
type_of_implement,
implement_weight_kg,
trailer_gross_weight_kg,
-- test specific measures: Speed and gear
-- test specific measures: fuel, area, speed,wheel-slip, productivity,rpm and depth-of-operation
fuel_consumption_lit_per_hr,
gear_used,
speed_kmph,
mileage_kmpl,
fuel_consumption_ml_per_km_per_tonne,
trailer_hitch_height_above_ground_level_mm,
created_by,
updated_by,
create_timestamp,
update_timestamp
--created_by, updated_by, create_timestamp, update_timestamp
)
select
-- File Identifier: Test_Mnemonic, Sheet_Mnemonic, file_syspk(id), test_instance_id, test_file_name,
a.client_id,
a.function_id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.test_name,
a.file_syspk,
a.test_file_name,
a.syspk,
-- Tractor Identifier: tractor make,tractor model,tractor engine hp,wheel drive type,configuration,Test insance tractor id
b.tractor_make,
b.tractor_model,
b.mahindra_model_yn,
b.test_tractor_yn,
b.tractor_engine_hp,
b.wheel_drive_type,
b.configuration,
b.syspk,
--test specific: date & test dimensions
a.date_of_test,
extract( year from a.date_of_test),
extract( quarter from a.date_of_test),
extract( month from a.date_of_test),
extract( day from a.date_of_test),
extract( dow from a.date_of_test),
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
a.test_location_name,
'Trailer',
c.trailer_type,
c.gross_mass_of_trailer_tonne *1000,
c.gross_mass_of_trailer_tonne *1000,
-- test specific measures: Speed and gear
-- test specific measures: fuel, area, speed,wheel-slip, productivity,rpm and depth-of-operation
((trim(split_part(c.avg_fuel_consumption_ltr_per_hr,'to',1))::numeric) + (case trim(split_part(c.avg_fuel_consumption_ltr_per_hr,'to',2)) when '' then trim(split_part(c.avg_fuel_consumption_ltr_per_hr,'to',1))::numeric else trim(split_part(c.avg_fuel_consumption_ltr_per_hr,'to',2))::numeric end ))/2::numeric,
c.gear_used_negotiating_slopes_up_to_8pct,
((trim(split_part(c.avg_travel_speed_kmph,'to',1))::numeric) + (case trim(split_part(c.avg_travel_speed_kmph,'to',2)) when '' then trim(split_part(c.avg_travel_speed_kmph,'to',1))::numeric else trim(split_part(c.avg_travel_speed_kmph,'to',2))::numeric end ))/2::numeric,
(((trim(split_part(avg_dist_traveled_per_litre_of_fuel_consumption_km,'to',1))::numeric) + (case trim(split_part(avg_dist_traveled_per_litre_of_fuel_consumption_km,'to',2)) when '' then trim(split_part(avg_dist_traveled_per_litre_of_fuel_consumption_km,'to',1))::numeric else trim(split_part(avg_dist_traveled_per_litre_of_fuel_consumption_km,'to',2))::numeric end ))/2::numeric),
(((trim(split_part(c.avg_fuel_consumption_ml_per_km_per_tonne,'to',1))::numeric) + (case trim(split_part(c.avg_fuel_consumption_ml_per_km_per_tonne,'to',2)) when '' then trim(split_part(c.avg_fuel_consumption_ml_per_km_per_tonne,'to',1))::numeric else trim(split_part(c.avg_fuel_consumption_ml_per_km_per_tonne,'to',2))::numeric end ))/2::numeric) ,
c.height_of_trailer_hitch_above_ground_level_mm,
current_user,
current_user,
current_timestamp,
current_timestamp
-- add user and timestamp fields
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
transactional.budni_haulage_perf_results c
where
a.file_syspk = b.file_syspk
and b.file_syspk = c.file_syspk
and c.tractor_model = b.tractor_model
and c.test_instance_tractor_id = b.syspk
and a.file_sheet_mnemonic = 'BUDNI_HLG'
and a.file_mnemonic = b.file_mnemonic
and a.file_mnemonic = c.file_mnemonic
and a.file_sheet_mnemonic = b.file_sheet_mnemonic
and a.file_sheet_mnemonic = c.file_sheet_mnemonic
AND a.file_syspk = __file_syspk;
insert into fw_ods.fw_ods
(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_name,
test_file_name,
test_instance_id,
-- Tractor Identifier: tractor make,tractor model,tractor engine hp,wheel drive type,configuration,Test insance tractor id
tractor_make,
tractor_model,
mahindra_model_yn,
test_tractor_yn,
tractor_engine_hp,
wheel_drive_type,
"configuration",
test_instance_tractor_id,
--test specific: date & test dimensions
season,
test_date,
test_date_year,
test_date_quarter,
test_date_month,
test_date_dayofmonth,
test_date_dayofweek,
--test specific: condition
--test specific: location
location_name,
test_condition,
test_sub_type,
test_type,
coordinates,
created_by,
updated_by,
create_timestamp,
update_timestamp
)
select
a.client_id,
a.function_Id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.file_syspk,
a.test_name,
a.test_file_name,
a.syspk,
b.tractor_make,
b.tractor_model,
b.test_tractor_yn,
b.mahindra_model_yn,
b.tractor_engine_hp,
b.wheel_drive_type,
b.configuration,
b.syspk,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
a.date_of_test,
extract( year from a.date_of_test),
extract( quarter from a.date_of_test),
extract( month from a.date_of_test),
extract( day from a.date_of_test),
extract( dow from a.date_of_test),
a.test_location_name,
c.condition,
(case when c.particulars like '%Height%' then 'z' when c.particulars like '%vertical%' then 'x' when c.particulars like '%median%' then 'y' else null end),
(case split_part(coordinates,'(',2) when '' then c.particulars else concat(c.particulars,'-(',split_part(coordinates,'(',2)) end),
split_part(coordinates,'(',1)::numeric,
current_user,
current_user,
current_timestamp,
current_timestamp
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
transactional.budni_centre_of_gravity_location c
where
a.file_syspk = b.file_syspk
and a.file_syspk = c.file_syspk
and c.test_instance_id = a.syspk
and c.test_instance_tractor_id =b.syspk
and a.file_mnemonic = b.file_mnemonic
and a.file_mnemonic = c.file_mnemonic
and a.file_sheet_mnemonic = b.file_sheet_mnemonic
and a.file_sheet_mnemonic = c.file_sheet_mnemonic
and a.file_sheet_mnemonic = 'BUDNI_LCG'
AND a.file_syspk = __file_syspk;
insert into fw_ods.fw_ods(
-- File Identifier: Test_Mnemonic, Sheet_Mnemonic, file_syspk(id), test_instance_id, test_file_name,
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_name,
test_file_id,
test_file_name,
test_instance_id,
-- Tractor Identifier: tractor make,tractor model,tractor engine hp,wheel drive type,""""configuration"""",Test insance tractor id
tractor_make,
tractor_model,
mahindra_model_yn,
test_tractor_yn,
tractor_engine_hp,
wheel_drive_type,
"configuration",
test_instance_tractor_id,
--test specific: date & test dimensions
test_date,
test_date_year,
test_date_quarter,
test_date_month,
test_date_dayofmonth,
test_date_dayofweek,
season,
--test specific: location and test purpose
-- test_mode,
test_type,
-- test_purpose,
location_name,
--Test Specific:
gear_used,
speed_kmph,
noise_dba,
pull_kn,
created_by,
updated_by,
create_timestamp,
update_timestamp
)
select
-- File Identifier: Test_Mnemonic, Sheet_Mnemonic, file_syspk(id), test_instance_id, test_file_name,
a.client_id,
a.function_id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.test_name,
a.file_syspk,
a.test_file_name,
a.syspk,
-- Tractor Identifier: tractor make,tractor model,tractor engine hp,wheel drive type,""""configuration"""",Test insance tractor id
b.tractor_make,
b.tractor_model,
b.mahindra_model_yn,
b.test_tractor_yn,
b.tractor_engine_hp,
b.wheel_drive_type,
b."configuration",
b.syspk,
--test specific: date & test dimensions
a.date_of_test,
extract( year from a.date_of_test),
extract( quarter from a.date_of_test),
extract( month from a.date_of_test),
extract( day from a.date_of_test),
extract( dow from a.date_of_test),
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
--test specific: location
-- c.test_mode,
c.noise_position as test_type,
-- a.test_purpose,
a.test_location_name,
-- Test Specific:
c.gear,
((trim(split_part(c.travel_speed_km_per_hr,'to',1))::numeric) + (case trim(split_part(c.travel_speed_km_per_hr,'to',2)) when '' then trim(split_part(c.travel_speed_km_per_hr,'to',1))::numeric else trim(split_part(c.travel_speed_km_per_hr,'to',2))::numeric end ))/2::numeric,
c.noise_level_db_a,
((trim(split_part(c.drawbar_pull_max_noise_kn,'to',1))::numeric) + (case trim(split_part(c.drawbar_pull_max_noise_kn,'to',2)) when '' then trim(split_part(c.drawbar_pull_max_noise_kn,'to',1))::numeric else trim(split_part(c.drawbar_pull_max_noise_kn,'to',2))::numeric end ))/2::numeric,
current_user,
current_user,
current_timestamp,
current_timestamp
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
transactional.Budni_noise_measurement_results c
where
a.file_syspk = b.file_syspk
and b.file_syspk = c.file_syspk
and c.tractor_model = b.tractor_model
and b.syspk = c.test_instance_tractor_id
and a.file_sheet_mnemonic in ('BUDNI_NMT')
and a.file_mnemonic = b.file_mnemonic
and a.file_mnemonic = c.file_mnemonic
and a.file_sheet_mnemonic = b.file_sheet_mnemonic
and b.file_sheet_mnemonic = c.file_sheet_mnemonic
and a.file_syspk = __file_syspk;
insert into fw_ods.fw_ods
(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_name,
test_file_name,
test_instance_id,
-- Tractor Identifier: tractor make,tractor model,tractor engine hp,wheel drive type,configuration,Test insance tractor id
tractor_make,
tractor_model,
mahindra_model_yn,
test_tractor_yn,
tractor_engine_hp,
wheel_drive_type,
"configuration",
test_instance_tractor_id,
--test specific: date & test dimensions
season,
test_date,
test_date_year,
test_date_quarter,
test_date_month,
test_date_dayofmonth,
test_date_dayofweek,
--test specific: condition
--test specific: location
location_name,
test_iteration_number,
sensor_body_location,
vb_no_load_vd_microns,
vb_no_load_hd_microns,
vb_load_85_pct_max_pto_power_vd_microns,
vb_load_85_pct_max_pto_power_hd_microns,
created_by,
updated_by,
create_timestamp,
update_timestamp
)
select
a.client_id,
a.function_Id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.file_syspk,
a.test_name,
a.test_file_name,
a.syspk,
b.tractor_make,
b.tractor_model,
b.test_tractor_yn,
b.mahindra_model_yn,
b.tractor_engine_hp,
b.wheel_drive_type,
b.configuration,
b.syspk,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
a.date_of_test,
extract( year from a.date_of_test),
extract( quarter from a.date_of_test),
extract( month from a.date_of_test),
extract( day from a.date_of_test),
extract( dow from a.date_of_test),
a.test_location_name,
c.srl_no,measuring_points,
c.vibration_at_no_load_vd_microns,
c.vibration_at_no_load_hd_microns,
c.vibration_at_load_85_pct_of_max_pto_power_vd_microns,
c.vibration_at_load_85_pct_of_max_pto_power_hd_microns,
current_user,
current_user,
current_timestamp,
current_timestamp
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
transactional.budni_vibration_measurement c
where
a.file_syspk = b.file_syspk
and b.file_syspk = c.file_syspk
-- and trim(c.tractor_model) = trim(b.tractor_model)
-- and trim(c.tractor_model) = trim(a.tractor_model)
and a.file_sheet_mnemonic = 'BUDNI_VMT'
and a.file_mnemonic = b.file_mnemonic
and a.file_mnemonic = c.file_mnemonic
and a.file_sheet_mnemonic = b.file_sheet_mnemonic
and b.file_sheet_mnemonic = c.file_sheet_mnemonic
and c.test_instance_id = a.syspk
and c.test_instance_tractor_id =b.syspk
and a.file_syspk = __file_syspk;
update transactional.budni_field_perf_results
set avg_wheel_slip_pct = regexp_replace(avg_wheel_slip_pct ,'\s','', 'g')
where file_syspk = __file_syspk;
insert into fw_ods.fw_ods
(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_name,
test_file_name,
test_instance_id,
-- Tractor Identifier: tractor make,tractor model,tractor engine hp,wheel drive type,configuration,Test insance tractor id
tractor_make,
tractor_model,
mahindra_model_yn,
test_tractor_yn,
tractor_engine_hp,
wheel_drive_type,
"configuration",
test_instance_tractor_id,
--test specific: date & test dimensions
season,
test_date,
test_date_year,
test_date_quarter,
test_date_month,
test_date_dayofmonth,
test_date_dayofweek,
--test specific: condition
--test specific: location
location_name,
type_of_soil,
----test specific: Implement details(name, type and Weight_kg)
name_of_implement,
type_of_implement,
test_type ,
gear_used,
fuel_consumption_lit_per_hr,
fuel_consumption_lit_per_acr,
area_covered_acr_per_hr,
speed_kmph,
wheel_slippage_pct,
depth_of_cut_cm_low,
depth_of_cut_cm_high,
pull_kn,
cage_wheel_width_mm,
cage_wheel_weight,
soil_moisture_content_pct,
soil_bulk_density_g_per_cc,
soil_cone_index,
created_by,
updated_by,
create_timestamp,
update_timestamp
)
select
a.client_id,
a.function_Id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.file_syspk,
a.test_name,
a.test_file_name,
a.syspk,
b.tractor_make,
b.tractor_model,
b.test_tractor_yn,
b.mahindra_model_yn,
b.tractor_engine_hp,
b.wheel_drive_type,
b.configuration,
b.syspk,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
a.date_of_test,
extract( year from a.date_of_test),
extract( quarter from a.date_of_test),
extract( month from a.date_of_test),
extract( day from a.date_of_test),
extract( dow from a.date_of_test),
a.test_location_name,
c.type_of_soil,
case d.name_of_implement when 'Specifications' then d.type_of_implement else d.name_of_implement end,
d.type_of_implement,
c.operation_type,
c.gear_used,
((trim(split_part(c.fuel_consumption_ltr_per_hr,'to',1))::numeric) + (case trim(split_part(c.fuel_consumption_ltr_per_hr,'to',2)) when '' then trim(split_part(c.fuel_consumption_ltr_per_hr,'to',1))::numeric else trim(split_part(c.fuel_consumption_ltr_per_hr,'to',2))::numeric end ))/2::numeric,
(((trim(split_part(c.fuel_consumption_ltr_per_ha,'to',1))::numeric) + (case trim(split_part(c.fuel_consumption_ltr_per_ha,'to',2)) when '' then trim(split_part(c.fuel_consumption_ltr_per_ha,'to',1))::numeric else trim(split_part(c.fuel_consumption_ltr_per_ha,'to',2))::numeric end ))/2::numeric)/2.47105,
(((trim(split_part(c.area_covered_ha_per_hr,'to',1))::numeric) + (case trim(split_part(c.area_covered_ha_per_hr,'to',2)) when '' then trim(split_part(c.area_covered_ha_per_hr,'to',1))::numeric else trim(split_part(c.area_covered_ha_per_hr,'to',2))::numeric end ))/2::numeric)*2.47105,
((trim(split_part(c.avg_speed_of_operation_kmph,'to',1))::numeric) + (case trim(split_part(c.avg_speed_of_operation_kmph,'to',2)) when '' then trim(split_part(c.avg_speed_of_operation_kmph,'to',1))::numeric else trim(split_part(c.avg_speed_of_operation_kmph,'to',2))::numeric end ))/2::numeric,
(case c.operation_type when 'Puddling' then
(case
(trim(split_part(c.avg_travel_reduction_pct,'Rear:',2)))
when
''
then
((cast(trim(split_part(c.avg_travel_reduction_pct,'to',1))as numeric)) + ((case ((trim(split_part(c.avg_travel_reduction_pct,'to',2)))) when '' then cast(trim(split_part(c.avg_travel_reduction_pct,'to',1)) as numeric) else (cast(trim(split_part(c.avg_travel_reduction_pct,'to',2)) as numeric)) end )::numeric)/2)::numeric
else
((trim(split_part((trim(split_part(c.avg_travel_reduction_pct,'Rear:',2))),'to',1))::numeric) + (case trim(split_part((trim(split_part(c.avg_travel_reduction_pct,'Rear:',2))),'to',2)) when '' then trim(split_part((trim(split_part(c.avg_travel_reduction_pct,'Rear:',2))),'to',1))::numeric else trim(split_part((trim(split_part(c.avg_travel_reduction_pct,'Rear:',2))),'to',2))::numeric end ))/2::numeric
end)
else (
case
(trim(split_part(c.avg_wheel_slip_pct,'Rear:',2)))
when
''
then
((cast(trim(split_part(c.avg_wheel_slip_pct,'to',1))as numeric)) + ((case ((trim(split_part(c.avg_wheel_slip_pct,'to',2)))) when '' then cast(trim(split_part(c.avg_wheel_slip_pct,'to',1)) as numeric) else (cast(trim(split_part(c.avg_wheel_slip_pct,'to',2)) as numeric)) end )::numeric)/2)::numeric
else
((trim(split_part((trim(split_part(c.avg_wheel_slip_pct,'Rear:',2))),'to',1))::numeric) + (case trim(split_part((trim(split_part(c.avg_wheel_slip_pct,'Rear:',2))),'to',2)) when '' then trim(split_part((trim(split_part(c.avg_wheel_slip_pct,'Rear:',2))),'to',1))::numeric else trim(split_part((trim(split_part(c.avg_wheel_slip_pct,'Rear:',2))),'to',2))::numeric end ))/2::numeric
end)
end)
,
( case c.operation_type when 'Puddling' then trim(split_part(c.avg_depth_of_puddle_cm,'to',1))::numeric else trim(split_part(c.avg_depth_of_cut_cm,'to',1))::numeric end),
(case c.operation_type when 'Puddling' then (case trim(split_part(c.avg_depth_of_puddle_cm ,'to',2)) when '' then null else trim(split_part(c.avg_depth_of_puddle_cm ,'to',2))::numeric end) else (case trim(split_part(c.avg_depth_of_cut_cm,'to',2)) when '' then null else trim(split_part(c.avg_depth_of_cut_cm,'to',2))::numeric end)end),
((trim(split_part(c.avg_draft_of_implement_kn,'to',1))::numeric) + (case trim(split_part(c.avg_draft_of_implement_kn,'to',2)) when '' then trim(split_part(c.avg_draft_of_implement_kn,'to',1))::numeric else trim(split_part(c.avg_draft_of_implement_kn,'to',2))::numeric end ))/2::numeric,
d.cage_wheel_width_mm,
d.cage_wheel_weight_kg,
((trim(split_part(c.avg_soil_moisture_pct_,'to',1))::numeric) + (case trim(split_part(c.avg_soil_moisture_pct_,'to',2)) when '' then trim(split_part(c.avg_soil_moisture_pct_,'to',1))::numeric else trim(split_part(c.avg_soil_moisture_pct_,'to',2))::numeric end ))/2::numeric,
((trim(split_part(c.bulk_density_of_soil_g_per_cc,'to',1))::numeric) + (case trim(split_part(c.bulk_density_of_soil_g_per_cc,'to',2)) when '' then trim(split_part(c.bulk_density_of_soil_g_per_cc,'to',1))::numeric else trim(split_part(c.bulk_density_of_soil_g_per_cc,'to',2))::numeric end ))/2::numeric,
((trim(split_part(c.cone_index_kgf_per_sq_cm,'to',1))::numeric) + (case trim(split_part(c.cone_index_kgf_per_sq_cm,'to',2)) when '' then trim(split_part(c.cone_index_kgf_per_sq_cm,'to',1))::numeric else trim(split_part(c.cone_index_kgf_per_sq_cm,'to',2))::numeric end ))/2::numeric,
current_user,
current_user,
current_timestamp,
current_timestamp
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
transactional.budni_field_perf_results c,
transactional.test_instance_implement_info d
where
a.file_syspk = b.file_syspk
and b.file_syspk = c.file_syspk
and c.file_syspk = d.file_syspk
and c.test_instance_id = d.test_instance_id
and c.test_instance_tractor_id =b.syspk
and ((c.operation_type like '%lough%' and d.name_of_implement like '%lough%') or (c.operation_type like '%Rotava%' and d.name_of_implement like '%Rotava%') or (c.operation_type like '%uddling%' and d.name_of_implement like '%pecification%'))
and a.file_sheet_mnemonic = 'BUDNI_FLD'
and a.file_mnemonic = b.file_mnemonic
and a.file_mnemonic = c.file_mnemonic
and a.file_sheet_mnemonic = b.file_sheet_mnemonic
and a.file_sheet_mnemonic = c.file_sheet_mnemonic
and a.file_syspk = __file_syspk;
END if;
end loop;
@@ -230,6 +822,8 @@ then
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_budni_load', err_state, err_msg, err_detail, err_hint, err_context,'success');
/*
EXCEPTION when OTHERS then
err_state = returned_sqlstate, /* P0002 */
@@ -244,10 +838,9 @@ perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compege
*/
end
$$
LANGUAGE plpgsql;
$function$
;

View File

@@ -21,7 +21,7 @@ begin
CREATE SEQUENCE if not exists mysequence INCREMENT 1 START 1;
-- Adding data to file fw_ods_field:
for f in select distinct file_mnemonic from fw_core.fw_jobctl_file_runschedule
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed'
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed' and file_syspk= __file_syspk
loop
if f.file_mnemonic in('FTDRY','FTWET')
then
@@ -43,6 +43,9 @@ wheel_drive_type,
tractor_engine_hp,
name_of_implement,
type_of_implement,
gear_used,
speed_rpm,
test_date_year,
season,
users,
"role",
@@ -72,6 +75,9 @@ create_timestamp
c.tractor_engine_hp,
d.name_of_implement,
d.Type_of_implement,
b.gear_used,
b.engine_rpm_set,
extract( year from a.date_of_test) ,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
@@ -101,6 +107,8 @@ create_timestamp
and b.file_syspk = c.file_syspk
and c.file_syspk = d.file_syspk
and c.tractor_model = b.tractor_model
and b.test_instance_tractor_id = c.syspk
and b.test_instance_id = d.test_instance_id
and a.file_syspk = __file_syspk;
ALTER SEQUENCE mysequence RESTART WITH 1;
@@ -128,6 +136,8 @@ wheel_drive_type,
tractor_engine_hp,
name_of_implement,
type_of_implement,
test_date_year ,
gear_used,
season,
users,
"role",
@@ -157,6 +167,8 @@ create_timestamp
c.tractor_engine_hp,
'Trailer',
d.trailer_type,
extract( year from a.date_of_test) ,
gear_used_on_straight_road,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
@@ -191,14 +203,8 @@ create_timestamp
ALTER SEQUENCE mysequence RESTART WITH 1;
END IF;
end loop;
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_comments_load', err_state, err_msg, err_detail, err_hint, err_context,'success');
/*
EXCEPTION when OTHERS then
@@ -210,8 +216,8 @@ EXCEPTION when OTHERS then
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_comments_load', err_state, err_msg, err_detail, err_hint, err_context,'error');
*/
end
$$
LANGUAGE plpgsql;
LANGUAGE plpgsql;

View File

@@ -20,7 +20,7 @@ AS $$
begin
-- Adding data to file fw_ods_field:
for f in select distinct file_mnemonic from fw_core.fw_jobctl_file_runschedule
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed'
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed' and file_syspk = __file_syspk
loop
if f.file_mnemonic = 'IHTEMT'
then
@@ -125,7 +125,7 @@ and a.file_mnemonic like 'IHT%';
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_detailed_load', err_state, err_msg, err_detail, err_hint, err_context,'success');
/*
EXCEPTION when OTHERS then
@@ -139,7 +139,7 @@ EXCEPTION when OTHERS then
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_detailed_load', err_state, err_msg, err_detail, err_hint, err_context,'error');
*/

View File

@@ -0,0 +1,116 @@
CREATE OR REPLACE FUNCTION fw_ods.fn_fw_ods_drawbar_comments_load(p_client_id int,p_function_id int, p_file_mnemonic text,
p_file_sheet_mnemonic text, p_file_syspk int)
RETURNS void
AS $$
declare
f record;
declare __client_id int :=p_client_id;
declare __function_id int :=p_function_id;
declare __file_mnemonic text :=p_file_mnemonic;
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
declare __file_syspk int :=p_file_syspk;
declare err_state text;
declare err_msg text;
declare err_detail text;
declare err_hint text;
declare err_context text;
declare _error int;
begin
insert into fw_ods.fw_ods_observations
(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_file_name,
--platform,
--benchmark_yn,
tractor_make,
tractor_model,
tractor_engine_hp,
wheel_drive_type,
configuration,
season,
test_date_year,
parameters,
sequence,
value1,
value2,
gear_used,
--display_yn,
acceptance_criteria,
remarks,
created_by,
updated_by,
create_timestamp,
update_timestamp
)
select
a.client_id,
a.function_Id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.file_syspk,
a.test_file_name,
b.tractor_make,
b.tractor_model,
b.tractor_engine_hp,
b.wheel_drive_type,
b.configuration,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
extract( year from a.date_of_test),
concat(split_part(c.test_parameter,' ',2) ,' ',split_part(c.test_parameter,' ',3)) as test_parameters,
case When split_part(trim(c.test_parameter),' ',2) like 'Pull%' then 1 else 2 end,
split_part(c.observation,' ',1),
split_Part( split_part(c.observation, ')',1), '(',2),
(select arr[array_length(arr,1)-1] FROM (SELECT string_to_array(c.remarks, ' ') AS arr) AS t) as gear_used,
--split_part(trim(split_part(c.remarks, 'in', 2)), ' ', 1 ) as gear_used,
c.acceptance_criteria,
c.remarks,
current_user,
current_user,
current_timestamp,
current_timestamp
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
transactional.drawbar_perf_observations c
where a.file_syspk = b.file_syspk
and a.file_syspk = c.file_syspk
and a.file_mnemonic = b.file_mnemonic
and a.file_mnemonic = c.file_mnemonic
and a.file_sheet_mnemonic = b.file_sheet_mnemonic
and a.file_sheet_mnemonic = c.file_sheet_mnemonic
and a.file_syspk =__file_syspk;
err_context :='';
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_comments_load', err_state, err_msg, err_detail, err_hint, err_context,'success');
/*
EXCEPTION when OTHERS then
err_state = returned_sqlstate, /* P0002 */
err_msg = message_text, /* No Data in FTDRY */
err_detail = pg_exception_detail, /* No data in table t_test_new */
err_hint = pg_exception_hint, /* No data error capture */
err_context = pg_exception_context; /* PL/pgSQL function staging2.fn_ftdry_trs_block(integer,integer,text,text,integer) line 69 at RAISE*/
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_comments_load', err_state, err_msg, err_detail, err_hint, err_context,'error');
*/
end
$$
LANGUAGE plpgsql;

View File

@@ -20,7 +20,7 @@ AS $$
begin
-- Adding data to file fw_ods_field:
for f in select distinct file_mnemonic from fw_core.fw_jobctl_file_runschedule
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed' and file_mnemonic = 'DBSTD'
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed' and file_mnemonic = 'DBSTD' and file_syspk = __file_syspk
loop
@@ -153,7 +153,7 @@ FROM staging1.staging_generic_table a where file_mnemonic = 'DBSTD' and test_fil
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_drawbar_load', err_state, err_msg, err_detail, err_hint, err_context,'success');
/*
EXCEPTION when OTHERS then
@@ -167,7 +167,7 @@ EXCEPTION when OTHERS then
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_drawbar_load', err_state, err_msg, err_detail, err_hint, err_context,'error');
*/
end

View File

@@ -0,0 +1,371 @@
CREATE OR REPLACE FUNCTION fw_ods.fn_fw_ods_drawbar_observations_load(p_client_id int,p_function_id int, p_file_mnemonic text,
p_file_sheet_mnemonic text, p_file_syspk int)
RETURNS void
AS $$
declare
f record;
declare __client_id int :=p_client_id;
declare __function_id int :=p_function_id;
declare __file_mnemonic text :=p_file_mnemonic;
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
declare __file_syspk int :=p_file_syspk;
declare err_state text;
declare err_msg text;
declare err_detail text;
declare err_hint text;
declare err_context text;
declare _error int;
begin
CREATE SEQUENCE if not exists obssequence INCREMENT 1 START 1;
insert into fw_ods.fw_ods_observations
(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_file_name,
--platform,
--benchmark_yn,
tractor_make,
tractor_model,
tractor_engine_hp,
wheel_drive_type,
configuration,
season,
test_date_year,
group_category,
sequence,
parameters,
value1,
value2,
--display_yn,
created_by,
updated_by,
create_timestamp,
update_timestamp
)
select
a.client_id,
a.function_Id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.file_syspk,
a.test_file_name,
b.tractor_make,
b.tractor_model,
b.tractor_engine_hp,
b.wheel_drive_type,
b.configuration,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
extract( year from a.date_of_test),
'Engine-RPM' as group_category,
nextval('obssequence'),
unnest(Array
[
'Low Idle RPM',
'High Idle RPM',
'Rated Speed',
'Engine to PTO Ratio',
'Wheel Base (mm)',
'Engine Power hp',
'PTO Power hp'
]
) as parameters,
unnest(Array[
c.low_idle_declared::text,
c.high_idle_declared::text,
c.rated_rpm::text,
c.engine_to_pto_ratio_540_pto::text,
b.wheel_base_mm::text,
c.engine_power_hp::text,
c.pto_power_hp::text
]) as value1,
unnest(Array[
c.low_idle_observed::text,
c.high_idle_observed::text,
c.rated_rpm_observed::text
]) as value2,
current_user,
current_user,
current_timestamp,
current_timestamp
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
transactional.test_instance_engine_info c
where a.file_syspk = b.file_syspk
and a.file_syspk = c.file_syspk
and a.file_mnemonic = b.file_mnemonic
and a.file_mnemonic = c.file_mnemonic
and a.file_sheet_mnemonic = b.file_sheet_mnemonic
and a.file_sheet_mnemonic = c.file_sheet_mnemonic
and a.file_syspk =__file_syspk;
insert into fw_ods.fw_ods_observations
(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_file_name,
--platform,
--benchmark_yn,
tractor_make,
tractor_model,
tractor_engine_hp,
wheel_drive_type,
configuration,
season,
test_date_year,
group_category,
sequence,
parameters,
value1,
value2,
--display_yn,
created_by,
updated_by,
create_timestamp,
update_timestamp
)
select
a.client_id,
a.function_Id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.file_syspk,
a.test_file_name,
b.tractor_make,
b.tractor_model,
b.tractor_engine_hp,
b.wheel_drive_type,
b.configuration,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
extract( year from a.date_of_test),
'Engine-RPM' as group_value,
nextval('obssequence'),
t.col as parameters,
t.value1,
t.value2,
current_user,
current_user,
current_timestamp,
current_timestamp
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
staging2.crosstab(
'SELECT unnest(''{
Drawbar Type,
Drawbar Type INFO,
Required Pull in kg,
Required Power in hp,
Actual Pull in kg,
Actual Power in hp,
Calculated hitch height (mm),
Actual hitch height (mm)
}''::text[]) AS col
, row_number() OVER ()
, unnest(ARRAY[
drawbar_type_name::text,
drawbar_type_info::text,
concat(drawbar_type,''-'',required_pull_in_kg)::text,
concat(drawbar_type,''-'',required_power_in_hp)::text,
concat(drawbar_type,''-'',actual_pull_in_kg)::text,
concat(drawbar_type,''-'',actual_power_in_hp)::text,
concat(drawbar_type,''-'',calculated_hitch_height_mm)::text,
concat(drawbar_type,''-'',actual_hitch_height_mm)::text
]) AS val
FROM transactional.test_instance_drawbar_info
where
file_syspk = '''||__file_syspk||'''
ORDER BY generate_series(1,8), 2'
) t (col text, value1 text,value2 text)
where a.file_syspk = b.file_syspk
and a.file_mnemonic = b.file_mnemonic
and a.file_sheet_mnemonic = b.file_sheet_mnemonic
and a.file_syspk =__file_syspk;
ALTER SEQUENCE obssequence RESTART WITH 1;
insert into fw_ods.fw_ods_observations
(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_file_name,
--platform,
--benchmark_yn,
tractor_make,
tractor_model,
tractor_engine_hp,
wheel_drive_type,
configuration,
season,
test_date_year,
group_category,
sequence,
parameters,
value1,
value2,
--display_yn,
created_by,
updated_by,
create_timestamp,
update_timestamp
)
select
a.client_id,
a.function_Id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.file_syspk,
a.test_file_name,
b.tractor_make,
b.tractor_model,
b.tractor_engine_hp,
b.wheel_drive_type,
b.configuration,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
extract( year from a.date_of_test),
'Weight-Kg' as group_name,
nextval('obssequence') as sequence_no,
t.col as parameters,
t.value1,
t.value2,
current_user,
current_user,
current_timestamp,
current_timestamp
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
staging2.crosstab(
'SELECT unnest(''{
Weight Front kg,
Weight Rear kg,
Weight Total kg
}''::text[]) AS col
, row_number() OVER ()
, unnest(ARRAY[
concat(drawbar_type,''-'',weight_front_kg)::text,
concat(drawbar_type,''-'',weight_rear_kg)::text,
concat(drawbar_type,''-'',weight_total_kg)::text
]) AS val
FROM transactional.test_instance_drawbar_info
where
file_syspk = '''||__file_syspk||'''
ORDER BY generate_series(1,3), 2'
) t (col text, value1 text,value2 text)
where a.file_syspk = b.file_syspk
and a.file_mnemonic = b.file_mnemonic
and a.file_sheet_mnemonic = b.file_sheet_mnemonic
and a.file_syspk =__file_syspk;
ALTER SEQUENCE obssequence RESTART WITH 1;
insert into fw_ods.fw_ods_observations
(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_file_name,
--platform,
--benchmark_yn,
tractor_make,
tractor_model,
tractor_engine_hp,
wheel_drive_type,
configuration,
season,
test_date_year,
group_category,
sequence,
parameters,
value1,
value2,
--display_yn,
created_by,
updated_by,
create_timestamp,
update_timestamp
)
select
a.client_id,
a.function_Id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.file_syspk,
a.test_file_name,
b.tractor_make,
b.tractor_model,
b.tractor_engine_hp,
b.wheel_drive_type,
b.configuration,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
extract( year from a.date_of_test),
'Tyre Details' as group_value,
nextval('obssequence'),
t.col as parameters,
t.value1 ,
t.value2,
current_user,
current_user,
current_timestamp,
current_timestamp
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
staging2.crosstab(
'SELECT unnest(''{Tyre Type,Tyre Make,Tyre Size,Tyre Ply Rating,Tyre Load Carrying Capacity in KG,Pressure (kg/cm2),Tyre number of lug,Tyre number of no load lug (30m),Tyre Lug Height,Tyre Dynamic Rolling Radius (mm),Tyre Wheel Rim Make and Size}''::text[]) AS col
, row_number() OVER ()
, unnest(ARRAY[tyre_type::text,tyre_make::text,tyre_size::text,tyre_ply_rating::text,tyre_load_carrying_capacity::text,tyre_pressure_kg_per_cm2::text,tyre_number_of_lug::text,tyre_number_of_no_load_lug_30m::text,tyre_lug_height::text,tyre_dynamic_rolling_radius_mm::text,tyre_wheel_rim_make_and_size]) AS val
FROM transactional.test_instance_tyre_info
where
file_syspk = '''||__file_syspk||'''
ORDER BY generate_series(1,11), 2'
) t (col text, value1 text,value2 text)
where a.file_syspk = b.file_syspk
and a.file_mnemonic = b.file_mnemonic
and a.file_sheet_mnemonic = b.file_sheet_mnemonic
and a.file_syspk =__file_syspk;
ALTER SEQUENCE obssequence RESTART WITH 1;
err_context :='';
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_comments_load', err_state, err_msg, err_detail, err_hint, err_context,'success');
/*
EXCEPTION when OTHERS then
err_state = returned_sqlstate, /* P0002 */
err_msg = message_text, /* No Data in FTDRY */
err_detail = pg_exception_detail, /* No data in table t_test_new */
err_hint = pg_exception_hint, /* No data error capture */
err_context = pg_exception_context; /* PL/pgSQL function staging2.fn_ftdry_trs_block(integer,integer,text,text,integer) line 69 at RAISE*/
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_comments_load', err_state, err_msg, err_detail, err_hint, err_context,'error');
*/
end
$$
LANGUAGE plpgsql;

View File

@@ -20,7 +20,7 @@ AS $$
begin
-- Adding data to file fw_ods_field:
for f in select distinct file_mnemonic from fw_core.fw_jobctl_file_runschedule
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed'
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed' and file_syspk= __file_syspk
loop
if f.file_mnemonic = 'DBSTD'
then
@@ -168,7 +168,7 @@ insert into fw_ods.fw_ods_drawbar_performance (
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_drawbar_performance_load', err_state, err_msg, err_detail, err_hint, err_context,'success');
/*
EXCEPTION when OTHERS then
@@ -183,7 +183,7 @@ EXCEPTION when OTHERS then
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_drawbar_performance_load', err_state, err_msg, err_detail, err_hint, err_context,'error');
*/
end
$$

View File

@@ -21,7 +21,7 @@ AS $$
begin
-- Adding data to file fw_ods_field:
for f in select distinct file_mnemonic from fw_core.fw_jobctl_file_runschedule
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed'
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed' and file_syspk = __file_syspk
loop
if f.file_mnemonic = 'FTDRY'
then
@@ -461,7 +461,7 @@ perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compege
/*
EXCEPTION when OTHERS then
@@ -477,7 +477,7 @@ perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compege
*/
end
$$
LANGUAGE plpgsql;

View File

@@ -20,7 +20,7 @@ AS $$
begin
-- Adding data to file fw_ods_field:
for f in select distinct file_mnemonic from fw_core.fw_jobctl_file_runschedule
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed'
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed' and file_syspk = __file_syspk
loop
if f.file_mnemonic like 'IHT%'
then
@@ -319,6 +319,112 @@ then
and c.tractor_model = b.tractor_model
and a.file_mnemonic in ('IHTSLL')
and a.file_syspk = __file_syspk;
-- Insert data to fw_ods_iht: for Speed Lag:
insert into fw_ods.fw_ods(
-- File Identifier: Test_Mnemonic, Sheet_Mnemonic, file_syspk(id), test_instance_id, test_file_name,
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_name,
test_file_id,
test_file_name,
test_instance_id,
-- Tractor Identifier: tractor make,tractor model,tractor engine hp,wheel drive type,""""configuration"""",Test insance tractor id
tractor_make,
tractor_model,
mahindra_model_yn,
test_tractor_yn,
tractor_engine_hp,
wheel_drive_type,
"configuration",
test_instance_tractor_id,
--test specific: date & test dimensions
test_date,
test_date_year,
test_date_quarter,
test_date_month,
test_date_dayofmonth,
test_date_dayofweek,
season,
--test specific: location and test purpose
-- test_condition,
test_purpose,
location_name,
test_type,
--Test Specific:
gear_used,
engine_speed_var,
no_of_revolution_front,
Lead_lag_ratio,
Lead_lag_pct,
Lead_lag_type,
created_by,
updated_by,
create_timestamp,
update_timestamp
)
select
-- File Identifier: Test_Mnemonic, Sheet_Mnemonic, file_syspk(id), test_instance_id, test_file_name,
a.client_id,
a.function_id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.test_name,
a.file_syspk,
a.test_file_name,
a.syspk,
-- Tractor Identifier: tractor make,tractor model,tractor engine hp,wheel drive type,"""configuration""",Test insance tractor id
b.tractor_make,
b.tractor_model,
b.mahindra_model_yn,
b.test_tractor_yn,
b.tractor_engine_hp,
c.wheel_drive_type,
b."configuration",
b.syspk,
--test specific: date & test dimensions
a.date_of_test,
extract( year from a.date_of_test),
extract( quarter from a.date_of_test),
extract( month from a.date_of_test),
extract( day from a.date_of_test),
extract( dow from a.date_of_test),
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
--test specific: location
-- c.test_condition,
a.test_purpose,
a.test_location_name,
'Lead-Lag',
-- Test Specific:
--wheel_drive_type
c.gear,
c.engine_rpm,
c.no_of_revolution_front,
c.ratio,
split_part(c.lead_lag_pct,' ',1)::numeric,
split_part(c.lead_lag_pct,' ',2),
current_user,
current_user,
current_timestamp,
current_timestamp
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
transactional.iht_speed_lead_lag_measurement c
where
a.file_syspk = b.file_syspk
and b.file_syspk = c.file_syspk
and c.tractor_model = b.tractor_model
and a.file_mnemonic in ('IHTSLL')
and a.file_syspk = __file_syspk;
-- Insert data to fw_ods_iht: for Brake:
@@ -829,6 +935,219 @@ then
and c.tractor_model = b.tractor_model
and a.file_mnemonic in ('IHTEMT')
and a.file_syspk = __file_syspk;
insert into fw_ods.fw_ods
(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_name,
test_file_name,
test_instance_id,
-- Tractor Identifier: tractor make,tractor model,tractor engine hp,wheel drive type,configuration,Test insance tractor id
tractor_make,
tractor_model,
mahindra_model_yn,
test_tractor_yn,
tractor_engine_hp,
wheel_drive_type,
"configuration",
test_instance_tractor_id,
--test specific: date & test dimensions
season,
test_date,
test_date_year,
test_date_quarter,
test_date_month,
test_date_dayofmonth,
test_date_dayofweek,
--test specific: condition
--test specific: location
location_name,
load_kg,
speed_kmph ,
engine_speed_var,
gear_used,
test_type,
sensor_body_location,
body_location_temperature,
created_by,
updated_by,
create_timestamp,
update_timestamp
)
select
a.client_id,
a.function_Id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.file_syspk,
a.test_name,
a.test_file_name,
a.syspk,
b.tractor_make,
b.tractor_model,
b.test_tractor_yn,
b.mahindra_model_yn,
b.tractor_engine_hp,
b.wheel_drive_type,
b.configuration,
b.syspk,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
a.date_of_test,
extract( year from a.date_of_test),
extract( quarter from a.date_of_test),
extract( month from a.date_of_test),
extract( day from a.date_of_test),
extract( dow from a.date_of_test),
a.test_location_name,
c.load_kg,
c.speed_kmph,
c.speed_rpm,
gear,
(case when d.col LiKE '%temp%' then 'TEMP' when d.col like '%roa%' then 'ROA' else null end) as TEStype,
split_part(d.col,' ',1),
d.r1,
current_user,
current_user,
current_timestamp,
current_timestamp
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
transactional.iht_hot_air_mapping_results c,
(
SELECT *
FROM staging2.crosstab(
'SELECT unnest(''{Ambient temp,Head temp,Head roa,Chest temp,Chest roa,LH-Leg temp,LH-Leg roa,RH-Leg temp,RH-Leg roa,RH-Hand temp,RH-Hand roa,LH-Hand temp,LH-Hand roa}''::text[]) AS col
, row_number() OVER ()
, unnest(ARRAY[ambient_measured_temp_c::int,head_measured_temp_c::int,head_roa_c::int,chest_measured_temp_c::int,chest_roa_c::int,lh_leg_measured_temp_c::int,lh_leg_roa_c::int,rh_leg_measured_temp_c::int,rh_leg_roa_c::int,rh_hand_measured_temp_c::int,rh_hand_roa_c::int,lh_hand_measured_temp_c::int,lh_hand_roa_c::int]) AS val
FROM transactional.iht_hot_air_mapping_results where gear = ''Max''
and file_syspk = '''||__file_syspk||'''
ORDER BY generate_series(1,13), 2'
) t (col text, r1 int)
)d
where
a.file_syspk = b.file_syspk
and b.file_syspk = c.file_syspk
and trim(c.tractor_model) = trim(b.tractor_model)
and trim(c.tractor_model) = trim(a.tractor_model)
and a.file_sheet_mnemonic = 'IHTHAM_HAM'
and c.gear='Max'
and c.test_instance_id = a.syspk
and c.test_instance_tractor_id =b.syspk
and a.file_mnemonic = b.file_mnemonic
and a.file_mnemonic = c.file_mnemonic
and a.file_sheet_mnemonic = b.file_sheet_mnemonic
and a.file_sheet_mnemonic = c.file_sheet_mnemonic
and a.file_syspk = __file_syspk;
insert into fw_ods.fw_ods
(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_name,
test_file_name,
test_instance_id,
-- Tractor Identifier: tractor make,tractor model,tractor engine hp,wheel drive type,configuration,Test insance tractor id
tractor_make,
tractor_model,
mahindra_model_yn,
test_tractor_yn,
tractor_engine_hp,
wheel_drive_type,
"configuration",
test_instance_tractor_id,
--test specific: date & test dimensions
season,
test_date,
test_date_year,
test_date_quarter,
test_date_month,
test_date_dayofmonth,
test_date_dayofweek,
--test specific: condition
--test specific: location
location_name,
test_sub_type,
test_type,
coordinates,
created_by,
updated_by,
create_timestamp,
update_timestamp
)
select
a.client_id,
a.function_Id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.file_syspk,
a.test_name,
a.test_file_name,
a.syspk,
b.tractor_make,
b.tractor_model,
b.test_tractor_yn,
b.mahindra_model_yn,
b.tractor_engine_hp,
b.wheel_drive_type,
b.configuration,
b.syspk,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
a.date_of_test,
extract( year from a.date_of_test),
extract( quarter from a.date_of_test),
extract( month from a.date_of_test),
extract( day from a.date_of_test),
extract( dow from a.date_of_test),
a.test_location_name,
split_part(c.col,'-',2),
split_part(c.col,'-',1),
c.r1,
current_user,
current_user,
current_timestamp,
current_timestamp
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
(
SELECT *
FROM staging2.crosstab(
'SELECT unnest(''{horizontal_distance_from_rac(mm)-x,lateral_co_ordinate_in_horizontal_plane(mm)-y,vertical_co_ordinate(mm)-z}''::text[]) AS col
, row_number() OVER ()
, unnest(ARRAY[horizontal_distance_from_rac_x_mm::numeric,lateral_co_ordinate_in_horizontal_plane_y_mm::numeric,vertical_co_ordinate_z_mm::numeric]) AS val
FROM transactional.iht_cgm_results
where
file_syspk = '''||__file_syspk||'''
ORDER BY generate_series(1,3), 2'
) t (col text, r1 numeric)
) c
where
a.file_syspk = b.file_syspk
and trim(a.tractor_model) = trim(b.tractor_model)
and a.file_sheet_mnemonic = 'IHTCGM_CGM'
and a.file_mnemonic = b.file_mnemonic
and a.file_sheet_mnemonic = b.file_sheet_mnemonic
and a.file_syspk =__file_syspk;
update fw_ods.fw_ods b
@@ -848,7 +1167,7 @@ END IF;
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_iht_load', err_state, err_msg, err_detail, err_hint, err_context,'success');
/*
EXCEPTION when OTHERS then
@@ -862,7 +1181,7 @@ EXCEPTION when OTHERS then
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_iht_load', err_state, err_msg, err_detail, err_hint, err_context,'error');
*/
end
$$

View File

@@ -171,7 +171,7 @@ and b.file_syspk = __file_syspk
end loop;
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_implement_details_update', err_state, err_msg, err_detail, err_hint, err_context,'success');
/*
EXCEPTION when OTHERS then
err_state = returned_sqlstate, /* P0002 */
err_msg = message_text, /* No Data in FTDRY */
@@ -180,6 +180,6 @@ EXCEPTION when OTHERS then
err_context = pg_exception_context; /* PL/pgSQL function staging2.fn_ftdry_trs_block(integer,integer,text,text,integer) line 69 at RAISE*/
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_implement_details_update', err_state, err_msg, err_detail, err_hint, err_context,'error');
*/
end
$$ LANGUAGE plpgsql;

View File

@@ -1,11 +1,13 @@
CREATE OR REPLACE FUNCTION fw_ods.fn_fw_ods_observations_load(p_client_id int,p_function_id int, p_file_mnemonic text,
p_file_sheet_mnemonic text, p_file_syspk int)
RETURNS void
AS $$
declare
f record;
total_count int :=5;
null_count record;
i record;
counter integer := 1;
declare __client_id int :=p_client_id;
declare __function_id int :=p_function_id;
@@ -17,187 +19,408 @@ f record;
declare err_detail text;
declare err_hint text;
declare err_context text;
declare _error int;
declare _error int;
begin
for i in select distinct test_iteration_number, file_syspk from transactional.field_perf_summary fps where file_syspk =__file_syspk
loop
insert into fw_ods.fw_ods_observations(
parameters,
value1,
value2,
value3,
value4,
value5
)
(
SELECT *
FROM staging2.crosstab(
'SELECT unnest(''{tractor_model,engine_smoke_on_load,engine_acceleration_smoke,range_gear_shifting,speed_gear_shifting,draft_response,
tractor_steer_ability,tractor_braking_perf,front_visibility,implement_accessibility,front_wheel_dragging_at_turning,front_end_lifting_during_operation
,rpm_recovery_time,engine_vibration,engine_sound,implement_lifting_per_lowering_response,pulverization_quality,pulverization_index}''::text[]) AS col
, row_number() OVER ()
, unnest(ARRAY[tractor_model::text,engine_smoke_on_load::text,engine_acceleration_smoke::text,
range_gear_shifting::text,speed_gear_shifting::text,draft_response::text,tractor_steer_ability::text,tractor_braking_perf::text,
front_visibility::text,implement_accessibility::text,front_wheel_dragging_at_turning::text,
front_end_lifting_during_operation::text,rpm_recovery_time::text,engine_vibration::text,engine_sound::text,
implement_lifting_per_lowering_response,pulverization_quality::text,pulverization_index::text]) AS val
FROM transactional.field_perf_summary
where file_syspk = '''||__file_syspk||'''
and test_iteration_number = '''||i.test_iteration_number||'''
ORDER BY generate_series(1,18),tractor_model, 2'
) t (col text,a1 text,a2 text,a3 text,a4 text,a5 text));
update fw_ods.fw_ods_observations set parameters = 'Tractor Model',sequence = 1 where parameters = 'tractor_model';
update fw_ods.fw_ods_observations set parameters = 'Engine Smoke on Load' , sequence = 2 where parameters = 'engine_smoke_on_load';
update fw_ods.fw_ods_observations set parameters = 'Engine acceleration smoke' , sequence = 3 where parameters = 'engine_acceleration_smoke';
update fw_ods.fw_ods_observations set parameters = 'Draft Response' , sequence = 4 where parameters = 'draft_response';
update fw_ods.fw_ods_observations set parameters = 'Tractor Steer ability' , sequence = 5 where parameters = 'tractor_steer_ability';
update fw_ods.fw_ods_observations set parameters = 'Tractor braking performance' , sequence = 6 where parameters = 'tractor_braking_perf';
update fw_ods.fw_ods_observations set parameters = 'Front Visibility' , sequence = 7 where parameters = 'front_visibility';
update fw_ods.fw_ods_observations set parameters = 'Implement Accessibility' , sequence = 8 where parameters = 'implement_accessibility';
update fw_ods.fw_ods_observations set parameters = 'Front Wheel dragging at turning' , sequence = 9 where parameters = 'front_wheel_dragging_at_turning';
update fw_ods.fw_ods_observations set parameters = 'Front end lifting during operation' , sequence = 10 where parameters = 'front_end_lifting_during_operation';
update fw_ods.fw_ods_observations set parameters = 'RPM Recovery Time' , sequence = 11 where parameters = 'rpm_recovery_time';
update fw_ods.fw_ods_observations set parameters = 'Engine Vibration' , sequence = 12 where parameters = 'engine_vibration';
update fw_ods.fw_ods_observations set parameters = 'Engine Sound' , sequence = 13 where parameters = 'engine_sound';
update fw_ods.fw_ods_observations set parameters = 'Implement Lifting/Lowering response ' , sequence = 14 where parameters = 'implement_lifting_per_lowering_response';
update fw_ods.fw_ods_observations set parameters = 'Pulverization Quality' , sequence = 15 where parameters = 'pulverization_quality';
update fw_ods.fw_ods_observations set parameters = 'Pulverization Index' , sequence = 16 where parameters = 'pulverization_index';
update fw_ods.fw_ods_observations set parameters = 'Tractor Model' , sequence = 17 where parameters = 'tractor_model';
update fw_ods.fw_ods_observations set parameters = 'Range Gear Shifting' , sequence = 18 where parameters = 'range_gear_shifting';
update fw_ods.fw_ods_observations set parameters = 'Speed Gear Shifting' , sequence = 19 where parameters = 'speed_gear_shifting';
DELETE FROM fw_ods.fw_ods_observations WHERE parameters IS null;
update fw_ods.fw_ods_observations set test_file_id = i.file_syspk where test_file_id is null;
update fw_ods.fw_ods_observations set test_iteration_number = i.test_iteration_number where test_file_id = __file_syspk and __file_syspk=i.file_syspk and test_iteration_number is null;
update fw_ods.fw_ods_observations c set
client_id=a.client_id,
function_id = a.function_id,
test_file_mnemonic = a.file_mnemonic,
test_sheet_mnemonic = a.file_sheet_mnemonic,
display_yn = 'Y'
from transactional.field_perf_summary a
where a.file_syspk = __file_syspk
and c.test_file_id =a.file_syspk;
--end if;
end loop;
--end loop;
for f in select distinct file_mnemonic from fw_core.fw_jobctl_file_runschedule
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed' and file_mnemonic like 'FT%'
for i in select distinct test_file_id, test_iteration_number from fw_ods.fw_ods_observations where test_file_mnemonic = 'FTHLG' and tractor_model is null
loop
insert into fw_ods.fw_ods_observations
(
client_id ,
function_id ,
test_file_mnemonic ,
test_sheet_mnemonic ,
test_file_id ,
test_file_name ,
test_iteration_number ,
--platform ,
--benchmark_yn ,
tractor_make ,
tractor_model ,
tractor_engine_hp ,
wheel_drive_type ,
name_of_implement ,
type_of_implement ,
season ,
engine_smoke_on_load,
engine_acceleration_smoke ,
range_gear_shifting ,
speed_gear_shifting ,
draft_response ,
tractor_steer_ability ,
tractor_braking_performance ,
front_visibility ,
implement_accessibility ,
front_wheel_dragging_at_turning ,
front_end_lifting_during_operation ,
rpm_recovery_time ,
engine_vibration ,
engine_sound ,
implement_lifing_lowering_response ,
pulverization_quality ,
pulverization_index
)
select
a.client_id ,
a.function_id ,
a.file_mnemonic,
a.file_sheet_mnemonic ,
b.file_syspk ,
a.test_file_name ,
b.test_iteration_number ,
--platform ,
--benchmark_yn ,
b.tractor_make ,
b.tractor_model ,
d.tractor_engine_hp ,
d.wheel_drive_type ,
c.name_of_implement ,
c.type_of_implement ,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',a.season) AS "Month Name",
b.engine_smoke_on_load,
b.engine_acceleration_smoke ,
b.range_gear_shifting ,
b.speed_gear_shifting ,
b.draft_response ,
b.tractor_steer_ability ,
b.tractor_braking_perf ,
b.front_visibility ,
b.implement_accessibility ,
b.front_wheel_dragging_at_turning ,
b.front_end_lifting_during_operation ,
b.rpm_recovery_time ,
b.engine_vibration ,
b.engine_sound ,
b.implement_lifting_per_lowering_response,
b.pulverization_quality ,
b.pulverization_index
from
transactional.test_instance a,
transactional.field_perf_summary b,
transactional.test_instance_implement_info c ,
transactional.test_instance_tractor_info d
where
a.file_syspk= b.file_syspk
and b.file_syspk = c.file_syspk
and c.file_syspk = d.file_syspk
and d.tractor_model = b.tractor_model
and a.file_mnemonic in ('FTDRY','FTWET')
and a.file_syspk = __file_syspk;
SELECT distinct num_nulls(value1,value2,value3,value4,value5) as nullcount
FROM fw_ods.fw_ods_observations
WHERE test_file_id= i.test_file_id and "sequence" = 1
and test_iteration_number = i.test_iteration_number
into null_count;
insert into fw_ods.fw_ods_observations
(
client_id ,
function_id ,
test_file_mnemonic ,
test_sheet_mnemonic ,
test_file_id ,
test_file_name ,
test_iteration_number ,
--platform ,
--benchmark_yn ,
tractor_make ,
tractor_model ,
tractor_engine_hp ,
wheel_drive_type ,
name_of_implement ,
type_of_implement ,
season ,
engine_smoke_on_load,
engine_acceleration_smoke ,
range_gear_shifting ,
speed_gear_shifting ,
draft_response ,
tractor_steer_ability ,
tractor_braking_performance ,
front_visibility ,
implement_accessibility ,
front_wheel_dragging_at_turning ,
front_end_lifting_during_operation ,
rpm_recovery_time ,
engine_vibration ,
engine_sound ,
implement_lifing_lowering_response ,
pulverization_quality ,
pulverization_index
)
select
a.client_id ,
a.function_id ,
a.file_mnemonic,
a.file_sheet_mnemonic ,
b.file_syspk ,
a.test_file_name ,
b.test_iteration_number ,
--platform ,
--benchmark_yn ,
b.tractor_make ,
b.tractor_model ,
d.tractor_engine_hp ,
d.wheel_drive_type ,
'Trailer',
c.trailer_type ,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
b.engine_smoke_on_load,
b.engine_acceleration_smoke ,
b.range_gear_shifting ,
b.speed_gear_shifting ,
b.draft_response ,
b.tractor_steer_ability ,
b.tractor_braking_perf ,
b.front_visibility ,
b.implement_accessibility ,
b.front_wheel_dragging_at_turning ,
b.front_end_lifting_during_operation ,
b.rpm_recovery_time ,
b.engine_vibration ,
b.engine_sound ,
b.implement_lifting_per_lowering_response,
b.pulverization_quality ,
b.pulverization_index
from
transactional.test_instance a,
transactional.field_perf_summary b,
transactional.field_perf_summary_trailer_info c ,
transactional.test_instance_tractor_info d
where
a.file_syspk= b.file_syspk
and b.file_syspk = c.file_syspk
and c.file_syspk = d.file_syspk
and d.tractor_model = b.tractor_model
and a.file_mnemonic= 'FTHLG'
and a.file_syspk = __file_syspk;
-- for repeating
while counter <= (total_count-null_count.nullcount)
loop
insert into fw_ods.fw_ods_observations(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_file_name,
test_iteration_number,
tractor_model,
name_of_implement,
type_of_implement,
season,
test_date_year,
parameters,
"sequence",
value1,
value2,
value3,
value4,
value5,
display_yn,
created_by,
create_timestamp )
select
a.client_id,
a.function_id,
a.test_file_mnemonic,
a.test_sheet_mnemonic,
a.test_file_id,
b.test_file_name,
a.test_iteration_number,
(case
when counter = 1 then (select distinct value1 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
when counter = 2 then (select distinct value2 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
when counter = 3 then (select distinct value3 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
when counter = 4 then (select distinct value4 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
when counter = 5 then (select distinct value5 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
end),
'Trailer',
d.type_of_trailer,
concat(lpad(extract( month from b.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from b.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
extract( year from b.date_of_test),
a.parameters,
a."sequence",
a.value1,
a.value2,
a.value3,
a.value4,
a.value5,
a.display_yn,
current_user,
current_timestamp
from fw_ods.fw_ods_observations a,
transactional.test_instance b,
transactional.test_instance_trailer_info d
where
a.test_file_id = b.file_syspk
and a.test_file_id = d.file_syspk
and a.test_file_id = i.test_file_id
and a.test_iteration_number = i.test_iteration_number
and a.tractor_model is null;
update fw_ods.fw_ods_observations set tractor_engine_hp = e.tractor_engine_hp , wheel_drive_type=e.wheel_drive_type from transactional.test_instance_tractor_info e where fw_ods.fw_ods_observations.tractor_model= e.tractor_model and test_file_id = e.file_syspk ;
update fw_ods.fw_ods_observations
set tractor_make = x.tractor_make
from transactional.test_instance_tractor_info x
where fw_ods.fw_ods_observations.tractor_model =x.tractor_model and fw_ods.fw_ods_observations.test_file_id= x.file_syspk and fw_ods.fw_ods_observations.test_file_id= __file_syspk;
counter := counter + 1;
update fw_ods.fw_ods_observations a
set
gear_used = b.gear_used_on_straight_road
--speed_rpm = b.engine_rpm_set
from transactional.field_perf_summary b
where a.test_file_id = b.file_syspk
and a.tractor_model = b.tractor_model
and a.test_iteration_number = b.test_iteration_number
and a.test_file_mnemonic = b.file_mnemonic
and a.test_sheet_mnemonic = b.file_sheet_mnemonic
and b.file_mnemonic in ('FTHLG')
and a.test_iteration_number = i.test_iteration_number
and b.file_syspk = i.test_file_id;
end loop;
counter :=1;
end loop;
for i in select distinct test_file_id, test_iteration_number from fw_ods.fw_ods_observations where test_file_mnemonic = 'FTWET' and tractor_model is null
loop
SELECT distinct num_nulls(value1,value2,value3,value4,value5) as nullcount
FROM fw_ods.fw_ods_observations
WHERE test_file_id= i.test_file_id and "sequence" = 1
and test_iteration_number = i.test_iteration_number
into null_count;
-- for repeating
while counter <= (total_count-null_count.nullcount)
loop
insert into fw_ods.fw_ods_observations(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_file_name,
test_iteration_number,
tractor_model,
name_of_implement,
type_of_implement,
season,
test_date_year,
parameters,
"sequence",
value1,
value2,
value3,
value4,
value5,
display_yn,
created_by,
create_timestamp )
select
a.client_id,
a.function_id,
a.test_file_mnemonic,
a.test_sheet_mnemonic,
a.test_file_id,
b.test_file_name,
a.test_iteration_number,
(case
when counter = 1 then (select distinct value1 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
when counter = 2 then (select distinct value2 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
when counter = 3 then (select distinct value3 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
when counter = 4 then (select distinct value4 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
when counter = 5 then (select distinct value5 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
end),
end loop;
d.name_of_implement,
d.type_of_implement,
concat(lpad(extract( month from b.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from b.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
extract( year from b.date_of_test),
a.parameters,
a."sequence",
a.value1,
a.value2,
a.value3,
a.value4,
a.value5,
a.display_yn,
current_user,
current_timestamp
from fw_ods.fw_ods_observations a,
transactional.test_instance b,
transactional.test_instance_implement_info d
where
a.test_file_id = b.file_syspk
and a.test_file_id = i.test_file_id
-- and a.test_file_id = null_count.test_file_id
and a.test_file_id = d.file_syspk
and a.test_iteration_number = i.test_iteration_number
and a.tractor_model is null;
update fw_ods.fw_ods_observations set tractor_engine_hp = e.tractor_engine_hp , wheel_drive_type=e.wheel_drive_type from transactional.test_instance_tractor_info e where fw_ods.fw_ods_observations.tractor_model= e.tractor_model and test_file_id = e.file_syspk ;
update fw_ods.fw_ods_observations
set tractor_make = x.tractor_make
from transactional.test_instance_tractor_info x
where fw_ods.fw_ods_observations.tractor_model =x.tractor_model and fw_ods.fw_ods_observations.test_file_id= x.file_syspk and fw_ods.fw_ods_observations.test_file_id= __file_syspk;
update fw_ods.fw_ods_observations a
set
gear_used = b.gear_used,
speed_rpm = b.engine_rpm_set
from transactional.field_perf_summary b
where a.test_file_id = b.file_syspk
and a.tractor_model = b.tractor_model
and a.test_iteration_number = b.test_iteration_number
and a.test_file_mnemonic = b.file_mnemonic
and a.test_sheet_mnemonic = b.file_sheet_mnemonic
and b.file_mnemonic in ('FTDRY', 'FTWET')
and a.test_iteration_number = i.test_iteration_number
and b.file_syspk = i.test_file_id;
counter := counter + 1;
end loop;
counter :=1;
end loop;
for i in select distinct test_file_id, test_iteration_number from fw_ods.fw_ods_observations where test_file_mnemonic = 'FTDRY' and tractor_model is null
loop
SELECT distinct num_nulls(value1,value2,value3,value4,value5) as nullcount
FROM fw_ods.fw_ods_observations
WHERE test_file_id= i.test_file_id and "sequence" = 1
and test_iteration_number = i.test_iteration_number
into null_count;
-- for repeating
while counter <= (total_count-null_count.nullcount)
loop
insert into fw_ods.fw_ods_observations(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_file_name,
test_iteration_number,
tractor_model,
name_of_implement,
type_of_implement,
season,
test_date_year,
parameters,
"sequence",
value1,
value2,
value3,
value4,
value5,
display_yn,
created_by,
create_timestamp )
select
a.client_id,
a.function_id,
a.test_file_mnemonic,
a.test_sheet_mnemonic,
a.test_file_id,
b.test_file_name,
a.test_iteration_number,
(case
when counter = 1 then (select distinct value1 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
when counter = 2 then (select distinct value2 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
when counter = 3 then (select distinct value3 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
when counter = 4 then (select distinct value4 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
when counter = 5 then (select distinct value5 from fw_ods.fw_ods_observations WHERE "sequence" = 1 and test_file_id=i.test_file_id and test_iteration_number = i.test_iteration_number )
end),
d.name_of_implement,
d.type_of_implement,
concat(lpad(extract( month from b.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from b.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
extract( year from b.date_of_test),
a.parameters,
a."sequence",
a.value1,
a.value2,
a.value3,
a.value4,
a.value5,
a.display_yn,
current_user,
current_timestamp
from fw_ods.fw_ods_observations a,
transactional.test_instance b,
transactional.test_instance_implement_info d
where
a.test_file_id = b.file_syspk
and a.test_file_id = i.test_file_id
-- and a.test_file_id = null_count.test_file_id
and a.test_file_id = d.file_syspk
and a.test_iteration_number = i.test_iteration_number
and a.tractor_model is null;
update fw_ods.fw_ods_observations set tractor_engine_hp = e.tractor_engine_hp , wheel_drive_type=e.wheel_drive_type from transactional.test_instance_tractor_info e where fw_ods.fw_ods_observations.tractor_model= e.tractor_model and test_file_id = e.file_syspk ;
update fw_ods.fw_ods_observations
set tractor_make = x.tractor_make
from transactional.test_instance_tractor_info x
where fw_ods.fw_ods_observations.tractor_model =x.tractor_model and fw_ods.fw_ods_observations.test_file_id= x.file_syspk and fw_ods.fw_ods_observations.test_file_id= __file_syspk;
counter := counter + 1;
update fw_ods.fw_ods_observations a
set
gear_used = b.gear_used,
speed_rpm = b.engine_rpm_set
from transactional.field_perf_summary b
where a.test_file_id = b.file_syspk
and a.tractor_model = b.tractor_model
and a.test_iteration_number = b.test_iteration_number
and a.test_file_mnemonic = b.file_mnemonic
and a.test_sheet_mnemonic = b.file_sheet_mnemonic
and b.file_mnemonic in ('FTDRY', 'FTWET')
and a.test_iteration_number = i.test_iteration_number
and b.file_syspk = i.test_file_id;
end loop;
counter :=1;
end loop;
delete from fw_ods.fw_ods_observations where tractor_model is null;
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_observations_load', err_state, err_msg, err_detail, err_hint, err_context,'success');
/*
EXCEPTION when OTHERS then
@@ -209,6 +432,7 @@ EXCEPTION when OTHERS then
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_observations_load', err_state, err_msg, err_detail, err_hint, err_context,'error');
*/
end
$$ LANGUAGE plpgsql;
$$ LANGUAGE plpgsql;

View File

@@ -20,7 +20,7 @@ AS $$
begin
-- Adding data to file fw_ods_field:
for f in select distinct file_mnemonic from fw_core.fw_jobctl_file_runschedule
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed'
where latest_runschedule_flag = '1' and end_status = 'success' and end_status_note = 'TRX_completed' and file_syspk = __file_syspk
loop
if f.file_mnemonic LIKE 'PTO%'
then
@@ -272,6 +272,7 @@ then
engine_speed_var,
power_hp,
torque_kg_m,
sfc_gms_per_hp_hr,
fuelling_mm3_per_stroke_per_cyl
-- audit fields
-- validate how it is being done
@@ -315,6 +316,7 @@ then
a.power_hp,
-- test specific measures
a.torque_kg_m,
a.sfc_gm_per_hp_hr,
a.fuelling_mm3_per_stroke_per_cyl
-- add user and timestamp fields
from transactional.pto_perf_governing_graph a, transactional.test_instance_tractor_info b,transactional.test_instance d
@@ -343,7 +345,7 @@ then
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_pto_load', err_state, err_msg, err_detail, err_hint, err_context,'success');
/*
EXCEPTION when OTHERS then
@@ -358,7 +360,7 @@ EXCEPTION when OTHERS then
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_pto_load', err_state, err_msg, err_detail, err_hint, err_context,'error');
*/
end
$$
LANGUAGE plpgsql;

View File

@@ -0,0 +1,198 @@
CREATE OR REPLACE FUNCTION fw_ods.fn_fw_ods_pto_observations_load(p_client_id int,p_function_id int, p_file_mnemonic text,
p_file_sheet_mnemonic text, p_file_syspk int)
RETURNS void
AS $$
declare
f record;
declare __client_id int :=p_client_id;
declare __function_id int :=p_function_id;
declare __file_mnemonic text :=p_file_mnemonic;
declare __file_sheet_mnemonic text :=p_file_sheet_mnemonic;
declare __file_syspk int :=p_file_syspk;
declare err_state text;
declare err_msg text;
declare err_detail text;
declare err_hint text;
declare err_context text;
declare _error int;
begin
insert into fw_ods.fw_ods_observations(
client_id,
function_id,
test_file_mnemonic,
test_sheet_mnemonic,
test_file_id,
test_file_name,
--platform,
--benchmark_yn,
tractor_make,
tractor_model,
tractor_engine_hp,
wheel_drive_type,
configuration,
season,
test_date_year,
sequence,
parameters,
value1,
value2,
--display_yn,
created_by,
updated_by,
create_timestamp,
update_timestamp
)
select
a.client_id,
a.function_Id,
a.file_mnemonic,
a.file_sheet_mnemonic,
a.file_syspk,
a.test_file_name,
b.tractor_make,
b.tractor_model,
b.tractor_engine_hp,
b.wheel_drive_type,
b.configuration,
concat(lpad(extract( month from a.date_of_test)::text,2,'0'),'-',(TO_CHAR(
TO_DATE (extract( month from a.date_of_test)::text, 'MM'), 'Month'
))) AS "Month Name",
extract( year from a.date_of_test),
unnest(Array[
'1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30']::int[]),
unnest(Array[
'Tractor Serial Number',
'Tractor Emission',
'Test Standard',
'Test mode',
'PTO Gear Ratio',
'Specific Gravity of Fuel (kg/m3)',
'PTO Power (hp)',
'PTO Power (kw)',
'PTO SFC (gm/hp.hr)',
'PTO SFC (Kg/kw.hr)',
'% of Backup Torque',
'Max Equ Crankshaft Torque (Nm)',
'Equ Crankshaft Torque at Maximun Power (Nm)',
'Engine Speed at Max Equivalent Crankshaft Torque (rpm)',
'Rated Engine Speed',
'Max Torque Engine Speed',
'Engine High Idle Speed',
'Engine Low Idle Speed',
'Engine Oil Temp (degree-c)@NA',
'Coolant Temp (degree-c)@NA',
'Engine Oil Temp(degree-c)@HA',
'Coolant Temp (degree-c)HA',
'Ambient Pressure (Bar)',
'Ambient Pressure (mm of hg)',
'Back Pressure (Bar)',
'Back Pressure (mm of hg)',
'Engine Oil Pressure (bar)',
'Exhaust Temperature (c)',
'Relative Humidity %',
'Coolant (water) (% of total coolant capacity)'
]) as parameters,
unnest(Array[
c.tractor_serial_number::text,
c.tractor_emission::text,
c.test_standard::text,
c.test_mode::text,
c.pto_gear_ratio::text,
c.specific_gravity_of_fuel_kg_per_m3::text,
c.pto_power_declared_hp::text,
c.pto_power_declared_kw::text,
c.pto_sfc_declared_gm_per_hp_hr::text,
c.pto_sfc_declared_kg_per_kw_hr::text,
c.pct_of_backup_torque_declared::text,
c.max_equ_crankshaft_torque_declared_nm::text,
c.equ_crankshaft_torque_at_max_power_declared_nm::text,
c.engine_speed_at_max_equ_crankshaft_torque_declared_rpm::text,
c.rated_engine_speed_declared_rpm::text,
c.max_torque_engine_speed_declared_rpm::text,
c.engine_high_idle_speed_declared_rpm::text,
c.engine_low_idle_speed_declared_rpm::text,
c.engine_oil_temp_at_na_declared_c::text,
c.coolant_temp_at_na_declared_c::text,
c.engine_oil_temp_at_ha_declared_c::text,
c.coolant_temp_at_ha_declared_c::text,
c.ambient_pressure_declared_bar::text,
c.ambient_pressure_declared_mm_of_hg::text,
c.back_pressure_declared_bar::text,
c.back_pressure_declared_mm_of_hg::text,
c.engine_oil_pressure_declared_bar::text,
c.exhaust_temp_declared_c::text,
c.relative_humidity_declared_pct::text,
c.coolant_water_pct_of_total_coolant_capacity_declared::text
]) as value1,
unnest(Array[
null,
null,
null,
null,
null,
null,
c.pto_power_observed_hp::text,
c.pto_power_observed_kw::text,
c.pto_sfc_observed_gm_per_hp_hr::text,
c.pto_sfc_observed_kg_per_kw_hr::text,
c.pct_of_backup_torque_observed::text,
c.max_equ_crankshaft_torque_observed_nm::text,
c.equ_crankshaft_torque_at_max_power_observed_nm::text,
c.engine_speed_at_max_equ_crankshaft_torque_observed_rpm::text,
c.rated_engine_speed_observed_rpm::text,
c.max_torque_engine_speed_observed_rpm::text,
c.engine_high_idle_speed_observed_rpm::text,
c.engine_low_idle_speed_observed_rpm::text,
c.engine_oil_temp_at_na_observed_c::text,
c.coolant_temp_at_na_observed_c::text,
c.engine_oil_temp_at_ha_observed_c::text,
c.coolant_temp_at_ha_observed_c::text,
c.ambient_pressure_observed_bar::text,
c.ambient_pressure_observed_mm_of_hg::text,
c.back_pressure_observed_bar::text,
c.back_pressure_observed_mm_of_hg::text,
c.engine_oil_pressure_observed_bar::text,
c.exhaust_temp_observed_c::text,
c.relative_humidity_observed_pct::text,
c.coolant_water_pct_of_total_coolant_capacity_observed::text
]) as value2,
current_user,
current_user,
current_timestamp,
current_timestamp
from
transactional.test_instance a,
transactional.test_instance_tractor_info b,
transactional.pto_key_perf_parameters c
where
a.file_syspk = b.file_syspk
and b.file_syspk = c.file_syspk
and a.file_mnemonic = b.file_mnemonic
and a.file_mnemonic = c.file_mnemonic
and a.file_sheet_mnemonic = b.file_sheet_mnemonic
and a.file_sheet_mnemonic = c.file_sheet_mnemonic
and b.tractor_model = c.tractor_model
and a.file_syspk =__file_syspk;
err_context :='';
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_comments_load', err_state, err_msg, err_detail, err_hint, err_context,'success');
/*
EXCEPTION when OTHERS then
err_state = returned_sqlstate, /* P0002 */
err_msg = message_text, /* No Data in FTDRY */
err_detail = pg_exception_detail, /* No data in table t_test_new */
err_hint = pg_exception_hint, /* No data error capture */
err_context = pg_exception_context; /* PL/pgSQL function staging2.fn_ftdry_trs_block(integer,integer,text,text,integer) line 69 at RAISE*/
perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compegence', __file_syspk ,__file_mnemonic,__file_sheet_mnemonic ,null,'ods', 'fn_fw_ods_comments_load', err_state, err_msg, err_detail, err_hint, err_context,'error');
*/
end
$$
LANGUAGE plpgsql;

0
onetime/dataloadfunctions/PTO/PTO_GVG_ods.sql Normal file → Executable file
View File

0
onetime/dataloadfunctions/PTO/PTO_GVG_stg2.sql Normal file → Executable file
View File

View File

@@ -1,5 +1,4 @@
drop function if exists staging2.fn_BUDNI_NMT_Block ;
CREATE OR REPLACE FUNCTION staging2.fn_BUDNI_NMT_Block(p_client_id int,p_function_id int, p_file_mnemonic text,p_file_sheet_mnemonic text, p_file_syspk int)
CREATE OR REPLACE FUNCTION staging2.fn_budni_nmt_block(p_client_id integer, p_function_id integer, p_file_mnemonic text, p_file_sheet_mnemonic text, p_file_syspk integer)
RETURNS void
LANGUAGE plpgsql
AS $function$
@@ -125,7 +124,6 @@ order by a.row_number';
execute 'insert into staging2.stg_process_table_BUDNI_NMT
select a.* , RANK () OVER ( ORDER BY row_number) as block_row_number,b.block_tag as block_tag
from staging2.stg_specific_table_BUDNI_NMT a
@@ -197,7 +195,7 @@ and b.block_row_number=5
and a.file_syspk=b.file_syspk;
perform fw_core.fn_jobctl_block_end(__file_syspk,'BUDNI_NMT_Spec_H1_Block');
perform fw_core.fn_jobctl_block_end(__file_syspk,'BUDNI_NMT_Spec_H1_block');
/* blocks data loading - BUDNI_NMT_noise_at_bystander_position_block */
@@ -216,7 +214,6 @@ column8,column9,block_row_number
from staging2.stg_process_table_BUDNI_NMT a
where block_tag ='BUDNI_NMT_Noise_at_bystanders_position';
update staging2.BUDNI_NMT_noise_at_bystander_position_block
set column2=column3 where block_row_number=1;
@@ -277,7 +274,7 @@ update staging2.BUDNI_NMT_Atmos_Cond_1_Block
set trx_record=0 where
block_row_number in (1,2,3);
perform fw_core.fn_jobctl_block_end(__file_syspk,'BUDNI_NMT_Atmos_Cond_1_Block ');
perform fw_core.fn_jobctl_block_end(__file_syspk,'BUDNI_NMT_Atmos_Cond_1_Block');
@@ -315,7 +312,7 @@ file_syspk='||p_file_syspk||',
file_mnemonic='''||p_file_mnemonic||''',
file_sheet_mnemonic='''||p_file_sheet_mnemonic||'''';
perform fw_core.fn_jobctl_block_end(__file_syspk,'BUDNI_NMT_Meas_Results_1_Block ');
perform fw_core.fn_jobctl_block_end(__file_syspk,'BUDNI_NMT_Meas_Results_1_Block');
/* blocks data loading - BUDNI_NMT_Noise_at_operator_ear_level_block */
@@ -462,8 +459,3 @@ perform fw_core.fn_insert_db_error ( __client_id, __function_id, 1001, 'Compege
end
$function$
;

View File

@@ -155,9 +155,9 @@ depth_of_cut_cm,
fuel_consumption_lit_per_hr,
area_covered_acr_per_hr,
fuel_consumption_lit_per_acr,
fuel_consumption_var_lit_per_hr,
area_covered_var_acr_per_hr,
fuel_consumption_var_lit_per_acr,
fuel_consumption_var_pct_lit_per_hr,
area_covered_var_pct_acr_per_hr,
fuel_consumption_var_pct_lit_per_acr,
Engine_Smoke_on_Load,
Engine_acceleration_smoke,
Draft_Response,
@@ -199,9 +199,9 @@ Avg_Depth_of_cut_cm depth_of_cut_cm ,
Fuel_consumption_lit_hr::numeric fuel_consumption_lit_per_hr,
Area_covered_acr_hr::numeric area_covered_acr_per_hr,
Fuel_consumption_lit_Acr::numeric fuel_consumption_lit_per_acr,
case when fuel_consumption_lit_hr_2 ~ E'^\\d+$' then fuel_consumption_lit_hr_2::numeric else null end as fuel_consumption_var_lit_per_hr ,
case when area_covered_acr_hr_2 ~ E'^\\d+$' then area_covered_acr_hr_2::numeric else null end as area_covered_var_acr_per_hr ,
case when fuel_consumption_lit_acr_2 ~ E'^\\d+$' then fuel_consumption_lit_acr_2::numeric else null end as fuel_consumption_var_lit_per_acr,
fuel_consumption_lit_hr_2::numeric as fuel_consumption_var_lit_per_hr ,
area_covered_acr_hr_2::numeric as area_covered_var_acr_per_hr ,
fuel_consumption_lit_acr_2::numeric as fuel_consumption_var_lit_per_acr,
Engine_Smoke_on_Load,
Engine_acceleration_smoke,
Draft_Response,