FSN#32209: code cleanup: ins_v_defined_inspect_xcp geintroduceerd, res_deel subquery verwijderd
svn path=/Website/trunk/; revision=29831
This commit is contained in:
@@ -84,26 +84,11 @@ else
|
||||
return "<div class='listbodykop'>" + safe.html(oRs("plaats").Value) + "</div>";
|
||||
};
|
||||
|
||||
var lastinspect = "(SELECT GREATEST(COALESCE (idsc.ins_deelsrtcontrole_plandatum"
|
||||
+ " , CASE di.ins_srtcontrole_mode"
|
||||
+ " WHEN 0"
|
||||
+ " THEN idsc.ins_deelsrtcontrole_datum_org" // Moment modus. Uitgaan van eigenlijke/orginele inspectiedatum.
|
||||
+ " ELSE idsc.ins_deelsrtcontrole_datum" // Interval modus. Uitgaan van werkelijke inspectiedatum.
|
||||
+ " END)"
|
||||
+ " , CASE di.ins_srtcontrole_mode"
|
||||
+ " WHEN 0"
|
||||
+ " THEN idsc.ins_deelsrtcontrole_datum_org" // Moment modus. Uitgaan van eigenlijke/orginele inspectiedatum.
|
||||
+ " ELSE idsc.ins_deelsrtcontrole_datum" // Interval modus. Uitgaan van werkelijke inspectiedatum.
|
||||
+ " END) ins_deelsrtcontrole_datum"
|
||||
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_deelsrtcontrole_key = (SELECT MAX(idsc2.ins_deelsrtcontrole_key)"
|
||||
+ " FROM ins_deelsrtcontrole idsc2"
|
||||
+ " WHERE idsc2.ins_deel_key = di.ins_deel_key"
|
||||
+ " AND idsc2.ins_srtcontrole_key = di.ins_srtcontrole_key"
|
||||
+ " AND idsc2.ins_deelsrtcontrole_status IN (5, 6)))";
|
||||
+ " AND idsc.ins_deel_key = di.ins_deel_key)";
|
||||
|
||||
// Eerstvolgende inspectie
|
||||
var sqlNext = "SELECT ins_deel_key"
|
||||
@@ -115,17 +100,14 @@ else
|
||||
+ " , di.ins_deel_key"
|
||||
+ " , fac.nextcyclusdate(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)"
|
||||
+ " , di.ins_srtcontrole_eenheid"
|
||||
+ " , di.ins_srtcontrole_periode"
|
||||
+ " , di.ins_srtcontrole_bits"
|
||||
+ " , 1) inspectie_next"
|
||||
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_periode, di.ins_srtcontrole_periode) periode"
|
||||
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_eind, di.ins_srtcontrole_eind) inspectie_eind"
|
||||
+ " FROM ins_v_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, di.ins_srtcontrole_key) NOT IN"
|
||||
+ " , di.ins_srtcontrole_periode periode"
|
||||
+ " , di.ins_srtcontrole_eind inspectie_eind"
|
||||
+ " FROM ins_v_defined_inspect_xcp di"
|
||||
+ " WHERE (di.ins_deel_key, di.ins_srtcontrole_key) NOT IN"
|
||||
+ " (SELECT ins_deel_key, ins_srtcontrole_key"
|
||||
+ " FROM ins_deelsrtcontrole)"
|
||||
+ " UNION ALL"
|
||||
@@ -147,20 +129,17 @@ else
|
||||
+ " ELSE idsc.ins_deelsrtcontrole_datum" // Interval modus (1). Uitgaan van werkelijke inspectiedatum.
|
||||
+ " END"
|
||||
+ " , 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)"
|
||||
+ " , di.ins_srtcontrole_eenheid"
|
||||
+ " , di.ins_srtcontrole_periode"
|
||||
+ " , di.ins_srtcontrole_bits"
|
||||
+ " , 1)"
|
||||
+ " END inspectie_next"
|
||||
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_periode, di.ins_srtcontrole_periode) periode"
|
||||
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_eind, di.ins_srtcontrole_eind) inspectie_eind"
|
||||
+ " , di.ins_srtcontrole_periode periode"
|
||||
+ " , di.ins_srtcontrole_eind inspectie_eind"
|
||||
+ " FROM ins_deelsrtcontrole idsc"
|
||||
+ " , ins_v_defined_inspect di"
|
||||
+ " , ins_srtcontroledl_xcp xcp"
|
||||
+ " , ins_v_defined_inspect_xcp di"
|
||||
+ " , ins_controlemode cm"
|
||||
+ " WHERE di.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)"
|
||||
+ " AND di.ins_deel_key = xcp.ins_deel_key(+)"
|
||||
+ " AND idsc.ins_controlemode_key = cm.ins_controlemode_key(+)"
|
||||
+ " WHERE idsc.ins_controlemode_key = cm.ins_controlemode_key(+)"
|
||||
+ " AND idsc.ins_srtcontrole_key = di.ins_srtcontrole_key"
|
||||
+ " AND idsc.ins_deel_key = di.ins_deel_key"
|
||||
+ " ORDER BY inspectie_next)"
|
||||
@@ -195,22 +174,8 @@ else
|
||||
+ sqlInspectie_from
|
||||
+ " , alg_locatie l"
|
||||
+ " , alg_district di" // I added this for alg_district_key (FSN#1082)
|
||||
+ " , (SELECT res_deel_key"
|
||||
+ " , res_ins_deel_key"
|
||||
+ " , " + lcl.xsqla('res_deel_opmerking', 'res_deel_key')
|
||||
+ " FROM res_deel"
|
||||
+ " WHERE res_deel_verwijder IS NULL"
|
||||
+ " AND res_deel_vervaldatum IS NULL"
|
||||
+ " UNION ALL"
|
||||
+ " SELECT res_deel_key"
|
||||
+ " , res_ins_deel_key"
|
||||
+ " , " + lcl.xsqla('res_deel_opmerking', 'res_deel_key')
|
||||
+ " FROM res_deel"
|
||||
+ " WHERE res_deel_verwijder IS NULL"
|
||||
+ " AND res_deel_vervaldatum > SYSDATE) rd"
|
||||
+ " WHERE i.ins_deel_verwijder IS NULL"
|
||||
+ " AND i.ins_deel_module = 'INS'"
|
||||
+ " AND i.ins_deel_key = rd.res_ins_deel_key(+)"
|
||||
+ " AND s.ins_srtgroep_key NOT IN (" + S("sle_ins_srt_groep_key") + ", " + S("cil_ins_srt_groep_key") + ")"
|
||||
+ (ins_srtgroep_key > -1
|
||||
? " AND s.ins_srtgroep_key = " + ins_srtgroep_key
|
||||
|
||||
Reference in New Issue
Block a user