1 APPS.Halux.Planning.impl.AutoBatchMaker 1 1 %Integer 1 1 TECH.Comparator.IComparator %ListOfObjects ELEMENTTYPE="APPS.Halux.Planning.dto.MaatwerkBatch" 0) { Set BatchService = ##class(APPS.Halux.common.impl.BatchService).%New() #dim Comparator As TECH.Comparator.IComparator = ..GeefLadeComparator() Do ##class(TECH.Algo.Sort.MergeSort).Sort(..Toeleveringen, Comparator) #dim AantalProductenInBatch As %Integer = 0 #dim LaatsteDueOut As %String = "" #dim LaatsteProductieGroep As %String = "" Set Iterator = ##class(TECH.ListIterator).%New(..Toeleveringen) While (Iterator.HasNext()) { #dim Toelevering As DOM.AKP.Toelevering = Iterator.Next() #dim ProductieGroepen As list of APPS.Halux.common.enu.ProductieGroep = ..BatchService.GeefProductieGroepen(Toelevering) #dim ProductieGroep As APPS.Halux.common.enu.ProductieGroep = ProductieGroepen.GetAt(1) If (AantalProductenInBatch > ..GeefStreefAantalVoorBatch()) || (LaatsteDueOut '= Toelevering.GeefDueOutTime()) || (LaatsteProductieGroep '= ProductieGroep) { #dim Batch As APPS.Halux.common.Batch = ##class(APPS.Halux.common.BatchFactory).MaakNieuweLegeBatch(..Datum, ..GeefCategorie()) Do AangemaakteBatches.Insert(Batch) Set AantalProductenInBatch = 0 Do Batch.ZetLijn(..BatchService.GeefInitieleLijnVoorToelevering(Toelevering)) } Do Batch.VoegToeToelevering(Toelevering) Set AantalProductenInBatch = AantalProductenInBatch + Toelevering.GeefAantalProducten() Set LaatsteDueOut = Toelevering.GeefDueOutTime() Set LaatsteProductieGroep = ProductieGroep } } Set BatchIterator = ##class(TECH.ListIterator).%New(AangemaakteBatches) While (BatchIterator.HasNext()) { Set Batch = BatchIterator.Next() Do Batch.ZetStatus(##class(APPS.Halux.common.enu.BatchStatus).Auto()) Do Batch.Save() Do MaatwerkBatches.Insert(..BatchService.GeefMaatwerkBatch(Batch)) } Quit MaatwerkBatches ]]>