VBGO#74320 -- Ruimte en werkplekken overzetten van VENR naar VBGO

svn path=/Customer/; revision=57803
This commit is contained in:
Arthur Egberink
2022-10-31 14:26:40 +00:00
parent 5d9d480705
commit 8f1abb857f
2 changed files with 546 additions and 0 deletions

View File

@@ -0,0 +1,276 @@
--
-- $Id$
--
-- Script om ruimtereserveringen over te zetten van de VENR omgeving naar de VBGO omgeving.
--
DEFINE thisfile = 'VBGO#74320_ruimte.SQL'
DEFINE dbuser = '^VBGO'
SET ECHO ON
SET DEFINE ON
COLUMN fcltlogfile NEW_VALUE fcltlogfile NOPRINT;
COLUMN fcltcusterr NEW_VALUE fcltcusterr NOPRINT;
WHENEVER SQLERROR CONTINUE;
SELECT adm.getscriptspoolfile('&thisfile') AS fcltlogfile FROM DUAL;
SPOOL &fcltlogfile
WHENEVER SQLERROR EXIT;
SELECT adm.checkscriptcust('&dbuser') AS fcltcusterr FROM DUAL;
WHENEVER SQLERROR CONTINUE;
PROMPT &fcltcusterr
SET DEFINE OFF
------ payload begin ------
/* Select om de data uit de VENR omgeving in Excel te zetten
SELECT DISTINCT res_reservering_key,
res_rsv_ruimte_volgnr,
res_ruimte_nr,
res_rsv_ruimte_omschrijving,
REPLACE(res_rsv_ruimte_opmerking, CHR(10)),
TO_CHAR(res_rsv_ruimte_van, 'dd-mm-yyyy hh24:mi:ss') res_rsv_ruimte_van,
TO_CHAR(res_rsv_ruimte_tot, 'dd-mm-yyyy hh24:mi:ss') res_rsv_ruimte_tot,
pg.prs_perslid_email,
pc.prs_perslid_email,
res_rsv_ruimte_bezoekers
FROM res_rsv_ruimte rrr,
res_ruimte_opstelling rro,
res_ruimte rr,
prs_perslid pg,
prs_perslid pc,
res_alg_ruimte rar,
alg_v_ruimte_gegevens rg
WHERE rrr.res_ruimte_opstel_key = rro.res_ruimte_opstel_key
AND rro.res_ruimte_key = rr.res_ruimte_key
AND rrr.res_rsv_ruimte_host_key = pg.prs_perslid_key
AND rrr.res_rsv_ruimte_contact_key = pc.prs_perslid_key
AND rr.res_ruimte_key = rar.res_ruimte_key
AND rar.alg_ruimte_key = rg.alg_ruimte_key
AND rrr.res_rsv_ruimte_van > TO_DATE ('20221101', 'YYYYMMDD')
AND rg.alg_locatie_key = 1421
AND rrr.res_rsv_ruimte_verwijder IS NULL;
*/
DECLARE
CURSOR c IS
SELECT REPLACE (fac_imp_csv_col01, '.')
res_reservering_key,
fac_imp_csv_col02
res_rsv_ruimte_volgnr,
DECODE(fac_imp_csv_col03, 'HTC5 - A - The Facility Farm', 'The Facility Farm',
'HTC5 - B - The Service Room', 'The Service Room',
'HTC5 - C - The Hospitality Hub', 'The Hospitality Hub',
'HTC5 - D - The Incubator', 'The Incubator',
'HTC5 - E - The Leisure Loft', 'The Leisure Loft',
'HTC5 - F - The Tender Pit', 'The Tender Pit',
'HTC5 - G - The Community Club', 'The Community Club',
'HTC5 - H - The Sustainability Shack', 'The Sustainability Shack',
'HTC5 - Vergaderruimte D en E gekoppeld', 'The Incubator en The Leisure Loft')
res_ruimte_nr,
fac_imp_csv_col04
res_rsv_ruimte_omschrijving,
fac_imp_csv_col05
res_rsv_ruimte_opmerking,
TO_DATE (fac_imp_csv_col06, 'dd-mm-yyyy hh24:mi:ss')
res_rsv_ruimte_van,
TO_DATE (fac_imp_csv_col07, 'dd-mm-yyyy hh24:mi:ss')
res_rsv_ruimte_tot,
fac_imp_csv_col08
prs_perslid_email_host,
fac_imp_csv_col09
prs_perslid_email_cont,
fac_imp_csv_col10
res_rsv_ruimte_bezoekers
FROM fac_imp_csv
WHERE fac_imp_csv_col01 <> 'res_reservering_key'
ORDER BY res_reservering_key, FAC.safe_to_number(res_rsv_ruimte_volgnr);
v_ruimte_opstel_key NUMBER;
v_perslid_key_host NUMBER;
v_perslid_key_contact NUMBER;
v_res_ruimte_nr VARCHAR2 (200);
v_res_ruimte_key NUMBER;
v_rsv_ruimte_key NUMBER;
v_reservering_key NUMBER;
v_opmerking VARCHAR2 (200);
v_conversie_txt VARCHAR2 (1000);
v_old_reservering_key NUMBER;
v_volgnr NUMBER;
v_aanduiding VARCHAR2 (100);
v_errorhint VARCHAR2 (1000);
v_errormsg VARCHAR2 (1000);
oracle_err_num NUMBER;
oracle_err_mes VARCHAR2 (200);
BEGIN
BEGIN
v_old_reservering_key := -1;
v_volgnr := 1;
FOR rec IN c
LOOP
BEGIN
v_opmerking := NULL;
v_conversie_txt := NULL;
v_aanduiding :=
'VENR nummer: '
|| rec.res_reservering_key
|| '/'
|| rec.res_rsv_ruimte_volgnr;
v_errorhint :=
'Opzoeken reserveerbare ruimte: ' || rec.res_ruimte_nr;
v_conversie_txt := v_aanduiding || CHR (10);
SELECT res_ruimte_key
INTO v_res_ruimte_key
FROM res_ruimte
WHERE res_ruimte_verwijder IS NULL
AND res_ruimte_nr = rec.res_ruimte_nr;
v_errorhint := 'Opzoeken opstelling: ' || rec.res_ruimte_nr;
SELECT res_ruimte_opstel_key
INTO v_ruimte_opstel_key
FROM res_ruimte_opstelling
WHERE res_ruimte_opstel_verwijder IS NULL
AND res_opstelling_key = 1 -- standaard
AND res_ruimte_key = v_res_ruimte_key;
v_errormsg := 'Fout bij opzoeken host: ' || rec.prs_perslid_email_host;
SELECT MAX (prs_perslid_key)
INTO v_perslid_key_host
FROM prs_perslid
WHERE prs_perslid_verwijder IS NULL
AND LOWER (prs_perslid_email) =
LOWER (rec.prs_perslid_email_host);
IF v_perslid_key_host IS NULL
THEN
v_perslid_key_host := 3; -- Facilitor
--fac.imp_writelog (p_import_key, 'W', v_errormsg, '');
fac.writelog ('IMP_RES', 'W', v_errormsg, '');
v_conversie_txt := v_conversie_txt ||
'Host niet gevonden: '
|| rec.prs_perslid_email_host
|| CHR (10);
END IF;
v_errormsg := 'Fout bij opzoeken contact: ' || rec.prs_perslid_email_cont;
SELECT MAX (prs_perslid_key)
INTO v_perslid_key_contact
FROM prs_perslid
WHERE prs_perslid_verwijder IS NULL
AND LOWER (prs_perslid_email) =
LOWER (rec.prs_perslid_email_cont);
IF v_perslid_key_contact IS NULL
THEN
v_perslid_key_contact := 3; -- Facilitor
--fac.imp_writelog (p_import_key, 'W', v_errormsg, '');
fac.writelog ('IMP_RES', 'W', v_errormsg, '');
v_conversie_txt := v_conversie_txt ||
'Contact niet gevonden: '
|| rec.prs_perslid_email_cont
|| CHR (10);
END IF;
IF v_old_reservering_key <> rec.res_reservering_key
THEN
INSERT INTO res_reservering (res_reservering_verwijder)
VALUES (NULL)
RETURNING res_reservering_key
INTO v_reservering_key;
v_volgnr := 1;
v_old_reservering_key := rec.res_reservering_key;
ELSE
v_volgnr := v_volgnr + 1;
END IF;
v_errormsg := 'Fout toevoegen rsv_ruimte.';
INSERT INTO res_rsv_ruimte (res_reservering_key,
res_rsv_ruimte_volgnr,
res_rsv_ruimte_opmerking,
res_rsv_ruimte_omschrijving,
prs_kostenplaats_key,
res_rsv_ruimte_contact_key,
res_rsv_ruimte_host_key,
res_ruimte_opstel_key,
res_activiteit_key,
res_rsv_ruimte_van,
res_rsv_ruimte_tot,
res_rsv_ruimte_bezoekers,
res_status_fo_key,
res_status_bo_key)
VALUES (v_reservering_key,
v_volgnr,
v_conversie_txt || rec.res_rsv_ruimte_opmerking,
rec.res_rsv_ruimte_omschrijving,
NULL,
v_perslid_key_contact,
v_perslid_key_host,
v_ruimte_opstel_key,
10, -- vergadering
rec.res_rsv_ruimte_van,
rec.res_rsv_ruimte_tot,
rec.res_rsv_ruimte_bezoekers,
2,
2)
RETURNING res_rsv_ruimte_key
INTO v_rsv_ruimte_key;
FAC.trackaction ('RESNEW',
v_rsv_ruimte_key,
3,
SYSDATE,
'Aangemaakt door conversie uit VENR');
RES.set_ruimte_dirty (v_rsv_ruimte_key);
--fac.imp_writelog (p_import_key, 'I', 'Reservering is aangemaakt: ' || v_rsv_ruimte_key, v_aanduiding);
fac.writelog ('IMP_RES', 'I', 'Reservering is aangemaakt: ' || v_rsv_ruimte_key, v_aanduiding);
EXCEPTION
WHEN OTHERS
THEN
oracle_err_num := SQLCODE;
oracle_err_mes := SUBSTR (SQLERRM, 1, 100);
v_errormsg :=
'OTHERS (error '
|| oracle_err_num
|| '/'
|| oracle_err_mes
|| ')';
--fac.imp_writelog (p_import_key, 'E', v_aanduiding || v_errormsg, v_errorhint);
fac.writelog ('IMP_RES', 'E', v_aanduiding || v_errormsg, v_errorhint);
END;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
oracle_err_num := SQLCODE;
oracle_err_mes := SUBSTR (SQLERRM, 1, 100);
v_errormsg :=
'OTHERS (error '
|| oracle_err_num
|| '/'
|| oracle_err_mes
|| ')';
--fac.imp_writelog (p_import_key, 'E', v_aanduiding || v_errormsg, v_errorhint);
fac.writelog ('IMP_RES', 'E', v_aanduiding || v_errormsg, v_errorhint);
END;
END;
/
------ payload end ------
SET DEFINE OFF
BEGIN adm.systrackscriptId ('$Id$', 1); END;
/
COMMIT;
SET ECHO OFF
SPOOL OFF
SET DEFINE ON
PROMPT Logfile of this upgrade is: &fcltlogfile

View File

@@ -0,0 +1,270 @@
--
-- $Id$
--
-- Script om werkplekreserveringen over te zetten van de VENR omgeving naar de VBGO omgeving.
--
DEFINE thisfile = 'VBGO#74320_wp.SQL'
DEFINE dbuser = '^VBGO'
SET ECHO ON
SET DEFINE ON
COLUMN fcltlogfile NEW_VALUE fcltlogfile NOPRINT;
COLUMN fcltcusterr NEW_VALUE fcltcusterr NOPRINT;
WHENEVER SQLERROR CONTINUE;
SELECT adm.getscriptspoolfile('&thisfile') AS fcltlogfile FROM DUAL;
SPOOL &fcltlogfile
WHENEVER SQLERROR EXIT;
SELECT adm.checkscriptcust('&dbuser') AS fcltcusterr FROM DUAL;
WHENEVER SQLERROR CONTINUE;
PROMPT &fcltcusterr
SET DEFINE OFF
------ payload begin ------
/* Select om de data uit de VENR omgeving in Excel te zetten
SELECT DISTINCT res_reservering_key,
res_rsv_ruimte_volgnr,
res_rsv_ruimte_omschrijving,
REPLACE(res_rsv_ruimte_opmerking, CHR(10)),
TO_CHAR(res_rsv_ruimte_van, 'dd-mm-yyyy hh24:mi:ss') res_rsv_ruimte_van,
TO_CHAR(res_rsv_ruimte_tot, 'dd-mm-yyyy hh24:mi:ss') res_rsv_ruimte_tot,
pg.prs_perslid_email,
pc.prs_perslid_email,
rd.res_deel_omschrijving
FROM res_rsv_ruimte rrr,
prs_perslid pg,
prs_perslid pc,
alg_v_ruimte_gegevens rg,
res_rsv_deel rrd,
res_deel rd
WHERE rrr.res_rsv_ruimte_key = rrd.res_rsv_ruimte_key
AND rrd.res_deel_key = rd.res_deel_key
AND rrr.res_rsv_ruimte_host_key = pg.prs_perslid_key
AND rrr.res_rsv_ruimte_contact_key = pc.prs_perslid_key
AND rrr.alg_ruimte_key = rg.alg_ruimte_key
AND rrr.res_rsv_ruimte_van > TO_DATE ('20221101', 'YYYYMMDD')
AND rg.alg_locatie_key = 1421
AND rrr.res_rsv_ruimte_verwijder IS NULL;
*/
DECLARE
CURSOR c IS
SELECT REPLACE (fac_imp_csv_col01, '.')
res_reservering_key,
fac_imp_csv_col02
res_rsv_ruimte_volgnr,
fac_imp_csv_col03
res_rsv_ruimte_omschrijving,
fac_imp_csv_col04
res_rsv_ruimte_opmerking,
TO_DATE (fac_imp_csv_col05, 'dd-mm-yyyy hh24:mi:ss')
res_rsv_ruimte_van,
TO_DATE (fac_imp_csv_col06, 'dd-mm-yyyy hh24:mi:ss')
res_rsv_ruimte_tot,
fac_imp_csv_col07
prs_perslid_email_host,
fac_imp_csv_col08
prs_perslid_email_cont,
fac_imp_csv_col09
res_deel_omschrijving
FROM fac_imp_csv
WHERE fac_imp_csv_col01 <> 'res_reservering_key'
ORDER BY res_reservering_key;
v_res_deel_key NUMBER;
v_deel_key NUMBER;
v_ruimte_key NUMBER;
v_perslid_key_host NUMBER;
v_perslid_key_contact NUMBER;
v_rsv_ruimte_key NUMBER;
v_rsv_deel_key NUMBER;
v_reservering_key NUMBER;
v_opmerking VARCHAR2 (200);
v_conversie_txt VARCHAR2 (1000);
v_aanduiding VARCHAR2 (100);
v_errorhint VARCHAR2 (1000);
v_errormsg VARCHAR2 (1000);
oracle_err_num NUMBER;
oracle_err_mes VARCHAR2 (200);
BEGIN
BEGIN
FOR rec IN c
LOOP
BEGIN
v_opmerking := NULL;
v_conversie_txt := NULL;
v_aanduiding :=
'VENR nummer: '
|| rec.res_reservering_key
|| '/'
|| rec.res_rsv_ruimte_volgnr;
v_errorhint :=
'Opzoeken reserveerbare deel: ' || rec.res_deel_omschrijving;
v_conversie_txt := v_aanduiding || CHR (10);
SELECT res_deel_key, res_ins_deel_key
INTO v_res_deel_key, v_deel_key
FROM res_deel rd
WHERE res_deel_verwijder IS NULL
AND LOWER(rd.res_deel_omschrijving) = LOWER(rec.res_deel_omschrijving);
v_errorhint := 'Opzoeken alg_ruimte: ' || rec.res_deel_omschrijving || '-' || v_res_deel_key || '-' || v_deel_key;
SELECT ins_alg_ruimte_key
INTO v_ruimte_key
FROM ins_deel d
WHERE d.ins_deel_key = v_deel_key;
v_errormsg := 'Fout bij opzoeken host: ' || rec.prs_perslid_email_host;
SELECT MAX (prs_perslid_key)
INTO v_perslid_key_host
FROM prs_perslid
WHERE prs_perslid_verwijder IS NULL
AND LOWER (prs_perslid_email) =
LOWER (rec.prs_perslid_email_host);
IF v_perslid_key_host IS NULL
THEN
v_perslid_key_host := 3; -- Facilitor
--fac.imp_writelog (p_import_key, 'W', v_errormsg, '');
fac.writelog ('IMP_RES', 'W', v_errormsg, '');
v_conversie_txt := v_conversie_txt ||
'Host niet gevonden: '
|| rec.prs_perslid_email_host
|| CHR (10);
END IF;
v_errormsg := 'Fout bij opzoeken contact: ' || rec.prs_perslid_email_cont;
SELECT MAX (prs_perslid_key)
INTO v_perslid_key_contact
FROM prs_perslid
WHERE prs_perslid_verwijder IS NULL
AND LOWER (prs_perslid_email) =
LOWER (rec.prs_perslid_email_cont);
IF v_perslid_key_contact IS NULL
THEN
v_perslid_key_contact := 3; -- Facilitor
--fac.imp_writelog (p_import_key, 'W', v_errormsg, '');
fac.writelog ('IMP_RES', 'W', v_errormsg, '');
v_conversie_txt := v_conversie_txt ||
'Contact niet gevonden: '
|| rec.prs_perslid_email_cont
|| CHR (10);
END IF;
INSERT INTO res_reservering (res_reservering_verwijder)
VALUES (NULL)
RETURNING res_reservering_key
INTO v_reservering_key;
v_errormsg := 'Fout toevoegen rsv_ruimte.';
INSERT INTO res_rsv_ruimte (res_reservering_key,
res_rsv_ruimte_volgnr,
res_rsv_ruimte_opmerking,
res_rsv_ruimte_omschrijving,
prs_kostenplaats_key,
res_rsv_ruimte_contact_key,
res_rsv_ruimte_host_key,
res_activiteit_key,
alg_ruimte_key,
res_rsv_ruimte_van,
res_rsv_ruimte_tot,
res_rsv_ruimte_bezoekers,
res_rsv_ruimte_cvab_mode,
res_status_fo_key,
res_status_bo_key)
VALUES (v_reservering_key,
1,
v_conversie_txt || rec.res_rsv_ruimte_opmerking,
rec.res_rsv_ruimte_omschrijving,
NULL,
v_perslid_key_contact,
v_perslid_key_host,
30, -- werkplek
v_ruimte_key,
rec.res_rsv_ruimte_van,
rec.res_rsv_ruimte_tot,
NULL,
2,
2,
NULL)
RETURNING res_rsv_ruimte_key
INTO v_rsv_ruimte_key;
FAC.trackaction ('RESNEW',
v_rsv_ruimte_key,
3,
SYSDATE,
'Aangemaakt door conversie uit VENR');
v_errormsg := 'Fout toevoegen rsv_deel.';
INSERT INTO res_rsv_deel (res_rsv_ruimte_key,
res_deel_key,
res_rsv_deel_van,
res_rsv_deel_tot,
res_rsv_deel_aantal,
res_status_bo_key)
VALUES (v_rsv_ruimte_key,
v_res_deel_key,
rec.res_rsv_ruimte_van,
rec.res_rsv_ruimte_tot,
1,
2)
RETURNING res_rsv_deel_key INTO v_rsv_deel_key;
RES.set_ruimte_dirty (v_rsv_ruimte_key);
RES.set_deel_dirty (v_rsv_deel_key);
--fac.imp_writelog (p_import_key, 'I', 'Reservering is aangemaakt: ' || v_rsv_ruimte_key, v_aanduiding);
fac.writelog ('IMP_RES', 'I', 'Reservering is aangemaakt: ' || v_rsv_ruimte_key, v_aanduiding);
EXCEPTION
WHEN OTHERS
THEN
oracle_err_num := SQLCODE;
oracle_err_mes := SUBSTR (SQLERRM, 1, 100);
v_errormsg :=
'OTHERS (error '
|| oracle_err_num
|| '/'
|| oracle_err_mes
|| ')';
--fac.imp_writelog (p_import_key, 'E', v_aanduiding || v_errormsg, v_errorhint);
fac.writelog ('IMP_RES', 'E', v_aanduiding || v_errormsg, v_errorhint);
END;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
oracle_err_num := SQLCODE;
oracle_err_mes := SUBSTR (SQLERRM, 1, 100);
v_errormsg :=
'OTHERS (error '
|| oracle_err_num
|| '/'
|| oracle_err_mes
|| ')';
--fac.imp_writelog (p_import_key, 'E', v_aanduiding || v_errormsg, v_errorhint);
fac.writelog ('IMP_RES', 'E', v_aanduiding || v_errormsg, v_errorhint);
END;
END;
/
------ payload end ------
SET DEFINE OFF
BEGIN adm.systrackscriptId ('$Id$', 1); END;
/
COMMIT;
SET ECHO OFF
SPOOL OFF
SET DEFINE ON
PROMPT Logfile of this upgrade is: &fcltlogfile