lazhen
2024-11-15 2f810c64ce22dabb7bb3bd0d6cf901da8d9f5ca4
_Main/BL/Type_CustomerDemandIDS/StaticMethod_GenerateData.qbl
@@ -2,7 +2,7 @@
#parent: #root
StaticMethod GenerateData (
  InterfaceDataset interface,
  const MacroPlan macroplan,
  MacroPlan macroplan,
  RecycleBin recycle,
  const Archive archive
)
@@ -15,12 +15,15 @@
    //interface.CustomerDemandIDSSearch( relflush );
    info( '-------------------------Start---------------------');
    allunit               := CustomerDemandIDS::GetDefaultAllUnit();
    if( isnull( interface.CustomerDemandIDSSearch() ) ){
      interface.CustomerDemandIDSSearch( relnew, Generation := allunit, MqbMlb := allunit, Power := allunit, TimeUnit := Translations::MP_GlobalParameters_Day(), Unit := allunit );
    }
    idstable              := selectobject( interface, CustomerDemandIDS, idstable, idstable.ID() = '客户需求' );
    search                := interface.CustomerDemandIDSSearch( relnew, Product := allunit, StartDate := Date::MinDate(), EndDate := Date::MaxDate(), TimeUnit := Translations::MP_GlobalParameters_Day(), Unit := allunit );
    name                  := '客户需求';
    idstable              := selectobject( interface, CustomerDemandIDS, idstable, idstable.ID() = name );
    if( isnull( idstable ) ){
      idstable            := interface.CustomerDemandIDS( relnew, ID := '客户需求', Name := '客户需求' );
      idstable            := interface.CustomerDemandIDS( relnew, ID := name, Name := name );
    }
    showtable             := selectobject( interface, CustomerDemandIDS, version, version.IsShow() );
    if( isnull( showtable ) ){
      showtable           := interface.CustomerDemandIDS( relnew, ID := name + 'Show', Name := name, IsShow := true );
    }
    binaryValue           := TemplateManager::GetIDSFullTable( archive, Date::ActualDate().Year() );
    source                := GeneralExcelImportAndExportDataSource::Upload( recycle, binaryValue, OS::TempPath() + "template.xlsx" );
@@ -34,7 +37,7 @@
    periods               := idsdates.Union( ppadates );
    periods               := selectuniquevalues( periods, Elements, e, not exists( idstable, Column, column, column.StartDate() = e ), e );
    if( periods.Size() > 0 ){
      idstable.GenerateColumn( periods.Sort() );
      idstable.GenerateColumn( periods.Sort(), false );
    }
    traverse( recycle, GeneralExcelImportAndExportDataSource.GeneralExcelImportAndExportDataTable, table ){
      traverse( table, GeneralExcelImportAndExportDataRow, row ){
@@ -54,8 +57,12 @@
      }
    }
    traverse ( macroplan, SalesDemand.astype( Forecast ), forecast, not isnull( forecast.Product_MP() ) and forecast.Origin() = 'PPA' ){
      unitname              := ifexpr( forecast.SalesSegment_MP().Name().StartsWith( 'Changchun' )
                                       or exists( forecast.SalesSegment_MP().GetAllParent(), Elements, psalessegment, psalessegment.Name().StartsWith( 'Changchun' ) )
                                       , FinancialProductionReport::GetDefaultCCUnit()
                                       , FinancialProductionReport::GetDefaultDLUnit() );
      traverse( forecast, PlanningSalesDemandInPeriod, sdip ){
        idsrow              := idstable.GetRowByUnit( forecast.ProductID(), forecast.SalesSegmentName() );
        idsrow              := idstable.GetRowByUnit( forecast.ProductID(), unitname );
        daycolumn           := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Day(), sdip.StartDate() );
        weekcolumn          := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Week(), sdip.StartDate() );
        monthcolumn         := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Month(), sdip.StartDate() );
@@ -68,5 +75,6 @@
    
    source.Delete();
    info( '-------------------------End---------------------');
    showtable.Generate( search );
  *]
}