Quintiq file version 2.0
|
#parent: #root
|
StaticMethod BatchSetUnitShiftPatternByMonth (
|
Unit unit,
|
ShiftPattern shiftPattern,
|
Date startDate,
|
Date endDate,
|
Number skipMonth
|
)
|
{
|
TextBody:
|
[*
|
// Akari Oct-10-2024 (created)
|
owner := unit.MacroPlan();
|
|
saveMonths := construct( Numbers );
|
|
for( i := LocalTool::GetYYYYMM( startDate ); i < LocalTool::GetYYYYMM( endDate ) ; i := LocalTool::AddMonthByYYYYMM( i,skipMonth ) ){
|
|
saveMonths.Add( i );
|
|
}
|
|
|
dayPeriod_MPs := selectsortedset( owner,Period_MP,period_MP,
|
period_MP.TimeUnit() = 'Day' and
|
period_MP.StartDate() >= startDate and
|
period_MP.EndDate() <= endDate and exists( saveMonths, Elements,month,month = LocalTool::GetYYYYMM( period_MP.StartDate() )) ,period_MP.StartDate());
|
weekPeriod_MPs := selectsortedset( owner,Period_MP,period_MP,
|
period_MP.TimeUnit() = 'Week' and
|
period_MP.StartDate() >= startDate and
|
period_MP.EndDate() <= endDate and exists( saveMonths, Elements,month,month = LocalTool::GetYYYYMM( period_MP.StartDate() )) ,period_MP.StartDate());
|
monthPeriod_MPs := selectsortedset( owner,Period_MP,period_MP,
|
period_MP.TimeUnit() = 'Month' and
|
period_MP.StartDate() >= startDate and
|
period_MP.EndDate() <= endDate and exists( saveMonths, Elements,month,month = LocalTool::GetYYYYMM( period_MP.StartDate() )) ,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()));
|
if( unitPeriodTimes.Size() > 0 ){
|
info( unitPeriodTimes.Size() );
|
LocalTool::SetUnitShiftPattern( owner,unitPeriodTimes,shiftPattern );
|
}
|
}
|
if( weekPeriod_MPs.Size() <> 0 ){
|
unitPeriodTimes := selectset( unit,UnitPeriod.astype( UnitPeriodTime ),unitPeriodTime,exists( weekPeriod_MPs,Elements,period_MP,period_MP = unitPeriodTime.Period_MP()));
|
if( unitPeriodTimes.Size() > 0 ){
|
LocalTool::SetUnitShiftPattern( owner,unitPeriodTimes,shiftPattern );
|
}
|
}
|
if( monthPeriod_MPs.Size() <> 0 ){
|
unitPeriodTimes := selectset( unit,UnitPeriod.astype( UnitPeriodTime ),unitPeriodTime,exists( monthPeriod_MPs,Elements,period_MP,period_MP = unitPeriodTime.Period_MP()));
|
if( unitPeriodTimes.Size() > 0 ){
|
LocalTool::SetUnitShiftPattern( owner,unitPeriodTimes,shiftPattern );
|
}
|
}
|
*]
|
}
|