362 lines
14 KiB
SQL
362 lines
14 KiB
SQL
--
|
|
-- $Id$
|
|
--
|
|
-- Script containing customer specific configuration sql statements for aads: Arcadis Aqumen Facility Management
|
|
|
|
DEFINE thisfile = 'KFSG.SQL'
|
|
DEFINE dbuser = '^KFSG'
|
|
|
|
SET ECHO ON
|
|
SET DEFINE ON
|
|
COLUMN fcltlogfile NEW_VALUE fcltlogfile NOPRINT;
|
|
WHENEVER SQLERROR EXIT;
|
|
SELECT adm.scriptspoolfile('&dbuser', '&thisfile') AS fcltlogfile FROM DUAL;
|
|
WHENEVER SQLERROR CONTINUE;
|
|
SPOOL &fcltlogfile
|
|
SET DEFINE OFF
|
|
|
|
------ payload begin ------
|
|
|
|
CREATE OR REPLACE PACKAGE KFSG
|
|
AS
|
|
PROCEDURE set_werkplek;
|
|
END;
|
|
/
|
|
|
|
CREATE OR REPLACE PACKAGE BODY KFSG
|
|
AS
|
|
-- Geef alle mensen een werkplek in het Schiphol gebouw (key
|
|
PROCEDURE set_werkplek
|
|
AS
|
|
|
|
CURSOR c
|
|
IS
|
|
SELECT *
|
|
FROM prs_perslid p
|
|
WHERE NOT EXISTS
|
|
(SELECT prs_perslidwerkplek_key
|
|
FROM prs_perslidwerkplek pwp
|
|
WHERE pwp.prs_perslid_key = p.prs_perslid_key)
|
|
AND SUBSTR (prs_perslid_oslogin, 1, 1) <> '_';
|
|
|
|
BEGIN
|
|
|
|
FOR rec IN c
|
|
LOOP
|
|
PRS.movetoruimte (rec.prs_perslid_key, 4963, 'R', 0);
|
|
END LOOP;
|
|
|
|
COMMIT;
|
|
END;
|
|
END;
|
|
/
|
|
|
|
CREATE OR REPLACE PROCEDURE kfsg_export_daily_task (
|
|
p_applname IN VARCHAR2,
|
|
p_applrun IN VARCHAR2,
|
|
p_filedir IN VARCHAR2,
|
|
p_filename IN VARCHAR2)
|
|
AS
|
|
BEGIN
|
|
KFSG.set_werkplek();
|
|
END;
|
|
/
|
|
|
|
-- Notificatie om catering wijzigingen in de catalogus borrel (key 165) en gebak (key=162) te notificeren
|
|
CREATE OR REPLACE VIEW KFSG_V_NOTI_CATERING
|
|
(
|
|
sender,
|
|
receiver,
|
|
text,
|
|
code,
|
|
fac_srtnotificatie_key,
|
|
KEY,
|
|
xkey,
|
|
xemail,
|
|
xmobile
|
|
)
|
|
AS
|
|
SELECT NULL sender,
|
|
NULL receiver, --Catering1@schiphol.nl
|
|
'Catering bij reservering '
|
|
|| rrr.res_reservering_key
|
|
|| '/'
|
|
|| rrr.res_rsv_ruimte_volgnr
|
|
|| ' is aangemaakt/gewijzigd '
|
|
text,
|
|
'RESINF' code,
|
|
NULL fac_srtnotificatie_key,
|
|
rrr.res_reservering_key key,
|
|
rrr.res_rsv_ruimte_key xkey,
|
|
'Catering1@schiphol.nl' xemail,
|
|
NULL xmobile
|
|
FROM res_rsv_artikel rra, res_rsv_ruimte rrr, res_artikel ra
|
|
WHERE rra.res_rsv_ruimte_key = rrr.res_rsv_ruimte_key
|
|
AND rra.res_artikel_key = ra.res_artikel_key
|
|
AND ra.res_discipline_key IN (165,162, 167)
|
|
AND rra.res_rsv_artikel_levering > SYSDATE
|
|
AND GREATEST (COALESCE (res_rsv_artikel_mutatie, SYSDATE - 100),
|
|
COALESCE (res_rsv_artikel_verwijder, SYSDATE - 100),
|
|
COALESCE (res_rsv_artikel_aanmaak, SYSDATE - 100)) >
|
|
(SELECT fac_notificatie_job_nextrun
|
|
- fac_notificatie_job_interval / 24
|
|
FROM fac_notificatie_job
|
|
WHERE fac_notificatie_job_view = 'KFSG_V_NOTI_CATERING')
|
|
AND GREATEST (COALESCE (res_rsv_artikel_mutatie, SYSDATE - 100),
|
|
COALESCE (res_rsv_artikel_verwijder, SYSDATE - 100),
|
|
COALESCE (res_rsv_artikel_aanmaak, SYSDATE - 100)) <
|
|
(SELECT fac_notificatie_job_nextrun
|
|
FROM fac_notificatie_job
|
|
WHERE fac_notificatie_job_view = 'KFSG_V_NOTI_CATERING')
|
|
GROUP BY rrr.res_rsv_ruimte_key,
|
|
rrr.res_reservering_key,
|
|
rrr.res_rsv_ruimte_volgnr
|
|
UNION ALL
|
|
SELECT NULL sender,
|
|
NULL receiver, --Catering1@schiphol.nl
|
|
'Reservering '
|
|
|| rrr.res_reservering_key
|
|
|| '/'
|
|
|| rrr.res_rsv_ruimte_volgnr
|
|
|| ' is aangemaakt/gewijzigd '
|
|
text,
|
|
'RESINF' code,
|
|
NULL fac_srtnotificatie_key,
|
|
rrr.res_reservering_key key,
|
|
rrr.res_rsv_ruimte_key xkey,
|
|
'Catering1@schiphol.nl' xemail,
|
|
NULL xmobile
|
|
FROM fac_tracking t,
|
|
res_rsv_ruimte rrr,
|
|
res_ruimte_opstelling ro,
|
|
res_ruimte rr
|
|
WHERE fac_srtnotificatie_key IN (88, 89) -- resnew, resupd
|
|
AND t.fac_tracking_refkey = rrr.res_rsv_ruimte_key
|
|
AND rrr.res_ruimte_opstel_key = ro.res_ruimte_opstel_key
|
|
AND ro.res_ruimte_key = rr.res_ruimte_key
|
|
AND rr.res_discipline_key = 142 -- FSP
|
|
AND t.fac_tracking_datum >
|
|
(SELECT fac_notificatie_job_nextrun
|
|
- fac_notificatie_job_interval / 24
|
|
FROM fac_notificatie_job
|
|
WHERE fac_notificatie_job_view = 'KFSG_V_NOTI_CATERING')
|
|
AND t.fac_tracking_datum <
|
|
(SELECT fac_notificatie_job_nextrun
|
|
FROM fac_notificatie_job
|
|
WHERE fac_notificatie_job_view = 'KFSG_V_NOTI_CATERING')
|
|
GROUP BY rrr.res_rsv_ruimte_key,
|
|
rrr.res_reservering_key,
|
|
rrr.res_rsv_ruimte_volgnr;
|
|
|
|
-- rapport met mensen die via de interface inactief gemaakt zijn en nog lopende verplichtingen hebben te tonen.
|
|
CREATE OR REPLACE VIEW kfsg_v_rap_prs_inactief
|
|
AS
|
|
SELECT prs_perslid_inactief - SYSDATE hide_f_volgorde,
|
|
pf.prs_perslid_naam_full,
|
|
p.prs_perslid_key,
|
|
COUNT (item) aantal,
|
|
prs_perslid_inactief + 90 einddatum
|
|
FROM prs_perslid p, prs_v_perslid_fullnames pf, prs_v_verplichting v
|
|
WHERE prs_perslid_inactief IS NOT NULL
|
|
AND prs_perslid_verwijder IS NULL
|
|
AND p.prs_perslid_key = v.prs_perslid_key
|
|
AND p.prs_perslid_key = pf.prs_perslid_key(+)
|
|
GROUP BY p.prs_perslid_key, prs_perslid_inactief, prs_perslid_naam_full;
|
|
|
|
CREATE OR REPLACE VIEW kfsg_v_noti_resreminder
|
|
(
|
|
code,
|
|
sender,
|
|
receiver,
|
|
text,
|
|
key,
|
|
xkey
|
|
)
|
|
AS
|
|
SELECT 'RESINF',
|
|
NULL,
|
|
rsvr.res_rsv_ruimte_host_key,
|
|
'Reservering '
|
|
|| res.res_reservering_key
|
|
|| ': U heeft op '
|
|
|| TO_CHAR (rsvr.res_rsv_ruimte_van, 'DD-MM')
|
|
|| ' van '
|
|
|| TO_CHAR (rsvr.res_rsv_ruimte_van, 'HH24:MI')
|
|
|| ' tot '
|
|
|| TO_CHAR (rsvr.res_rsv_ruimte_tot, 'HH24:MI')
|
|
|| ' ruimte '
|
|
|| r.res_ruimte_nr
|
|
|| ' gereserveerd.',
|
|
res.res_reservering_key,
|
|
rsvr.res_rsv_ruimte_key
|
|
FROM res_v_aanwezigreservering res,
|
|
res_v_aanwezigrsv_ruimte rsvr,
|
|
res_ruimte_opstelling opst,
|
|
res_disc_params rdp,
|
|
res_ruimte r
|
|
WHERE r.res_discipline_key = rdp.res_ins_discipline_key
|
|
AND rdp.res_disc_params_noti_dagen IS NOT NULL
|
|
AND res.res_reservering_key = rsvr.res_reservering_key
|
|
AND opst.res_ruimte_opstel_key = rsvr.res_ruimte_opstel_key
|
|
AND opst.res_ruimte_key = r.res_ruimte_key
|
|
AND rsvr.res_status_fo_key <= 5
|
|
AND rsvr.res_rsv_ruimte_van BETWEEN fac.datumtijdplusuitvoertijd (
|
|
SYSDATE,
|
|
res_disc_params_noti_dagen,
|
|
'DAGEN')
|
|
AND fac.datumtijdplusuitvoertijd (
|
|
SYSDATE,
|
|
res_disc_params_noti_dagen
|
|
+ 1,
|
|
'DAGEN')
|
|
AND fac.getweekdaynum (SYSDATE) NOT IN (1, 7)
|
|
AND rsvr.res_rsv_ruimte_van >= SYSDATE
|
|
UNION ALL
|
|
SELECT 'RESINF',
|
|
NULL,
|
|
res_rsv_ruimte_host_key,
|
|
'Reservering '
|
|
|| res_reservering_key
|
|
|| ': U heeft op '
|
|
|| TO_CHAR (MIN (van), 'dd-mm')
|
|
|| DECODE (
|
|
MIN (van),
|
|
MAX (tot),
|
|
' om ' || TO_CHAR (MIN (van), 'hh24:mi'),
|
|
' van '
|
|
|| TO_CHAR (MIN (van), 'hh24:mi')
|
|
|| ' tot '
|
|
|| TO_CHAR (MAX (tot), 'hh24:mi'))
|
|
|| ' in ruimte ('
|
|
|| (SELECT alg_gebouw_code
|
|
|| '-'
|
|
|| alg_verdieping_code
|
|
|| '-'
|
|
|| alg_ruimte_nr
|
|
FROM alg_v_onroerendgoed_gegevens arg
|
|
WHERE arg.alg_ruimte_key = ruimte_key)
|
|
|| ') '
|
|
|| COUNT (res_reservering_key)
|
|
|| ' voorziening(en) gereserveerd.',
|
|
res_reservering_key,
|
|
res_rsv_ruimte_key
|
|
FROM (SELECT rsvr.res_rsv_ruimte_host_key,
|
|
res.res_reservering_key,
|
|
rsvd.res_rsv_deel_van van,
|
|
rsvd.res_rsv_deel_tot tot,
|
|
rsvr.res_rsv_ruimte_key,
|
|
rsvr.alg_ruimte_key ruimte_key
|
|
FROM res_v_aanwezigreservering res,
|
|
res_v_aanwezigrsv_ruimte rsvr,
|
|
res_disc_params rdp,
|
|
res_rsv_deel rsvd,
|
|
res_deel rd
|
|
WHERE rsvd.res_rsv_ruimte_key = rsvr.res_rsv_ruimte_key
|
|
AND rd.res_deel_key = rsvd.res_deel_key
|
|
AND rd.res_discipline_key = rdp.res_ins_discipline_key
|
|
AND rdp.res_disc_params_noti_dagen IS NOT NULL
|
|
AND res.res_reservering_key = rsvr.res_reservering_key
|
|
AND rsvr.res_ruimte_opstel_key IS NULL
|
|
AND rsvr.res_status_fo_key <= 5
|
|
AND rsvd.res_rsv_deel_verwijder IS NULL
|
|
AND rsvd.res_rsv_deel_van BETWEEN fac.datumtijdplusuitvoertijd (
|
|
SYSDATE,
|
|
res_disc_params_noti_dagen,
|
|
'DAGEN')
|
|
AND fac.datumtijdplusuitvoertijd (
|
|
SYSDATE,
|
|
res_disc_params_noti_dagen
|
|
+ 1,
|
|
'DAGEN')
|
|
AND fac.getweekdaynum (SYSDATE) NOT IN (1, 7)
|
|
AND rsvd.res_rsv_deel_van >= SYSDATE
|
|
UNION ALL
|
|
SELECT rsvr.res_rsv_ruimte_host_key,
|
|
res.res_reservering_key,
|
|
rsva.res_rsv_artikel_levering van,
|
|
rsva.res_rsv_artikel_levering tot,
|
|
rsvr.res_rsv_ruimte_key,
|
|
rsvr.alg_ruimte_key ruimte_key
|
|
FROM res_v_aanwezigreservering res,
|
|
res_v_aanwezigrsv_ruimte rsvr,
|
|
res_disc_params rdp,
|
|
res_rsv_artikel rsva,
|
|
res_artikel ra
|
|
WHERE rsva.res_rsv_ruimte_key = rsvr.res_rsv_ruimte_key
|
|
AND ra.res_discipline_key = rdp.res_ins_discipline_key
|
|
AND rsva.res_artikel_key = ra.res_artikel_key
|
|
AND rdp.res_disc_params_noti_dagen IS NOT NULL
|
|
AND res.res_reservering_key = rsvr.res_reservering_key
|
|
AND rsvr.res_ruimte_opstel_key IS NULL
|
|
AND rsvr.res_status_fo_key <= 5
|
|
AND rsva.res_rsv_artikel_verwijder IS NULL
|
|
AND rsva.res_rsv_artikel_levering BETWEEN fac.datumtijdplusuitvoertijd (
|
|
SYSDATE,
|
|
res_disc_params_noti_dagen,
|
|
'DAGEN')
|
|
AND fac.datumtijdplusuitvoertijd (
|
|
SYSDATE,
|
|
res_disc_params_noti_dagen
|
|
+ 1,
|
|
'DAGEN')
|
|
AND fac.getweekdaynum (SYSDATE) NOT IN (1, 7)
|
|
AND rsva.res_rsv_artikel_levering >= SYSDATE)
|
|
GROUP BY res_rsv_ruimte_host_key,
|
|
res_reservering_key,
|
|
res_rsv_ruimte_key,
|
|
ruimte_key;
|
|
|
|
CREATE OR REPLACE VIEW kfsg_v_resruimte_qrc
|
|
(
|
|
district,
|
|
locatie,
|
|
gebouw,
|
|
catalogus,
|
|
ruimte_nr,
|
|
ruimte_omschrijving,
|
|
res_ruimte_key,
|
|
fac_bookmark_naam,
|
|
fac_bookmark_id
|
|
)
|
|
AS
|
|
SELECT DISTINCT alg_district_omschrijving,
|
|
alg_locatie_omschrijving,
|
|
alg_gebouw_omschrijving,
|
|
ins_discipline_omschrijving,
|
|
res_ruimte_nr,
|
|
res_ruimte_omschrijving,
|
|
rr.res_ruimte_key,
|
|
fac_bookmark_naam,
|
|
fac_bookmark_id
|
|
FROM res_ruimte rr,
|
|
res_discipline rd,
|
|
fac_bookmark bk,
|
|
(SELECT rag.res_ruimte_key,
|
|
alg_district_omschrijving,
|
|
alg_locatie_omschrijving,
|
|
alg_gebouw_omschrijving
|
|
FROM res_alg_ruimte rag,
|
|
alg_v_onroerendgoed aor,
|
|
alg_gebouw g,
|
|
alg_locatie l,
|
|
alg_district d
|
|
WHERE rag.alg_ruimte_key = aor.alg_onroerendgoed_keys
|
|
AND aor.alg_gebouw_key = g.alg_gebouw_key
|
|
AND g.alg_locatie_key = l.alg_locatie_key
|
|
AND l.alg_district_key = d.alg_district_key) res_alg
|
|
WHERE res_ruimte_verwijder IS NULL
|
|
AND rd.ins_discipline_key = rr.res_discipline_key
|
|
AND rr.res_ruimte_key = res_alg.res_ruimte_key(+)
|
|
AND bk.fac_bookmark_naam LIKE '%QRC_RES_RUIMTE%';
|
|
|
|
------ payload end ------
|
|
|
|
SET DEFINE OFF
|
|
BEGIN adm.systrackscriptId ('$Id$', 0); END;
|
|
/
|
|
|
|
COMMIT;
|
|
SET ECHO OFF
|
|
SPOOL OFF
|
|
SET DEFINE ON
|
|
PROMPT Logfile of this upgrade is: &fcltlogfile |