AAIT#33506 Statusveld bij inspecties

svn path=/Database/trunk/; revision=26962
This commit is contained in:
Peter Feij
2015-11-11 13:32:55 +00:00
parent d0487e289c
commit 0b5e199792
2 changed files with 118 additions and 117 deletions

View File

@@ -126,9 +126,7 @@ CREATE OR REPLACE PACKAGE fac
FUNCTION isdatefeestdag(p_date IN DATE) RETURN BOOLEAN;
FUNCTION calcnextcyclusdate (p_date IN DATE, p_mode IN NUMBER, p_eenheid IN NUMBER, p_periode IN NUMBER, p_bits IN NUMBER) RETURN DATE;
FUNCTION nextcyclusdate (p_date IN DATE, p_mode IN NUMBER, p_eenheid IN NUMBER, p_periode IN NUMBER, p_bits IN NUMBER, p_steps IN NUMBER DEFAULT 0) RETURN DATE;
FUNCTION nextcyclusdate (p_insdeel IN NUMBER, p_srtcontrole IN NUMBER, p_steps IN NUMBER DEFAULT 0) RETURN DATE;
FUNCTION nextcyclusdatesteps (p_date IN DATE, p_mode IN NUMBER, p_eenheid IN NUMBER, p_periode IN NUMBER, p_bits IN NUMBER, p_steps IN NUMBER DEFAULT 1, p_enddate IN DATE DEFAULT SYSDATE) RETURN NUMBER;
FUNCTION nextcyclusdatesteps (p_insdeel IN NUMBER, p_srtcontrole IN NUMBER, p_steps IN NUMBER DEFAULT 1) RETURN NUMBER;
FUNCTION makehash (p_in VARCHAR2, method IN VARCHAR2 DEFAULT 'MD5') RETURN VARCHAR2;
FUNCTION testhash (p_hash VARCHAR2, p_in VARCHAR2) RETURN NUMBER;
PROCEDURE createlikebookmark (pxmlnode VARCHAR2, prefkey NUMBER);
@@ -4385,7 +4383,7 @@ CREATE OR REPLACE PACKAGE BODY fac AS
-- Bij het meegegeven van de huidige datum en steps is 0 de huidige controledatum weer teruggeven.
IF NOT (p_steps = 0 AND toekomst) -- p_steps != 0 || !toekomst
THEN
-- Calulate next cyclus date m.b.v. voledige datum met tijd.
-- Calculate next cyclus date m.b.v. voledige datum met tijd.
inspdate := calcnextcyclusdate (inspdate, p_mode, p_eenheid, p_periode, p_bits);
END IF;
@@ -4417,69 +4415,6 @@ CREATE OR REPLACE PACKAGE BODY fac AS
END IF;
END;
-- Berekent de n-de (p_steps) controledatum na p_date.
-- Indien p_steps niet is meegegeven dan wordt de eerstvolgende controledatum na nu teruggegeven.
-- steps = 0, (NULL): 1-ste vandaag of in de toekomst (als meegegeven datum (p_date) de huidite datum is, dan deze weer teruggeven).
-- steps = n: n-volgende vanaf meegegeven datum (p_date). Als deze berekende datum in de toekomst ligt en steps is nog niet null, dan wordt NULL teruggegeven).
FUNCTION nextcyclusdate (p_insdeel IN NUMBER,
p_srtcontrole IN NUMBER,
p_steps IN NUMBER DEFAULT 0)
RETURN DATE
IS
inspdate DATE;
BEGIN
SELECT inspectie_next
INTO inspdate
FROM (WITH defined_inspect AS (SELECT isc.ins_srtcontrole_key,
isc.ins_srtcontrole_mode,
isc.ins_srtcontrole_eenheid,
isc.ins_srtcontrole_bits,
isc.ins_srtcontrole_periode,
id.ins_deel_key,
id.ins_deel_aanmaak
FROM ins_deel id,
ins_srtdeel s,
ins_srtcontrole isc
WHERE s.ins_srtdeel_key = id.ins_srtdeel_key
AND (isc.ins_srtcontrole_niveau = 'S'
AND isc.ins_srtinstallatie_key = id.ins_srtdeel_key
OR isc.ins_srtcontrole_niveau = 'G'
AND isc.ins_srtinstallatie_key = s.ins_srtgroep_key
OR isc.ins_srtcontrole_niveau = 'D'
AND isc.ins_srtinstallatie_key = id.ins_discipline_key)
AND id.ins_deel_key = p_insdeel)
SELECT fac.nextcyclusdate (COALESCE ( (SELECT MAX ( GREATEST (COALESCE (idsc.ins_deelsrtcontrole_datum_xcp,
CASE di.ins_srtcontrole_mode
WHEN 0
THEN idsc.ins_deelsrtcontrole_datum_org
ELSE idsc.ins_deelsrtcontrole_datum END),
CASE di.ins_srtcontrole_mode
WHEN 0
THEN idsc.ins_deelsrtcontrole_datum_org
ELSE idsc.ins_deelsrtcontrole_datum
END)
) ins_deelsrtcontrole_datum
FROM ins_deelsrtcontrole idsc
WHERE idsc.ins_srtcontrole_key = di.ins_srtcontrole_key
AND idsc.ins_deel_key = di.ins_deel_key),
di.ins_deel_aanmaak),
di.ins_srtcontrole_mode,
COALESCE(xcp.ins_srtcontroledl_xcp_eenheid, di.ins_srtcontrole_eenheid),
COALESCE(xcp.ins_srtcontroledl_xcp_periode, di.ins_srtcontrole_periode),
COALESCE(xcp.ins_srtcontroledl_xcp_bits, di.ins_srtcontrole_bits),
p_steps
) inspectie_next
FROM defined_inspect di,
ins_srtcontroledl_xcp xcp
WHERE di.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)
AND di.ins_deel_key = xcp.ins_deel_key(+)
AND di.ins_deel_key = p_insdeel
AND di.ins_srtcontrole_key = p_srtcontrole
AND (xcp.ins_srtcontroledl_xcp_eind(+) IS NULL OR xcp.ins_srtcontroledl_xcp_eind(+) > TRUNC(SYSDATE, 'DD')));
RETURN inspdate;
END;
-- Bereken hoeveel controlestappen het is naar de eerste controle datum in de toekomst (standaard) of na de meegegeven datum.
FUNCTION nextcyclusdatesteps (p_date IN DATE,
@@ -4508,55 +4443,6 @@ CREATE OR REPLACE PACKAGE BODY fac AS
END IF;
END;
FUNCTION nextcyclusdatesteps (p_insdeel IN NUMBER,
p_srtcontrole IN NUMBER,
p_steps IN NUMBER DEFAULT 1) -- Standaard beginnen te tellen bij 1.
RETURN NUMBER
IS
lsteps NUMBER;
BEGIN
SELECT inspectie_steps
INTO lsteps
FROM (WITH defined_inspect AS (SELECT isc.ins_srtcontrole_key,
isc.ins_srtcontrole_mode,
isc.ins_srtcontrole_eenheid,
isc.ins_srtcontrole_bits,
isc.ins_srtcontrole_periode,
id.ins_deel_key,
id.ins_deel_aanmaak
FROM ins_deel id,
ins_srtdeel s,
ins_srtcontrole isc
WHERE s.ins_srtdeel_key = id.ins_srtdeel_key
AND (isc.ins_srtcontrole_niveau = 'S'
AND isc.ins_srtinstallatie_key = id.ins_srtdeel_key
OR isc.ins_srtcontrole_niveau = 'G'
AND isc.ins_srtinstallatie_key = s.ins_srtgroep_key
OR isc.ins_srtcontrole_niveau = 'D'
AND isc.ins_srtinstallatie_key = id.ins_discipline_key)
AND id.ins_deel_key = p_insdeel)
SELECT fac.nextcyclusdatesteps (COALESCE ( (SELECT MAX (COALESCE(idsc.ins_deelsrtcontrole_datum_xcp, idsc.ins_deelsrtcontrole_datum_org)) ins_deelsrtcontrole_datum
FROM ins_deelsrtcontrole idsc
WHERE di.ins_srtcontrole_key = idsc.ins_srtcontrole_key
AND idsc.ins_deel_key = di.ins_deel_key),
ins_deel_aanmaak),
di.ins_srtcontrole_mode,
COALESCE(xcp.ins_srtcontroledl_xcp_eenheid, di.ins_srtcontrole_eenheid),
COALESCE(xcp.ins_srtcontroledl_xcp_periode, di.ins_srtcontrole_periode),
COALESCE(xcp.ins_srtcontroledl_xcp_bits, di.ins_srtcontrole_bits),
p_steps
) inspectie_steps
FROM defined_inspect di,
ins_srtcontroledl_xcp xcp
WHERE di.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)
AND di.ins_deel_key = xcp.ins_deel_key(+)
AND di.ins_deel_key = p_insdeel
AND di.ins_srtcontrole_key = p_srtcontrole
AND (xcp.ins_srtcontroledl_xcp_eind(+) IS NULL OR xcp.ins_srtcontroledl_xcp_eind(+) > TRUNC(SYSDATE, 'DD')));
RETURN lsteps;
END;
-- We garanderen maximaal 64 characters
-- We ondersteunen alleen nog maar 'MD5'
FUNCTION makehash (p_in VARCHAR2, method IN VARCHAR2 DEFAULT 'MD5')