Quintiq file version 2.0 
 | 
#parent: #root 
 | 
StaticMethod IterativeGeneration ( 
 | 
  GlobalOTDTable globalOTDTable, 
 | 
  ProductInStockingPoint_MP pisp, 
 | 
  Number numberOfLayers, 
 | 
  NewSupply finaleNewSupply, 
 | 
  Real finaleDependentDemand, 
 | 
  Date targetDate 
 | 
) 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    traverse ( pisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispippl, pispippl.Start().Date() = targetDate ) { 
 | 
      traverse ( pispippl, NewSupply, ns, ns.Quantity() > 0 ) { 
 | 
    //    info( "生成的产品:", pisp.ProductID(), "    产品在库存点:", pisp.Name(), "    层数:", numberOfLayers, "    总生产量:", ns.Quantity(), "    最终依赖物料数量:", finaleDependentDemand ); 
 | 
        if ( finaleDependentDemand < 0 ) { 
 | 
          finaleDependentDemand := ns.Quantity(); 
 | 
        } 
 | 
        if ( isnull( finaleNewSupply ) ) { 
 | 
          finaleNewSupply := ns; 
 | 
        } 
 | 
        if ( guard( ns.PeriodTask_MP().astype( PeriodTaskOperation ).DependentDemand( relsize ) > 0, false ) ) { 
 | 
          numberOfLayers++; 
 | 
          traverse ( ns, PeriodTask_MP.astype( PeriodTaskOperation ).DependentDemand, dd ) { 
 | 
            oo := ns.ProcessOutput().astype( OperationOutput ); 
 | 
            oi := dd.ProcessInput().astype( OperationInput ); 
 | 
            finaleDependentDemand := finaleDependentDemand * oo.Quantity() * oi.Quantity(); 
 | 
    //        info( "依赖需求产品ID:", dd.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP().ProductID(), "    依赖数量:", dd.Quantity(), "    当前周期任务Key:", dd.PeriodTask_MP().astype( PeriodTaskOperation ).Key() ); 
 | 
            CapacityAllocationResults::IterativeGeneration( globalOTDTable, dd.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP(), numberOfLayers, finaleNewSupply, finaleDependentDemand, targetDate ); 
 | 
          } 
 | 
    //      info( "----------------------------------------------------" ); 
 | 
        } else { 
 | 
    //      info( "无依赖需求,需要生成产能分配结果。。。" ); 
 | 
    //      info( "======" ); 
 | 
          pispPanel := ns.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP(); 
 | 
          pispModule := finaleNewSupply.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP(); 
 | 
          globalOTDTable.CapacityAllocationResults( relnew, 
 | 
                                                    PanelBase             := pispPanel.StockingPointID(), 
 | 
                                                    PanelMaterialCode     := pispPanel.ProductID(), 
 | 
                                                    NumberOfPanels        := finaleDependentDemand, 
 | 
                                                    PanelMeasurementUnit  := pispPanel.UnitOfMeasure_MP().Name(), 
 | 
                                                    ModuleMaterialCode    := pispModule.ProductID(), 
 | 
                                                    NumberOfModules       := finaleNewSupply.Quantity(), 
 | 
                                                    ModuleMeasurementUnit := pispModule.UnitOfMeasure_MP().Name(), 
 | 
                                                    ModuleBase            := pispModule.StockingPointID(), 
 | 
                                                    RequirementDate       := finaleNewSupply.Start().Date() 
 | 
                                                   ); 
 | 
        } 
 | 
        finaleNewSupply := null( NewSupply ); 
 | 
      } 
 | 
      numberOfLayers := 1; 
 | 
    } 
 | 
  *] 
 | 
} 
 |