陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
Quintiq file version 2.0
#parent: #root
StaticMethod CreateProductInTripMessage (
  MacroPlan macroplan
)
{
  Description: 'Create sanity check message for feedback.'
  TextBody:
  [*
    // Get the limit for number of sanity check messages
    messagelimit := macroplan.GlobalParameters_MP().SanityCheckLimit();
    
    // Get ProductInTrips that has sanity check violation(s)
    invalidobjects := selectsortedset( macroplan, 
                                       SanityCheckGroup.astype( SanityCheckGroupFeedback ).InvalidProductInTrip,
                                       invalidobject,
                                       true,
                                       invalidobject.SanityCheckFeedbackMostSevere() );
                                       
    objcount := 0;
    // Traverse the set of ProductInTrips and create sanity check message
    // as long as the number of ProductInTrips processed doesn't exceed the limit of number of messages
    traverse( invalidobjects,
              Elements,
              invalidobject,
              objcount <= messagelimit )
    {
      objcount := objcount + 1;
      feedbacks := construct( Strings );
      sanitycheckfeedbacks := construct( Strings );
      
      // Get sanity check violation messages and categories
      invalidobject.DoSanityCheckGroupFeedback( feedbacks, sanitycheckfeedbacks );
    
      i := 0;
      // Traverse each sanity check violation feedbacks
      traverse( feedbacks, Elements, fb )
      {
        // Check if there're any SanityCheckMessageFeedback with the same description, if there's none, create one
        if( not exists( invalidobject, SanityCheckMessageFeedback, msg, msg.Description() = fb ) )
        {
          //tokenize msg to retrieve category level and seperate the actual feedback
          sanitycheckmessage := SanityCheckMessageFeedback::Create( invalidobject.SanityCheckGroupFeedback(),
                                                                    fb, 
                                                                    true,
                                                                    sanitycheckfeedbacks.Element( i ) );
          sanitycheckmessage.ProductInTrip( relset, invalidobject );
        }
        i := i + 1;
      }
    }
  *]
}