This commit is contained in:
dheepa
2021-08-09 11:14:23 +00:00
parent a0d3257be0
commit f3cf5e1d2d
89 changed files with 4769 additions and 1508 deletions

View File

@@ -105,7 +105,7 @@ end if;
continue;
end if;
perform archive.fn_run_block_archive(w_client_id, w_function_id);
--run transactional scripts depending on sheet mnemonic
if f.file_sheet_mnemonic = 'FTDRY_TRS' then
@@ -189,6 +189,9 @@ end if;
end if;
end loop;
perform transactional.fn_run_updates(w_client_id, w_function_id);
-- update fw_jobctl_file_runschedule table.
update fw_core.fw_jobctl_file_runschedule set end_status_note = 'stg2_failed', end_status='error',staging_type = 'stg2',end_time=now() from fw_core.fw_jobctl_file_sheet_runschedule a
@@ -206,14 +209,10 @@ SELECT SUM (case WHEN end_status = 'success' THEN 1
if (success_sum > 0 or success_sum is null) then
update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'trx_completed', end_status='success', end_time=now() where job_id = w_job_id and step_id = w_step_id and latest_runschedule_flag = '1';
else
update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'trx_failed', end_status='error', end_time=now() where job_id = w_job_id and step_id = w_step_id and latest_runschedule_flag = '1';
update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'trx_failed', end_status='success', end_time=now() where job_id = w_job_id and step_id = w_step_id and latest_runschedule_flag = '1';
end if;
--insert into fw_core.track_jobstep select *,'master_wrapper' from fw_core.fw_jobctl_runschedule_jobstep;
--insert into fw_core.track_file select *,'mater_wrapper' from fw_core.fw_jobctl_file_runschedule;
--insert into fw_core.track_file_sheet select *,'master_wrapper' from fw_core.fw_jobctl_file_sheet_runschedule;
end;
$$ LANGUAGE plpgsql;

163
onetime/wrappers/wrapper.sql Executable file
View File

@@ -0,0 +1,163 @@
CREATE OR REPLACE FUNCTION fw_ods.fn_fw_ods_load(p_client_id int,p_function_id int,p_job_id int,p_step_id int)
RETURNS void
AS $$
declare
f record;
w_job_id int := p_job_id;
w_step_id int := p_step_id;
w_function_id int := p_function_id;
w_client_id int := p_client_id;
w_file_sheet_mnemonic text := 'Sheets';
begin
for f in select distinct file_syspk, file_mnemonic
from fw_core.fw_jobctl_file_runschedule
where latest_runschedule_flag = '1' and
end_status = 'success' and
end_status_note = 'TRX_completed'
order by file_syspk
loop
if f.file_mnemonic in ('FTDRY', 'FTWET', 'FTHLG')
then
perform fw_core.fn_get_function_exception('fw_ods.fn_fw_ods_field_load('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||w_file_sheet_mnemonic||''','||f.file_syspk||')');
perform fw_core.fn_get_function_exception('fw_ods.fn_fw_ods_implement_details_update('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||w_file_sheet_mnemonic||''','||f.file_syspk||')');
perform fw_core.fn_get_function_exception('fw_ods.fn_fw_ods_comments_load('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||w_file_sheet_mnemonic||''','||f.file_syspk||')');
SET search_path To fw_ods;
drop extension tablefunc;
CREATE extension tablefunc;
perform fw_core.fn_get_function_exception('fw_ods.fn_fw_ods_observations_load('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||w_file_sheet_mnemonic||''','||f.file_syspk||')');
SET search_path To staging2;
drop extension tablefunc;
CREATE extension tablefunc;
elsif f.file_mnemonic ='PTO' then
perform fw_core.fn_get_function_exception('fw_ods.fn_fw_ods_PTO_load('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||w_file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_mnemonic = 'BUDNI' then
perform fw_core.fn_get_function_exception('fw_ods.fn_fw_ods_budni_load('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||w_file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_mnemonic in ('PTOBEN', 'PTOSTD') then
perform fw_core.fn_get_function_exception('fw_ods.fn_fw_ods_PTO_load('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||w_file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_mnemonic in ('IHTBT30','IHTBT50','IHTBTD','IHTCGM','IHTHAM','IHTEMT','IHTHLS','IHTNST','IHTSLL') then
perform fw_core.fn_get_function_exception('fw_ods.fn_fw_ods_IHT_load('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||w_file_sheet_mnemonic||''','||f.file_syspk||')');
perform fw_core.fn_get_function_exception('fw_ods.fn_fw_ods_detailed_load('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||w_file_sheet_mnemonic||''','||f.file_syspk||')');
elsif f.file_mnemonic in ('DBOECD', 'DBSTD') then
perform fw_core.fn_get_function_exception('fw_ods.fn_fw_ods_drawbar_performance_load('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||w_file_sheet_mnemonic||''','||f.file_syspk||')');
perform fw_core.fn_get_function_exception('fw_ods.fn_fw_ods_drawbar_load('||w_client_id||','||w_function_id||','''||f.file_mnemonic||''','''||w_file_sheet_mnemonic||''','||f.file_syspk||')');
end if;
end loop;
update fw_ods.fw_ods set tractor_model=REGEXP_REPLACE(tractor_model,'\r|\n','','g');
update fw_ods.fw_ods set tractor_make = m.target_value from fw_ods.fw_ods_misnomer m where trim(tractor_make) = m.source_value ;
update fw_ods.fw_ods set tractor_model = m.target_value from fw_ods.fw_ods_misnomer m where trim(tractor_model) = m.source_value ;
update fw_ods.fw_ods set wheel_drive_type = m.target_value from fw_ods.fw_ods_misnomer m where trim(wheel_drive_type) = m.source_value ;
update fw_ods.fw_ods set name_of_implement = m.target_value from fw_ods.fw_ods_misnomer m where trim(name_of_implement) = m.source_value ;
update fw_ods.fw_ods set type_of_implement = m.target_value from fw_ods.fw_ods_misnomer m where trim(type_of_implement) = m.source_value ;
update fw_ods.fw_ods set "configuration" = m."configuration",
tractor_engine_hp = m.tractor_engine_hp, wheel_drive_type=m.wheel_drive_type,platform = m.platform,tractor_make = m.tractor_make
from fw_ods.tractor_info m where fw_ods.fw_ods.tractor_model = m.tractor_model;
update fw_ods.fw_ods_comments set tractor_model=REGEXP_REPLACE(tractor_model,'\r|\n','','g');
update fw_ods.fw_ods_comments set tractor_make = m.target_value from fw_ods.fw_ods_misnomer m where trim(tractor_make) = m.source_value ;
update fw_ods.fw_ods_comments set tractor_model = m.target_value from fw_ods.fw_ods_misnomer m where trim(tractor_model) = m.source_value ;
update fw_ods.fw_ods_comments set wheel_drive_type = m.target_value from fw_ods.fw_ods_misnomer m where trim(wheel_drive_type) = m.source_value ;
update fw_ods.fw_ods_comments set name_of_implement = m.target_value from fw_ods.fw_ods_misnomer m where trim(name_of_implement) = m.source_value ;
update fw_ods.fw_ods_comments set type_of_implement = m.target_value from fw_ods.fw_ods_misnomer m where trim(type_of_implement) = m.source_value ;
update fw_ods.fw_ods_drawbar_performance set tractor_model=REGEXP_REPLACE(tractor_model,'\r|\n','','g');
update fw_ods.fw_ods_drawbar_performance set tractor_make = m.target_value from fw_ods.fw_ods_misnomer m where trim(tractor_make) = m.source_value ;
update fw_ods.fw_ods_drawbar_performance set tractor_model = m.target_value from fw_ods.fw_ods_misnomer m where trim(tractor_model) = m.source_value ;
update fw_ods.fw_ods_drawbar_performance set wheel_drive_type = m.target_value from fw_ods.fw_ods_misnomer m where trim(wheel_drive_type) = m.source_value ;
-- update fw_ods.fw_ods_drawbar_performance set name_of_implement = m.target_value from fw_ods.fw_ods_misnomer m where trim(name_of_implement) = m.source_value ;
--update fw_ods.fw_ods_drawbar_performance set type_of_implement = m.target_value from fw_ods.fw_ods_misnomer m where trim(type_of_implement) = m.source_value ;
update fw_ods.fw_ods_drawbar_performance set "configuration" = m."configuration",
tractor_engine_hp = m.tractor_engine_hp, wheel_drive_type=m.wheel_drive_type,platform = m.platform,tractor_make = m.tractor_make
from fw_ods.tractor_info m where fw_ods.fw_ods_drawbar_performance.tractor_model = m.tractor_model;
update fw_ods.fw_ods_comments set "configuration" = m."configuration",
tractor_engine_hp = m.tractor_engine_hp, wheel_drive_type=m.wheel_drive_type,platform = m.platform,tractor_make = m.tractor_make
from fw_ods.tractor_info m where fw_ods.fw_ods_comments.tractor_model = m.tractor_model;
update fw_ods.fw_ods_detailed set tractor_model=REGEXP_REPLACE(tractor_model,'\r|\n','','g');
update fw_ods.fw_ods_detailed set tractor_make = m.target_value from fw_ods.fw_ods_misnomer m where trim(tractor_make) = m.source_value ;
update fw_ods.fw_ods_detailed set tractor_model = m.target_value from fw_ods.fw_ods_misnomer m where trim(tractor_model) = m.source_value ;
update fw_ods.fw_ods_detailed set wheel_drive_type = m.target_value from fw_ods.fw_ods_misnomer m where trim(wheel_drive_type) = m.source_value ;
-- update fw_ods.fw_ods_detailed set name_of_implement = m.target_value from fw_ods.fw_ods_misnomer m where trim(name_of_implement) = m.source_value ;
--update fw_ods.fw_ods_detailed set type_of_implement = m.target_value from fw_ods.fw_ods_misnomer m where trim(type_of_implement) = m.source_value ;
update fw_ods.fw_ods_detailed set "configuration" = m."configuration",
tractor_engine_hp = m.tractor_engine_hp, wheel_drive_type=m.wheel_drive_type,platform = m.platform,tractor_make = m.tractor_make
from fw_ods.tractor_info m where fw_ods.fw_ods_detailed.tractor_model = m.tractor_model;
update fw_ods.fw_ods_observations set tractor_model=REGEXP_REPLACE(tractor_model,'\r|\n','','g');
update fw_ods.fw_ods_observations set tractor_make = m.target_value from fw_ods.fw_ods_misnomer m where trim(tractor_make) = m.source_value ;
update fw_ods.fw_ods_observations set tractor_model = m.target_value from fw_ods.fw_ods_misnomer m where trim(tractor_model) = m.source_value ;
update fw_ods.fw_ods_observations set wheel_drive_type = m.target_value from fw_ods.fw_ods_misnomer m where trim(wheel_drive_type) = m.source_value ;
update fw_ods.fw_ods_observations set name_of_implement = m.target_value from fw_ods.fw_ods_misnomer m where trim(name_of_implement) = m.source_value ;
update fw_ods.fw_ods_observations set type_of_implement = m.target_value from fw_ods.fw_ods_misnomer m where trim(type_of_implement) = m.source_value ;
update fw_ods.fw_ods_observations set "configuration" = m."configuration",
tractor_engine_hp = m.tractor_engine_hp, wheel_drive_type=m.wheel_drive_type,platform = m.platform,tractor_make = m.tractor_make
from fw_ods.tractor_info m where fw_ods.fw_ods_observations.tractor_model = m.tractor_model;
update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'TRX_completed', end_status='success', end_time=now() where job_id = p_job_id and step_id = p_step_id and latest_runschedule_flag = '1';
end
$$
LANGUAGE plpgsql;