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
Quintiq file version 2.0
#parent: #root
Function CalcEnd
{
  TextBody:
  [*
    tt := this.TransitionType_MP();
    value := tt.Unit().MacroPlan().StartOfPlanning();
    gapduration := Duration::Zero();
    
    if ( not isnull( this.FromCampaign() ) 
         and this.FromCampaign().HasNextTransitionDurationByOpt() and this.FromCampaign().NextTransitionDurationByOpt() > Duration::Zero() ) 
    {
      // case: end of transition determined by campaign sequence optimizer
      value := this.Start() + this.FromCampaign().NextTransitionDurationByOpt(); 
    }
    else
    {
      // case: end of transition determined by decision support system
      if( not isnull( this.ToCampaign() )
          and not isnull( this.FromCampaign() ) and this.ToCampaign().Start().IsFinite() and this.FromCampaign().End().IsFinite() )
      {
        value := this.ToCampaign().Start();
        gapduration := this.ToCampaign().Start() - this.FromCampaign().End();
      }
      
      if( gapduration > tt.DefaultDuration() )
      {
        duration := minvalue( gapduration, tt.DefaultDuration() );
        value := this.Start() + duration;  
      }
      
      if( not tt.IsDuration() and this.OperationInTransition( relsize ) > 0 )
      {
        duration := tt.DefaultDuration();
        value := this.Start() + duration
      }
      
      if( not isnull( this.FromCampaign() )
          and this.FromCampaign().HistoricalTransitionDuration() > Duration::Zero() )
      {
        duration := this.FromCampaign().HistoricalTransitionDuration();
        value := this.Start() + duration; 
      }
      
     
    }
    
    this.End( value );
  *]
}