import at.clockwork.calculation.CalculationData import at.clockwork.calculation.data.* import at.clockwork.calculation.GeneralCalculationData import at.clockwork.time.service.DateTimeService import at.clockwork.calculation.RestartCalculationException import at.clockwork.time.enumeration.* import at.clockwork.time.domain.* class Calc99903Service { static transactional = false def run(CalculationData calculationData, GeneralCalculationData generalCalculationData, boolean saving, Map parameters) throws RestartCalculationException { return //println "_cd.firstAcceptedBooking: ${_cd.firstAcceptedBooking.date.format("HH:mm:ss")}" //println "_cd.firstBooking: ${_cd.firstBooking.getTime().format("HH:mm:ss")}" //println "_cd.lastAcceptedBooking: ${_cd.lastAcceptedBooking.date.format("HH:mm:ss")}" //println "_cd.lastBooking: ${_cd.lastBooking.getTime().format("HH:mm:ss")}" if ( !_cd.firstAcceptedBooking ) return if ( !_cd.firstBooking ) return if ( !_cd.lastAcceptedBooking ) return if ( !_cd.lastBooking ) return double comingMinutes = 0 double goingMinutes = 0 List bookingList = _cd.getTimeBookings( _cd.firstAcceptedBooking.date, _cd.lastAcceptedBooking.date ) int counter = 0 for ( itBooking in bookingList ) { //println "$itBooking --> ${itBooking?.terminal?.number}" if ( counter == 0 || counter == bookingList.size()-1 ) { switch( itBooking?.terminal?.number ) { case "111": case "124": if ( itBooking.bookingType == BookingType.COMING ) comingMinutes = 10 else goingMinutes = 10 break case "112": if ( itBooking.bookingType == BookingType.COMING ) comingMinutes = 20 else goingMinutes = 20 break } } counter ++ } // println "comingMinutes: $comingMinutes" // println "goingMinutes: $goingMinutes" _addDV( "27", comingMinutes + goingMinutes ) if ( _yV[903] == 0 ) { // 1. Durchlauf // moegliche zu frueh- und zu spaet-Regelung deaktivieren if ( comingMinutes > 0 ) { _cd.yCalValues[ 1 ] = _dts.getCalendar( _cd.firstBooking, -comingMinutes ) _cd.yCalValues[ 2 ] = _cd.firstBooking _cd.addToTooSoonExceptions( new StartEndCalendarPair( _cd.yCalValues[ 1 ], _cd.yCalValues[ 2 ] ) ) } if ( goingMinutes > 0 ) { _cd.yCalValues[ 3 ] = _cd.lastBooking _cd.yCalValues[ 4 ] = _dts.getCalendar( _cd.lastBooking, goingMinutes ) _cd.addToTooLateExceptions( new StartEndCalendarPair( _cd.yCalValues[ 3 ], _cd.yCalValues[ 4 ] ) ) } _yV[903] ++ if ( comingMinutes > 0 || goingMinutes > 0 ) throw new RestartCalculationException(restartCalculation:new RestartCalculation(restart:true)) } else if ( _yV[903] == 1 ) { // 2. Durchlauf // pruefen, wieviele Minuten durch das Deaktivieren der zu frueh- und zu spaet-Regelungen "freigegeben" wurden double part1 = 0 if ( comingMinutes > 0 ) part1 = _cd.getTime( _cd.yCalValues[ 1 ], _cd.yCalValues[ 2 ] ) double part2 = 0 if ( goingMinutes > 0 ) part2 = _cd.getTime( _cd.yCalValues[ 3 ], _cd.yCalValues[ 4 ] ) // die restlichen Minuten durch zusaetliche Buchungen "freigeben" if ( comingMinutes > part1 ) { _cd.addFictitiousBooking( _cd.firstBooking, (Absence) null, BookingType.GOING, true, false ) _cd.addFictitiousBooking( _cd.yCalValues[ 1 ], (Absence) null, BookingType.COMING, true, false ) } if ( goingMinutes > part2 ) { _cd.addFictitiousBooking( _cd.lastBooking, (Absence) null, BookingType.COMING, false, true ) _cd.addFictitiousBooking( _cd.yCalValues[ 4 ], (Absence) null, BookingType.GOING, false, true ) } _yV[903] ++ if ( comingMinutes > 0 || goingMinutes > 0 ) throw new RestartCalculationException(restartCalculation:new RestartCalculation(restart:true)) } return } } /* ::1:: // FEHLER: die abgezogene Mittagspause wird um 10 Minuten verschoben (durch zu-füh-Regelung) IF FUNC DO ; ::1:: IF FOXPRO_m.AktDatum < FOXPRO_{1.11.2021} FUNC RETURN_ DO ; ::2:: IF FUNC YVAR_27 DO =_ZA_27 ; ::3:: IF YVAR_3 > NW_0 FUNC RETURN_ DO ; ::4:: IF FUNC NW_1 DO =_YVAR_3 ; ::5:: IF FUNC ZP_ErstesKommen - VAR_ZuFrüh DO =_ZP_141 ; ::6:: IF FUNC ZP_LetztesGehen + VAR_ZuSpät DO =_ZP_142 ; ::7:: IF ZP_141 = ZP_142 FUNC RETURN_ DO ; ::8:: IF FUNC NW_0 DO =_YVAR_27 ; ::9:: IF FUNC ZP_0:00 DO =_ZP_143 =_ZP_144 ; ::10:: IF FUNC ZP_0:00 DO =_ZP_145 =_ZP_146 ; ::11:: IF FUNC SCRIPT_21 DO ; ::9:: IF FUNC ZP_143 + ZP_144 DO ; ::10:: IF FUNC ZP_145 + ZP_146 DO ; ::12:: IF YVAR_27 = NW_0 FUNC RETURN_ DO ; ::13:: IF FUNC VAR_ZuFrüh DO +_ZP_143 ; ::14:: IF FUNC FKT_VZFrueh1/ZP143 DO ; ::15:: IF FUNC VAR_ZuSpät DO +_ZP_146 ; ::16:: IF FUNC FKT_VZSpaet1/ZP146 DO ; ::17:: IF FUNC FKT_ERSTE-BUCHUNG-VON/ZP143 DO ; ::18:: IF FUNC FKT_ERSTE-BUCHUNG-BIS/ZP144 DO ; ::19:: IF FUNC FKT_LETZTE-BUCHUNG-VON/ZP145 DO ; ::20:: IF FUNC FKT_LETZTE-BUCHUNG-BIS/ZP146 DO ; ::21:: IF FUNC FKT_NEUBERECHNUNG DO ; SCRIPT 21 ========= 0011 lvorher = 0 0012 lnachher = 0 0021 lDatumVorher = m.AktDatum 0022 lZeitVorher = m.Zeitpunkt[141]-1440 0023 lZeitVorher < 0 lDatumVorher = lDatumVorher - 1 0024 lZeitVorher < 0 lZeitVorher = lZeitVorher + 1440 0025 lZeitVorher >= 1440 lDatumVorher = lDatumVorher + 1 0026 lZeitVorher >= 1440 lZeitVorher = lZeitVorher - 1440 0031 lDatumNachher = m.AktDatum 0032 lZeitNachher = m.Zeitpunkt[142]-1440 0033 lZeitNachher < 0 lDatumNachher = lDatumNachher - 1 0034 lZeitNachher < 0 lZeitNachher = lZeitNachher + 1440 0035 lZeitNachher >= 1440 lDatumNachher = lDatumNachher + 1 0036 lZeitNachher >= 1440 lZeitNachher = lZeitNachher - 1440 0101 NOT SEEK(m.aktarbeitnehm + dtos(lDatumVorher) + str(lZeitVorher, 5), "Zeitbuch", "ZBAll") :GOTO 0201 0111 val(zeitbuch.terminal) = 111 lvorher = 10 0112 val(zeitbuch.terminal) = 112 lvorher = 20 0113 val(zeitbuch.terminal) = 124 lvorher = 10 0201 NOT SEEK(m.aktarbeitnehm + dtos(lDatumNachher) + str(lZeitNachher, 5), "Zeitbuch", "ZBAll") :GOTO 999 0211 val(zeitbuch.terminal) = 111 lnachher = 10 0212 val(zeitbuch.terminal) = 112 lnachher = 20 0213 val(zeitbuch.terminal) = 124 lnachher = 10 0311 m.Zeitpunkt[143] = m.Zeitpunkt[141] - lvorher 0312 m.Zeitpunkt[144] = m.Zeitpunkt[141] 0313 m.Zeitpunkt[145] = m.Zeitpunkt[142] 0314 m.Zeitpunkt[146] = m.Zeitpunkt[142] + lnachher 0315 m.yvar[27] = lvorher + lnachher 9999 // */