limj
2023-10-24 93652435728de839582440eefd5122c281181d35
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
Quintiq file version 2.0
#parent: #root
StaticMethod GetCopies (
  Number nrcopies,
  Routings routings
) as owning Routings
{
  TextBody:
  [*
    //return Routing::GetCopies_Slow( nrcopies, routings ); 
    
    copies := construct( RoutingPairs ); 
    returnset := construct(  Routings ); 
    if ( routings.Size() > 0 ) 
    {
      routings.Element( 0 ).MacroPlan().RoutingPair( relflush ); 
    }
    
    
    traverse( routings, Elements, routing ) 
    {
      for ( i := 1; i <= nrcopies; i++ ) 
      {
        routingname := routing.MacroPlan().GetUniqueRoutingName( routing.Name() + GlobalParameters_MP::GetCopyString() );
        
        newrouting := Routing::Create( routing.MacroPlan(),
                                       routingname,
                                       routingname,
                                       routing.Start(),
                                       routing.End(),
                                       routing.AllowWIPInventory(),
                                       false 
                                       );
        newrouting.CopyHelper( i ); 
        routingpair := routing.MacroPlan().RoutingPair( relnew, FirstRouting := routing, SecondRouting := newrouting );                                   
        copies.Add(  routingpair ); 
        returnset.Add( newrouting );  
        // Copy rouitng step with operations
        traverse( routing, RoutingStep, rs )
        {
          rs.Copy( newrouting );
        }
      }
    }
    
    debuginfo( 'Step 1 created copies size = ', copies.Size() ); 
     
    // Propagated all Operation-Step-Routing relation before copy operation link
    Transaction::Transaction().Propagate();
    
    debuginfo(  'propagated' );
    traverse( copies, Elements, routingpair ) 
    {
      routing := routingpair.FirstRouting(); 
      newrouting := routingpair.SecondRouting(); 
      traverse( routing, RoutingStep.Operation.SourceOperationLink, ol )
      {
        ol.Copy( newrouting );
      }
    }
    debuginfo(  'Step 2 done' ); 
    if ( routings.Size() > 0 ) 
    {
      routings.Element( 0 ).MacroPlan().RoutingPair( relflush ); 
    }
    
    return &returnset;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}