hongji.li
2023-11-11 df5a7e1ad6835e78b2f9eb7428817b0c23b116bc
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
Quintiq file version 2.0
#parent: #root
Method FindCreatePISPIPNodeAndEdge (
  output owning shadow[SCVConfiguration] owner,
  shadow[SCVNode] ownernode,
  ProductInStockingPointInPeriod pispip,
  Boolean isupstream,
  Process_MP process,
  output Number depth
) as shadow[SCVNode] id:Method_FormSupplyChainVisualization_FindCreatePISPIPNodeAndEdge
{
  #keys: '[133968.0.65085111]'
  Body:
  [*
    // Create a node that the current node will link to
    scvNode := this.GetPISPIPNode( &owner, ownernode, pispip, isupstream );
    
    if( isnull( scvNode ) )
    {
      scvNode := this.CreateSCVPISPIPNode( &owner, pispip, false /*isroot*/ );
      
      // Establish their linkage
      this.CreateSCVEdge( &owner, ownernode, scvNode, isupstream, process );
    }
    
    // Quantity to grab edge value, so that we can truncate branch if the value is 0
    quantity := 0.0;  
                                                                                                                                                                                                                                
    this.ReturnEdgeLabel( &owner, ifexpr( isupstream, scvNode, ownernode ), ifexpr( isupstream, ownernode, scvNode ), quantity );       
    
    // Set depth to 0, meaning stop the drilling,
    if( quantity = 0.0 and owner.IsHideZeroSupplyPaths() )
    {
      scvNode.IsDepthLimitMet( true );
    }
    else
    {
      // if it is upstream, we will generate inventory supply node,
      // if it is downstream, we will generate sales demand node
      if( isupstream )
      {
        this.CreateSCVISNode( &owner, scvNode, pispip, isupstream );
      }
      else
      {
        this.CreateSCVSDNode( &owner, scvNode, pispip, isupstream );
      }
    }
    
    value := max( owner, SCVNode, e, 
                  e.Depth() = scvNode.Depth() 
                  and e.IsUpstream() = scvNode.IsUpstream(), 
                  e.SortSequence() );
                  
    scvNode.SortSequence( value + 1 ); 
    
    return scvNode;
  *]
}