added deployment folder with latest code
This commit is contained in:
408
deployment-20210427T103328Z-001/deployment/IHT/IHT_BRT_ODS.SQL
Normal file
408
deployment-20210427T103328Z-001/deployment/IHT/IHT_BRT_ODS.SQL
Normal file
@@ -0,0 +1,408 @@
|
||||
drop function if exists mmt_staging2.fn_IHT_BRT_ODS;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_IHT_BRT_ODS()
|
||||
RETURNS void AS $$
|
||||
declare __test_instance_id int;
|
||||
declare __brake_perf_test_condition_id int;
|
||||
declare __file_syspk int;
|
||||
declare __model text;
|
||||
declare __make text;
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHT_BRT_ODS
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHT
|
||||
Sheet Format: IHT_BRT
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select mmt_staging2.fn_IHT_BRT_ODS()
|
||||
***************************************************************/
|
||||
delete from mmt_ods.test_instance where test_file_sheet_format='IHT_BRT';
|
||||
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='IHT_BRT';
|
||||
delete from mmt_ods.test_instance_drawbar_info where test_file_sheet_format='IHT_BRT';
|
||||
delete from mmt_ods.test_instance_weight_reaction where test_file_sheet_format='IHT_BRT';
|
||||
delete from mmt_ods.test_instance_tyre_info where test_file_sheet_format='IHT_BRT';
|
||||
delete from mmt_ods.iht_brake_perf_test_condition where test_file_sheet_format='IHT_BRT';
|
||||
delete from mmt_ods.iht_brake_perf_test_results where test_file_sheet_format='IHT_BRT';
|
||||
|
||||
|
||||
|
||||
insert into mmt_ods.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
job_order_no,
|
||||
sample_receipt_date,
|
||||
test_report_no,
|
||||
generation,
|
||||
customer_name,
|
||||
test_engineer,
|
||||
test_report_date,
|
||||
no_of_sample,
|
||||
test_start_date,
|
||||
test_end_date,
|
||||
tractor_sr_no,
|
||||
test_standard_ref,
|
||||
test_location_name,
|
||||
test_operator,
|
||||
project_group,
|
||||
objective_of_test,
|
||||
test_condition,
|
||||
test_standard_desc,
|
||||
test_standard_id,
|
||||
acceptance_criteria,
|
||||
remarks,
|
||||
observations
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
Test_Request_no,
|
||||
to_date(sample_receipt_date,'DD-MM-YYYY'),
|
||||
Test_report_No,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
to_date(Test_Report_Date,'DD-MM-YYYY'),
|
||||
No_of_Sample,
|
||||
to_date(Test_Start_Date,'DD-MM-YYYY'),
|
||||
to_date(Test_End_Date, 'DD-MM-YYYY'),
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
test_location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
condition,
|
||||
test_standard,
|
||||
test_standard_id::numeric,
|
||||
acceptance_criteria,
|
||||
remarks,
|
||||
observations
|
||||
from
|
||||
mmt_staging2.IHT_BRT_H1_block;
|
||||
|
||||
update mmt_ods.test_instance a
|
||||
set
|
||||
report_prepared_date=to_date(b.prepared_date,'DD-MM-YYYY'),
|
||||
report_reviewed_date=to_date(b.reviewed_date,'DD-MM-YYYY'),
|
||||
report_approved_date=to_date(b.approved_date,'DD-MM-YYYY'),
|
||||
report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from mmt_staging2.IHT_BRT_footer_block b
|
||||
where a.test_file_sheet_format='IHT_BRT';
|
||||
|
||||
|
||||
|
||||
insert into mmt_ods.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_use_type,
|
||||
tyre_pressure_kg_per_cm2
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric,
|
||||
tyre_use_type,
|
||||
pressure_kg_cm2::numeric
|
||||
from mmt_staging2.IHT_BRT_tyre_details_block;
|
||||
|
||||
|
||||
|
||||
insert into mmt_ods.test_instance_drawbar_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
weight_front_kg,
|
||||
weight_rear_kg,
|
||||
weight_total_kg,
|
||||
status
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
test_condition,
|
||||
front::numeric ,
|
||||
rear::numeric ,
|
||||
total::numeric ,
|
||||
status
|
||||
from mmt_staging2.IHT_BRT_weight_block;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into mmt_ods.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tractor_platform
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
platform
|
||||
from mmt_staging2.iht_brt_h1_block;
|
||||
|
||||
insert into mmt_ods.iht_brake_perf_test_condition
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
date_of_test,
|
||||
time_of_test,
|
||||
location_name,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column3::date,
|
||||
column8,
|
||||
column6,
|
||||
column10
|
||||
from mmt_staging2.iht_brt_test_res_block where rank =1;
|
||||
|
||||
insert into mmt_ods.iht_brake_perf_test_condition
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
date_of_test,
|
||||
time_of_test,
|
||||
location_name,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column3::date,
|
||||
column6,
|
||||
column8,
|
||||
column10
|
||||
from mmt_staging2.iht_brt_test_res_block where rank =16;
|
||||
|
||||
insert into mmt_ods.iht_brake_perf_test_condition
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
date_of_test,
|
||||
location_name,
|
||||
time_of_test,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column3::date,
|
||||
column6,
|
||||
column8,
|
||||
column10
|
||||
from mmt_staging2.iht_brt_test_res_1_block where rank =1;
|
||||
|
||||
|
||||
insert into mmt_ods.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_mode,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
wind_velocity_kmph,
|
||||
ambient_temp_c,
|
||||
humidity_rh_pct,
|
||||
observation
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column10::numeric,
|
||||
column11::numeric,
|
||||
column12
|
||||
from mmt_staging2.iht_brt_test_res_block where ods_record =1;
|
||||
|
||||
insert into mmt_ods.iht_brake_perf_test_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_mode,
|
||||
srl_no,
|
||||
trigger_speed_km_per_h,
|
||||
brake_control_input_force_kg,
|
||||
required_corrected_stopping_distance_m,
|
||||
actual_stopping_distance_m,
|
||||
deceleration_m_s2_v2_2s,
|
||||
wind_velocity_kmph,
|
||||
ambient_temp_c,
|
||||
humidity_rh_pct,
|
||||
observation
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9,
|
||||
column10::numeric,
|
||||
column11::numeric,
|
||||
column12
|
||||
from mmt_staging2.iht_brt_test_res_1_block where column3 is not null and column4 is not null and ods_record =1;
|
||||
|
||||
update mmt_ods.iht_brake_perf_test_results a
|
||||
set brake_perf_test_condition_id=(select syspk
|
||||
from mmt_ods.iht_brake_perf_test_condition b
|
||||
where a.test_mode =b.test_mode);
|
||||
|
||||
select file_syspk into __file_syspk from mmt_staging2.IHT_BRT_H1_block;
|
||||
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_model into __model from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_make into __make from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.test_instance_drawbar_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_brake_perf_test_condition
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_brake_perf_test_results
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
|
||||
784
deployment-20210427T103328Z-001/deployment/IHT/IHT_BRT_STG2.sql
Normal file
784
deployment-20210427T103328Z-001/deployment/IHT/IHT_BRT_STG2.sql
Normal file
@@ -0,0 +1,784 @@
|
||||
drop function if exists mmt_staging2.fn_IHT_BRT_block;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_IHT_BRT_block(p_client_id int,p_function_id int, p_file_format text,
|
||||
p_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS text AS $$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_format text :=p_file_format;
|
||||
declare __sheet_mnemonic text :=p_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare v_state text;
|
||||
declare v_msg text;
|
||||
declare v_detail text;
|
||||
declare v_hint text;
|
||||
declare v_context text;
|
||||
declare _error int;
|
||||
declare v_block text;
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHT_BRT_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHT
|
||||
Sheet Format: IHT_BRT
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select mmt_staging2.fn_IHT_BRT_block(p_client_id,p_function_id, p_file_format,
|
||||
p_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select mmt_staging2.fn_IHT_BRT_block(1,2,'IHT','IHT_BRT',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO mmt_staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table mmt_staging2.IHT_BRT_H1_Int;
|
||||
truncate table mmt_staging2.IHT_BRT_H1_block;
|
||||
truncate table mmt_staging2.IHT_BRT_Weight_Tyre_Int;
|
||||
truncate table mmt_staging2.IHT_BRT_Weight_Block;
|
||||
truncate table mmt_staging2.IHT_BRT_Tyre_Details_Block;
|
||||
truncate table mmt_staging2.IHT_BRT_Test_Res_Block;
|
||||
truncate table mmt_staging2.IHT_BRT_Test_Res_1_Block;
|
||||
truncate table mmt_staging2.IHT_BRT_Footer_Block;
|
||||
truncate table mmt_staging2.stg_specific_table_IHT_BRT;
|
||||
truncate table mmt_staging2.stg_process_table_IHT_BRT;
|
||||
|
||||
|
||||
execute 'delete from mmt_ods.fw_jobctrl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHT */
|
||||
execute 'insert into mmt_staging2.stg_specific_table_IHT_BRT
|
||||
select * from mmt_staging1.mmt_staging_generic_table a
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
|
||||
/* trimming data */
|
||||
update mmt_staging2.stg_specific_table_IHT_BRT
|
||||
set column11='Objective' where column11 like 'Objective%';
|
||||
|
||||
update mmt_staging2.stg_specific_table_IHT_BRT
|
||||
set column10='Acceptance criteria' where column10 like 'Acceptance criteria%';
|
||||
|
||||
|
||||
update mmt_staging2.stg_specific_table_IHT_BRT
|
||||
set column11='Condition' where column11 like 'Condition%';
|
||||
|
||||
|
||||
update mmt_staging2.stg_specific_table_IHT_BRT set column3 = TRIM (TRAILING FROM column3 );
|
||||
update mmt_staging2.stg_specific_table_IHT_BRT set column3 = TRIM (LEADING FROM column3 );
|
||||
|
||||
update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ;
|
||||
update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ;
|
||||
update mmt_ods.mmt_config set F1_source=F1_modified ;
|
||||
update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source);
|
||||
update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source);
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from mmt_staging2.stg_specific_table_IHT_BRT b
|
||||
where trim(upper(F1_modified))=trim(upper(column3))
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update mmt_staging2.stg_specific_table_IHT_BRT a
|
||||
set is_rownumber_fetched=1
|
||||
from mmt_ods.mmt_config b
|
||||
where trim(upper(F1_modified))=trim(upper(column3))
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from mmt_ods.mmt_config b
|
||||
where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' )
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Prepared by''
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging ranks*/
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_BRT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_BRT a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request No''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_BRT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_BRT a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Date- 21-FEB-2021''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_BRT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_BRT a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Date- 04-July-2019''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_BRT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_BRT a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Weight (kg)''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_BRT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_BRT a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Remarks:''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model*/
|
||||
select column5 into __model from mmt_staging2.stg_process_table_IHT_BRT a
|
||||
where rank_tag='IHT_BRT_H1' and trim(column3)='Tractor Model';
|
||||
|
||||
/*block starts - IHT_BRT_H1_BLOCK */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_BRT_H1_BLOCK',__file_format,__sheet_mnemonic,1);
|
||||
v_block:='IHT_BRT_H1_BLOCK';
|
||||
insert into mmt_staging2.IHT_BRT_H1_INT (c1,c2)
|
||||
select a.column3,column5 from mmt_staging2.stg_process_table_IHT_BRT a where rank_tag='IHT_BRT_H1'
|
||||
and rank <=9;
|
||||
|
||||
insert into mmt_staging2.IHT_BRT_H1_INT (c1,c2)
|
||||
select a.column7,column9 from mmt_staging2.stg_process_table_IHT_BRT a where rank_tag='IHT_BRT_H1'
|
||||
and rank <=9;
|
||||
|
||||
insert into mmt_staging2.IHT_BRT_H1_INT (c1,c2)
|
||||
select 'Objective',column11
|
||||
from mmt_staging2.stg_process_table_IHT_BRT a
|
||||
where rank_tag='IHT_BRT_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
mmt_staging2.stg_process_table_IHT_BRT a
|
||||
where column11='Objective'
|
||||
and rank_tag='IHT_BRT_H1'
|
||||
);
|
||||
|
||||
insert into mmt_staging2.IHT_BRT_H1_INT (c1,c2)
|
||||
select 'Acceptance criteria',column10
|
||||
from mmt_staging2.stg_process_table_IHT_BRT a
|
||||
where rank_tag='IHT_BRT_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
mmt_staging2.stg_process_table_IHT_BRT a
|
||||
where column10='Acceptance criteria'
|
||||
and rank_tag='IHT_BRT_H1'
|
||||
);
|
||||
|
||||
insert into mmt_staging2.IHT_BRT_H1_INT (c1,c2)
|
||||
select 'Condition',column11
|
||||
from mmt_staging2.stg_process_table_IHT_BRT a
|
||||
where rank_tag='IHT_BRT_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
mmt_staging2.stg_process_table_IHT_BRT a
|
||||
where column11='Condition'
|
||||
and rank_tag='IHT_BRT_H1'
|
||||
);
|
||||
|
||||
|
||||
insert into mmt_staging2.IHT_BRT_H1_INT (c1,c2)
|
||||
select 'Test std',column4
|
||||
from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.column3='Test std'
|
||||
and rank_tag='IHT_BRT_H1';
|
||||
|
||||
insert into mmt_staging2.IHT_BRT_H1_INT (c1,c2)
|
||||
select 'Test std Id',column9
|
||||
from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.column3='Test std'
|
||||
and rank_tag='IHT_BRT_H1';
|
||||
|
||||
insert into mmt_staging2.IHT_BRT_H1_INT (c1,c2)
|
||||
select split_part(column3,':',1),split_part(column3,':',2)
|
||||
from mmt_staging2.stg_process_table_IHT_BRT
|
||||
where rank_tag='IHT_BRT_Footer' and rank=1;
|
||||
|
||||
insert into mmt_staging2.IHT_BRT_H1_INT (c1,c2)
|
||||
select split_part(column3,':',1),split_part(column3,':',2)
|
||||
from mmt_staging2.stg_process_table_IHT_BRT
|
||||
where rank_tag='IHT_BRT_Footer' and rank=2;
|
||||
|
||||
update mmt_staging2.IHT_BRT_H1_Int set model=__model;
|
||||
execute 'update mmt_staging2.IHT_BRT_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
insert into mmt_staging2.IHT_BRT_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
Test_Location,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Domestic_Export,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Platform,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
condition,
|
||||
Test_Standard,
|
||||
Test_Standard_id,
|
||||
Remarks,
|
||||
Observations
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM mmt_staging2.IHT_BRT_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,
|
||||
a_18 text,a_19 text,a_20 text,a_21 text,a_22 text,a_23 text,a_24 text,a_25 text);
|
||||
|
||||
|
||||
delete from mmt_staging2.IHT_BRT_H1_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_BRT_H1_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_BRT_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_BRT_H1_Block');
|
||||
|
||||
|
||||
insert into mmt_staging2.IHT_BRT_Weight_Tyre_Int
|
||||
(
|
||||
column3,column4,column5,column6,column7,column8,column9,
|
||||
column10,column11,column12,rank
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,column8,
|
||||
column9,column10,column11,column12,rank
|
||||
from mmt_staging2.stg_process_table_IHT_BRT a
|
||||
where rank_tag='IHT_BRT_Weight_Tyre'
|
||||
order by rank;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Weight_Tyre_Int set model=__model;
|
||||
execute 'update mmt_staging2.IHT_BRT_Weight_Tyre_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
/*block starts - IHT_BRT_Weight_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_BRT_Weight_Block',__file_format,__sheet_mnemonic,2);
|
||||
v_block:='IHT_BRT_Weight_Block';
|
||||
insert into mmt_staging2.IHT_BRT_Weight_Block
|
||||
(
|
||||
dummy_f,
|
||||
test_condition,
|
||||
Front,
|
||||
Rear,
|
||||
Total
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column5,column7}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column5::text,column7::text]) AS val
|
||||
FROM mmt_staging2.IHT_BRT_Weight_Tyre_Int where rank <>1
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text);
|
||||
|
||||
update mmt_staging2.IHT_BRT_Weight_Block set status=
|
||||
(select column9 FROM mmt_staging2.IHT_BRT_Weight_Tyre_Int
|
||||
where rank=3) where test_condition='Unballast';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Weight_Block set status=
|
||||
(select column9 FROM mmt_staging2.IHT_BRT_Weight_Tyre_Int
|
||||
where rank=3) where test_condition='Max Ballast';
|
||||
|
||||
delete from mmt_staging2.IHT_BRT_Weight_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_BRT_Weight_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_BRT_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_BRT_Weight_Block');
|
||||
|
||||
/*block starts - IHT_BRT_Tyre_Details_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_BRT_Tyre_Details_Block',__file_format,__sheet_mnemonic,3);
|
||||
v_block:='IHT_BRT_Tyre_Details_Block';
|
||||
insert into mmt_staging2.IHT_BRT_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Pressure_kg_cm2,
|
||||
tyre_use_type,
|
||||
Tyre_Make
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column11,column12}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column11::text,column12::text]) AS val
|
||||
FROM mmt_staging2.IHT_BRT_Weight_Tyre_Int where column11 is not null and column12 is not null
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text);
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Tyre_Details_Block
|
||||
set tyre_size =(select split_part(Tyre_Make,'/ ',2)
|
||||
from mmt_staging2.IHT_BRT_Tyre_Details_Block where tyre_details ='Front ')
|
||||
where tyre_details ='Front ';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Tyre_Details_Block
|
||||
set ply_rating =(select split_part(replace(Tyre_Make,'PR',''),'/ ',3)
|
||||
from mmt_staging2.IHT_BRT_Tyre_Details_Block where tyre_details ='Front ')
|
||||
where tyre_details ='Front ';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Tyre_Details_Block
|
||||
set tyre_make =(select split_part(Tyre_Make,'/ ',1)
|
||||
from mmt_staging2.IHT_BRT_Tyre_Details_Block where tyre_details ='Front ')
|
||||
where tyre_details ='Front ';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Tyre_Details_Block
|
||||
set tyre_size =(select split_part(Tyre_Make,'/ ',2)
|
||||
from mmt_staging2.IHT_BRT_Tyre_Details_Block where tyre_details ='Rear')
|
||||
where tyre_details ='Rear';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Tyre_Details_Block
|
||||
set ply_rating =(select split_part(replace(Tyre_Make,'PR',''),'/',3)
|
||||
from mmt_staging2.IHT_BRT_Tyre_Details_Block where tyre_details ='Rear')
|
||||
where tyre_details ='Rear';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Tyre_Details_Block
|
||||
set tyre_make =(select split_part(Tyre_Make,'/ ',1)
|
||||
from mmt_staging2.IHT_BRT_Tyre_Details_Block where tyre_details ='Rear')
|
||||
where tyre_details ='Rear';
|
||||
|
||||
delete from mmt_staging2.IHT_BRT_Tyre_Details_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_BRT_Tyre_Details_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_BRT_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_BRT_Tyre_Details_Block');
|
||||
|
||||
|
||||
/*block starts - IHT_BRT_Test_Res_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_BRT_Test_Res_Block',__file_format,__sheet_mnemonic,4);
|
||||
v_block:='IHT_BRT_Test_Res_Block';
|
||||
insert into mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,rank
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,rank
|
||||
from mmt_staging2.stg_process_table_IHT_BRT a
|
||||
where rank_tag='IHT_BRT_Test_Res'
|
||||
order by rank;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
set column3 =(select split_part(column3,'- ',2)
|
||||
from mmt_staging2.IHT_BRT_Test_Res_Block where rank=1)
|
||||
where rank=1;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
set column6 =(select split_part(column6,'-',2)
|
||||
from mmt_staging2.IHT_BRT_Test_Res_Block where rank=1)
|
||||
where rank=1;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
set column8 =(select split_part(column8,'-',2)
|
||||
from mmt_staging2.IHT_BRT_Test_Res_Block where rank=1)
|
||||
where rank=1;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
set column3 =(select split_part(column3,'- ',2)
|
||||
from mmt_staging2.IHT_BRT_Test_Res_Block where rank=16)
|
||||
where rank=16;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
set column6 =(select split_part(column6,'- ',2)
|
||||
from mmt_staging2.IHT_BRT_Test_Res_Block where rank=16)
|
||||
where rank=16;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
set column8 =(select split_part(column8,'-',2)
|
||||
from mmt_staging2.IHT_BRT_Test_Res_Block where rank=16)
|
||||
where rank=16;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block a
|
||||
set column2=(select column10
|
||||
from mmt_staging2.IHT_BRT_Test_Res_Block where rank=1) where a.rank=3;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
rank,column2, value_partition, first_value(column2) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
ORDER BY rank ASC
|
||||
) as q) b where a.rank=b.rank and a.rank<=15;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block a
|
||||
set column9= b.first_value from (SELECT
|
||||
rank,column9, value_partition, first_value(column9) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
column9,
|
||||
sum(case when column9 is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
ORDER BY rank ASC
|
||||
) as q) b where a.rank=b.rank and a.rank >=3 and a.rank<=15;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
rank,column10, value_partition, first_value(column10) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
ORDER BY rank ASC
|
||||
) as q) b where a.rank=b.rank and a.rank >=3 and a.rank<=15;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block a
|
||||
set column11= b.first_value from (SELECT
|
||||
rank,column11, value_partition, first_value(column11) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
column11,
|
||||
sum(case when column11 is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
ORDER BY rank ASC
|
||||
) as q) b where a.rank=b.rank and a.rank >=3 and a.rank<=15;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
set column2=(select column10
|
||||
from mmt_staging2.IHT_BRT_Test_Res_Block where rank=16) where rank=18;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
rank,column2, value_partition, first_value(column2) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
ORDER BY rank ASC
|
||||
) as q) b where a.rank=b.rank and a.rank >=18;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block a
|
||||
set column9= b.first_value from (SELECT
|
||||
rank,column9, value_partition, first_value(column9) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
column9,
|
||||
sum(case when column9 is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
ORDER BY rank ASC
|
||||
) as q) b where a.rank=b.rank and a.rank >=18;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
rank,column10, value_partition, first_value(column10) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
ORDER BY rank ASC
|
||||
) as q) b where a.rank=b.rank and a.rank >=18;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block a
|
||||
set column11= b.first_value from (SELECT
|
||||
rank,column11, value_partition, first_value(column11) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
column11,
|
||||
sum(case when column11 is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.IHT_BRT_Test_Res_Block
|
||||
ORDER BY rank ASC
|
||||
) as q) b where a.rank=b.rank and a.rank >=18;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block set ods_record =0 where rank in (1,3,2,17,16,18);
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_BRT_Test_Res_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_BRT_Test_Res_Block');
|
||||
|
||||
|
||||
/*block starts - IHT_BRT_Test_Res_1_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_BRT_Test_Res_1_Block',__file_format,__sheet_mnemonic,5);
|
||||
v_block:='IHT_BRT_Test_Res_1_Block';
|
||||
insert into mmt_staging2.IHT_BRT_Test_Res_1_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,
|
||||
rank
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,column11,column12,
|
||||
rank
|
||||
from mmt_staging2.stg_process_table_IHT_BRT a
|
||||
where rank_tag='IHT_BRT_Test_Res_1'
|
||||
order by rank;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_1_Block
|
||||
set column3 =(select split_part(column3,'- ',2)
|
||||
from mmt_staging2.IHT_BRT_Test_Res_1_Block where rank=1)
|
||||
where rank=1;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_1_Block
|
||||
set column6 =(select split_part(column6,'-',2)
|
||||
from mmt_staging2.IHT_BRT_Test_Res_1_Block where rank=1)
|
||||
where rank=1;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_1_Block
|
||||
set column8 =(select split_part(column8,'-',2)
|
||||
from mmt_staging2.IHT_BRT_Test_Res_1_Block where rank=1)
|
||||
where rank=1;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_1_Block set ods_record =0 where rank in (1,2,3,13);
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_1_Block
|
||||
set column2=(select column10
|
||||
from mmt_staging2.IHT_BRT_Test_Res_1_Block where rank=1) where rank=3;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_1_Block a
|
||||
set column2= b.first_value from (SELECT
|
||||
rank,column2, value_partition, first_value(column2) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
column2,
|
||||
sum(case when column2 is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.IHT_BRT_Test_Res_1_Block
|
||||
ORDER BY rank ASC
|
||||
) as q) b where a.rank=b.rank and a.rank<=15;
|
||||
|
||||
update mmt_staging2.IHT_BRT_Test_Res_1_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_BRT_Test_Res_1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_BRT_Test_Res_1_Block');
|
||||
|
||||
/*block starts - IHT_BRT_Footer_block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_BRT_Footer_block',__file_format,__sheet_mnemonic,6);
|
||||
v_block:='IHT_BRT_Footer_block';
|
||||
|
||||
insert into mmt_staging2.IHT_BRT_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Footer_block a
|
||||
set prepared_by=( select column6 from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.rank_tag='IHT_BRT_Footer'
|
||||
and trim(column3)='Prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Footer_block a
|
||||
set reviewed_by=( select column6 from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.rank_tag='IHT_BRT_Footer'
|
||||
and trim(column3)='Reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Footer_block a
|
||||
set approved_by=( select column6 from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.rank_tag='IHT_BRT_Footer'
|
||||
and trim(column3)='Approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Footer_block a
|
||||
set comments=( select column3 from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.rank_tag='IHT_BRT_Footer'
|
||||
and rank=7 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Footer_block a
|
||||
set rev1=( select column3 from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.rank_tag='IHT_BRT_Footer'
|
||||
and rank=8 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_BRT_Footer_block a
|
||||
set rev2=( select column7 from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.rank_tag='IHT_BRT_Footer'
|
||||
and rank=8 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Footer_block a
|
||||
set rev3=( select column11 from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.rank_tag='IHT_BRT_Footer'
|
||||
and rank=8 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Footer_block a
|
||||
set replaces=( select column12 from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.rank_tag='IHT_BRT_Footer'
|
||||
and rank=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Footer_block a
|
||||
set revision_no=( select column12 from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.rank_tag='IHT_BRT_Footer'
|
||||
and rank=5)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Footer_block a
|
||||
set prepared_date=( select column11 from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.rank_tag='IHT_BRT_Footer'
|
||||
and rank=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Footer_block a
|
||||
set reviewed_date=( select column11 from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.rank_tag='IHT_BRT_Footer'
|
||||
and rank=4)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Footer_block a
|
||||
set approved_date=( select column11 from mmt_staging2.stg_process_table_IHT_BRT b
|
||||
where b.rank_tag='IHT_BRT_Footer'
|
||||
and rank=5)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_BRT_Footer_block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_BRT_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_BRT_Footer_block');
|
||||
|
||||
v_context := '';
|
||||
return v_context;
|
||||
EXCEPTION when OTHERS then
|
||||
|
||||
GET STACKED DIAGNOSTICS
|
||||
v_state = returned_sqlstate,
|
||||
v_msg = message_text,
|
||||
v_detail = pg_exception_detail,
|
||||
v_hint = pg_exception_hint,
|
||||
v_context = pg_exception_context;
|
||||
|
||||
perform mmt_insert_db_error ( __client_id, __function_id, 1001, 'Compegence',v_block,'stg2', 'test_db_error', v_state, v_msg, v_detail, v_hint, v_context);
|
||||
return v_context;
|
||||
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
305
deployment-20210427T103328Z-001/deployment/IHT/IHT_CGM_ODS.SQL
Normal file
305
deployment-20210427T103328Z-001/deployment/IHT/IHT_CGM_ODS.SQL
Normal file
@@ -0,0 +1,305 @@
|
||||
drop function if exists mmt_staging2.fn_IHT_CGM_ODS;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_IHT_CGM_ODS()
|
||||
RETURNS void AS $$
|
||||
declare __test_instance_id int;
|
||||
declare __file_syspk int;
|
||||
declare __model text;
|
||||
declare __make text;
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHT_CGM_ODS
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHT
|
||||
Sheet Format: IHT_CGM
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select mmt_staging2.fn_IHT_CGM_ODS()
|
||||
***************************************************************/
|
||||
delete from mmt_ods.test_instance where test_file_sheet_format='IHT_CGM';
|
||||
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='IHT_CGM';
|
||||
delete from mmt_ods.test_instance_tyre_info where test_file_sheet_format='IHT_CGM';
|
||||
delete from mmt_ods.test_instance_weight_reaction where test_file_sheet_format='IHT_CGM';
|
||||
delete from mmt_ods.iht_cgm_lifting_angle_load_details where test_file_sheet_format='IHT_CGM';
|
||||
delete from mmt_ods.iht_cgm_results where test_file_sheet_format='IHT_CGM';
|
||||
|
||||
|
||||
insert into mmt_ods.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
job_order_no,
|
||||
sample_receipt_date,
|
||||
test_report_no,
|
||||
generation,
|
||||
customer_name,
|
||||
test_engineer,
|
||||
test_report_date,
|
||||
no_of_sample,
|
||||
test_start_date,
|
||||
test_end_date,
|
||||
tractor_sr_no,
|
||||
test_standard_ref,
|
||||
test_location_name,
|
||||
test_operator,
|
||||
project_group,
|
||||
objective_of_test,
|
||||
acceptance_criteria,
|
||||
remarks
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
Test_Request_no,
|
||||
date '1899-12-30' + sample_receipt_date::int * interval '1' day as Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
date '1899-12-30' + Test_Report_Date::int * interval '1' day as Test_Report_Date,
|
||||
No_of_Sample,
|
||||
date '1899-12-30' + Test_Start_Date::int * interval '1' day as Test_Start_Date,
|
||||
date '1899-12-30' + Test_End_Date::int * interval '1' day as Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks
|
||||
from mmt_staging2.IHT_CGM_H1_block;
|
||||
|
||||
update mmt_ods.test_instance a
|
||||
set
|
||||
report_prepared_date=to_date(b.prepared_date,'DD-MM-YYYY'),
|
||||
report_reviewed_date=to_date(b.reviewed_date,'DD-MM-YYYY'),
|
||||
report_approved_date=to_date(b.approved_date,'DD-MM-YYYY'),
|
||||
report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from mmt_staging2.IHT_CGM_footer_block b
|
||||
where a.test_file_sheet_format ='IHT_CGM';
|
||||
|
||||
insert into mmt_ods.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_load_carrying_capacity,
|
||||
tyre_pressure_kg_per_cm2,
|
||||
tyre_static_rolling_radius_mm,
|
||||
tyre_dynamic_rolling_radius_mm,
|
||||
tyre_wheel_rim_make_and_size
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric,
|
||||
load_carrying_capacity,
|
||||
Pressure_kg_cm2::numeric ,
|
||||
Dynamic_rolling_radius::numeric ,
|
||||
Static_rolling_radius::numeric ,
|
||||
wheel_rim_make_size
|
||||
from mmt_staging2.IHT_CGM_tyre_details_block;
|
||||
|
||||
insert into mmt_ods.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
wheel_base_mm,
|
||||
rear_tractor_width_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
wheel_base::numeric ,
|
||||
rear_track_width::numeric
|
||||
from mmt_staging2.IHT_CGM_wheel_block;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into mmt_ods.test_instance_weight_reaction
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
total_weight_kg,
|
||||
front_reaction_kg,
|
||||
rear_reaction_kg,
|
||||
left_reaction_fl_rl_kg,
|
||||
right_reaction_fr_rr_kg,
|
||||
front_left_reaction_kg,
|
||||
front_right_reactionkg,
|
||||
rear_left_reaction_kg,
|
||||
rear_right_reactionkg,
|
||||
distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg::numeric,
|
||||
Front_Reaction_kg::numeric ,
|
||||
Rear_Reaction_kg::numeric ,
|
||||
Left_Reaction_FL_RL_kg::numeric ,
|
||||
Right_reaction_FR_RR_kg::numeric ,
|
||||
Front_Left_Reaction_kg::numeric ,
|
||||
Front_Right_Reaction_kg::numeric ,
|
||||
Rear_Left_Reaction_kg::numeric ,
|
||||
Rear_Right_Reaction_kg::numeric ,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1::numeric
|
||||
from mmt_staging2.IHT_CGM_weight_block;
|
||||
|
||||
|
||||
insert into mmt_ods.iht_cgm_lifting_angle_load_details
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
angle,
|
||||
value_in_tan,
|
||||
diff_of_tan_value,
|
||||
load_kn,
|
||||
load_kg,
|
||||
diff_in_load_kg,
|
||||
vertical_co_ordinate_z_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column3::numeric,
|
||||
column4::numeric ,
|
||||
column5::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9::numeric,
|
||||
column10::numeric
|
||||
from mmt_staging2.iht_cgm_lifting_block where ods_record=1;
|
||||
|
||||
insert into mmt_ods.iht_cgm_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
horizontal_distance_from_rac_x_mm,
|
||||
lateral_co_ordinate_in_horizontal_plane_y_mm,
|
||||
vertical_co_ordinate_z_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
determination_of_horizontal_distance_from_rac_x::numeric ,
|
||||
determination_of_lateral_coordinate_in_horizontal_plane_y::numeric ,
|
||||
determination_of_vertical_coordinate_z::numeric
|
||||
from mmt_staging2.iht_cgm_results_block where ods_record=1;
|
||||
|
||||
|
||||
select file_syspk into __file_syspk from mmt_staging2.IHT_CGM_H1_block;
|
||||
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_model into __model from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_make into __make from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
|
||||
update mmt_ods.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_weight_reaction
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_cgm_lifting_angle_load_details
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_cgm_results
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
|
||||
563
deployment-20210427T103328Z-001/deployment/IHT/IHT_CGM_STG2.sql
Normal file
563
deployment-20210427T103328Z-001/deployment/IHT/IHT_CGM_STG2.sql
Normal file
@@ -0,0 +1,563 @@
|
||||
drop function if exists mmt_staging2.fn_IHT_CGM_block;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_IHT_CGM_block(p_client_id int,p_function_id int, p_file_format text,
|
||||
p_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS text AS $$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_format text :=p_file_format;
|
||||
declare __sheet_mnemonic text :=p_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare v_state text;
|
||||
declare v_msg text;
|
||||
declare v_detail text;
|
||||
declare v_hint text;
|
||||
declare v_context text;
|
||||
declare _error int;
|
||||
declare v_block text;
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHT_CGM_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHT
|
||||
Sheet Format: IHT_CGM
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select mmt_staging2.fn_IHT_CGM_block(p_client_id,p_function_id, p_file_format,
|
||||
p_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select mmt_staging2.fn_IHT_CGM_block(1,2,'IHT','IHT_CGM',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO mmt_staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table mmt_staging2.IHT_CGM_H1_Int;
|
||||
truncate table mmt_staging2.IHT_CGM_H1_block;
|
||||
truncate table mmt_staging2.IHT_CGM_Weight_Tyre_Int;
|
||||
truncate table mmt_staging2.IHT_CGM_Weight_Block;
|
||||
truncate table mmt_staging2.IHT_CGM_Wheel_Block;
|
||||
truncate table mmt_staging2.IHT_CGM_Tyre_Details_Block;
|
||||
truncate table mmt_staging2.IHT_CGM_Lifting_Block;
|
||||
truncate table mmt_staging2.IHT_CGM_Results_Block;
|
||||
truncate table mmt_staging2.IHT_CGM_Footer_Block;
|
||||
truncate table mmt_staging2.stg_specific_table_IHT_CGM;
|
||||
truncate table mmt_staging2.stg_process_table_IHT_CGM;
|
||||
|
||||
|
||||
execute 'delete from mmt_ods.fw_jobctrl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHT */
|
||||
execute 'insert into mmt_staging2.stg_specific_table_IHT_CGM
|
||||
select * from mmt_staging1.mmt_staging_generic_table a
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
|
||||
/* trimming data */
|
||||
update mmt_staging2.stg_specific_table_IHT_CGM
|
||||
set column15='Objective' where column15 like 'Objective%';
|
||||
|
||||
update mmt_staging2.stg_specific_table_IHT_CGM
|
||||
set column15='Acceptance criteria' where column15 like 'Acceptance criteria%';
|
||||
|
||||
update mmt_staging2.stg_specific_table_IHT_CGM set column3 = TRIM (TRAILING FROM column3 );
|
||||
update mmt_staging2.stg_specific_table_IHT_CGM set column3 = TRIM (LEADING FROM column3 );
|
||||
|
||||
update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ;
|
||||
update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ;
|
||||
update mmt_ods.mmt_config set F1_source=F1_modified ;
|
||||
update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source);
|
||||
update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source);
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from mmt_staging2.stg_specific_table_IHT_CGM b
|
||||
where trim(upper(F1_modified))=trim(upper(column3))
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update mmt_staging2.stg_specific_table_IHT_CGM a
|
||||
set is_rownumber_fetched=1
|
||||
from mmt_ods.mmt_config b
|
||||
where trim(upper(F1_modified))=trim(upper(column3))
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from mmt_ods.mmt_config b
|
||||
where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' )
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Remarks:''
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging ranks*/
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_CGM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_CGM a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request no.''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_CGM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_CGM a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Weight Reaction''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_CGM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_CGM a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Lifting Angle & Load''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_CGM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_CGM a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Remarks:''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model*/
|
||||
select column6 into __model from mmt_staging2.stg_process_table_IHT_CGM a
|
||||
where rank_tag='IHT_CGM_H1' and trim(column3)='Tractor Model';
|
||||
|
||||
/*block starts - IHT_CGM_H1_BLOCK */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_CGM_H1_BLOCK',__file_format,__sheet_mnemonic,1);
|
||||
v_block:='IHT_CGM_H1_BLOCK';
|
||||
|
||||
insert into mmt_staging2.IHT_CGM_H1_INT (c1,c2)
|
||||
select a.column3,column6 from mmt_staging2.stg_process_table_IHT_CGM a where rank_tag='IHT_CGM_H1';
|
||||
|
||||
insert into mmt_staging2.IHT_CGM_H1_INT (c1,c2)
|
||||
select a.column9,column12 from mmt_staging2.stg_process_table_IHT_CGM a where rank_tag='IHT_CGM_H1';
|
||||
|
||||
insert into mmt_staging2.IHT_CGM_H1_INT (c1,c2)
|
||||
select 'Objective',column15
|
||||
from mmt_staging2.stg_process_table_IHT_CGM a
|
||||
where rank_tag='IHT_CGM_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
mmt_staging2.stg_process_table_IHT_CGM a
|
||||
where column15='Objective'
|
||||
and rank_tag='IHT_CGM_H1'
|
||||
);
|
||||
|
||||
insert into mmt_staging2.IHT_CGM_H1_INT (c1,c2)
|
||||
select 'Acceptance criteria',column15
|
||||
from mmt_staging2.stg_process_table_IHT_CGM a
|
||||
where rank_tag='IHT_CGM_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
mmt_staging2.stg_process_table_IHT_CGM a
|
||||
where column15='Acceptance criteria'
|
||||
and rank_tag='IHT_CGM_H1'
|
||||
);
|
||||
|
||||
insert into mmt_staging2.IHT_CGM_H1_INT (c1,c2)
|
||||
select split_part(column3,':',1),split_part(column3,':',2)
|
||||
from mmt_staging2.stg_process_table_IHT_CGM
|
||||
where rank_tag='IHT_CGM_Footer' and rank=1;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_CGM_H1_Int set model=__model;
|
||||
execute 'update mmt_staging2.IHT_CGM_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
insert into mmt_staging2.IHT_CGM_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM mmt_staging2.IHT_CGM_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,
|
||||
a_18 text,a_19 text);
|
||||
|
||||
|
||||
delete from mmt_staging2.IHT_CGM_H1_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_CGM_H1_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_CGM_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_CGM_H1_Block');
|
||||
|
||||
|
||||
insert into mmt_staging2.IHT_CGM_Weight_Tyre_Int
|
||||
(
|
||||
column3,column6,column10,column11,column13,column15,column17,column19,
|
||||
column20,rank
|
||||
)
|
||||
select
|
||||
column3,column6,column10,column11,column13,column15,column17,column19,
|
||||
column20,rank
|
||||
from mmt_staging2.stg_process_table_IHT_CGM a
|
||||
where rank_tag='IHT_CGM_Weight_Tyre'
|
||||
order by rank;
|
||||
|
||||
update mmt_staging2.IHT_CGM_Weight_Tyre_Int set model=__model;
|
||||
execute 'update mmt_staging2.IHT_CGM_Weight_Tyre_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Weight_Tyre_Int set ods_record = 0 where rank=3;
|
||||
|
||||
/*block starts - IHT_CGM_Weight_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_CGM_Weight_Block',__file_format,__sheet_mnemonic,2);
|
||||
v_block:='IHT_CGM_Weight_Block';
|
||||
|
||||
insert into mmt_staging2.IHT_CGM_Weight_Block
|
||||
(
|
||||
dummy_f,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg,
|
||||
Front_Reaction_kg,
|
||||
Rear_Reaction_kg,
|
||||
Left_Reaction_FL_RL_kg,
|
||||
Right_reaction_FR_RR_kg,
|
||||
Front_Left_Reaction_kg,
|
||||
Front_Right_Reaction_kg,
|
||||
Rear_Left_Reaction_kg,
|
||||
Rear_Right_Reaction_kg,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column6}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column6::text]) AS val
|
||||
FROM mmt_staging2.IHT_CGM_Weight_Tyre_Int where ods_record=1
|
||||
ORDER BY generate_series(1,15),rank,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,
|
||||
a_10 text,a_11 text);
|
||||
|
||||
delete from mmt_staging2.IHT_CGM_Weight_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_CGM_Weight_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_CGM_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_CGM_Weight_Block');
|
||||
|
||||
/*block starts - IHT_CGM_Tyre_Details_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_CGM_Tyre_Details_Block',__file_format,__sheet_mnemonic,3);
|
||||
v_block:='IHT_CGM_Tyre_Details_Block';
|
||||
insert into mmt_staging2.IHT_CGM_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Tyre_Make,
|
||||
Tyre_size,
|
||||
Ply_Rating,
|
||||
Load_Carrying_Capacity,
|
||||
Pressure_kg_cm2,
|
||||
Dynamic_rolling_radius,
|
||||
Static_rolling_radius,
|
||||
Wheel_rim_Make_size
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column15,column19}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column15::text,column19::text]) AS val
|
||||
FROM mmt_staging2.IHT_CGM_Weight_Tyre_Int where rank between 4 and 12
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text);
|
||||
|
||||
delete from mmt_staging2.IHT_CGM_Tyre_Details_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_CGM_Tyre_Details_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_CGM_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_CGM_Tyre_Details_Block');
|
||||
|
||||
|
||||
/*block starts - IHT_CGM_Wheel_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_CGM_Wheel_Block',__file_format,__sheet_mnemonic,4);
|
||||
v_block:='IHT_CGM_Wheel_Block';
|
||||
insert into mmt_staging2.IHT_CGM_Wheel_Block(dummy_f) values ('dummy');
|
||||
|
||||
update mmt_staging2.IHT_CGM_Wheel_Block
|
||||
set Wheel_Base=(select column13 from
|
||||
mmt_staging2.IHT_CGM_Weight_Tyre_Int
|
||||
where rank=1 and column10='Wheel Base')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Wheel_Block
|
||||
set Rear_Track_Width=(select column20 from
|
||||
mmt_staging2.IHT_CGM_Weight_Tyre_Int
|
||||
where rank=1 and column17='Rear Track Width')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_CGM_Wheel_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_CGM_Wheel_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_CGM_Wheel_Block');
|
||||
|
||||
/*block starts - IHT_CGM_Lifting_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_CGM_Lifting_Block',__file_format,__sheet_mnemonic,5);
|
||||
v_block:='IHT_CGM_Lifting_Block';
|
||||
|
||||
insert into mmt_staging2.IHT_CGM_Lifting_Block
|
||||
(
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,rank
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,column10,rank
|
||||
from mmt_staging2.stg_process_table_IHT_CGM a
|
||||
where rank_tag='IHT_CGM_Lifting'
|
||||
order by rank;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_CGM_Lifting_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_CGM_Lifting_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Lifting_Block set ods_record =0 where rank not in (3,4,5,6,7,8,9);
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_CGM_Lifting_Block');
|
||||
|
||||
|
||||
/*block starts - IHT_CGM_Results_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_CGM_Results_Block',__file_format,__sheet_mnemonic,6);
|
||||
v_block:='IHT_CGM_Results_Block';
|
||||
insert into mmt_staging2.IHT_CGM_Results_Block (dummy_f) values('dummy');
|
||||
|
||||
update mmt_staging2.IHT_CGM_Results_Block
|
||||
set Determination_of_Horizontal_Distance_from_RAC_X=
|
||||
(select column10 from mmt_staging2.IHT_CGM_Lifting_Block
|
||||
where rank=12) where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Results_Block
|
||||
set Determination_of_Lateral_CoOrdinate_in_Horizontal_Plane_Y=
|
||||
(select column10 from mmt_staging2.IHT_CGM_Lifting_Block
|
||||
where rank=13) where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Results_Block
|
||||
set Determination_of_Vertical_CoOrdinate_Z=
|
||||
(select column10 from mmt_staging2.IHT_CGM_Lifting_Block
|
||||
where rank=14) where dummy_f='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_CGM_Results_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_CGM_Results_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_CGM_Results_Block');
|
||||
|
||||
|
||||
/*block starts - IHT_CGM_Footer_block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_CGM_Footer_block',__file_format,__sheet_mnemonic,8);
|
||||
v_block='IHT_CGM_Footer_block';
|
||||
insert into mmt_staging2.IHT_CGM_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
update mmt_staging2.IHT_CGM_Footer_block a
|
||||
set prepared_by=( select column7 from mmt_staging2.stg_process_table_IHT_CGM b
|
||||
where b.rank_tag='IHT_CGM_Footer'
|
||||
and trim(column3)='Prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Footer_block a
|
||||
set reviewed_by=( select column7 from mmt_staging2.stg_process_table_IHT_CGM b
|
||||
where b.rank_tag='IHT_CGM_Footer'
|
||||
and trim(column3)='Reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Footer_block a
|
||||
set approved_by=( select column7 from mmt_staging2.stg_process_table_IHT_CGM b
|
||||
where b.rank_tag='IHT_CGM_Footer'
|
||||
and trim(column3)='Approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Footer_block a
|
||||
set comments=( select column3 from mmt_staging2.stg_process_table_IHT_CGM b
|
||||
where b.rank_tag='IHT_CGM_Footer'
|
||||
and rank=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Footer_block a
|
||||
set rev1=( select column3 from mmt_staging2.stg_process_table_IHT_CGM b
|
||||
where b.rank_tag='IHT_CGM_Footer'
|
||||
and rank=7 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_CGM_Footer_block a
|
||||
set rev2=( select column9 from mmt_staging2.stg_process_table_IHT_CGM b
|
||||
where b.rank_tag='IHT_CGM_Footer'
|
||||
and rank=7 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Footer_block a
|
||||
set rev3=( select column18 from mmt_staging2.stg_process_table_IHT_CGM b
|
||||
where b.rank_tag='IHT_CGM_Footer'
|
||||
and rank=7 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Footer_block a
|
||||
set replaces=( select column19 from mmt_staging2.stg_process_table_IHT_CGM b
|
||||
where b.rank_tag='IHT_CGM_Footer'
|
||||
and rank=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Footer_block a
|
||||
set revision_no=( select column19 from mmt_staging2.stg_process_table_IHT_CGM b
|
||||
where b.rank_tag='IHT_CGM_Footer'
|
||||
and rank=4)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Footer_block a
|
||||
set prepared_date=( select column16 from mmt_staging2.stg_process_table_IHT_CGM b
|
||||
where b.rank_tag='IHT_CGM_Footer'
|
||||
and rank=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Footer_block a
|
||||
set reviewed_date=( select column16 from mmt_staging2.stg_process_table_IHT_CGM b
|
||||
where b.rank_tag='IHT_CGM_Footer'
|
||||
and rank=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Footer_block a
|
||||
set approved_date=( select column16 from mmt_staging2.stg_process_table_IHT_CGM b
|
||||
where b.rank_tag='IHT_CGM_Footer'
|
||||
and rank=4)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_CGM_Footer_block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_CGM_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_CGM_Footer_block');
|
||||
v_context := '';
|
||||
return v_context;
|
||||
EXCEPTION when OTHERS then
|
||||
|
||||
GET STACKED DIAGNOSTICS
|
||||
v_state = returned_sqlstate,
|
||||
v_msg = message_text,
|
||||
v_detail = pg_exception_detail,
|
||||
v_hint = pg_exception_hint,
|
||||
v_context = pg_exception_context;
|
||||
|
||||
perform mmt_insert_db_error ( __client_id, __function_id, 1001, 'Compegence',v_block,'stg2', 'test_db_error', v_state, v_msg, v_detail, v_hint, v_context);
|
||||
return v_context;
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
401
deployment-20210427T103328Z-001/deployment/IHT/IHT_EMT_ODS.SQL
Normal file
401
deployment-20210427T103328Z-001/deployment/IHT/IHT_EMT_ODS.SQL
Normal file
@@ -0,0 +1,401 @@
|
||||
drop function if exists mmt_staging2.fn_IHT_EMT_ODS;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_IHT_EMT_ODS()
|
||||
RETURNS void AS $$
|
||||
declare __test_instance_id int;
|
||||
declare __file_syspk int;
|
||||
declare __model text;
|
||||
declare __make text;
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHT_EMT_ODS
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHT
|
||||
Sheet Format: IHT_EMT
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select mmt_staging2.fn_IHT_EMT_ODS()
|
||||
***************************************************************/
|
||||
delete from mmt_ods.test_instance where test_file_sheet_format='IHT_EMT';
|
||||
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='IHT_EMT';
|
||||
delete from mmt_ods.test_instance_tyre_info where test_file_sheet_format='IHT_EMT';
|
||||
delete from mmt_ods.test_instance_weight_reaction where test_file_sheet_format='IHT_EMT';
|
||||
delete from mmt_ods.iht_steering_effort where test_file_sheet_format='IHT_EMT';
|
||||
delete from mmt_ods.iht_pedal_effort where test_file_sheet_format='IHT_EMT';
|
||||
delete from mmt_ods.iht_clutch_pedal_effort where test_file_sheet_format='IHT_EMT';
|
||||
delete from mmt_ods.iht_brake_pedal_effort where test_file_sheet_format='IHT_EMT';
|
||||
delete from mmt_ods.iht_gear_effort where test_file_sheet_format='IHT_EMT';
|
||||
|
||||
|
||||
insert into mmt_ods.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
job_order_no,
|
||||
sample_receipt_date,
|
||||
test_report_no,
|
||||
generation,
|
||||
customer_name,
|
||||
test_engineer,
|
||||
test_report_date,
|
||||
no_of_sample,
|
||||
test_start_date,
|
||||
test_end_date,
|
||||
tractor_sr_no,
|
||||
test_standard_ref,
|
||||
test_location_name,
|
||||
test_operator,
|
||||
project_group,
|
||||
objective_of_test,
|
||||
acceptance_criteria,
|
||||
remarks
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
Test_Request_no,
|
||||
date '1899-12-30' + sample_receipt_date::int * interval '1' day as Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
date '1899-12-30' + Test_Report_Date::int * interval '1' day as Test_Report_Date,
|
||||
No_of_Sample,
|
||||
date '1899-12-30' + Test_Start_Date ::int * interval '1' day as Test_Start_Date,
|
||||
date '1899-12-30' + Test_End_Date ::int * interval '1' day as Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks
|
||||
from mmt_staging2.IHT_EMT_H1_block;
|
||||
|
||||
update mmt_ods.test_instance a
|
||||
set
|
||||
report_prepared_date=to_date(b.prepared_date,'DD-MM-YYYY'),
|
||||
report_reviewed_date=to_date(b.reviewed_date,'DD-MM-YYYY'),
|
||||
report_approved_date=to_date(b.approved_date,'DD-MM-YYYY'),
|
||||
report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from mmt_staging2.IHT_EMT_footer_block b
|
||||
where a.test_file_sheet_format ='IHT_EMT';
|
||||
|
||||
insert into mmt_ods.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_load_carrying_capacity,
|
||||
tyre_pressure_kg_per_cm2,
|
||||
tyre_static_rolling_radius_mm,
|
||||
tyre_dynamic_rolling_radius_mm,
|
||||
tyre_wheel_rim_make_and_size
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric,
|
||||
load_carrying_capacity,
|
||||
Pressure_kg_cm2::numeric ,
|
||||
Dynamic_rolling_radius::numeric ,
|
||||
Static_rolling_radius::numeric ,
|
||||
wheel_rim_make_size
|
||||
from mmt_staging2.IHT_EMT_tyre_details_block where ods_record =1;
|
||||
|
||||
insert into mmt_ods.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
wheel_base_mm,
|
||||
turning_circle_diameter_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
wheel_base::numeric ,
|
||||
tcd::numeric
|
||||
from mmt_staging2.IHT_EMT_wheel_block;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into mmt_ods.test_instance_weight_reaction
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
total_weight_kg,
|
||||
front_reaction_kg,
|
||||
rear_reaction_kg,
|
||||
left_reaction_fl_rl_kg,
|
||||
right_reaction_fr_rr_kg,
|
||||
front_left_reaction_kg,
|
||||
front_right_reactionkg,
|
||||
rear_left_reaction_kg,
|
||||
rear_right_reactionkg,
|
||||
distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg::numeric,
|
||||
Front_Reaction_kg::numeric ,
|
||||
Rear_Reaction_kg::numeric ,
|
||||
Left_Reaction_FL_RL_kg::numeric ,
|
||||
Right_reaction_FR_RR_kg::numeric ,
|
||||
Front_Left_Reaction_kg::numeric ,
|
||||
Front_Right_Reaction_kg::numeric ,
|
||||
Rear_Left_Reaction_kg::numeric ,
|
||||
Rear_Right_Reaction_kg::numeric ,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1::numeric
|
||||
from mmt_staging2.IHT_EMT_weight_block;
|
||||
|
||||
|
||||
insert into mmt_ods.iht_steering_effort
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_speed_kmph,
|
||||
max_angle_lh,
|
||||
max_angle_rh,
|
||||
max_effort_lh,
|
||||
max_effort_rh
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column8::numeric
|
||||
from mmt_staging2.iht_emt_steering_block where ods_record=1;
|
||||
|
||||
insert into mmt_ods.iht_pedal_effort
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
parameters,
|
||||
efforts_kg,
|
||||
travel_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3::numeric ,
|
||||
column4::numeric
|
||||
from mmt_staging2.iht_emt_pedal_block where ods_record=1;
|
||||
|
||||
insert into mmt_ods.iht_gear_effort
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
parameters,
|
||||
efforts_kg
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column5,
|
||||
column8::numeric
|
||||
from mmt_staging2.iht_emt_pedal_block where ods_record=1;
|
||||
|
||||
insert into mmt_ods.iht_brake_pedal_effort
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
srl_no,
|
||||
pedal_effort_kg,
|
||||
pedal_travel_lh_mm,
|
||||
pedal_travel_rh_mm,
|
||||
pedal_travel_latched_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column2::numeric,
|
||||
column3::numeric,
|
||||
column4::numeric ,
|
||||
column5::numeric,
|
||||
column6::numeric
|
||||
from mmt_staging2.iht_emt_brake_pedal_block where ods_record=1;
|
||||
|
||||
insert into mmt_ods.iht_clutch_pedal_effort
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
srl_no,
|
||||
pedal_effort_kg,
|
||||
pedal_travel_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9::numeric
|
||||
from mmt_staging2.iht_emt_brake_pedal_block where ods_record=1;
|
||||
|
||||
select file_syspk into __file_syspk from mmt_staging2.IHT_EMT_H1_block;
|
||||
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_model into __model from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_make into __make from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_weight_reaction
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_brake_pedal_effort
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_pedal_effort
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_steering_effort
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_gear_effort
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_clutch_pedal_effort
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
607
deployment-20210427T103328Z-001/deployment/IHT/IHT_EMT_STG2.sql
Normal file
607
deployment-20210427T103328Z-001/deployment/IHT/IHT_EMT_STG2.sql
Normal file
@@ -0,0 +1,607 @@
|
||||
drop function if exists mmt_staging2.fn_IHT_EMT_block;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_IHT_EMT_block(p_client_id int,p_function_id int, p_file_format text,
|
||||
p_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS text AS $$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_format text :=p_file_format;
|
||||
declare __sheet_mnemonic text :=p_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare v_state text;
|
||||
declare v_msg text;
|
||||
declare v_detail text;
|
||||
declare v_hint text;
|
||||
declare v_context text;
|
||||
declare _error int;
|
||||
declare v_block text;
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHT_EMT_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHT
|
||||
Sheet Format: IHT_EMT
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select mmt_staging2.fn_IHT_EMT_block(p_client_id,p_function_id, p_file_format,
|
||||
p_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select mmt_staging2.fn_IHT_EMT_block(1,2,'IHT','IHT_EMT',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO mmt_staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table mmt_staging2.IHT_EMT_H1_Int;
|
||||
truncate table mmt_staging2.IHT_EMT_H1_block;
|
||||
truncate table mmt_staging2.IHT_EMT_Weight_Tyre_Int;
|
||||
truncate table mmt_staging2.IHT_EMT_Weight_Block;
|
||||
truncate table mmt_staging2.IHT_EMT_Wheel_Block;
|
||||
truncate table mmt_staging2.IHT_EMT_Tyre_Details_Block;
|
||||
truncate table mmt_staging2.IHT_EMT_Steering_Block;
|
||||
truncate table mmt_staging2.IHT_EMT_Pedal_Block;
|
||||
truncate table mmt_staging2.IHT_EMT_Brake_Pedal_Block;
|
||||
truncate table mmt_staging2.IHT_EMT_Footer_Block;
|
||||
truncate table mmt_staging2.stg_specific_table_IHT_EMT;
|
||||
truncate table mmt_staging2.stg_process_table_IHT_EMT;
|
||||
|
||||
|
||||
execute 'delete from mmt_ods.fw_jobctrl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHT */
|
||||
execute 'insert into mmt_staging2.stg_specific_table_IHT_EMT
|
||||
select * from mmt_staging1.mmt_staging_generic_table a
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
|
||||
/* trimming data */
|
||||
update mmt_staging2.stg_specific_table_IHT_EMT
|
||||
set column14='Objective' where column14 like 'Objective%';
|
||||
|
||||
update mmt_staging2.stg_specific_table_IHT_EMT
|
||||
set column14='Acceptance criteria' where column14 like 'Acceptance criteria%';
|
||||
|
||||
update mmt_staging2.stg_specific_table_IHT_EMT set column2 = TRIM (TRAILING FROM column2 );
|
||||
update mmt_staging2.stg_specific_table_IHT_EMT set column2 = TRIM (LEADING FROM column2 );
|
||||
|
||||
update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ;
|
||||
update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ;
|
||||
update mmt_ods.mmt_config set F1_source=F1_modified ;
|
||||
update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source);
|
||||
update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source);
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from mmt_staging2.stg_specific_table_IHT_EMT b
|
||||
where trim(upper(F1_modified))=trim(upper(column2))
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update mmt_staging2.stg_specific_table_IHT_EMT a
|
||||
set is_rownumber_fetched=1
|
||||
from mmt_ods.mmt_config b
|
||||
where trim(upper(F1_modified))=trim(upper(column2))
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from mmt_ods.mmt_config b
|
||||
where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' )
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Remarks:''
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging ranks*/
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_EMT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_EMT a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request no.''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_EMT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_EMT a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Weight Reaction''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_EMT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_EMT a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Steering effort''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_EMT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_EMT a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Pedal Effort''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_EMT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_EMT a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Brake Pedal Effort''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_EMT
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_EMT a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Remarks:''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model*/
|
||||
select column5 into __model from mmt_staging2.stg_process_table_IHT_EMT a
|
||||
where rank_tag='IHT_EMT_H1' and trim(column2)='Tractor Model';
|
||||
|
||||
/*block starts - IHT_EMT_H1_BLOCK */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_EMT_H1_BLOCK',__file_format,__sheet_mnemonic,1);
|
||||
v_block:='IHT_EMT_H1_BLOCK';
|
||||
insert into mmt_staging2.IHT_EMT_H1_INT (c1,c2)
|
||||
select a.column2,column5 from mmt_staging2.stg_process_table_IHT_EMT a where rank_tag='IHT_EMT_H1';
|
||||
|
||||
insert into mmt_staging2.IHT_EMT_H1_INT (c1,c2)
|
||||
select a.column8,column11 from mmt_staging2.stg_process_table_IHT_EMT a where rank_tag='IHT_EMT_H1';
|
||||
|
||||
insert into mmt_staging2.IHT_EMT_H1_INT (c1,c2)
|
||||
select 'Objective',column14
|
||||
from mmt_staging2.stg_process_table_IHT_EMT a
|
||||
where rank_tag='IHT_EMT_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
mmt_staging2.stg_process_table_IHT_EMT a
|
||||
where column14='Objective'
|
||||
and rank_tag='IHT_EMT_H1'
|
||||
);
|
||||
|
||||
insert into mmt_staging2.IHT_EMT_H1_INT (c1,c2)
|
||||
select 'Acceptance criteria',column14
|
||||
from mmt_staging2.stg_process_table_IHT_EMT a
|
||||
where rank_tag='IHT_EMT_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
mmt_staging2.stg_process_table_IHT_EMT a
|
||||
where column14='Acceptance criteria'
|
||||
and rank_tag='IHT_EMT_H1'
|
||||
);
|
||||
|
||||
insert into mmt_staging2.IHT_EMT_H1_INT (c1,c2)
|
||||
select split_part(column2,':',1),split_part(column2,':',2)
|
||||
from mmt_staging2.stg_process_table_IHT_EMT
|
||||
where rank_tag='IHT_EMT_Footer' and rank=1;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_EMT_H1_Int set model=__model;
|
||||
execute 'update mmt_staging2.IHT_EMT_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
insert into mmt_staging2.IHT_EMT_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM mmt_staging2.IHT_EMT_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,
|
||||
a_18 text,a_19 text);
|
||||
|
||||
|
||||
delete from mmt_staging2.IHT_EMT_H1_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_EMT_H1_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_EMT_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_EMT_H1_Block');
|
||||
|
||||
|
||||
insert into mmt_staging2.IHT_EMT_Weight_Tyre_Int
|
||||
(
|
||||
column2,column5,column9,column10,column12,column14,column16,column18,
|
||||
column19,rank
|
||||
)
|
||||
select
|
||||
column2,column5,column9,column10,column12,column14,column16,column18,
|
||||
column19,rank
|
||||
from mmt_staging2.stg_process_table_IHT_EMT a
|
||||
where rank_tag='IHT_EMT_Weight_Tyre'
|
||||
order by rank;
|
||||
|
||||
update mmt_staging2.IHT_EMT_Weight_Tyre_Int set model=__model;
|
||||
execute 'update mmt_staging2.IHT_EMT_Weight_Tyre_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
/*block starts - IHT_EMT_Weight_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_EMT_Weight_Block',__file_format,__sheet_mnemonic,2);
|
||||
v_block:='IHT_EMT_Weight_Block';
|
||||
|
||||
insert into mmt_staging2.IHT_EMT_Weight_Block
|
||||
(
|
||||
dummy_f,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg,
|
||||
Front_Reaction_kg,
|
||||
Rear_Reaction_kg,
|
||||
Left_Reaction_FL_RL_kg,
|
||||
Right_reaction_FR_RR_kg,
|
||||
Front_Left_Reaction_kg,
|
||||
Front_Right_Reaction_kg,
|
||||
Rear_Left_Reaction_kg,
|
||||
Rear_Right_Reaction_kg,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column5}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column5::text]) AS val
|
||||
FROM mmt_staging2.IHT_EMT_Weight_Tyre_Int
|
||||
ORDER BY generate_series(1,15),rank,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,
|
||||
a_10 text,a_11 text);
|
||||
|
||||
delete from mmt_staging2.IHT_EMT_Weight_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_EMT_Weight_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_EMT_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_EMT_Weight_Block');
|
||||
|
||||
/*block starts - IHT_EMT_Tyre_Details_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_EMT_Tyre_Details_Block',__file_format,__sheet_mnemonic,3);
|
||||
v_block:='IHT_EMT_Tyre_Details_Block';
|
||||
|
||||
insert into mmt_staging2.IHT_EMT_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Tyre_Make,
|
||||
Tyre_size,
|
||||
Ply_Rating,
|
||||
Load_Carrying_Capacity,
|
||||
Pressure_kg_cm2,
|
||||
Dynamic_rolling_radius,
|
||||
Static_rolling_radius,
|
||||
Wheel_rim_Make_size
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column14,column18}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column14::text,column18::text]) AS val
|
||||
FROM mmt_staging2.IHT_EMT_Weight_Tyre_Int where rank between 3 and 11
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text);
|
||||
|
||||
delete from mmt_staging2.IHT_EMT_Tyre_Details_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_EMT_Tyre_Details_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_EMT_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_EMT_Tyre_Details_Block');
|
||||
|
||||
|
||||
/*block starts - IHT_EMT_Wheel_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_EMT_Wheel_Block',__file_format,__sheet_mnemonic,4);
|
||||
v_block:='IHT_EMT_Wheel_Block';
|
||||
insert into mmt_staging2.IHT_EMT_Wheel_Block(dummy_f) values ('dummy');
|
||||
|
||||
update mmt_staging2.IHT_EMT_Wheel_Block
|
||||
set Wheel_Base=(select column12 from
|
||||
mmt_staging2.IHT_EMT_Weight_Tyre_Int
|
||||
where rank=1 and column9='Wheel Base')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Wheel_Block
|
||||
set TCD=(select replace(column19,'mm','') from
|
||||
mmt_staging2.IHT_EMT_Weight_Tyre_Int
|
||||
where rank=1 and column16='TCD')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_EMT_Wheel_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_EMT_Wheel_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_EMT_Wheel_Block');
|
||||
|
||||
/*block starts - IHT_EMT_Steering_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_EMT_Steering_Block',__file_format,__sheet_mnemonic,5);
|
||||
v_block:='IHT_EMT_Steering_Block';
|
||||
|
||||
insert into mmt_staging2.IHT_EMT_Steering_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,
|
||||
column8,rank
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,
|
||||
column8,rank
|
||||
from mmt_staging2.stg_process_table_IHT_EMT a
|
||||
where rank_tag='IHT_EMT_Steering'
|
||||
order by rank;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_EMT_Steering_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_EMT_Steering_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Steering_Block set ods_record =0 where rank in (1,2,3);
|
||||
|
||||
|
||||
/*block starts - IHT_EMT_Pedal_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_EMT_Pedal_Block',__file_format,__sheet_mnemonic,6);
|
||||
v_block:='IHT_EMT_Pedal_Block';
|
||||
insert into mmt_staging2.IHT_EMT_Pedal_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,
|
||||
column8,rank
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,
|
||||
column8,rank
|
||||
from mmt_staging2.stg_process_table_IHT_EMT a
|
||||
where rank_tag='IHT_EMT_Pedal'
|
||||
order by rank;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_EMT_Pedal_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_EMT_Pedal_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Pedal_Block set ods_record =0 where rank in (1,2);
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_EMT_Pedal_Block');
|
||||
|
||||
/*block starts - IHT_EMT_Brake_Pedal_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_EMT_Brake_Pedal_Block',__file_format,__sheet_mnemonic,7);
|
||||
v_block:='IHT_EMT_Brake_Pedal_Block';
|
||||
insert into mmt_staging2.IHT_EMT_Brake_Pedal_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,rank
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,rank
|
||||
from mmt_staging2.stg_process_table_IHT_EMT a
|
||||
where rank_tag='IHT_EMT_Brake_Pedal'
|
||||
order by rank;
|
||||
|
||||
|
||||
|
||||
update mmt_staging2.IHT_EMT_Brake_Pedal_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_EMT_Brake_Pedal_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_EMT_Brake_Pedal_Block set ods_record =0 where rank in (1,2,3);
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_EMT_Brake_Pedal_Block');
|
||||
|
||||
/*block starts - IHT_EMT_Footer_block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_EMT_Footer_block',__file_format,__sheet_mnemonic,8);
|
||||
v_block:='IHT_EMT_Footer_block';
|
||||
insert into mmt_staging2.IHT_EMT_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
update mmt_staging2.IHT_EMT_Footer_block a
|
||||
set prepared_by=( select column6 from mmt_staging2.stg_process_table_IHT_EMT b
|
||||
where b.rank_tag='IHT_EMT_Footer'
|
||||
and trim(column2)='Prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Footer_block a
|
||||
set reviewed_by=( select column6 from mmt_staging2.stg_process_table_IHT_EMT b
|
||||
where b.rank_tag='IHT_EMT_Footer'
|
||||
and trim(column2)='Reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Footer_block a
|
||||
set approved_by=( select column6 from mmt_staging2.stg_process_table_IHT_EMT b
|
||||
where b.rank_tag='IHT_EMT_Footer'
|
||||
and trim(column2)='Approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Footer_block a
|
||||
set comments=( select column2 from mmt_staging2.stg_process_table_IHT_EMT b
|
||||
where b.rank_tag='IHT_EMT_Footer'
|
||||
and rank=5 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Footer_block a
|
||||
set rev1=( select column2 from mmt_staging2.stg_process_table_IHT_EMT b
|
||||
where b.rank_tag='IHT_EMT_Footer'
|
||||
and rank=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_EMT_Footer_block a
|
||||
set rev2=( select column8 from mmt_staging2.stg_process_table_IHT_EMT b
|
||||
where b.rank_tag='IHT_EMT_Footer'
|
||||
and rank=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Footer_block a
|
||||
set rev3=( select column17 from mmt_staging2.stg_process_table_IHT_EMT b
|
||||
where b.rank_tag='IHT_EMT_Footer'
|
||||
and rank=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Footer_block a
|
||||
set replaces=( select column18 from mmt_staging2.stg_process_table_IHT_EMT b
|
||||
where b.rank_tag='IHT_EMT_Footer'
|
||||
and rank=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Footer_block a
|
||||
set revision_no=( select column18 from mmt_staging2.stg_process_table_IHT_EMT b
|
||||
where b.rank_tag='IHT_EMT_Footer'
|
||||
and rank=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Footer_block a
|
||||
set prepared_date=( select column15 from mmt_staging2.stg_process_table_IHT_EMT b
|
||||
where b.rank_tag='IHT_EMT_Footer'
|
||||
and rank=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Footer_block a
|
||||
set reviewed_date=( select column15 from mmt_staging2.stg_process_table_IHT_EMT b
|
||||
where b.rank_tag='IHT_EMT_Footer'
|
||||
and rank=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Footer_block a
|
||||
set approved_date=( select column15 from mmt_staging2.stg_process_table_IHT_EMT b
|
||||
where b.rank_tag='IHT_EMT_Footer'
|
||||
and rank=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_EMT_Footer_block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_EMT_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_EMT_Footer_block');
|
||||
v_context := '';
|
||||
return v_context;
|
||||
EXCEPTION when OTHERS then
|
||||
|
||||
GET STACKED DIAGNOSTICS
|
||||
v_state = returned_sqlstate,
|
||||
v_msg = message_text,
|
||||
v_detail = pg_exception_detail,
|
||||
v_hint = pg_exception_hint,
|
||||
v_context = pg_exception_context;
|
||||
|
||||
perform mmt_insert_db_error ( __client_id, __function_id, 1001, 'Compegence',v_block,'stg2', 'test_db_error', v_state, v_msg, v_detail, v_hint, v_context);
|
||||
return v_context;
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
384
deployment-20210427T103328Z-001/deployment/IHT/IHT_HAM_ODS.SQL
Normal file
384
deployment-20210427T103328Z-001/deployment/IHT/IHT_HAM_ODS.SQL
Normal file
@@ -0,0 +1,384 @@
|
||||
drop function if exists mmt_staging2.fn_IHT_HAM_ODS;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_IHT_HAM_ODS()
|
||||
RETURNS void AS $$
|
||||
declare __test_instance_id int;
|
||||
declare __file_syspk int;
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHT_HAM_ODS
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHT
|
||||
Sheet Format: IHT_HAM
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select mmt_staging2.fn_IHT_HAM_ODS()
|
||||
***************************************************************/
|
||||
delete from mmt_ods.test_instance where test_file_sheet_format='IHT_HAM';
|
||||
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='IHT_HAM';
|
||||
delete from mmt_ods.test_instance_engine_info where test_file_sheet_format='IHT_HAM';
|
||||
delete from mmt_ods.test_instance_tyre_info where test_file_sheet_format='IHT_HAM';
|
||||
delete from mmt_ods.test_instance_atmospheric_info where test_file_sheet_format='IHT_HAM';
|
||||
delete from mmt_ods.test_instance_atmospheric_info where test_file_sheet_format='IHT_HAM';
|
||||
delete from mmt_ods.test_instance_drawbar_info where test_file_sheet_format='IHT_HAM';
|
||||
delete from mmt_ods.test_instance_weight_reaction where test_file_sheet_format='IHT_HAM';
|
||||
delete from mmt_ods.iht_hot_air_mapping_results where test_file_sheet_format='IHT_HAM';
|
||||
|
||||
|
||||
insert into mmt_ods.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
job_order_no,
|
||||
sample_receipt_date,
|
||||
test_report_no,
|
||||
generation,
|
||||
customer_name,
|
||||
test_engineer,
|
||||
test_report_date,
|
||||
no_of_sample,
|
||||
test_start_date,
|
||||
test_end_date,
|
||||
tractor_sr_no,
|
||||
test_standard_ref,
|
||||
test_location_name,
|
||||
test_operator,
|
||||
project_group,
|
||||
objective_of_test,
|
||||
acceptance_criteria,
|
||||
test_condition
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
Test_Request_no,
|
||||
date '1899-12-30' + sample_receipt_date::int * interval '1' day as Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
date '1899-12-30' + Test_Report_Date::int * interval '1' day as Test_Report_Date,
|
||||
No_of_Sample,
|
||||
date '1899-12-30' + Test_Start_Date::int * interval '1' day as Test_Start_Date,
|
||||
date '1899-12-30' + Test_End_Date::int * interval '1' day as Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_facility,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Condition
|
||||
from
|
||||
mmt_staging2.IHT_HAM_H1_block;
|
||||
|
||||
update mmt_ods.test_instance a
|
||||
set report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from mmt_staging2.IHT_HAM_footer_block b
|
||||
where a.test_file_sheet_format='IHT_HAM';
|
||||
|
||||
insert into mmt_ods.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_load_carrying_capacity,
|
||||
tyre_pressure_kg_per_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
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
Tyre_Make,
|
||||
Tyre_size,
|
||||
Ply_Rating::numeric ,
|
||||
Load_Carrying_Capacity,
|
||||
pressure_kg_cm2::numeric ,
|
||||
No_of_lug::numeric,
|
||||
Number_of_no_load_lug_30m::numeric,
|
||||
Lug_Height::numeric,
|
||||
Dynamic_rolling_radius::numeric ,
|
||||
Wheel_rim_Make_size
|
||||
from mmt_staging2.IHT_HAM_tyre_details_block;
|
||||
|
||||
|
||||
insert into mmt_ods.test_instance_engine_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
low_idle_declared,
|
||||
low_idle_observed,
|
||||
high_idle_declared,
|
||||
high_idle_observed,
|
||||
rated_rpm,
|
||||
rated_rpm_observed,
|
||||
engine_to_pto_ratio_540_pto
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
low_idle_declared,
|
||||
low_idle_observed::numeric,
|
||||
high_idle_declared,
|
||||
high_idle_observed::numeric,
|
||||
rated_rpm_declared::numeric,
|
||||
rated_rpm_observed::numeric,
|
||||
engine_to_pto_ratio
|
||||
from mmt_staging2.IHT_HAM_engine_rpm_block;
|
||||
|
||||
insert into mmt_ods.test_instance_weight_reaction
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
front_reaction_kg,
|
||||
rear_reaction_kg,
|
||||
total_weight_kg
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
test_condition,
|
||||
Front_weight::numeric,
|
||||
Rear_weight::numeric,
|
||||
Total_weight::numeric
|
||||
from mmt_staging2.IHT_HAM_weight_block;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into mmt_ods.test_instance_atmospheric_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
ambient_temp_c,
|
||||
humidity_pct,
|
||||
wind_velocity_kmph,
|
||||
date,
|
||||
start_time,
|
||||
end_time
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
Ambient_temp_C,
|
||||
humidity,
|
||||
wind_velocity,
|
||||
date,
|
||||
start_time,
|
||||
end_time
|
||||
from mmt_staging2.IHT_HAM_atmos_cond_block;
|
||||
|
||||
insert into mmt_ods.test_instance_drawbar_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
required_pull_in_kg,
|
||||
required_power_in_hp,
|
||||
actual_pull_in_kg,
|
||||
actual_power_in_hp,
|
||||
calculated_hitch_height_mm,
|
||||
actual_hitch_height_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
test_condition,
|
||||
Required_pull_in_kg::numeric ,
|
||||
Required_Power_in_hp::numeric ,
|
||||
Actual_pull_in_kg::numeric ,
|
||||
actual_power_in_hp::numeric ,
|
||||
Calculated_hitch_heigh_mm::numeric ,
|
||||
Actual_hitch_height_mm::numeric
|
||||
from mmt_staging2.iht_ham_drawbar_block;
|
||||
|
||||
insert into mmt_ods.iht_hot_air_mapping_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
gear,
|
||||
load_kg,
|
||||
speed_kmph,
|
||||
speed_rpm,
|
||||
ambient_measured_temp_c,
|
||||
head_measured_temp_c,
|
||||
head_roa_c,
|
||||
chest_measured_temp_c,
|
||||
chest_roa_c,
|
||||
lh_leg_measured_temp_c,
|
||||
lh_leg_roa_c,
|
||||
rh_leg_measured_temp_c,
|
||||
rh_leg_roa_c,
|
||||
lh_hand_measured_temp_c,
|
||||
lh_hand_roa_c,
|
||||
rh_hand_measured_temp_c,
|
||||
rh_hand_roa_c,
|
||||
hood_gas_spring_rh_side_measured_temp_c,
|
||||
hood_gas_spring_rh_side_roa_c,
|
||||
hood_foam_top_measured_temp_c,
|
||||
hood_foam_top_roa_c,
|
||||
hood_foam_middle_measured_temp_c,
|
||||
hood_foam_middle_roa_c,
|
||||
hood_foam_bottom_measured_temp_c,
|
||||
hood_foam_bottom_roa_c,
|
||||
outside_hood_top_measured_temp_c,
|
||||
outside_hood_top_roa_c,
|
||||
outside_hood_middle_measured_temp_c,
|
||||
outside_hood_middle_roa_c,
|
||||
outside_hood_bottom_measured_temp_c,
|
||||
outside_hood_bottom_roa_c,
|
||||
time_of_test,
|
||||
time_diff_h_min
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column7::numeric,column8::numeric ,column9::numeric ,
|
||||
column10::numeric ,column11::numeric ,column12::numeric ,
|
||||
column13::numeric ,column14::numeric ,column15::numeric ,
|
||||
column16::numeric ,column17::numeric ,column18::numeric ,
|
||||
column19::numeric ,column20::numeric ,column21::numeric ,
|
||||
column22::numeric ,column23::numeric ,column24::numeric ,
|
||||
column25::numeric ,column26::numeric ,column27::numeric ,
|
||||
column28::numeric ,column29::numeric ,column30::numeric ,
|
||||
column31::numeric ,column32::numeric ,column33::numeric ,
|
||||
column34 ,column36::numeric
|
||||
from mmt_staging2.iht_ham_results_block ihrb where ods_record=1;
|
||||
|
||||
|
||||
select to_char(to_timestamp((-0.74861111111109402)* 60),'HH12:MIPM');
|
||||
|
||||
select to_char(to_timestamp((4.8611111111110938)* 60),'HH12:MI');
|
||||
|
||||
select file_syspk into __file_syspk from mmt_staging2.IHT_HAM_H1_block;
|
||||
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_model into __model from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_make into __make from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
|
||||
update mmt_ods.test_instance_engine_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.test_instance_weight_reaction
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.test_instance_atmospheric_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.test_instance_drawbar_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_hot_air_mapping_results
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
|
||||
785
deployment-20210427T103328Z-001/deployment/IHT/IHT_HAM_STG2.sql
Normal file
785
deployment-20210427T103328Z-001/deployment/IHT/IHT_HAM_STG2.sql
Normal file
@@ -0,0 +1,785 @@
|
||||
drop function if exists mmt_staging2.fn_IHT_HAM_block;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_IHT_HAM_block(p_client_id int,p_function_id int, p_file_format text,
|
||||
p_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS text AS $$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_format text :=p_file_format;
|
||||
declare __sheet_mnemonic text :=p_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHT_HAM_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHT
|
||||
Sheet Format: IHT_HAM
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select mmt_staging2.fn_IHT_HAM_block(p_client_id,p_function_id, p_file_format,
|
||||
p_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select mmt_staging2.fn_IHT_HAM_block(1,2,'IHT','IHT_HAM',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO mmt_staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table mmt_staging2.IHT_HAM_h1_block;
|
||||
truncate table mmt_staging2.IHT_HAM_H1_Int;
|
||||
truncate table mmt_staging2.IHT_HAM_H1_block;
|
||||
truncate table mmt_staging2.IHT_HAM_Tyre_Details_Block;
|
||||
truncate table mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int;
|
||||
truncate table mmt_staging2.IHT_HAM_Engine_RPM_Block;
|
||||
truncate table mmt_staging2.IHT_HAM_Tractor_Block;
|
||||
truncate table mmt_staging2.IHT_HAM_Weight_Block;
|
||||
truncate table mmt_staging2.IHT_HAM_Drawbar_Block;
|
||||
truncate table mmt_staging2.IHT_HAM_Atmos_Cond_Block;
|
||||
truncate table mmt_staging2.IHT_HAM_Results_Block;
|
||||
truncate table mmt_staging2.IHT_HAM_Footer_Block;
|
||||
truncate table mmt_staging2.stg_specific_table_IHT_HAM;
|
||||
truncate table mmt_staging2.stg_process_table_IHT_HAM;
|
||||
|
||||
|
||||
execute 'delete from mmt_ods.fw_jobctrl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHT */
|
||||
execute 'insert into mmt_staging2.stg_specific_table_IHT_HAM
|
||||
select * from mmt_staging1.mmt_staging_generic_table a
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
|
||||
/* trimming data */
|
||||
update mmt_staging2.stg_specific_table_IHT_HAM set column13='Objective'
|
||||
where column13 like 'Objective%';
|
||||
|
||||
update mmt_staging2.stg_specific_table_IHT_HAM set column13='Acceptance Criteria'
|
||||
where column13 like 'Acceptance Criteria%';
|
||||
|
||||
update mmt_staging2.stg_specific_table_IHT_HAM set column3 = TRIM (TRAILING FROM column3 );
|
||||
update mmt_staging2.stg_specific_table_IHT_HAM set column3 = TRIM (LEADING FROM column3 );
|
||||
|
||||
update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ;
|
||||
update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ;
|
||||
update mmt_ods.mmt_config set F1_source=F1_modified ;
|
||||
update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source);
|
||||
update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source);
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from mmt_staging2.stg_specific_table_IHT_HAM b
|
||||
where trim(upper(F1_modified))=trim(upper(column3))
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update mmt_staging2.stg_specific_table_IHT_HAM a
|
||||
set is_rownumber_fetched=1
|
||||
from mmt_ods.mmt_config b
|
||||
where trim(upper(F1_modified))=trim(upper(column3))
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from mmt_ods.mmt_config b
|
||||
where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' )
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Prepared by''
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging ranks*/
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_HAM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_HAM a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request no.''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_HAM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_HAM a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Engine (RPM)''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_HAM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_HAM a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Atmospheric condition''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_HAM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_HAM a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Condition''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_HAM
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_HAM a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Prepared By''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model*/
|
||||
select column6 into __model from mmt_staging2.stg_process_table_IHT_HAM a
|
||||
where rank_tag='IHT_HAM_H1' and trim(column3)='Tractor Model';
|
||||
|
||||
/*block starts - IHT_HAM_H1_BLOCK */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HAM_H1_BLOCK',__file_format,__sheet_mnemonic,1);
|
||||
v_block:='IHT_HAM_H1_BLOCK';
|
||||
|
||||
insert into mmt_staging2.IHT_HAM_H1_INT (c1,c2)
|
||||
select a.column3,column6 from mmt_staging2.stg_process_table_IHT_HAM a where rank_tag='IHT_HAM_H1';
|
||||
|
||||
insert into mmt_staging2.IHT_HAM_H1_INT (c1,c2)
|
||||
select a.column10,column14 from mmt_staging2.stg_process_table_IHT_HAM a where rank_tag='IHT_HAM_H1';
|
||||
|
||||
insert into mmt_staging2.IHT_HAM_H1_INT (c1,c2)
|
||||
select 'Objective',column13
|
||||
from mmt_staging2.stg_process_table_IHT_HAM a
|
||||
where rank_tag='IHT_HAM_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
mmt_staging2.stg_process_table_IHT_HAM a
|
||||
where column13='Objective'
|
||||
and rank_tag='IHT_HAM_H1'
|
||||
);
|
||||
|
||||
insert into mmt_staging2.IHT_HAM_H1_INT (c1,c2)
|
||||
select 'Acceptance Criteria',column8
|
||||
from mmt_staging2.stg_process_table_IHT_HAM a
|
||||
where rank_tag='IHT_HAM_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
mmt_staging2.stg_process_table_IHT_HAM a
|
||||
where column8='Acceptance_Criteria'
|
||||
and rank_tag='IHT_HAM_H1'
|
||||
);
|
||||
|
||||
insert into mmt_staging2.IHT_HAM_H1_INT (c1,c2)
|
||||
select split_part(column3,':',1),split_part(column3,':',2)
|
||||
from mmt_staging2.stg_process_table_IHT_HAM
|
||||
where rank_tag='IHT_HAM_Footer';
|
||||
|
||||
update mmt_staging2.IHT_HAM_H1_Int set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HAM_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
insert into mmt_staging2.IHT_HAM_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Facility,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Test_standard_refer,
|
||||
Objective,
|
||||
Acceptance_Criteria
|
||||
Remarks
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM mmt_staging2.IHT_HAM_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,a_18 text
|
||||
a_19 text );
|
||||
|
||||
|
||||
|
||||
|
||||
delete from mmt_staging2.IHT_HAM_H1_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_HAM_H1_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HAM_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HAM_H1_Block');
|
||||
|
||||
insert into mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
(
|
||||
column3,column6,column10,column14,
|
||||
column15,column16,column21,column22,
|
||||
column27,column30,column32,rank
|
||||
)
|
||||
select
|
||||
column3,column6,column10,column14,
|
||||
column15,column16,column21,column22,
|
||||
column27,column30,column32,rank
|
||||
from mmt_staging2.stg_process_table_IHT_HAM a
|
||||
where rank_tag='IHT_HAM_Engine_Tyre_Weight'
|
||||
order by rank;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/*block starts - IHT_HAM_Tyre_Details_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HAM_Tyre_Details_Block',__file_format,__sheet_mnemonic,2);
|
||||
v_block:='IHT_HAM_Tyre_Details_Block';
|
||||
insert into mmt_staging2.IHT_HAM_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Tyre_Make,
|
||||
Tyre_size,
|
||||
Ply_Rating,
|
||||
Load_Carrying_Capacity,
|
||||
pressure_kg_cm2,
|
||||
No_of_lug,
|
||||
Number_of_no_load_lug_30m,
|
||||
Lug_Height,
|
||||
Dynamic_rolling_radius,
|
||||
Wheel_rim_Make_size
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column22,column30}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column22::text,column30::text]) AS val
|
||||
FROM mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int where rank between 4 and 14
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,
|
||||
a_8 text,a_9 text,a_10 text,a_11 text);
|
||||
|
||||
|
||||
|
||||
delete from mmt_staging2.IHT_HAM_Tyre_Details_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_HAM_Tyre_Details_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HAM_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HAM_Tyre_Details_Block');
|
||||
|
||||
|
||||
/*block starts - IHT_HAM_Engine_RPM_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HAM_Engine_RPM_Block',__file_format,__sheet_mnemonic,3);
|
||||
v_block:='IHT_HAM_Engine_RPM_Block';
|
||||
insert into mmt_staging2.IHT_HAM_Engine_RPM_Block(dummy_f) values ('dummy');
|
||||
|
||||
update mmt_staging2.IHT_HAM_Engine_RPM_Block
|
||||
set low_idle_declared=(select column6 from
|
||||
mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where rank=2 and column3='Low Idle RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Engine_RPM_Block
|
||||
set low_idle_observed=(select column10 from
|
||||
mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where rank=2 and column3='Low Idle RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Engine_RPM_Block
|
||||
set high_idle_declared=(select column6 from
|
||||
mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where rank=3 and column10='High Idle RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Engine_RPM_Block
|
||||
set high_idle_observed=(select column10 from
|
||||
mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where rank=3 and column3='High Idle RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Engine_RPM_Block
|
||||
set rated_rpm_declared=(select column6 from
|
||||
mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where rank=4 and column3='Rated RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Engine_RPM_Block
|
||||
set rated_rpm_observed=(select column10 from
|
||||
mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where rank=4 and column3='Rated RPM')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Engine_RPM_Block
|
||||
set Engine_to_PTO_Ratio=(select column6 from
|
||||
mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where rank=5 and column3='Engine to PTO Ratio')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Engine_RPM_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HAM_Engine_RPM_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HAM_Engine_RPM_Block');
|
||||
|
||||
|
||||
/*block starts -IHT_HAM_Drawbar_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HAM_Drawbar_Block',__file_format,__sheet_mnemonic,4);
|
||||
v_block:='IHT_HAM_Drawbar_Block';
|
||||
|
||||
insert into mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
(test_condition) values
|
||||
select column6 from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where rank between 9 and 14;
|
||||
|
||||
|
||||
insert into mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
(test_condition) values
|
||||
select column14 from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where rank between 9 and 14;
|
||||
|
||||
update mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
set Required_pull_in_kg = (select column8
|
||||
from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='UB' and rank =9)
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
set Required_Power_in_hp = (select column8
|
||||
from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='UB' and rank =10)
|
||||
|
||||
update mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
set Actual_pull_in_kg = (select column8
|
||||
from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='UB' and rank =11)
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
set actual_power_in_hp = (select column8
|
||||
from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='UB' and rank =12)
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
set Calculated_hitch_heigh_mm = (select column8
|
||||
from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='UB' and rank =13)
|
||||
|
||||
update mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
set Actual_hitch_height_mm = (select column8
|
||||
from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='UB' and rank =14)
|
||||
|
||||
update mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
set Required_pull_in_kg = (select column14
|
||||
from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='Ballast' and rank =9)
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
set Required_Power_in_hp = (select column14
|
||||
from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='Ballast' and rank =10)
|
||||
|
||||
update mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
set Actual_pull_in_kg = (select column14
|
||||
from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='Ballast' and rank =11)
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
set actual_power_in_hp = (select column14
|
||||
from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='Ballast' and rank =12)
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
set Calculated_hitch_heigh_mm = (select column14
|
||||
from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='Ballast' and rank =13)
|
||||
|
||||
update mmt_staging2.IHT_HAM_Drawbar_Block
|
||||
set Actual_hitch_height_mm = (select column14
|
||||
from mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where test_condition='Ballast' and rank =14)
|
||||
|
||||
update mmt_staging2.IHT_HAM_Drawbar_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HAM_Drawbar_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HAM_Drawbar_Block');
|
||||
|
||||
/*block starts - IHT_HAM_Tractor_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HAM_Tractor_Block',__file_format,__sheet_mnemonic,5);
|
||||
v_block:='IHT_HAM_Tractor_Block';
|
||||
|
||||
insert into mmt_staging2.IHT_HAM_Tractor_Block(dummy_f) values ('dummy');
|
||||
|
||||
update mmt_staging2.IHT_HAM_Tractor_Block
|
||||
set Wheel_Base_mm=(select column6 from
|
||||
mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where rank=5 and column3='Wheel Base (mm)')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Tractor_Block
|
||||
set Engine_Power_hp=(select column6 from
|
||||
mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where rank=6 and column3='Engine Power hp')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Tractor_Block
|
||||
set PTO_Power_hp=(select column6 from
|
||||
mmt_staging2.IHT_HAM_Engine_Tyre_Weight_Int
|
||||
where rank=7 and column3='PTO Power hp')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Tractor_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HAM_Tractor_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HAM_Tractor_Block');
|
||||
|
||||
/*block starts -IHT_HAM_Weight_Block*/
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HAM_Weight_Block',__file_format,__sheet_mnemonic,6);
|
||||
v_block:='IHT_HAM_Weight_Block';
|
||||
|
||||
insert into mmt_staging2.IHT_HAM_Weight_Block(dummy_f) values ('dummy');
|
||||
|
||||
update mmt_staging2.IHT_HAM_Weight_Block
|
||||
set test_condition=(select column14 from
|
||||
mmt_staging2.IHT_HAM_Engine_RPM_Atmos_Int
|
||||
where rank=2 )
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Weight_Block
|
||||
set test_condition=(select column14 from
|
||||
mmt_staging2.IHT_HAM_Engine_RPM_Atmos_Int
|
||||
where rank=3)
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Weight_Block
|
||||
set Front_weight=(select column21 from
|
||||
mmt_staging2.IHT_HAM_Engine_RPM_Atmos_Int
|
||||
where rank=2 and column14='Unballast')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Weight_Block
|
||||
set Front_weight=(select column21 from
|
||||
mmt_staging2.IHT_HAM_Engine_RPM_Atmos_Int
|
||||
where rank=3 and column14='Ballast')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Weight_Block
|
||||
set Rear_weight=(select column27 from
|
||||
mmt_staging2.IHT_HAM_Engine_RPM_Atmos_Int
|
||||
where rank=2 and column14='Unballast')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Weight_Block
|
||||
set Rear_weight=(select column27 from
|
||||
mmt_staging2.IHT_HAM_Engine_RPM_Atmos_Int
|
||||
where rank=3 and column14='Ballast')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Weight_Block
|
||||
set Total_weight=(select column32 from
|
||||
mmt_staging2.IHT_HAM_Engine_RPM_Atmos_Int
|
||||
where rank=2 and column14='Unballast')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Weight_Block
|
||||
set Total_weight=(select column32 from
|
||||
mmt_staging2.IHT_HAM_Engine_RPM_Atmos_Int
|
||||
where rank=3 and column14='Ballast')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Weight_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HAM_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HAM_Weight_Block');
|
||||
|
||||
|
||||
/*block starts - IHT_HAM_Atmos_Cond_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HAM_Atmos_Cond_Block',__file_format,__sheet_mnemonic,7);
|
||||
v_block:='IHT_HAM_Atmos_Cond_Block';
|
||||
insert into mmt_staging2.IHT_HAM_Atmos_Cond_Block
|
||||
(
|
||||
dummy_f,
|
||||
Ambient_temp_C,
|
||||
humidity,
|
||||
wind_velocity,
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column9}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column9::text]) AS val
|
||||
FROM mmt_staging2.IHT_HAM_Engine_RPM_Atmos_Int where rank in (15,16,17)
|
||||
ORDER BY generate_series(1,15),rank,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text);
|
||||
|
||||
update mmt_staging2.IHT_HAM_Atmos_Cond_Block set date=
|
||||
select where column8
|
||||
FROM mmt_staging2.IHT_HAM_Engine_RPM_Atmos_Int
|
||||
where column7='Date' and rank=15;
|
||||
|
||||
update mmt_staging2.IHT_HAM_Atmos_Cond_Block set start_time=
|
||||
select where column8
|
||||
FROM mmt_staging2.IHT_HAM_Engine_RPM_Atmos_Int
|
||||
where column7='Start Time' and rank=16;
|
||||
|
||||
update mmt_staging2.IHT_HAM_Atmos_Cond_Block set end_time=
|
||||
select where column8
|
||||
FROM mmt_staging2.IHT_HAM_Engine_RPM_Atmos_Int
|
||||
where column7='End Time' and rank=17;
|
||||
|
||||
|
||||
delete from mmt_staging2.IHT_HAM_Atmos_Cond_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_HAM_Atmos_Cond_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HAM_Atmos_Cond_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HAM_Atmos_Cond_Block');
|
||||
|
||||
|
||||
/*block starts - IHT_HAM_Results_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HAM_Results_Block',__file_format,__sheet_mnemonic,8);
|
||||
v_block:='IHT_HAM_Results_Block';
|
||||
insert into mmt_staging2.IHT_HAM_Results_Block
|
||||
(
|
||||
column7,column8,column9,
|
||||
column10,column11,column12,
|
||||
column13,column14,column15,
|
||||
column16,column17,column18,
|
||||
column19,column20,column21,
|
||||
column22,column23,column24,
|
||||
column25,column26,column27,
|
||||
column28,column29,column30,
|
||||
column31,column32,column33,
|
||||
column34,column35,column36,rank
|
||||
)
|
||||
select
|
||||
column7,column8,column9,
|
||||
column10,column11,column12,
|
||||
column13,column14,column15,
|
||||
column16,column17,column18,
|
||||
column19,column20,column21,
|
||||
column22,column23,column24,
|
||||
column25,column26,column27,
|
||||
column28,column29,column30,
|
||||
column31,column32,column33,
|
||||
column34,column35,column36,rank
|
||||
from mmt_staging2.stg_process_table_IHT_HAM a
|
||||
where rank_tag='IHT_HAM_Results'
|
||||
order by rank;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Results_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HAM_Results_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HAM_Results_Block');
|
||||
|
||||
/*block starts - IHT_HAM_Footer_block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HAM_Footer_block',__file_format,__sheet_mnemonic,8);
|
||||
v_block:='IHT_HAM_Footer_block';
|
||||
|
||||
insert into mmt_staging2.IHT_HAM_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
update mmt_staging2.IHT_HAM_Footer_block a
|
||||
set prepared_by=( select column7 from mmt_staging2.stg_process_table_IHT_HAM b
|
||||
where b.rank_tag='IHT_HAM_Footer'
|
||||
and trim(column3)='Prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Footer_block a
|
||||
set reviewed_by=( select column7 from mmt_staging2.stg_process_table_IHT_HAM b
|
||||
where b.rank_tag='IHT_HAM_Footer'
|
||||
and trim(column3)='Reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Footer_block a
|
||||
set approved_by=( select column7 from mmt_staging2.stg_process_table_IHT_HAM b
|
||||
where b.rank_tag='IHT_HAM_Footer'
|
||||
and trim(column3)='Approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Footer_block a
|
||||
set comments=( select column3 from mmt_staging2.stg_process_table_IHT_HAM b
|
||||
where b.rank_tag='IHT_HAM_Footer'
|
||||
and rank=5 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Footer_block a
|
||||
set rev1=( select column3 from mmt_staging2.stg_process_table_IHT_HAM b
|
||||
where b.rank_tag='IHT_HAM_Footer'
|
||||
and rank=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Footer_block a
|
||||
set rev2=( select column16 from mmt_staging2.stg_process_table_IHT_HAM b
|
||||
where b.rank_tag='IHT_HAM_Footer'
|
||||
and rank=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HAM_Footer_block a
|
||||
set replaces=( select column35 from mmt_staging2.stg_process_table_IHT_HAM b
|
||||
where b.rank_tag='IHT_HAM_Footer'
|
||||
and rank=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Footer_block a
|
||||
set revision_no=( select column35 from mmt_staging2.stg_process_table_IHT_HAM b
|
||||
where b.rank_tag='IHT_HAM_Footer'
|
||||
and rank=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Footer_block a
|
||||
set prepared_date=( select column17 from mmt_staging2.stg_process_table_IHT_HAM b
|
||||
where b.rank_tag='IHT_HAM_Footer'
|
||||
and rank=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block a
|
||||
set reviewed_date=( select column17 from mmt_staging2.stg_process_table_IHT_HAM b
|
||||
where b.rank_tag='IHT_HAM_Footer'
|
||||
and rank=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Footer_block a
|
||||
set approved_date=( select column17 from mmt_staging2.stg_process_table_IHT_HAM b
|
||||
where b.rank_tag='IHT_HAM_Footer'
|
||||
and rank=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HAM_Footer_block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HAM_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HAM_Footer_block');
|
||||
|
||||
v_context := '';
|
||||
return v_context;
|
||||
EXCEPTION when OTHERS then
|
||||
|
||||
GET STACKED DIAGNOSTICS
|
||||
v_state = returned_sqlstate,
|
||||
v_msg = message_text,
|
||||
v_detail = pg_exception_detail,
|
||||
v_hint = pg_exception_hint,
|
||||
v_context = pg_exception_context;
|
||||
|
||||
perform mmt_insert_db_error ( __client_id, __function_id, 1001, 'Compegence',v_block,'stg2', 'test_db_error', v_state, v_msg, v_detail, v_hint, v_context);
|
||||
return v_context;
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
269
deployment-20210427T103328Z-001/deployment/IHT/IHT_HLS_ODS.SQL
Normal file
269
deployment-20210427T103328Z-001/deployment/IHT/IHT_HLS_ODS.SQL
Normal file
@@ -0,0 +1,269 @@
|
||||
drop function if exists mmt_staging2.fn_IHT_HLS_ODS;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_IHT_HLS_ODS()
|
||||
RETURNS void AS $$
|
||||
declare __test_instance_id int;
|
||||
declare __file_syspk int;
|
||||
declare __model text;
|
||||
declare __make text;
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHT_HLS_ODS
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHT
|
||||
Sheet Format: IHT_HLS
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select mmt_staging2.fn_IHT_HLS_ODS()
|
||||
***************************************************************/
|
||||
delete from mmt_ods.test_instance where test_file_sheet_format='IHT_HLS';
|
||||
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='IHT_HLS';
|
||||
delete from mmt_ods.test_instance_tyre_info where test_file_sheet_format='IHT_HLS';
|
||||
delete from mmt_ods.test_instance_weight_reaction where test_file_sheet_format='IHT_HLS';
|
||||
delete from mmt_ods.iht_hyd_lift_sensitivity where test_file_sheet_format='IHT_HLS';
|
||||
|
||||
|
||||
|
||||
|
||||
insert into mmt_ods.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
job_order_no,
|
||||
sample_receipt_date,
|
||||
test_report_no,
|
||||
generation,
|
||||
customer_name,
|
||||
test_engineer,
|
||||
test_report_date,
|
||||
no_of_sample,
|
||||
test_start_date,
|
||||
test_end_date,
|
||||
tractor_sr_no,
|
||||
test_standard_ref,
|
||||
test_location_name,
|
||||
test_operator,
|
||||
project_group,
|
||||
objective_of_test,
|
||||
acceptance_criteria,
|
||||
remarks
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
Test_Request_no,
|
||||
date '1899-12-30' + sample_receipt_date::int * interval '1' day as Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
date '1899-12-30' + Test_Report_Date::int * interval '1' day as Test_Report_Date,
|
||||
No_of_Sample,
|
||||
to_date(Test_Start_Date,'DD-MM-YYYY'),
|
||||
to_date(Test_End_Date, 'DD-MM-YYYY'),
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks
|
||||
from mmt_staging2.IHT_HLS_H1_block;
|
||||
|
||||
update mmt_ods.test_instance a
|
||||
set
|
||||
report_prepared_date=to_date(b.prepared_date,'DD-MM-YYYY'),
|
||||
report_reviewed_date=to_date(b.reviewed_date,'DD-MM-YYYY'),
|
||||
report_approved_date=to_date(b.approved_date,'DD-MM-YYYY'),
|
||||
report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from mmt_staging2.IHT_HLS_footer_block b
|
||||
where a.test_file_sheet_format ='IHT_HLS';
|
||||
|
||||
insert into mmt_ods.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_load_carrying_capacity,
|
||||
tyre_pressure_kg_per_cm2,
|
||||
tyre_static_rolling_radius_mm,
|
||||
tyre_dynamic_rolling_radius_mm,
|
||||
tyre_wheel_rim_make_and_size
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric,
|
||||
load_carrying_capacity,
|
||||
Pressure_kg_cm2::numeric ,
|
||||
Dynamic_rolling_radius::numeric ,
|
||||
Static_rolling_radius::numeric ,
|
||||
wheel_rim_make_size
|
||||
from mmt_staging2.IHT_HLS_tyre_details_block;
|
||||
|
||||
insert into mmt_ods.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
wheel_base_mm,
|
||||
rear_tractor_width_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
wheel_base::numeric ,
|
||||
rear_track_width::numeric
|
||||
from mmt_staging2.iht_hls_wheel_block;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into mmt_ods.test_instance_weight_reaction
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
total_weight_kg,
|
||||
front_reaction_kg,
|
||||
rear_reaction_kg,
|
||||
left_reaction_fl_rl_kg,
|
||||
right_reaction_fr_rr_kg,
|
||||
front_left_reaction_kg,
|
||||
front_right_reactionkg,
|
||||
rear_left_reaction_kg,
|
||||
rear_right_reactionkg,
|
||||
distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg::numeric,
|
||||
Front_Reaction_kg::numeric ,
|
||||
Rear_Reaction_kg::numeric ,
|
||||
Left_Reaction_FL_RL_kg::numeric ,
|
||||
Right_reaction_FR_RR_kg::numeric ,
|
||||
Front_Left_Reaction_kg::numeric ,
|
||||
Front_Right_Reaction_kg::numeric ,
|
||||
Rear_Left_Reaction_kg::numeric ,
|
||||
Rear_Right_Reaction_kg::numeric ,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1::numeric
|
||||
from mmt_staging2.iht_hls_weight_block;
|
||||
|
||||
|
||||
insert into mmt_ods.iht_hyd_lift_sensitivity
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tpl_load,
|
||||
engine_rpm_type,
|
||||
lifting_time_sec,
|
||||
lowering_time_sec
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
TPL_load,
|
||||
Engine_RPM,
|
||||
Lifting_time_Sec::numeric ,
|
||||
Lowering_time_Sec::numeric
|
||||
from mmt_staging2.iht_hls_numeric_block where ods_record=1;
|
||||
|
||||
select file_syspk into __file_syspk from mmt_staging2.IHT_HLS_H1_block;
|
||||
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_model into __model from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_make into __make from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_weight_reaction
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_hyd_lift_sensitivity
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
|
||||
567
deployment-20210427T103328Z-001/deployment/IHT/IHT_HLS_STG2.sql
Normal file
567
deployment-20210427T103328Z-001/deployment/IHT/IHT_HLS_STG2.sql
Normal file
@@ -0,0 +1,567 @@
|
||||
drop function if exists mmt_staging2.fn_IHT_HLS_block;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_IHT_HLS_block(p_client_id int,p_function_id int, p_file_format text,
|
||||
p_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS text AS $$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_format text :=p_file_format;
|
||||
declare __sheet_mnemonic text :=p_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare v_state text;
|
||||
declare v_msg text;
|
||||
declare v_detail text;
|
||||
declare v_hint text;
|
||||
declare v_context text;
|
||||
declare _error int;
|
||||
declare v_block text;
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHT_HLS_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHT
|
||||
Sheet Format: IHT_HLS
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select mmt_staging2.fn_IHT_HLS_block(p_client_id,p_function_id, p_file_format,
|
||||
p_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select mmt_staging2.fn_IHT_HLS_block(1,2,'IHT','IHT_HLS',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO mmt_staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table mmt_staging2.IHT_HLS_H1_Int;
|
||||
truncate table mmt_staging2.IHT_HLS_H1_block;
|
||||
truncate table mmt_staging2.IHT_HLS_Weight_Tyre_Int;
|
||||
truncate table mmt_staging2.IHT_HLS_Weight_Block;
|
||||
truncate table mmt_staging2.IHT_HLS_Wheel_Block;
|
||||
truncate table mmt_staging2.IHT_HLS_Numeric_Int;
|
||||
truncate table mmt_staging2.IHT_HLS_Numeric_Block;
|
||||
truncate table mmt_staging2.IHT_HLS_Tyre_Details_Block;
|
||||
truncate table mmt_staging2.IHT_HLS_Footer_Block;
|
||||
truncate table mmt_staging2.stg_specific_table_IHT_HLS;
|
||||
truncate table mmt_staging2.stg_process_table_IHT_HLS;
|
||||
|
||||
|
||||
execute 'delete from mmt_ods.fw_jobctrl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHT */
|
||||
execute 'insert into mmt_staging2.stg_specific_table_IHT_HLS
|
||||
select * from mmt_staging1.mmt_staging_generic_table a
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
|
||||
/* trimming data */
|
||||
update mmt_staging2.stg_specific_table_IHT_HLS
|
||||
set column15='Objective' where column15 like 'Objective%';
|
||||
|
||||
update mmt_staging2.stg_specific_table_IHT_HLS
|
||||
set column15='Acceptance Criteria' where column15 like 'Acceptance Criteria%';
|
||||
|
||||
update mmt_staging2.stg_specific_table_IHT_HLS set column3 = TRIM (TRAILING FROM column3 );
|
||||
update mmt_staging2.stg_specific_table_IHT_HLS set column3 = TRIM (LEADING FROM column3 );
|
||||
|
||||
update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ;
|
||||
update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ;
|
||||
update mmt_ods.mmt_config set F1_source=F1_modified ;
|
||||
update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source);
|
||||
update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source);
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from mmt_staging2.stg_specific_table_IHT_HLS b
|
||||
where trim(upper(F1_modified))=trim(upper(column3))
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update mmt_staging2.stg_specific_table_IHT_HLS a
|
||||
set is_rownumber_fetched=1
|
||||
from mmt_ods.mmt_config b
|
||||
where trim(upper(F1_modified))=trim(upper(column3))
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from mmt_ods.mmt_config b
|
||||
where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' )
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Prepared by''
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging ranks*/
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_HLS
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_HLS a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request no.''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_HLS
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_HLS a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Weight Reaction''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_HLS
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_HLS a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Numerical data''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_HLS
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_HLS a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Prepared By''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model*/
|
||||
select column6 into __model from mmt_staging2.stg_process_table_IHT_HLS a
|
||||
where rank_tag='IHT_HLS_H1' and trim(column3)='Tractor Model';
|
||||
|
||||
/*block starts - IHT_HLS_H1_BLOCK */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HLS_H1_BLOCK',__file_format,__sheet_mnemonic,1);
|
||||
v_block:='IHT_HLS_H1_BLOCK';
|
||||
|
||||
insert into mmt_staging2.IHT_HLS_H1_INT (c1,c2)
|
||||
select a.column3,column6 from mmt_staging2.stg_process_table_IHT_HLS a where rank_tag='IHT_HLS_H1';
|
||||
|
||||
insert into mmt_staging2.IHT_HLS_H1_INT (c1,c2)
|
||||
select a.column9,column12 from mmt_staging2.stg_process_table_IHT_HLS a where rank_tag='IHT_HLS_H1';
|
||||
|
||||
insert into mmt_staging2.IHT_HLS_H1_INT (c1,c2)
|
||||
select 'Objective',column15
|
||||
from mmt_staging2.stg_process_table_IHT_HLS a
|
||||
where rank_tag='IHT_HLS_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
mmt_staging2.stg_process_table_IHT_HLS a
|
||||
where column15='Objective'
|
||||
and rank_tag='IHT_HLS_H1'
|
||||
);
|
||||
|
||||
insert into mmt_staging2.IHT_HLS_H1_INT (c1,c2)
|
||||
select 'Acceptance criteria',column15
|
||||
from mmt_staging2.stg_process_table_IHT_HLS a
|
||||
where rank_tag='IHT_HLS_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
mmt_staging2.stg_process_table_IHT_HLS a
|
||||
where column15='Acceptance criteria'
|
||||
and rank_tag='IHT_HLS_H1'
|
||||
);
|
||||
|
||||
insert into mmt_staging2.IHT_HLS_H1_INT (c1,c2)
|
||||
select split_part(column3,':',1),split_part(column3,':',2)
|
||||
from mmt_staging2.stg_process_table_IHT_HLS
|
||||
where rank_tag='IHT_HLS_Numeric' and rank=6;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HLS_H1_Int set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HLS_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
insert into mmt_staging2.IHT_HLS_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM mmt_staging2.IHT_HLS_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,
|
||||
a_18 text,a_19 text);
|
||||
|
||||
|
||||
delete from mmt_staging2.IHT_HLS_H1_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_HLS_H1_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HLS_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HLS_H1_Block');
|
||||
|
||||
|
||||
insert into mmt_staging2.IHT_HLS_Weight_Tyre_Int
|
||||
(
|
||||
column3,column6,column10,column13,column15,column17,column19,
|
||||
column20,rank
|
||||
)
|
||||
select
|
||||
column3,column6,column10,column13,column15,column17,column19,
|
||||
column20,rank
|
||||
from mmt_staging2.stg_process_table_IHT_HLS a
|
||||
where rank_tag='IHT_HLS_Weight_Tyre'
|
||||
order by rank;
|
||||
|
||||
update mmt_staging2.IHT_HLS_Weight_Tyre_Int set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HLS_Weight_Tyre_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
/*block starts - IHT_HLS_Weight_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HLS_Weight_Block',__file_format,__sheet_mnemonic,2);
|
||||
v_block:='IHT_HLS_Weight_Block';
|
||||
insert into mmt_staging2.IHT_HLS_Weight_Block
|
||||
(
|
||||
dummy_f,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg,
|
||||
Front_Reaction_kg,
|
||||
Rear_Reaction_kg,
|
||||
Left_Reaction_FL_RL_kg,
|
||||
Right_reaction_FR_RR_kg,
|
||||
Front_Left_Reaction_kg,
|
||||
Front_Right_Reaction_kg,
|
||||
Rear_Left_Reaction_kg,
|
||||
Rear_Right_Reaction_kg,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column6}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column6::text]) AS val
|
||||
FROM mmt_staging2.IHT_HLS_Weight_Tyre_Int
|
||||
ORDER BY generate_series(1,15),rank,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,
|
||||
a_10 text,a_11 text);
|
||||
|
||||
delete from mmt_staging2.IHT_HLS_Weight_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_HLS_Weight_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HLS_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HLS_Weight_Block');
|
||||
|
||||
/*block starts - IHT_HLS_Tyre_Details_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HLS_Tyre_Details_Block',__file_format,__sheet_mnemonic,3);
|
||||
v_block:='IHT_HLS_Tyre_Details_Block';
|
||||
insert into mmt_staging2.IHT_HLS_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Tyre_Make,
|
||||
Tyre_size,
|
||||
Ply_Rating,
|
||||
Load_Carrying_Capacity,
|
||||
Pressure_kg_cm2,
|
||||
Dynamic_rolling_radius,
|
||||
Static_rolling_radius,
|
||||
Wheel_rim_Make_size
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column15,column19}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column15::text,column19::text]) AS val
|
||||
FROM mmt_staging2.IHT_HLS_Weight_Tyre_Int where rank between 3 and 11
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text);
|
||||
|
||||
delete from mmt_staging2.IHT_HLS_Tyre_Details_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_HLS_Tyre_Details_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HLS_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HLS_Tyre_Details_Block');
|
||||
|
||||
|
||||
/*block starts - IHT_HLS_Wheel_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HLS_Wheel_Block',__file_format,__sheet_mnemonic,4);
|
||||
v_block:='IHT_HLS_Wheel_Block';
|
||||
insert into mmt_staging2.IHT_HLS_Wheel_Block(dummy_f) values ('dummy');
|
||||
|
||||
update mmt_staging2.IHT_HLS_Wheel_Block
|
||||
set Wheel_Base=(select column13 from
|
||||
mmt_staging2.IHT_HLS_Weight_Tyre_Int
|
||||
where rank=1 and column10='Wheel Base')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Wheel_Block
|
||||
set Rear_Track_Width=(select column20 from
|
||||
mmt_staging2.IHT_HLS_Weight_Tyre_Int
|
||||
where rank=1 and column17='Rear Track Width')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HLS_Wheel_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HLS_Wheel_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HLS_Wheel_Block');
|
||||
|
||||
|
||||
/* insert IHT_HLS_Numeric_Int*/
|
||||
|
||||
insert into mmt_staging2.IHT_HLS_Numeric_Int
|
||||
(
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,rank
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,rank
|
||||
from mmt_staging2.stg_process_table_IHT_HLS a
|
||||
where rank_tag='IHT_HLS_Numeric'
|
||||
order by rank;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HLS_Numeric_Int set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HLS_Numeric_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Numeric_Int set ods_record =0 where rank in (1,6);
|
||||
|
||||
|
||||
/*block starts - IHT_HLS_Numeric_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HLS_Numeric_Block',__file_format,__sheet_mnemonic,5);
|
||||
v_block:='IHT_HLS_Numeric_Block';
|
||||
insert into mmt_staging2.IHT_HLS_Numeric_Block
|
||||
(
|
||||
dummy_f,
|
||||
TPL_load,
|
||||
Engine_RPM,
|
||||
Lifting_time_Sec,
|
||||
Lowering_time_Sec
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column5,column6,column8}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column5::text,column6::text,column8::text]) AS val
|
||||
FROM mmt_staging2.IHT_HLS_Numeric_Int
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text);
|
||||
|
||||
update mmt_staging2.iht_hls_numeric_block a
|
||||
set TPL_load= b.first_value from (SELECT
|
||||
rank,TPL_load, value_partition, first_value(TPL_load) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
TPL_load,
|
||||
sum(case when TPL_load is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.iht_hls_numeric_block
|
||||
ORDER BY rank ASC
|
||||
) as q) b;
|
||||
|
||||
delete from mmt_staging2.IHT_HLS_Numeric_Block where dummy_f is null;
|
||||
update mmt_staging2.IHT_HLS_Numeric_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HLS_Numeric_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HLS_Numeric_Block');
|
||||
|
||||
/*block starts - IHT_HLS_Footer_block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_HLS_Footer_block',__file_format,__sheet_mnemonic,6);
|
||||
v_block:='IHT_HLS_Footer_block';
|
||||
insert into mmt_staging2.IHT_HLS_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block a
|
||||
set prepared_by=( select column7 from mmt_staging2.stg_process_table_IHT_HLS b
|
||||
where b.rank_tag='IHT_HLS_Footer'
|
||||
and trim(column3)='Prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block a
|
||||
set reviewed_by=( select column7 from mmt_staging2.stg_process_table_IHT_HLS b
|
||||
where b.rank_tag='IHT_HLS_Footer'
|
||||
and trim(column3)='Reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block a
|
||||
set approved_by=( select column7 from mmt_staging2.stg_process_table_IHT_HLS b
|
||||
where b.rank_tag='IHT_HLS_Footer'
|
||||
and trim(column3)='Approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block a
|
||||
set comments=( select column3 from mmt_staging2.stg_process_table_IHT_HLS b
|
||||
where b.rank_tag='IHT_HLS_Footer'
|
||||
and rank=5 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block a
|
||||
set rev1=( select column3 from mmt_staging2.stg_process_table_IHT_HLS b
|
||||
where b.rank_tag='IHT_HLS_Footer'
|
||||
and rank=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block a
|
||||
set rev2=( select column9 from mmt_staging2.stg_process_table_IHT_HLS b
|
||||
where b.rank_tag='IHT_HLS_Footer'
|
||||
and rank=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block a
|
||||
set rev3=( select column18 from mmt_staging2.stg_process_table_IHT_HLS b
|
||||
where b.rank_tag='IHT_HLS_Footer'
|
||||
and rank=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block a
|
||||
set replaces=( select column19 from mmt_staging2.stg_process_table_IHT_HLS b
|
||||
where b.rank_tag='IHT_HLS_Footer'
|
||||
and rank=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block a
|
||||
set revision_no=( select column19 from mmt_staging2.stg_process_table_IHT_HLS b
|
||||
where b.rank_tag='IHT_HLS_Footer'
|
||||
and rank=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block a
|
||||
set prepared_date=( select column16 from mmt_staging2.stg_process_table_IHT_HLS b
|
||||
where b.rank_tag='IHT_HLS_Footer'
|
||||
and rank=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block a
|
||||
set reviewed_date=( select column16 from mmt_staging2.stg_process_table_IHT_HLS b
|
||||
where b.rank_tag='IHT_HLS_Footer'
|
||||
and rank=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block a
|
||||
set approved_date=( select column16 from mmt_staging2.stg_process_table_IHT_HLS b
|
||||
where b.rank_tag='IHT_HLS_Footer'
|
||||
and rank=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_HLS_Footer_block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_HLS_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_HLS_Footer_block');
|
||||
v_context := '';
|
||||
return v_context;
|
||||
EXCEPTION when OTHERS then
|
||||
|
||||
GET STACKED DIAGNOSTICS
|
||||
v_state = returned_sqlstate,
|
||||
v_msg = message_text,
|
||||
v_detail = pg_exception_detail,
|
||||
v_hint = pg_exception_hint,
|
||||
v_context = pg_exception_context;
|
||||
|
||||
perform mmt_insert_db_error ( __client_id, __function_id, 1001, 'Compegence',v_block,'stg2', 'test_db_error', v_state, v_msg, v_detail, v_hint, v_context);
|
||||
return v_context;
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
499
deployment-20210427T103328Z-001/deployment/IHT/IHT_NST_ODS.SQL
Normal file
499
deployment-20210427T103328Z-001/deployment/IHT/IHT_NST_ODS.SQL
Normal file
@@ -0,0 +1,499 @@
|
||||
drop function if exists mmt_staging2.fn_IHT_NST_ODS;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_IHT_NST_ODS()
|
||||
RETURNS void AS $$
|
||||
declare __test_instance_id int;
|
||||
declare __file_syspk int;
|
||||
declare __model text;
|
||||
declare __make text;
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHT_NST_ODS
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHT
|
||||
Sheet Format: IHT_NST
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select mmt_staging2.fn_IHT_NST_ODS()
|
||||
***************************************************************/
|
||||
delete from mmt_ods.test_instance where test_file_sheet_format='IHT_NST';
|
||||
delete from mmt_ods.test_instance_engine_info where test_file_sheet_format='IHT_NST';
|
||||
delete from mmt_ods.test_instance_tyre_info where test_file_sheet_format='IHT_NST';
|
||||
delete from mmt_ods.test_instance_atmospheric_info where test_file_sheet_format='IHT_NST';
|
||||
delete from mmt_ods.iht_noise_measurement_results where test_file_sheet_format='IHT_NST';
|
||||
delete from mmt_ods.iht_noise_measurement_test where test_file_sheet_format='IHT_NST';
|
||||
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='IHT_NST';
|
||||
|
||||
|
||||
|
||||
insert into mmt_ods.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
job_order_no,
|
||||
sample_receipt_date,
|
||||
test_report_no,
|
||||
generation,
|
||||
customer_name,
|
||||
test_engineer,
|
||||
test_report_date,
|
||||
no_of_sample,
|
||||
test_start_date,
|
||||
test_end_date,
|
||||
tractor_sr_no,
|
||||
test_standard_ref,
|
||||
test_location_name,
|
||||
test_operator,
|
||||
project_group,
|
||||
objective_of_test,
|
||||
test_condition
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
Test_Request_no,
|
||||
date '1899-12-30' + sample_receipt_date::int * interval '1' day as Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
date '1899-12-30' + Test_Report_Date::int * interval '1' day as Test_Report_Date,
|
||||
No_of_Sample,
|
||||
date '1899-12-30' + Test_Start_Date::int * interval '1' day as Test_Start_Date,
|
||||
date '1899-12-30' + Test_End_Date::int * interval '1' day as Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_facility,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Condition
|
||||
from
|
||||
mmt_staging2.IHT_NST_H1_block;
|
||||
|
||||
update mmt_ods.test_instance a
|
||||
set report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from mmt_staging2.iht_nst_footer_block b
|
||||
where a.test_file_sheet_format='IHT_NST';
|
||||
|
||||
insert into mmt_ods.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_load_carrying_capacity,
|
||||
tyre_wheel_rim_make_and_size
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric ,
|
||||
load_carrying_capacity,
|
||||
wheel_rim_make_size
|
||||
from mmt_staging2.iht_nst_tyre_details_block;
|
||||
|
||||
|
||||
insert into mmt_ods.test_instance_engine_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
low_idle_declared,
|
||||
low_idle_observed,
|
||||
high_idle_declared,
|
||||
high_idle_observed,
|
||||
rated_rpm,
|
||||
rated_rpm_observed,
|
||||
engine_to_pto_ratio_540_pto
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
low_idle_declared,
|
||||
low_idle_observed::numeric,
|
||||
high_idle_declared,
|
||||
high_idle_observed::numeric,
|
||||
rated_rpm_declared::numeric,
|
||||
rated_rpm_observed::numeric,
|
||||
engine_to_pto_ratio
|
||||
from mmt_staging2.iht_nst_engine_rpm_block;
|
||||
|
||||
insert into mmt_ods.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
weight_reactions_front_kg,
|
||||
tractor_weight_front_observed_kg,
|
||||
tractor_weight_front_remark,
|
||||
weight_reactions_rear_kg,
|
||||
tractor_weight_rear_observed_kg,
|
||||
tractor_weight_rear_remark,
|
||||
tractor_weight_total_kg,
|
||||
tractor_weight_total_observed_kg,
|
||||
tractor_weight_total_remark
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
front_weight_declared::numeric ,
|
||||
front_weight_observed::numeric,
|
||||
front_weight_remark,
|
||||
rear_weight_declared::numeric,
|
||||
rear_weight_observed::numeric,
|
||||
rear_weight_remark,
|
||||
total_weight_declared::numeric,
|
||||
total_weight_observed::numeric,
|
||||
total_weight_remark
|
||||
from mmt_staging2.iht_nst_weight_block;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into mmt_ods.test_instance_atmospheric_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
ambient_temp_c,
|
||||
humidity_pct,
|
||||
pressure_kpa,
|
||||
background_noise_dba,
|
||||
wind_velocity_kmph
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
ambient_temp_c::numeric,
|
||||
humidity::numeric,
|
||||
pressure_kpa::numeric,
|
||||
background_noise::numeric,
|
||||
wind_velocity
|
||||
from mmt_staging2.iht_nst_atmos_cond_block;
|
||||
|
||||
insert into mmt_ods.iht_noise_measurement_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_type,
|
||||
test_mode,
|
||||
gear,
|
||||
noise_level_1_db_a,
|
||||
noise_level_2_db_a,
|
||||
noise_level_3_db_a
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column1,
|
||||
column2,
|
||||
column3,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric
|
||||
from mmt_staging2.iht_nst_stand_noise_block where ods_record=1;
|
||||
|
||||
update mmt_ods.iht_noise_measurement_results
|
||||
set test_condition = (select column4
|
||||
from mmt_staging2.iht_nst_stand_noise_block
|
||||
where rank=3);
|
||||
|
||||
insert into mmt_ods.iht_noise_measurement_test
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
from mmt_ods.iht_noise_measurement_results where test_type='BY STANDARD NOISE';
|
||||
|
||||
update mmt_ods.iht_noise_measurement_test
|
||||
set acceptance_criteria=b.acceptance_criteria,
|
||||
remarks =b.remarks
|
||||
from mmt_staging2.iht_nst_stand_noise_block b
|
||||
where b.column1 ='BY STANDARD NOISE' and test_type='BY STANDARD NOISE';
|
||||
|
||||
insert into mmt_ods.iht_noise_measurement_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_type,
|
||||
test_mode,
|
||||
gear,
|
||||
noise_level_1_db_a,
|
||||
noise_level_2_db_a,
|
||||
noise_level_3_db_a
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column1,
|
||||
column2,
|
||||
column3,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9::numeric
|
||||
from mmt_staging2.iht_nst_stand_noise_block where ods_record=1;
|
||||
|
||||
update mmt_ods.iht_noise_measurement_results
|
||||
set test_condition = (select column7
|
||||
from mmt_staging2.iht_nst_stand_noise_block
|
||||
where rank=3) where test_condition is null;
|
||||
|
||||
insert into mmt_ods.iht_noise_measurement_test
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
from mmt_ods.iht_noise_measurement_results where test_type='BY STANDARD NOISE';
|
||||
|
||||
update mmt_ods.iht_noise_measurement_test
|
||||
set acceptance_criteria=b.acceptance_criteria,
|
||||
remarks =b.remarks
|
||||
from mmt_staging2.iht_nst_stand_noise_block b
|
||||
where b.column1 ='BY STANDARD NOISE' and test_type='BY STANDARD NOISE';
|
||||
|
||||
|
||||
|
||||
insert into mmt_ods.iht_noise_measurement_results
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_type,
|
||||
test_mode,
|
||||
gear,
|
||||
load_kg,
|
||||
speed_kmph,
|
||||
speed_rpm,
|
||||
noise_level_1_db_a,
|
||||
noise_level_2_db_a,
|
||||
noise_level_3_db_a
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column1,
|
||||
column2,
|
||||
column3,
|
||||
column4::numeric,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9::numeric
|
||||
from mmt_staging2.iht_nst_oel_noise_block where ods_record=1;
|
||||
|
||||
insert into mmt_ods.iht_noise_measurement_test
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
test_type,
|
||||
test_mode
|
||||
from mmt_ods.iht_noise_measurement_results where test_type ='OEL Noise';
|
||||
|
||||
update mmt_ods.iht_noise_measurement_test
|
||||
set acceptance_criteria=b.acceptance_criteria,
|
||||
remarks =b.remarks
|
||||
from mmt_staging2.iht_nst_oel_noise_block b
|
||||
where b.column1 ='OEL Noise' and test_type='OEL Noise';
|
||||
|
||||
delete from mmt_ods.iht_noise_measurement_test a
|
||||
using mmt_ods.iht_noise_measurement_test b
|
||||
where (a.syspk < b.syspk and
|
||||
a.test_condition is not null and
|
||||
a.test_condition =b.test_condition and
|
||||
a.test_mode =b.test_mode and a.test_type=b.test_type) or
|
||||
(a.syspk < b.syspk and a.test_condition is null and a.test_mode =b.test_mode and a.test_type=b.test_type);
|
||||
|
||||
update mmt_ods.iht_noise_measurement_results a
|
||||
set noise_measurement_id =(select syspk
|
||||
from mmt_ods.iht_noise_measurement_test b
|
||||
where (a.test_condition =b.test_condition and a.test_condition is not null and
|
||||
a.test_mode =b.test_mode and a.test_type=b.test_type) or
|
||||
(a.test_condition is null and a.test_mode =b.test_mode and a.test_type=b.test_type));
|
||||
|
||||
select file_syspk into __file_syspk from mmt_staging2.IHT_NST_H1_block;
|
||||
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_model into __model from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_make into __make from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
|
||||
update mmt_ods.test_instance_engine_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_atmospheric_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_noise_measurement_results
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_noise_measurement_test
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
|
||||
347
deployment-20210427T103328Z-001/deployment/IHT/IHT_SLL_ODS.SQL
Normal file
347
deployment-20210427T103328Z-001/deployment/IHT/IHT_SLL_ODS.SQL
Normal file
@@ -0,0 +1,347 @@
|
||||
drop function if exists mmt_staging2.fn_IHT_SLL_ODS;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_IHT_SLL_ODS()
|
||||
RETURNS void AS $$
|
||||
declare __test_instance_id int;
|
||||
declare __file_syspk int;
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHT_SLL_ODS
|
||||
Function Desc: This function populates data into ODS
|
||||
File Format: IHT
|
||||
Sheet Format: IHT_SLL
|
||||
Creation Date:
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select mmt_staging2.fn_IHT_SLL_ODS()
|
||||
***************************************************************/
|
||||
delete from mmt_ods.test_instance where test_file_sheet_format='IHT_SLL';
|
||||
delete from mmt_ods.test_instance_tractor_info where test_file_sheet_format='IHT_SLL';
|
||||
delete from mmt_ods.test_instance_tyre_info where test_file_sheet_format='IHT_SLL';
|
||||
delete from mmt_ods.test_instance_weight_reaction where test_file_sheet_format='IHT_SLL';
|
||||
delete from mmt_ods.iht_gear_max_speed where test_file_sheet_format='IHT_SLL';
|
||||
delete from mmt_ods.iht_speed_lead_lag_measurement where test_file_sheet_format='IHT_SLL';
|
||||
|
||||
|
||||
|
||||
|
||||
insert into mmt_ods.test_instance
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
job_order_no,
|
||||
sample_receipt_date,
|
||||
test_report_no,
|
||||
generation,
|
||||
customer_name,
|
||||
test_engineer,
|
||||
test_report_date,
|
||||
no_of_sample,
|
||||
test_start_date,
|
||||
test_end_date,
|
||||
tractor_sr_no,
|
||||
test_standard_ref,
|
||||
test_location_name,
|
||||
test_operator,
|
||||
project_group,
|
||||
objective_of_test,
|
||||
acceptance_criteria,
|
||||
remarks
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
Test_Request_no,
|
||||
date '1899-12-30' + sample_receipt_date::int * interval '1' day as Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
date '1899-12-30' + Test_Report_Date::int * interval '1' day as Test_Report_Date,
|
||||
No_of_Sample,
|
||||
to_date(Test_Start_Date,'DD-MM-YYYY'),
|
||||
to_date(Test_End_Date, 'DD-MM-YYYY'),
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks
|
||||
from mmt_staging2.IHT_SLL_H1_block;
|
||||
|
||||
update mmt_ods.test_instance a
|
||||
set
|
||||
report_prepared_date=to_date(b.prepared_date,'DD-MM-YYYY'),
|
||||
report_reviewed_date=to_date(b.reviewed_date,'DD-MM-YYYY'),
|
||||
report_approved_date=to_date(b.approved_date,'DD-MM-YYYY'),
|
||||
report_prepared_by=b.prepared_by,
|
||||
report_reviewed_by=b.reviewed_by,
|
||||
report_approved_by=b.approved_by,
|
||||
report_template_replaces=b.replaces,
|
||||
report_title=b.comments,
|
||||
report_template_no=b.rev1,
|
||||
report_template_rev_date=b.rev2,
|
||||
report_template_rev_no= b.rev3
|
||||
from mmt_staging2.IHT_SLL_footer_block b
|
||||
where a.test_file_sheet_format ='IHT_SLL';
|
||||
|
||||
insert into mmt_ods.test_instance_tyre_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
tyre_type,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
tyre_ply_rating,
|
||||
tyre_load_carrying_capacity,
|
||||
tyre_pressure_kg_per_cm2,
|
||||
tyre_static_rolling_radius_mm,
|
||||
tyre_dynamic_rolling_radius_mm,
|
||||
tyre_wheel_rim_make_and_size
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
tyre_details,
|
||||
tyre_make,
|
||||
tyre_size,
|
||||
ply_rating::numeric,
|
||||
load_carrying_capacity,
|
||||
Pressure_kg_cm2::numeric ,
|
||||
Dynamic_rolling_radius::numeric ,
|
||||
Static_rolling_radius::numeric ,
|
||||
wheel_rim_make_size
|
||||
from mmt_staging2.IHT_SLL_tyre_details_block;
|
||||
|
||||
insert into mmt_ods.test_instance_tractor_info
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
wheel_base_mm,
|
||||
rear_tractor_width_mm
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
wheel_base::numeric ,
|
||||
rear_track_width::numeric
|
||||
from mmt_staging2.IHT_SLL_wheel_block;
|
||||
|
||||
|
||||
/*block */
|
||||
|
||||
insert into mmt_ods.test_instance_weight_reaction
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
total_weight_kg,
|
||||
front_reaction_kg,
|
||||
rear_reaction_kg,
|
||||
left_reaction_fl_rl_kg,
|
||||
right_reaction_fr_rr_kg,
|
||||
front_left_reaction_kg,
|
||||
front_right_reactionkg,
|
||||
rear_left_reaction_kg,
|
||||
rear_right_reactionkg,
|
||||
distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg::numeric,
|
||||
Front_Reaction_kg::numeric ,
|
||||
Rear_Reaction_kg::numeric ,
|
||||
Left_Reaction_FL_RL_kg::numeric ,
|
||||
Right_reaction_FR_RR_kg::numeric ,
|
||||
Front_Left_Reaction_kg::numeric ,
|
||||
Front_Right_Reaction_kg::numeric ,
|
||||
Rear_Left_Reaction_kg::numeric ,
|
||||
Rear_Right_Reaction_kg::numeric ,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1::numeric
|
||||
from mmt_staging2.IHT_SLL_weight_block;
|
||||
|
||||
|
||||
insert into mmt_ods.iht_gear_max_speed
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
gear,
|
||||
low_1000_rpm,
|
||||
rated_2300_rpm,
|
||||
specification,
|
||||
high_2500_rpm,
|
||||
actual_speed_pct,
|
||||
diff_in_speed_kmph
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3,
|
||||
column4::numeric ,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9::numeric
|
||||
from mmt_staging2.iht_sll_forward_block where ods_record=1;
|
||||
|
||||
insert into mmt_ods.iht_gear_max_speed
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
test_condition,
|
||||
gear,
|
||||
low_1000_rpm,
|
||||
rated_2300_rpm,
|
||||
specification,
|
||||
high_2500_rpm,
|
||||
actual_speed_pct,
|
||||
diff_in_speed_kmph
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column2,
|
||||
column3,
|
||||
column4::numeric ,
|
||||
column5::numeric,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8::numeric,
|
||||
column9::numeric
|
||||
from mmt_staging2.iht_sll_reverse_block where ods_record=1;
|
||||
|
||||
insert into mmt_ods.iht_speed_lead_lag_measurement
|
||||
(
|
||||
client_id,
|
||||
function_id,
|
||||
test_file_ref_no,
|
||||
test_file_format,
|
||||
test_file_sheet_format,
|
||||
tractor_make,
|
||||
tractor_model,
|
||||
gear,
|
||||
engine_rpm,
|
||||
wheel_drive_type,
|
||||
no_of_revolution_front,
|
||||
ratio,
|
||||
lead_lag_pct
|
||||
)
|
||||
select
|
||||
client_id,
|
||||
function_id,
|
||||
file_syspk,
|
||||
file_format,
|
||||
sheet_mnemonic,
|
||||
make,model,
|
||||
column3,
|
||||
column4::numeric ,
|
||||
column5,
|
||||
column6::numeric,
|
||||
column7::numeric,
|
||||
column8
|
||||
from mmt_staging2.iht_sll_lead_lag_block where ods_record=1;
|
||||
|
||||
select file_syspk into __file_syspk from mmt_staging2.IHT_SLL_H1_block;
|
||||
select syspk into __test_instance_id from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_model into __model from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
select tractor_make into __make from mmt_ods.test_instance where test_file_ref_no =__file_syspk;
|
||||
|
||||
update mmt_ods.test_instance_tractor_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_tyre_info
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
update mmt_ods.test_instance_weight_reaction
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_gear_max_speed
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
update mmt_ods.iht_speed_lead_lag_measurement
|
||||
set test_instance_id=__test_instance_id,
|
||||
tractor_model =__model,
|
||||
tractor_make=__make
|
||||
where test_file_ref_no=__file_syspk;
|
||||
|
||||
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
|
||||
664
deployment-20210427T103328Z-001/deployment/IHT/IHT_SLL_STG2.sql
Normal file
664
deployment-20210427T103328Z-001/deployment/IHT/IHT_SLL_STG2.sql
Normal file
@@ -0,0 +1,664 @@
|
||||
drop function if exists mmt_staging2.fn_IHT_SLL_block;
|
||||
CREATE OR REPLACE FUNCTION mmt_staging2.fn_IHT_SLL_block(p_client_id int,p_function_id int, p_file_format text,
|
||||
p_sheet_mnemonic text, p_file_syspk int)
|
||||
RETURNS text AS $$
|
||||
declare __make text;
|
||||
declare __model text;
|
||||
|
||||
declare __client_id int :=p_client_id;
|
||||
declare __function_id int :=p_function_id;
|
||||
declare __file_format text :=p_file_format;
|
||||
declare __sheet_mnemonic text :=p_sheet_mnemonic;
|
||||
declare __file_syspk int :=p_file_syspk;
|
||||
declare v_state text;
|
||||
declare v_msg text;
|
||||
declare v_detail text;
|
||||
declare v_hint text;
|
||||
declare v_context text;
|
||||
declare _error int;
|
||||
declare v_block text;
|
||||
|
||||
begin
|
||||
|
||||
/************************************************************
|
||||
Function Name:fn_IHT_SLL_block
|
||||
Function Desc: This function populates data into staging 2 block
|
||||
File Format: IHT
|
||||
Sheet Format: IHT_SLL
|
||||
Creation Date: March 25 2021
|
||||
Updation Date:
|
||||
Author: compegence team
|
||||
Function Call: select mmt_staging2.fn_IHT_SLL_block(p_client_id,p_function_id, p_file_format,
|
||||
p_sheet_mnemonic, p_file_syspk)
|
||||
Function call ex: select mmt_staging2.fn_IHT_SLL_block(1,2,'IHT','IHT_SLL',456)
|
||||
***************************************************************/
|
||||
|
||||
|
||||
SET search_path TO mmt_staging2;
|
||||
|
||||
/* to process multiple files - re-runnability*/
|
||||
|
||||
truncate table mmt_staging2.IHT_SLL_H1_Int;
|
||||
truncate table mmt_staging2.IHT_SLL_H1_block;
|
||||
truncate table mmt_staging2.IHT_SLL_Weight_Tyre_Int;
|
||||
truncate table mmt_staging2.IHT_SLL_Weight_Block;
|
||||
truncate table mmt_staging2.IHT_SLL_Wheel_Block;
|
||||
truncate table mmt_staging2.IHT_SLL_Tyre_Details_Block;
|
||||
truncate table mmt_staging2.IHT_SLL_Forward_Block;
|
||||
truncate table mmt_staging2.IHT_SLL_Reverse_Block;
|
||||
truncate table mmt_staging2.IHT_SLL_Lead_Lag_Block;
|
||||
truncate table mmt_staging2.IHT_SLL_Footer_Block;
|
||||
truncate table mmt_staging2.stg_specific_table_IHT_SLL;
|
||||
truncate table mmt_staging2.stg_process_table_IHT_SLL;
|
||||
|
||||
|
||||
execute 'delete from mmt_ods.fw_jobctrl_file_sheet_block_run_schedule where file_syspk='||p_file_syspk||' and sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_number_start=null,
|
||||
row_previous_number=null,
|
||||
row_read_end=null,
|
||||
run_time=null
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* transfer data from generic to specific for IHT */
|
||||
execute 'insert into mmt_staging2.stg_specific_table_IHT_SLL
|
||||
select * from mmt_staging1.mmt_staging_generic_table a
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''
|
||||
and a.file_syspk='||p_file_syspk||'';
|
||||
|
||||
|
||||
/* trimming data */
|
||||
update mmt_staging2.stg_specific_table_IHT_SLL
|
||||
set column15='Objective' where column15 like 'Objective%';
|
||||
|
||||
update mmt_staging2.stg_specific_table_IHT_SLL
|
||||
set column15='Acceptance criteria' where column15 like 'Acceptance criteria%';
|
||||
|
||||
update mmt_staging2.stg_specific_table_IHT_SLL set column3 = TRIM (TRAILING FROM column3 );
|
||||
update mmt_staging2.stg_specific_table_IHT_SLL set column3 = TRIM (LEADING FROM column3 );
|
||||
|
||||
update mmt_ods.mmt_config set F1_modified = TRIM (TRAILING FROM F1_modified) ;
|
||||
update mmt_ods.mmt_config set F1_modified = TRIM (LEADING FROM F1_modified) ;
|
||||
update mmt_ods.mmt_config set F1_source=F1_modified ;
|
||||
update mmt_ods.mmt_config set F1_source = TRIM (TRAILING FROM F1_source);
|
||||
update mmt_ods.mmt_config set F1_source = TRIM (LEADING FROM F1_source);
|
||||
|
||||
/* keyword match in config table*/
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_number_start=(select min(b.row_number)
|
||||
from mmt_staging2.stg_specific_table_IHT_SLL b
|
||||
where trim(upper(F1_modified))=trim(upper(column3))
|
||||
and b.is_rownumber_fetched is null)
|
||||
where a.row_number_start is null
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* reverese update in process table for match*/
|
||||
execute 'update mmt_staging2.stg_specific_table_IHT_SLL a
|
||||
set is_rownumber_fetched=1
|
||||
from mmt_ods.mmt_config b
|
||||
where trim(upper(F1_modified))=trim(upper(column3))
|
||||
and b.row_number_start=a.row_number
|
||||
and is_rownumber_fetched is null
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'update mmt_ods.mmt_config a set row_previous_number=row_number_start-1
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* update config files for row numbers start, end */
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_read_end= (select b.row_number_start
|
||||
from mmt_ods.mmt_config b
|
||||
where b.syspk=a.syspk+1 and file_format='''||p_file_format||''' and sheet_mnemonic='''||p_sheet_mnemonic||''' )
|
||||
where a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* config file last field update as null otherwise it picks up next format row number*/
|
||||
execute 'update mmt_ods.mmt_config a
|
||||
set row_read_end = null ,run_time=current_timestamp
|
||||
where f1_modified =''Remarks:''
|
||||
and a.file_format='''||p_file_format||''' and a.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/* tagging ranks*/
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_SLL
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_SLL a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Test Request no.''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_SLL
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_SLL a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Weight Reaction''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_SLL
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_SLL a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''DHRUV EXPORT EACH GEAR MAX SPEED - FORWARD''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_SLL
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_SLL a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''DHRUV EXPORT EACH GEAR MAX SPEED REVERSE''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_SLL
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_SLL a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Lead / Lag Measurement on Dhruv Export 4WD''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
execute 'insert into mmt_staging2.stg_process_table_IHT_SLL
|
||||
select a.* , RANK () OVER ( ORDER BY row_number) as rank,b.rank_tag as rank_tag
|
||||
from mmt_staging2.stg_specific_table_IHT_SLL a
|
||||
join mmt_ods.mmt_config b
|
||||
on a.row_number >=row_number_start
|
||||
and (a.row_number< row_read_end or row_read_end is null)
|
||||
and f1_modified=''Remarks:''
|
||||
and b.file_format='''||p_file_format||''' and b.sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
/*selecting tractor model*/
|
||||
select column6 into __model from mmt_staging2.stg_process_table_IHT_SLL a
|
||||
where rank_tag='IHT_SLL_H1' and trim(column3)='Tractor Model';
|
||||
|
||||
/*block starts - IHT_SLL_H1_BLOCK */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_SLL_H1_BLOCK',__file_format,__sheet_mnemonic,1);
|
||||
v_block:='IHT_SLL_H1_BLOCK';
|
||||
|
||||
insert into mmt_staging2.IHT_SLL_H1_INT (c1,c2)
|
||||
select a.column3,column6 from mmt_staging2.stg_process_table_IHT_SLL a where rank_tag='IHT_SLL_H1';
|
||||
|
||||
insert into mmt_staging2.IHT_SLL_H1_INT (c1,c2)
|
||||
select a.column9,column12 from mmt_staging2.stg_process_table_IHT_SLL a where rank_tag='IHT_SLL_H1';
|
||||
|
||||
insert into mmt_staging2.IHT_SLL_H1_INT (c1,c2)
|
||||
select 'Objective',column15
|
||||
from mmt_staging2.stg_process_table_IHT_SLL a
|
||||
where rank_tag='IHT_SLL_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
mmt_staging2.stg_process_table_IHT_SLL a
|
||||
where column15='Objective'
|
||||
and rank_tag='IHT_SLL_H1'
|
||||
);
|
||||
|
||||
insert into mmt_staging2.IHT_SLL_H1_INT (c1,c2)
|
||||
select 'Acceptance criteria',column15
|
||||
from mmt_staging2.stg_process_table_IHT_SLL a
|
||||
where rank_tag='IHT_SLL_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
mmt_staging2.stg_process_table_IHT_SLL a
|
||||
where column15='Acceptance criteria'
|
||||
and rank_tag='IHT_SLL_H1'
|
||||
);
|
||||
|
||||
insert into mmt_staging2.IHT_SLL_H1_INT (c1,c2)
|
||||
select split_part(column3,':',1),split_part(column3,':',2)
|
||||
from mmt_staging2.stg_process_table_IHT_SLL
|
||||
where rank_tag='IHT_SLL_Footer' and rank=1;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_SLL_H1_Int set model=__model;
|
||||
execute 'update mmt_staging2.IHT_SLL_H1_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
insert into mmt_staging2.IHT_SLL_H1_Block
|
||||
(
|
||||
dummy_f,
|
||||
Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
Test_Report_Date,
|
||||
No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
Test_Standard_Refer,
|
||||
Test_Location,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
Remarks
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{c2}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM mmt_staging2.IHT_SLL_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,
|
||||
a_18 text,a_19 text);
|
||||
|
||||
|
||||
delete from mmt_staging2.IHT_SLL_H1_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_SLL_H1_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_SLL_H1_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_SLL_H1_Block');
|
||||
|
||||
|
||||
insert into mmt_staging2.IHT_SLL_Weight_Tyre_Int
|
||||
(
|
||||
column3,column6,column10,column11,column13,column15,column17,column19,
|
||||
column20,rank
|
||||
)
|
||||
select
|
||||
column3,column6,column10,column11,column13,column15,column17,column19,
|
||||
column20,rank
|
||||
from mmt_staging2.stg_process_table_IHT_SLL a
|
||||
where rank_tag='IHT_SLL_Weight_Tyre'
|
||||
order by rank;
|
||||
|
||||
update mmt_staging2.IHT_SLL_Weight_Tyre_Int set model=__model;
|
||||
execute 'update mmt_staging2.IHT_SLL_Weight_Tyre_Int set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
/*block starts - IHT_SLL_Weight_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_SLL_Weight_Block',__file_format,__sheet_mnemonic,2);
|
||||
v_block:='IHT_SLL_Weight_Block';
|
||||
insert into mmt_staging2.IHT_SLL_Weight_Block
|
||||
(
|
||||
dummy_f,
|
||||
Weight_Reaction,
|
||||
Total_Weight_kg,
|
||||
Front_Reaction_kg,
|
||||
Rear_Reaction_kg,
|
||||
Left_Reaction_FL_RL_kg,
|
||||
Right_reaction_FR_RR_kg,
|
||||
Front_Left_Reaction_kg,
|
||||
Front_Right_Reaction_kg,
|
||||
Rear_Left_Reaction_kg,
|
||||
Rear_Right_Reaction_kg,
|
||||
Distance_of_lifting_point_from_rear_axle_mm_d1
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column6}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column6::text]) AS val
|
||||
FROM mmt_staging2.IHT_SLL_Weight_Tyre_Int
|
||||
ORDER BY generate_series(1,15),rank,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text,
|
||||
a_10 text,a_11 text);
|
||||
|
||||
delete from mmt_staging2.IHT_SLL_Weight_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_SLL_Weight_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_SLL_Weight_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_SLL_Weight_Block');
|
||||
|
||||
/*block starts - IHT_SLL_Tyre_Details_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_SLL_Tyre_Details_Block',__file_format,__sheet_mnemonic,3);
|
||||
v_block:='IHT_SLL_Tyre_Details_Block';
|
||||
insert into mmt_staging2.IHT_SLL_Tyre_Details_Block
|
||||
(
|
||||
dummy_f,
|
||||
Tyre_Details,
|
||||
Tyre_Make,
|
||||
Tyre_size,
|
||||
Ply_Rating,
|
||||
Load_Carrying_Capacity,
|
||||
Pressure_kg_cm2,
|
||||
Dynamic_rolling_radius,
|
||||
Static_rolling_radius,
|
||||
Wheel_rim_Make_size
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column15,column19}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column15::text,column19::text]) AS val
|
||||
FROM mmt_staging2.IHT_SLL_Weight_Tyre_Int where rank between 3 and 11
|
||||
ORDER BY generate_series(1,15),2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,a_9 text);
|
||||
|
||||
delete from mmt_staging2.IHT_SLL_Tyre_Details_Block where dummy_f is null ;
|
||||
update mmt_staging2.IHT_SLL_Tyre_Details_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_SLL_Tyre_Details_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_SLL_Tyre_Details_Block');
|
||||
|
||||
|
||||
/*block starts - IHT_SLL_Wheel_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_SLL_Wheel_Block',__file_format,__sheet_mnemonic,4);
|
||||
v_block:='IHT_SLL_Wheel_Block';
|
||||
insert into mmt_staging2.IHT_SLL_Wheel_Block(dummy_f) values ('dummy');
|
||||
|
||||
update mmt_staging2.IHT_SLL_Wheel_Block
|
||||
set Wheel_Base=(select column13 from
|
||||
mmt_staging2.IHT_SLL_Weight_Tyre_Int
|
||||
where rank=1 and column10='Wheel Base')
|
||||
where dummy_f='dummy';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Wheel_Block
|
||||
set Rear_Track_Width=(select column20 from
|
||||
mmt_staging2.IHT_SLL_Weight_Tyre_Int
|
||||
where rank=1 and column17='Rear Track Width')
|
||||
where dummy_f='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_SLL_Wheel_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_SLL_Wheel_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_SLL_Wheel_Block');
|
||||
|
||||
/*block starts - IHT_SLL_Forward_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_SLL_Forward_Block',__file_format,__sheet_mnemonic,5);
|
||||
v_block:='IHT_SLL_Forward_Block';
|
||||
|
||||
insert into mmt_staging2.IHT_SLL_Forward_Block
|
||||
(
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,rank
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,column9,rank
|
||||
from mmt_staging2.stg_process_table_IHT_SLL a
|
||||
where rank_tag='IHT_SLL_Forward'
|
||||
order by rank;
|
||||
|
||||
update mmt_staging2.IHT_SLL_Forward_Block
|
||||
set column2=(select split_part(column3,'-',2)
|
||||
from mmt_staging2.IHT_SLL_Forward_Block where rank =1);
|
||||
|
||||
update mmt_staging2.IHT_SLL_Forward_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_SLL_Forward_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Forward_Block set ods_record =0 where rank in (1,2);
|
||||
|
||||
|
||||
/*block starts - IHT_SLL_Forward_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_SLL_Forward_Block',__file_format,__sheet_mnemonic,6);
|
||||
|
||||
v_block:='IHT_SLL_Forward_Block';
|
||||
|
||||
insert into mmt_staging2.IHT_SLL_Reverse_Block
|
||||
(
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,rank
|
||||
)
|
||||
select
|
||||
column2,column3,column4,column5,column6,column7,
|
||||
column8,column9,rank
|
||||
from mmt_staging2.stg_process_table_IHT_SLL a
|
||||
where rank_tag='IHT_SLL_Reverse'
|
||||
order by rank;
|
||||
|
||||
update mmt_staging2.iht_sll_reverse_block
|
||||
set column2=(select split_part(column3,' ',7)
|
||||
from mmt_staging2.iht_sll_reverse_block where rank =1);
|
||||
|
||||
update mmt_staging2.IHT_SLL_Reverse_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_SLL_Reverse_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Reverse_Block set ods_record =0 where rank in (1,2);
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_SLL_Reverse_Block');
|
||||
|
||||
/*block starts - IHT_SLL_Lead_Lag_Block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_SLL_Lead_Lag_Block',__file_format,__sheet_mnemonic,7);
|
||||
v_block='IHT_SLL_Lead_Lag_Block';
|
||||
insert into mmt_staging2.IHT_SLL_Lead_Lag_Block
|
||||
(
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,rank
|
||||
)
|
||||
select
|
||||
column3,column4,column5,column6,column7,
|
||||
column8,rank
|
||||
from mmt_staging2.stg_process_table_IHT_SLL a
|
||||
where rank_tag='IHT_SLL_Lead_Lag'
|
||||
order by rank;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_SLL_Lead_Lag_Block a
|
||||
set column3= b.first_value from (SELECT
|
||||
rank, column3, value_partition, first_value(column3) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
column3,
|
||||
sum(case when column3 is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.IHT_SLL_Lead_Lag_Block
|
||||
ORDER BY rank ASC
|
||||
) as q) b where a.rank = b.rank;
|
||||
|
||||
update mmt_staging2.IHT_SLL_Lead_Lag_Block a
|
||||
set column4= b.first_value from (SELECT
|
||||
rank, column4, value_partition, first_value(column4) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
column4,
|
||||
sum(case when column4 is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.IHT_SLL_Lead_Lag_Block
|
||||
ORDER BY rank ASC
|
||||
) as q) b where a.rank = b.rank;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_SLL_Lead_Lag_Block a
|
||||
set column7= b.first_value from (SELECT
|
||||
rank, column7, value_partition, first_value(column7) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
column7,
|
||||
sum(case when column7 is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.IHT_SLL_Lead_Lag_Block
|
||||
ORDER BY rank ASC
|
||||
) as q) b where a.rank = b.rank;
|
||||
|
||||
|
||||
update mmt_staging2.IHT_SLL_Lead_Lag_Block a
|
||||
set column8= b.first_value from (SELECT
|
||||
rank, column8, value_partition, first_value(column8) over (partition by value_partition order by rank)
|
||||
FROM (
|
||||
SELECT
|
||||
rank,
|
||||
column8,
|
||||
sum(case when column8 is null then 0 else 1 end) over (order by rank) as value_partition
|
||||
FROM mmt_staging2.IHT_SLL_Lead_Lag_Block
|
||||
ORDER BY rank ASC
|
||||
) as q) b where a.rank = b.rank;
|
||||
|
||||
update mmt_staging2.IHT_SLL_Lead_Lag_Block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_SLL_Lead_Lag_Block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
|
||||
|
||||
update mmt_staging2.IHT_SLL_Lead_Lag_Block set ods_record =0 where rank in (1,2,3);
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_SLL_Lead_Lag_Block');
|
||||
|
||||
/*block starts - IHT_SLL_Footer_block */
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
'IHT_SLL_Footer_block',__file_format,__sheet_mnemonic,8);
|
||||
v_block:='IHT_SLL_Footer_block';
|
||||
insert into mmt_staging2.IHT_SLL_Footer_block(dummy_f) values ('dummy');
|
||||
|
||||
update mmt_staging2.IHT_SLL_Footer_block a
|
||||
set prepared_by=( select column7 from mmt_staging2.stg_process_table_IHT_SLL b
|
||||
where b.rank_tag='IHT_SLL_Footer'
|
||||
and trim(column3)='Prepared by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Footer_block a
|
||||
set reviewed_by=( select column7 from mmt_staging2.stg_process_table_IHT_SLL b
|
||||
where b.rank_tag='IHT_SLL_Footer'
|
||||
and trim(column3)='Reviewed by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Footer_block a
|
||||
set approved_by=( select column7 from mmt_staging2.stg_process_table_IHT_SLL b
|
||||
where b.rank_tag='IHT_SLL_Footer'
|
||||
and trim(column3)='Approved by' )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Footer_block a
|
||||
set comments=( select column3 from mmt_staging2.stg_process_table_IHT_SLL b
|
||||
where b.rank_tag='IHT_SLL_Footer'
|
||||
and rank=5 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Footer_block a
|
||||
set rev1=( select column3 from mmt_staging2.stg_process_table_IHT_SLL b
|
||||
where b.rank_tag='IHT_SLL_Footer'
|
||||
and rank=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
|
||||
update mmt_staging2.IHT_SLL_Footer_block a
|
||||
set rev2=( select column9 from mmt_staging2.stg_process_table_IHT_SLL b
|
||||
where b.rank_tag='IHT_SLL_Footer'
|
||||
and rank=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Footer_block a
|
||||
set rev3=( select column18 from mmt_staging2.stg_process_table_IHT_SLL b
|
||||
where b.rank_tag='IHT_SLL_Footer'
|
||||
and rank=6 )
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Footer_block a
|
||||
set replaces=( select column19 from mmt_staging2.stg_process_table_IHT_SLL b
|
||||
where b.rank_tag='IHT_SLL_Footer'
|
||||
and rank=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Footer_block a
|
||||
set revision_no=( select column19 from mmt_staging2.stg_process_table_IHT_SLL b
|
||||
where b.rank_tag='IHT_SLL_Footer'
|
||||
and rank=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Footer_block a
|
||||
set prepared_date=( select column16 from mmt_staging2.stg_process_table_IHT_SLL b
|
||||
where b.rank_tag='IHT_SLL_Footer'
|
||||
and rank=1)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Footer_block a
|
||||
set reviewed_date=( select column16 from mmt_staging2.stg_process_table_IHT_SLL b
|
||||
where b.rank_tag='IHT_SLL_Footer'
|
||||
and rank=2)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Footer_block a
|
||||
set approved_date=( select column16 from mmt_staging2.stg_process_table_IHT_SLL b
|
||||
where b.rank_tag='IHT_SLL_Footer'
|
||||
and rank=3)
|
||||
where dummy_F='dummy';
|
||||
|
||||
update mmt_staging2.IHT_SLL_Footer_block set model=__model;
|
||||
execute 'update mmt_staging2.IHT_SLL_Footer_block set
|
||||
client_id='||p_client_id||',
|
||||
function_id='||p_function_id||',
|
||||
file_syspk='||p_file_syspk||',
|
||||
file_format='''||p_file_format||''',
|
||||
sheet_mnemonic='''||p_sheet_mnemonic||'''';
|
||||
|
||||
perform mmt_staging2.fn_jobctrl_block_end(__file_syspk,'IHT_SLL_Footer_block');
|
||||
v_context := '';
|
||||
return v_context;
|
||||
EXCEPTION when OTHERS then
|
||||
|
||||
GET STACKED DIAGNOSTICS
|
||||
v_state = returned_sqlstate,
|
||||
v_msg = message_text,
|
||||
v_detail = pg_exception_detail,
|
||||
v_hint = pg_exception_hint,
|
||||
v_context = pg_exception_context;
|
||||
|
||||
perform mmt_insert_db_error ( __client_id, __function_id, 1001, 'Compegence',v_block,'stg2', 'test_db_error', v_state, v_msg, v_detail, v_hint, v_context);
|
||||
return v_context;
|
||||
end
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
Reference in New Issue
Block a user