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
Quintiq file version 2.0
#parent: #root
Method InitializeLaneAfterImport
{
  Description: 'Set StockingPointInLane after import Lane & LaneLeg'
  TextBody:
  [*
    // Jian Giang Aug-17-2016 (created)
    
    //traverse laneleg for origin
    traverse( this, Unit.Lane, lane )
    {
      originSPs := construct( StockingPoint_MPs );
      destSPs := construct( StockingPoint_MPs );
      
      oristockingpointinlanes := construct( StockingPointInLanes ); 
      desstockingpointinlanes := construct( StockingPointInLanes ); 
      
      // select the old stockingpointinlanes 
      oldoristockingpointinlanes := selectset( lane, Origin, ori, true, true );
      olddesstockingpointinlanes := selectset( lane, Destination, dest, true, true );
      
      traverse( lane, LaneLeg, laneleg )
      {
        laneid := lane.ID();
        orispil := select( lane, Origin, o, 
                           o.OriginLaneID() = laneid and o.StockingPointID() = laneleg.OriginStockingPointID() );
        desspil := select( lane, Destination, d, 
                           d.DestinationLaneID() = laneid and d.StockingPointID() = laneleg.DestinationStockingPointID() );
        
        oristockingpointinlanes.Add( orispil );
        desstockingpointinlanes.Add( desspil );
        
        orisp := StockingPoint_MP::FindStockingPointTypeIndex( laneleg.OriginStockingPointID() );
        if( not isnull( orisp ) )
        {
          originSPs.Add( orisp );
        }
        destsp := StockingPoint_MP::FindStockingPointTypeIndex( laneleg.DestinationStockingPointID() );
        if( not isnull( destsp ) )
        {
          destSPs.Add( destsp );
        }
      }
      originSPs := originSPs.Unique();
      if( originSPs.Size() > 0 )
      {
        lane.AddStockingPoints( originSPs, true, true );
      }
      
      destSPs := destSPs.Unique();
      if( destSPs.Size() > 0 )
      {
        lane.AddStockingPoints( destSPs, false, true );
      }
      //delete unused stockingointinlanes
      obsoleteoristockingpointinlanes := oldoristockingpointinlanes.Difference( oristockingpointinlanes );
      obsoletedesstockingpointinlanes := olddesstockingpointinlanes.Difference( desstockingpointinlanes );
      Lane::DeleteLaneLegs( lane, obsoleteoristockingpointinlanes, true );
      Lane::DeleteLaneLegs( lane, obsoletedesstockingpointinlanes, false );
    }
  *]
}