4621 lines
221 KiB
Groovy
4621 lines
221 KiB
Groovy
// --------------------------------------------------------------------------------------------------------
|
|
// Hooks.groovy
|
|
// --------------------------------------------------------------------------------------------------------
|
|
// Historie:
|
|
// 29.04.2019 imue/dvelop Initiale Umstellung einzelner Einstiegspunkte auf Groovy
|
|
//
|
|
// --------------------------------------------------------------------------------------------------------
|
|
|
|
import com.dvelop.d3.server.Document
|
|
import com.dvelop.d3.server.DocumentType
|
|
import com.dvelop.d3.server.Entrypoint
|
|
import com.dvelop.d3.server.User
|
|
import com.dvelop.d3.server.core.D3Interface
|
|
import com.dvelop.d3.server.core.D3.Archive
|
|
import groovy.sql.GroovyRowResult
|
|
import java.sql.Timestamp;
|
|
import java.text.SimpleDateFormat
|
|
import com.dvelop.d3.server.PhysicalVersion
|
|
import com.dvelop.d3.server.PhysicalVersion.FileLocalisation
|
|
import com.dvelop.d3.server.UserOrUserGroup;
|
|
|
|
public class Hooks {
|
|
|
|
// global benötigte Arrays / Variablen
|
|
List<String> gAREGIChild // für Updateprozess: Da die Verknüpfung vor dem Exit Hook gelöst wird müssen die Children früher ermittelt werden
|
|
|
|
/*
|
|
* Dokumentanlage (ImportDocument)
|
|
* beinhaltet:
|
|
* + hook_hostimp_entry_10 (nicht in Nutzung)
|
|
* + hook_insert_entry_10 (aktiv)
|
|
* + hook_insert_entry_20 (aktiv seit Groovy)
|
|
* + hook_insert_exit_10 (nicht in Nutzung seit Groovy, wird jetzt im insertEntry20 ausgeführt)
|
|
* + hook_insert_exit_20 (aktiv)
|
|
* + hook_insert_exit_30 (aktiv)
|
|
*/
|
|
|
|
@Entrypoint( entrypoint = "hook_insert_entry_10" )
|
|
public int insertEntry10_Kernprozess(D3Interface d3, User user, DocumentType docType, Document doc) {
|
|
|
|
d3.log.info("insertEntry10All gestartet");
|
|
|
|
def lTextMig = doc.getText(4)
|
|
def userName = ""
|
|
if(user != null) {
|
|
userName = user.id();
|
|
}
|
|
|
|
// Validierung der Administrativen Akten
|
|
if(docType.getId().equals(Const.gDTS_AAFOL) || docType.getId().equals(Const.gDTS_AZTXT)) {
|
|
int resultValidate = Functions.validateAdminFolder(d3, doc, "INSERT")
|
|
if(resultValidate == 1) {
|
|
return -170
|
|
}
|
|
}
|
|
|
|
//Validieren der Prozessart
|
|
Functions.validateProcess(d3, doc)
|
|
|
|
//jleu 06.08.2020 - Mapping für Dateisystemablage über d.3one
|
|
if(user != null && userName != null && !userName.equals("d3_async") && !userName.equals("hostimp")) {
|
|
Functions.validateD3oneMapping(d3, doc);
|
|
}
|
|
|
|
if( lTextMig.equals("Migration") && ( user.isMemberOfGroup( Const.gTECHNICAL_GROUP ) || userName.equals("d3_async") ) ) {
|
|
// mache nix
|
|
|
|
} else {
|
|
|
|
d3.log.info("Start proc insertEntry10 - pUser = ${userName}, pDocTypeShort = ${docType.getId()}, text " + lTextMig)
|
|
int lReturn
|
|
def lReturn2
|
|
def lRetCode
|
|
def lOppNR
|
|
def lLength
|
|
def lWhereClause = ""
|
|
|
|
if( docType.getId().equals(Const.gDTS_DLIMA) || docType.getId().equals(Const.gDTS_DKUMA) ) {
|
|
lReturn = Functions.validateWeitKundLiefNo(d3, doc, docType);
|
|
if(lReturn != null && lReturn == -170) {
|
|
return lReturn;
|
|
}
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_DLIMA) || docType.getId().equals(Const.gDTS_DLONT) || docType.getId().equals(Const.gDTS_DKUMA) || docType.getId().equals(Const.gDTS_DERZ1) ) {
|
|
def sqlStatement = "SELECT abteilung as lDep, benutzer_feld_2 as lBuKr FROM benutzer WHERE benutzername = '${userName}' "
|
|
def sqlResult = d3.sql.executeAndGet(sqlStatement)
|
|
if( sqlResult != null && sqlResult.size() > 0 ) {
|
|
def lDep = sqlResult.getAt(0).get("lDep")
|
|
def lBuKr = sqlResult.getAt(0).get("lBuKr")
|
|
if( lDep != null ) {
|
|
doc.field[Const.gDFF_ABTEILUNG] = lDep
|
|
}
|
|
if( lBuKr != null ) {
|
|
doc.field[Const.gDDF_BUCHKREIS] = lBuKr
|
|
}
|
|
}
|
|
}
|
|
|
|
// 22.08.2016/phoer d-velop: Anpassung ausschließlich für das Q-System zur Einführung des SAP-Systemklon vom Produktivsystem
|
|
if( docType.getId().equals(Const.gDTS_AREGI) && doc.getText(4).equals("SAP-Systemklon") ) {
|
|
def lOppANNo = doc.field[Const.gDDF_OPPANNr]
|
|
if( lOppANNo != null && !lOppANNo.substring(0,4).equals("Neue") && !lOppANNo.substring(0,4).equals("") ) {
|
|
String[] splittedString = lOppANNo.split("\\.")
|
|
doc.field[Const.gDDF_HAUPTOPPANNR] = splittedString[0]
|
|
} else {
|
|
d3.log.error("Bei der Akte handelt es sich um eine neue Angebotsversion und diese kann nicht zugeordnet werden")
|
|
}
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_APROJ) ) {
|
|
//Setze die nächste freie Projektnummer für Organisationsprojekte
|
|
Functions.setNextProjnr(d3, doc, Const.gDDF_PROJNR, 3, "INSERT")
|
|
//Vorbelegung des Prozesses und der Prozessgruppe anhand der Projektart
|
|
doc.field[Const.gDDF_PROZESS] = "010301"
|
|
//Setzen des Attributs Hauptprojekt mit der Projektnummer ohne Suffix
|
|
def lProjNr = doc.field[Const.gDDF_PROJNR].substring(0,11)
|
|
doc.field[Const.gDDF_HAUPTPROJEKT] = lProjNr
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_DKUKO) ) {
|
|
String lKukoID = doc.field[Const.gDDF_KONTAKTNUMMER]
|
|
if(lKukoID != null) {
|
|
String[] splittedStringKuko = lKukoID.split("\\|");
|
|
if(splittedStringKuko != null && splittedStringKuko.size() > 1) {
|
|
lKukoID = splittedStringKuko[2];
|
|
if(lKukoID != null) {
|
|
doc.field[Const.gDDF_KONTAKTNUMMER] = lKukoID;
|
|
}
|
|
}
|
|
def sqlStatement = "SELECT dok_dat_feld_${Const.gDDF_BUCHKREIS} as lBuchkrDKUKO " +
|
|
"FROM firmen_spezifisch " +
|
|
"WHERE dok_dat_feld_${Const.gDDF_KONTAKTNUMMER} = '${lKukoID}' " +
|
|
"AND kue_dokuart = '${Const.gDTS_AKONT}' "
|
|
def sqlResult = d3.sql.executeAndGet(sqlStatement)
|
|
if(sqlResult != null && sqlResult.size() > 0) {
|
|
def lBuchkrDKUKO = sqlResult.getAt(0).get("lBuchkrDKUKO")
|
|
doc.field[Const.gDDF_BUCHKREIS] = lBuchkrDKUKO
|
|
}
|
|
}
|
|
}
|
|
|
|
// Splitten des zusammengesetzten Strings Projektnr, Projektname nach Projektnummer für das Feld Projektnummer ==> Organisationsprojektdokumente
|
|
if( docType.getId().equals(Const.gDTS_AMEIS) || docType.getId().equals(Const.gDTS_DPROO) || docType.getId().equals(Const.gDTS_APROJ) ) {
|
|
def returnSplitProjekt = Functions.splitProjekt(d3, doc, docType, user, "INSERT");
|
|
|
|
if (docType.getId().equals(Const.gDTS_DPROO)) {
|
|
def returngetOrgUn = Functions.getOrgUnitByID(d3, doc, docType)
|
|
}
|
|
}
|
|
|
|
// 21.10.2019 Auslagerung des Splits für Eigenschaft Opportunitynummer, Hauptopportunity, Submission in die Functions
|
|
def returnSplitOppSub = Functions.splitOpportunitySubmission(d3, doc, docType);
|
|
|
|
|
|
// phoer 20191024: Splitten der zusammengesetzten Strings SR-ID, Beschreibung
|
|
if( docType.getId().equals(Const.gDTS_DSERE) || docType.getId().equals(Const.gDTS_ASERE) ) {
|
|
Functions.splitServSrId(d3, doc, docType);
|
|
int resultCheckSrId = Functions.checkServiceNr(d3, doc, SystemSpecificConst.gWeitereSRIDID);
|
|
if(resultCheckSrId != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "SR_ID in Zeile ${resultCheckSrId} ist doppelt eingetragen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "SR_ID in line ${resultCheckSrId} exists multiple")
|
|
}
|
|
return -170;
|
|
}
|
|
int resultValidateSrId = Functions.validateSrId(d3, doc);
|
|
if(resultValidateSrId != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte weitere SR_ID in Zeile ${resultValidateSrId} prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check further SR_ID in line ${resultValidateSrId} ")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// phoer 20191024: Splitten der zusammengesetzten Strings SR-ID, Beschreibung
|
|
if( docType.getId().equals(Const.gDTS_DSEBE) || docType.getId().equals(Const.gDTS_ASEBE) ) {
|
|
Functions.splitServBelegnummer(d3, doc, docType);
|
|
int resultCheckBelegNr = Functions.checkServiceNr(d3, doc, SystemSpecificConst.gWeitereBelegNrID);
|
|
if(resultCheckBelegNr != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Belegnummer in Zeile ${resultCheckBelegNr} ist doppelt eingetragen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Further actitivy in line ${resultCheckBelegNr} exists multiple")
|
|
}
|
|
return -170;
|
|
}
|
|
int resultValidateBelegNr = Functions.validateBelegNr(d3, doc);
|
|
if(resultValidateBelegNr != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte weitere Belegnummer in Zeile ${resultValidateBelegNr} prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check further actitivy no in line ${resultValidateBelegNr} ")
|
|
}
|
|
return -170
|
|
}
|
|
if( doc.field[Const.gDDF_BELEGTYP] == null ) {
|
|
String belegNrTemp = doc.field[Const.gDDF_BELEGNUMMER];
|
|
String sqlStatement = "SELECT dok_dat_feld_${Const.gDDF_BELEGTYP} as belegTyp FROM firmen_spezifisch " +
|
|
"WHERE dok_dat_feld_${Const.gDDF_BELEGNUMMER} = '${belegNrTemp}' " +
|
|
"AND kue_dokuart = '${Const.gDTS_ASEBE}' ";
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
if(sqlResult != null && sqlResult.size() > 0) {
|
|
String lBelegTyp = sqlResult.getAt(0).get("belegTyp");
|
|
if( lBelegTyp != null && !lBelegTyp.equals("") && docType.getId().equals(Const.gDTS_DSEBE) ) {
|
|
doc.field[Const.gDDF_BELEGTYP] = lBelegTyp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// imue: Validierung doppelter Einträge für weitere Belegnummer Einkauf
|
|
if( docType.getId().equals(Const.gDTS_DEINK) ) {
|
|
int resultCheckBelegNr = Functions.checkPurchaseNr(d3, doc, SystemSpecificConst.gWeitereEinkaufBelegNrID);
|
|
if(resultCheckBelegNr != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Belegnummer in Zeile ${resultCheckBelegNr} ist doppelt eingetragen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Further actitivy in line ${resultCheckBelegNr} exists multiple")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// imue: Validierung der Belegart für den Service
|
|
if(Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gBelegNrID) && Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gBelegArtID)) {
|
|
Functions.validateBelegart(d3, doc);
|
|
}
|
|
|
|
// imue: Validierung der Belegart für den Einkauf
|
|
if(Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gEinkaufsBelegNrID)) {
|
|
Functions.validateBelegart(d3, doc);
|
|
}
|
|
|
|
// imue 26.08.2020 - Ergänzung für Equipment
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gWeitereEquipmentID) == true ) {
|
|
|
|
Functions.splitEquipment(d3, doc, docType, "INSERT");
|
|
|
|
int resultValidateEquipment = Functions.validateEquipment(d3, doc, user, true);
|
|
if(resultValidateEquipment != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte Equipment Zeile ${resultValidateEquipment} prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check further equipment in line ${resultValidateEquipment} ")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gEquipmentID) == true ) {
|
|
|
|
Functions.splitEquipment(d3, doc, docType, "INSERT");
|
|
|
|
int resultValidateEquipment = Functions.validateEquipment(d3, doc, user, false);
|
|
if(resultValidateEquipment != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte Equipment prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check equipment")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// imue 12.12.2022
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gEquipmentsID) == true ) {
|
|
Functions.splitEquipments(d3, doc, docType);
|
|
int resultValidateEquipment = Functions.validateEquipments(d3, doc, user);
|
|
if(resultValidateEquipment != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte Equipments prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check equipments")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// 21.10.2019 Auslagerung des Splits für Eigenschaft Projektnummer in die Functions
|
|
def returnSplitProjnr = Functions.splitProjektnummer(d3, doc, docType);
|
|
|
|
// 21.10.2019 Auslagerung des Splits für Eigenschaft Opportunity-Nummern (Mehrfachfeld) in die Functions
|
|
def returnSplitOppoMehr = Functions.splitOpportunityMehrf(d3, doc, docType)
|
|
if(returnSplitOppoMehr == -170) {
|
|
return -170
|
|
}
|
|
|
|
// Prüfung der Kommunikationsrichtung bei Ablage über Outlook
|
|
int returnValueMailProperties = Functions.checkMailProperties(d3, doc, docType);
|
|
|
|
// phoer 20170803: Geändert, Ergebnisdokument wird nur auf "Nein" gesetzt, wenn es beim Import leer ist
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gErgebnisDokID) && doc.field[Const.gDDF_ERGEBNISDOK] == null ) {
|
|
doc.field[Const.gDDF_ERGEBNISDOK] = "Nein"
|
|
}
|
|
|
|
// Wenn es sich um ein Ergebnisdokument handelt und ein Angebotsdokument ist, muss die übergeordnete Angebotsversion "in Arbeit" sein.
|
|
if( docType.getId().equals(Const.gDTS_DOPPD) && doc.field[Const.gDDF_ERGEBNISDOK].equals("Ja") && doc.field[Const.gDDF_ARCDOCID] == null ) {
|
|
lReturn = Functions.validateErgebnisdokumenteAngebot(d3, doc, user);
|
|
if(lReturn == -170) {
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// 21.10.2019 Auslagerung des Splits für Eigenschaft Lieferantenname, Lieferantennummer in die Functions
|
|
if(Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gLieferantNrID)) {
|
|
def returnSplitLieferant = Functions.splitLieferant(d3, doc, docType, user, "insert", null);
|
|
if(returnSplitLieferant == -170) {
|
|
return -170
|
|
}
|
|
}
|
|
|
|
if( ( docType.getId().equals(Const.gDTS_DKUKO) && doc.field[Const.gDDF_KNR] != null ) || docType.getId().equals(Const.gDTS_DKUMA) || docType.getId().equals(Const.gDTS_AKUMA) || docType.getId().equals(Const.gDTS_ASERE) || docType.getId().equals(Const.gDTS_ASEBE) ) {
|
|
int returnValidateKunden = Functions.validateKunden(d3, doc, docType, user, "insert")
|
|
if(returnValidateKunden == -170) {
|
|
return -170
|
|
}
|
|
}
|
|
|
|
// Lieferantenaktivitätsdokuemnte
|
|
if( docType.getId().equals(Const.gDTS_DLONT) ) {
|
|
def returnSplitKundenkontaktbe = Functions.splitLieferantenkontaktbeschreibung(d3, doc, docType);
|
|
if( returnSplitKundenkontaktbe == -170) {
|
|
return -170
|
|
}
|
|
}
|
|
|
|
// dkle, 01.02.2016 - Ausschluß des Benutzers hostimp entfernt, statt dessen <Username>: Systemuser für Benutzer ohne Abteilung eingeführt
|
|
if(Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gAbteilungOrgID)) {
|
|
def userDepartment = user.getDepartment()
|
|
if( userDepartment != null ) {
|
|
doc.field[Const.gDFF_ABTEILUNG] = userDepartment
|
|
// d3.log.info("Abteilung = " + userDepartment)
|
|
} else {
|
|
if(docType != null && docType.id().equals(Const.gDTS_DBAUD)) {
|
|
// Dokumentart "Baudokumente" erlaubt keine zusätzlichen Eingaben zur Wertemenge. Daher darf nur Part 1 erfolgen!
|
|
} else {
|
|
String userNameTemp = "${userName}: Systemuser";
|
|
doc.field[Const.gDFF_ABTEILUNG] = userNameTemp;
|
|
}
|
|
// d3.log.errpr("Der Benutzerkontext für die Vergabe des Attributs Abteilung konnte nicht geladen werden!")
|
|
}
|
|
}
|
|
|
|
// Insert Entry: Vererbung der Verkaufsphase auf die Dokumente einer Opportunity beim Import
|
|
// es handelt sich dabei um ein SQL Statement
|
|
if( docType.getId().equals(Const.gDTS_DOPPD) || docType.getId().equals(Const.gDTS_DKUKO) || docType.getId().equals(Const.gDTS_DLIKO) ||
|
|
docType.getId().equals(Const.gDTS_DKOMM) || docType.getId().equals(Const.gDTS_DPRST) || docType.getId().equals(Const.gDTS_DVERD) ) {
|
|
Functions.inheritSalesProcess(d3, doc)
|
|
}
|
|
|
|
// Ermittlung des Buchungskreises anhand Opportunity_Nr, Projekt_Nr oder Kundenkontakt_ID
|
|
// 19.02.2020 Für Service Ermittlung über SR_ID oder Belegnummer
|
|
// 31.08.2020 Für Equipment Ermittlung über Equipment Nummer
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gBuchungskreisID) || Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gBuchungskreiseID) ) {
|
|
Functions.validateBuchungskreisInsert(d3, doc, docType);
|
|
}
|
|
|
|
// Angebotsdokumente: Angebot_Nr in den Zusatztitel einfügen, wenn die Angebot_Nr nicht "Neue" oder "9999" ist
|
|
if( docType.getId().equals(Const.gDTS_DOPPD) ) {
|
|
Functions.setAdditionalTitle(d3, doc);
|
|
}
|
|
|
|
// Splitten der Kundenaktivitäts-ID beim Import | Wenn mit Termin und Beschreibung gearbeitet wird, ergänze ggf. die ID
|
|
if( docType.getId().equals(Const.gDTS_DKUKO) ) {
|
|
lReturn = Functions.validateKuKoID( d3, doc, user, "Insert" );
|
|
if( lReturn == -170 ) {
|
|
// dkle, 02.02.2016 additional info Text eingefügt
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT014049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT014001)
|
|
}
|
|
d3.log.error( "Bitte geben Sie eine gueltige Kundenkontakt-ID ein." )
|
|
return -170
|
|
}
|
|
}
|
|
|
|
//Wenn weder eine Auftrags- noch eine Opportunity-Nr. eingetragen wird, verhindere die Ablage
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gOpportunityNrID) && Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gProjektNrID) ) {
|
|
def lReturnString = Functions.validateOppProjNr( d3, doc )
|
|
if( lReturnString.equals("WITHOUTPROJOPP") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT012049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT012001)
|
|
}
|
|
d3.log.error( "Sie versuchen ein Dokument zu importieren, ohne entweder eine Projekt- oder eine Opportunitynummer eingetragen zu haben. Bitte korrigieren Sie Ihre Eingabe." )
|
|
return -170
|
|
|
|
} else if( lReturnString.equals("PROJOPP") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT013049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT013001)
|
|
}
|
|
d3.log.error( "Sie versuchen ein Dokument zu importieren, und haben sowohl eine Projekt- als auch eine Opportunitynummer eingetragen. Bitte korrigieren Sie Ihre Eingabe." )
|
|
return -170
|
|
}
|
|
}
|
|
|
|
//Maschinenprojekt Prototyp 4: Wenn beim Import die Dokumentgruppe Medien gewählt wurde, aber das Feld Akte leer ist, gib einen Fehler aus
|
|
//Schlüsselumstellung "Medien" -> DG074
|
|
if( ( docType.getId().equals(Const.gDTS_DMDOK) || docType.getId().equals(Const.gDTS_DMAUF) || docType.getId().equals(Const.gDTS_DMSPE) ||
|
|
docType.getId().equals(Const.gDTS_DPRST) || docType.getId().equals(Const.gDTS_DLIMA) || docType.getId().equals(Const.gDTS_DKUMA) ) &&
|
|
doc.field[Const.gDDF_DOKGROUP].equals(Const.gDG_Medien) && doc.field[Const.gDDF_SUBJECT] == null ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT015049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT015001)
|
|
}
|
|
d3.log.error( "Sie versuchen ein Dokument mit der Dokumentgruppe Medien abzulegen, ohne eine Akte ausgewaehlt zu haben. Bitte korrigieren Sie Ihre Eingabe" )
|
|
return -170
|
|
} else if ( docType.getId().equals(Const.gDTS_DPRST) && doc.field[Const.gDDF_SUBJECT].equals(Const.gAK_Projektorganisation) ) {
|
|
doc.field[Const.gDDF_SUBJECT] = ""
|
|
}
|
|
|
|
// Anpassung Maschinenprojekt, bei der Ablage einer Unterakte ECR soll das Feld ECR-Status auf "neu" und im Feld Sortierreihenfolge der Wert "32" gesetzt werden
|
|
if( docType.getId().equals(Const.gDTS_AMECR) && !user.isMemberOfGroup( Const.gTECHNICAL_GROUP ) ) {
|
|
doc.field[Const.gDDF_ECRSTATUS] = "neu"
|
|
doc.field[Const.gDDF_SORTIERUNG] = "32"
|
|
// 05.07.2021 imue: Wenn ein Anwender auf eine bestehende Unterakte ECR/ChangeOrder Akte kliegt und Neue Akte unterhalb anlegt, werden fälschlicherweise Eigenschaften übernommen und müssen daher geleert werden
|
|
if(doc.field[Const.gDDF_REFERENZNR] != null) {
|
|
doc.field[Const.gDDF_REFERENZNR] = null;
|
|
}
|
|
if(doc.field[Const.gDDF_REFERENZOBJ] != null) {
|
|
doc.field[Const.gDDF_REFERENZOBJ] = null;
|
|
}
|
|
// Bei einer neuen ECR: ECR Aktivitäts_ID für diese Projekt_Nr ermitteln -- "Neuer ECR >höchste Nummer für dieses Projekt< :lDateTime"
|
|
// if( dok_dat_feld[gDDF_AKTIVITAETSID] == "" || dok_dat_feld[gDDF_AKTIVITAETSID] == "0000000000" )
|
|
Functions.fillActivityId(d3, doc)
|
|
}
|
|
|
|
// 30.08.2016 dkle: Plausibilitätsprüfung/Ermittlung Projekt_Nr, Aktivitäts-ID und Beschreibung ECR Dokumente und Unterakte ECR
|
|
// Split der ECR Aktivitäts_ID und ECR Beschreibung, führend ist die ECR Aktivitäts_ID
|
|
// SQL Abfrage an die Unterakte ECR, anhand Projekt_Nr und ECR Aktivitäts_ID
|
|
def invalidData = 0
|
|
if( docType.getId().equals(Const.gDTS_DMECR) && doc.field[Const.gDDF_AUFTRNR] != null ) {
|
|
// Split Aktivitäts-ID und Beschreibung, sowie Überprüfung der Daten
|
|
invalidData = Functions.validateActivity( d3, doc, "Insert" )
|
|
} else if( docType.getId().equals(Const.gDTS_DMECR) && ( doc.field[Const.gDDF_AKTIVITAETSID] != null || doc.field[Const.gDDF_BESCHREIBUNG] != null ) && doc.field[Const.gDDF_AUFTRNR] == null ) {
|
|
invalidData = 2
|
|
}
|
|
if( docType.getId().equals(Const.gDTS_DMECR) && invalidData == 1 ) {
|
|
// Meldung an den Benutzer, dass die Projektnummer gefüllt werden muss
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT002049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT002001)
|
|
}
|
|
d3.log.error( Const.gADITXT002049 )
|
|
return -170
|
|
} else if( docType.getId().equals(Const.gDTS_DMECR) && invalidData == 2 ) {
|
|
// Meldung an den Benutzer, dass die Projektnummer gefüllt werden muss
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT001049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT001001)
|
|
}
|
|
d3.log.error( Const.gADITXT001049 )
|
|
return -170
|
|
}
|
|
|
|
// PSP-Element, Netzplan_Nr und Projekt_Nr auf Plausibilität prüfen und ergänzen
|
|
if( ( docType.getId().equals(Const.gDTS_DMDOK) || docType.getId().equals(Const.gDTS_DMSPE) || docType.getId().equals(Const.gDTS_DPRST) || docType.getId().equals(Const.gDTS_DLIKO) ) && doc.field[Const.gDDF_AUFTRNR] != null ) {
|
|
invalidData = 0
|
|
invalidData = Functions.validateNetzPSP( d3, doc )
|
|
if( invalidData != 0 ) {
|
|
return -170
|
|
}
|
|
}
|
|
|
|
// ECR-Dokumente und Ergebnisdokument dürfen nicht in genehmigte ECRs importiert werden.
|
|
if( docType.getId().equals(Const.gDTS_DMECR) && doc.field[Const.gDDF_ERGEBNISDOK].equals("Ja") && doc.field[Const.gDDF_ARCDOCID] == null ) {
|
|
int resultvalidateErgebnisdokumente = Functions.validateErgebnisdokumenteECR(d3, doc, user);
|
|
if(resultvalidateErgebnisdokumente == -170) {
|
|
return -170
|
|
}
|
|
}
|
|
|
|
int returnvalueMM = Functions.validateMustermaterialNr(d3, doc, null, docType, "Insert")
|
|
if(returnvalueMM == -170) {
|
|
return -170;
|
|
}
|
|
|
|
// Split Attribut Funktion bei Technikdokumenten im Import
|
|
if( docType.getId().equals(Const.gDTS_DMDOK) && doc.field[Const.gDDF_FUNKTION] != null ) {
|
|
String lReturnString = Functions.splitFunction( d3, doc, docType.getId() )
|
|
if( lReturnString.equals("FEHLER") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT005049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT005001)
|
|
}
|
|
d3.log.error( "Bitte waehlen Sie eine gültige Funktion aus." )
|
|
return -170
|
|
}
|
|
}
|
|
|
|
// Split Attribut Modul bei Technikdokumenten im Import
|
|
if( docType.getId().equals(Const.gDTS_DMDOK) && doc.field[Const.gDDF_MODUL] != null ) {
|
|
String lReturnString = Functions.splitModule( d3, doc, docType.getId() )
|
|
if( lReturnString.equals("FEHLER") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT006049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT006001)
|
|
}
|
|
d3.log.error( "Bitte waehlen Sie eine gültige Modulnummer aus." )
|
|
return -170
|
|
}
|
|
}
|
|
|
|
// Prüfung des ausgewählten Lieferanten bei der Ablage
|
|
if( !userName.equals("d3_async") && !userName.equals("hostimp") && ( docType.getId().equals(Const.gDTS_DLIKO) || docType.getId().equals(Const.gDTS_ALIKO) || docType.getId().equals(Const.gDTS_ALONT) || docType.getId().equals(Const.gDTS_DLIMA) ) ) {
|
|
String lReturnString = Functions.validateLiefName( d3, doc, "Insert" )
|
|
if( lReturnString.equals("OK") ) {
|
|
// Es handelt sich um einen validen Wert
|
|
} else if( lReturnString.equals("Fehler") ) {
|
|
// dkle, 02.02.2016 additional info Text eingefügt
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT016049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT016001)
|
|
}
|
|
d3.log.error( "Bitte geben Sie einen gültigen, eindeutigen Lieferanten an oder wählen Sie den Lieferanten aus der Auswahlliste." )
|
|
return -170
|
|
}
|
|
}
|
|
|
|
// imue 12.06.2019 - Prüfung das bei Anlage einer Lieferantenaktivität ALONT die Akte in Kombiniation Beschreibung, Termin und Kategorie nicht bereits existiert
|
|
if( docType.getId().equals(Const.gDTS_ALONT) ) {
|
|
def docIdAlont
|
|
def docIdsAlontCount
|
|
def sqlStatement = "SELECT doku_id as docIdAlont " +
|
|
"FROM firmen_spezifisch " +
|
|
"WHERE kue_dokuart = '${Const.gDTS_ALONT}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_LNR} = '${doc.field[Const.gDDF_LNR]}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_KONTAKTBESCH} = '${doc.field[Const.gDDF_KONTAKTBESCH]}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_LIEFAKTKAT} = '${doc.field[Const.gDDF_LIEFAKTKAT]}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_KONTAKTDATE} = '${doc.field[Const.gDDF_KONTAKTDATE]}' "
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
docIdsAlontCount = sqlResult.size()
|
|
if( sqlResult != null && docIdsAlontCount > 0 ) {
|
|
docIdAlont = sqlResult.getAt(0).get("docIdAlont")
|
|
d3.log.error("Akte darf NICHT angelegt werden")
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Die Akte existiert bereits mit der Dokument-ID ${docIdAlont}")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "The file already exists with Document-ID ${docIdAlont}")
|
|
}
|
|
return -170
|
|
} else {
|
|
// Alles in Ordnung - Akte exisitert noch nicht
|
|
}
|
|
}
|
|
|
|
// 17.01.2023 - Neue Validierung der Materialnummer
|
|
if(doc.getType().getId().equals(Const.gDTS_DMATE) && doc.field[Const.gDDF_MATERIALNUMMER] != null) {
|
|
String returnValueMatNo = Functions.validateMaterialNum(d3, doc);
|
|
if(returnValueMatNo != null && returnValueMatNo.equals("ERROR")) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte geben Sie eine Material_Nr ein, zu der bereits eine Materialakte existiert.");
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please enter a material no. for which a mertial file already exists.");
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
d3.log.info("Ende proc insertEntry10_Kernprozess - pUser = ${userName}, pDocTypeShort = ${docType.getId()}")
|
|
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
// 16.12.2019 imue - Doppelte Registrierung möglich
|
|
@Entrypoint( entrypoint = "hook_insert_entry_10" )
|
|
public int insertEntry10_UnterProzess(D3Interface d3, User user, DocumentType docType, Document doc) {
|
|
|
|
def lTextMig = doc.getText(4)
|
|
|
|
d3.log.info("insertEntry10_UnterProzess gestartet");
|
|
|
|
//Validieren der Prozessart
|
|
Functions.validateProcess(d3, doc)
|
|
|
|
if( lTextMig.equals("Migration") && ( user.isMemberOfGroup( Const.gTECHNICAL_GROUP ) || user.id().equals("d3_async") ) ) {
|
|
// mache nix
|
|
} else {
|
|
|
|
//Alle Dokumente, die über d.3one abgelegt werden, im Status Fr importieren
|
|
// 31.07.2017 Durch Attributmapping noch notwendig
|
|
|
|
if( user != null && !user.id().equals("d3_async") && !user.id().equals("hostimp") && !user.id().equals("Master") ) {
|
|
try {
|
|
if( d3.remote.getVersion()[0..2].equals(SystemSpecificConst.gApp_D3one) ) {
|
|
doc.setStatus("Freigabe")
|
|
}
|
|
} catch(Exception e) {
|
|
d3.log.error("insertEntry10_UnterProzess Ermittlung getVersion() schlug fehl - " + e);
|
|
}
|
|
}
|
|
|
|
//jleu 21.05.2021 ITSM Dokumente
|
|
if( docType.getId().equals(Const.gDTS_DITSM) ) {
|
|
def RetVal = Functions.checkITSMNumber(d3, doc)
|
|
|
|
if (RetVal == 10)
|
|
{
|
|
// Meldung an den Benutzer, dass eine unbekannte ITSM ID verwendet wird
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT025049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT025001)
|
|
}
|
|
return -170
|
|
}
|
|
|
|
}
|
|
|
|
//jleu 25.04.2018 Hauptvorgaenge
|
|
if( docType.getId().equals(Const.gDTS_AHAUP) ) {
|
|
Functions.entryFunctionMainfolder(d3, doc, user, 1)
|
|
}
|
|
|
|
//jleu 16.05.2018 Dossier
|
|
if( docType.getId().equals(Const.gDTS_DOSSI) ) {
|
|
Functions.splitDossierValue(d3, doc, docType, "INSERTENTRY")
|
|
}
|
|
|
|
//jleu 11.10.2017 Daten von Abteilungsakte validieren für Abteilungsdokumente
|
|
//02.2020 Abteilungsdokumente heißen nun Teamsitzugnsdokumente
|
|
if( docType.getId().equals(Const.gDTS_DABTE) ) {
|
|
def sqlStatement = "SELECT doku_id as lDokuID, dok_dat_feld_${Const.gDDF_VOROWNER} as lCaseOwner, dok_dat_feld_${Const.gDDF_ZUGRIFF} as lAccess " +
|
|
"FROM firmen_spezifisch " +
|
|
"WHERE kue_dokuart = '${Const.gDTS_AREME}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_CASE} = '${doc.field[Const.gDDF_CASE]}' "
|
|
def sqlResult = d3.sql.executeAndGet(sqlStatement)
|
|
def lCaseOwner
|
|
def lAccess
|
|
def lDokuID
|
|
if( sqlResult != null ) {
|
|
if( sqlResult.size() > 0 ) {
|
|
lCaseOwner = sqlResult.getAt(0).get("lCaseOwner")
|
|
lAccess = sqlResult.getAt(0).get("lAccess")
|
|
lDokuID = sqlResult.getAt(0).get("lDokuID")
|
|
}
|
|
if( lDokuID != null ) {
|
|
Document docTempAreme = d3.archive.getDocument(lDokuID);
|
|
doc.field[Const.gDDF_ZUGRIFF] = lAccess
|
|
doc.field[Const.gDDF_VOROWNER] = lCaseOwner
|
|
for(int i=1; i <= Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); i++) {
|
|
doc.field[Const.gDDF_D3USER67][i] = docTempAreme.field[Const.gDDF_D3USER67][i];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//Ende Regelmeetings - Abteilungsdokumente
|
|
//jleu 23.08.2017 Vertrauliche Vorgangsakten und Abteilungsprozessakten
|
|
if( docType.getId().equals(Const.gDTS_AVEVO) || docType.getId().equals(Const.gDTS_AREME) ) {
|
|
//jleu 30.08.2017 Regelmeetings - Abteilungsdokumente
|
|
if( docType.getId().equals(Const.gDTS_AREME) ) {
|
|
doc.field[Const.gDDF_PROZESS] = "010302"
|
|
doc.field[Const.gDDF_BUCHKREIS68][1] = user.getOptField(2)
|
|
//doc.field[Const.gDFF_ABTEILUNG] = user.getOptField(10) -> Feld gibt es nicht mehr
|
|
}
|
|
if( docType.getId().equals(Const.gDTS_AVEVO) ) {
|
|
doc.field[Const.gDDF_GLAKTYP] = "Vertrauliche Dokumente"
|
|
}
|
|
doc.field[Const.gDDF_VOROWNER] = user.id();
|
|
def sqlStatement = "SELECT * FROM firmen_spezifisch where kue_dokuart = '${docType.getId()}' and dok_dat_feld_${Const.gDDF_CASE} = '${doc.field[Const.gDDF_CASE]}' "
|
|
def sqlResult = d3.sql.executeAndGet(sqlStatement)
|
|
if( sqlResult != null && sqlResult.size() > 0 ) {
|
|
return -171
|
|
}
|
|
}
|
|
|
|
// Ende Vertrauliche Vorgangsakten
|
|
//jleu 13.09.2017 vertrauliche Dokumente
|
|
//Prüfen, ob Ereignisdatum und Dokumenttitel gefüllt sind, ansonsten mit Dateidatum und Dateiname befüllen
|
|
if( docType.getId().equals(Const.gDTS_DVEDO) ) {
|
|
Date date = new Date();
|
|
Timestamp timestamp = new java.sql.Timestamp(date.getTime());
|
|
if( doc.field[Const.gDDF_DOKTITLE] == null || doc.field[Const.gDDF_DOKTITLE].equals("") ) {
|
|
doc.field[Const.gDDF_DOKTITLE] = doc.getFilename()
|
|
}
|
|
if( doc.field[Const.gDDF_ERDATE] == null || doc.field[Const.gDDF_ERDATE].equals("") ) {
|
|
doc.field[Const.gDDF_ERDATE] = timestamp
|
|
}
|
|
}
|
|
|
|
//Ende vertrauliche Dokumente
|
|
//jleu 08.03.2017 Marketingprojekt
|
|
if( docType.getId().equals(Const.gDTS_AMARK) ) {
|
|
doc.field[Const.gDDF_PROZESS] = "PZ001"
|
|
SimpleDateFormat dateFormatYear = new SimpleDateFormat("yyyy");
|
|
SimpleDateFormat dateFormatMonth = new SimpleDateFormat("MM");
|
|
if( doc.field[Const.gDDF_JAHR] == null || doc.field[Const.gDDF_JAHR].equals("") ) {
|
|
doc.field[Const.gDDF_JAHR] = dateFormatYear.format(new Date())
|
|
}
|
|
if( doc.field[Const.gDDF_MONAT] == null || doc.field[Const.gDDF_MONAT].equals("") ) {
|
|
doc.field[Const.gDDF_MONAT] = dateFormatMonth.format(new Date())
|
|
}
|
|
if( doc.field[Const.gDDF_ANFORDERER] != null && !doc.field[Const.gDDF_ANFORDERER].equals("") ) {
|
|
String[] splittedString = doc.field[Const.gDDF_ANFORDERER].split("\\(")
|
|
String convertedString = splittedString[1].replace(")", "")
|
|
def sqlStatement = "SELECT abteilung as lDep, benutzer_feld_2 as lBuKr FROM benutzer WHERE benutzername = '${convertedString}' "
|
|
def sqlResult = d3.sql.executeAndGet(sqlStatement)
|
|
if( sqlResult != null && sqlResult.size() > 0 ) {
|
|
def lDep = sqlResult.getAt(0).get("lDep")
|
|
def lBuKr = sqlResult.getAt(0).get("lBuKr")
|
|
if( lDep != null && !lDep.equals("") ) {
|
|
doc.field[Const.gDFF_ABTEILUNG] = lDep
|
|
}
|
|
if( lBuKr != null && !lBuKr.equals("") ) {
|
|
doc.field[Const.gDDF_BUCHKREIS] = lBuKr
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_DMARK) || docType.getId().equals(Const.gDTS_AVEVO) || docType.getId().equals(Const.gDTS_DVEDO) || docType.getId().equals(Const.gDTS_AREME) || docType.getId().equals(Const.gDTS_AMARK) || docType.getId().equals(Const.gDTS_AHAUP) || docType.getId().equals(Const.gDTS_DSCHU) ) {
|
|
def ld3user
|
|
for(int i=1; i <= Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); i++) {
|
|
if( doc.field[Const.gDDF_D3USER67][i] != null && !doc.field[Const.gDDF_D3USER67][i].equals("") ) {
|
|
ld3user = doc.field[Const.gDDF_D3USER67][i]
|
|
String[] splittedString = ld3user.split("\\=")
|
|
def lReturn = splittedString.size()
|
|
if( lReturn > 0 ) {
|
|
doc.field[Const.gDDF_D3USER67][i] = splittedString[0]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_DLOEH) ) {
|
|
Functions.sixty2single(d3, doc)
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_DWISS) ) {
|
|
// 31.07.2017 Generell: Überprüfung, ob es für bestimmte Dokumentarten Sinn macht auszulagern
|
|
// 10.08.2016 jleu: Anpassung Feld Themen für Caption aus 60er Feld Thema Wissensdokumente
|
|
//Füllen von Themen anhand 60er Feld Thema
|
|
def themen
|
|
doc.field[Const.gDDF_THEMEN] = ""
|
|
for( int i=1; i <= Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); i++ ) {
|
|
if( doc.field[Const.gDDF_THEMA][i] != null && !doc.field[Const.gDDF_THEMA][i].equals("") ) {
|
|
def tmp = doc.field[Const.gDDF_THEMA][i]
|
|
|
|
if(tmp != null && !tmp.equals("")) {
|
|
if( themen.equals("") || themen == null ) {
|
|
themen = tmp;
|
|
} else {
|
|
themen = themen + " I " + tmp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(themen.toString().length() > 250) {
|
|
themen = themen.substring(0,248);
|
|
}
|
|
doc.field[Const.gDDF_THEMEN] = themen;
|
|
//jleu 23.12.2016 Reihenfolge
|
|
doc.field[Const.gDDF_REIHENFOLGE] = "01"
|
|
//jleu - 08.11.2016 - Alle neuen Wissensdokumente bekommen die Ordnung Aktuell
|
|
doc.field[Const.gDDF_ORDNUNG] = "Neu eingestellt"
|
|
}
|
|
|
|
//jleu 23.12.2016 Reihenfolge
|
|
if( docType.getId().equals(Const.gDTS_DSCHU) ) {
|
|
doc.field[Const.gDDF_REIHENFOLGE] = "01"
|
|
}
|
|
|
|
//jleu 06.10.2016 Ergebnisdokumente auf Nein setzen, falls Feld leer bleibt für Baudokumente
|
|
if( docType.getId().equals(Const.gDTS_DBAUD) ) {
|
|
if( doc.field[Const.gDDF_ERGEBNISDOK] == null || doc.field[Const.gDDF_ERGEBNISDOK].equals("") ) {
|
|
doc.field[Const.gDDF_ERGEBNISDOK] = "Nein"
|
|
}
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_ABAUP) ) {
|
|
doc.field[Const.gDDF_PROZESS] = "PZ003"
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_AITSM) || docType.getId().equals(Const.gDTS_DITSM) ) {
|
|
doc.field[Const.gDDF_PROZESS] = "PZ081"
|
|
}
|
|
|
|
//jleu 15.11.2017 Anpassung Organisationseinheit für Case Manager Contract
|
|
if( docType.getId().equals(Const.gDTS_MNDNT) ) {
|
|
if( doc.field[Const.gDDF_ORGEINHEIT] != null && !doc.field[Const.gDDF_ORGEINHEIT].equals("") ) {
|
|
doc.field[Const.gDDF_ORGEINHEIT] = Functions.splitBuKrs(doc.field[Const.gDDF_ORGEINHEIT])
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
@Entrypoint( entrypoint = "hook_insert_entry_20" )
|
|
public int insertEntry20(D3Interface d3, Document doc, DocumentType docType, User user) {
|
|
|
|
d3.log.info("insertEntry20 gestartet für Dokumentart ${docType.id()} und User ${user.id()} ");
|
|
/*
|
|
* Ausführungsbeschreibung:
|
|
* Prüfung, ob das Dokument bereits im d.3 existiert (über HashValue), falls ja wird es nicht importiert.
|
|
* Datenbank -> files_datentraeger: Eindeutig ist nur der file_hash
|
|
*/
|
|
|
|
def userName = ""
|
|
if(user != null) {
|
|
userName = user.id()
|
|
}
|
|
|
|
// Umstellung -> In JPL wurde die Erstellung durch bestimmte Nutzer ausgeführt
|
|
// in Groovy müssen wir dies über das Bemerkungsfeld lösen
|
|
|
|
if( doc.field[Const.gDDF_ARCDOCID] == null && !userName.equals("d3_async")
|
|
&& !userName.equals("hostimp") && !userName.equals("d3_rs") && !userName.equals("d3_content") && !userName.equals("d3_exch") && !user.isMemberOfGroup( Const.gTECHNICAL_GROUP )
|
|
&& (doc.getText(4) == null || (doc.getText(4) != null && !doc.getText(4).equals("cloned") && !doc.getText(4).equals("ECR cloned") && !doc.getText(4).equals("Ergebnisdokument cloned")))
|
|
&& !docType.getId().equals(Const.gDTS_DALTD) ) {
|
|
|
|
// 08.2020 Sonderbindung für Equipment
|
|
if( !docType.getId().equals(Const.gDTS_DEQUI) ) {
|
|
|
|
String fileHash
|
|
List<String> foundDocIDs = new ArrayList<>();
|
|
int lDocCount
|
|
def lResult
|
|
String lFileExtension
|
|
|
|
lFileExtension = doc.getFileExtension()
|
|
//d3.log.error("Dublettenprüfung - lFileExtension = ${lFileExtension}")
|
|
|
|
if( !lFileExtension.equals("D3L") ) {
|
|
|
|
// Ermittlung des HashValue
|
|
PhysicalVersion[] pv = doc.getPhysicalVersions();
|
|
// Initialer Import
|
|
if(pv.size() == 1) {
|
|
fileHash = pv[0].getFileHash()
|
|
|
|
//d3.log.error("Dublettenprüfung - fileHash : " + fileHash);
|
|
|
|
// 28.07.2022 imue: Änderung für Vorlagenmanagement
|
|
// Umsetzungsbeschreibung Herr Kopp:
|
|
// Wenn die Duplettenprüfung ein Duplikat feststellt, dann ist dem System die DocId der bereits abgelegten Datei bekannt.
|
|
// Falls es sich bei der abgelegten Datei um ein Vorlagendokument (DVORL) und Dateityp PDF handelt, dann soll soll die Duplettenprüfung in diesem Fall übergangen werden!
|
|
String sqlStatementVorl = """SELECT fd.doku_id
|
|
FROM files_datentraeger fd
|
|
LEFT JOIN firmen_spezifisch fs ON fs.doku_id = fd.doku_id
|
|
WHERE fd.file_hash = '${fileHash}'
|
|
AND fs.kue_dokuart = '${Const.gDTS_DVORL}'
|
|
AND fd.datei_erw = 'PDF' """;
|
|
List<GroovyRowResult> sqlResultVorl = d3.sql.executeAndGet(sqlStatementVorl);
|
|
if(sqlResultVorl != null && sqlResultVorl.size() >= 1) {
|
|
d3.log.info("insertEntry20 - Abbruch Duplettenprüfung aufgrund Vorlage als Basis");
|
|
return 0;
|
|
}
|
|
|
|
// 23.05.2023 imue - Dokumete an denen die ARC_DOC_ID gefüllt ist, sollen nicht bei der Duplikatsprüfung betrachtet werden
|
|
// ALT = """SELECT doku_id as foundDocIDs FROM files_datentraeger WHERE file_hash = '${fileHash}' """;
|
|
String sqlStatement = """SELECT fd.doku_id as foundDocIDs
|
|
FROM files_datentraeger fd
|
|
LEFT JOIN firmen_spezifisch fs ON fd.doku_id = fs.doku_id
|
|
WHERE fd.file_hash = '${fileHash}'
|
|
AND dok_dat_feld_${Const.gDDF_ARCDOCID} IS NULL""";
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
if(sqlResult != null) {
|
|
|
|
//d3.log.error("Dublettenprüfung - sqlResult : " + sqlResult);
|
|
|
|
for(GroovyRowResult grr : sqlResult) {
|
|
foundDocIDs.add(grr.get("foundDocIDs"))
|
|
}
|
|
lDocCount = sqlResult.size()
|
|
|
|
if( lDocCount >= 1 ) {
|
|
|
|
if( (docType.getId().equals(Const.gDTS_DWISS) || docType.getId().equals(Const.gDTS_DSCHU) ) && lDocCount == 1 ) {
|
|
|
|
//jleu 22.11.2017 Lasse Duplikat für Wissensdokumente zu und verlinke die beiden Dokumente - aber nur, wenn es nur ein Ursprungsdokument gibt
|
|
lResult = d3.call.link_documents(foundDocIDs[0], doc.id(), "d3groovy", false, false);
|
|
|
|
if( lResult != 0 ) {
|
|
d3.log.error("Fehler beim Verlinken Result ${lResult}")
|
|
} else {
|
|
Document docTemp = d3.archive.getDocument(foundDocIDs[0])
|
|
docTemp.setText(1, "Copied to ${doc.id()}")
|
|
doc.setText(1, "Original ${foundDocIDs[0]}")
|
|
try {
|
|
docTemp.updateAttributes("d3groovy", true)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, docTemp.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
try {
|
|
doc.updateAttributes("d3groovy", true)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, doc.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
}
|
|
} else {
|
|
for(int i = 0; i < lDocCount; i++) {
|
|
if( !foundDocIDs[i].equals(doc.id())) {
|
|
Document docTemp = d3.archive.getDocument(foundDocIDs[i]);
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
if(docTemp != null) {
|
|
d3.hook.setProperty("additional_info_text", "Das Dokument ist bereits ${lDocCount} Mal im d.3 abgelegt. Eine erneute Ablage ist nicht möglich. Das letzte Mal wurde es unter DokID ${foundDocIDs[i]} durch den Ersteller ${docTemp.getOwner()} gespeichert.")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Das Dokument ist bereits ${lDocCount} Mal im d.3 abgelegt. Eine erneute Ablage ist nicht möglich. Das letzte Mal wurde es unter DokID ${foundDocIDs[i]} gespeichert.")
|
|
}
|
|
} else {
|
|
if(docTemp != null) {
|
|
d3.hook.setProperty("additional_info_text", "The document already exists ${lDocCount} times in d.3. You are not allowed to import it again. The last Document ID is ${foundDocIDs[i]} from Owner ${docTemp.getOwner()} ).")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "The document already exists ${lDocCount} times in d.3. You are not allowed to import it again. The last Document ID is ${foundDocIDs[i]}).")
|
|
}
|
|
|
|
}
|
|
d3.log.info( "Das Dokument ist bereits ${lDocCount} Mal im d.3 abgelegt. Eine erneute Ablage ist nicht möglich. Das letzte Mal wurde es unter DokID ${foundDocIDs[i]} gespeichert." )
|
|
return -170
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
} else if( docType.getId().equals(Const.gDTS_DEQUI) ) {
|
|
|
|
// Kopie eines Dokumentes nach Equipment erlauben unter folgenden Bedingungen:
|
|
// Gleicher Hashwert innerhalb von Equipment -> keine Ablage
|
|
// Gleicher Hashwert innerhalb von Equipment und irgendeiner anderen Dokumentart -> Ablage erlauben
|
|
|
|
List<String> foundDocIDs = new ArrayList<>();
|
|
String lFileExtension = doc.getFileExtension()
|
|
|
|
if( !lFileExtension.equals("D3L") ) {
|
|
|
|
// Ermittlung des HashValue
|
|
PhysicalVersion[] pv = doc.getPhysicalVersions();
|
|
// Initialer Import
|
|
if(pv.size() == 1) {
|
|
String fileHash = pv[0].getFileHash()
|
|
|
|
def sqlStatement = "SELECT fd.doku_id as foundDocIDs " +
|
|
"FROM files_datentraeger fd " +
|
|
"LEFT JOIN firmen_spezifisch fs ON fs.doku_id = fd.doku_id " +
|
|
"WHERE fd.file_hash = '${fileHash}' " +
|
|
"AND fs.kue_dokuart = '${Const.gDTS_DEQUI}' ";
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
for(GroovyRowResult grr : sqlResult) {
|
|
foundDocIDs.add(grr.get("foundDocIDs"))
|
|
}
|
|
int lDocCount = sqlResult.size()
|
|
|
|
if( lDocCount >= 1 ) {
|
|
for(int i = 0; i < lDocCount; i++) {
|
|
if( !foundDocIDs[i].equals(doc.id())) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Das Dokument ist bereits ${lDocCount} Mal im d.3 abgelegt. Eine erneute Ablage ist nicht möglich. Das letzte Mal wurde es unter DokID ${foundDocIDs[i]} gespeichert.")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "The document already exists ${lDocCount} times in d.3. You are not allowed to import it again. The last Document ID is ${foundDocIDs[i]}).")
|
|
}
|
|
d3.log.info( "Das Dokument ist bereits ${lDocCount} Mal im d.3 abgelegt. Eine erneute Ablage ist nicht möglich. Das letzte Mal wurde es unter DokID ${foundDocIDs[i]} gespeichert." )
|
|
return -170
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0
|
|
}
|
|
|
|
|
|
@Entrypoint( entrypoint = "hook_insert_exit_20" )
|
|
public int insertExit20(D3Interface d3, Document doc, String fileDestination, Integer importOk, User user, DocumentType docType) {
|
|
if( docType.getId().equals(Const.gDTS_AHAUP) ) {
|
|
Functions.setMainfolder(d3, doc)
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
@Entrypoint( entrypoint = "hook_insert_exit_30" )
|
|
public int insertExit30 (D3Interface d3, Document doc, String fileDestination, Integer importOk, User user, DocumentType docType) {
|
|
|
|
def lTextMig
|
|
if(doc != null) {
|
|
lTextMig = doc.getText(4)
|
|
}
|
|
def lSalesgroup
|
|
def lFileExtension
|
|
def lCount
|
|
def lReturn
|
|
def lSubject
|
|
def lDokGroup
|
|
if(doc != null) {
|
|
lDokGroup = doc.field[Const.gDDF_DOKGROUP]
|
|
}
|
|
def lAndClause
|
|
def lRetCode
|
|
def lRetVal
|
|
def pRowCount
|
|
|
|
|
|
def lUser = ""
|
|
if(user != null) {
|
|
lUser = user.id();
|
|
}
|
|
|
|
if ( docType.getId().equals(Const.gDTS_DABTE) ) {
|
|
Functions.inheritTeamdoc(d3, doc, lUser)
|
|
}
|
|
|
|
// d3.log.info("Der Besitzer lautet ${lUser} und der Text ${lTextMig} und der Importstatus ${importOk}")
|
|
if( importOk != 0 ) {
|
|
|
|
if ( Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gAktuellVersInternID) ) {
|
|
// OPG-2024 - Erstellung Hook zur Füllung des Attributs "interne Version" mit der Versionsinformation des d.3 Dokuments
|
|
// Technikdokumenten (DMDOK) - DDF 88 soll mit der aktuellen Versionsnummer befüllt werden
|
|
Functions.setInternalVersion( d3, doc.id() );
|
|
}
|
|
|
|
|
|
//Wenn für Opportunity Dokumente mehrere Opportunity Nummern eingetragen sind, rufe die Funktion zur Erstellung der d3l Datei auf
|
|
if ( docType.getId().equals(Const.gDTS_DKUKO) || (Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gWeitProjektnummerID) || Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gWeitOpportunityID)) ) {
|
|
|
|
if( lUser == "hostimp" ) {
|
|
// 01.08.2017 Es können nun Kundenkontaktdokumente auch per Hostimport angeliefert werden. (vorher war in dieser Funktion alles was per Hostimport hereinkam ausgeschlossen!)
|
|
// Für diese Dokumente sollen zu den zugehörigen Kundenkontakt IDs D3L Dateien erstellt werden.
|
|
// Da diese D3L Dateien dann ebenfalls per Hostimport hereinkommen benötigen wir eine Prüfung, dass nicht für D3L Dateien weitere D3L Dateien erstellt weden.
|
|
// Diese Prüfung erfolgt nun über die Dateiextension.
|
|
lFileExtension = doc.getFileExtension()
|
|
}
|
|
|
|
if ( docType.getId().equals(Const.gDTS_DKUKO) && (!doc.field[Const.gDDF_KONTAKTNUMMER].equals("") && doc.field[Const.gDDF_KONTAKTNUMMER] != null) && !lFileExtension.equals("d3l") && !lFileExtension.equals("D3L") ) {
|
|
|
|
def lOppCount
|
|
def lKuKoID = doc.field[Const.gDDF_KONTAKTNUMMER]
|
|
def lOppNRMain = doc.field[Const.gDDF_OPPNUMMER]
|
|
def lProjNrMain = doc.field[Const.gDDF_AUFTRNR]
|
|
def lProzessMain = doc.field[Const.gDDF_PROZESS]
|
|
def lKdNummerMain = doc.field[Const.gDDF_KNR]
|
|
List<String> lOppNR = new ArrayList<>();
|
|
List<String> lProjNr = new ArrayList<>();
|
|
List<String> lProzess = new ArrayList<>();
|
|
List<String> lDokIdRef = new ArrayList<>();
|
|
List<String> lKdName = new ArrayList<>();
|
|
List<String> lKdNummer = new ArrayList<>();
|
|
|
|
def sqlStatement =
|
|
"SELECT doku_id as lDokIdRef, dok_dat_feld_${Const.gDDF_OPPNUMMER} as lOppNR, " +
|
|
"dok_dat_feld_${Const.gDDF_AUFTRNR} as lProjNr, dok_dat_feld_${Const.gDDF_PROZESS} as lProzess, " +
|
|
"dok_dat_feld_${Const.gDDF_KNAME} as lKdName, dok_dat_feld_${Const.gDDF_KNR} as lKdNummer " +
|
|
"FROM firmen_spezifisch " +
|
|
"WHERE dok_dat_feld_${Const.gDDF_KONTAKTNUMMER} = '${lKuKoID}' " +
|
|
"AND kue_dokuart = '${Const.gDTS_AKONT}' ";
|
|
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement)
|
|
|
|
if( sqlResult != null && sqlResult.size() > 0) {
|
|
lOppCount = sqlResult.size();
|
|
for(GroovyRowResult grr : sqlResult) {
|
|
lOppNR.add(grr.get("lOppNR"))
|
|
lProjNr.add(grr.get("lProjNr"))
|
|
lProzess.add(grr.get("lProzess"))
|
|
lDokIdRef.add(grr.get("lDokIdRef"))
|
|
lKdName.add(grr.get("lKdName"))
|
|
lKdNummer.add(grr.get("lKdNummer"))
|
|
}
|
|
}
|
|
|
|
// Es ist nur notwendig das Kundenkontaktdokument zu clonen, falls es mehr als eine passende Akte hierzu gibt
|
|
if ( lOppCount > 1 ) {
|
|
for (int i = 0; i < lOppCount; i++) {
|
|
if ( !lOppNRMain.equals(lOppNR.get(i)) && lProzess.get(i).equals("0201") ) {
|
|
lReturn = Functions.createLinkFiles(d3, doc.id(), lOppNR.get(i), lProjNr.get(i), lProzess.get(i), lDokIdRef.get(i), lKdName.get(i), lKdNummer.get(i), "", "")
|
|
} else if ( !lProjNrMain.equals(lProjNr.get(i)) && lProzess.get(i).equals("0202") ) {
|
|
lReturn = Functions.createLinkFiles(d3, doc.id(), lOppNR.get(i), lProjNr.get(i), lProzess.get(i), lDokIdRef.get(i), lKdName.get(i), lKdNummer.get(i), "", "")
|
|
} else if ( !lKdNummerMain.equals(lKdNummer.get(i)) && lProzess.get(i).equals("0200") ) {
|
|
lReturn = Functions.createLinkFiles(d3, doc.id(), lOppNR.get(i), lProjNr.get(i), lProzess.get(i), lDokIdRef.get(i), lKdName.get(i), lKdNummer.get(i), "", "")
|
|
}
|
|
}
|
|
}
|
|
|
|
//jleu - 09.11.2016 - Wenn einer neuer Besuchsbericht importiert wird, soll eine Gruppe darüber informiert werden
|
|
if ( docType.getId().equals(Const.gDTS_DKUKO) && doc.field[Const.gDDF_DOKGROUP].equals(Const.gDOKUGRP) ) {
|
|
lSubject = "Kundenbericht von ${lUser} mit Titel ${doc.field[Const.gDDF_ERDATE]} I ${doc.field[Const.gDDF_DOKTITLE]}"
|
|
boolean lExpandGroups = true // JPL -> 1
|
|
boolean lIgnoreCheckout = true // JPL -> 1
|
|
def lSender = "d3_mailser"
|
|
def lFileExtHold = ""
|
|
|
|
lFileExtHold = doc.getFileExtension()
|
|
if ( !lFileExtHold.equals("D3L") ) {
|
|
//Sende einen Postkorbeintrag an die entsprechende Gruppe
|
|
lRetVal = d3.call.hold_file_send(Const.gINFOGRP, lSubject, doc.id(), null, null, lExpandGroups, lIgnoreCheckout, null, null, lSender, 0, false, false, null, 0, false);
|
|
d3.log.info("SendHoldFile Returnwert - ${lRetVal} - ${lUser} Titel ${doc.field[Const.gDDF_ERDATE]} I ${doc.field[Const.gDDF_DOKTITLE]}");
|
|
} else {
|
|
d3.log.info("Kein Postkorbeintrag - d3l Datei Importiert");
|
|
}
|
|
}
|
|
|
|
} else if( !lFileExtension.equals("d3l") && !lFileExtension.equals("D3L") ) {
|
|
for(int i = 1; i <= Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); i++) {
|
|
if ( doc.field[Const.gDDF_OPPNRM][i] != null && !docType.getId().equals(Const.gDTS_DMAUF) && !docType.getId().equals(Const.gDTS_DMDOK) && !docType.getId().equals(Const.gDTS_DMSPE) ) {
|
|
def lOppNR = doc.field[Const.gDDF_OPPNRM][i]
|
|
lReturn = Functions.createLinkFiles(d3, doc.id(), lOppNR, "", "", "", "", "", "", "");
|
|
} else if ( (!doc.field[Const.gDDF_WEITAUFTRAGSNR][i].equals("") && doc.field[Const.gDDF_WEITAUFTRAGSNR][i] != null) && !docType.getId().equals(Const.gDTS_DMEOP) && !docType.getId().equals(Const.gDTS_DOPPD) && !docType.getId().equals(Const.gDTS_DVERD) ) {
|
|
def lOppNR = ""
|
|
def lProjNr = doc.field[Const.gDDF_WEITAUFTRAGSNR][i]
|
|
lReturn = Functions.createLinkFiles(d3, doc.id(), lOppNR, lProjNr, docType.getId(), "", "", "", "", "");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//Wenn mehrere Beleg oder SR-ID Nummern eingetragen sind, rufe die Funktion zur Erstellung der d3l Datei auf (#Service)
|
|
if ( (Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gWeitereBelegNrID) || Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gWeitereSRIDID)) && !doc.getFileExtension().equals("d3l") && !doc.getFileExtension().equals("D3L") ) {
|
|
for(int i = 1; i <= Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); i++) {
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gWeitereBelegNrID) ) {
|
|
def lBelegNr = doc.field[Const.gDDF_WEITEREBELEGNR][i]
|
|
if(lBelegNr != null) {
|
|
Functions.createLinkFilesService( d3, doc, lBelegNr, null );
|
|
}
|
|
} else if( Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gWeitereSRIDID) ) {
|
|
def lSrId = doc.field[Const.gDDF_WEITERESRID][i]
|
|
if(lSrId != null) {
|
|
Functions.createLinkFilesService( d3, doc, null, lSrId );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// imue 26.08.2020: Ergänzung für Equipment
|
|
if ( Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gWeitereEquipmentID) ) {
|
|
for(int i = 1; i <= Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); i++) {
|
|
String currentEquipment = doc.field[Const.gDDF_WEITEREEQUIPMENT][i];
|
|
if(currentEquipment != null) {
|
|
Functions.createLinkFilesEquipment(d3, doc, currentEquipment);
|
|
}
|
|
}
|
|
}
|
|
|
|
// imue 06.05.2022: Ergänzung für Einkauf
|
|
if ( Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gWeitereEinkaufBelegNrID) ) {
|
|
for(int i = 1; i <= Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); i++) {
|
|
String lBelegNr = doc.field[Const.gDDF_WEITEREBELEGNR][i];
|
|
if(lBelegNr != null) {
|
|
Functions.createLinkFilesPurchase(d3, doc, lBelegNr);
|
|
}
|
|
}
|
|
}
|
|
|
|
if( lTextMig.equals("Migration") ) {
|
|
|
|
// Das Attribut "Akte" wird im Maschinenprojekt bis auf die Ausnahme ECR automatisch anhand der Dokumentgruppe und der Dokumentart (Anwendungsfall) ermittelt
|
|
// 25.07.2016/dkle: Anpassung auf die neuen Dokumentgruppen von ECR
|
|
//Schlüsselumstellung "Medien" -> DG074
|
|
Functions.setAttributSubject(d3, doc, docType, user.id());
|
|
|
|
} else {
|
|
|
|
d3.log.info("Start proc insertExit30 - docId = ${doc.id()}, pFileDest = ${doc.getFileExtension()}, pImportOk = ${importOk}, lUser = ${lUser}, pDocTypeShort = ${docType.getId()}")
|
|
|
|
//jleu 18.01.2017 Schulungsdokumentation
|
|
if (docType.getId().equals(Const.gDTS_DSCHU)) {
|
|
//Die Funktion erstellt eine sucheschulungattr.html Datei
|
|
//die auf den d.3one Server der jeweiligen Umgebung nach c:\inetpub\wwwroot kopiert werden muss
|
|
//Die Datei sucheschulungattr.html stellt eine Suche über Werte aus der Dokumtart Schulungsdokumentation bereit.
|
|
Functions.createSearchHTML(d3, doc)
|
|
} //Ende Schulungsdokumentation
|
|
|
|
if (docType.getId().equals(Const.gDTS_DWISS)) {
|
|
// call CreateSearchHTML(pDocTypeShort)
|
|
Functions.sendMailRecom(d3, doc, lUser)
|
|
}
|
|
|
|
// imue 15.04.2019 - OPG-2133 - beim Import muss die Hauptangebot_Nr immer leer sein
|
|
if( docType.getId().equals(Const.gDTS_AUNTE) && (doc.field[Const.gDDF_HAUPTOPPANNR] != null && !doc.field[Const.gDDF_HAUPTOPPANNR].equals("")) ) {
|
|
doc.field[Const.gDDF_HAUPTOPPANNR] = "";
|
|
try {
|
|
doc.updateAttributes("d3groovy", true)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, doc.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_AUNTE) && ( doc.field[Const.gDDF_HAUPTOPPANNR] == null || doc.field[Const.gDDF_HAUPTOPPANNR].equals("") ) ) {
|
|
lReturn = Functions.createOfferFolder(d3, doc, docType.getId());
|
|
}
|
|
|
|
//jleu 08.03.2017 Erstelle Unterakten Marketingprojekt
|
|
if( docType.getId().equals(Const.gDTS_AMARK)) {
|
|
Functions.createMarketResearchFolder(d3, doc, doc.field[Const.gDDF_MARKETINGPROJEKT])
|
|
}
|
|
|
|
// --------------------------------------------------------------
|
|
// ######## Anpassung zum Prototyp für Maschinenprojekte V2 ########
|
|
// dkle 06.12.2016: Bei Anlage der Akte Kundenkontakt mit einer
|
|
// Kundenkontakt_ID die bereits besteht sollen alle vorhandenen Dokumente
|
|
// per d3l in die neue Akte verlinkt werden
|
|
// --------------------------------------------------------------
|
|
if( docType.getId().equals(Const.gDTS_AKONT) ) {
|
|
Functions.createD3lForDKUKO(d3, doc, doc.field[Const.gDDF_KONTAKTNUMMER] )
|
|
}
|
|
|
|
// --------------------------------------------------------------
|
|
//
|
|
// ######## Anpassung zum Prototyp für Maschinenprojekte ########
|
|
// Bei Anlage der Akte Ergebnis Opportunity wird automatisch die Kopie der
|
|
// Ergebnisdokumente ausgelöst
|
|
// --------------------------------------------------------------
|
|
if( docType.getId().equals(Const.gDTS_AMEOP) && (doc.field[Const.gDDF_BASEOPP] != null && !doc.field[Const.gDDF_BASEOPP].equals("")) ) {
|
|
def lBaseOpp = doc.field[Const.gDDF_BASEOPP];
|
|
def lOrderNo = doc.field[Const.gDDF_AUFTRNR];
|
|
|
|
//... und verknüpfe die Ergebnisdokumente in die Maschinenprojektakte
|
|
lReturn = Functions.copyResultDocs(d3, doc, lBaseOpp, lOrderNo )
|
|
}
|
|
|
|
// Das Attribut "Akte" wird im Maschinenprojekt bis auf die Ausnahme ECR automatisch anhand der Dokumentgruppe und der Dokumentart (Anwendungsfall) ermittelt
|
|
Functions.setAttributSubject(d3, doc, docType, user.id());
|
|
|
|
// 11.05.2020 - kann eigentlich im InsertExit nicht auftreten, daher erstmal auskommentiert
|
|
// Maschinenprojekt Wenn der Status der Unterakte ECR auf "Genehmigung" steht soll eine Dublette alle Ergebnisdokumente in die Dokumentart DMSPE kopiert werden.
|
|
//if( docType.getId().equals(Const.gDTS_AMECR) && doc.field[Const.gDDF_ECRSTATUS].equals("E0003") ) {
|
|
// def lActID = doc.field[Const.gDDF_AKTIVITAETSID]
|
|
// def lOrderID = doc.field[Const.gDDF_AUFTRNR]
|
|
// Functions.copyApprovedECR(d3, lActID, lOrderID, "");
|
|
//}
|
|
|
|
// Eine neue Unterakte ECR wird zu einer bestehenden Aktivitäts-ID angelegt. In dem Falle sollen alle Dokumente der "Originalen" Akte per D3L in die neue Akte verknüpft werden
|
|
if( docType.getId().equals(Const.gDTS_AMECR) && !doc.getText(4).equals("Original") ) {
|
|
Functions.createLinkFilesOrder(d3, doc, docType.getId());
|
|
}
|
|
|
|
|
|
//Splitte für alle Dokument- und Aktenarten zur Opportunity das Erstelldatum wenn nicht leer und schreibe die Werte in Jahr und Monat
|
|
// dkle, 02.02.2016 Dies gilt für alle Dokumentarten, sowie die Opportunityakte. Andernfalls wird im Insert Entry das Jahr/Monat anhand des aktuellen Datums ermittelt
|
|
if ( doc.field[Const.gDDF_ERDATE] != null && Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gEreignisDateID) == true ) {
|
|
|
|
SimpleDateFormat dateFormatYear = new SimpleDateFormat("yyyy");
|
|
def lJahr = dateFormatYear.format(doc.field[Const.gDDF_ERDATE]);
|
|
SimpleDateFormat dateFormatMonth = new SimpleDateFormat("MM");
|
|
def lMonat = dateFormatMonth.format(doc.field[Const.gDDF_ERDATE]);
|
|
|
|
try {
|
|
doc.field[Const.gDDF_JAHR] = lJahr;
|
|
doc.field[Const.gDDF_MONAT] = lMonat;
|
|
doc.updateAttributes("d3groovy", true)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, doc.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
|
|
// 31.07.2017 Überprüfung, ob das notwendig ist, oder ob d.search dieses Dokument nicht am Ende des imports ohnehin erhält
|
|
d3.call.document_send_to_dsearch( doc.id(), "", 0, "", false, "Fr", 0, "d3groovy")
|
|
}
|
|
|
|
if (docType.getId().equals(Const.gDTS_ABAUP)) {
|
|
Functions.createConstDocFolder(d3, doc, doc.field[Const.gDDF_BAUPROJEKT])
|
|
}
|
|
|
|
// phoer 20160823: Wenn beim Insert der Maschinenprojektdokumente das Zuordnung Kundenkontakt gefüllt ist...
|
|
if( doc.field[Const.gDDF_MAPPCUSTACTION] != null &&
|
|
( docType.getId().equals(Const.gDTS_DKOMM)||
|
|
docType.getId().equals(Const.gDTS_DLIKO) ||
|
|
docType.getId().equals(Const.gDTS_DPRST) ||
|
|
docType.getId().equals(Const.gDTS_DMSPE) ||
|
|
docType.getId().equals(Const.gDTS_DMECR) ||
|
|
docType.getId().equals(Const.gDTS_DMDOK) ||
|
|
docType.getId().equals(Const.gDTS_DMAUF) ) ) {
|
|
//...rufe die Funktion zum Kopieren des Dokuments auf, damit es in die Kundenkontaktakte importiert wird
|
|
Functions.copyCustAction(d3, doc, doc.field[Const.gDDF_MAPPCUSTACTION]);
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_DMECR) && ( lUser.equals("hostimp") ) ) {
|
|
// Überprüfe, wenn es eine D3L Datei ist, ob diese schon existiert
|
|
// Falls ja, Bereinigung des Hostimport-Verzeichnisses
|
|
// 31.07.2017 Überprüfung, wie es dazu kommt, dass
|
|
// - Diese Funktion überhaupt existiert (ggf. schon beim Schreiben der D3L Prüfen, ob sie erstellt werden muss
|
|
// - Sie im Exit und nciht im Entry ist
|
|
if( doc.getText(4).equals("ToCopy") ) {
|
|
doc.setText(4, "");
|
|
try {
|
|
doc.updateAttributes("d3groovy", true)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, doc.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
Functions.copyApprovedECR( d3, "", "", doc.id() )
|
|
}
|
|
List<String> lECRDokID
|
|
def lFileName
|
|
def sqlStatement = "SELECT f.doku_id as lECRDokID " +
|
|
"FROM firmen_spezifisch as f, phys_datei as p " +
|
|
"WHERE f.dok_dat_feld_${Const.gDDF_AUFTRNR} = '${doc.field[Const.gDDF_AUFTRNR]}' " +
|
|
"AND f.dok_dat_feld_${Const.gDDF_AKTIVITAETSID} = '${doc.field[Const.gDDF_AKTIVITAETSID]}' " +
|
|
"AND p.datei_erw = 'D3L' " +
|
|
"AND ( p.text like '%${doc.getText(4)}%' OR p.text like '${doc.getText(4)}%' OR p.text like '%${doc.getText(4)}') " +
|
|
"AND f.kue_dokuart = '${Const.gDTS_DMECR}' " +
|
|
"AND p.doku_id = f.doku_id " +
|
|
"AND p.doku_id <> '${doc.id()}' "
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement)
|
|
pRowCount = sqlResult.size()
|
|
if( sqlResult != null ) {
|
|
for(GroovyRowResult grr : sqlResult) {
|
|
lECRDokID.add(grr.get("lECRDokID"))
|
|
}
|
|
}
|
|
if( pRowCount > 0 ) {
|
|
// Lösche die Datei aus dem Hostimport-Verzeichnis
|
|
d3.call.document_delete("HOSTIMP Es handelt sich um ein Duplikat", true, true, doc.id(), "d3groovy", false);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
// Aufruf der Funktion manage_d3l_Supp_Custo, wenn weitere Kunden_Nr oder weitere Lieferanten_Nr bei Kundendokumenten oder Lieferantendokumenten hinzugefügt oder entfernt werden
|
|
if( docType.getId().equals(Const.gDTS_DKUMA) || docType.getId().equals(Const.gDTS_DLIMA) ) {
|
|
// gDDF_WEITLIEFNR - gDDF_WEITKDNR
|
|
def lFileExt
|
|
lFileExt = doc.getFileExtension()
|
|
if( !lFileExt.equals("D3L") ) {
|
|
// d3.log.error( "Dokumentart: " + docType.getId() + " DokuID: " + doc.id() )
|
|
// Variablen setzen je nach Dokumentart
|
|
// Welches DDF ist zu befüllen?
|
|
// Welche Ziel-Dokumentart wird benötigt und muss abgefragt werden?
|
|
def lDDFToFill
|
|
def lScenario
|
|
def lBlock
|
|
if( docType.getId().equals(Const.gDTS_DKUMA) ) {
|
|
lDDFToFill = Const.gDDF_WEITKDNR
|
|
lScenario = "CustomerNumber"
|
|
}
|
|
else if( docType.getId().equals(Const.gDTS_DLIMA) ) {
|
|
lDDFToFill = Const.gDDF_WEITLIEFNR
|
|
lScenario = "SupplierNumber"
|
|
}
|
|
for(int i = 1; i <= Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); i++) {
|
|
if(doc.field[lDDFToFill][i] != null && !doc.field[lDDFToFill][i].equals("")) {
|
|
lBlock = "CREATE/UNBLOCK"
|
|
Functions.createD3lForSuppCusto(d3, lBlock, doc.field[lDDFToFill][i], lScenario, doc.id());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
d3.log.info("End proc insertExit30 - pDocId = ${doc.id()}, pFileDest = ${doc.getFileExtension()}, pImportOk = ${importOk}, pUser = ${lUser}, pDocTypeShort = ${docType.getId()}")
|
|
}
|
|
|
|
return 0;
|
|
} // end of insertExit30
|
|
|
|
|
|
/*
|
|
* Verknüpfen von Dokumenten bzw. Akten
|
|
* beinhaltet:
|
|
* + hook_link_entry_30 (aktiv)
|
|
* + hook_link_exit_10 (aktiv)
|
|
*/
|
|
|
|
@Entrypoint( entrypoint = "hook_link_entry_30" )
|
|
public int linkEntry30( D3Interface d3, Document docFather, Document docChild ){
|
|
|
|
d3.log.info("Start proc linkEntry30 - doku_id_ref_ueber = ${docFather.id()}, doku_id_ref_unter = ${docChild.id()}")
|
|
|
|
def child_doc_type_short = docChild.getType().getId()
|
|
def parent_doc_type_short = docFather.getType().getId()
|
|
//def lUser = d3.remote.getUserName() -> 26.06.2020 führte zu fehlerhaften LIN002 Jobs und wurde daher auf getOwner() geändert
|
|
def lUser = docChild.getOwner()
|
|
def lLinkAllowed
|
|
def lRetCode
|
|
def lLinkAllowed2
|
|
def lIdentifier
|
|
def lIdentifierF
|
|
def lFather
|
|
def lChild
|
|
def lOppNo
|
|
def lAuftrNo
|
|
def lText4Unter
|
|
def lReturn
|
|
def pRowCount
|
|
def lCount
|
|
def lRetVal
|
|
|
|
d3.log.info("linkEntry30 - lUser = ${lUser}");
|
|
|
|
lText4Unter = docChild.getText(4)
|
|
|
|
// OPG-2054 - imue 15.10.2019
|
|
if( ( parent_doc_type_short.equals(Const.gDTS_ALIMA) && !child_doc_type_short.equals(Const.gDTS_DLIMA) ) ||
|
|
( parent_doc_type_short.equals(Const.gDTS_ALONT) && !child_doc_type_short.equals(Const.gDTS_DLONT) ) ||
|
|
( parent_doc_type_short.equals(Const.gDTS_ALIKO) && !child_doc_type_short.equals(Const.gDTS_DLIKO) ) ) {
|
|
// Ablage ist mit einer anderen Konstellation nicht erlaubt - Abbruch ohne Usermeldung
|
|
return 9500;
|
|
}
|
|
|
|
if ( child_doc_type_short.equals(Const.gDTS_DWISS) || child_doc_type_short.equals(Const.gDTS_DSCHU) || child_doc_type_short.equals(Const.gDTS_DREGE) || child_doc_type_short.equals(Const.gDTS_DAREG)
|
|
|| child_doc_type_short.equals(Const.gDTS_ABAUN) || child_doc_type_short.equals(Const.gDTS_DBAUD) || child_doc_type_short.equals(Const.gDTS_AMARK) || child_doc_type_short.equals(Const.gDTS_AUNMA) || child_doc_type_short.equals(Const.gDTS_DMARK)
|
|
|| child_doc_type_short.equals(Const.gDTS_AGLAK) || child_doc_type_short.equals(Const.gDTS_AVEVO) || child_doc_type_short.equals(Const.gDTS_DVEDO) || child_doc_type_short.equals(Const.gDTS_DABTE) || child_doc_type_short.equals(Const.gDTS_AVODA)
|
|
|| child_doc_type_short.equals(Const.gDTS_AREME) || child_doc_type_short.equals(Const.gDTS_AHAUP) || child_doc_type_short.equals(Const.gDTS_ATEIL) || child_doc_type_short.equals(Const.gDTS_DOSSI) || child_doc_type_short.equals(Const.gDTS_AITSM)
|
|
|| child_doc_type_short.equals(Const.gDTS_DITSM)) {
|
|
//Überspringe die Verknüpfung
|
|
} else {
|
|
//lUser == "d3_server" || phoer 20170803: Auskommentiert, da sonst innerhalb der Aktenstruktur manuell verknüpft werden kann
|
|
def user = d3.archive.getUser( lUser );
|
|
if ( lUser != null && ( user.isMemberOfGroup( Const.gTECHNICAL_GROUP ) || lText4Unter.equals("SAP-Systemklon") || lUser.equals("hostimp") ) ) {
|
|
//Überspringe die Verknüpfung
|
|
} else if ( child_doc_type_short.equals(Const.gDTS_DPRST) ) {
|
|
// Ausnahme Projektorganisationsdokumente wegen Verwendung in beiden Anwendungsfällen
|
|
// 31.07.2017 teilweise werden Attribute doppelt geholt - prüfen!
|
|
lOppNo = docChild.field[Const.gDDF_OPPNUMMER]
|
|
lAuftrNo = docChild.field[Const.gDDF_AUFTRNR]
|
|
|
|
if ( !lOppNo.equals("") && lOppNo != null && ( parent_doc_type_short.equals(Const.gDTS_APROR) || parent_doc_type_short.substring(0,1).equals("D") ) ) {
|
|
//lasse die Verknüpfung zu
|
|
}
|
|
else if ( !lAuftrNo.equals("") && lAuftrNo != null && ( parent_doc_type_short.equals(Const.gDTS_AMUPO) || parent_doc_type_short.substring(0,1).equals("D") ) ) {
|
|
//lasse die Verknüpfung zu
|
|
} else if ( parent_doc_type_short.substring(0,1).equals("A") ) {
|
|
//Prüfung ob die gewünschte Verlinkung erlaubt ist
|
|
def sqlStatement = "SELECT dok_dat_feld_${Const.gDDF_DTSVATER} as lFather, dok_dat_feld_${Const.gDDF_DTSKIND} as lChild " +
|
|
"FROM firmen_spezifisch " +
|
|
"WHERE kue_dokuart = '${Const.gDTS_AABWL}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_DTSVATER} = '${parent_doc_type_short}' "
|
|
|
|
GroovyRowResult grr = d3.sql.firstRow(sqlStatement);
|
|
if(grr != null && grr.size() > 0) {
|
|
lFather = grr.get("lFather")
|
|
lChild = grr.get("lChild")
|
|
}
|
|
|
|
if ( lFather.equals(parent_doc_type_short) && lChild.equals("A") ) {
|
|
//Verknüpfung darf erfolgen
|
|
} else {
|
|
//Für diesen Returnwert kann kein Additional Info Text vergeben werden, denn dieser wird dem Benutzer nicht angezeigt! Die msglib.usr muss weiterhin gepflegt werden
|
|
d3.log.error("LinkEntry30 - return -155")
|
|
return -155
|
|
}
|
|
}
|
|
} else {
|
|
lIdentifier = child_doc_type_short.substring(0,1)
|
|
lIdentifierF = parent_doc_type_short.substring(0,1)
|
|
|
|
if ( lIdentifier.equals("A") || lIdentifier.equals("a") ) {
|
|
|
|
//Prüfung ob die gewünschte Verlinkung erlaubt ist
|
|
def sqlStatement = "SELECT * " +
|
|
"FROM firmen_spezifisch " +
|
|
"WHERE kue_dokuart = '${Const.gDTS_AABWL}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_DTSVATER} = '${parent_doc_type_short}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_DTSKIND} = '${lIdentifier}' "
|
|
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
lLinkAllowed = sqlResult.size()
|
|
|
|
if ( lLinkAllowed == 1 ) {
|
|
//Für diesen Returnwert kann kein Additional Info Text vergeben werden, denn dieser wird dem Benutzer nicht angezeigt! Die msglib.usr muss weiterhin gepflegt werden
|
|
// Hier wird der Standard-Fehlercode überschrieben! 75!
|
|
d3.log.error("LinkEntry30 - return 9425")
|
|
return 9425
|
|
} else {
|
|
//Prüfung ob die gewünschte Verlinkung erlaubt ist
|
|
def sqlStatementSec = "SELECT * " +
|
|
"FROM firmen_spezifisch " +
|
|
"WHERE kue_dokuart = '${Const.gDTS_AABWL}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_DTSVATER} = '${parent_doc_type_short}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_DTSKIND} = '${child_doc_type_short}'"
|
|
|
|
List<GroovyRowResult> sqlResultSec = d3.sql.executeAndGet(sqlStatementSec);
|
|
lLinkAllowed2 = sqlResultSec.size()
|
|
|
|
if ( lLinkAllowed2 == 0 ) {
|
|
//Für diesen Returnwert kann kein Additional Info Text vergeben werden, denn dieser wird dem Benutzer nicht angezeigt! Die msglib.usr muss weiterhin gepflegt werden
|
|
d3.log.error("LinkEntry30 - return -150")
|
|
return -150
|
|
} else {
|
|
//Akten dürfen verknüpft werden
|
|
}
|
|
}
|
|
} else if ( lIdentifier.equals("D") && lIdentifierF.equals("D") ) {
|
|
//Verknüpfung darf erfolgen
|
|
} else if ( ( lIdentifier.equals("D") || lIdentifier.equals("d") ) && (lIdentifierF.equals("A") || lIdentifierF.equals("a") ) ) {
|
|
|
|
//Prüfung ob die gewünschte Verlinkung erlaubt ist
|
|
def sqlStatement = "SELECT dok_dat_feld_${Const.gDDF_DTSVATER} as lFather, dok_dat_feld_${Const.gDDF_DTSKIND} as lChild " +
|
|
"FROM firmen_spezifisch " +
|
|
"WHERE kue_dokuart = '${Const.gDTS_AABWL}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_DTSVATER} = '${parent_doc_type_short}' "
|
|
|
|
GroovyRowResult grr = d3.sql.firstRow(sqlStatement);
|
|
if(grr != null && grr.size() > 0) {
|
|
lFather = grr.get("lFather")
|
|
lChild = grr.get("lChild")
|
|
}
|
|
|
|
if ( lFather.equals(parent_doc_type_short) && lChild.equals("A") ) {
|
|
//Verknüpfung darf erfolgen
|
|
} else {
|
|
//Für diesen Returnwert kann kein Additional Info Text vergeben werden, denn dieser wird dem Benutzer nicht angezeigt! Die msglib.usr muss weiterhin gepflegt werden
|
|
d3.log.error("LinkEntry30 - return -155")
|
|
return -155
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Wenn das Dokument bis hierher gekommen ist darf die Verknüpfung generell stattfinden.
|
|
// Weitere Prüfung 03 ECR Dokumente -> Unterakte ECR ist diese das Original (anhand Aktivitäts-ID),
|
|
// Ja = Es passiert nichts
|
|
// Nein = Es muss an die Original gelinkt werden.
|
|
if( child_doc_type_short.equals(Const.gDTS_DMECR) && parent_doc_type_short.equals(Const.gDTS_AMECR) ) {
|
|
|
|
def lText1
|
|
def lText2
|
|
def lText3
|
|
def lText4
|
|
def lTextAll
|
|
def lText4Link
|
|
def lChildActivity
|
|
def lFatherActivity
|
|
def lProjNumberTmp
|
|
def lFileExt
|
|
def lFatherOriginalDocID
|
|
|
|
lChildActivity = docChild.field[Const.gDDF_AKTIVITAETSID]
|
|
lFatherActivity = docFather.field[Const.gDDF_AKTIVITAETSID]
|
|
|
|
lText1 = docFather.getText(1)
|
|
lText2 = docFather.getText(2)
|
|
lText3 = docFather.getText(3)
|
|
lText4 = docFather.getText(4)
|
|
lFileExt = docChild.getFileExtension()
|
|
|
|
|
|
if( lText1.equals("Original") || lText2.equals("Original") || lText3.equals("Original") || lText4.equals("Original") ) {
|
|
lTextAll = "Original"
|
|
}
|
|
if( lFileExt.equals("d3l") || lFileExt.equals("D3L") ) {
|
|
// Wird manuell verlinkt nichts zu tun
|
|
// d3.log.error( "lFileExt: ${lFileExt} Wird manuell verlinkt nichts zu tun" )
|
|
|
|
// lText2 = docFather.getText(4)
|
|
// lRetCode = d3.call.link_documents( lFatherOriginalDocID[1], docChild.id(), "d3groovy", false, false)
|
|
// if( lRetCode != 0 ) {
|
|
// d3.log.error( "Fehler bei der Verknüpfung des Dokumentes mit der Originalakte" )
|
|
// }
|
|
|
|
} else if( lChildActivity.equals(lFatherActivity) && lTextAll.equals("Original") ) {
|
|
// Verknüpfung darf erfolgen
|
|
// erstelle d3l Dateien in allen zugehörigen Aktivitäts-IDs
|
|
// Suche nach allen Unterakten ECR mit dieser Aktivitäts-ID
|
|
|
|
// 31.07.2017 Frage: Kann es zu Timing Problemen kommen??? Aktenplan läuft schon an während das DOK schon in diesem Einsprungspunkt ist.
|
|
def sqlStatement = "SELECT fs.doku_id as lFatherD3LDocID " +
|
|
"FROM firmen_spezifisch fs, phys_datei pd " +
|
|
"WHERE fs.doku_id = pd.doku_id " +
|
|
"AND fs.kue_dokuart = '${Const.gDTS_AMECR}' " +
|
|
"AND fs.dok_dat_feld_${Const.gDDF_AKTIVITAETSID} = '${lChildActivity}' "
|
|
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
pRowCount = sqlResult.size()
|
|
|
|
for( GroovyRowResult grr : sqlResult ) {
|
|
try {
|
|
Document docTemp2 = d3.archive.getDocument(grr.get("lFatherD3LDocID"), "d3groovy")
|
|
lText4Link = docTemp2.getText(4)
|
|
|
|
if( !lText4Link.equals("Original") && !docTemp2.id().equals(docFather.id() ) ) {
|
|
Functions.createD3lForECR(d3, docChild.id(), docTemp2.id());
|
|
}
|
|
} catch(Exception e) {
|
|
d3.log.error("Exception in linkentry30 - " + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
else if( ( lChildActivity.equals(lFatherActivity) && !lTextAll.equals("Original") && !lChildActivity.substring(0,4).equals("Neue") && !lChildActivity.equals("0000000000") ) || !lChildActivity.equals(lFatherActivity) ) {
|
|
// Suche das Original
|
|
// erstelle den passenden Link
|
|
|
|
def sqlStatement = "SELECT fs.doku_id as lFatherOriginalDocID " +
|
|
"FROM firmen_spezifisch fs, phys_datei pd " +
|
|
"WHERE fs.doku_id = pd.doku_id " +
|
|
"AND fs.kue_dokuart = '${Const.gDTS_AMECR}' " +
|
|
"AND fs.dok_dat_feld_${Const.gDDF_AKTIVITAETSID} = '${lChildActivity}' " +
|
|
"AND ( pd.text like '%Original%' OR pd.text like 'Original%' OR pd.text like '%Original') "
|
|
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
if(sqlResult != null && sqlResult.size() > 0) {
|
|
pRowCount = sqlResult.size()
|
|
lFatherOriginalDocID = sqlResult.getAt(0).get("lFatherOriginalDocID")
|
|
}
|
|
|
|
if( pRowCount != 1 ) {
|
|
d3.log.error( "Es konnte keine korrekte Verknüpfung erstellt werden" )
|
|
d3.log.error("LinkEntry30 - return -185")
|
|
return -185
|
|
} else {
|
|
// verlinken mit der passenden Akte
|
|
// 31.07.2017 unschön, kann zu Problemen führen, einmal prüfen, obs Probleme gibt
|
|
if( !docFather.id().equals(lFatherOriginalDocID) ) {
|
|
Document docTemp = d3.archive.getDocument(lFatherOriginalDocID)
|
|
lProjNumberTmp = docTemp.field[Const.gDDF_AUFTRNR]
|
|
if ( lProjNumberTmp != null ) {
|
|
docChild.field[Const.gDDF_AUFTRNR] = lProjNumberTmp
|
|
try {
|
|
docChild.updateAttributes("d3groovy", false)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, docChild.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
d3.log.error("Fehler bei der Zuordnung zur Originalakte eines ECR/Change Order Dokuments. Dokument ID: ${docChild.id()} ")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
d3.log.error( "Verknüpfung NICHT Originalakte mit Originaldatei verhindern" )
|
|
d3.log.error("LinkEntry30 - return -155")
|
|
return -155
|
|
}
|
|
}
|
|
|
|
//jleu 20.02.2017 Prüfen, ob Baukten gleich sind, sonst nicht erlauben
|
|
if( ( child_doc_type_short.equals(Const.gDTS_DBAUD) && ( parent_doc_type_short.equals(Const.gDTS_ABAUN) || parent_doc_type_short.equals(Const.gDTS_ABAUK) ) ) || ( child_doc_type_short.equals(Const.gDTS_ABAUN) && parent_doc_type_short.equals(Const.gDTS_ABAUK) ) ) {
|
|
|
|
def BauakteUeber
|
|
def BauakteUnter
|
|
def i = 0
|
|
def j = 1
|
|
def ResString = ""
|
|
def CountRes
|
|
|
|
BauakteUeber = docFather.field[Const.gDDF_BAUAKTE]
|
|
BauakteUnter = docChild.field[Const.gDDF_BAUAKTE]
|
|
|
|
if( !BauakteUeber.equals(BauakteUnter) ) {
|
|
d3.log.error("LinkEntry30 - return -155")
|
|
return -155
|
|
}
|
|
|
|
// Umsetzung in Groovy von d3set_get_filter? - Siehe Ticket D003769593 - WORKAROUND:
|
|
if ( parent_doc_type_short.equals(Const.gDTS_ABAUK) && child_doc_type_short.equals(Const.gDTS_DBAUD) ) {
|
|
|
|
def sqlStatement = "SELECT fsmv.value_char as value " +
|
|
"FROM firm_spez_mult_val fsmv " +
|
|
"LEFT JOIN firmen_spezifisch fs ON fsmv.doku_id = fs.doku_id " +
|
|
"WHERE kue_dokuart = '\$SET\$' " +
|
|
"AND fs.doku_id = '${SystemSpecificConst.gResBauakteID}'"
|
|
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
if( sqlResult.size() > 1 ) {
|
|
for(GroovyRowResult grr : sqlResult) {
|
|
ResString = ResString + grr.get("value")
|
|
}
|
|
} else if( sqlResult.size() == 1 ) {
|
|
ResString = sqlResult.getAt(0).get("value")
|
|
}
|
|
String[] splittedString = ResString.split(";")
|
|
for ( String s : splittedString ) {
|
|
if( BauakteUnter.equals(s) ) {
|
|
d3.log.error("LinkEntry30 - return -155")
|
|
return -155
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
d3.log.info("End proc linkEntry30 - doku_id_ref_ueber = ${docFather.id()}, doku_id_ref_unter = ${docChild.id()}")
|
|
// 31.07.2017 Generell bessere Kommentare und Erklärungen in die Funktion einbringen
|
|
return 0
|
|
|
|
}
|
|
|
|
@Entrypoint( entrypoint = "hook_link_exit_10" )
|
|
public int linkExit10(D3Interface d3, Document docFather, Document docChild, Integer errorCode) {
|
|
/*
|
|
* Ausführungsbeschreibung:
|
|
* Wenn es sich um einen Projektlieferanten handelt, dessen Projekt- oder Opportunity-Nummer sich ändert,
|
|
* dann hole alle Kinder und gebe Ihnen das neue Erkennungsattribut, damit der Aktenplan für die Kinder erneut ausgeführt wird (Verknüpfung)
|
|
*/
|
|
|
|
d3.log.info( "linkExit10 ( ${docFather.id()}, ${docChild.id()}, ${errorCode} )" )
|
|
|
|
def userName = ""
|
|
if(d3.remote.getUserName() != null || !d3.remote.getUserName().equals("") ) {
|
|
userName = d3.remote.getUserName()
|
|
}
|
|
|
|
//d3.log.error( "linkExit10 - Aufruf mit ${userName}" )
|
|
|
|
if( errorCode == 0 ) {
|
|
if( (docChild.getType().getId().equals(Const.gDTS_ALIKO)) && (userName != null && !userName.equals("d3_async") && (!userName.equals(""))) ) {
|
|
|
|
// Erkennungsattribut des Vaters holen - entweder Projektnummer oder OpportunityNummer
|
|
def fatherProjectNo = docFather.field[Const.gDDF_AUFTRNR]
|
|
def fatherOpporNo = docFather.field[Const.gDDF_OPPNUMMER]
|
|
|
|
String[] childrenList = d3.call.link_get_children(docChild.id(), "d3groovy")
|
|
|
|
d3.log.error( "linkExit10 ( ${docFather.id()} hat ${childrenList.size()} Kinder )" )
|
|
|
|
if( childrenList.size() > 0 ) {
|
|
for( String dokuId : childrenList ) {
|
|
// Workaround: Erkenenungsattribut des Kindes ändern, anstatt Aktenplan nochmals auslösen (JPL Lösung)
|
|
// d3.log.error("linkExit10 - fatherProjectNo = " + fatherProjectNo)
|
|
// d3.log.error("linkExit10 - fatherOpporNo = " + fatherOpporNo)
|
|
Document docTemp = d3.archive.getDocument(dokuId)
|
|
if(fatherProjectNo != null && !fatherProjectNo.equals("")) {
|
|
docTemp.field[Const.gDDF_AUFTRNR] = fatherProjectNo
|
|
} else if(fatherOpporNo != null && !fatherOpporNo.equals("")) {
|
|
docTemp.field[Const.gDDF_OPPNUMMER] = fatherOpporNo
|
|
}
|
|
try {
|
|
docTemp.updateAttributes("d3groovy", true)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, docTemp.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// imue 15.09.2020: Prüfung das der Kundenname bei Prozess Kunde übernommen wird
|
|
if( docChild.getType().getId().equals(Const.gDTS_APROZ) && (userName == null || (userName != null && userName.equals("d3_async"))) ) {
|
|
|
|
String lKundenNameFather = docFather.field[Const.gDDF_KNAME];
|
|
String lKundenNameChild = docChild.field[Const.gDDF_KNAME];
|
|
|
|
if(lKundenNameChild == null) {
|
|
d3.log.info("Kundenname wird gesetzt = " + lKundenNameFather)
|
|
docChild.field[Const.gDDF_KNAME] = lKundenNameFather;
|
|
try {
|
|
docChild.updateAttributes("d3groovy", true)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, docChild.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0
|
|
}
|
|
|
|
|
|
/*
|
|
* Aktualisierung der Eigenschaftswerte
|
|
* beinhaltet:
|
|
* + hook_upd_attrib_entry_20 (aktiv)
|
|
* + hook_upd_attrib_entry_10 (nicht in Nutzung)
|
|
* + hook_upd_attrib_exit_20 (aktiv)
|
|
*/
|
|
|
|
|
|
@Entrypoint( entrypoint = "hook_upd_attrib_entry_20" )
|
|
public int updateAttribEntry20(D3Interface d3, Document doc, User user, DocumentType docType, DocumentType docTypeNew) {
|
|
d3.log.debug("Start updateAttribEntry20");
|
|
|
|
def lCnt
|
|
def pRowCount
|
|
def lReturn
|
|
def lCount
|
|
def lRetCode
|
|
def lLength
|
|
def lReturn2
|
|
def lDokGroup
|
|
def lSubject
|
|
def lAndClause
|
|
|
|
def userName = ""
|
|
if(user != null) {
|
|
userName = user.id();
|
|
}
|
|
|
|
// Validierung der Administrativen Akten
|
|
if(docType.getId().equals(Const.gDTS_AAFOL) || docType.getId().equals(Const.gDTS_AZTXT)) {
|
|
int resultValidate = Functions.validateAdminFolder(d3, doc, "UPDATE")
|
|
if(resultValidate == 1) {
|
|
return -170
|
|
}
|
|
}
|
|
|
|
// Values for old_dok_dat_field
|
|
Document docTemp = d3.archive.getDocument(doc.id())
|
|
|
|
//Validieren der Prozessart
|
|
Functions.validateProcess(d3, doc)
|
|
|
|
d3.log.info( "updateAttribEntry20(${doc.id()}, ${userName}, ${docType.getId()}, ${docTypeNew.getId()} )" )
|
|
|
|
//jleu 01.08.2018 Vertragsdokumente
|
|
if( docType.getId().equals(Const.gDTS_EVDOK) || docType.getId().equals(Const.gDTS_EVUNT) ) {
|
|
def lRetVal = Functions.checkContractNumber(d3, doc)
|
|
if (lRetVal == 10) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT019049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT019001)
|
|
}
|
|
return -200
|
|
}
|
|
}
|
|
|
|
//jleu 21.05.2021 ITSM Dokumente
|
|
if( docType.getId().equals(Const.gDTS_DITSM) ) {
|
|
def RetVal = Functions.checkITSMNumber(d3, doc)
|
|
|
|
if (RetVal == 10)
|
|
{
|
|
// Meldung an den Benutzer, dass eine unbekannte ITSM ID verwendet wird
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT025049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT025001)
|
|
}
|
|
return -170
|
|
}
|
|
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_DLOEH) ) {
|
|
Functions.sixty2single(d3, doc)
|
|
}
|
|
|
|
//jleu 25.04.2018 Hauptvorgaenge
|
|
if( docType.getId().equals(Const.gDTS_AHAUP) ) {
|
|
Functions.entryFunctionMainfolder(d3, doc, user, 0)
|
|
}
|
|
|
|
|
|
//jleu 18.10.2017 Prüfen, ob Vorgang bereits existiert
|
|
if( docType.getId().equals(Const.gDTS_AVEVO) || docType.getId().equals(Const.gDTS_AREME) ) {
|
|
String caseold = docTemp.field[Const.gDDF_CASE];
|
|
String casenew = doc.field[Const.gDDF_CASE];
|
|
if ( !doc.field[Const.gDDF_CASE].equals(docTemp.field[Const.gDDF_CASE]) ) {
|
|
def sqlStatement = "SELECT * FROM firmen_spezifisch as lVorgang where kue_dokuart = '${docType.getId()}' and dok_dat_feld_${Const.gDDF_CASE} = '${doc.field[Const.gDDF_CASE]}' "
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement)
|
|
lCnt = sqlResult.size()
|
|
if( lCnt != 0 ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Vorgang existiert bereits")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Case name already exists")
|
|
}
|
|
return -171
|
|
}
|
|
}
|
|
}
|
|
// Ende Prüfung Vorgang
|
|
|
|
def InvalidData
|
|
def lECRStatus
|
|
def lChildCount
|
|
|
|
if( !docType.getId().equals(Const.gDTS_SAPDO) ) {
|
|
d3.log.info("Start proc updateAttribEntry20 - pDocId = ${doc.id()}, pUser = ${userName}, pDocTypeShort = ${docType.getId()}")
|
|
|
|
def h_projnr
|
|
def lProjNr
|
|
def lBuchKr
|
|
def lBuchKr68
|
|
|
|
lReturn = 0
|
|
// Split Attribut Funktion bei Technikdokumenten im Import
|
|
if( docType.getId().equals(Const.gDTS_DMDOK) && (!doc.field[Const.gDDF_FUNKTION].equals("") && doc.field[Const.gDDF_FUNKTION] != null) && ( !doc.field[Const.gDDF_FUNKTION].equals(docTemp.field[Const.gDDF_FUNKTION] || !doc.field[Const.gDDF_NPN].equals(docTemp.field[Const.gDDF_NPN]) ) ) ) {
|
|
lReturn = Functions.splitFunction( d3, doc, docType.getId() )
|
|
if( lReturn.equals("FEHLER") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte waehlen Sie eine gültige Funktion aus.")
|
|
lReturn = 0
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please choose a valid function.")
|
|
lReturn = 0
|
|
}
|
|
d3.log.error( "Bitte waehlen Sie eine gültige Funktion aus." )
|
|
return -170
|
|
} else if( lReturn.equals("FEHLERODATA") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Problem Funktionsaufruf: Bitte wenden Sie sich an Ihren Administrator.")
|
|
lReturn = 0
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Error on Call Function: Please contact your administrator.")
|
|
lReturn = 0
|
|
}
|
|
d3.log.error( "Problem Funktionsaufruf stringSplitFunction: Bitte wenden Sie sich an Ihren Administrator." )
|
|
return -170
|
|
} else if( lReturn.equals("FEHLERFUNKTION") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Problem Funktionsaufruf: Bitte wenden Sie sich an Ihren Administrator.")
|
|
lReturn = 0
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Error on Call Function: Please contact your administrator.")
|
|
lReturn = 0
|
|
}
|
|
d3.log.error( "Problem Funktionsaufruf stringSplitFunction: Bitte wenden Sie sich an Ihren Administrator." )
|
|
return -170
|
|
} else {
|
|
lReturn = 0
|
|
}
|
|
}
|
|
// Split Attribut Modul bei Technikdokumenten im Import
|
|
if( docType.getId().equals(Const.gDTS_DMDOK) && (!doc.field[Const.gDDF_MODUL].equals("") && doc.field[Const.gDDF_MODUL] != null) && (!doc.field[Const.gDDF_MODUL].equals(docTemp.field[Const.gDDF_MODUL]) || !doc.field[Const.gDDF_FUNKTION].equals(docTemp.field[Const.gDDF_FUNKTION]) ) ) {
|
|
lReturn = Functions.splitModule( d3, doc, docType.getId() )
|
|
if( lReturn.equals("FEHLER") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte waehlen Sie ein gültige Modulnummer aus.")
|
|
lReturn = 0
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please choose a valid module number.")
|
|
lReturn = 0
|
|
}
|
|
d3.log.error( "Bitte waehlen Sie eine gültige Modulnummer aus." )
|
|
return -170
|
|
} else if( lReturn.equals("FEHLERODATA") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Problem Funktionsaufruf: Bitte wenden Sie sich an Ihren Administrator.")
|
|
lReturn = 0
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Error on Call Function: Please contact your administrator.")
|
|
lReturn = 0
|
|
}
|
|
d3.log.error( "Problem Funktionsaufruf stringSplitFunction: Bitte wenden Sie sich an Ihren Administrator." )
|
|
return -170
|
|
} else if( lReturn.equals("FEHLERFUNKTION") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Problem Funktionsaufruf: Bitte wenden Sie sich an Ihren Administrator.")
|
|
lReturn = 0
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Error on Call Function: Please contact your administrator.")
|
|
lReturn = 0
|
|
}
|
|
d3.log.error( "Problem Funktionsaufruf stringSplitFunction: Bitte wenden Sie sich an Ihren Administrator." )
|
|
return -170
|
|
} else {
|
|
lReturn = 0
|
|
}
|
|
}
|
|
|
|
//jleu - Wird benötigt für Wertemenge "d3uservalues"
|
|
if( docType.getId().equals(Const.gDTS_DMARK) || docType.getId().equals(Const.gDTS_AVEVO) || docType.getId().equals(Const.gDTS_DVEDO) || docType.getId().equals(Const.gDTS_AREME) || docType.getId().equals(Const.gDTS_AMARK) || docType.getId().equals(Const.gDTS_AHAUP) || docType.getId().equals(Const.gDTS_DSCHU) ) {
|
|
Functions.splitUser(d3, doc);
|
|
}
|
|
|
|
//Splitten des zusammengesetzten Strings Projektnr, Projektname nach Projektnummer für das Feld Projektnummer
|
|
if ( docType.getId().equals(Const.gDTS_AMEIS) || docType.getId().equals(Const.gDTS_DPROO) || docType.getId().equals(Const.gDTS_APROJ) ) {
|
|
if(doc.field[Const.gDDF_PROJNR] != null) {
|
|
h_projnr = doc.field[Const.gDDF_PROJNR].substring(0,14)
|
|
doc.field[Const.gDDF_PROJNR] = h_projnr
|
|
}
|
|
if( docType.getId().equals(Const.gDTS_APROJ) ) {
|
|
Functions.setNextProjnr( d3, doc, Const.gDDF_PROJNR, 3, "UPDATE" )
|
|
}
|
|
}
|
|
|
|
// 26.04.2021: Ergänzung des Splits im UpdateEntry
|
|
// 25.11.2022: imue Ergänzung auch für Dokumentartwechsel
|
|
if(Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gLieferantNrID) || Functions.checkIfRepoIDExistsInDocType(d3, docTypeNew, SystemSpecificConst.gLieferantNrID)) {
|
|
def returnSplitLieferant
|
|
if(!docType.getId().equals(docTypeNew.getId())) {
|
|
returnSplitLieferant = Functions.splitLieferant(d3, doc, docTypeNew, user, "update", null);
|
|
} else {
|
|
returnSplitLieferant = Functions.splitLieferant(d3, doc, docType, user, "update", null);
|
|
}
|
|
if(returnSplitLieferant == -170) {
|
|
return -170
|
|
}
|
|
}
|
|
|
|
// Split für Buchungskreis nicht mehr notwendig, da wir diese Wertemenge bereits auf Groovy / Schlüssel-Übersetzung
|
|
// umgestellt haben -> imue 07.08.2019
|
|
if( ( !doc.field[Const.gDDF_LNR].equals(docTemp.field[Const.gDDF_LNR]) || !doc.field[Const.gDDF_LNAME].equals(docTemp.field[Const.gDDF_LNAME]) ||
|
|
!doc.field[Const.gDDF_KONTAKTBESCH].equals(docTemp.field[Const.gDDF_KONTAKTBESCH]) ||
|
|
!doc.field[Const.gDDF_LIEFAKTKAT].equals(docTemp.field[Const.gDDF_LIEFAKTKAT]) ||
|
|
!doc.field[Const.gDDF_KONTAKTDATE].equals(docTemp.field[Const.gDDF_KONTAKTDATE]) ) &&
|
|
docType.getId().equals(Const.gDTS_DLONT) && !userName.equals("d3_async") ) {
|
|
lReturn = Functions.splitLieferantenkontaktbeschreibung(d3, doc, docType);
|
|
if(lReturn == -170) {
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// Wenn der nur der Lieferantenname geändert wurde, aber nicht die Lieferantennummer, dann muss die Lieferantennummer geleert werden
|
|
// da ansonsten aufgrund der führenden Lieferantennummer, der Lieferantename wieder geändert wird (OPG-2055)
|
|
// - nicht im ValidateUpdateEntry möglich, da dort der alte Eigenschafts-Wert nicht verfügbar ist
|
|
if( docType.getId().equals(Const.gDTS_ALIKO) && docTemp.field[Const.gDDF_LNR].equals(doc.field[Const.gDDF_LNR]) && !docTemp.field[Const.gDDF_LNAME].equals(doc.field[Const.gDDF_LNAME]) ) {
|
|
def lLFName = doc.field[Const.gDDF_LNAME]
|
|
// wenn der Benutzer einen Lieferantennamen manuell eingibt, dann besteht kein |, der returnValue ist null
|
|
if( lLFName != null ) {
|
|
lReturn = lLFName.indexOf("|")
|
|
if( lReturn == -1 ) {
|
|
doc.field[Const.gDDF_LNR] = ""
|
|
}
|
|
}
|
|
}
|
|
|
|
if( ( !doc.field[Const.gDDF_KNR].equals(docTemp.field[Const.gDDF_KNR]) || !doc.field[Const.gDDF_KNAME].equals(docTemp.field[Const.gDDF_KNAME]) ) &&
|
|
( docType.getId().equals(Const.gDTS_DKUMA) ) ) {
|
|
int returnValidateKunden = Functions.validateKunden(d3, doc, docType, user, "update")
|
|
if(returnValidateKunden == -170) {
|
|
return -170
|
|
}
|
|
}
|
|
|
|
//Maschinenprojekt: Wenn weder eine Auftrags- noch eine Opportunity-Nr. eingetragen wird, verhindere die Ablage
|
|
if( docType.getId().equals(Const.gDTS_AKOMM) || docType.getId().equals(Const.gDTS_AKONT) ||
|
|
docType.getId().equals(Const.gDTS_AKUKO) || docType.getId().equals(Const.gDTS_ALIEK) ||
|
|
docType.getId().equals(Const.gDTS_APROR) || docType.getId().equals(Const.gDTS_DKOMM) ||
|
|
docType.getId().equals(Const.gDTS_DKUKO) || docType.getId().equals(Const.gDTS_DLIKO) ||
|
|
docType.getId().equals(Const.gDTS_DMEOP) || docType.getId().equals(Const.gDTS_DPRST) ||
|
|
docType.getId().equals(Const.gDTS_DVERD) || docType.getId().equals(Const.gDTS_DMDOK) ||
|
|
docType.getId().equals(Const.gDTS_DMSPE) || docType.getId().equals(Const.gDTS_DMECR) ||
|
|
docType.getId().equals(Const.gDTS_ALIKO) || docType.getId().equals(Const.gDTS_DMAUF) ) {
|
|
|
|
lReturn = Functions.validateOppProjNr( d3, doc)
|
|
|
|
if( lReturn.equals("WITHOUTPROJOPP") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT012049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT012001)
|
|
}
|
|
d3.log.error( "Sie versuchen ein Dokument zu importieren, ohne entweder eine Projekt- oder eine Opportunitynummer eingetragen zu haben. Bitte korrigieren Sie Ihre Eingabe." )
|
|
return -170
|
|
} else if(lReturn.equals("PROJOPP")) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT013049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT013001)
|
|
}
|
|
d3.log.error( "Sie versuchen ein Dokument zu importieren, und haben sowohl eine Projekt- als auch eine Opportunitynummer eingetragen. Bitte korrigieren Sie Ihre Eingabe." )
|
|
return -170
|
|
}
|
|
}
|
|
|
|
//Anpassung Jahr und Monat, wenn das Ereignisdatum geändert wurde
|
|
// dkle 01.02.2016: Erweiterung, nur für Dokumente, nicht für Akten, außer Opportunityakte
|
|
if( !doc.field[Const.gDDF_ERDATE].equals(docTemp.field[Const.gDDF_ERDATE]) &&
|
|
( docType.getId().equals(Const.gDTS_AOPPU) || docType.getId().equals(Const.gDTS_DOPPD) ||
|
|
docType.getId().equals(Const.gDTS_DKOMM) || docType.getId().equals(Const.gDTS_DKUKO) ||
|
|
docType.getId().equals(Const.gDTS_DLIKO) || docType.getId().equals(Const.gDTS_DLIMA) ||
|
|
docType.getId().equals(Const.gDTS_DLONT) || docType.getId().equals(Const.gDTS_DPRST) ||
|
|
docType.getId().equals(Const.gDTS_DMDOK) || docType.getId().equals(Const.gDTS_DMAUF) ||
|
|
docType.getId().equals(Const.gDTS_DMSPE) || docType.getId().equals(Const.gDTS_DMECR) ||
|
|
docType.getId().equals(Const.gDTS_AMPRA) || docType.getId().equals(Const.gDTS_APREN) ||
|
|
docType.getId().equals(Const.gDTS_DSERE) || docType.getId().equals(Const.gDTS_DSEBE) ||
|
|
docType.getId().equals(Const.gDTS_ASERE) || docType.getId().equals(Const.gDTS_ASEBE) ||
|
|
docType.getId().equals(Const.gDTS_DVERD) ) ) {
|
|
|
|
def lJahr = doc.field[Const.gDDF_ERDATE].toString().substring(0,4)
|
|
def lMonat = doc.field[Const.gDDF_ERDATE].toString().substring(5,7)
|
|
|
|
doc.field[Const.gDDF_JAHR] = lJahr
|
|
doc.field[Const.gDDF_MONAT] = lMonat
|
|
}
|
|
|
|
// Wenn Angebotsversion geschlossen, darf nicht eine neue Angebotsversion erstellt werden (Ja mit Dokumenten, Ja ohne Dokumente)
|
|
// 06.03.2023 imue: Anpassungen aufgrund Änderungen Quicktag.dxp
|
|
if( docType.getId().equals(Const.gDTS_AREGI) && doc.field[Const.gDDF_ANNEU] != null && !doc.field[Const.gDDF_ANNEU].equals(docTemp.field[Const.gDDF_ANNEU]) && ( doc.field[Const.gDDF_ANNEU].toString().startsWith("Ja, mit Dokumenten") || doc.field[Const.gDDF_ANNEU].toString().startsWith("Ja, ohne Dokumente") ) ) {
|
|
def lANState = doc.field[Const.gDDF_ANSTATUS]
|
|
if( lANState != null && lANState.toString().startsWith("geschlossen") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Die Angebotsnummer, die Sie erstellen moechten existiert bereits. Bitte waehlen Sie für die Neuanlage die hoechste Angebotsnummer.")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "The offer number you want to create already exists. Please choose the latest offer number for to create a new folder.")
|
|
}
|
|
d3.log.error( "Die Angebotsnummer, die Sie erstellen moechten existiert bereits. Bitte waehlen Sie für die Neuanlage die hoechste Angebotsnummer." )
|
|
return -170
|
|
}
|
|
}
|
|
|
|
if( ( docTypeNew.getId().equals(Const.gDTS_DMDOK) || docType.getId().equals(Const.gDTS_DMDOK) || docTypeNew.getId().equals(Const.gDTS_DPRST) || docType.getId().equals(Const.gDTS_DPRST) || docTypeNew.getId().equals(Const.gDTS_DLIKO) || docType.getId().equals(Const.gDTS_DLIKO) ) && !doc.field[Const.gDDF_NPN].equals(docTemp.field[Const.gDDF_NPN]) ) {
|
|
InvalidData = 0
|
|
InvalidData = Functions.validateNetzPSP(d3, doc)
|
|
|
|
if( InvalidData != 0 ) {
|
|
// Der additional_info_text wird in der Funktion "validateNetzPSP" gesetzt
|
|
return -170
|
|
}
|
|
}
|
|
|
|
|
|
// ECR-Dokumente und Ergebnisdokument dürfen nicht in genehmigte ECRs importiert werden.
|
|
if ( docType.getId().equals(Const.gDTS_DMECR) && doc.field[Const.gDDF_ERGEBNISDOK].equals("Ja") && !userName.equals("d3_async") && (doc.field[Const.gDDF_ARCDOCID].equals("") || doc.field[Const.gDDF_ARCDOCID] == null) ) {
|
|
int resultValidateErgebnisdokumente = Functions.validateErgebnisdokumenteECR(d3, doc, user)
|
|
if( resultValidateErgebnisdokumente == -170) {
|
|
return -170
|
|
}
|
|
}
|
|
|
|
// Hier wurde in JPL die Mustermaterialnummer (jedoch Einfachfeld) gesplittet.
|
|
// Da es dieses nicht mehr gibt und das Mehrfachfeld im unterem Verlauf gesplittet wird,
|
|
// kann es hier in Groovy entfernt werden. 12.08.2019
|
|
int returnvalueMM = Functions.validateMustermaterialNr(d3, doc, docTemp, docType, "Update")
|
|
if(returnvalueMM == -170) {
|
|
return -170;
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_DMEOP) || docType.getId().equals(Const.gDTS_DMSPE) || docType.getId().equals(Const.gDTS_DOPPD) ) {
|
|
|
|
// d3.log.error( "Multi Field" )
|
|
for (int i=1; i <= Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); i++) {
|
|
if( (!doc.field[Const.gDDF_MUSTERMATNR69][i].equals("") && doc.field[Const.gDDF_MUSTERMATNR69][i] != null) && !doc.field[Const.gDDF_MUSTERMATNR69][i].equals(docTemp.field[Const.gDDF_MUSTERMATNR69][i]) ) {
|
|
// d3.log.error( "pDocTypeShort: ${docType.getId()} Mustermaterial Mehrfachfeld 60: ${:(doc.field[Const.gDDF_MUSTERMATNR69][i]})")
|
|
String[] splittedString = doc.field[Const.gDDF_MUSTERMATNR69][i].split(" \\| ")
|
|
lReturn = splittedString.size()
|
|
|
|
if( lReturn == 2 ) {
|
|
def convertedString = splittedString[0].trim()
|
|
doc.field[Const.gDDF_MUSTERMATNR69][i] = convertedString
|
|
// d3.log.info( "Eingabe: dok_dat_feld[{$Const.gDDF_MUSTERMATNR}]: ${doc.field[Const.gDDF_MUSTERMATNR]})\"" )
|
|
}
|
|
lReturn = Functions.validateSAPMaterialNo( d3, doc, doc.field[Const.gDDF_MUSTERMATNR69][i] )
|
|
if( lReturn.equals("FEHLER") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT004049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT004001)
|
|
}
|
|
d3.log.error( "Bitte waehlen Sie eine gültige Mustermaterialnummer aus." )
|
|
return -170
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//Vererbung der Angebotsnummer auf die Dokumente einer Angebotsversion
|
|
if ( docType.getId().equals(Const.gDTS_AREGI) ) {
|
|
|
|
// dkle: 2017-11-13 Da die Verknüpfung vor dem Exit Hook gelöst wird müssen die Children früher ermittelt werden.
|
|
// Ziel ist die Vererbung von Attributen
|
|
String[] linkedChildren = d3.call.link_get_children(doc.id(), "d3groovy" )
|
|
|
|
// Initialisierung des Arrays in den Const
|
|
gAREGIChild = new ArrayList<>()
|
|
|
|
// d3.log.error( "Es wurden ${lReturn} Children gefunden" )
|
|
if ( linkedChildren.size() > 0 ) {
|
|
for( int i=0; i < linkedChildren.size(); i++) {
|
|
def linkedChildrenTemp = linkedChildren.getAt(i)
|
|
gAREGIChild.add(linkedChildrenTemp)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// Das Attribut "Akte" wird im Maschinenprojekt bis auf die Ausnahme ECR automatisch anhand der Dokumentgruppe und der Dokumentart (Anwendungsfall) ermittelt
|
|
// 25.07.2016/dkle: Anpassung auf die neuen Dokumentgruppen von ECR
|
|
// 25.11.2022 imue: Ausführung muss auch bei Dokumentartänderung funktionieren
|
|
if( ( docType.getId().equals(Const.gDTS_DMAUF) || docTypeNew.getId().equals(Const.gDTS_DMAUF) ||
|
|
docType.getId().equals(Const.gDTS_DMDOK) || docTypeNew.getId().equals(Const.gDTS_DMDOK) ||
|
|
docType.getId().equals(Const.gDTS_DMSPE) || docTypeNew.getId().equals(Const.gDTS_DMSPE) ||
|
|
docType.getId().equals(Const.gDTS_DPRST) || docTypeNew.getId().equals(Const.gDTS_DPRST) ||
|
|
docType.getId().equals(Const.gDTS_DMECR) || docTypeNew.getId().equals(Const.gDTS_DMECR) ||
|
|
docType.getId().equals(Const.gDTS_DLIMA) || docTypeNew.getId().equals(Const.gDTS_DLIMA) ||
|
|
docType.getId().equals(Const.gDTS_DKUMA) || docTypeNew.getId().equals(Const.gDTS_DKUMA)) &&
|
|
( !doc.field[Const.gDDF_DOKGROUP].equals(Const.gDG_ECRChangeOrder) && !doc.field[Const.gDDF_DOKGROUP].equals(Const.gDG_Medien) && (doc.field[Const.gDDF_SUBJECT].equals("") || doc.field[Const.gDDF_SUBJECT] == null) ) ) {
|
|
|
|
lDokGroup = doc.field[Const.gDDF_DOKGROUP]
|
|
def lProcess = doc.field[Const.gDDF_PROZESS]
|
|
|
|
if ( docType.getId().equals(Const.gDTS_DPRST) && !lProcess.equals("")) {
|
|
lAndClause = "and dok_dat_feld_${Const.gDDF_PROZESS} = '${lProcess}' "
|
|
} else {
|
|
lAndClause = ""
|
|
}
|
|
|
|
// 31.07.2017 Hinweis: Hier kann nur ein Wert zurückkommen, da es eine fachlich gepflegte administrative Akte ist.
|
|
// 25.11.2022 imue: Bei Dokumentartänderung muss die neue Doumentart zur Ermittlung genommen werden
|
|
def sqlStatement
|
|
if(!docType.getId().equals(docTypeNew.getId())) {
|
|
sqlStatement = "SELECT dok_dat_feld_${Const.gDDF_SUBJECT} as lSubject " +
|
|
"FROM firmen_spezifisch " +
|
|
"WHERE dok_dat_feld_${Const.gDDF_REGISTER} = '${lDokGroup}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_ANWENDUNGSFALL} = '${docTypeNew.getId()}' " +
|
|
"AND kue_dokuart = '${Const.gDTS_AAFOL}' ${lAndClause} "
|
|
} else {
|
|
sqlStatement = "SELECT dok_dat_feld_${Const.gDDF_SUBJECT} as lSubject " +
|
|
"FROM firmen_spezifisch " +
|
|
"WHERE dok_dat_feld_${Const.gDDF_REGISTER} = '${lDokGroup}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_ANWENDUNGSFALL} = '${docType.getId()}' " +
|
|
"AND kue_dokuart = '${Const.gDTS_AAFOL}' ${lAndClause} "
|
|
}
|
|
def sqlResult = d3.sql.executeAndGet(sqlStatement)
|
|
if(sqlResult.size() > 0) {
|
|
lSubject = sqlResult.getAt(0).get("lSubject")
|
|
}
|
|
|
|
// Der Wert "Projektorganisation" darf nicht gesetzt werden, im Code wird bei dieser Bedingung das Feld immer geleert
|
|
if(lSubject.equals("Projektorganisation")) {
|
|
} else {
|
|
doc.field[Const.gDDF_SUBJECT] = lSubject
|
|
}
|
|
}
|
|
|
|
//Maschinenprojekt Prototyp 4: Wenn beim Import die Dokumentgruppe Medien gewählt wurde, aber das Feld Akte leer ist, gib einen Fehler aus
|
|
if( ( docType.getId().equals(Const.gDTS_DMDOK) || docType.getId().equals(Const.gDTS_DMAUF) || docType.getId().equals(Const.gDTS_DMSPE) || docType.getId().equals(Const.gDTS_DPRST) || docType.getId().equals(Const.gDTS_DLIMA) || docType.getId().equals(Const.gDTS_DKUMA) )
|
|
&& doc.field[Const.gDDF_DOKGROUP].equals(Const.gDG_Medien) && ( doc.field[Const.gDDF_SUBJECT] == null || doc.field[Const.gDDF_SUBJECT].equals("") ) ) {
|
|
// dkle, 02.02.2016 additional infotext eingefügt
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Sie versuchen ein Dokument mit der Dokumentgruppe Medien zu aktualisieren, ohne eine Akte ausgewaehlt zu haben. Bitte korrigieren Sie Ihre Eingabe")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "You try to update an document as Medien without choosing a folder. Please correct your input.")
|
|
}
|
|
d3.log.error( "Sie versuchen ein Dokument mit der Dokumentgruppe Medien zu aktualisieren, ohne eine Akte ausgewaehlt zu haben. Bitte korrigieren Sie Ihre Eingabe" )
|
|
return -170
|
|
} else if ( docType.getId().equals(Const.gDTS_DPRST) && doc.field[Const.gDDF_SUBJECT].equals(Const.gAK_Projektorganisation) ) {
|
|
doc.field[Const.gDDF_SUBJECT] = ""
|
|
}
|
|
|
|
//Splitte für alle Dokument- und Aktenarten zur Opportunity das Erstelldatum wenn nicht leer und schreibe die Werte in Jahr und Monat
|
|
// dkle, 02.02.2016 Dies gilt für alle Dokumentarten, sowie die Opportunityakte. Andernfalls wird im Insert Entry das Jahr/Monat anhand des aktuellen Datums ermittelt
|
|
if( (!doc.field[Const.gDDF_ERDATE].equals("") && doc.field[Const.gDDF_ERDATE] != null) &&
|
|
( docType.getId().equals(Const.gDTS_AOPPU) || docType.getId().equals(Const.gDTS_DOPPD) || docType.getId().equals(Const.gDTS_DKOMM) ||
|
|
docType.getId().equals(Const.gDTS_DLIKO) || docType.getId().equals(Const.gDTS_DLIMA) || docType.getId().equals(Const.gDTS_DLONT) ||
|
|
docType.getId().equals(Const.gDTS_DPRST) || docType.getId().equals(Const.gDTS_DVERD) || docType.getId().equals(Const.gDTS_DKUKO) ||
|
|
docType.getId().equals(Const.gDTS_DMDOK) || docType.getId().equals(Const.gDTS_DMAUF) || docType.getId().equals(Const.gDTS_DMSPE) ||
|
|
docType.getId().equals(Const.gDTS_DMECR) || docType.getId().equals(Const.gDTS_AMPRA) || docType.getId().equals(Const.gDTS_APREN) ||
|
|
docType.getId().equals(Const.gDTS_DSERE) || docType.getId().equals(Const.gDTS_ASERE) || docType.getId().equals(Const.gDTS_DSEBE) ||
|
|
docType.getId().equals(Const.gDTS_ASEBE) || docType.getId().equals(Const.gDTS_SAPDO) ) ) {
|
|
def lJahr = doc.field[Const.gDDF_ERDATE].toString().substring(0,4)
|
|
def lMonat = doc.field[Const.gDDF_ERDATE].toString().substring(5,7)
|
|
doc.field[Const.gDDF_JAHR] = lJahr
|
|
doc.field[Const.gDDF_MONAT] = lMonat
|
|
}
|
|
|
|
// Angebotsdokumente: Angebot_Nr in den Zusatztitel einfügen, wenn die Angebot_Nr nicht "Neue" oder "9999" ist
|
|
if( docType.getId().equals(Const.gDTS_DOPPD) ) {
|
|
Functions.setAdditionalTitle(d3, doc);
|
|
}
|
|
|
|
//Prüfung des ausgewählten Lieferanten bei der Ablage
|
|
if( !userName.equals("d3_async") && !userName.equals("hostimp") && ( docType.getId().equals(Const.gDTS_DLIKO) || docType.getId().equals(Const.gDTS_ALIKO) || docType.getId().equals(Const.gDTS_ALONT) || docType.getId().equals(Const.gDTS_DLIMA) ) ) {
|
|
|
|
lReturn = Functions.validateLiefName( d3, doc, "Update")
|
|
|
|
if( lReturn.equals("OK") ) {
|
|
// Es handelt sich um einen validen Wert
|
|
} else if ( lReturn.equals("Fehler") ) {
|
|
// dkle, 02.02.2016 additional info Text eingefügt
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT016049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT016001)
|
|
}
|
|
d3.log.error( "Bitte geben Sie einen gültigen, eindeutigen Lieferanten an oder wählen Sie den Lieferanten aus der Auswahlliste." )
|
|
return -170
|
|
}
|
|
|
|
// Validierung der Lieferantennummer (nur bei gDTS_ALIKO) - OPG-2105 - updateAttribEntry20
|
|
lReturn = Functions.validateLiefNum( d3, doc, "Update" )
|
|
if( lReturn.equals("OK") ) {
|
|
// Es handelt sich um einen validen Wert
|
|
} else if ( lReturn.equals("Fehler") ) {
|
|
// dkle, 02.02.2016 additional info Text eingefügt
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT016049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT016001)
|
|
}
|
|
d3.log.error( "Bitte geben Sie einen gültigen, eindeutigen Lieferanten an oder wählen Sie den Lieferanten aus der Auswahlliste." )
|
|
return -170
|
|
}
|
|
}
|
|
|
|
// Wenn es sich um ein Ergebnisdokument handelt und ein Angebotsdokument ist, muss die übergeordnete Angebotsversion "in Arbeit" sein.
|
|
if( docType.getId().equals(Const.gDTS_DOPPD) && doc.field[Const.gDDF_ERGEBNISDOK].equals("Ja") && doc.field[Const.gDDF_ARCDOCID] == null ) {
|
|
lReturn = Functions.validateErgebnisdokumenteAngebot(d3, doc, user);
|
|
if(lReturn == -170) {
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_APROJ) ) {
|
|
|
|
for( int hCount60=1; hCount60 <= Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); hCount60++) {
|
|
// d3.log.error("Ich bin in Runde ${hCount60} mit Benutzer ${doc.field[Const.gDDF_PROJBER][hCount60]} ")
|
|
|
|
if( !doc.field[Const.gDDF_PROJBER][hCount60].equals(docTemp.field[Const.gDDF_PROJBER][hCount60]) && (doc.field[Const.gDDF_PROJBER][hCount60] != null) ) {
|
|
for(int lExist=1; lExist <= Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); lExist++) {
|
|
if ( doc.field[Const.gDDF_PROJBER][hCount60].equals(docTemp.field[Const.gDDF_PROJBER][lExist]) ) {
|
|
|
|
// d3.log.error("Der neue Benutzer ${doc.field[Const.gDDF_PROJBER][hCount60]} und der alte ${docTemp.field[Const.gDDF_PROJBER][lExist]}")
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT018049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT018001)
|
|
}
|
|
d3.log.error( "Der Benutzer ist bereits als Projektbeteiligter in diesem Organisationsprojekt hinterlegt." )
|
|
return -170
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
} // Ende von !SAP_DO
|
|
|
|
try {
|
|
// IMUE 05.03.2019 - Ergänzung für Massenänderungen ("Einzeländerung" befindet sich im ValidateUpdateEntry10)
|
|
def lApiIdTemp = d3.remote.getVersion()[0..2];
|
|
if(lApiIdTemp.equals('231')) {
|
|
d3.log.info(" ## Start Massenänderung - updateAttribEntry20 - ${docType.getId()}")
|
|
|
|
// Splitten des zusammengesetzten String Opportunity-Nummern (Mehrfachfeld Opportunitydokumente) und Submission nach Opportunitynummer
|
|
def returnOpp = Functions.splitOpportunityMehrf(d3, doc, docType);
|
|
|
|
}
|
|
} catch(Exception e) {
|
|
d3.log.info("updateAttribEntry20 - lApiIdTemp konnte nicht ermittelt weden")
|
|
}
|
|
|
|
//Splitten der zusammengesetzten Strings Projektnummer und Submission nach Projektnummer
|
|
def returnProj = Functions.splitProjektnummer(d3, doc, docType);
|
|
|
|
// phoer 20191024: Splitten der zusammengesetzten Strings SR-ID, Beschreibung
|
|
Functions.splitServSrId(d3, doc, docType);
|
|
int resultCheckSrId = Functions.checkServiceNr(d3, doc, SystemSpecificConst.gWeitereSRIDID);
|
|
if(resultCheckSrId != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "SR_ID in Zeile ${resultCheckSrId} ist doppelt eingetragen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "SR_ID in line ${resultCheckSrId} exists multiple")
|
|
}
|
|
return -170;
|
|
}
|
|
int resultValidateSrId = Functions.validateSrId(d3, doc);
|
|
if(resultValidateSrId != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte weitere SR_ID in Zeile ${resultValidateSrId} prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check further SR_ID in line ${resultValidateSrId} ")
|
|
}
|
|
return -170;
|
|
}
|
|
|
|
// phoer 20191024: Splitten der zusammengesetzten Strings SR-ID, Beschreibung
|
|
if( docType.getId().equals(Const.gDTS_DSEBE) || docType.getId().equals(Const.gDTS_ASEBE) ) {
|
|
Functions.splitServBelegnummer(d3, doc, docType);
|
|
int resultCheckBelegNr = Functions.checkServiceNr(d3, doc, SystemSpecificConst.gWeitereBelegNrID);
|
|
if(resultCheckBelegNr != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Belegnummer in Zeile ${resultCheckBelegNr} ist doppelt eingetragen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Further actitivy in line ${resultCheckBelegNr} exists multiple")
|
|
}
|
|
return -170;
|
|
}
|
|
int resultValidateBelegNr = Functions.validateBelegNr(d3, doc);
|
|
if(resultValidateBelegNr != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte weitere Belegnummer in Zeile ${resultValidateBelegNr} prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check further actitivy no in line ${resultValidateBelegNr} ")
|
|
}
|
|
return -170
|
|
}
|
|
if( doc.field[Const.gDDF_BELEGTYP] == null ) {
|
|
String belegNrTemp = doc.field[Const.gDDF_BELEGNUMMER];
|
|
String sqlStatement = "SELECT dok_dat_feld_${Const.gDDF_BELEGTYP} as belegTyp FROM firmen_spezifisch " +
|
|
"WHERE dok_dat_feld_${Const.gDDF_BELEGNUMMER} = '${belegNrTemp}' " +
|
|
"AND kue_dokuart = '${Const.gDTS_ASEBE}' ";
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
if(sqlResult != null && sqlResult.size() > 0) {
|
|
String lBelegTyp = sqlResult.getAt(0).get("belegTyp");
|
|
if( lBelegTyp != null && !lBelegTyp.equals("") && docType.getId().equals(Const.gDTS_DSEBE) ) {
|
|
doc.field[Const.gDDF_BELEGTYP] = lBelegTyp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// imue: Validierung doppelter Einträge für weitere Belegnummer Einkauf
|
|
if( docType.getId().equals(Const.gDTS_DEINK) ) {
|
|
int resultCheckBelegNr = Functions.checkPurchaseNr(d3, doc, SystemSpecificConst.gWeitereEinkaufBelegNrID);
|
|
if(resultCheckBelegNr != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Belegnummer in Zeile ${resultCheckBelegNr} ist doppelt eingetragen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Further actitivy in line ${resultCheckBelegNr} exists multiple")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// imue: Validierung der Belegart für den Service
|
|
if(Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gBelegNrID) && Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gBelegArtID)) {
|
|
Functions.validateBelegart(d3, doc);
|
|
}
|
|
|
|
// imue: Validierung der Belegart für den Einkauf
|
|
if(Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gEinkaufsBelegNrID)) {
|
|
Functions.validateBelegart(d3, doc);
|
|
}
|
|
|
|
// imue 26.08.2020 - Ergänzung für Equipment
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gWeitereEquipmentID) == true ) {
|
|
|
|
Functions.splitEquipment(d3, doc, docType, "UPDATE");
|
|
|
|
int resultValidateEquipment = Functions.validateEquipment(d3, doc, user, true);
|
|
if(resultValidateEquipment != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte Equipment Zeile ${resultValidateEquipment} prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check further equipment in line ${resultValidateEquipment} ")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gEquipmentID) == true ) {
|
|
|
|
Functions.splitEquipment(d3, doc, docType, "UPDATE");
|
|
|
|
int resultValidateEquipment = Functions.validateEquipment(d3, doc, user, false);
|
|
if(resultValidateEquipment != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte Equipment prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check equipment")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// imue 12.12.2022
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gEquipmentsID) == true ) {
|
|
Functions.splitEquipments(d3, doc, docType);
|
|
int resultValidateEquipment = Functions.validateEquipments(d3, doc, user);
|
|
if(resultValidateEquipment != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte Equipments prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check equipments")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// Splitten der weiteren Kundenummer und weiteren Lieferantennummer
|
|
if( docType.getId().equals(Const.gDTS_DLIMA) || docType.getId().equals(Const.gDTS_DKUMA) ) {
|
|
Functions.validateWeitKundLiefNo(d3, doc, docType);
|
|
}
|
|
|
|
|
|
// 17.01.2023 - Neue Validierung der Materialnummer
|
|
if(doc.getType().getId().equals(Const.gDTS_DMATE) && doc.field[Const.gDDF_MATERIALNUMMER] != null) {
|
|
String returnValueMatNo = Functions.validateMaterialNum(d3, doc);
|
|
if(returnValueMatNo != null && returnValueMatNo.equals("ERROR")) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte geben Sie eine Material_Nr ein, zu der bereits eine Materialakte existiert.");
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please enter a material no. for which a mertial file already exists.");
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
return 0
|
|
}
|
|
|
|
|
|
@Entrypoint( entrypoint = "hook_upd_attrib_exit_20" )
|
|
public int updAttribExit20(D3Interface d3, Document doc, Integer errorCode, User user, DocumentType docType, DocumentType docTypeOld, Document gOldDoc) {
|
|
//proc updateAttribExit20(pDocId, pError, pUser, pDocTypeShort, pDocTypeShortOld)
|
|
|
|
def lCnt = 0
|
|
def lRetCode
|
|
def lRetcode2
|
|
def lReturn
|
|
def lRetVal
|
|
def lRowCount
|
|
|
|
def userName = ""
|
|
if(user != null) {
|
|
userName = user.id();
|
|
}
|
|
|
|
d3.log.info("updAttribExit20 Ausführung für Document ${doc.id()} mit User - " + userName);
|
|
|
|
// siehe globale Variable (alte Dokumenteigenschaften ansonsten im Exit nicht zur Verfügung)
|
|
Document docTemp = gOldDoc;
|
|
|
|
if( docType.getId().equals(Const.gDTS_AHAUP) ) {
|
|
for(int i=1; i<=Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); i++) {
|
|
if( !doc.field[Const.gDDF_TEILVOBEZGEN][i].equals(gOldDoc.field[Const.gDDF_TEILVOBEZGEN][i]) ) {
|
|
def sqlStatement = "SELECT doku_id FROM firmen_spezifisch WHERE kue_dokuart = '${Const.gDTS_ATEIL}' AND dok_dat_feld_${Const.gDDF_TEILVONR} = '${doc.field[Const.gDDF_TEILVONRM][i]}'";
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
if( sqlResult != null && sqlResult.size() == 1 ) {
|
|
Document docChild = d3.archive.getDocument(sqlResult.getAt(0).get("doku_id"));
|
|
docChild.field[Const.gDDF_TEILVOBEZ] = doc.field[Const.gDDF_TEILVOBEZGEN][i]
|
|
try {
|
|
docChild.updateAttributes("d3groovy", true)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, docChild.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Functions.setMainfolder(d3, doc);
|
|
}
|
|
|
|
if( !docType.getId().equals(Const.gDTS_SAPDO) ) {
|
|
|
|
d3.log.info("Start proc updateAttribExit20 - pDocId = ${doc.id()}, pError = ${errorCode}, pUser = ${userName}, pDocTypeShort = ${docType.getId()} " )
|
|
|
|
//imue 09.08.2021 Dossier
|
|
if( docType.getId().equals(Const.gDTS_DOSSI) ) {
|
|
Functions.splitDossierValue(d3, doc, docType, "UPDATEEXIT")
|
|
}
|
|
|
|
//jleu 18.01.2017 Schulungsdokumentation
|
|
if( docType.getId().equals(Const.gDTS_DSCHU) ) {
|
|
//Die Funktion erstellt eine sucheschulungattr.html Datei
|
|
//die auf den d.3one Server der jeweiligen Umgebung nach c:\inetpub\wwwroot kopiert werden muss
|
|
//Die Datei sucheschulungattr.html stellt eine Suche über Werte aus der Dokumtart Schulungsdokumentation bereit.
|
|
Functions.createSearchHTML( d3, doc)
|
|
} //Ende Schulungsdokumentation
|
|
|
|
//Aufruf der Funktion für die Anlage der Unterakten für Arbeitspakete und Meilensteine
|
|
// 31.07.2017 Weshalb werden Attribute in einem Exit Hook aktualisiert?
|
|
if( docType.getId().equals(Const.gDTS_APROJ) ) {
|
|
def projNr = doc.field[Const.gDDF_PROJNR];
|
|
def oldProjNr = gOldDoc.field[Const.gDDF_PROJNR];
|
|
if( !doc.field[Const.gDDF_PROJNR].equals(gOldDoc.field[Const.gDDF_PROJNR]) ) {
|
|
if(doc.field[Const.gDDF_PROJNR] != null) {
|
|
def lProjNr = doc.field[Const.gDDF_PROJNR].substring(0,11)
|
|
doc.field[Const.gDDF_PROJEKTKLAMMER] = lProjNr
|
|
try {
|
|
doc.updateAttributes(userName, true)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, doc.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
lRetCode = d3.call.document_send_to_dsearch( doc.id(), "", 0, "", false, "Fr", 0, "d3groovy")
|
|
Functions.inheritOrgProjAttributes( d3, doc, gOldDoc, user, oldProjNr )
|
|
}
|
|
} else {
|
|
Functions.inheritOrgProjAttributes( d3, doc, gOldDoc, user, projNr )
|
|
}
|
|
}
|
|
|
|
//jleu - Aufruf der Aktualisierung von Teamsitzungsakten
|
|
if( docType.getId().equals(Const.gDTS_AREME) ) {
|
|
if( !doc.field[Const.gDDF_CASE].equals(gOldDoc.field[Const.gDDF_CASE]) ) {
|
|
// erst alle Akten aktualisieren
|
|
def sqlStatement = "SELECT doku_id FROM firmen_spezifisch WHERE kue_dokuart = '${Const.gDTS_AVODA}' AND dok_dat_feld_${Const.gDDF_CASE} = '${gOldDoc.field[Const.gDDF_CASE]}'";
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
if( sqlResult != null ) {
|
|
for( GroovyRowResult grr: sqlResult ) {
|
|
Document docTempUpdate = d3.archive.getDocument(grr.get("doku_id"))
|
|
docTempUpdate.field[Const.gDDF_CASE] = doc.field[Const.gDDF_CASE]
|
|
try {
|
|
docTempUpdate.updateAttributes("d3groovy", true)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, docTempUpdate.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
}
|
|
}
|
|
// danach die Dokumente aktualisieren
|
|
def sqlStatementDoc = "SELECT doku_id FROM firmen_spezifisch WHERE kue_dokuart = '${Const.gDTS_DABTE}' AND dok_dat_feld_${Const.gDDF_CASE} = '${gOldDoc.field[Const.gDDF_CASE]}'";
|
|
List<GroovyRowResult> sqlResultDoc = d3.sql.executeAndGet(sqlStatementDoc);
|
|
if( sqlResultDoc != null ) {
|
|
for( GroovyRowResult grr: sqlResultDoc ) {
|
|
Document docTempUpdate = d3.archive.getDocument(grr.get("doku_id"))
|
|
docTempUpdate.field[Const.gDDF_CASE] = doc.field[Const.gDDF_CASE]
|
|
try {
|
|
docTempUpdate.updateAttributes("d3groovy", true)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, docTempUpdate.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//jleu - 18.10.2017 Aufruf der Aktualisierung von vertraulichen Vorgangsakten
|
|
if( docType.getId().equals(Const.gDTS_AVEVO) ) {
|
|
if( !doc.field[Const.gDDF_CASE].equals(gOldDoc.field[Const.gDDF_CASE]) ) {
|
|
def sqlStatement = "SELECT doku_id as DokuId FROM firmen_spezifisch WHERE kue_dokuart = '${Const.gDTS_DVEDO}' AND dok_dat_feld_${Const.gDDF_CASE} = '${gOldDoc.field[Const.gDDF_CASE]}'";
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
if( sqlResult != null ) {
|
|
for( GroovyRowResult grr: sqlResult ) {
|
|
Document docTempUpdate = d3.archive.getDocument(grr.get("DokuId"))
|
|
docTempUpdate.field[Const.gDDF_CASE] = doc.field[Const.gDDF_CASE]
|
|
try {
|
|
docTempUpdate.updateAttributes("d3groovy", true)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, docTempUpdate.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//Aufruf der Aktualisierung zum Projektstatus durch Arbeitspaketphase
|
|
if( docType.getId().equals(Const.gDTS_AMEIS) ) {
|
|
def msap = doc.field[Const.gDDF_MSAPS];
|
|
def msapold = gOldDoc.field[Const.gDDF_MSAPS];
|
|
if( !doc.field[Const.gDDF_MSAPS].equals(gOldDoc.field[Const.gDDF_MSAPS]) ) {
|
|
def sqlStatement = "SELECT doku_id as DokuId FROM firmen_spezifisch WHERE kue_dokuart = '${Const.gDTS_DPROO}' AND dok_dat_feld_${Const.gDDF_MSAPS} = '${gOldDoc.field[Const.gDDF_MSAPS]}'";
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
if(sqlResult != null) {
|
|
for( GroovyRowResult grr : sqlResult ) {
|
|
Document docTempUpdate = d3.archive.getDocument(grr.get("DokuId"))
|
|
docTempUpdate.field[Const.gDDF_MSAPS] = doc.field[Const.gDDF_MSAPS]
|
|
try {
|
|
docTempUpdate.updateAttributes("d3groovy", false)
|
|
} catch( Exception e ) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, docTempUpdate.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//Änderung der Attribute Submission und Hauptopportunity für alle Akten und Dokumente wenn die Werte auf der Opportunityakte geändert werden
|
|
if( docType.getId().equals(Const.gDTS_AOPPU) ) {
|
|
Functions.inheritOppAttr( d3, doc, gOldDoc, user )
|
|
}
|
|
|
|
//Anpassung der Ergebnisdokumente, wenn ein neues Angebot erstellt werden soll
|
|
// 06.03.2023 imue: Anpassungen aufgrund Änderungen Quicktag.dxp
|
|
if( docType.getId().equals(Const.gDTS_AREGI) && (doc.field[Const.gDDF_ANNEU] != null && (doc.field[Const.gDDF_ANNEU].toString().startsWith("Ja, mit Dokumenten") || doc.field[Const.gDDF_ANNEU].toString().startsWith("Ja, ohne Dokumente"))) ) {
|
|
def lAnAlt = doc.field[Const.gDDF_OPPANNr]
|
|
def lAnNeu = doc.field[Const.gDDF_ANNEU]
|
|
//Erstelle eine neue Angebotsakte und kopiere die angebotsrelevanten Dokumente
|
|
lRetcode2 = Functions.createNewOffer( d3, doc)
|
|
//Rufe diese Funktion auf, wenn auch Dokumente kopiert werden sollen
|
|
if( lAnNeu != null && lAnNeu.toString().startsWith("Ja, mit Dokumenten") ) {
|
|
lRetCode = Functions.copyOfferDocuments( d3, doc, lRetcode2)
|
|
|
|
// Mache aus Ergebnisdokumenten keine Ergebnisdokumente wenn ein neues Angebot erstellt werden soll
|
|
// Achtung: Wenn folgende Funktion ausgeführt wird (Update des Dokumentes) wird der Aktenplan ausgeführt
|
|
// daher ist zwingend erforderlich: Angebotsdokumente -> Angebotsversion "Nur Verknüpfungen die durch diese Regel erstellt wurden löschen",
|
|
// da ansonsten die komplette Verbindung der untereinander verknüpften Angebotsdokumente verloren geht!
|
|
lRetCode = Functions.updResultDoc(d3, doc)
|
|
}
|
|
}
|
|
|
|
|
|
//Vererbung der Angebotsnummer auf die Dokumente einer Angebotsversion
|
|
if( docType.getId().equals(Const.gDTS_AREGI) ) {
|
|
|
|
// Prüfung ob sich die Opportunity-Nummer überhaupt geändert hat
|
|
if(doc.field[Const.gDDF_OPPANNr] != null && gOldDoc != null && gOldDoc.field[Const.gDDF_OPPANNr] != null && !doc.field[Const.gDDF_OPPANNr].equals(gOldDoc.field[Const.gDDF_OPPANNr])) {
|
|
Functions.inheritOfferNo(d3, doc, gOldDoc, gAREGIChild, user)
|
|
|
|
// nach Verwendung muss das Array wieder geleert werden
|
|
while(gAREGIChild.size() > 0) {
|
|
gAREGIChild.remove(0);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//Wenn eine weitere Opportunity Nummer in das Mehrfachfeld eingetragen wird, schaue ob es diese Link Datei gibt
|
|
//ansonsten lege eine neue an
|
|
if( docType.getId().equals(Const.gDTS_DOPPD) || docType.getId().equals(Const.gDTS_DLIKO)
|
|
|| docType.getId().equals(Const.gDTS_DKUKO) || docType.getId().equals(Const.gDTS_DKOMM)
|
|
|| docType.getId().equals(Const.gDTS_DMDOK) || docType.getId().equals(Const.gDTS_DMAUF)
|
|
|| docType.getId().equals(Const.gDTS_DMSPE) || docType.getId().equals(Const.gDTS_DVERD) || docType.getId().equals(Const.gDTS_DPRST)
|
|
|| docType.getId().equals(Const.gDTS_DSEBE) || docType.getId().equals(Const.gDTS_DSERE) || docType.getId().equals(Const.gDTS_DEQUI)
|
|
|| docType.getId().equals(Const.gDTS_DEINK))
|
|
{
|
|
Functions.checkForLinkFiles(d3, doc, docType, docTemp);
|
|
}
|
|
|
|
|
|
//Änderung des Attributs Angebotsname für alle Akten und Dokumente wenn die Werte auf dem Angebotsvorgange geändert werden
|
|
if( docType.getId().equals(Const.gDTS_AUNTE) && ( docTemp != null && !doc.field[Const.gDDF_ANNAME].equals(docTemp.field[Const.gDDF_ANNAME]) ) ) {
|
|
Functions.inheritANNameNew( d3, doc, user )
|
|
|
|
}
|
|
/* 04.11.2019 Funktion wird bereits durch inheritOppAttr abgedeckt
|
|
else if( docType.getId().equals(Const.gDTS_AUNTE) &&
|
|
( !doc.field[Const.gDDF_HAUPTOPP].equals(docTemp.field[Const.gDDF_HAUPTOPP]) || !doc.field[Const.gDDF_SALESGROUP].equals(docTemp.field[Const.gDDF_SALESGROUP]) ||
|
|
!doc.field[Const.gDDF_STATUS].equals(docTemp.field[Const.gDDF_STATUS]) || !doc.field[Const.gDDF_SUBMISSION].equals(docTemp.field[Const.gDDF_SUBMISSION]) ||
|
|
!doc.field[Const.gDDF_PROZESS].equals(docTemp.field[Const.gDDF_PROZESS]) || !doc.field[Const.gDDF_KNR].equals(docTemp.field[Const.gDDF_KNR]) || \
|
|
!doc.field[Const.gDDF_KNAME].equals(docTemp.field[Const.gDDF_KNAME]) || !doc.field[Const.gDDF_BUCHKREIS].equals(docTemp.field[Const.gDDF_BUCHKREIS]) || \
|
|
!doc.field[Const.gDDF_OPPNUMMER].equals(docTemp.field[Const.gDDF_OPPNUMMER]) ) ) {
|
|
// Anpassung 24.10.2017 Vererbung der Attribute des Angebotsvorgangs auf die Angebotsversionen und Angebotsdokumente
|
|
// Vorbereitung: hier muss weiteres vererbt werden!
|
|
// get children für AUNTE -> Ergebnis 1-n AREGI
|
|
// DokuIds und Dokumentart speichern
|
|
// get children für AREGI -> Ergebnis 1-n DOPPD
|
|
// DokuIds und Dokumentart speichern
|
|
// Vererbungsarray durchlaufen, neue Informationen vererben
|
|
def lChildCount1
|
|
def lChildArrCount2
|
|
String[] lChildArray1
|
|
String[] lChildArray2
|
|
// get children für AUNTE -> Ergebnis 1-n AREGI
|
|
lChildArray1 = d3.archive.link_get_children( doc.id(), "d3groovy")
|
|
lChildCount1 = lChildArray1.size()
|
|
// get children für AREGI -> Ergebnis 1-n DOPPD
|
|
lChildArrCount2 = 1
|
|
for(int lChildCount2=0; lChildCount2 < lChildCount1; lChildCount2++) {
|
|
lChildArray2 = d3.archive.link_get_children( lChildArray1[lChildCount2], "d3groovy")
|
|
lChildArrCount2 = lChildArray2.size()
|
|
}
|
|
// Kontrolle nach dem Durchlauf
|
|
for(int lCount=0; lCount < lChildArrCount2; lCount++) {
|
|
// d3.log.error( "Start inheritOPPValues lChildArray1[${lCount}]: ${lChildArray1[lCount]}" )
|
|
Functions.inheritOPPValues( d3, lChildArray1[lCount], doc.id() )
|
|
}
|
|
for(int lCount=0; lCount < lChildArrCount2; lCount++) {
|
|
// d3.log.error( "Start inheritOPPValues lChildArray2[${lCount}]: ${lChildArray2[lCount]}" )
|
|
Functions.inheritOPPValues( d3, lChildArray2[lCount], doc.id() )
|
|
}
|
|
}
|
|
*/
|
|
|
|
|
|
//Änderung der Attribute Kundenname und Kundennummer bei Änderung auf der Opportunityakte
|
|
if( docType.getId().equals(Const.gDTS_AOPPU) && ( docTemp != null && !doc.field[Const.gDDF_KNR].equals(docTemp.field[Const.gDDF_KNR]) ) ) {
|
|
Functions.inheritKInfoNew(d3, doc, user)
|
|
}
|
|
|
|
|
|
// --------------------------------------------------------------
|
|
// ######## Anpassung zum Prototyp für Maschinenprojekte ########
|
|
// --------------------------------------------------------------
|
|
if( docType.getId().equals(Const.gDTS_AMPRA) && docTemp != null && !doc.field[Const.gDDF_BASEOPP].equals(docTemp.field[Const.gDDF_BASEOPP]) && (!doc.field[Const.gDDF_BASEOPP].equals("") && doc.field[Const.gDDF_BASEOPP] != null) ) {
|
|
def lBaseOpp = doc.field[Const.gDDF_BASEOPP]
|
|
def lOrderNo = doc.field[Const.gDDF_AUFTRNR]
|
|
//... und verknüpfe die Ergebnisdokumente in die Maschinenprojektakte
|
|
Functions.copyResultDocs( d3, doc, lBaseOpp, lOrderNo )
|
|
}
|
|
|
|
//Anpassung phoer 05.10.2016: 26.07.2016/dkle: Maschinenprojekt Wenn der Status der Unterakte ECR auf "Genehmigung" steht soll eine Dublette alle Ergebnisdokumente in die Dokumentart DMSPE kopiert werden.
|
|
if( docType.getId().equals(Const.gDTS_AMECR) && docTemp != null && !doc.field[Const.gDDF_ECRSTATUS].equals(docTemp.field[Const.gDDF_ECRSTATUS]) && doc.field[Const.gDDF_ECRSTATUS].equals("E0003") && !userName.equals("d3_async") ) {
|
|
def lActID = doc.field[Const.gDDF_AKTIVITAETSID]
|
|
def lOrderID = doc.field[Const.gDDF_AUFTRNR]
|
|
Functions.copyApprovedECR( d3, lActID, lOrderID, "" )
|
|
}
|
|
|
|
if(docTemp != null) {
|
|
if( !doc.field[Const.gDDF_AKTIVITAETSID].equals(docTemp.field[Const.gDDF_AKTIVITAETSID]) && docType.getId().equals(Const.gDTS_AMECR) ) {
|
|
List<String> lChildID = new ArrayList<>();
|
|
def lChildCount
|
|
def lActID
|
|
def sqlStatement = "SELECT pd.doku_id as lChildID " +
|
|
"FROM phys_datei as pd, firmen_spezifisch as fs " +
|
|
"WHERE fs.doku_id = pd.doku_id " +
|
|
"AND fs.kue_dokuart = '${Const.gDTS_DMECR}' " +
|
|
"AND fs.dok_dat_feld_${Const.gDDF_AKTIVITAETSID} = '${docTemp.field[Const.gDDF_AKTIVITAETSID]}' " +
|
|
"AND fs.dok_dat_feld_${Const.gDDF_AUFTRNR} = '${doc.field[Const.gDDF_AUFTRNR]}' "
|
|
List<GroovyRowResult> sqlResult = d3.getSql().executeAndGet(sqlStatement)
|
|
lChildCount = sqlResult.size()
|
|
for(GroovyRowResult grr : sqlResult) {
|
|
lChildID.add(grr.get("lChildID"))
|
|
}
|
|
if( lChildCount > 0 ) {
|
|
lActID = doc.field[Const.gDDF_AKTIVITAETSID]
|
|
for(int lCount=0; lCount < lChildCount; lCount++) {
|
|
try {
|
|
Document docChild = d3.archive.getDocument(lChildID.get(lCount), "d3groovy")
|
|
docChild.field[Const.gDDF_AKTIVITAETSID] = lActID
|
|
docChild.updateAttributes("d3groovy", true)
|
|
} catch(Exception e) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, docChild.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
d3.log.error("Fehler bei der Aktualisierung des ECR/Change Order Dokuments bei Änderung der Unterakte ECR/Change Order. Dokument ID: :(lChildID[lCount])")
|
|
}
|
|
// d3.log.error( "Aktivitäts-ID vererben, Kind Nummer ${lCount} bearbeitet ${doc.field[Const.gDDF_AKTIVITAETSID]})" )
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(docTemp != null) {
|
|
// dkle, 01.02.2016 Bei Aktualisierung der Opportunityakten und wenn sich der Status ändert soll der Aktenplan für alle children ausgeführt werden.
|
|
// entfernt, in Funktion inheritOppAttr aufgenommen
|
|
// phoer 20160823: Wenn beim Update der Maschinenprojektdokumente das Zuordnung Kundenkontakt geändert wurde...
|
|
if( ( docType.getId().equals(Const.gDTS_DKOMM) ||
|
|
docType.getId().equals(Const.gDTS_DLIKO) ||
|
|
docType.getId().equals(Const.gDTS_DPRST) ||
|
|
docType.getId().equals(Const.gDTS_DMSPE) ||
|
|
docType.getId().equals(Const.gDTS_DMECR) ||
|
|
docType.getId().equals(Const.gDTS_DMDOK) ||
|
|
docType.getId().equals(Const.gDTS_DMAUF) )
|
|
&& !doc.field[Const.gDDF_MAPPCUSTACTION].equals(docTemp.field[Const.gDDF_MAPPCUSTACTION])
|
|
&& (!doc.field[Const.gDDF_MAPPCUSTACTION].equals("") && doc.field[Const.gDDF_MAPPCUSTACTION] != null)
|
|
) {
|
|
//...rufe die Funktion zum Kopieren des Dokuments auf, damit es in die Kundenkontaktakte importiert wird
|
|
String subMappCustAction = "";
|
|
if(doc.field[Const.gDDF_MAPPCUSTACTION] != null && doc.field[Const.gDDF_MAPPCUSTACTION].toString().size() >= 7) {
|
|
subMappCustAction = doc.field[Const.gDDF_MAPPCUSTACTION].substring(0,7);
|
|
}
|
|
if( !subMappCustAction.equals("bereits") ) {
|
|
Functions.copyCustAction( d3, doc, doc.field[Const.gDDF_MAPPCUSTACTION] );
|
|
}
|
|
}
|
|
}
|
|
|
|
//Änderung der Attribute, wenn die Maschinenprojektakte sich in SAP geändert hat
|
|
if( docType.getId().equals(Const.gDTS_AMPRA) || docType.getId().equals(Const.gDTS_APREN) ) {
|
|
// 20.07.202 Optimierung: Es muss nur in die Funktion eingestiegen werden, wenn sich relevante Eigenschaften geändert haben
|
|
if( Functions.checkIfValueChanged(d3, doc, gOldDoc, Const.gDDF_KNAME) == true || Functions.checkIfValueChanged(d3, doc, gOldDoc, Const.gDDF_KNR) == true ||
|
|
Functions.checkIfValueChanged(d3, doc, gOldDoc, Const.gDDF_STATUS) == true || Functions.checkIfValueChanged(d3, doc, gOldDoc, Const.gDDF_SUBMISSION) == true ||
|
|
Functions.checkIfValueChanged(d3, doc, gOldDoc, Const.gDDF_SALESGROUP) == true || Functions.checkIfValueChanged(d3, doc, gOldDoc, Const.gDDF_BUCHKREIS68) == true ) {
|
|
Functions.inheritMProjAttributes( d3, doc, gOldDoc, user );
|
|
}
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_AKONT) ) {
|
|
Functions.inheritAkontAttributes(d3, doc, gOldDoc, user);
|
|
}
|
|
|
|
|
|
if( docType.getId().equals(Const.gDTS_ALIKO) ) {
|
|
// Zur Aktualisierung der Dokumente -> Akte markieren für die Verarbeitung im Skript CheckMassDataChanged!
|
|
try {
|
|
|
|
String ddfValueChanged = null;
|
|
// Lieferantennummer
|
|
boolean liefNrChanged = Functions.checkIfValueChanged(d3, doc, gOldDoc, Const.gDDF_LNR);
|
|
if(liefNrChanged == true) {
|
|
if(ddfValueChanged == null) {
|
|
ddfValueChanged = String.valueOf(Const.gDDF_LNR);
|
|
} else {
|
|
ddfValueChanged = ddfValueChanged + ";" + String.valueOf(Const.gDDF_LNR);
|
|
}
|
|
}
|
|
|
|
// Lieferantenname
|
|
boolean liefNameChanged = Functions.checkIfValueChanged(d3, doc, gOldDoc, Const.gDDF_LNAME);
|
|
if(liefNameChanged == true) {
|
|
if(ddfValueChanged == null) {
|
|
ddfValueChanged = String.valueOf(Const.gDDF_LNAME);
|
|
} else {
|
|
ddfValueChanged = ddfValueChanged + ";" + String.valueOf(Const.gDDF_LNAME);
|
|
}
|
|
}
|
|
|
|
if(ddfValueChanged != null) {
|
|
// Ermittlung der bisherigen Einträge
|
|
String sqlStatementMdc = "SELECT doc_id FROM mass_data_change WHERE doc_id = '${doc.id()}' "
|
|
List<GroovyRowResult> sqlResultMdc = d3.sql.executeAndGet(sqlStatementMdc);
|
|
int indexCounter = sqlResultMdc.size();
|
|
if(indexCounter == 0) {
|
|
String sqlStatementMdcInsert = "INSERT INTO mass_data_change (doc_id, field_name, field_index, field_value) VALUES ('${doc.id()}', 'MDC-ALIKO', 1, '${ddfValueChanged}') ";
|
|
int returnValue = d3.sql.execute(sqlStatementMdcInsert);
|
|
} else if(indexCounter >= 1) {
|
|
indexCounter = indexCounter + 1;
|
|
String sqlStatementMdcInsert = "INSERT INTO mass_data_change (doc_id, field_name, field_index, field_value) VALUES ('${doc.id()}', 'MDC-ALIKO', ${indexCounter}, '${ddfValueChanged}') ";
|
|
int returnValue = d3.sql.execute(sqlStatementMdcInsert);
|
|
}
|
|
}
|
|
} catch(Exception e) {
|
|
d3.log.error("Error Functions inheritAkontAttributes - Akte ${doc.id()} konnte nicht in die Tabelle mass_data_change ergänzt werden: " + e);
|
|
}
|
|
}
|
|
|
|
// Vererbung der Erkennungsattribute
|
|
if( docType.getId().equals(Const.gDTS_ALONT) && (!doc.field[Const.gDDF_LNR].equals(gOldDoc.field[Const.gDDF_LNR]) ||
|
|
!doc.field[Const.gDDF_LIEFAKTKAT].equals(gOldDoc.field[Const.gDDF_LIEFAKTKAT]) ||
|
|
!doc.field[Const.gDDF_KONTAKTDATE] != gOldDoc.field[Const.gDDF_KONTAKTDATE] ||
|
|
!doc.field[Const.gDDF_KONTAKTBESCH].equals(gOldDoc.field[Const.gDDF_KONTAKTBESCH]) ) ) {
|
|
|
|
def returninheritLiefAttrib = Functions.inheritLiefAttrib(d3, doc, docType, userName, gOldDoc);
|
|
}
|
|
|
|
|
|
if( docType.getId().equals(Const.gDTS_AKUND) && docTemp != null && !doc.field[Const.gDDF_KNAME].equals(docTemp.field[Const.gDDF_KNAME]) ) {
|
|
|
|
if( SystemSpecificConst.workWithAsyncJplForMassDataUpdate == true ) {
|
|
d3.log.info("Functions updUpdateExit20 AKUND Verarbeitung JPL Asynchron");
|
|
try {
|
|
d3.call.d3async_job_open(doc.id(), "CUJ001", "d3groovy");
|
|
d3.call.d3async_job_set_attribute("hook_function", "gyInheritKundenname", 0);
|
|
d3.call.d3async_job_set_attribute("custom_job_par[1]", doc.id(), 0);
|
|
d3.call.d3async_job_set_attribute("custom_job_par[2]", String.valueOf(Const.gDDF_KNR), 0);
|
|
d3.call.d3async_job_set_attribute("custom_job_par[3]", docTemp.field[Const.gDDF_KNR], 0);
|
|
d3.call.d3async_job_close();
|
|
} catch(Exception e) {
|
|
String noticeHoldfile = "UPD-Job konnte nicht erstellt werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, doc.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
d3.log.error("UPD-Job konnte nicht erstellt werden = " + e);
|
|
}
|
|
|
|
} else {
|
|
d3.log.info("Functions updUpdateExit20 AKUND Verarbeitung Asynchron");
|
|
def sqlStatement = "SELECT doku_id as dokuId FROM firmen_spezifisch WHERE dok_dat_feld_${Const.gDDF_KNR} = '${docTemp.field[Const.gDDF_KNR]}'"
|
|
List<GroovyRowResult> sqlResult = d3.getSql().executeAndGet(sqlStatement)
|
|
Map<Integer, Object> attribUpdate = new HashMap<>();
|
|
attribUpdate.put(Const.gDDF_KNAME, doc.field[Const.gDDF_KNAME]);
|
|
List<String> docIds = new ArrayList<>();
|
|
for(GroovyRowResult grr : sqlResult) {
|
|
docIds.add(grr.get("dokuId"));
|
|
}
|
|
Functions.createAsyncJobForUpdates(d3, doc, docIds, attribUpdate, "UpdateExitAKUND");
|
|
}
|
|
}
|
|
|
|
// phoer, 20180306: Sperren von Dokumenten im Werkauftrag wenn der ECR von zunächst "Genehmigung" auf "Abgelehnt" gestzt wird
|
|
if( docType.getId().equals(Const.gDTS_DMECR) && docTemp.field[Const.gDDF_ECRSTATUS].equals("E0003") && doc.field[Const.gDDF_ECRSTATUS].equals("E0009") && doc.field[Const.gDDF_ERGEBNISDOK].equals("Ja") ) {
|
|
def lProjNo = doc.field[Const.gDDF_AUFTRNR]
|
|
List<String> lTargetDocID = new ArrayList<>();
|
|
def lRetBlock
|
|
def sqlStatement = "SELECT fs.doku_id as lTargetDocID " +
|
|
"FROM firmen_spezifisch fs, phys_datei pd " +
|
|
"WHERE fs.doku_id = pd.doku_id " +
|
|
"AND fs.kue_dokuart = '${Const.gDTS_DMSPE}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_AUFTRNR} = '${lProjNo}' " +
|
|
"AND pd.text like '%${doc.id()}%' "
|
|
List<GroovyRowResult> sqlResult = d3.getSql().executeAndGet(sqlStatement)
|
|
for(GroovyRowResult grr : sqlResult) {
|
|
lTargetDocID.add(grr.get("lTargetDocID"))
|
|
}
|
|
lRowCount = sqlResult.size()
|
|
if( lRowCount == 0 ) {
|
|
d3.log.error("Das kopierte Ergebnisdokument für das Dokument ${doc.id()} konnte nicht gefunden werden!")
|
|
} else {
|
|
for(String docuId : lTargetDocID) {
|
|
Document docTempTarget = d3.archive.getDocument(docuId)
|
|
// 0 = gesperrt (Groovy 'g') | 1 = freigegeben (Groovy 'f')
|
|
def lBlockInfo = docTempTarget.getReleaseVersionStatus()
|
|
// TODO Hinweis: 24.06.2019 - wenn Dokument freigegeben, nochmal freigeben?
|
|
if ( lBlockInfo.equals("f") ) {
|
|
lReturn = docTempTarget.block(true, "d3groovy")
|
|
if (lReturn != 0) {
|
|
d3.log.error("Das Dokument ${docTempTarget.id()} konnte nicht auf Freigabe / Gesperrt gesetzt werden! Errorcode = ${lReturn}")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// jleu 18.01.2017 Umbenennen von Bauprojekten
|
|
if( docType.getId().equals(Const.gDTS_ABAUP) && ( docTemp != null && !doc.field[Const.gDDF_BAUPROJEKT].equals(docTemp.field[Const.gDDF_BAUPROJEKT] ) ) ) {
|
|
def sqlStatement1 = "SELECT doku_id as dokuID FROM firmen_spezifisch WHERE ( kue_dokuart = '${Const.gDTS_ABAUN}' OR kue_dokuart = '${Const.gDTS_ABAUK}' OR kue_dokuart = '${Const.gDTS_DBAUD}' ) AND dok_dat_feld_${Const.gDDF_BAUPROJEKT} = '${docTemp.field[Const.gDDF_BAUPROJEKT]}' "
|
|
List<GroovyRowResult> sqlResult1 = d3.getSql().executeAndGet(sqlStatement1)
|
|
if( sqlResult1 != null ) {
|
|
for(GroovyRowResult grr : sqlResult1) {
|
|
Document docSearch = d3.archive.getDocument(grr.get("dokuID"))
|
|
docSearch.field[Const.gDDF_BAUPROJEKT] = doc.field[Const.gDDF_BAUPROJEKT]
|
|
try{
|
|
docSearch.updateAttributes("d3groovy", true)
|
|
} catch(Exception e) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, docSearch.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//jleu 15.03.2017 Wissensdokumente
|
|
//jleu 10.02.2022 Anpassung wg. fehlerhafter Caption
|
|
if( docType.getId().equals(Const.gDTS_DWISS) ) {
|
|
List<String> lValueArr = new ArrayList<>();
|
|
def lThemen = ""
|
|
def tmp
|
|
|
|
if( user.getIsSysUser() == false && !user.getRealName().equals("Master") && !user.getRealName().equals("d3groovy") ) {
|
|
// E-Mail Versand
|
|
Functions.sendMailRecom(d3, doc, user.id())
|
|
}
|
|
|
|
def sqlStatement = "SELECT value_char as lValueArr FROM firm_spez_mult_val WHERE doku_id = '${doc.id()}' and field_no = '${Const.gDDF_THEMA}' "
|
|
List<GroovyRowResult> sqlResult = d3.getSql().executeAndGet(sqlStatement)
|
|
if(sqlResult != null && sqlResult.size() > 0) {
|
|
for(GroovyRowResult grr : sqlResult) {
|
|
lValueArr.add(grr.get("lValueArr"))
|
|
}
|
|
for(int i = 0; i < sqlResult.size(); i++) {
|
|
tmp = lValueArr[i]
|
|
|
|
if( tmp != null && !tmp.equals("")) {
|
|
if ( i == 0)
|
|
{
|
|
lThemen = tmp
|
|
} else {
|
|
lThemen = lThemen + " I " + tmp
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(lThemen.toString().length() > 250) {
|
|
lThemen = lThemen.substring(0, 248);
|
|
}
|
|
doc.field[Const.gDDF_THEMEN] = lThemen
|
|
|
|
try {
|
|
doc.updateAttributes("d3groovy", true)
|
|
} catch(Exception e) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, doc.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
}
|
|
|
|
//Umbennen von Marktforschungsprojekten
|
|
if( docType.getId().equals(Const.gDTS_AMARK) ) {
|
|
if(docTemp.field[Const.gDDF_MARKETINGPROJEKT] != null) {
|
|
def sqlStatement1 = "SELECT doku_id as dokuID FROM firmen_spezifisch WHERE " +
|
|
"( kue_dokuart = '${Const.gDTS_AMARK}' OR kue_dokuart = '${Const.gDTS_AUNMA}' OR kue_dokuart = '${Const.gDTS_DMARK}' ) " +
|
|
" AND dok_dat_feld_${Const.gDDF_MARKETINGPROJEKT} = '${docTemp.field[Const.gDDF_MARKETINGPROJEKT]}' ";
|
|
List<GroovyRowResult> sqlResult1 = d3.getSql().executeAndGet(sqlStatement1)
|
|
if(sqlResult1 != null) {
|
|
for(GroovyRowResult grr : sqlResult1) {
|
|
Document docSearch = d3.archive.getDocument(grr.get("dokuID"))
|
|
docSearch.field[Const.gDDF_MARKETINGPROJEKT] = doc.field[Const.gDDF_MARKETINGPROJEKT]
|
|
try {
|
|
docSearch.updateAttributes("d3groovy", true)
|
|
} catch(Exception e) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, docSearch.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Aufruf der Funktion manage_d3l_Supp_Custo, wenn weitere Kunden_Nr oder weitere Lieferanten_Nr bei Kundendokumenten oder Lieferantendokumenten hinzugefügt oder entfernt werden
|
|
if( docType.getId().equals(Const.gDTS_DKUMA) || docType.getId().equals(Const.gDTS_DLIMA) ) {
|
|
// gDDF_WEITLIEFNR - gDDF_WEITKDNR
|
|
def lFileExt = doc.getFileExtension().toUpperCase()
|
|
if( !lFileExt.equals("D3L") ) {
|
|
// d3.log.error( "Dokumentart: " + docType.getId() + " DokuID: " + doc.id() )
|
|
// Variablen setzen je nach Dokumentart
|
|
// Welches DDF ist zu befüllen?
|
|
// Welche Ziel-Dokumentart wird benötigt und muss abgefragt werden?
|
|
def lDDFToFill
|
|
def lScenario
|
|
def lBlock
|
|
if( docType.getId().equals(Const.gDTS_DKUMA) ) {
|
|
lDDFToFill = Const.gDDF_WEITKDNR
|
|
lScenario = "CustomerNumber"
|
|
} else if( docType.getId().equals(Const.gDTS_DLIMA) ) {
|
|
lDDFToFill = Const.gDDF_WEITLIEFNR
|
|
lScenario = "SupplierNumber"
|
|
}
|
|
|
|
for(int i=1; i <= Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); i++) {
|
|
if( doc.field[lDDFToFill][i] != null || !doc.field[lDDFToFill][i].equals(docTemp.field[lDDFToFill][i]) ) {
|
|
if( docTemp.field[lDDFToFill][i] != null && doc.field[lDDFToFill][i] != null && !doc.field[lDDFToFill][i].equals(docTemp.field[lDDFToFill][i]) ) {
|
|
// d3.log.error( "Start manage_d3l_Supp_Custo with: BLOCK " + lOldNumber[i] )
|
|
lBlock = "BLOCK"
|
|
Functions.createD3lForSuppCusto( d3, lBlock, docTemp.field[lDDFToFill][i], lScenario, doc.id() )
|
|
// d3.log.error( "Start manage_d3l_Supp_Custo with: CREATE/UNBLOCK " + lNewNumber[i] )
|
|
lBlock = "CREATE/UNBLOCK"
|
|
Functions.createD3lForSuppCusto( d3, lBlock, doc.field[lDDFToFill][i], lScenario, doc.id() )
|
|
} else if( docTemp.field[lDDFToFill][i] != null && doc.field[lDDFToFill][i] == null && !doc.field[lDDFToFill][i].equals(docTemp.field[lDDFToFill][i]) ) {
|
|
// d3.log.error( "Start manage_d3l_Supp_Custo with: BLOCK " + lOldNumber[i] )
|
|
lBlock = "BLOCK"
|
|
Functions.createD3lForSuppCusto( d3, lBlock, docTemp.field[lDDFToFill][i], lScenario, doc.id() )
|
|
} else if( doc.field[lDDFToFill][i] != null && !doc.field[lDDFToFill][i].equals(docTemp.field[lDDFToFill][i]) ) {
|
|
// d3.log.error( "Start manage_d3l_Supp_Custo with: CREATE/UNBLOCK " + lNewNumber[i] )
|
|
lBlock = "CREATE/UNBLOCK"
|
|
Functions.createD3lForSuppCusto( d3, lBlock, doc.field[lDDFToFill][i], lScenario, doc.id() )
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 02.2020 - Änderung der Attribute, wenn die Service-Akte sich in SAP geändert hat
|
|
// 08.2020 - Ergänzung um Equipment
|
|
if( docType.getId().equals(Const.gDTS_ASEBE) || docType.getId().equals(Const.gDTS_ASERE) || docType.getId().equals(Const.gDTS_AEQUI) ) {
|
|
Functions.inheritServiceAttributes( d3, doc, docTemp, docType, user )
|
|
}
|
|
|
|
}
|
|
|
|
if ( docTemp != null && docTemp.getType().getId().equals(Const.gDTS_SAPDO) ) {
|
|
def lJahr = doc.field[Const.gDDF_ERDATE].toString()
|
|
lJahr = lJahr.substring(0,4)
|
|
def lMonat = doc.field[Const.gDDF_ERDATE].toString()
|
|
lMonat = lMonat.substring(5,7)
|
|
try {
|
|
def abteilungTemp = "${userName}: Systemuser";
|
|
doc.field[Const.gDFF_ABTEILUNG] = abteilungTemp.toString();
|
|
doc.field[Const.gDDF_JAHR] = lJahr
|
|
doc.field[Const.gDDF_MONAT] = lMonat
|
|
try {
|
|
doc.updateAttributes("d3groovy", true)
|
|
} catch(Exception e) {
|
|
String noticeHoldfile = "Eigenschaten konnten nicht aktualisiert werden: " + e
|
|
int returnValue = d3.call.hold_file_send ( SystemSpecificConst.recipientHoldFile, noticeHoldfile, doc.id(), null, null, false, false, null, null, "d3groovy", 0, false, false, null, 0, false)
|
|
}
|
|
} catch(Exception e) {
|
|
d3.log.error("UpdAttribExit20 " + e.getMessage());
|
|
}
|
|
}
|
|
|
|
gOldDoc = null; // globales Dokument leeren (Sicherheitsfaktor)
|
|
d3.log.info("End proc updateAttribExit20 - pDocId = ${doc.id()}, pError = ${errorCode}, pUser = ${userName}, pDocTypeShort = ${docType.getId()}")
|
|
return 0
|
|
}
|
|
|
|
|
|
/*
|
|
* Dokumentsuche
|
|
* + hook_search_entry_05 (nicht in Nutzung)
|
|
* + hook_search_entry_10 (aktiv)
|
|
* + hook_search_entry_20 (nicht in Nutzung)
|
|
* + hook_search_exit_30 (nicht mehr in Nutzung)
|
|
*/
|
|
|
|
|
|
@Entrypoint( entrypoint = "hook_search_entry_10" )
|
|
public int searchEntry10(D3Interface d3, User user, DocumentType docType, Document searchContext) {
|
|
|
|
def userName = ""
|
|
if(user != null) {
|
|
userName = user.id();
|
|
}
|
|
|
|
// im SearchEntry10 gibt es das Dokument Objekt nur als searchContext, daher folgender Workaround:
|
|
// Document doc = d3.archive.getDocument(searchContext.id())
|
|
Document doc = searchContext;
|
|
|
|
d3.log.info("Start proc searchEntry10 - pUser = ${userName}, pDocTypeShort = ${docType.getId()}")
|
|
|
|
def lLength
|
|
def lReturn
|
|
def lRetCode
|
|
def lReturn2
|
|
|
|
def h_projnr
|
|
def lBuchKr
|
|
def lBuchKr68
|
|
def lLFName
|
|
def lLFNr
|
|
def lKDNr
|
|
def lKDName
|
|
def lHauptProj
|
|
|
|
//Validieren der Prozessart
|
|
if( doc.getType() != null) {
|
|
Functions.validateProcess(d3, doc)
|
|
}
|
|
|
|
//jleu 12.09.2018 Dossier
|
|
if( docType != null && (docType.getId().equals(Const.gDTS_DOSSI) || docType.getId().equals(Const.gDTS_AHAUP) || docType.getId().equals(Const.gDTS_ATEIL) ) ) {
|
|
Functions.splitDossierValue(d3, doc, docType, "SEARCHENTRY");
|
|
}
|
|
|
|
if( docType != null && docType.getId().equals(Const.gDTS_DUMMY) && doc.field[Const.gDDF_HAUPTVONR] != null) {
|
|
String[] splittedString = doc.field[Const.gDDF_HAUPTVONR].split("\\|");
|
|
if( splittedString != null && splittedString.size() == 2) {
|
|
doc.field[Const.gDDF_HAUPTVONR] = splittedString[1];
|
|
}
|
|
}
|
|
|
|
// Splitten des zusammengesetzten Strings ECR Aktivitäts_ID und ECR Beschreibung
|
|
boolean repoIdActivityExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gECRCONRID);
|
|
if( repoIdActivityExists == true && doc.field[Const.gDDF_AKTIVITAETSID] != null ) {
|
|
Functions.splitActivity(d3, doc);
|
|
}
|
|
|
|
/* 02.2020 - da wir nun mit Groovy-Übersetzungen arbeiten, sollte dies überflüssig sein
|
|
*
|
|
// Ermittlung in welchen Dokumentarten die Eigenschaften Buchungskreis, Buchungskreise verwendet werden
|
|
def sqlStatementBuch = "SELECT DISTINCT kue_dokuart as dokuart " +
|
|
"FROM fispe_titel_dokuart " +
|
|
"WHERE repository_id = '${SystemSpecificConst.gBuchungskreisID}' " +
|
|
"OR repository_id = '${SystemSpecificConst.gBuchungskreiseID}' "
|
|
List<GroovyRowResult> sqlResultBuch = d3.sql.executeAndGet(sqlStatementBuch);
|
|
List<String> listDokuArtenBuchngskreis = new ArrayList<>()
|
|
for(GroovyRowResult grr : sqlResultBuch) {
|
|
listDokuArtenBuchngskreis.add(grr.get("dokuart"))
|
|
}
|
|
//Splitten des zusammengesetzten Strings Buchungskreis, Buchungskreise
|
|
if( listDokuArtenBuchngskreis.contains(docType.getId()) && ( doc.field[Const.gDDF_BUCHKREIS] != null || doc.field[Const.gDDF_BUCHKREIS68][1] != null )) {
|
|
String[] splittedStringEinf = doc.field[Const.gDDF_BUCHKREIS].split(" \\| ")
|
|
lReturn = splittedStringEinf.size()
|
|
if ( lReturn >= 1 ) {
|
|
doc.field[Const.gDDF_BUCHKREIS] = splittedStringEinf[0].trim()
|
|
// d3.log.info( "Suchparameter: dok_dat_feld[gDDF_BUCHKREIS]: ${doc.field[Const.gDDF_BUCHKREIS]}" )
|
|
}
|
|
if(doc.field[Const.gDDF_BUCHKREIS68][1] != null) {
|
|
String[] splittedStringMehrf = doc.field[Const.gDDF_BUCHKREIS68][1].split(" \\| ")
|
|
lReturn = splittedStringMehrf.size()
|
|
if( lReturn > 1 ) {
|
|
doc.field[Const.gDDF_BUCHKREIS68][1] = splittedStringMehrf[0].replaceAll(" ", "")
|
|
// d3.log.info( "Suchparameter: dok_dat_feld_:(gDDF_BUCHKREIS68)[1]: ${doc.field[Const.gDDF_BUCHKREIS68][1]}" )
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
|
|
// JLEU 07.05.2020: sobald die Organisationseinheiten von Buchungskreisen zu Funktionen umgestellt wurden (Steuerung über Akten) kann dieser Teil weg!
|
|
boolean repoIdOrganEinheitExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gOrganEinheitID);
|
|
// Split des zusammengesetzten Feldes Organisationseinheit
|
|
if ( repoIdOrganEinheitExists == true && doc.field[Const.gDDF_ORGEINHEIT] != null ) {
|
|
doc.field[Const.gDDF_ORGEINHEIT] = Functions.splitBuKrs(doc.field[Const.gDDF_ORGEINHEIT]);
|
|
}
|
|
|
|
boolean repoIdFunktionExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gFunktionID);
|
|
if( repoIdFunktionExists == true && doc.field[Const.gDDF_FUNKTION] != null ) {
|
|
lReturn = Functions.splitFunction( d3, doc, docType.getId());
|
|
}
|
|
|
|
boolean repoIdModuleExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gModuleID);
|
|
if( repoIdModuleExists == true && doc.field[Const.gDDF_MODUL] != null ) {
|
|
// Split Attribut Modul bei Technikdokumenten im Import
|
|
lReturn = Functions.splitModule(d3, doc, docType.getId());
|
|
}
|
|
|
|
//Splitten des Lieferantennamens und der Lieferantennummer für die Suche
|
|
boolean repoIdLieferantExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gLieferantNrID);
|
|
if( repoIdLieferantExists == true && ( doc.field[Const.gDDF_LNAME] != null || doc.field[Const.gDDF_LNR] != null ) ) {
|
|
Functions.splitLieferantSearch(d3, doc, docType);
|
|
}
|
|
|
|
// Ermittlung in welchen Dokumentarten die Eigenschaften Kundennamens, Kundennummer verwendet werden
|
|
boolean repoIdKundeExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gKundennrID);
|
|
if( repoIdKundeExists == true ) {
|
|
Functions.splitKunde(d3, doc, docType);
|
|
}
|
|
|
|
// Ermittlung in welchen Dokumentarten die Eigenschaften Endkundenname und Endkundennummer verwendet werden
|
|
boolean repoIdEndKundeExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gEndkundennrID);
|
|
if( repoIdEndKundeExists == true ) {
|
|
Functions.splitEndKunde(d3, doc, docType);
|
|
}
|
|
|
|
// Split Zuordnung Kundenkontakt
|
|
// if( ( pDocTypeShort == gDTS_DLIKO || pDocTypeShort == gDTS_DMSPE || pDocTypeShort == gDTS_DKOMM || \
|
|
// pDocTypeShort == gDTS_DMAP1 || pDocTypeShort == gDTS_DMAUF || pDocTypeShort == gDTS_DMDOK || \
|
|
// pDocTypeShort == gDTS_DMECR || pDocTypeShort == gDTS_DOPP1 || pDocTypeShort == gDTS_DPRST || \
|
|
// pDocTypeShort == gDTS_DUMMY ) && \
|
|
// dok_dat_feld[gDDF_MAPPCUSTACTION] != "" )
|
|
// {
|
|
// // Nur der Vollständigkeit halber, wird nicht gesplittet
|
|
// }
|
|
|
|
|
|
// Ermittlung in welchen Dokumentarten die Eigenschaften Hauptopportunitynummer und Opportunitynummer verwendet werden
|
|
boolean repoIdOppExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gOpportunityNrID);
|
|
boolean repoIdHauptOppSubExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gHauptOpportunityID);
|
|
if(repoIdOppExists == true || repoIdHauptOppSubExists == true) {
|
|
Functions.splitOpportunitySubmission(d3, doc, docType);
|
|
}
|
|
|
|
|
|
/* 02.2020 - In der suche steht weitere Opportunitynummer nicht zur Verfügung
|
|
*
|
|
// Ermittlung in welchen Dokumentarten die Eigenschaft Opportunity-Nummern (Mehrfachfeld) verwendet wird
|
|
def sqlStatementOppMehrf = "SELECT DISTINCT kue_dokuart as dokuart " +
|
|
"FROM fispe_titel_dokuart " +
|
|
"WHERE repository_id = '${SystemSpecificConst.gWeitOpportunityID}' "
|
|
List<GroovyRowResult> sqlResultOppMehrf = d3.sql.executeAndGet(sqlStatementOppMehrf);
|
|
List<String> listDokuArtenOppMehrf = new ArrayList<>()
|
|
for(GroovyRowResult grr : sqlResultOppMehrf) {
|
|
listDokuArtenOppMehrf.add(grr.get("dokuart"))
|
|
}
|
|
//Splitten des zusammengesetzten String Opportunity-Nummern (Mehrfachfeld Opportunitydokumente) und Submission nach Opportunitynummer
|
|
if( ( listDokuArtenOppMehrf.contains(docType.getId()) ) && doc.field[Const.gDDF_OPPNRM][1] != null ) {
|
|
String[] splittedString = doc.field[Const.gDDF_OPPNRM][1].split(" \\| ")
|
|
lRetCode = splittedString.size()
|
|
if( splittedString[0] != null ) {
|
|
doc.field[Const.gDDF_OPPNRM][1] = splittedString[0]
|
|
}
|
|
}
|
|
*/
|
|
|
|
|
|
// Ermittlung in welchen Dokumentarten die Eigenschaft Projektnummer
|
|
boolean repoIdProjektNrExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gProjektNrID);
|
|
if(repoIdProjektNrExists == true) {
|
|
Functions.splitProjektnummer(d3, doc, docType);
|
|
}
|
|
|
|
// phoer 20191024: Splitten der zusammengesetzten Strings SR-ID, Beschreibung
|
|
boolean repoIdSrIdExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gSRIDID);
|
|
if(repoIdSrIdExists == true) {
|
|
Functions.splitServSrId(d3, doc, docType);
|
|
int resultValidateSrId = Functions.validateSrId(d3, doc);
|
|
if(resultValidateSrId != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte weitere SR_ID in Zeile ${resultValidateSrId} prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check further SR_ID in line ${resultValidateSrId} ")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// phoer 20191024: Splitten der zusammengesetzten Strings SR-ID, Beschreibung
|
|
boolean repoIdServBelegExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gBelegNrID);
|
|
if(repoIdServBelegExists == true) {
|
|
Functions.splitServBelegnummer(d3, doc, docType);
|
|
int resultValidateBelegNr = Functions.validateBelegNr(d3, doc);
|
|
if(resultValidateBelegNr != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte weitere Belegnummer in Zeile ${resultValidateBelegNr} prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check further actitivy no in line ${resultValidateBelegNr} ")
|
|
}
|
|
return -170
|
|
}
|
|
}
|
|
|
|
// imue 26.08.2020 - Ergänzung für Equipment
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gWeitereEquipmentID) == true ) {
|
|
Functions.splitEquipment(d3, doc, docType, "SEARCH");
|
|
}
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gEquipmentID) == true ) {
|
|
Functions.splitEquipment(d3, doc, docType, "SEARCH");
|
|
}
|
|
|
|
// imue 12.12.2022
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gEquipmentsID) == true ) {
|
|
Functions.splitEquipments(d3, doc, docType);
|
|
}
|
|
|
|
/* 02.2020 - Weitere Projektnummer ist in der Suche nicht verfügbar
|
|
*
|
|
if( ( docType.getId().equals(Const.gDTS_DLIKO) || docType.getId().equals(Const.gDTS_DMSPE) || docType.getId().equals(Const.gDTS_DKOMM) ||
|
|
docType.getId().equals(Const.gDTS_DMAP1) || docType.getId().equals(Const.gDTS_DMAUF) || docType.getId().equals(Const.gDTS_DMDOK) ||
|
|
docType.getId().equals(Const.gDTS_DOPP1) || docType.getId().equals(Const.gDTS_DPRST) || docType.getId().equals(Const.gDTS_DUMMY) ) && doc.field[Const.gDDF_WEITAUFTRAGSNR][1] != null ) {
|
|
String[] splittedString = doc.field[Const.gDDF_WEITAUFTRAGSNR][1].split("\\|")
|
|
lReturn = splittedString.size()
|
|
if( lReturn > 1 ) {
|
|
def convertedString = splittedString[0].replaceAll(" ", "")
|
|
doc.field[Const.gDDF_WEITAUFTRAGSNR][1] = convertedString
|
|
}
|
|
}
|
|
*/
|
|
|
|
//Splitten des zusammengesetzten Strings Projektnr, Projektname nach Projektnummer für das Feld Projektnummer (Organisation)
|
|
boolean repoIdOrgProjNrExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gProjOrgNrID);
|
|
if( repoIdOrgProjNrExists == true && doc.field[Const.gDDF_PROJNR] != null ) {
|
|
Functions.splitProjekt(d3, doc, docType, user, "SEARCH");
|
|
}
|
|
|
|
//Org. Hauptprojekt
|
|
// if(( pDocTypeShort == gDTS_AMEIS || pDocTypeShort == gDTS_APROJ || pDocTypeShort == gDTS_DPROO || pDocTypeShort == gDTS_DUMMY ) && ( dok_dat_feld[gDDF_PROJVERKN] != "" ) ) {
|
|
// Der Wert im Feld Org.Hauptprojekt wird ungesplittet abgelegt, daher kein Split notwendig
|
|
// }
|
|
|
|
/* 02.2020 - PSP Element gibt es in der Suche nicht
|
|
*
|
|
// Splitten des zusammengesetzten Strings PSP Element
|
|
if( ( docType.getId().equals(Const.gDTS_DMDOK) || docType.getId().equals(Const.gDTS_DMSPE) || docType.getId().equals(Const.gDTS_AMPRO) ) && doc.field[Const.gDDF_PSPELEMENT] != null ) {
|
|
String[] splittedString = doc.field[Const.gDDF_PSPELEMENT].split(" \\| ")
|
|
lReturn = splittedString.size()
|
|
if( lReturn > 1 ) {
|
|
doc.field[Const.gDDF_PSPELEMENT] = splittedString[0]
|
|
doc.field[Const.gDDF_NPN] = splittedString[1].trim()
|
|
d3.log.info( "Suchparameter: dok_dat_feld[:gDDF_PSPELEMENT]: ${doc.field[Const.gDDF_PSPELEMENT]})\"" )
|
|
d3.log.info( "Suchparameter: dok_dat_feld[:gDDF_NPN]: ${doc.field[Const.gDDF_NPN]})\"" )
|
|
}
|
|
}
|
|
*/
|
|
|
|
// Splitten des zusammengesetzten Strings Netzplan
|
|
boolean repoIdNetzplanExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gNetzplanNrId);
|
|
if( repoIdNetzplanExists == true && doc.field[Const.gDDF_NPN] != null ) {
|
|
String[] splittedString = doc.field[Const.gDDF_NPN].split(" \\| ");
|
|
if(splittedString != null) {
|
|
lReturn = splittedString.size()
|
|
if( lReturn > 1 ) {
|
|
doc.field[Const.gDDF_NPN] = splittedString[0];
|
|
}
|
|
}
|
|
}
|
|
|
|
// imue 18.10.2019 - Splitten des zusammengesetzten Strings Maschinentyp
|
|
boolean repoIdMaTypExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gMaschinentypID);
|
|
if( repoIdMaTypExists == true && doc.field[Const.gDDF_MASCHINENTYP] != null ) {
|
|
String[] splittedString = doc.field[Const.gDDF_MASCHINENTYP].split(" \\| ")
|
|
if(splittedString != null) {
|
|
lReturn = splittedString.size()
|
|
if( lReturn > 1 ) {
|
|
doc.field[Const.gDDF_MASCHINENTYP] = splittedString[2].trim();
|
|
}
|
|
}
|
|
}
|
|
|
|
// 09.05.2017 Split Kundenkontakt-ID
|
|
boolean repoIdKundenKontaktIdExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gKundenkontaktIDID);
|
|
if( repoIdKundenKontaktIdExists == true && doc.field[Const.gDDF_KONTAKTNUMMER] != null ) {
|
|
int returnValue = Functions.validateKuKoID(d3, doc, user, "SEARCH");
|
|
/* JE NACH RÜCKMELDUNG FACHBEREICH; KANN DIES WEG
|
|
String[] splittedString = doc.field[Const.gDDF_KONTAKTNUMMER].split("\\|")
|
|
if(splittedString != null) {
|
|
lReturn = splittedString.size()
|
|
if( lReturn == 5 ) {
|
|
doc.field[Const.gDDF_KONTAKTNUMMER] = splittedString[2].trim()
|
|
doc.field[Const.gDDF_KDAKTNAME] = splittedString[4]
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
|
|
boolean repoIdMusterMaterialMehrfachIdExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gMusterMaterialMehrfID);
|
|
if( repoIdMusterMaterialMehrfachIdExists == true && doc.field[Const.gDDF_MUSTERMATNR69][1] != null ) {
|
|
String[] splittedString = doc.field[Const.gDDF_MUSTERMATNR69][1].split(" \\| ")
|
|
if(splittedString != null) {
|
|
lReturn = splittedString.size()
|
|
if( lReturn == 2 ) {
|
|
doc.field[Const.gDDF_MUSTERMATNR69][1] = splittedString[0].trim()
|
|
}
|
|
}
|
|
}
|
|
|
|
// jleu, 24.01.2018 Splitten der Eigenschaft d.3Benutzer
|
|
if( docType != null && ( docType.getId().equals(Const.gDTS_DMARK) || docType.getId().equals(Const.gDTS_AVEVO) || docType.getId().equals(Const.gDTS_DVEDO) || docType.getId().equals(Const.gDTS_AREME) || docType.getId().equals(Const.gDTS_AMARK) ) ) {
|
|
def ld3user
|
|
String test = doc.field[Const.gDDF_D3USER67][1];
|
|
if( doc.field[Const.gDDF_D3USER67][1] != null ) {
|
|
ld3user = doc.field[Const.gDDF_D3USER67][1];
|
|
if(ld3user != null) {
|
|
String[] splittedString = ld3user.split("\\=");
|
|
if(splittedString != null) {
|
|
doc.field[Const.gDDF_D3USER67][1] = splittedString[0];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Split der Kontakt_Beschreibung DLONT Lieferantenaktivitätsdokumente Lieferantenmanagement
|
|
boolean repoIdKDKontaktBeschIdExists = Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gKontaktBeschreibungID);
|
|
if( repoIdKDKontaktBeschIdExists == true ) {
|
|
Functions.splitLieferantenkontaktbeschreibung(d3, doc, docType);
|
|
}
|
|
|
|
// Vorbelegung des Attribut Prozess bei Maschinenprojektdokumente und Opportunitydokumente (OPG-2169)
|
|
if( docType != null && ( docType.getId().equals(Const.gDTS_DMAP1) || docType.getId().equals(Const.gDTS_DOPP1) || docType.getId().equals(Const.gDTS_ENTMAP) ) ) {
|
|
if( docType.getId().equals(Const.gDTS_DMAP1) ) {
|
|
doc.field[Const.gDDF_PROZESS] = '0202'
|
|
} else if( docType.getId().equals(Const.gDTS_DOPP1) ) {
|
|
doc.field[Const.gDDF_PROZESS] = '0201'
|
|
} else if( docType.getId().equals(Const.gDTS_ENTMAP) ) {
|
|
doc.field[Const.gDDF_PROZESS] = '0204'
|
|
}
|
|
}
|
|
|
|
d3.log.info("Ende proc searchEntry10 - pUser = ${userName}, pDocTypeShort = ${docType.getId()}")
|
|
return 0;
|
|
}
|
|
|
|
|
|
/*
|
|
* Validieren von Eigenschaftswerten
|
|
* + hook_validate_import_entry_10 (aktiv)
|
|
* + hook_validate_search_entry_10 (nicht in Nutzung)
|
|
* + hook_validate_update_entry_10 (aktiv)
|
|
*/
|
|
|
|
|
|
@Entrypoint( entrypoint = "hook_validate_update_entry_10" )
|
|
public int validateUpdateEntry10(D3Interface d3, User user, DocumentType docType, Document doc, String nextcall) {
|
|
|
|
def userName = ""
|
|
if(user != null) {
|
|
userName = user.id();
|
|
}
|
|
d3.log.info( "validateUpdateEntry10( ${userName}, ${docType.getId()}, ${doc.id()} )" )
|
|
def lReturn
|
|
def lReturn2
|
|
def lAndClause = ""
|
|
def lRetCode
|
|
|
|
//jleu 16.05.2018 Dossier
|
|
if ( docType.getId().equals(Const.gDTS_DOSSI) ){
|
|
Functions.splitDossierValue(d3, doc, docType, "UPDATEENTRY")
|
|
}
|
|
|
|
def returnWeit = Functions.validateWeitKundLiefNo(d3, doc, docType);
|
|
|
|
// Documenteigenschaften vor Update
|
|
// 25.11.2022 imue: Korrektur
|
|
Document docBeforeUpdate = null;
|
|
try {
|
|
docBeforeUpdate = d3.archive.getDocument(doc.id().toString());
|
|
} catch(Exception e) {
|
|
d3.log.info("validateUpdateEntry10 - docBeforeUpdate konnte nicht geladen werden");
|
|
}
|
|
|
|
// Splitten des zusammengesetzten Strings Lieferantenname, Lieferantennummer nach Lieferantennumer für das Feld Lieferantennummer und Lieferantenname (führend immer die Lieferantennummer)
|
|
if ( ( docType.getId().equals(Const.gDTS_DMEOP) || docType.getId().equals(Const.gDTS_ALIEF) || docType.getId().equals(Const.gDTS_ALIKO) ||
|
|
docType.getId().equals(Const.gDTS_DLIMA) || docType.getId().equals(Const.gDTS_DLONT) || docType.getId().equals(Const.gDTS_ALIMA) ||
|
|
docType.getId().equals(Const.gDTS_ALIAK) || docType.getId().equals(Const.gDTS_ALONT) || docType.getId().equals(Const.gDTS_DLIKO) ) &&
|
|
( docBeforeUpdate != null && (!docBeforeUpdate.field[Const.gDDF_LNR].equals(doc.field[Const.gDDF_LNR]) || !docBeforeUpdate.field[Const.gDDF_LNAME].equals(doc.field[Const.gDDF_LNAME]) ) ) ) {
|
|
|
|
def returnSplitLieferant = Functions.splitLieferant(d3, doc, docType, user, "update" , docBeforeUpdate);
|
|
if(returnSplitLieferant == -170) {
|
|
return -170
|
|
}
|
|
}
|
|
|
|
/*
|
|
// wird bereits im UpdateEntry20 erledigt
|
|
// Split der Kundenkontakt_Beschreibung DLONT Lieferantenkontaktdokumente_neu Lieferantenmanagement
|
|
if ( docType.getId().equals(Const.gDTS_DLONT) ) {
|
|
if( doc.field[Const.gDDF_KDAKTBESCH] != null && !doc.field[Const.gDDF_KDAKTBESCH].equals("") ) {
|
|
lReturn = doc.field[Const.gDDF_KDAKTBESCH].indexOf("|")
|
|
String[] splittedString
|
|
if( lReturn > 0 ) {
|
|
splittedString = doc.field[Const.gDDF_KDAKTBESCH].split("\\|")
|
|
lReturn = splittedString.size()
|
|
}
|
|
if( lReturn == 3 ) {
|
|
// Anpassung imue 17.04.2019
|
|
def sqlStatement = "SELECT value_char_allowed as allowedValue " +
|
|
"FROM doc_field_val_lang " +
|
|
"WHERE predef_value_id = '${SystemSpecificConst.gPredValueIDKatLief}' AND value_char_transl = '{splittedString[1]}' "
|
|
GroovyRowResult grr = d3.sql.firstRow(sqlStatement);
|
|
def lKontKategorie
|
|
if(grr != null) {
|
|
lKontKategorie = grr.get("allowedValue");
|
|
}
|
|
doc.field[Const.gDDF_KONTAKTDATE] = splittedString[0]
|
|
doc.field[Const.gDDF_KDAKTKAT] = lKontKategorie
|
|
doc.field[Const.gDDF_KDAKTBESCH] = splittedString[2]
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
|
|
//Maschinenprojekt Prototyp 4: Wenn beim Import die Dokumentgruppe Medien gewählt wurde, aber das Feld Akte leer ist, gib einen Fehler aus
|
|
if ( ( docType.getId().equals(Const.gDTS_DMDOK) || docType.getId().equals(Const.gDTS_DMAUF) || docType.getId().equals(Const.gDTS_DMSPE) || docType.getId().equals(Const.gDTS_DPRST) ||
|
|
docType.getId().equals(Const.gDTS_DLIMA) || docType.getId().equals(Const.gDTS_DKUMA) )
|
|
&& doc.field[Const.gDDF_DOKGROUP].equals(Const.gDG_Medien) && ( doc.field[Const.gDDF_SUBJECT] == null || doc.field[Const.gDDF_SUBJECT].equals("")) ) {
|
|
// dkle, 02.02.2016 additional infotext eingefügt
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Sie versuchen ein Dokument mit der Dokumentgruppe Medien zu aktualisieren, ohne eine Akte ausgewaehlt zu haben. Bitte korrigieren Sie Ihre Eingabe")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "You try to update an document as Medien without choosing a folder. Please correct your input.")
|
|
}
|
|
d3.log.error( "Sie versuchen ein Dokument mit der Dokumentgruppe Medien zu aktualisieren, ohne eine Akte ausgewaehlt zu haben. Bitte korrigieren Sie Ihre Eingabe" )
|
|
return -170
|
|
} else if ( docType.getId().equals(Const.gDTS_DPRST) && doc.field[Const.gDDF_SUBJECT].equals(Const.gAK_Projektorganisation) ) {
|
|
doc.field[Const.gDDF_SUBJECT] = ""
|
|
}
|
|
|
|
def InvalidData = 0
|
|
if( docType.getId().equals(Const.gDTS_DMECR) && (!doc.field[Const.gDDF_AUFTRNR].equals("") && doc.field[Const.gDDF_AUFTRNR] != null) ) {
|
|
// d3.log.error( doc.field[Const.gDDF_AKTIVITAETSID] )
|
|
// d3.log.error( doc.field[Const.gDDF_BESCHREIBUNG] )
|
|
InvalidData = Functions.validateActivity( d3, doc, "Update")
|
|
} else if( docType.getId().equals(Const.gDTS_DMECR) && ( (doc.field[Const.gDDF_AKTIVITAETSID] != null && !doc.field[Const.gDDF_AKTIVITAETSID].equals("")) || (doc.field[Const.gDDF_BESCHREIBUNG] != null && !doc.field[Const.gDDF_BESCHREIBUNG].equals("")) ) && (doc.field[Const.gDDF_AUFTRNR].equals("") || doc.field[Const.gDDF_AUFTRNR] == null) ) {
|
|
InvalidData = 2
|
|
}
|
|
if( InvalidData == 1 ) {
|
|
// Meldung an den Benutzer, dass die Projektnummer gefüllt werden muss
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT002049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT002001)
|
|
}
|
|
d3.log.error( Const.gADITXT002049 )
|
|
return -170
|
|
} else if( InvalidData == 2 ) {
|
|
// Meldung an den Benutzer, dass die Projektnummer gefüllt werden muss
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT001049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT001001)
|
|
}
|
|
d3.log.error( Const.gADITXT001049 )
|
|
return -170
|
|
}
|
|
|
|
//Splitten des zusammengesetzten String Opportunitynummer und Submission nach Opportunitynummer
|
|
def returnOpp = Functions.splitOpportunitySubmission(d3, doc, docType);
|
|
|
|
//Splitten der zusammengesetzten Strings Projektnummer und Submission nach Projektnummer
|
|
def returnProj = Functions.splitProjektnummer(d3, doc, docType);
|
|
|
|
|
|
/* wird bereits im UpdateEntry10 ausgeführt, daher hier nicht notwendig
|
|
// phoer 20191024: Splitten der zusammengesetzten Strings SR-ID, Beschreibung
|
|
if( docType.getId().equals(Const.gDTS_DSERE) || docType.getId().equals(Const.gDTS_ASERE) ) {
|
|
String[] splittedString = doc.field[Const.gDDF_SRID].split(" \\| ");
|
|
//Wenn SR-ID ermittelt wurde, dann SR-ID in Attributfeld schreiben
|
|
if( splittedString[0] != null ) {
|
|
doc.field[Const.gDDF_SRID] = splittedString[0].trim();
|
|
}
|
|
}
|
|
// phoer 20191024: Splitten der zusammengesetzten Strings SR-ID, Beschreibung
|
|
if( docType.getId().equals(Const.gDTS_DSEBE) || docType.getId().equals(Const.gDTS_ASEBE) ) {
|
|
String[] splittedString = doc.field[Const.gDDF_BELEGNUMMER].split(" \\| ");
|
|
//Wenn SR-ID ermittelt wurde, dann Servicebelegnummer in Attributfeld schreiben
|
|
if( splittedString[0] != null) {
|
|
doc.field[Const.gDDF_BELEGNUMMER] = splittedString[0].trim();
|
|
if( splittedString[2] != null) {
|
|
doc.field[Const.gDDF_BELEGTYP] = splittedString[2].trim();
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
|
|
|
|
//Splitten des zusammengesetzten String Opportunity-Nummern (Mehrfachfeld Opportunitydokumente) und Submission nach Opportunitynummer
|
|
// 21.03.2018 dkle: Wegen Groovy Hook Validierung in den validateUpdateEntry10 umgezogen
|
|
def returnOppMehr = Functions.splitOpportunityMehrf(d3, doc, docType);
|
|
|
|
|
|
// Splitten der Kundenaktivitäts-ID beim Update
|
|
// 21.03.2018 dkle: Wegen Groovy Hook Validierung in den validateUpdateEntry10 umgezogen
|
|
if ( docType.getId().equals(Const.gDTS_DKUKO) && docBeforeUpdate != null && !doc.field[Const.gDDF_KONTAKTNUMMER].equals(docBeforeUpdate.field[Const.gDDF_KONTAKTNUMMER] ) ) {
|
|
lReturn = Functions.validateKuKoID( d3, doc, user, "Update" )
|
|
if( lReturn == -170 ) {
|
|
// dkle, 02.02.2016 additional info Text eingefügt
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT014049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT014001)
|
|
}
|
|
d3.log.error( "Bitte geben Sie eine gueltige Kundenkontakt-ID ein." )
|
|
return -170
|
|
}
|
|
}
|
|
|
|
|
|
d3.log.info("ENDE validateUpdateEntry10 -- pUser ${userName}, pDocTypeShort {docType.getId()} ")
|
|
return 0;
|
|
}
|
|
|
|
|
|
@Entrypoint( entrypoint = "hook_validate_import_entry_10" )
|
|
public int validateImportEntry10(D3Interface d3, User user, DocumentType docType, Document doc, String nextcall) {
|
|
|
|
//jleu 01.08.2018 Vertragsdokumente
|
|
if( docType.getId().equals(Const.gDTS_EVDOK) || docType.getId().equals(Const.gDTS_EVUNT) ) {
|
|
def lRetVal = Functions.checkContractNumber(d3, doc)
|
|
if( lRetVal == 10 ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT019049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT019001)
|
|
}
|
|
return -200
|
|
}
|
|
}
|
|
return 0;
|
|
|
|
//jleu 21.05.2021 ITSM Dokumente
|
|
if( docType.getId().equals(Const.gDTS_DITSM) ) {
|
|
def RetVal = Functions.checkITSMNumber(d3, doc)
|
|
|
|
if (RetVal == 10)
|
|
{
|
|
// Meldung an den Benutzer, dass eine unbekannte ITSM ID verwendet wird
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT025049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT025001)
|
|
}
|
|
return -170
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
* Einspielen einer neuen Version
|
|
* + hook_new_version_entry_10 (aktiv)
|
|
* + hook_new_version_entry_20 (aktiv)
|
|
* + hook_new_version_entry_30 (nicht in Nutzung)
|
|
* + hook_new_version_exit_10 (nicht in Nutzung)
|
|
* + hook_new_version_exit_20 (nicht in Nutzung)
|
|
* + hook_new_version_exit_30 (aktiv)
|
|
*/
|
|
|
|
|
|
@Entrypoint( entrypoint = "hook_new_version_entry_10" )
|
|
public int newVersionEntry10(D3Interface d3, Document doc, String fileSource, String fileDestination, User user, DocumentType docType) {
|
|
// proc NewVersionEntry10(pDocId, pFileSource, pFileDest, pUser, pDocTypeShort)
|
|
|
|
def userName = ""
|
|
if(user != null) {
|
|
userName = user.id();
|
|
}
|
|
|
|
Document oldDoc = null;
|
|
if(doc.id() == null) {
|
|
//Ermittlung der Doku-Id über ZeichNr
|
|
def sqlStatement = "SELECT doku_id as pDocId FROM phys_datei WHERE zeich_nr = '${doc.getNumber()}' "
|
|
def sqlResult = d3.sql.executeAndGet(sqlStatement)
|
|
if( sqlResult != null && sqlResult.size()> 0) {
|
|
def pDocId = sqlResult.getAt(0).get("pDocId")
|
|
oldDoc = d3.archive.getDocument(pDocId);
|
|
}
|
|
} else {
|
|
oldDoc = d3.archive.getDocument(doc.id());
|
|
}
|
|
|
|
d3.log.info("Start proc NewVersionEntry10 - pDocId = ${doc.id()}, pUser = ${userName}, pDocTypeShort = ${docType.getId()}, pFileSource = ${fileSource}, pFileDest = ${fileDestination}")
|
|
|
|
def lTextMig
|
|
def InvalidData
|
|
def lECRStatus
|
|
def lChildCount
|
|
def h_projnr
|
|
def lProjNr
|
|
def lBuchKr
|
|
def lBuchKr68
|
|
def lRetCode
|
|
def pRowCount
|
|
def lLength
|
|
def lReturn2
|
|
def lReturn
|
|
def lSubject
|
|
def lAndClause
|
|
def lCount
|
|
def datei_erw
|
|
if ( doc.getFileExtension() != null )
|
|
{
|
|
datei_erw = doc.getFileExtension().toLowerCase()
|
|
}
|
|
def pDocId
|
|
|
|
//Validieren der Prozessart
|
|
Functions.validateProcess(d3, doc)
|
|
|
|
// imue 25.02.2019 - Aktualisierung durch MSG verhindern (Import über Dokumentklasse gelöst) - OPG-2106
|
|
if( datei_erw.equals('msg') && doc.id() == null ) {
|
|
|
|
//Ermittlung der Doku-Id über ZeichNr
|
|
def sqlStatement = "SELECT doku_id as pDocId FROM phys_datei WHERE dokuart = '${docType.getId()}' AND zeich_nr = '${doc.getNumber()}' "
|
|
def sqlResult = d3.sql.executeAndGet(sqlStatement)
|
|
if(sqlResult != null) {
|
|
pDocId = sqlResult.getAt(0).get("pDocId")
|
|
}
|
|
|
|
// Meldung an den Benutzer, dass ein MSG File nicht genutzt werden darf
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT024049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT024001)
|
|
}
|
|
d3.log.error( Const.gADITXT024049 )
|
|
lReturn = d3.call.document_transfer("Freigabe", null, null, true, 0, "d3groovy", pDocId)
|
|
return -170
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_DLIMA) || docType.getId().equals(Const.gDTS_DKUMA) ) {
|
|
Functions.validateWeitKundLiefNo(d3, doc, docType);
|
|
}
|
|
|
|
//jleu 16.05.2018 Dossier
|
|
if( docType.getId().equals(Const.gDTS_DOSSI) ) {
|
|
Functions.splitDossierValue(d3, doc, docType, "NEWVERSIONENTRY")
|
|
}
|
|
|
|
//jleu 29.03.2017 Marktforschungsdokumente
|
|
if( docType.getId().equals(Const.gDTS_DMARK) || docType.getId().equals(Const.gDTS_AVEVO) || docType.getId().equals(Const.gDTS_DVEDO) || docType.getId().equals(Const.gDTS_AREME) || docType.getId().equals(Const.gDTS_AMARK) || docType.getId().equals(Const.gDTS_DSCHU) ) {
|
|
Functions.splitUser(d3, doc);
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_DLOEH) ) {
|
|
Functions.sixty2single(d3, doc)
|
|
}
|
|
|
|
//Splitten des zusammengesetzten Strings Buchungskreis, Buchungskreistext nach Buchungskreis
|
|
def returnBuch = Functions.splitBuchungskreis(d3, doc, docType);
|
|
|
|
//Splitten des zusammengesetzten Strings Projektnr, Projektname nach Projektnummer für das Feld Projektnummer
|
|
if( docType.getId().equals(Const.gDTS_DPROO) ) {
|
|
h_projnr = doc.field[Const.gDDF_PROJNR].substring(0,14)
|
|
doc.field[Const.gDDF_PROJNR] = h_projnr
|
|
}
|
|
|
|
//Splitten des zusammengesetzten String Opportunitynummer und Submission nach Opportunitynummer
|
|
def returnOpp = Functions.splitOpportunitySubmission(d3, doc, docType);
|
|
|
|
|
|
//Splitten der zusammengesetzten Strings Projektnummer und Submission nach Projektnummer
|
|
def returnProj = Functions.splitProjektnummer(d3, doc, docType);
|
|
|
|
|
|
//Splitten des zusammengesetzten String Opportunity-Nummern (Mehrfachfeld Opportunitydokumente) und Submission nach Opportunitynummer
|
|
def returnOppMehr = Functions.splitOpportunityMehrf(d3, doc, docType);
|
|
|
|
if( (doc.field[Const.gDDF_LNR] != null && oldDoc.field[Const.gDDF_LNR] != null) || (doc.field[Const.gDDF_LNAME] != null && oldDoc.field[Const.gDDF_LNAME] != null) ) {
|
|
if( ( !doc.field[Const.gDDF_LNR].equals(oldDoc.field[Const.gDDF_LNR]) || !doc.field[Const.gDDF_LNAME].equals(oldDoc.field[Const.gDDF_LNAME]) ) &&
|
|
( docType.getId().equals(Const.gDTS_DLIKO) || docType.getId().equals(Const.gDTS_DLONT) || docType.getId().equals(Const.gDTS_DLIMA) ) ) {
|
|
|
|
def returnSplitLieferant = Functions.splitLieferant(d3, doc, docType, user, "update", oldDoc);
|
|
if(returnSplitLieferant == -170) {
|
|
return -170
|
|
}
|
|
}
|
|
}
|
|
|
|
if( (doc.field[Const.gDDF_KNR] != null && oldDoc.field[Const.gDDF_KNR] != null) || (doc.field[Const.gDDF_KNAME] != null && oldDoc.field[Const.gDDF_KNAME] != null) ) {
|
|
if( ( !doc.field[Const.gDDF_KNR].equals(oldDoc.field[Const.gDDF_KNR]) || !doc.field[Const.gDDF_KNAME].equals(oldDoc.field[Const.gDDF_KNAME]) ) &&
|
|
( docType.getId().equals(Const.gDTS_DKUMA) ) ) {
|
|
int returnValidateKunden = Functions.validateKunden(d3, doc, docType, user, "update")
|
|
if(returnValidateKunden == -170) {
|
|
return -170
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if( docType.getId().equals(Const.gDTS_DKUKO) && doc.field[Const.gDDF_KONTAKTNUMMER] != null && !doc.field[Const.gDDF_KONTAKTNUMMER].equals("") && !doc.field[Const.gDDF_KONTAKTNUMMER].equals(oldDoc.field[Const.gDDF_KONTAKTNUMMER]) ) {
|
|
// 09.05.2017 Anpassung, da sich der Aufbau geändert hat
|
|
// Aufbau: <Präfix: OP, CM, PR>|<Zuordnung (KdNr, OppNr, ProjNr)>|<KuKo-ID>|<KuKo-Termin>|<KuKo-Bezeichnung>
|
|
lReturn = Functions.validateKuKoID( d3, doc, user, "NewVersion" )
|
|
if( lReturn == -170 ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT014049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT014001)
|
|
}
|
|
d3.log.error( "Bitte geben Sie eine gueltige Kundenkontakt-ID ein." )
|
|
return -170
|
|
}
|
|
}
|
|
|
|
|
|
//Maschinenprojekt: Wenn weder eine Auftrags- noch eine Opportunity-Nr. eingetragen wird, verhindere die Ablage
|
|
lReturn = Functions.validateOppProjNr( d3, doc )
|
|
if( lReturn.equals("WITHOUTPROJOPP") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT012049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT012001)
|
|
}
|
|
return -170
|
|
} else if( lReturn.equals("PROJOPP") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT013049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT013001)
|
|
}
|
|
return -170
|
|
}
|
|
|
|
// 30.08.2016 dkle: Aktivitäts-ID und Beschreibung ECR Dokumente und Unterakte ECR
|
|
if( docType.getId().equals(Const.gDTS_DMECR) && doc.field[Const.gDDF_AUFTRNR] != null ) {
|
|
int resultValidateActivity = Functions.validateActivity(d3, doc, "Update")
|
|
if(resultValidateActivity == 1) {
|
|
return -170
|
|
}
|
|
}
|
|
|
|
|
|
// ECR-Dokumente und Ergebnisdokument dürfen nicht in genehmigte ECRs importiert werden.
|
|
if( docType.getId().equals(Const.gDTS_DMECR) && doc.field[Const.gDDF_ERGEBNISDOK].equals("Ja") && doc.field[Const.gDDF_ARCDOCID] == null ) {
|
|
int resultvalidateErgebnisdokumente = Functions.validateErgebnisdokumenteECR(d3, doc, user);
|
|
if(resultvalidateErgebnisdokumente == -170) {
|
|
return -170
|
|
}
|
|
}
|
|
|
|
int returnvalueMM = Functions.validateMustermaterialNr(d3, doc, oldDoc, docType, "NewVersion")
|
|
if(returnvalueMM == -170) {
|
|
return -170;
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_DMDOK) && doc.field[Const.gDDF_FUNKTION] != null && !doc.field[Const.gDDF_FUNKTION].equals("") && ( !doc.field[Const.gDDF_FUNKTION].equals(oldDoc.field[Const.gDDF_FUNKTION] || !doc.field[Const.gDDF_NPN].equals(oldDoc.field[Const.gDDF_NPN]) ) ) ) {
|
|
lReturn = 0
|
|
// Split Attribut Funktion bei Technikdokumenten im Import
|
|
lReturn = Functions.splitFunction ( d3, doc, docType.getId() )
|
|
if( lReturn.equals("FEHLER") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte waehlen Sie eine gültige Funktion aus.")
|
|
lReturn = 0
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please choose a valid function.")
|
|
lReturn = 0
|
|
}
|
|
d3.log.error( "Bitte waehlen Sie eine gültige Funktion aus." )
|
|
return -170
|
|
} else if( lReturn.equals("FEHLERODATA") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Problem Funktionsaufruf: Bitte wenden Sie sich an Ihren Administrator.")
|
|
lReturn = 0
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Error on Call Function: Please contact your administrator.")
|
|
lReturn = 0
|
|
}
|
|
d3.log.error( "Problem Funktionsaufruf stringSplitFunction: Bitte wenden Sie sich an Ihren Administrator." )
|
|
return -170
|
|
} else if( lReturn.equals("FEHLERFUNKTION") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Problem Funktionsaufruf: Bitte wenden Sie sich an Ihren Administrator.")
|
|
lReturn = 0
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Error on Call Function: Please contact your administrator.")
|
|
lReturn = 0
|
|
}
|
|
d3.log.error( "Problem Funktionsaufruf stringSplitFunction: Bitte wenden Sie sich an Ihren Administrator." )
|
|
return -170
|
|
} else {
|
|
lReturn = 0
|
|
}
|
|
}
|
|
|
|
if( docType.getId().equals(Const.gDTS_DMDOK) && doc.field[Const.gDDF_MODUL] != null && !doc.field[Const.gDDF_MODUL].equals("") && (!doc.field[Const.gDDF_MODUL].equals(oldDoc.field[Const.gDDF_MODUL]) || !doc.field[Const.gDDF_FUNKTION].equals(oldDoc.field[Const.gDDF_FUNKTION])) ) {
|
|
// Split Attribut Modul bei Technikdokumenten im Import
|
|
lReturn = Functions.splitModule( d3, doc, docType.getId() )
|
|
if( lReturn.equals("FEHLER") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte waehlen Sie ein gültige Modulnummer aus.")
|
|
lReturn = 0
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please choose a valid module number.")
|
|
lReturn = 0
|
|
}
|
|
d3.log.error( "Bitte waehlen Sie eine gültige Modulnummer aus." )
|
|
return -170
|
|
} else if( lReturn.equals("FEHLERODATA") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Problem Funktionsaufruf: Bitte wenden Sie sich an Ihren Administrator.")
|
|
lReturn = 0
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Error on Call Function: Please contact your administrator.")
|
|
lReturn = 0
|
|
}
|
|
d3.log.error( "Problem Funktionsaufruf stringSplitFunction: Bitte wenden Sie sich an Ihren Administrator." )
|
|
return -170
|
|
} else if( lReturn.equals("FEHLERFUNKTION") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Problem Funktionsaufruf: Bitte wenden Sie sich an Ihren Administrator.")
|
|
lReturn = 0
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Error on Call Function: Please contact your administrator.")
|
|
lReturn = 0
|
|
}
|
|
d3.log.error( "Problem Funktionsaufruf stringSplitFunction: Bitte wenden Sie sich an Ihren Administrator." )
|
|
return -170
|
|
} else {
|
|
lReturn = 0
|
|
}
|
|
}
|
|
|
|
// Das Attribut "Akte" wird im Maschinenprojekt bis auf die Ausnahme ECR automatisch anhand der Dokumentgruppe und der Dokumentart (Anwendungsfall) ermittelt
|
|
// 25.07.2016/dkle: Anpassung auf die neuen Dokumentgruppen von ECR
|
|
if( ( docType.getId().equals(Const.gDTS_DMAUF) || docType.getId().equals(Const.gDTS_DMDOK) ||
|
|
docType.getId().equals(Const.gDTS_DMSPE) || docType.getId().equals(Const.gDTS_DPRST) ||
|
|
docType.getId().equals(Const.gDTS_DMECR) || docType.getId().equals(Const.gDTS_DLIMA) || docType.getId().equals(Const.gDTS_DKUMA) ) &&
|
|
( !doc.field[Const.gDDF_DOKGROUP].equals(Const.gDG_ECRChangeOrder) && !doc.field[Const.gDDF_DOKGROUP].equals(Const.gDG_Medien) && (doc.field[Const.gDDF_SUBJECT].equals("") || doc.field[Const.gDDF_SUBJECT] == null) ) ) {
|
|
|
|
def lDokGroup = doc.field[Const.gDDF_DOKGROUP]
|
|
def lProcess = doc.field[Const.gDDF_PROZESS]
|
|
|
|
if ( docType.getId().equals(Const.gDTS_DPRST) && !lProcess.equals("")) {
|
|
lAndClause = "and dok_dat_feld_${Const.gDDF_PROZESS} = '${lProcess}' "
|
|
} else {
|
|
lAndClause = ""
|
|
}
|
|
|
|
// 31.07.2017 Hinweis: Hier kann nur ein Wert zurückkommen, da es eine fachlich gepflegte administrative Akte ist.
|
|
def sqlStatement = "SELECT dok_dat_feld_${Const.gDDF_SUBJECT} as lSubject " +
|
|
"FROM firmen_spezifisch " +
|
|
"WHERE dok_dat_feld_${Const.gDDF_REGISTER} = '${lDokGroup}' " +
|
|
"AND dok_dat_feld_${Const.gDDF_ANWENDUNGSFALL} = '${docType.getId()}' " +
|
|
"AND kue_dokuart = '${Const.gDTS_AAFOL}' ${lAndClause} "
|
|
def sqlResult = d3.sql.executeAndGet(sqlStatement)
|
|
if(sqlResult != null && sqlResult.size() > 0) {
|
|
lSubject = sqlResult.getAt(0).get("lSubject")
|
|
}
|
|
|
|
if(lSubject.equals("Projektorganisation")) {
|
|
// Der Wert "Projektorganisation" darf nicht gesetzt werden, im Code wird bei dieser Bedingung das Feld immer geleert
|
|
} else {
|
|
doc.field[Const.gDDF_SUBJECT] = lSubject
|
|
}
|
|
}
|
|
|
|
//Maschinenprojekt Prototyp 4: Wenn beim Import die Dokumentgruppe Medien gewählt wurde, aber das Feld Akte leer ist, gib einen Fehler aus
|
|
if( ( docType.getId().equals(Const.gDTS_DMDOK) || docType.getId().equals(Const.gDTS_DMAUF) || docType.getId().equals(Const.gDTS_DMSPE) || docType.getId().equals(Const.gDTS_DPRST) || docType.getId().equals(Const.gDTS_DLIMA) || docType.getId().equals(Const.gDTS_DKUMA) )
|
|
&& doc.field[Const.gDDF_DOKGROUP].equals(Const.gDG_Medien) && ( doc.field[Const.gDDF_SUBJECT] == null || doc.field[Const.gDDF_SUBJECT].equals("") ) ) {
|
|
// dkle, 02.02.2016 additional infotext eingefügt
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Sie versuchen ein Dokument mit der Dokumentgruppe Medien zu aktualisieren, ohne eine Akte ausgewaehlt zu haben. Bitte korrigieren Sie Ihre Eingabe")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "You try to update an document as Medien without choosing a folder. Please correct your input.")
|
|
}
|
|
d3.log.error( "Sie versuchen ein Dokument mit der Dokumentgruppe Medien zu aktualisieren, ohne eine Akte ausgewaehlt zu haben. Bitte korrigieren Sie Ihre Eingabe" )
|
|
return -170
|
|
} else if ( docType.getId().equals(Const.gDTS_DPRST) && doc.field[Const.gDDF_SUBJECT].equals(Const.gAK_Projektorganisation) ) {
|
|
doc.field[Const.gDDF_SUBJECT] = ""
|
|
}
|
|
|
|
// Prüfung des ausgewählten Lieferanten bei der Ablage
|
|
if( !userName.equals("d3_async") && !userName.equals("hostimp") && ( docType.getId().equals(Const.gDTS_DLIKO) || docType.getId().equals(Const.gDTS_ALIKO) || docType.getId().equals(Const.gDTS_ALONT) || docType.getId().equals(Const.gDTS_DLIMA) ) ) {
|
|
lReturn = Functions.validateLiefName( d3, doc, "NewVersion" )
|
|
if( lReturn.equals("OK") ) {
|
|
// Es handelt sich um einen validen Wert
|
|
} else if( lReturn.equals("Fehler") ) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT016049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT016001)
|
|
}
|
|
d3.log.error( "Bitte geben Sie einen gültigen, eindeutigen Lieferanten an oder wählen Sie den Lieferanten aus der Auswahlliste." )
|
|
return -170
|
|
}
|
|
// Validierung der Lieferantennummer (nur bei gDTS_ALIKO) - OPG-2105 - NewVersionEntry10
|
|
lReturn = Functions.validateLiefNum( d3, doc, "Update")
|
|
if( lReturn.equals("OK") ) {
|
|
// Es handelt sich um einen validen Wert
|
|
} else if( lReturn.equals("Fehler") ) {
|
|
// dkle, 02.02.2016 additional info Text eingefügt
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT016049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT016001)
|
|
}
|
|
d3.log.error( "Bitte geben Sie einen gültigen, eindeutigen Lieferanten an oder wählen Sie den Lieferanten aus der Auswahlliste." )
|
|
return -170
|
|
}
|
|
// Überprüfung doppelter Einträge von Lieferanten
|
|
if( docType.getId().equals(Const.gDTS_ALIKO) ) {
|
|
lReturn = Functions.checkDuplikateLieferant( d3, "NewVersion", userName, doc.id() )
|
|
if( lReturn.equals("OK") ) {
|
|
// Do nothing
|
|
} else {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT017049)
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", Const.gADITXT017001)
|
|
}
|
|
d3.log.error( "Dieser Lieferant existiert bereits in dieser Opportunity, bzw. in diesem Projekt. Bitte nutzen Sie die existierende Akte." )
|
|
return -170
|
|
}
|
|
}
|
|
}
|
|
|
|
if( ( !doc.field[Const.gDDF_LNR].equals(oldDoc.field[Const.gDDF_LNR]) || !doc.field[Const.gDDF_LNAME].equals(oldDoc.field[Const.gDDF_LNAME]) ||
|
|
!doc.field[Const.gDDF_KONTAKTBESCH].equals(oldDoc.field[Const.gDDF_KONTAKTBESCH]) ||
|
|
!doc.field[Const.gDDF_LIEFAKTKAT].equals(oldDoc.field[Const.gDDF_LIEFAKTKAT]) ||
|
|
!doc.field[Const.gDDF_KONTAKTDATE].equals(oldDoc.field[Const.gDDF_KONTAKTDATE]) ) && docType.getId().equals(Const.gDTS_DLONT) ) {
|
|
lReturn = Functions.splitLieferantenkontaktbeschreibung(d3, doc, docType);
|
|
if(lReturn == -170) {
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// Wenn es sich um ein Ergebnisdokument handelt und ein Angebotsdokument ist, muss die übergeordnete Angebotsversion "in Arbeit" sein.
|
|
if( docType.getId().equals(Const.gDTS_DOPPD) && doc.field[Const.gDDF_ERGEBNISDOK].equals("Ja") && ( doc.field[Const.gDDF_ARCDOCID] == null || !doc.field[Const.gDDF_ARCDOCID].equals("") ) ) {
|
|
lReturn = Functions.validateErgebnisdokumenteAngebot(d3, doc, user);
|
|
if(lReturn == -170) {
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// phoer 20191024: Splitten der zusammengesetzten Strings SR-ID, Beschreibung
|
|
Functions.splitServSrId(d3, doc, docType);
|
|
int resultCheckSrId = Functions.checkServiceNr(d3, doc, SystemSpecificConst.gWeitereSRIDID);
|
|
if(resultCheckSrId != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "SR_ID in Zeile ${resultCheckSrId} ist doppelt eingetragen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "SR_ID in line ${resultCheckSrId} exists multiple")
|
|
}
|
|
return -170;
|
|
}
|
|
int resultValidateSrId = Functions.validateSrId(d3, doc);
|
|
if(resultValidateSrId != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte weitere SR_ID in Zeile ${resultValidateSrId} prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check further SR_ID in line ${resultValidateSrId} ")
|
|
}
|
|
return -170;
|
|
}
|
|
|
|
// phoer 20191024: Splitten der zusammengesetzten Strings SR-ID, Beschreibung
|
|
if( docType.getId().equals(Const.gDTS_DSEBE) || docType.getId().equals(Const.gDTS_ASEBE) ) {
|
|
Functions.splitServBelegnummer(d3, doc, docType);
|
|
int resultValidateBelegNr = Functions.validateBelegNr(d3, doc);
|
|
int resultCheckBelegNr = Functions.checkServiceNr(d3, doc, SystemSpecificConst.gWeitereBelegNrID);
|
|
if(resultCheckBelegNr != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Belegnummer in Zeile ${resultCheckBelegNr} ist doppelt eingetragen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Further actitivy in line ${resultCheckBelegNr} exists multiple")
|
|
}
|
|
return -170;
|
|
}
|
|
if(resultValidateBelegNr != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte weitere Belegnummer in Zeile ${resultValidateBelegNr} prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check further actitivy no in line ${resultValidateBelegNr} ")
|
|
}
|
|
return -170
|
|
}
|
|
if( doc.field[Const.gDDF_BELEGTYP] == null ) {
|
|
String belegNrTemp = doc.field[Const.gDDF_BELEGNUMMER];
|
|
String sqlStatement = "SELECT dok_dat_feld_${Const.gDDF_BELEGTYP} as belegTyp FROM firmen_spezifisch " +
|
|
"WHERE dok_dat_feld_${Const.gDDF_BELEGNUMMER} = '${belegNrTemp}' " +
|
|
"AND kue_dokuart = '${Const.gDTS_ASEBE}' ";
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
if(sqlResult != null && sqlResult.size() > 0) {
|
|
String lBelegTyp = sqlResult.getAt(0).get("belegTyp");
|
|
if( lBelegTyp != null && !lBelegTyp.equals("") && docType.getId().equals(Const.gDTS_DSEBE) ) {
|
|
doc.field[Const.gDDF_BELEGTYP] = lBelegTyp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// imue: Validierung doppelter Einträge für weitere Belegnummer Einkauf
|
|
if( docType.getId().equals(Const.gDTS_DEINK) ) {
|
|
int resultCheckBelegNr = Functions.checkPurchaseNr(d3, doc, SystemSpecificConst.gWeitereEinkaufBelegNrID);
|
|
if(resultCheckBelegNr != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Belegnummer in Zeile ${resultCheckBelegNr} ist doppelt eingetragen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Further actitivy in line ${resultCheckBelegNr} exists multiple")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// imue: Validierung der Belegart für den Service
|
|
if(Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gBelegNrID) && Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gBelegArtID)) {
|
|
Functions.validateBelegart(d3, doc);
|
|
}
|
|
|
|
// imue: Validierung der Belegart für den Einkauf
|
|
if(Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gEinkaufsBelegNrID)) {
|
|
Functions.validateBelegart(d3, doc);
|
|
}
|
|
|
|
// imue 26.08.2020 - Ergänzung für Equipment
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gWeitereEquipmentID) == true ) {
|
|
|
|
Functions.splitEquipment(d3, doc, docType, "NEWVERSION");
|
|
|
|
int resultValidateEquipment = Functions.validateEquipment(d3, doc, user, true);
|
|
if(resultValidateEquipment != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte Equipment Zeile ${resultValidateEquipment} prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check further equipment in line ${resultValidateEquipment} ")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gEquipmentID) == true ) {
|
|
|
|
Functions.splitEquipment(d3, doc, docType, "NEWVERSION");
|
|
|
|
int resultValidateEquipment = Functions.validateEquipment(d3, doc, user, false);
|
|
if(resultValidateEquipment != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte Equipment prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check equipment")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// imue 12.12.2022
|
|
if( Functions.checkIfRepoIDExistsInDocType(d3, doc.getType(), SystemSpecificConst.gEquipmentsID) == true ) {
|
|
Functions.splitEquipments(d3, doc, docType);
|
|
int resultValidateEquipment = Functions.validateEquipments(d3, doc, user);
|
|
if(resultValidateEquipment != 0) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte Equipments prüfen")
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please check equipments")
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
// 17.01.2023 - Neue Validierung der Materialnummer
|
|
if(doc.getType().getId().equals(Const.gDTS_DMATE) && doc.field[Const.gDDF_MATERIALNUMMER] != null) {
|
|
String returnValueMatNo = Functions.validateMaterialNum(d3, doc);
|
|
if(returnValueMatNo != null && returnValueMatNo.equals("ERROR")) {
|
|
if( d3.remote.getLanguage().equals("049") ) {
|
|
d3.hook.setProperty("additional_info_text", "Bitte geben Sie eine Material_Nr ein, zu der bereits eine Materialakte existiert.");
|
|
} else {
|
|
d3.hook.setProperty("additional_info_text", "Please enter a material no. for which a mertial file already exists.");
|
|
}
|
|
return -170;
|
|
}
|
|
}
|
|
|
|
d3.log.info("End proc NewVersionEntry10 - pDocId = ${doc.id()}, pUser = ${userName}, pDocTypeShort = ${docType.getId()}, pFileSource = ${fileSource}, pFileDest = ${fileDestination}")
|
|
return 0
|
|
}
|
|
|
|
@Entrypoint( entrypoint = "hook_new_version_entry_20" )
|
|
public int newVersionEntry20(D3Interface d3, Document doc, String fileSource, String fileDestination, User user, DocumentType docType) {
|
|
|
|
def InvalidData
|
|
if( ( docType.getId().equals(Const.gDTS_DMDOK) || docType.getId().equals(Const.gDTS_DMSPE) || docType.getId().equals(Const.gDTS_DPRST) || docType.getId().equals(Const.gDTS_DLIKO) ) && doc.field[Const.gDDF_AUFTRNR] != null && !doc.field[Const.gDDF_AUFTRNR].equals("") ) {
|
|
InvalidData = 0
|
|
InvalidData = Functions.validateNetzPSP(d3, doc)
|
|
if( InvalidData != 0 ) {
|
|
// Der additional_info_text wird in der Funktion "validateNetzPSP" gesetzt
|
|
return -170
|
|
}
|
|
}
|
|
|
|
// Angebotsdokumente: Angebot_Nr in den Zusatztitel einfügen, wenn die Angebot_Nr nicht "Neue" oder "9999" ist
|
|
if( docType.getId().equals(Const.gDTS_DOPPD) ) {
|
|
Functions.setAdditionalTitle(d3, doc);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
@Entrypoint( entrypoint = "hook_new_version_exit_30" )
|
|
public int newVersionExit30(D3Interface d3, Document doc, Integer importOk, Integer errorCode, User user, DocumentType docType, Document gOldDoc) {
|
|
//proc newVersionExit30(pDocId, pImportOk, pErrorNrApi, pUser, pDocTypeShort)
|
|
|
|
def userName = ""
|
|
if(user != null) {
|
|
userName = user.id();
|
|
}
|
|
|
|
d3.log.info("Start proc newVersionExit30 - pDocId = ${doc.id()}, pImportOk = ${importOk}, pErrorNrApi = ${errorCode}, pUser = ${userName}, pDocTypeShort = ${docType.getId()}")
|
|
|
|
def lReturn
|
|
def lRetCode
|
|
|
|
// ersetzt die Funktion drs_render() - nicht mehr benötigt 20210805 jleu
|
|
//Functions.renderDocument(d3, doc);
|
|
|
|
// 27.01.2020 imue - Funktion nicht notwendig, da die Vererbung auf die Dokuemnte bereits auf Basis der Akte über den Hook gemacht wird (siehe inheritOrgProjAttributes)
|
|
// if( docType.getId().equals(Const.gDTS_DPROO) ) {
|
|
// lRetCode = Functions.inheritDocAccess( d3, doc, "newVersion")
|
|
// }
|
|
|
|
//imue 09.08.2021 Dossier
|
|
if( docType.getId().equals(Const.gDTS_DOSSI) ) {
|
|
Functions.splitDossierValue(d3, doc, docType, "NEWVERSIONEXIT")
|
|
}
|
|
|
|
// 1: Einspielung der neuen Version erfolgreich / 0: Einspielung der neuen Version mit Fehler abgebrochen
|
|
if( importOk == 1 ) {
|
|
if ( Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gAktuellVersInternID) ) {
|
|
// https://jira.d-velop.de/browse/OPG-2024 Erstellung Hook zur Füllung des Attributs "interne Version" mit der Versionsinformation des d.3 Dokuments
|
|
// Technikdokumenten (DMDOK) - DDF 88 soll mit der aktuellen Versionsnummer befüllt werden
|
|
Functions.setInternalVersion( d3, doc.id() );
|
|
}
|
|
}
|
|
|
|
// phoer 20160823: Wenn beim Import einer neuen Version der Maschinenprojektdokumente das Zuordnung Kundenkontakt geändert wurde...
|
|
if( docType.getId().equals(Const.gDTS_DKOMM) || docType.getId().equals(Const.gDTS_DLIKO) || docType.getId().equals(Const.gDTS_DPRST) || docType.getId().equals(Const.gDTS_DMSPE) ||
|
|
docType.getId().equals(Const.gDTS_DMECR) || docType.getId().equals(Const.gDTS_DMDOK) || docType.getId().equals(Const.gDTS_DMAUF) ) {
|
|
|
|
def lMapCusAct = doc.field[Const.gDDF_MAPPCUSTACTION]
|
|
// d3.log.error("NewVersion DDF ${doc.field[Const.gDDF_MAPPCUSTACTION]}")
|
|
|
|
if ( lMapCusAct != null && !lMapCusAct.substring(0,7).equals("bereits") )
|
|
{
|
|
//...rufe die Funktion zum Kopieren des Dokuments auf, damit es in die Kundenkontaktakte importiert wird
|
|
Functions.copyCustAction(d3, doc, lMapCusAct)
|
|
}
|
|
}
|
|
|
|
|
|
//Wenn eine weitere Opportunity Nummer in das Mehrfachfeld eingetragen wird, schaue ob es diese Link Datei gibt
|
|
//ansonsten lege eine neue an
|
|
if ( docType.getId().equals(Const.gDTS_DOPPD) || docType.getId().equals(Const.gDTS_DLIKO) || docType.getId().equals(Const.gDTS_DKUKO) || docType.getId().equals(Const.gDTS_DKOMM)
|
|
|| docType.getId().equals(Const.gDTS_DMDOK) || docType.getId().equals(Const.gDTS_DMAUF) || docType.getId().equals(Const.gDTS_DMSPE) || docType.getId().equals(Const.gDTS_DVERD)
|
|
|| docType.getId().equals(Const.gDTS_DPRST) || docType.getId().equals(Const.gDTS_DSEBE) || docType.getId().equals(Const.gDTS_DSERE) || docType.getId().equals(Const.gDTS_DEQUI)
|
|
|| docType.getId().equals(Const.gDTS_DEINK)) {
|
|
Functions.checkForLinkFiles(d3, doc, docType, gOldDoc);
|
|
}
|
|
|
|
|
|
// Aufruf der Funktion manage_d3l_Supp_Custo, wenn weitere Kunden_Nr oder weitere Lieferanten_Nr bei Kundendokumenten oder Lieferantendokumenten hinzugefügt oder entfernt werden
|
|
if( docType.getId().equals(Const.gDTS_DKUMA) || docType.getId().equals(Const.gDTS_DLIMA) ) {
|
|
// gDDF_WEITLIEFNR - gDDF_WEITKDNR
|
|
def lFileExt = doc.getFileExtension().toUpperCase()
|
|
if( !lFileExt.equals("D3L") ) {
|
|
// d3.log.error( "Dokumentart: " + docType.getId() + " DokuID: " + doc.id() )
|
|
// Variablen setzen je nach Dokumentart
|
|
// Welches DDF ist zu befüllen?
|
|
// Welche Ziel-Dokumentart wird benötigt und muss abgefragt werden?
|
|
def lDDFToFill
|
|
def lScenario
|
|
def lBlock
|
|
if( docType.getId().equals(Const.gDTS_DKUMA) ) {
|
|
lDDFToFill = Const.gDDF_WEITKDNR
|
|
lScenario = "CustomerNumber"
|
|
} else if( docType.getId().equals(Const.gDTS_DLIMA) ) {
|
|
lDDFToFill = Const.gDDF_WEITLIEFNR
|
|
lScenario = "SupplierNumber"
|
|
}
|
|
|
|
for(int i=1; i <= Integer.valueOf(d3.config.value("CUR_60ER_FIELD_NR")); i++) {
|
|
if( doc.field[lDDFToFill][i] != null || !doc.field[lDDFToFill][i].equals(gOldDoc.field[lDDFToFill][i]) ) {
|
|
if( gOldDoc.field[lDDFToFill][i] != null && doc.field[lDDFToFill][i] != null && !doc.field[lDDFToFill][i].equals(gOldDoc.field[lDDFToFill][i]) ) {
|
|
// d3.log.error( "Start manage_d3l_Supp_Custo with: BLOCK " + lOldNumber[i] )
|
|
lBlock = "BLOCK"
|
|
Functions.createD3lForSuppCusto( d3, lBlock, gOldDoc.field[lDDFToFill][i], lScenario, doc.id() )
|
|
// d3.log.error( "Start manage_d3l_Supp_Custo with: CREATE/UNBLOCK " + lNewNumber[i] )
|
|
lBlock = "CREATE/UNBLOCK"
|
|
Functions.createD3lForSuppCusto( d3, lBlock, doc.field[lDDFToFill][i], lScenario, doc.id() )
|
|
} else if( gOldDoc.field[lDDFToFill][i] != null && doc.field[lDDFToFill][i] == null && !doc.field[lDDFToFill][i].equals(gOldDoc.field[lDDFToFill][i]) ) {
|
|
// d3.log.error( "Start manage_d3l_Supp_Custo with: BLOCK " + lOldNumber[i] )
|
|
lBlock = "BLOCK"
|
|
Functions.createD3lForSuppCusto( d3, lBlock, gOldDoc.field[lDDFToFill][i], lScenario, doc.id() )
|
|
} else if( doc.field[lDDFToFill][i] != null && !doc.field[lDDFToFill][i].equals(gOldDoc.field[lDDFToFill][i]) ) {
|
|
// d3.log.error( "Start manage_d3l_Supp_Custo with: CREATE/UNBLOCK " + lNewNumber[i] )
|
|
lBlock = "CREATE/UNBLOCK"
|
|
Functions.createD3lForSuppCusto( d3, lBlock, doc.field[lDDFToFill][i], lScenario, doc.id() )
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// globales Dokumetn Object null setzen
|
|
gOldDoc = null;
|
|
|
|
d3.log.info("Ende proc newVersionExit30 - pDocId = ${doc.id()}, pImportOk = ${importOk}, pErrorNrApi = ${errorCode}, pUser = ${userName}, pDocTypeShort = ${docType.getId()}")
|
|
return 0;
|
|
}
|
|
|
|
|
|
/*
|
|
* Dokumente freigeben
|
|
* + hook_release_entry_10 (nicht in Nutzung)
|
|
* + hook_release_exit_10 (aktiv)
|
|
*/
|
|
|
|
@Entrypoint( entrypoint = "hook_release_exit_10" )
|
|
public int releaseExit10(D3Interface d3, Document doc, User user, Integer errorCode, DocumentType docType, String unblock) {
|
|
|
|
def userName = ""
|
|
if(user != null) {
|
|
userName = user.id();
|
|
}
|
|
def lReturn
|
|
|
|
d3.log.info( "releaseExit10 Start ( ${doc.id()}, ${userName}, ${errorCode}, ${doc.getType().getId()}, ${unblock} )" )
|
|
|
|
/*
|
|
* Ausführungsbeschreibung:
|
|
* Wenn unblock gleich "1" (= das Dokument wird entsperrt), sollen auch alle zugehörigen D3L Dateien entsperrt werden
|
|
*/
|
|
if(unblock.equals("1")) {
|
|
def sqlStatement = "SELECT f.doku_id as dokuId " +
|
|
"FROM firmen_spezifisch as f, phys_datei as p " +
|
|
"WHERE f.kue_dokuart = '${doc.getType().getId()}' " +
|
|
"AND ( p.text LIKE '%${doc.id()}%' OR p.text LIKE '%${doc.id()}' OR p.text LIKE '${doc.id()}%' ) " +
|
|
"AND ( p.datei_erw = 'D3L' OR p.datei_erw = 'd3l' ) " +
|
|
"AND f.doku_id = p.doku_id "
|
|
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
|
|
d3.log.info( "releaseExit10 - Es wurden ${sqlResult.size()} Kinder gefunden." )
|
|
|
|
// Kenndaten des Kindes holen
|
|
if(sqlResult.size() > 0) {
|
|
for (GroovyRowResult grr : sqlResult) {
|
|
|
|
//d3.log.error( "releaseExit10 - Überprüfung d3l DokuId: ${grr.get("dokuId")} " )
|
|
Document docTemp = d3.archive.getDocument(grr.get("dokuId"))
|
|
|
|
if( (docTemp.getText(3).equals(doc.id())) || docTemp.getText(4).equals(doc.id()) ) {
|
|
|
|
// getReleaseVersionStatus() -> g = gesperrt, f = freigegeben
|
|
if( (docTemp.getStatus().toString().equals("DOC_STAT_RELEASE")) && (docTemp.getReleaseVersionStatus().equals("g")) ) {
|
|
|
|
// aktuell Bug enthalten - warte auf Lösung https://jira.d-velop.de/browse/DSR-8616
|
|
// def lReturnNew = docTemp.block(false, "d3groovy")
|
|
|
|
// Workaround:
|
|
lReturn = d3.call.document_block(false, "d3groovy", docTemp.id())
|
|
|
|
d3.log.info("releaseExit10 - Dokument ${grr.get("dokuId")} nicht mehr geblockt")
|
|
|
|
if (lReturn != 0) {
|
|
d3.log.error("Das Dokument ${docTemp.id()} konnte nicht Entsperrt werden! Errorcode = ${lReturn}")
|
|
} else {
|
|
d3.log.error( "Das Dokument kann nicht entsperrt werden. Status: ${docTemp.getStatus().toString()} Kennzeichen: ${docTemp.getReleaseVersionStatus()} g=gesperrt/f=freigegeben" )
|
|
}
|
|
|
|
} else {
|
|
d3.log.error( "Das Dokument kann nicht entsperrt werden, Vater DokumentID nicht im Bemerkungsfeld gefunden. Bemerkung 3: ${docTemp.getText(3)} Bemerkung 4: ${docTemp.getText(4)}" )
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
} else {
|
|
d3.log.info( "releaseExit10 - Die SQL Abfrage zur Ermittlung der Vaterdokumente ergab keine Treffer." )
|
|
}
|
|
|
|
/*
|
|
* Ausführungsbeschreibung:
|
|
* Wenn eine Freigabeversion erzeugt wird, muss die interne Version hochgeezählt werden
|
|
*/
|
|
if ( Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gAktuellVersInternID) ) {
|
|
// https://jira.d-velop.de/browse/OPG-2024 Erstellung Hook zur Füllung des Attributs "interne Version" mit der Versionsinformation des d.3 Dokuments
|
|
Functions.setInternalVersion( d3, doc.id() )
|
|
}
|
|
|
|
d3.log.info( "releaseExit10 Stop ( ${doc.id()}, ${userName}, ${errorCode}, ${doc.getType().getId()}, ${unblock} )" )
|
|
|
|
return 0
|
|
}
|
|
|
|
|
|
/*
|
|
* Sperren eines Dokumentes
|
|
* + hook_block_entry_10 (nicht in Nutzung)
|
|
* + hook_block_exit_10 (aktiv)
|
|
*/
|
|
|
|
@Entrypoint( entrypoint = "hook_block_entry_10" )
|
|
public int blockEntry10( D3Interface d3, Document doc, User user ) {
|
|
|
|
def userName = ""
|
|
if(user != null) {
|
|
userName = user.id()
|
|
}
|
|
|
|
// d3.log.error( "blockExit10 - Start blockExit10( ${doc.id()}, ${userName} )" )
|
|
def lReturn
|
|
|
|
/*
|
|
* Ausführungsbeschreibung:
|
|
* Sperrung zugehöriger d3l Dateien, wenn das Originaldokument gesperrt wird und sich die d3l Datei im Status "Freigabe" befindet und bisher ungesperrt ist
|
|
*/
|
|
def sqlStatement = "SELECT f.doku_id as dokuId " +
|
|
"FROM firmen_spezifisch as f, phys_datei as p " +
|
|
"WHERE f.kue_dokuart = '${doc.getType().getId()}' " +
|
|
"AND ( p.text LIKE '%${doc.id()}%' OR p.text LIKE '%${doc.id()}' OR p.text LIKE '${doc.id()}%' ) " +
|
|
"AND ( p.datei_erw = 'D3L' OR p.datei_erw = 'd3l' ) " +
|
|
"AND f.doku_id = p.doku_id "
|
|
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
|
|
d3.log.info( "blockExit10 - Es wurden ${sqlResult.size()} Kinder gefunden." )
|
|
|
|
// Kenndaten des Kindes holen
|
|
if(sqlResult.size() > 0) {
|
|
for (GroovyRowResult grr : sqlResult) {
|
|
|
|
//d3.log.info( "blockExit10 - Überprüfung d3l DokuId: ${grr.get("dokuId")} " )
|
|
|
|
Document docTemp = d3.archive.getDocument(grr.get("dokuId"))
|
|
|
|
if( (docTemp.getText(3).equals(doc.id())) || docTemp.getText(4).equals(doc.id()) ) {
|
|
|
|
if( (docTemp.getStatus().toString().equals("DOC_STAT_RELEASE")) && (docTemp.getReleaseVersionStatus().equals("f")) ) {
|
|
|
|
// aktuell Bug enthalten - warte auf Lösung https://jira.d-velop.de/browse/DSR-8616
|
|
def lReturnNew = docTemp.block(true, "d3groovy")
|
|
|
|
// Workaround:
|
|
// lReturn = d3.call.document_block(true, "d3groovy", docTemp.id())
|
|
|
|
d3.log.info("blockExit10 - Dokument ${grr.get("dokuId")} geblockt")
|
|
|
|
if (lReturn !=0) {
|
|
d3.log.error("blockExit10 - Das Dokument ${docTemp.id()} konnte nicht auf Freigabe / Gesperrt gesetzt werden! Errorcode = ${lReturn}")
|
|
}
|
|
|
|
} else {
|
|
d3.log.error( "blockExit10 - Das Dokument kann nicht gesperrt werden. Status: ${docTemp.getStatus().toString()} Kennzeichen: ${docTemp.getReleaseVersionStatus()} g=gesperrt/f=freigegeben" )
|
|
}
|
|
|
|
} else {
|
|
d3.log.error( "blockExit10 - Das Dokument kann nicht gesperrt werden, Vater DokumentID nicht im Bemerkungsfeld gefunden. Bemerkung 3: ${docTemp.getText(3)} Bemerkung 4: ${docTemp.getText(4)}" )
|
|
}
|
|
}
|
|
} else {
|
|
d3.log.info( "blockExit10 - Die SQL Abfrage zur Ermittlung der Vaterdokumente ergab keine Treffer." )
|
|
}
|
|
|
|
return 0
|
|
}
|
|
|
|
|
|
/*
|
|
* Löschen eines Dokumentes
|
|
* + hook_delete_entry_10 (nicht in Nutzung)
|
|
* + hook_delete_exit_10 (aktiv)
|
|
*/
|
|
|
|
@Entrypoint( entrypoint = "hook_delete_exit_10" )
|
|
public int deleteExit10(D3Interface d3, Document doc, User user, Integer errorCode, DocumentType docType) {
|
|
|
|
def userName = ""
|
|
if(user != null) {
|
|
userName = user.id()
|
|
}
|
|
|
|
d3.log.info( "hookDeleteExit10 - START ( " + doc.id() + ", " + userName + ", " + errorCode + ", " + docType.getId() + ")" )
|
|
|
|
/*
|
|
* Ausführungsbeschreibung:
|
|
* Löschen aller D3l Dateien, wenn das Hauptdokument gelöscht wird und keine Version mehr vorhanden ist
|
|
*/
|
|
if( (errorCode == 0) && (!userName.equals("")) ) {
|
|
|
|
def lReturn
|
|
|
|
// Anmerkung durch Frau Luk: D3l-Datien werden auch gelöscht, wenn eine Bearbeitungversion gelöscht wird - 07.05.2019 imue
|
|
def sqlStatementBea = "SELECT * " +
|
|
"FROM phys_datei as p " +
|
|
"WHERE p.doku_id = '${doc.id()}' "
|
|
|
|
List<GroovyRowResult> sqlResultBea = d3.sql.executeAndGet(sqlStatementBea);
|
|
|
|
d3.log.info( "hookDeleteExit10 - Es wurden ${sqlResultBea.size()} Versionen für Dokument ${doc.id()} gefunden" )
|
|
|
|
if(sqlResultBea.size() == 0) {
|
|
|
|
// SELECT auf text[3] und text[4]
|
|
// Finde alle zugehörigen d3l Dateien
|
|
def sqlStatement = "SELECT f.doku_id as dokuId " +
|
|
"FROM firmen_spezifisch as f, phys_datei as p " +
|
|
"WHERE ( p.text LIKE '%${doc.id()}%' OR p.text LIKE '%${doc.id()}' OR p.text LIKE '${doc.id()}%' ) " +
|
|
"AND ( p.datei_erw = 'D3L' OR p.datei_erw = 'd3l' ) " +
|
|
"AND f.doku_id = p.doku_id "
|
|
|
|
List<GroovyRowResult> sqlResult = d3.sql.executeAndGet(sqlStatement);
|
|
|
|
for (GroovyRowResult grr : sqlResult) {
|
|
|
|
d3.log.info( "hookDeleteExit10 - Löschung D3L: " + grr.get("dokuId") )
|
|
|
|
lReturn = d3.call.document_delete("Löschung Verweisdatei, aufgrund Löschung des Originals", true, true, grr.get("dokuId"), "d3groovy", false )
|
|
if( lReturn == 0 ) {
|
|
// Do nothing!
|
|
d3.log.info( "hookDeleteExit10 - D3L Datei " + grr.get("dokuId") + " erfolgreich gelöscht" )
|
|
} else {
|
|
d3.log.error( "hookDeleteExit10 - D3L Datei konnte nicht gelöscht werden " + grr.get("dokuId") + " Fehler: " + lReturn + "" )
|
|
}
|
|
|
|
}
|
|
} else {
|
|
d3.log.info( "hookDeleteExit10 - Es existieren noch weitere Versionen für Dokument ${doc.id()}, sodass die zugehörigen D3L Dateien nicht gelöscht werden!" )
|
|
}
|
|
|
|
|
|
/*
|
|
* Ausführungsbeschreibung:
|
|
* Wenn eine Bearbeitungsversion gelöscht wird, muss die interne Version runtergezählt werden
|
|
*/
|
|
if ( Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gAktuellVersInternID) ) {
|
|
|
|
// https://jira.d-velop.de/browse/OPG-2024 Erstellung Hook zur Füllung des Attributs "interne Version" mit der Versionsinformation des d.3 Dokuments
|
|
// Technikdokumenten (DMDOK) - DDF 88 soll mit der aktuellen Versionsnummer befüllt werden
|
|
|
|
// Prüfung ob docId überhaupt noch exisitert
|
|
def sqlStatementVers = "SELECT f.doku_id as d3lExistence " +
|
|
"FROM firmen_spezifisch as f " +
|
|
" WHERE f.doku_id = '${doc.id()}' "
|
|
List<GroovyRowResult> sqlResultVers = d3.getSql().executeAndGet(sqlStatementVers)
|
|
def d3lExistenceCount = sqlResultVers.size()
|
|
|
|
// https://jira.d-velop.de/browse/OPG-2024 Erstellung Hook zur Füllung des Attributs "interne Version" mit der Versionsinformation des d.3 Dokuments
|
|
// Technikdokumenten (DMDOK) - DDF 88 soll mit der aktuellen Versionsnummer befüllt werden
|
|
if(d3lExistenceCount > 0) {
|
|
d3.log.info( "hookDeleteExit10 - setInternalVersion: " + doc.id() )
|
|
Functions.setInternalVersion( d3, doc.id() )
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
d3.log.info( "hookDeleteExit10 - ENDE deleteExit10( " + doc.id() + ", " + errorCode + ", " + docType.getId() + ")" )
|
|
|
|
return 0
|
|
}
|
|
|
|
|
|
/*
|
|
* Statustranser
|
|
* + hook_transfer_entry_30 (nicht in Nutzung)
|
|
* + hook_transfer_exit_30 (aktiv)
|
|
*/
|
|
|
|
@Entrypoint( entrypoint = "hook_transfer_exit_30" )
|
|
public int transferExit30(D3Interface d3, User user, Document doc, Integer fileId, String sourceStatus, String destStatus, UserOrUserGroup destEditor, Integer errorCode) {
|
|
|
|
DocumentType docType = doc.getType()
|
|
|
|
def userName = ""
|
|
if(user != null) {
|
|
userName = user.id();
|
|
}
|
|
|
|
d3.log.info("hookTransferExit30 - START " + userName + ", " + doc.id() + ")")
|
|
|
|
if ( Functions.checkIfRepoIDExistsInDocType(d3, docType, SystemSpecificConst.gAktuellVersInternID) ) {
|
|
|
|
// https://jira.d-velop.de/browse/OPG-2024 Erstellung Hook zur Füllung des Attributs "interne Version" mit der Versionsinformation des d.3 Dokuments
|
|
// Technikdokumenten (DMDOK) - DDF 88 soll mit der aktuellen Versionsnummer befüllt werden
|
|
|
|
// jleu 02.04.2019 auskommentiert, da sonst ein Versionieren über d.3one nicht möglich ist
|
|
// Functions.setInternalVersion( d3, doc.id() )
|
|
|
|
}
|
|
|
|
d3.log.info("hookTransferExit30 - ENDE " + userName + ", " + doc.id() + ")")
|
|
|
|
return 0
|
|
}
|
|
|
|
|
|
} |