BLOS#61496 -- Implementatie Facilitor bij BLOS Kinderopvang - de werkplekkoppelingen
svn path=/Customer/trunk/; revision=46410
This commit is contained in:
211
BLOS/blos.sql
211
BLOS/blos.sql
@@ -392,6 +392,217 @@ EXCEPTION
|
||||
END;
|
||||
/
|
||||
|
||||
-- Hulpview: Alle locaties die bij een bepaald CLUSTER horen
|
||||
CREATE OR REPLACE VIEW blos_v_cluster_locaties
|
||||
(
|
||||
ALG_LOCATIE_KEY,
|
||||
ALG_LOCATIE_CODE,
|
||||
ALG_LOCATIE_OMSCHRIJVING,
|
||||
CLUSTER_CODE,
|
||||
TYPE_LOCATIE
|
||||
)
|
||||
AS
|
||||
SELECT l.alg_locatie_key,
|
||||
l.alg_locatie_code,
|
||||
l.alg_locatie_omschrijving,
|
||||
(SELECT ud.fac_usrdata_upper
|
||||
FROM alg_onrgoedkenmerk km, fac_usrdata ud
|
||||
WHERE km.alg_onrgoed_key = l.alg_locatie_key
|
||||
AND km.alg_onrgoed_niveau = 'L'
|
||||
AND km.alg_kenmerk_key = 1000 -- Cluster
|
||||
AND km.alg_onrgoedkenmerk_verwijder IS NULL
|
||||
AND fac.safe_to_number (km.alg_onrgoedkenmerk_waarde) =
|
||||
ud.fac_usrdata_key
|
||||
AND ud.fac_usrtab_key = 1)
|
||||
AS cluster_naam,
|
||||
(SELECT ud.fac_usrdata_upper
|
||||
FROM alg_onrgoedkenmerk km, fac_usrdata ud
|
||||
WHERE km.alg_onrgoed_key = l.alg_locatie_key
|
||||
AND km.alg_onrgoed_niveau = 'L'
|
||||
AND km.alg_kenmerk_key = 1002 -- type_opvang/locatie
|
||||
AND km.alg_onrgoedkenmerk_verwijder IS NULL
|
||||
AND fac.safe_to_number (km.alg_onrgoedkenmerk_waarde) =
|
||||
ud.fac_usrdata_key
|
||||
AND ud.fac_usrtab_key = 2)
|
||||
AS type_locatie
|
||||
FROM alg_locatie l -- , alg_onrgoedkenmerk km -- , fac_usrdata ud
|
||||
WHERE l.alg_locatie_verwijder IS NULL;
|
||||
|
||||
-- Hulpview Personen - Alle locatiemanagers onder REGMAN
|
||||
---- Alles onder locatie (niveau 1) REGMAN-Regiomanagement
|
||||
---- Per persoon de AFDELING (= CLUSTER-code) + De kostenplaats en de bovenliggende kostenplaats_groep (= tevens ook CLUSTER-code)
|
||||
---- PRS_perslid_key || Organisatie_CODE || Kostenplaats_Code || Kostenplaats_Groep_CODE
|
||||
CREATE OR REPLACE VIEW blos_v_cluster_personen
|
||||
(
|
||||
PRS_PERSLID_KEY,
|
||||
PRS_PERSLID_VOLLEDIGENAAM,
|
||||
PRS_AFDELING_UPPER, -- is CLUSTER_CODE
|
||||
PRS_AFDELING_OMSCHRIJVING,
|
||||
PRS_AFDELING_PARENT,
|
||||
PRS_AFDELING_PARENT_OMS,
|
||||
PRS_KOSTENPLAATS_KEY,
|
||||
PRS_KOSTENPLAATS_UPPER,
|
||||
PRS_KOSTENPLAATS_OMSCHRIJVING,
|
||||
PRS_KOSTENPLAATSGRP_OMS -- is CLUSTER_CODE
|
||||
)
|
||||
AS
|
||||
SELECT p.prs_perslid_key,
|
||||
p.prs_perslid_voornaam || ' ' || p.prs_perslid_naam,
|
||||
v.prs_afdeling_upper,
|
||||
v.prs_afdeling_omschrijving,
|
||||
ap.prs_afdeling_upper,
|
||||
ap.prs_afdeling_omschrijving,
|
||||
vkp.prs_kostenplaats_key,
|
||||
vkp.prs_kostenplaats_upper,
|
||||
vkp.prs_kostenplaats_omschrijving,
|
||||
vkp.prs_kostenplaatsgrp_oms
|
||||
FROM prs_perslid p,
|
||||
prs_v_aanwezigafdeling v,
|
||||
prs_afdeling ap,
|
||||
(SELECT kp.prs_kostenplaats_key,
|
||||
kp.prs_kostenplaats_upper,
|
||||
kp.prs_kostenplaats_omschrijving,
|
||||
kpg.prs_kostenplaatsgrp_oms
|
||||
FROM prs_kostenplaats kp, prs_kostenplaatsgrp kpg
|
||||
WHERE kp.prs_kostenplaatsgrp_key = kpg.prs_kostenplaatsgrp_key
|
||||
AND prs_kostenplaats_verwijder IS NULL
|
||||
AND kp.prs_kostenplaats_module = 'PRS') vkp
|
||||
WHERE p.prs_afdeling_key = v.prs_afdeling_key
|
||||
AND v.prs_afdeling_parentkey = ap.prs_afdeling_key
|
||||
AND ap.prs_afdeling_key = 34 -- REGMAN als PARENT_KEY (alles onder de Regiomanagement tonen en in procedure bewaken/herzien
|
||||
AND p.prs_perslid_verwijder is null
|
||||
AND v.prs_kostenplaats_key = vkp.prs_kostenplaats_key(+)
|
||||
ORDER BY v.prs_afdeling_upper, p.prs_perslid_naam ;
|
||||
|
||||
--- DE PROCEDURE om voor de Locatiemanagers van de CLUSTERS de juiste CLUSTER-LOCATIES te koppelen als werkplek
|
||||
CREATE OR REPLACE PROCEDURE blos_export_wpcluster (
|
||||
p_applname IN VARCHAR2,
|
||||
p_applrun IN VARCHAR2
|
||||
)
|
||||
AS
|
||||
CURSOR c_nieuw
|
||||
IS
|
||||
SELECT cp.prs_perslid_key, cl.alg_locatie_key, cl.alg_locatie_code,cl.alg_locatie_omschrijving,cl.cluster_code
|
||||
FROM blos_v_cluster_locaties cl, blos_v_cluster_personen cp
|
||||
WHERE cl.cluster_code = cp.prs_afdeling_upper
|
||||
AND NOT EXISTS
|
||||
(SELECT v.alg_locatie_key
|
||||
FROM prs_perslidwerkplek wp, prs_v_werkplekafdeling_geg v
|
||||
WHERE wp.prs_perslidwerkplek_key =
|
||||
v.prs_perslidwerkplek_key
|
||||
AND wp.prs_perslid_key = cp.prs_perslid_key
|
||||
AND v.alg_locatie_key = cl.alg_locatie_key);
|
||||
|
||||
CURSOR c_del
|
||||
IS
|
||||
SELECT b.prs_perslid_key, b.alg_locatie_key, cl.alg_locatie_code, cl.alg_locatie_omschrijving, cl.cluster_code, b.prs_perslidwerkplek_key
|
||||
FROM blos_v_cluster_locaties cl,
|
||||
(SELECT wp.prs_perslid_key,
|
||||
v.alg_locatie_key,
|
||||
wp.prs_perslidwerkplek_key,
|
||||
v.prs_werkplek_key,
|
||||
v.prs_werkplek_volgnr,
|
||||
v.alg_ruimte_key
|
||||
FROM prs_perslidwerkplek wp, prs_v_werkplekafdeling_geg v
|
||||
WHERE wp.prs_perslidwerkplek_key = v.prs_perslidwerkplek_key) b
|
||||
WHERE b.alg_locatie_key = cl.alg_locatie_key
|
||||
AND NOT EXISTS
|
||||
(SELECT cl.alg_locatie_key
|
||||
FROM blos_v_cluster_locaties cl, blos_v_cluster_personen cp
|
||||
WHERE cl.cluster_code = cp.prs_afdeling_upper
|
||||
AND cp.prs_perslid_key = b.prs_perslid_key
|
||||
AND cl.alg_locatie_key = b.alg_locatie_key)
|
||||
AND EXISTS
|
||||
(SELECT cp.prs_perslid_key
|
||||
FROM blos_v_cluster_personen cp
|
||||
WHERE cp.prs_perslid_key = b.prs_perslid_key);
|
||||
|
||||
v_ruimte_key NUMBER;
|
||||
v_prs_werkplek_volgnr NUMBER;
|
||||
v_prs_werkplek_key NUMBER ;
|
||||
|
||||
v_errormsg VARCHAR (200);
|
||||
v_errorhint VARCHAR (200);
|
||||
oracle_err_mes VARCHAR2 (150);
|
||||
currentversion fac_module.fac_module_version%TYPE;
|
||||
v_aanduiding VARCHAR (100);
|
||||
v_count NUMBER;
|
||||
|
||||
BEGIN
|
||||
v_count:=0;
|
||||
|
||||
FOR rec IN c_nieuw
|
||||
LOOP
|
||||
|
||||
v_aanduiding :=
|
||||
'Werkplekkoppeling gemaakt - betreft: ' || rec.alg_locatie_code || ' (' || rec.cluster_code || ')' ;
|
||||
v_errorhint := 'nieuwe werkplekkoppeling maken';
|
||||
|
||||
-- Ruimte_key ophalen van desbetreffende locatie_keten
|
||||
SELECT min(alg_ruimte_key)
|
||||
INTO v_ruimte_key
|
||||
FROM alg_v_allonrgoed_gegevens v
|
||||
WHERE v.alg_locatie_key = rec.alg_locatie_key and v.alg_type ='R' ;
|
||||
|
||||
-- Volgnr werkplek
|
||||
SELECT COALESCE(MIN (prs_werkplek_volgnr + 1),1)
|
||||
INTO v_prs_werkplek_volgnr
|
||||
FROM prs_werkplek pw WHERE prs_alg_ruimte_key = v_ruimte_key AND NOT EXISTS ( SELECT * FROM prs_werkplek pw2 WHERE prs_alg_ruimte_key = v_ruimte_key AND pw2.prs_werkplek_volgnr = pw.prs_werkplek_volgnr + 1);
|
||||
|
||||
INSERT INTO prs_werkplek w (prs_werkplek_volgnr, prs_werkplek_omschrijving, prs_alg_ruimte_key, prs_werkplek_virtueel)
|
||||
SELECT v_prs_werkplek_volgnr, alg_ruimte_nr || '/1', v_ruimte_key, 1 FROM alg_ruimte WHERE alg_ruimte_key = v_ruimte_key ;
|
||||
|
||||
SELECT prs_werkplek_key
|
||||
INTO v_prs_werkplek_key
|
||||
FROM prs_werkplek WHERE prs_alg_ruimte_key = v_ruimte_key AND prs_werkplek_volgnr = v_prs_werkplek_volgnr ;
|
||||
|
||||
INSERT INTO prs_perslidwerkplek(prs_perslidwerkplek_bezetting, prs_perslidwerkplek_volgnr, prs_werkplek_key, prs_perslid_key) -- prs_perslidwerkplek_key)
|
||||
VALUES (100, NULL, v_prs_werkplek_key, rec.prs_perslid_key) ; -- 82) ;
|
||||
|
||||
-- UPDATE prs_perslid p
|
||||
-- SET prs_perslid_telefoonnr = rec.nummer_object
|
||||
-- WHERE p.prs_perslid_key = rec.prs_perslid_key ;
|
||||
|
||||
fac.trackaction (
|
||||
'PRSUPD',
|
||||
rec.prs_perslid_key,
|
||||
3,
|
||||
SYSDATE,
|
||||
v_aanduiding);
|
||||
|
||||
END LOOP;
|
||||
|
||||
FOR rec IN c_del
|
||||
LOOP
|
||||
v_aanduiding :=
|
||||
'Werkplekkoppeling verwijderen - betreft: ' || rec.alg_locatie_code || ' (' || rec.cluster_code || ')' ;
|
||||
v_errorhint := 'werkplekkoppeling verwijderen';
|
||||
|
||||
DELETE FROM prs_werkplek WHERE prs_werkplek_key IN (SELECT prs_werkplek_key FROM prs_perslidwerkplek WHERE prs_perslidwerkplek_key = rec.prs_perslidwerkplek_key) ;
|
||||
|
||||
DELETE FROM PRS_PERSLIDWERKPLEK WHERE PRS_PERSLIDWERKPLEK_key = rec.prs_perslidwerkplek_key ;
|
||||
|
||||
fac.trackaction (
|
||||
'PRSUPD',
|
||||
rec.prs_perslid_key,
|
||||
3,
|
||||
SYSDATE,
|
||||
v_aanduiding);
|
||||
|
||||
END LOOP;
|
||||
|
||||
END;
|
||||
/
|
||||
|
||||
-- script om dagelijks terugkerende scripts aan te roepen.
|
||||
CREATE OR REPLACE PROCEDURE blos_select_daily_task (p_applname IN VARCHAR2, p_applrun IN VARCHAR2)
|
||||
AS
|
||||
BEGIN
|
||||
-- job om de werkplekkoppelingen te realiseren en onderhouden voor de locatiemanagers
|
||||
blos_export_wpcluster (p_applname, p_applrun);
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
------ payload end ------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user