yanyuan
2023-11-10 143ef74e2eeee697ac8fda3d9032a790fbb4e146
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
Quintiq file version 2.0
#parent: #root
Method GetHasNoDirectLoop (
  output Strings feedback_o,
  output Strings sanitychecklevel_o
) declarative remote as Boolean
{
  Description: 'Check if the lane leg has no direct loop (loop within 1 level, e.g. A->B and B->A)'
  TextBody:
  [*
    isvalid := true;
    
    // The loop should only be violated if both legs that are causing the loop are enabled
    
    if( this.IsEnabled() and exists( this, LaneLegInputOutput.ProductInStockingPoint_MP.Product_MP, product, product.HasShelfLifeOrMaturation() ) )
    {
      directlooplaneleg := select( this, AsDestinationStockingPointLeg.StockingPoint_MP.StockingPointInLane.OriginStockingPointLeg, o,
                                   o.IsEnabled()
                                   and o.DestinationStockingPointID() = this.OriginStockingPointID() );
     
     //check whether there are any overlap product in both laneleg                              
      productindirectlooplaneleg := selectset( directlooplaneleg, Lane.ProductInLane.Product_MP, p, p.HasShelfLifeOrMaturation() );
      currentproduct := selectset( this, Lane.ProductInLane.Product_MP, p, p.HasShelfLifeOrMaturation() );
      productoverlap := currentproduct.Intersect( productindirectlooplaneleg ); 
      
      isvalid := isnull( directlooplaneleg ) or productoverlap.Size() =0 ;
      
      if( not isnull( feedback_o ) and not isvalid )
      {
        name := MacroPlan::GetSubstituteName( this.Name() );
        feedback_o.Add( SanityCheckMessage::GetFormattedMessage( Translations::MP_Process_Instance( this.DefinitionName(), name ),
                                                                 Translations::MP_LaneLeg_ViolateHasNoDirectLoop( directlooplaneleg.Lane().Name() ) ) );
        sanitychecklevel_o.Add( SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning() );                                                           
      }
    }
    
    return isvalid;
  *]
}