Quintiq file version 2.0
|
#parent: #root
|
StaticMethod CreateFullTable (
|
const MacroPlans owners,
|
RecycleBin recycleBin,
|
const Archive archive
|
) as LocalTable
|
{
|
TextBody:
|
[*
|
// rislai Aug-7-2024 (created)
|
tables := construct( MP_Tables );
|
traverse( owners,Elements,owner ){
|
table := select( owner,MP_Table,table,table.Name() = MP_Cell_ScheduleSummary::GetTableName() );
|
if( isnull( table )){
|
table := MP_Cell_ScheduleSummary::Create( owner );
|
}
|
tables.Add( table );
|
}
|
|
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 );
|
}
|
}
|
|
return localTable;
|
*]
|
}
|