陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
Quintiq file version 2.0
#parent: #root
Method Enable (
  const OfflinePlanArchiveVersion offlinePlanTable
)
{
  TextBody:
  [*
    // Akari Oct-30-2024 (created)
    offlinePlanRow := select( offlinePlanTable,Row,row,row.ProductID() = this.ProductInStockingPoint_MP().ProductID() and row.StockingPointID() = this.ProductInStockingPoint_MP().StockingPointID() );
    
    if( not this.IsEnable() and not isnull( offlinePlanRow )){
      offlinePlanCells := selectset( offlinePlanRow, Cell,cell, true );//,cell.Column().TimeUnit() = "Day"
      offlinePlanCellIndexTree := NamedValueTree::Create();
      for( i := 0; i< offlinePlanCells.Size(); i++ ){
        offlinePlanCell := offlinePlanCells.Element( i );
        offlinePlanCellHandle := offlinePlanCellIndexTree.GetHandle( offlinePlanCell.Column().StartDate().AsQUILL() );
        offlinePlanCellIndexTree.Root().AddChild( offlinePlanCellHandle,i );
      }
      
      this.IsEnable( true );
      
      pispips := selectset( this,ProductInStockingPoint_MP.ProductInStockingPointInPeriod.astype( ProductInStockingPointInPeriodPlanningLeaf ),period,period.Period_MP().StartDate() <= this.LockDate() );
      traverse( pispips,Elements,element ){
        element.IsLock( true );
        offlinePlanCellHandle := offlinePlanCellIndexTree.GetHandle( element.Period_MP().StartDate().AsQUILL() );
        offlinePlanCellIndex := guard( offlinePlanCellIndexTree.Root().Child( offlinePlanCellHandle),null( NamedValue ));
        offlinePlanCellQuantity := 0.0;
        if( not isnull( offlinePlanCellIndex )){
          offlinePlanCell := offlinePlanCells.Element( offlinePlanCellIndex.GetValueAsNumber() );
          offlinePlanCellQuantity := offlinePlanCell.Quantity();
        }
    
        if( element.NewSupply( relsize ) = 1 ){
          traverse( element,NewSupply,newSupply ){
            newSupply.Update( offlinePlanCellQuantity );
          }
        }else if( element.NewSupply( relsize ) > 1 ){
          newSupplys := selectset( element,NewSupply,newSupply,true );
          for( i := 1; i < newSupplys.Size(); i++ ){
            newSupply := newSupplys.Element( i );
            newSupply.Update( 0.0 );
          }
          newSupplys.Element( 0 ).Update( offlinePlanCellQuantity )
        }else if( element.NewSupply( relsize ) = 0 ){
          if( offlinePlanCellQuantity <> 0 ){
            info( "new supply is null" );
            unit := element.StockingPointInPeriod().StockingPoint_MP().Unit();
            operaction := select( unit,Operation,op,true );
            if( not isnull( operaction )){
              info( "operaction is null" );
              // unitPeriod := element.Period_MP().UnitPeriod()
              // PeriodTaskOperation::Create( operaction,unitPeriod,quantity,false );
            }else{
              
            }
          }
        }
      }
      ProductInStockingPointInPeriod::LockUnlockPlanning( pispips, true, true );
    }else{
      info( "Archive data [" + this.ProductInStockingPoint_MP().Name() + "] is null.")
    }
  *]
}