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
64
65
66
67
68
69
70
Quintiq file version 2.0
#parent: #root
StaticMethod ThermalTrialRatio (
  Routing routing,
  Unit unit,
  Number capacity,
  Date start,
  Date end,
  Number ratio
) as owning Routings
{
  Description: 'Check input is valid'
  TextBody:
  [*
    // Adhi Feb-10-2016 (created)
    thermaltrial := Unit::GetThermalTrial();
    newroutings := construct( Routings );
    
    for( starttime := start; starttime <= end; starttime := starttime + 1 ){
      uc := selectobject( unit, UnitCapacity, uc, uc.Start().Date() = starttime );
      if( isnull( uc ) ){
        uc := UnitCapacity::Create( unit, starttime.DateTime(), 'Day', 0.0, [Real]capacity, 100.0, 1, false );
      }
      uc.MaxCapacity( [Real]capacity * ratio );
    }
    
    newrouting := routing.Copy();
    name := newrouting.Name().ReplaceAll( 'Copy', thermaltrial );
    newrouting.Name( name );
    newrouting.UpdateTypeIndex( name );
    
    newrouting.Start( start );
    newrouting.End( end );
    
    routingstep := newrouting.LastStep();
    
    newroutingstep := RoutingStep::Create( newrouting, thermaltrial, routingstep.Tool(), false );
    spname      := ifexpr( unit.ID().StartsWith( 'CC' ), 'CC-热试', 'DL-热试' );
    //info( '------------------', routingstep.Tool(), ',', unit.ID(), ',', spname );
    traverse( routingstep, Operation, operation ){
      id := Operation::GetConcatenatedID( newrouting.ID(), newroutingstep.Name(), unit.ID() );
    //  info( '------------------', operation.Name(), routingstep.Name(), newroutingstep.Name() );
      stockingpoint := StockingPoint_MP::FindCreateUpdate( routing.MacroPlan(), spname, unit, newrouting, true );
      
      traverse( operation, OperationBOM, obom, not obom.IsInput() ){
        pisp := obom.PISPNodeInRouting().ProductInStockingPoint_MP();
    //    info( 'before----', ',', obom.StockingPointID(), pisp.StockingPointID(), pisp.ProductID() );
        obom.OldStockingPointID( obom.StockingPointID() );
        newpisp := pisp.Product_MP().AddToStockingPoint( stockingpoint );
    //    obom.PISPNodeInRouting().ProductInStockingPoint_MP( relset, newpisp );
        obom.PISPNodeInRouting().Update( newpisp.Product_MP(), newpisp.StockingPoint_MP() );
    //    afterpisp := obom.PISPNodeInRouting().ProductInStockingPoint_MP();
        obom.UpdateTypeIndex( obom.OperationID(), obom.ProductID(), stockingpoint.ID(), obom.IsInput() );
    //    info( 'after----', obom.StockingPointID(), afterpisp.StockingPointID(), afterpisp.ProductID() );
      }
    //  info( '------------------------------', operation.SourceOperationLink( relsize ) );
      
      operation.Copy( newroutingstep, stockingpoint, id, unit );
    }
    
    traverse( newrouting, RoutingStep.Operation.SourceOperationLink, ol )
    {
      ol.SynchronizeAll( false );
    }
    
    newroutings.Add( routing );
    
    return &newroutings;
  *]
}