陈清红
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
Quintiq file version 2.0
#parent: #root
StaticMethod OptimizerPostProcessing (
  LibOpt_Scope scope,
  RunContextForCapacityPlanning runcontext
)
{
  TextBody:
  [*
    //We need to propagate InventoryDemandFulfilledQuantity 
    Transaction::Transaction().Propagate();
    pispipssmartplan := scope.GetSmartPlanPISPIPsInOptimizerRun(); 
    
    traverse( pispipssmartplan, Elements, pispip )
    {                                         
      // If this pispip has a user specified total available supply
      // Then set the total supply user equal to this total available supply
      // To make sure that any future optimizer runs will provide the user available supply
      if( pispip.HasTotalAvailableSupplyUser() )
      {
        pispip.UpdateTotalSupplyUser( true, pispip.TotalAvailableSupplyUser() );
      } 
      else
      {
        qty := guard( pispip.InventoryLevelStartPISPIP().InventoryLevelEnd(), 0.0 ) + pispip.NewSupplyQuantity() + pispip.InventorySupplyQuantity();    
        pispip.UpdateTotalSupplyUser( true, qty );
      }
      
      
      //set the user flag for period tasks
      //of the routing / laneleg units that are supplying to the pispip
      //YY Question: Is it safe to assume
      if( runcontext.IsSmartPlanForPeriodTask() and pispip.istype( ProductInStockingPointInPeriodPlanningLeaf ) )
      {      
        traverse( pispip.astype( ProductInStockingPointInPeriodPlanningLeaf ), 
                  NewSupply, 
                  ns, 
                  exists( scope.GetPeriodTaskOperationInOptimizerRun(), Elements.Operation, pto, ns.IsSuppliedByThisProcess( pto ), true )
                  or exists( scope.GetProductInTripInOptimizerRun(), Elements.Trip.LaneLeg, ll, ns.IsSuppliedByThisProcess( ll ), true ) )
        {   
          if( ns.IsNewSupplyOfTrip() )
          {
            pit := ns.ProductInTrip();
            pit.Update( pit.OptimizerQuantity(), true );
          }
          else if( ns.PeriodTask_MP().istype( PeriodTaskOperation ) )
          {
            pto := ns.PeriodTask_MP().astype( PeriodTaskOperation );
            pto.Update( pto.OptimizerQuantity(), true, scope );
          }
        }
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}