admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Quintiq file version 2.0
#parent: #root
StaticMethod GenerateData (
  InterfaceDataset interface,
  MacroPlan macroplan,
  RecycleBin recycle,
  const Archive archive
)
{
  Description: '生成客户需求存档数据'
  TextBody:
  [*
    // 甄兰鸽 Nov-22-2024 (created)
    info( '-------------------------Start---------------------');
    //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" );
    //
    //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 );
    //    unitname          := ifexpr( factorycell.Value().StartsWith( '长春' ), FinancialProductionReport::GetDefaultCCUnit(), FinancialProductionReport::GetDefaultDLUnit() );
    ////    idsrow            := idstable.GetRowByUnit( productcell.Value(), unitname );
    //    traverse( row, GeneralExcelImportAndExportDataCell, cell, cell.GeneralExcelImportAndExportDataColumn().ColumnIndex() > 2 ){
    //      period          := cnv2.Convert( cell.GeneralExcelImportAndExportDataColumn().Name() );
    //      archivedata     := selectobject( interface, CustomerDemandArchive, archivedata, archivedata.Factory() = factorycell.Value()
    //                                       and archivedata.Product() = productcell.Value()
    //                                       and archivedata.StartDate() = period
    //                                       and archivedata.Origin() = 'IDS' );
    //      if( isnull( archivedata ) ){
    //        archivedata   := interface.CustomerDemandArchive( relnew, Factory := factorycell.Value(), Product := productcell.Value(), StartDate := period, Origin := 'IDS', FactoryName := unitname );
    //      }
    //      archivedata.Quantity( [Real]cell.Value() );
    //    }
    //  }
    //}
    traverse ( macroplan, SalesDemand.astype( Forecast ), forecast, not isnull( forecast.Product_MP() ) and ( forecast.Origin() = 'PPA' or forecast.Origin() = 'IDS' ) ){
      
      unitname              := ifexpr( forecast.StockingPointID().StartsWith( '长春' ) , FinancialProductionReport::GetDefaultCCUnit(), FinancialProductionReport::GetDefaultDLUnit() );/*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 ){
        archivedata         := selectobject( interface, CustomerDemandArchive, archivedata, archivedata.SalesSegment() = forecast.SalesSegmentName()
                                               and archivedata.StockingPointID() =forecast.StockingPointID()
                                               and archivedata.Product() = forecast.ProductID()
                                               and archivedata.StartDate() = forecast.StartDate() 
                                               and archivedata.Origin() = forecast.Origin() );
        if( isnull( archivedata ) ){
          archivedata       := interface.CustomerDemandArchive( relnew, SalesSegment             := forecast.SalesSegmentName()
                                                                , Product                        := forecast.ProductID()
                                                                , StockingPointID                := forecast.StockingPointID()
                                                                , StartDate                      := forecast.StartDate() 
                                                                , Origin                         := forecast.Origin()
                                                                , FactoryName                    := unitname );
        }
        archivedata.Quantity( sdip.Quantity() );
      }
    }
    
    //source.Delete();
    info( '-------------------------End---------------------');
  *]
}