WZKW#80227 -- Implementatie Stichting Welzijnskwartier, bezettingsgraad rapport
svn path=/Customer/trunk/; revision=66081
This commit is contained in:
223
WZKW/WZKW.sql
223
WZKW/WZKW.sql
@@ -360,51 +360,126 @@ AS
|
||||
(SELECT alg_gebouw_naam
|
||||
from alg_gebouw
|
||||
where alg_gebouw_code=COALESCE(afd.alg_gebouw_code,res.alg_gebouw_code)) gebouw_naam,
|
||||
res.res_bezetting res_bezetting_proc,
|
||||
res.res_ruimtes res_ruimtes_aantal,
|
||||
ROUND(res.bezetting) res_bezetting_proc,
|
||||
res.aantal_ruimten res_ruimtes_aantal,
|
||||
afd.bezetting afdeling_bezetting_proc,
|
||||
afd.ruimtes afd_ruimtes_aantal
|
||||
FROM
|
||||
(SELECT alg_gebouw_code, ROUND(AVG(bezetting_res)) res_bezetting, COUNT(res_ruimte_key) res_ruimtes
|
||||
FROM
|
||||
(SELECT res_duur.alg_gebouw_code,
|
||||
res_duur.res_ruimte_key,
|
||||
res_duur.res_ruimte_nr,
|
||||
ROUND(100*tot_res_duur/beschikbaar.beschikbaar) bezetting_res
|
||||
from
|
||||
(SELECT x.alg_gebouw_code,
|
||||
res_ruimte_key,
|
||||
res_ruimte_nr,
|
||||
SUM(x.res_duur) tot_res_duur
|
||||
FROM
|
||||
(SELECT g.ALG_GEBOUW_CODE alg_gebouw_code, rrr.res_reservering_key,
|
||||
rr.res_ruimte_key res_ruimte_key,
|
||||
rr.RES_RUIMTE_NR res_ruimte_nr,
|
||||
((rrr.RES_RSV_RUIMTE_tot - rrr.res_rsv_ruimte_van) * 24) res_duur
|
||||
FROM res_rsv_ruimte rrr,
|
||||
RES_RUIMTE_OPSTELLING rro,
|
||||
res_ruimte rr,
|
||||
alg_v_onroerendgoed_gegevens alg,
|
||||
alg_gebouw g,
|
||||
alg_locatie l
|
||||
WHERE rrr.res_rsv_ruimte_verwijder IS NULL
|
||||
AND rrr.res_status_fo_key = 2
|
||||
AND rro.res_ruimte_opstel_key = rrr.res_ruimte_opstel_key
|
||||
AND rr.res_ruimte_key = rro.res_ruimte_key
|
||||
AND alg.alg_ruimte_key =
|
||||
(SELECT MAX (ra.alg_ruimte_key) -- WE WILLEN MAAR 1 ALG_RUIMTE BIJ EEN KOPPELZAAL
|
||||
FROM res_alg_ruimte ra
|
||||
WHERE ra.res_ruimte_key = rr.res_ruimte_key)
|
||||
AND g.alg_gebouw_code = alg.alg_gebouw_code
|
||||
AND l.alg_locatie_key = alg.alg_locatie_key
|
||||
AND rrr.res_rsv_ruimte_van BETWEEN v_datum_van AND v_datum_tot
|
||||
) x
|
||||
GROUP BY x.ALG_GEBOUW_CODE, x.res_ruimte_key, x.RES_RUIMTE_NR) res_duur,
|
||||
(SELECT DISTINCT rr1.res_discipline_key,
|
||||
rr1.res_ruimte_upper,
|
||||
rr1.RES_RUIMTE_KEY,
|
||||
ra.alg_ruimte_key,
|
||||
( fac.Count_work_days(v_datum_van, v_datum_tot)
|
||||
(SELECT
|
||||
gebouw,
|
||||
alg_gebouw_code,
|
||||
COUNT (alg_ruimte_key) aantal_ruimten,
|
||||
SUM (gebruik_uren) gebruik_uren,
|
||||
SUM (beschikbaar_uren) beschikbaar_uren,
|
||||
(CASE
|
||||
WHEN SUM (beschikbaar_uren) = 0
|
||||
THEN
|
||||
100
|
||||
ELSE
|
||||
ROUND ((SUM (gebruik_uren) / SUM (beschikbaar_uren)) * 100,
|
||||
2)
|
||||
END) bezetting
|
||||
FROM ( SELECT g.alg_gebouw_key res_keycolumn,
|
||||
g.alg_gebouw_naam gebouw,
|
||||
g.alg_gebouw_code alg_gebouw_code,
|
||||
x.alg_ruimte_key,
|
||||
SUM (bezetting) gebruik_uren,
|
||||
MAX (beschikbaar) beschikbaar_uren
|
||||
FROM (SELECT beschik.alg_ruimte_key,
|
||||
beschik.res_discipline_key,
|
||||
beschik.res_ruimte_upper,
|
||||
ROUND (NVL (bezetting, 0), 2) bezetting,
|
||||
ROUND (NVL (beschikbaar, 0), 2) beschikbaar,
|
||||
di.alg_regio_key,
|
||||
l.alg_district_key,
|
||||
l.alg_locatie_key,
|
||||
alg_gebouw_key,
|
||||
alg_verdieping_key
|
||||
FROM ( SELECT alg_ruimte_key,
|
||||
rarg.res_discipline_key,
|
||||
SUM (
|
||||
GREATEST (
|
||||
0,
|
||||
GREATEST (
|
||||
LEAST (
|
||||
TO_NUMBER (
|
||||
TO_CHAR (
|
||||
res_rsv_ruimte_tot_tz,
|
||||
'SSSSS'))
|
||||
/ 3600,
|
||||
COALESCE (
|
||||
res_ruimte_eindtijd,
|
||||
24),
|
||||
23.75),
|
||||
8)
|
||||
- LEAST (
|
||||
GREATEST (
|
||||
TO_NUMBER (
|
||||
TO_CHAR (
|
||||
res_rsv_ruimte_van_tz,
|
||||
'SSSSS'))
|
||||
/ 3600,
|
||||
COALESCE (
|
||||
res_ruimte_begintijd,
|
||||
8),
|
||||
8),
|
||||
23.75))) bezetting
|
||||
FROM (SELECT r.res_rsv_ruimte_key,
|
||||
ra.alg_ruimte_key,
|
||||
ra.res_alg_ruimte_key,
|
||||
rr.res_discipline_key,
|
||||
r.res_rsv_ruimte_van,
|
||||
r.res_rsv_ruimte_van
|
||||
res_rsv_ruimte_van_tz,
|
||||
r.res_rsv_ruimte_tot,
|
||||
r.res_rsv_ruimte_tot
|
||||
res_rsv_ruimte_tot_tz,
|
||||
ra.res_alg_ruimte_aanmaak,
|
||||
ra.res_alg_ruimte_verwijder,
|
||||
rr.res_ruimte_begintijd,
|
||||
rr.res_ruimte_eindtijd
|
||||
FROM res_rsv_ruimte r,
|
||||
res_ruimte_opstelling ro,
|
||||
res_ruimte rr,
|
||||
res_alg_ruimte ra
|
||||
WHERE r.res_rsv_ruimte_verwijder IS NULL
|
||||
AND r.res_rsv_ruimte_dirtlevel = 0
|
||||
AND ( rr.res_ruimte_startdatum
|
||||
IS NULL
|
||||
OR rr.res_ruimte_startdatum <=
|
||||
v_datum_van)
|
||||
AND ( rr.res_ruimte_vervaldatum
|
||||
IS NULL
|
||||
OR rr.res_ruimte_vervaldatum >
|
||||
v_datum_van)
|
||||
AND r.res_status_fo_key IN (1, 2)
|
||||
AND r.res_ruimte_opstel_key =
|
||||
ro.res_ruimte_opstel_key
|
||||
AND ro.res_ruimte_key =
|
||||
rr.res_ruimte_key
|
||||
AND rr.res_ruimte_key =
|
||||
ra.res_ruimte_key) rarg
|
||||
WHERE res_rsv_ruimte_van BETWEEN v_datum_van
|
||||
AND v_datum_tot
|
||||
AND TO_CHAR (res_rsv_ruimte_van_tz, 'd') >= 2
|
||||
AND TO_CHAR (res_rsv_ruimte_van_tz, 'd') <= 6
|
||||
AND TRUNC (res_rsv_ruimte_van_tz) NOT IN
|
||||
(SELECT mld_vrije_dagen_datum
|
||||
FROM mld_vrije_dagen)
|
||||
AND rarg.res_alg_ruimte_aanmaak <=
|
||||
v_datum_tot
|
||||
AND ( rarg.res_alg_ruimte_verwijder IS NULL
|
||||
OR rarg.res_alg_ruimte_verwijder >=
|
||||
v_datum_van)
|
||||
GROUP BY alg_ruimte_key, rarg.res_discipline_key) bez,
|
||||
(SELECT DISTINCT
|
||||
rr1.res_discipline_key,
|
||||
rr1.res_ruimte_upper,
|
||||
ra.alg_ruimte_key,
|
||||
( (fac.Count_Work_Days (
|
||||
v_datum_van
|
||||
- 1,
|
||||
v_datum_tot))
|
||||
* (GREATEST (
|
||||
0,
|
||||
LEAST (
|
||||
@@ -422,21 +497,36 @@ AS
|
||||
12)
|
||||
- COALESCE (
|
||||
rr1.res_ruimte_begintijdblok,
|
||||
12))))) beschikbaar
|
||||
FROM res_ruimte rr1,
|
||||
res_alg_ruimte ra
|
||||
WHERE rr1.res_ruimte_key = ra.res_ruimte_key
|
||||
AND ra.res_alg_ruimte_aanmaak <=v_datum_tot
|
||||
AND ( rr1.res_ruimte_startdatum IS NULL
|
||||
OR rr1.res_ruimte_startdatum <= v_datum_van)
|
||||
AND ( rr1.res_ruimte_vervaldatum IS NULL
|
||||
OR rr1.res_ruimte_vervaldatum >v_datum_van)
|
||||
AND ( ra.res_alg_ruimte_verwijder IS NULL
|
||||
OR ra.res_alg_ruimte_verwijder >=v_datum_van)
|
||||
) beschikbaar
|
||||
WHERE res_duur.res_ruimte_key= beschikbaar.res_ruimte_key
|
||||
)
|
||||
GROUP BY alg_gebouw_code
|
||||
12))))) beschikbaar
|
||||
FROM res_ruimte rr1, res_alg_ruimte ra
|
||||
WHERE rr1.res_ruimte_key = ra.res_ruimte_key
|
||||
AND ra.res_alg_ruimte_aanmaak <=
|
||||
v_datum_tot
|
||||
AND ( rr1.res_ruimte_startdatum IS NULL
|
||||
OR rr1.res_ruimte_startdatum <=
|
||||
v_datum_van)
|
||||
AND ( rr1.res_ruimte_vervaldatum IS NULL
|
||||
OR rr1.res_ruimte_vervaldatum >
|
||||
v_datum_van)
|
||||
AND ( ra.res_alg_ruimte_verwijder IS NULL
|
||||
OR ra.res_alg_ruimte_verwijder >=
|
||||
v_datum_van))
|
||||
beschik,
|
||||
alg_v_ruimte_gegevens_all ruimte_geg,
|
||||
alg_locatie l,
|
||||
alg_district di
|
||||
WHERE beschik.alg_ruimte_key = bez.alg_ruimte_key(+)
|
||||
AND beschik.res_discipline_key =
|
||||
bez.res_discipline_key(+)
|
||||
AND beschik.alg_ruimte_key = ruimte_geg.alg_ruimte_key
|
||||
AND ruimte_geg.alg_locatie_key = l.alg_locatie_key
|
||||
AND l.alg_district_key = di.alg_district_key
|
||||
) x,
|
||||
alg_gebouw g
|
||||
WHERE x.alg_gebouw_key = g.alg_gebouw_key
|
||||
GROUP BY g.alg_gebouw_key, g.alg_gebouw_naam, g.alg_gebouw_code,x.alg_ruimte_key) data
|
||||
GROUP BY res_keycolumn, gebouw, alg_gebouw_code
|
||||
ORDER BY gebouw
|
||||
) res,
|
||||
(
|
||||
SELECT b.alg_gebouw_code,
|
||||
@@ -462,7 +552,7 @@ AS
|
||||
) b
|
||||
GROUP BY b.alg_gebouw_code
|
||||
) afd
|
||||
WHERE res.alg_gebouw_code(+)=afd.alg_gebouw_code;
|
||||
WHERE res.alg_gebouw_code(+)=afd.alg_gebouw_code;
|
||||
END;
|
||||
|
||||
|
||||
@@ -1304,7 +1394,7 @@ AS
|
||||
oracle_err_mes VARCHAR2 (200);
|
||||
v_errormsg VARCHAR2 (200);
|
||||
v_errorhint VARCHAR2 (200);
|
||||
v_factuurregel VARCHAR2(40);
|
||||
v_omschrijving VARCHAR2(200);
|
||||
v_servicecost NUMBER;
|
||||
v_energiecost NUMBER;
|
||||
v_grootboek VARCHAR2(10);
|
||||
@@ -1377,9 +1467,18 @@ BEGIN
|
||||
v_grootboek:='8115';
|
||||
ELSE
|
||||
v_grootboek:='';
|
||||
END IF ;
|
||||
v_csv_regel:='0440|0101='||rex_exp.huurder||'|0425='||rex_exp.reservering_key||'|1490='||v_count||'|0451=|0452='||SUBSTR(rex_exp.soort||' '||rex_exp.oms||' ('||rex_exp.aantal||'x)',1,40)||'|0421=1.00|0455='||LTRIM(TO_CHAR(ROUND(rex_exp.prijs,2),'999999999.99'))||'|0442=|0118=|0201='||v_grootboek||'|0911='||rex_exp.kostenplaats_nr||'|1919=|';
|
||||
wzkw.add_csv_row (v_bestand, v_csv_regel);
|
||||
END IF ;
|
||||
v_omschrijving:= rex_exp.soort||' '||rex_exp.oms||' ('||rex_exp.aantal||'x)';
|
||||
v_csv_regel:='0440|0101='||rex_exp.huurder||'|0425='||rex_exp.reservering_key||'|1490='||v_count||'|0451=|0452='||SUBSTR(v_omschrijving,1,40)||'|0421=1.00|0455='||LTRIM(TO_CHAR(ROUND(rex_exp.prijs,2),'999999999.99'))||'|0442=|0118=|0201='||v_grootboek||'|0911='||rex_exp.kostenplaats_nr||'|1919=|';
|
||||
wzkw.add_csv_row (v_bestand, v_csv_regel);
|
||||
|
||||
-- IF LENGTH(v_omschrijving)>40
|
||||
-- THEN
|
||||
-- v_count:=v_count+1;
|
||||
-- v_csv_regel:='0440|0101='||rex_exp.huurder||'|0425='||rex_exp.reservering_key||'|1490='||v_count||'|0451=|0452='||SUBSTR(v_omschrijving,41,80)||'|0421=1.00|0455='||LTRIM(TO_CHAR(ROUND(rex_exp.prijs,2),'999999999.99'))||'|0442=|0118=|0201='||v_grootboek||'|0911='||rex_exp.kostenplaats_nr||'|1919=|';
|
||||
-- wzkw.add_csv_row (v_bestand, v_csv_regel);
|
||||
-- END IF;
|
||||
|
||||
|
||||
IF rex_exp.volgnr='1' THEN -- volgnr=1 betekend ruimte dus gaan we gelijk de service en energie kosten inboeken
|
||||
SELECT COALESCE((
|
||||
|
||||
Reference in New Issue
Block a user