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
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
Quintiq file version 2.0
#parent: #root
Method DataMockupGenerateRoutings (
  Unit unit,
  Number nrofroutings,
  Number nrofinputsperrouting,
  Number nrofoutputsperrouting
)
{
  TextBody:
  [*
    macroplan := this.MacroPlan();
    
    // Create Routing for the number of passed in nrofroutings
    for( i := 0; i < nrofroutings; i++ )
    {
      // Routing ID
      id := 'Routing_' + [String] i;
      
      // Create Routing
      routing := Routing::Create( macroplan, id, id, 
                                  Date::MinDate(),
                                  Date::MaxDate(),
                                  false,
                                  false );
      
      // Create RoutingStep
      routingstep := RoutingStep::Create( routing, id, '', false );
      
      // Randomly select an input StockingPoint_MP
      inputsp := minselect( macroplan, StockingPoint_MP, sp, true, Real::Random() );
      // Randomly select an output StockingPoint_MP
      outputsp := minselect( macroplan, StockingPoint_MP, sp, true, Real::Random() );
      
      // Create Operation
      operation := Operation::Create( unit, routingstep, false );
      // Create input OperationBOM for the number of passed in nrofinputsperrouting
      for( j := 0; j < nrofinputsperrouting; j++ )
      {                                  
        // Randomly select one Product_MP given that that it is not being used in any input OperationBOM of the current Operation
        product := minselect( macroplan, Product_MP, p, 
                              not exists( operation, OperationBOM, oi,
                                          oi.IsInput()
                                          and oi.ProductID() = p.ID() ),
                              Real::Random() );
                          
        // Create input OperationBOM
        OperationBOM::Create( operation, 
                              product.ID(), 
                              inputsp.ID(), 
                              true, 
                              1, 
                              false, 
                              1.0, 
                              0.0, 
                              0.0, 
                              false, 
                              false );
                               
      }
      // Create out OperationBOM for the number of passed in nrofoutputsperrouting
      for( k := 0; k < nrofoutputsperrouting; k++ )
      {                          
        // Randomly select one Product_MP given that that it is not being used in any output OperationBOM of the current Operation
        product := minselect( macroplan, Product_MP, p, 
                              not exists( operation, OperationBOM, oo,
                                          not oo.IsInput()
                                          and oo.ProductID() = p.ID() ),
                              Real::Random() );
                                 
        // Create output OperationBOM
        OperationBOM::Create( operation, 
                              product.ID(), 
                              outputsp.ID(), 
                              false, 
                              1, 
                              false, 
                              1.0, 
                              0.0, 
                              0.0, 
                              false, 
                              false );
      }
    }
    
    Transaction::Transaction().Propagate();
  *]
}