Lai,Risheng
2023-11-02 30c02e0c981b16be0918483543f4b812956c45d4
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
Quintiq file version 2.0
#parent: #root
Method GetPlanningCapacity (
  DateTimeVector datetimevector,
  RealVector realvector
) const declarative as Duration
{
  Description: 'sum of capacity from period start to end base on shiftpattern'
  TextBody:
  [*
    duration := Duration::Zero();
    numberofdays := this.Period_MP().EndDate() - this.Period_MP().StartDate();
    
    firstday := this.Start();
    datetimes := datetimevector.AsValues();
    
    // Only calculate if there's data to start with
    if( datetimevector.Size() > 0 and realvector.Size() > 0 )
    {
      for( i := 0; i < numberofdays; i++ )
      {
        start := firstday + Duration::Days( i );
        index := datetimes.Find( start );
        if ( index >-1 )
        {
          capacityinreal := realvector.Get( index );
          duration := duration + Duration::Hours( capacityinreal );
        }  
      }
    }
    
    return duration;
  *]
}