lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
Quintiq file version 2.0
#parent: #root
StaticMethod CreateOrUpdateForUnitPeriodTimes (
  UnitPeriodTimes unitperiodtimes,
  Boolean isbatcheditmaintenance,
  String timeunit,
  Duration maintenance,
  Boolean isbatcheditefficiency,
  Real efficiency,
  Boolean isbatcheditallocation,
  Real allocation,
  Boolean isbatcheditshiftpattern,
  ShiftPattern shiftpattern,
  Boolean isbatcheditmaxloadpercentage,
  Real maxloadpercentage,
  Boolean isbatcheditnrofunitsopen,
  Number nrofunitsopen,
  Boolean isthisperiodonwards,
  Boolean isbatcheditminimumloadthreshold,
  Real minimumloadthreshold
)
{
  Description: 'Edit unit availability from context menu of the unit period list in UI.'
  TextBody:
  [*
    // soh yee Sep-16-2012 (created)
    
    // Sort descendingly.
    // For merging purpose ( not implemented yet ) and for avoiding of creating unit availability with all having same time unit when all unit period times do not have a unit availability
    unitperiodtimes.Sort( attribute( UnitPeriodTime, Start ), false );
    traverse( unitperiodtimes, Elements, upt )
    {
      UnitAvailability::CreateOrUpdateForUnitPeriodTime( upt,
                                                         isbatcheditmaintenance,
                                                         timeunit,
                                                         maintenance,
                                                         isbatcheditefficiency,
                                                         efficiency,
                                                         isbatcheditallocation,
                                                         allocation,
                                                         isbatcheditshiftpattern,
                                                         shiftpattern,
                                                         isbatcheditmaxloadpercentage,
                                                         maxloadpercentage,
                                                         isbatcheditnrofunitsopen,
                                                         nrofunitsopen,
                                                         isthisperiodonwards,
                                                         isbatcheditminimumloadthreshold,
                                                         minimumloadthreshold
                                                       );
    
      // Without this all the relations will only set at the end of this method.
      Transaction::Transaction().Propagate();
    }
    
    // Get all units and clean up their transport capacities to remove repetition
    units := selectset( unitperiodtimes.Element( 0 ).MacroPlan(), Unit, unit, 
                        unit.UnitAvailability( relsize ) > 0 );
    
    UnitAvailability::RemoveRedundant( units );
  *]
}