Quintiq file version 2.0
|
#parent: #root
|
StaticMethod CreateFullTable (
|
const MacroPlans owners,
|
RecycleBin recycleBin,
|
const Archive archive,
|
const MacroPlan owner
|
) as LocalTable
|
{
|
TextBody:
|
[*
|
// rislai Aug-7-2024 (created)
|
tables := MP_Table::GetMP_Tables_ScheduleSummary( owners );
|
|
scheduleSummaryOutputDataIndexTree := NamedValueTree::Create();
|
scheduleSummaryOutputDatas := selectset( archive,ScheduleSummaryOutputLine.ScheduleSummaryOutputData,data,
|
exists( tables,Elements.MP_Row,row,row.CustomName() = data.ScheduleSummaryOutputLine().LineName() ));
|
|
for( i :=0;i < scheduleSummaryOutputDatas.Size();i++ ){
|
scheduleSummaryOutputData := scheduleSummaryOutputDatas.Element( i );
|
scheduleSummaryOutputDataKey := scheduleSummaryOutputData.ScheduleSummaryOutputLine().LineName() + scheduleSummaryOutputData.Date().AsQUILL();
|
scheduleSummaryOutputDataHandle := scheduleSummaryOutputDataIndexTree.GetHandle( scheduleSummaryOutputDataKey );
|
scheduleSummaryOutputDataIndexTree.Root().AddChild( scheduleSummaryOutputDataHandle,i );
|
}
|
|
localTable := recycleBin.LocalTable( relnew,Name := MP_Cell_ScheduleSummary::GetTableName() );
|
startDate := minselect( tables,Elements.MP_Column,column,column.CustomDate() ).CustomDate();
|
endDate := maxselect( tables,Elements.MP_Column,column,column.CustomDate() ).CustomDate();
|
|
localColumns := construct( LocalColumns );
|
localColumnIndexTree := NamedValueTree::Create();
|
for( i := startDate.StartOfMonth(); i <= endDate.StartOfMonth(); i := i.StartOfNextMonth() ){
|
localColumn := localTable.LocalColumn( relnew,CustomDate := i );
|
localColumnHandle := localColumnIndexTree.GetHandle( i.AsQUILL() );
|
localColumns.Add( localColumn );
|
localColumnIndexTree.Root().AddChild( localColumnHandle,localColumns.Size() - 1 );
|
}
|
traverse( tables,Elements.MP_Row,row ){
|
|
localRow := localTable.LocalRow( relnew,CustomName := row.Name(),Index := localTable.GetRowIndexCache() );
|
|
traverse( localColumns,Elements,localColumn ){
|
cells := selectset( row,MP_Cell.astype( MP_Cell_ScheduleSummary ),cell,cell.MP_Column().CustomDate() >= localColumn.CustomDate() and cell.MP_Column().CustomDate() < localColumn.CustomDate().StartOfNextMonth() );
|
|
output := 0.0;
|
|
scheduleSummaryOutputDataKey := row.Name() + localColumn.CustomDate().AsQUILL();
|
scheduleSummaryOutputDataHandle := scheduleSummaryOutputDataIndexTree.GetHandle( scheduleSummaryOutputDataKey );
|
scheduleSummaryOutputDataIndex := guard( scheduleSummaryOutputDataIndexTree.Root().Child( scheduleSummaryOutputDataHandle ),null( NamedValue ));
|
if( not isnull( scheduleSummaryOutputDataIndex )){
|
scheduleSummaryOutputData := scheduleSummaryOutputDatas.Element( scheduleSummaryOutputDataIndex.GetValueAsNumber() );
|
output := scheduleSummaryOutputData.Output();
|
}
|
|
maxShiftPattern := "";
|
maxShiftPatternCount := 0;
|
|
workingDay := 0;
|
capacity := 0.0;
|
|
traverse( cells,Elements,cell ){
|
workingDay := workingDay + cell.WorkingDay();
|
capacity := capacity + cell.Capacity();
|
|
if( maxShiftPattern <> cell.ShiftPattern() ){
|
if( maxShiftPatternCount = 0 ){
|
maxShiftPattern := cell.ShiftPattern();
|
maxShiftPatternCount ++;
|
}else{
|
maxShiftPatternCount --;
|
}
|
}else{
|
maxShiftPatternCount ++;
|
}
|
}
|
|
localCell := localRow.LocalCell( relnew,LocalCell_ScheduleSummary,LocalColumn := localColumn );
|
localCell.ShiftPattern( maxShiftPattern );
|
localCell.WorkingDay( workingDay );
|
localCell.Capacity( capacity );
|
localCell.Output( output );
|
}
|
}
|
|
//startDate := owner.StartOfPlanning().Date() + 7;
|
//endDate := maxselect( owner,Unit.UnitPeriod.astype( UnitPeriodTime ).Period_MP,period,period.EndDate(),period.TimeUnit() = "Month" ).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 );
|
//}
|
|
|
return localTable;
|
*]
|
}
|