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
70
71
72
73
74
75
76
77
78
79
80
81
Quintiq file version 2.0
#parent: #root
StaticMethod GenerateData (
  MacroPlan macroPlan,
  InterfaceDataset interfaceDataset
)
{
  Description: '生成计划库存存档数据'
  TextBody:
  [*
    //interfaceDataset.InventoryPlanArchiveVersion( relflush );
    info( '-------------------------Start---------------------');
    machineproductparent   := MachiningPipelineReport::GetDefaultProductParent();
    engineproductparent    := EnginePipelineReport::GetDefaultProductParent();
    allunit                := AssemblyOnlinePlanVersion::GetDefaultAllUnit();
    name                   := InventoryPlanArchiveVersion::GetDefaultName();//search                 := 
    interfaceDataset.InventoryPlanArchiveVersionSearch( relnew, Product := allunit, Unit := allunit, StartDate := Date::MinDate(), EndDate := Date::MaxDate() );//, TimeUnit := Translations::MP_GlobalParameters_Day()
    table                  := selectobject( interfaceDataset, InventoryPlanArchiveVersion, version, not version.IsShow() );
    if( isnull( table ) ){
      table                := interfaceDataset.InventoryPlanArchiveVersion( relnew, ID := name, Name := name );
    }
    //showtable              := selectobject( interfaceDataset, InventoryPlanArchiveVersion, version, version.IsShow() );
    //if( isnull( showtable ) ){ 
    //  showtable               := interfaceDataset.InventoryPlanArchiveVersion( relnew, ID := name, Name := name, IsShow := true );
    //}
    periods                := selectuniquevalues(  macroPlan, Period_MP, period, not period.IsHistorical() and period.TimeUnit() = Translations::MP_GlobalParameters_Day()
                                                   and not exists( table, Column, column, column.StartDate() = period.StartDate() ), period.StartDate() );//column.TimeUnit() = Translations::MP_GlobalParameters_Day() and 
    if( periods.Size() > 0 ){
      table.GenerateColumn( periods, false );
    }
    actinventorytree       := NamedValueTree::Create();
    inventoryqrys          := construct( Reals );
    inventoryindex         := 0;
    traverse( interfaceDataset,InterfaceLoginfo.MachineStockData, actinventory ){
      inventoryqrys.Add( actinventory.Total() );
      actinventoryKey      := actinventory.MaterialNo() + actinventory.DDay().AsQUILL();
      actinventoryhandle   := actinventorytree.GetHandle( actinventoryKey );
      actinventorytree.Root().AddChild( actinventoryhandle,inventoryindex ); 
      inventoryindex       := inventoryindex + 1;
    }
    traverse( interfaceDataset,InterfaceLoginfo.FinishedEngineInventory,actinventory ){
      product               := selectobject( macroPlan, Product_MP, product, product.Notes() = actinventory.FourCode() );
      if( not isnull( product ) ){
        inventoryqrys.Add( actinventory.Total() );
        actinventoryKey     := actinventory.FourCode() + actinventory.DDay().AsQUILL();
        actinventoryhandle  := actinventorytree.GetHandle( actinventoryKey );
        actinventorytree.Root().AddChild( actinventoryhandle,inventoryindex ); 
        inventoryindex      := inventoryindex + 1;
      }
    }
    traverse( macroPlan, Product_MP, product, exists( product.GetAllParent(), Elements, e, e.ID() = machineproductparent or e.ID() = engineproductparent ) ){ 
      traverse ( product, ProductInStockingPoint_MP, pispmp, not pispmp.IsSystem() and pispmp.IsLeaf() ) {
        unit                 := ifexpr( pispmp.StockingPointID().Regex( "大连" ) or pispmp.StockingPointID().Regex( "DL" ), FinancialProductionReport::GetDefaultDLUnit(), FinancialProductionReport::GetDefaultCCUnit() );
        inventoryrow         := table.GetRowByUnit( pispmp.Product_MP(), unit );
        traverse ( pispmp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispippl, not pispippl.IsPeriodFrozen() ) {
          startdate          := pispippl.Start().Date();
          daycolumn          := table.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Day(), startdate );
    //      weekcolumn         := table.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Week(), startdate );
    //      monthcolumn        := table.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Month(), startdate );
          actinventoryKey    := pispmp.ProductID() + startdate.AsQUILL();
          actinventoryhandle := actinventorytree.GetHandle( actinventoryKey );
          actinventoryindex  := guard( actinventorytree.Root().Child( actinventoryhandle ),null( NamedValue ));
          
          actinventoryqty    := 0.0;
          if( not isnull( actinventoryindex )){
            actinventoryqty  := inventoryqrys.Element( actinventoryindex.GetValueAsNumber() );
          }
          inventoryrow.SetQuantity( daycolumn, pispippl.InventoryLevelEnd(), actinventoryqty );
    //      inventoryrow.SetQuantity( weekcolumn, pispippl.InventoryLevelEnd(), actinventoryqty );
    //      inventoryrow.SetQuantity( monthcolumn, pispippl.InventoryLevelEnd(), actinventoryqty );
      
        }
      }
    }
    
    info( '-------------------------End---------------------');
    //productids             := selectuniquevalues( table, Row, row, row.Name() );
    //productlines           := selectuniquevalues( table, Row, row, row.Unit() );
    //showtable.Generate( search, productids, productlines );
  *]
}