| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod Initialize ( | 
|   MacroPlan owner | 
| ) | 
| { | 
|   TextBody: | 
|   [* | 
|     // 甄兰鸽 Jun-24-2024 (created) | 
|     owner.FinancialProductionSource( relflush ); | 
|     ccunit                    := MachiningPipelineReport::GetDefaultCCUnit(); | 
|     dlunit                    := MachiningPipelineReport::GetDefaultDLUnit(); | 
|     //allunit                   := EnginePipelineReport::GetDefaultAllUnit(); | 
|     source                    := owner.MachiningPipelineSource( relnew, Name := MachiningPipelineReport::GetDefaultName() ); | 
|     table                     := source.Report( relnew, ID := source.Name(), Name := source.Name() ); | 
|     showtable                 := source.Report( relnew, ID := source.Name() + 'Show', Name := source.Name(), IsShow := true ); | 
|      | 
|     search                    := source.Search( relnew, StartDate := Date::MinDate(), EndDate := Date::MaxDate(), TimeUnit := Translations::MP_GlobalParameters_Day() ); | 
|      | 
|     products                  := construct( Product_MPs ); | 
|     //初始化列 | 
|     table.GenerateColumn( owner, 'All', search.StartDate(), search.EndDate() ); | 
|      | 
|     //生成装配、生产和库存数据 | 
|     traverse( owner, Product_MP.ProductInStockingPoint_MP, pisp, pisp.IsLeaf() and not pisp.IsSystem() ){ | 
|       unit := pisp.StockingPoint_MP().UnitID(); | 
|       //初始化行 | 
|       row := table.GetRow( pisp.ProductID() ); | 
|        | 
|       traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() | 
|                 and ( pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day()  | 
|                       or pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Week() ) ){ | 
|         periodtime := pispip.Period_MP().StartDate(); | 
|         periodname := periodtime.Format( "M2/D2/Y" ); | 
|         column := selectobject( table, Column, column, column.Name() = periodname and column.Period() = periodtime and column.TimeUnit() = pispip.Period_MP().TimeUnit() ); | 
|      | 
|         //装配线 | 
|         if( unit = MachiningPipelineReport::GetDefaultCCAssemnlyUnit() or unit = MachiningPipelineReport::GetDefaultDLAssemnlyUnit() ){ | 
|           row.SetCellAssemblyValue( column, unit, pispip.NewSupplyProductionQuantity() ); | 
|         } | 
|         //机加线 | 
|         if( unit = MachiningPipelineReport::GetDefaultCCProductionUnit() or unit = MachiningPipelineReport::GetDefaultDLProductionUnit() ){ | 
|           row.SetCellProductionValue( column, unit, pispip.NewSupplyProductionQuantity() ); | 
|         } | 
|         if( unit = ccunit or unit = dlunit ){ | 
|           row.SetCellInventoryValue( column, unit, pispip.PlannedInventoryLevelEnd() ); | 
|         } | 
|       } | 
|     } | 
|      | 
|     //生成调拨数据 | 
|     traverse( owner, TransferPlanRow, tprow, ( tprow.SourceStockpoingPointID() = 'CC' and tprow.TargetStockpoingPointID() = 'DL' ) or ( tprow.SourceStockpoingPointID() = 'DL' and tprow.TargetStockpoingPointID() = 'CC' ) ){ | 
|       row := selectobject( table, Row, row, row.Name() = tprow.Name() ); | 
|       traverse( table, Column, column ){ | 
|         cell := selectobject( row, Cell, cell, cell.Column() = column ); | 
|         if( column.TimeUnit() = Translations::MP_GlobalParameters_Day() ){ | 
|           tpcell := selectobject( tprow, TransferPlanCell, tpcell, tpcell.TransferPlanColumn().ColumnDate() = column.Period() ); | 
|           if( tprow.SourceStockpoingPointID() = 'CC' and tprow.TargetStockpoingPointID() = 'DL' ){ | 
|             cell.CCTransferQty( [Real]tpcell.Value() ); | 
|           }else if( tprow.SourceStockpoingPointID() = 'DL' and tprow.TargetStockpoingPointID() = 'CC' ){ | 
|             cell.DLTransferQty( [Real]tpcell.Value() ); | 
|           } | 
|         }else if( column.TimeUnit() = Translations::MP_GlobalParameters_Week() ){ | 
|           period := column.Period() + Duration::Days( 6 ); | 
|           tpcell := selectobject( tprow, TransferPlanCell, tpcell, tpcell.TransferPlanColumn().ColumnDate() = period.Date() ); | 
|            | 
|           if( tprow.SourceStockpoingPointID() = 'CC' and tprow.TargetStockpoingPointID() = 'DL' ){ | 
|             cell.CCTransferQty( [Real]tpcell.Value() ); | 
|           }else if( tprow.SourceStockpoingPointID() = 'DL' and tprow.TargetStockpoingPointID() = 'CC' ){ | 
|             cell.DLTransferQty( [Real]tpcell.Value() ); | 
|           } | 
|         } | 
|       } | 
|     } | 
|      | 
|     rows := selectsortedset( table, Row, row, row.Name() ); | 
|     i    := 0; | 
|     traverse( rows, Elements, e ){ | 
|       e.RowNr( i ); | 
|       i := i + 1; | 
|     } | 
|     showtable.Generate( search, products ); | 
|   *] | 
| } |