yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
Method Copy (
  Routing newrouting
)
{
  Description: 'Copy operation link to new routing'
  IsAbstract: true
  TextBody:
  [*
    // DWE2 Feb-16-2016 (created)
    oldsource := this.AsSourceOperation();
    olddestination := this.AsDestinationOperation();
    
    /* User might have custom id, so we will get the system id to locate the exact operation.
       The ID creted via COPY/DEFAULT will always have the format as the concatenated method.
       E.g, source was system id and destiantion was user id
       Source                      Destination
    ID Routing - Step 1 - Unit 1   Abc123
    
    Copy-->
       Source                           Destination
    ID Routing_Copy - Step 1 - Unit 1   Routing_Copy - Step 2 - Unit 2  */
    newsourceid := Operation::GetConcatenatedID( newrouting.ID(), oldsource.RoutingStepName(), oldsource.UnitID() );
    newdestinationid := Operation::GetConcatenatedID( newrouting.ID(), olddestination.RoutingStepName(), olddestination.UnitID() );
    
    newsource := Operation::FindOperationTypeIndex( newsourceid );
    newdestination := Operation::FindOperationTypeIndex( newdestinationid );
    
    OperationLink::Create( newsource,
                           newdestination,
                           this.SourceGroupID(),
                           this.DestGroupID(),
                           this.SourceQuantity(),
                           this.DestHasUserQuantity(),
                           this.DestQuantity(),
                           this.DestMinQuantity(),
                           this.DestMaxQuantity(),
                           this.DestGroupQuantity(),
                           false,
                           true );
  *]
}