| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod GenerateData ( | 
|   InterfaceDataset interface, | 
|   RecycleBin recycle, | 
|   const Archive archive | 
| ) | 
| { | 
|   Description: '生成可以下发的客户需求(PPA+IDS)数据' | 
|   TextBody: | 
|   [* | 
|     // 甄兰鸽 Aug-20-2024 (created) | 
|     interface.CustomerDemandIDS( relflush ); | 
|     interface.CustomerDemandIDSSearch( relflush ); | 
|     allunit               := CustomerDemandIDS::GetDefaultAllUnit(); | 
|     interface.CustomerDemandIDSSearch( relnew, Generation := allunit, MqbMlb := allunit, Power := allunit, TimeUnit := Translations::MP_GlobalParameters_Day(), Unit := allunit ); | 
|     idstable              := interface.CustomerDemandIDS( relnew, ID := '客户需求', Name := '客户需求' ); | 
|     binaryValue           := TemplateManager::GetIDSFullTable( archive, Date::ActualDate().Year() ); | 
|     source                := GeneralExcelImportAndExportDataSource::Upload( recycle, binaryValue, OS::TempPath() + "template.xlsx" ); | 
|     source.ReadStructure(); | 
|     Transaction::Transaction().Propagate( attribute( GeneralExcelImportAndExportDataColumn, ColumnIndex ) ); | 
|     cnv2 := StringToDate::StandardConverter(); | 
|     cnv2.SetCustomConversion(); | 
|     cnv2.CustomFormatString( "yyyy/MM/dd" ); | 
|     idsdates              := selectuniquevalues( source, GeneralExcelImportAndExportDataTable.GeneralExcelImportAndExportDataColumn, column, column.ColumnIndex() > 2, cnv2.Convert( column.Name() ) ); | 
|     ppadates              := selectuniquevalues( interface, InterfaceForecast, forecast, forecast.Origin() = 'PPA', forecast.Date() ); | 
|     //ppadates              := construct( Dates ); | 
|     //traverse( macroplan, SalesDemand.astype( Forecast ), forecast, forecast.Origin() = 'PPA' ){ | 
|     //  ppadates            := ppadates.Union( selectuniquevalues( forecast, PlanningSalesDemandInPeriod, salesdemand, salesdemand.StartDate() ) ); | 
|     //} | 
|     periods               := idsdates.Union( ppadates ); | 
|     periods               := selectuniquevalues( periods, Elements, e, e ); | 
|     idstable.GenerateColumn( periods.Sort() ); | 
|     traverse( recycle, GeneralExcelImportAndExportDataSource.GeneralExcelImportAndExportDataTable, table ){ | 
|       traverse( table, GeneralExcelImportAndExportDataRow, row ){ | 
|         productcell       := selectobject( row, GeneralExcelImportAndExportDataCell, cell, cell.GeneralExcelImportAndExportDataColumn().ColumnIndex() = 2 ); | 
|         factorycell       := selectobject( row, GeneralExcelImportAndExportDataCell, cell, cell.GeneralExcelImportAndExportDataColumn().ColumnIndex() = 0 ); | 
|         idsrow            := idstable.GetRowByUnit( productcell.Value(), factorycell.Value() ); | 
|         traverse( row, GeneralExcelImportAndExportDataCell, cell, cell.GeneralExcelImportAndExportDataColumn().ColumnIndex() > 2 ){ | 
|           period          := cnv2.Convert( cell.GeneralExcelImportAndExportDataColumn().Name() ); | 
|           daycolumn       := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Day(), period ); | 
|           weekcolumn      := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Week(), period ); | 
|           monthcolumn     := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Month(), period ); | 
|           idsrow.SetCellValue( daycolumn, [Number]cell.Value() ); | 
|           idsrow.SetCellValue( weekcolumn, [Number]cell.Value() ); | 
|           idsrow.SetCellValue( monthcolumn, [Number]cell.Value() ); | 
|         } | 
|       } | 
|     } | 
|     traverse( interface, InterfaceForecast, forecast, forecast.Origin() = 'PPA' ){ | 
|       idsrow              := idstable.GetRowByUnit( forecast.PartNumber(), forecast.Factory() ); | 
|       daycolumn           := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Day(), forecast.Date() ); | 
|       weekcolumn          := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Week(), forecast.Date() ); | 
|       monthcolumn         := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Month(), forecast.Date() ); | 
|       idsrow.SetCellValue( daycolumn, [Number]forecast.Quantity() ); | 
|       idsrow.SetCellValue( weekcolumn, [Number]forecast.Quantity() ); | 
|       idsrow.SetCellValue( monthcolumn, [Number]forecast.Quantity() ); | 
|     } | 
|      | 
|     source.Delete(); | 
|   *] | 
| } |