Quintiq file version 2.0
|
#parent: #root
|
StaticMethod Create (
|
MacroPlan owner
|
) as MP_Table
|
{
|
TextBody:
|
[*
|
// rislai Aug-6-2024 (created)
|
table := select( owner,MP_Table,table,table.Name() = MP_Cell_ScheduleSummary::GetTableName() );
|
if( not isnull( table )){
|
table.Delete();
|
}
|
|
table := owner.MP_Table( relnew,Name := MP_Cell_ScheduleSummary::GetTableName());
|
|
startDate := owner.StartOfPlanning().Date();
|
|
endDate := maxselect( owner,Unit.UnitPeriod.astype( UnitPeriodTime ).Period_MP,period,period.TimeUnit() = Translations::MP_GlobalParameters_Day(),period.EndDate()).EndDate();
|
|
columns := construct( MP_Columns );
|
columnIndexTree := NamedValueTree::Create();
|
for( i := startDate;i < endDate; i := i + 1){
|
column := table.MP_Column( relnew,CustomDate := i );
|
columnHandle := columnIndexTree.GetHandle( i.AsQUILL() );
|
columns.Add( column );
|
columnIndexTree.Root().AddChild( columnHandle,columns.Size() - 1 );
|
}
|
|
traverse( owner,Unit,unit,unit.HasCapacityTypeTime() and not unit.HasChild()){
|
// unit.AsEntity().DisplayNameForSelection()
|
row := table.MP_Row( relnew,CustomName := unit.ID(),Index := table.GetRowIndexCache() );
|
throughput := guard( sum( unit,Operation,operation,operation.Throughput() ) / unit.Operation( relsize ) , 0 );
|
|
unitPeriodTimes := selectset( unit,UnitPeriod.astype( UnitPeriodTime ),unitPeriodTime,
|
unitPeriodTime.Period_MP().StartDate() >= startDate
|
and unitPeriodTime.Period_MP().EndDate() <= endDate
|
and unitPeriodTime.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day());
|
traverse( unitPeriodTimes,Elements,unitPeriodTime ){
|
columnHandle := columnIndexTree.GetHandle( unitPeriodTime.Period_MP().StartDate().AsQUILL() );
|
columnIndex := guard( columnIndexTree.Root().Child( columnHandle ),null( NamedValue ));
|
if( not isnull( columnIndex )){
|
// 当arrowedAvailableCapacity不为0,工作日 + 1
|
arrowedAvailableCapacity := unitPeriodTime.TotalAvailableCapacity();
|
zeroDuration := Duration::Construct( 0,0,0,0 );
|
|
column := columns.Element( columnIndex.GetValueAsNumber() );
|
|
dayOfWeek := column.CustomDate().DayOfWeek();
|
workHours := select( unitPeriodTime,ShiftPattern.ShiftDay,shifDay,shifDay.Day_MP().ID() = dayOfWeek );
|
capacity := 0.0;
|
|
workDay := ifexpr( arrowedAvailableCapacity <> zeroDuration, 1,0 );
|
if( not isnull( workHours )){
|
capacity := workDay * throughput * workHours.Capacity().HoursAsReal()
|
}
|
|
isFirstWeekData := true;
|
|
if( column.CustomDate() > startDate + 7 ){
|
isFirstWeekData := false;
|
}
|
|
row.MP_Cell( relnew,MP_Cell_ScheduleSummary,MP_Column := column,
|
IsFristWeekData := isFirstWeekData,
|
ShiftPattern := unitPeriodTime.ShiftPatternName(),
|
WorkingDay := workDay,
|
Capacity := capacity,
|
Output := 0 );
|
}
|
}
|
}
|
traverse( table,MP_Column,column,column.MP_Cell( relsize ) = 0 ){
|
column.Delete();
|
}
|
return table;
|
*]
|
}
|