hongji.li
2023-11-07 1a1ba3ad5ed9e4380185aa1ccad20204a0e5f115
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
Quintiq file version 2.0
#parent: #root
Method ReturnEdgeLabel (
  shadow[SCVNode] sourcenode,
  shadow[SCVNode] targetnode,
  output Real quantity_o
) as String id:Method_FormSupplyChainVisualization_ReturnEdgeLabel
{
  #keys: '[134266.1.1639225912]'
  Body:
  [*
    // Return edge label of this edge
    label := '';
    tooltip := '';
    scvConfig := DataHolderSCVConfiguration.Data();
    period := scvConfig.Period_MP();
    pisps := construct( ProductInStockingPoint_MPs );
    operations := construct( Operations );
    lane := null( Lane );
    targetPISPIP := null( ProductInStockingPoint_MP );
    
    // RoutingStep node to other nodes
    if( sourcenode.istype( shadow[SCVRoutingStepNode] ) )
    {
      sourceNode := sourcenode.astype( shadow[SCVRoutingStepNode] );
      operations := selectset( sourceNode, OperationInNode.Operation, op, true );
      
      if( targetnode.istype( shadow[SCVPISPIPNode] ) )
      {
        targetNode := targetnode.astype( shadow[SCVPISPIPNode] );
        pisps := pisps.Merge( targetNode.ProductInStockingPointInPeriod().ProductInStockingPoint_MP() )
      }
      else if( targetnode.istype( shadow[SCVRoutingStepNode] ) )
      {
        targetNode := targetnode.astype( shadow[SCVRoutingStepNode] );
        pisps := selectset( targetNode, OperationInNode.Operation.OperationInput.ProductInStockingPoint_MP, pisp, true )
      }
      
      quantity_o := SCVEdge::GetProcessQuantity( period, operations, pisps, false /*isdependentdemand*/, tooltip );  
    }  
    
    // PISPIP node to other nodes
    else if( sourcenode.istype( shadow[SCVPISPIPNode] ) )
    {
      sourceNode := sourcenode.astype( shadow[SCVPISPIPNode] );
      pisps := pisps.Merge( sourceNode.ProductInStockingPointInPeriod().ProductInStockingPoint_MP() )
      
      if( targetnode.istype( shadow[SCVRoutingStepNode] ) )
      {
        targetNode := targetnode.astype( shadow[SCVRoutingStepNode] );
        operations := selectset( targetNode, OperationInNode.Operation, op, true );
        
        quantity_o := SCVEdge::GetProcessQuantity( period, operations, pisps, true /*isdependentdemand*/, tooltip ); 
      }
      else if( targetnode.istype( shadow[SCVLaneNode] ) )
      {
        targetNode := targetnode.astype( shadow[SCVLaneNode] );
        lane := targetNode.Lane();
        isupstream := targetNode.IsUpstream();
        
        if( isupstream )
        {
          targetPISPIPNode := select( scvConfig, SCVNode, node, node.Key().AsQUILL() = targetNode.OwnerNodeKey() ).astype( shadow[SCVPISPIPNode] );
          targetPISPIP := targetPISPIPNode.ProductInStockingPointInPeriod().ProductInStockingPoint_MP();
        }
        
        quantity_o := SCVEdge::GetProcessQuantity( period, lane, pisps, targetPISPIP, true /*isdependentdemand*/, isupstream, tooltip ); 
      }
      else if( targetnode.istype( shadow[SCVSDNode] ) )
      {
        quantity_o := SCVEdge::GetProcessQuantity( sourceNode.ProductInStockingPointInPeriod(), tooltip );
      }
    }
    
    // Lane node to PISPIP node
    else if( sourcenode.istype( shadow[SCVLaneNode] ) )
    {
      sourceNode := sourcenode.astype( shadow[SCVLaneNode] );
      lane := sourceNode.Lane();
      
      if( targetnode.istype( shadow[SCVPISPIPNode] ) )
      {
        targetNode := targetnode.astype( shadow[SCVPISPIPNode] );
        isupstream := sourceNode.IsUpstream(); 
        
        if( not isupstream )
        {
          targetPISPIPNode := select( scvConfig, SCVNode, node, node.Key().AsQUILL() = sourceNode.OwnerNodeKey() ).astype( shadow[SCVPISPIPNode] );
          targetPISPIP := targetPISPIPNode.ProductInStockingPointInPeriod().ProductInStockingPoint_MP();
        }    
        pisps := pisps.Merge( targetNode.ProductInStockingPointInPeriod().ProductInStockingPoint_MP() )
      } 
      
      quantity_o := SCVEdge::GetProcessQuantity( period, lane, pisps, targetPISPIP, false /*isdependentdemand*/, sourceNode.IsUpstream(), tooltip );  
    }
    
    // Inventory supply node to PISPIP node
    else if( sourcenode.istype( shadow[SCVISNode] ) )
    {
      if( targetnode.istype( shadow[SCVPISPIPNode] ) )
      {
        targetNode := targetnode.astype( shadow[SCVPISPIPNode] );
        pisps := pisps.Merge( targetNode.ProductInStockingPointInPeriod().ProductInStockingPoint_MP() )
        
        quantity_o := SCVEdge::GetInventorySupplyQuantity( targetNode.ProductInStockingPointInPeriod(), tooltip );
      }
    }
    
    uom := select( pisps, Elements.UnitOfMeasure_MP, e, true );
                          
    label := quantity_o.Format( 'N(Dec(2))' ) 
             + ' ' 
             + uom.Name();
             
    if( not sourcenode.istype( shadow[SCVPISPIPNode] ) )
    {
      sourcenode.Tooltip( tooltip );
    }
    else
    {
      targetnode.Tooltip( tooltip );
    }
                      
    return label;
  *]
  Declarative: true
}