KFSN#54196: Gebouwinspectie NS.

svn path=/Website/branches/v2018.1/; revision=38933
This commit is contained in:
Maykel Geerdink
2018-08-23 13:58:26 +00:00
parent 6d2394836e
commit e5cb113d1d

View File

@@ -1341,12 +1341,12 @@ ins = {checkAutLevel:
// Eerstvolgende inspectie moet komen/had moeten komen: COALESCE (ins_deelsrtcontrole_datum, ins_deel_aanmaak) + ins_srtcontrole_periode
if (inspect)
{
var lastinspect = "(SELECT MAX(1)"
+ " FROM ins_deelsrtcontrole idsc"
+ " WHERE idsc.ins_srtcontrole_key = di.ins_srtcontrole_key"
+ " AND idsc.ins_deelsrtcontrole_status IN (5, 6)"
+ " AND idsc.ins_deel_key = di.ins_deel_key"
+ " AND idsc.ins_scenario_key = 1)";
var lastinspect = "EXISTS (SELECT 1"
+ " FROM ins_deelsrtcontrole idsc"
+ " WHERE idsc.ins_srtcontrole_key = di.ins_srtcontrole_key"
+ " AND idsc.ins_deelsrtcontrole_status IN (5, 6)"
+ " AND idsc.ins_deel_key = di.ins_deel_key"
+ " AND idsc.ins_scenario_key = 1)";
// Laatste (niet) succesvol uitgevoerde taak.
var laatste_not_suc = "(SELECT MAX(id2.ins_deelsrtcontrole_key)"
@@ -1562,7 +1562,7 @@ ins = {checkAutLevel:
+ " , di.ctr_ismjob))"
+ " END inspectie_next"
+ " , di.ins_srtcontroledl_xcp_startdat"
+ " , CASE WHEN " + lastinspect + " IS NULL THEN 1 ELSE 0 END nonext"
+ " , CASE WHEN NOT " + lastinspect + " THEN 1 ELSE 0 END nonext"
+ " , di.ins_srtcontrole_eenheid inspectie_eenheid"
+ " , di.ins_srtcontrole_eind inspectie_eind"
+ " , " + lcl.xsqla("di.ins_srtcontrole_omschrijving", "di.ins_srtcontrole_key")
@@ -1639,7 +1639,7 @@ ins = {checkAutLevel:
+ " END"
+ " ELSE" // Periodieke taken (NIET MJOB)
+ " CASE"
+ " WHEN " + lastinspect + " IS NULL" // Inspectie die voor het eerst is ingepland(0) of gestart(2) maar nog geen uitgevoerde/afgemelde(6) inspectie heeft.
+ " WHEN NOT " + lastinspect // Inspectie die voor het eerst is ingepland(0) of gestart(2) maar nog geen uitgevoerde/afgemelde(6) inspectie heeft.
+ " THEN COALESCE(CASE"
+ " WHEN di.ins_srtcontroledl_xcp_startdat > di.ins_deel_aanmaak"
+ " THEN di.ins_srtcontroledl_xcp_startdat"
@@ -1669,7 +1669,7 @@ ins = {checkAutLevel:
+ " END"
+ " END inspectie_next"
+ " , ins_srtcontroledl_xcp_startdat"
+ " , CASE WHEN " + lastinspect + " IS NULL THEN 1 ELSE 0 END nonext"
+ " , CASE WHEN NOT " + lastinspect + " THEN 1 ELSE 0 END nonext"
+ " , di.ins_srtcontrole_eenheid inspectie_eenheid"
+ " , di.ins_srtcontrole_eind inspectie_eind"
+ " , " + lcl.xsqla('di.ins_srtcontrole_omschrijving', 'di.ins_srtcontrole_key')
@@ -3182,11 +3182,16 @@ ins = {checkAutLevel:
+ " , ins.nextcyclusdate(el.ins_deel_key, el.ins_srtcontrole_key, 1, 0) nextdate"
+ " , el.ins_scenario_key"
+ (scenario > 1
? " , COALESCE((SELECT MAX(1)" // Heeft de periodieke taak ook de meegegeven scenario "scenario".
+ " FROM ins_srtcontroledl_xcp xcp2"
+ " WHERE xcp2.ins_deel_key = el.ins_deel_key"
+ " AND xcp2.ins_srtcontrole_key = el.ins_srtcontrole_key"
+ " AND xcp2.ins_scenario_key = " + scenario + "), 0)"
? " , COALESCE(CASE"
+ " WHEN EXISTS (SELECT 1" // Heeft de periodieke taak ook de meegegeven scenario "scenario".
+ " FROM ins_srtcontroledl_xcp xcp2"
+ " WHERE xcp2.ins_deel_key = el.ins_deel_key"
+ " AND xcp2.ins_srtcontrole_key = el.ins_srtcontrole_key"
+ " AND xcp2.ins_scenario_key = " + scenario + ")"
+ " THEN 1"
+ " ELSE NULL"
+ " END"
+ " , 0)"
: " , 0") + " hasscenario2"
+ (fulldetails && scenario == 1
? " , (SELECT LISTAGG(isc.ins_scenario_omschrijving, ', ') WITHIN GROUP (ORDER BY isc.ins_scenario_omschrijving)"