| | |
| | | ShiftPattern shiftPattern, |
| | | Date startDate, |
| | | Date endDate, |
| | | Numbers weekdays |
| | | Numbers weekdays, |
| | | Number skipWeek |
| | | ) |
| | | { |
| | | TextBody: |
| | | [* |
| | | // Akari Oct-10-2024 (created) |
| | | owner := unit.MacroPlan(); |
| | | |
| | | saveDays := construct( Dates ); |
| | | flag := startDate.StartOfNextWeek(); |
| | | for( i := startDate; i<endDate; i := i + 1 ){ |
| | | if( i < flag ){ |
| | | saveDays.Add( i ); |
| | | }else{ |
| | | temp := skipWeek - 1; |
| | | while( temp > 0 ){ |
| | | i := flag; |
| | | flag := i.StartOfNextWeek(); |
| | | temp--; |
| | | |
| | | info( i.Format( "Y-M2-D2") ); |
| | | info( flag.Format( "Y-M2-D2") ); |
| | | } |
| | | } |
| | | } |
| | | |
| | | info( "----------------------------"); |
| | | |
| | | traverse( saveDays,Elements,element ){ |
| | | info( element.Format( "Y-M2-D2")); |
| | | } |
| | | |
| | | dayPeriod_MPs := selectsortedset( owner,Period_MP,period_MP, |
| | | period_MP.TimeUnit() = 'Day' and |
| | | period_MP.StartDate() >= startDate and |
| | |
| | | period_MP.StartDate() >= startDate and |
| | | period_MP.EndDate() <= endDate and exists( weekdays, Elements,dayOfWeek,dayOfWeek = period_MP.StartDate().DayOfWeek() ),period_MP.StartDate()); |
| | | |
| | | |
| | | if( dayPeriod_MPs.Size() > 0 ){ |
| | | unitPeriodTimes := selectset( unit,UnitPeriod.astype( UnitPeriodTime ),unitPeriodTime,exists( dayPeriod_MPs,Elements,period_MP,period_MP = unitPeriodTime.Period_MP()) and not isnull( unitPeriodTime.UnitAvailability())); |
| | | unitPeriodTimes := selectset( unit,UnitPeriod.astype( UnitPeriodTime ),unitPeriodTime,exists( dayPeriod_MPs,Elements,period_MP,period_MP = unitPeriodTime.Period_MP())); |
| | | if( unitPeriodTimes.Size() > 0 ){ |
| | | LocalTool::SetUnitShiftPattern( owner,unitPeriodTimes,shiftPattern ); |
| | | } |
| | | |
| | | } |
| | | if( weekPeriod_MPs.Size() <> 0 ){ |
| | | traverse( weekPeriod_MPs,Elements,period_MP ){ |
| | | unitPeriodTimes := selectset( unit,UnitPeriod.astype( UnitPeriodTime ),unitPeriodTime,period_MP = unitPeriodTime.Period_MP() and not isnull( unitPeriodTime.UnitAvailability())); |
| | | unitPeriodTimes := selectset( unit,UnitPeriod.astype( UnitPeriodTime ),unitPeriodTime,period_MP = unitPeriodTime.Period_MP()); |
| | | if( unitPeriodTimes.Size() > 0 ){ |
| | | LocalTool::SetUnitShiftPattern( owner,unitPeriodTimes,shiftPattern ); |
| | | } |