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 );
|
}
|
|
localRows := construct( LocalRows );
|
localRowIndexTree := NamedValueTree::Create();
|
|
localCells := construct( LocalCell_ScheduleSummarys );
|
localCellIndexTree := NamedValueTree::Create();
|
|
units := selectset( owner,Unit,unit,unit.HasCapacityTypeTime() and not unit.HasChild());
|
unitIndexTree := NamedValueTree::Create();
|
for( i := 0 ; i< units.Size() ; i++ ){
|
unit := units.Element( i );
|
unitHandle := unitIndexTree.GetHandle( unit.ID() );
|
unitIndexTree.Root().AddChild( unitHandle,i );
|
}
|
|
|
//shiftPatternCount := NamedValueTree::Create();
|
traverse( tables,Elements.MP_Row,row ){
|
rowMacroPlan := row.MP_Table().MacroPlan();
|
localRow := null( LocalRow );
|
{
|
localRowHandle := localRowIndexTree.GetHandle( row.Name() );
|
localRowIndex := guard( localRowIndexTree.Root().Child( localRowHandle ),null( NamedValue ));
|
if( isnull( localRowIndex )){
|
localRow := localTable.LocalRow( relnew,CustomName := row.Name(),Index := localTable.GetRowIndexCache() );
|
localRows.Add( localRow );
|
localRowIndexTree.Root().AddChild( localRowHandle,localRows.Size() - 1 );
|
}else{
|
localRow := localRows.Element( localRowIndex.GetValueAsNumber());
|
}
|
}
|
traverse( localColumns,Elements,localColumn ){
|
cells := selectset( row,MP_Cell.astype( MP_Cell_ScheduleSummary ),cell,
|
ifexpr( rowMacroPlan = owner , true , cell.IsFristWeekData()) and
|
cell.MP_Column().CustomDate() >= localColumn.CustomDate() and
|
cell.MP_Column().CustomDate() < localColumn.CustomDate().StartOfNextMonth() );
|
|
isFuture := owner.StartOfPlanning().Date() < localColumn.CustomDate();
|
|
output := 0.0;
|
if( isFuture ){
|
unitHandle := unitIndexTree.GetHandle( row.Name() );
|
unitIndex := guard( unitIndexTree.Root().Child( unitHandle ),null( NamedValue ));
|
if( not isnull( unitIndex )){
|
unit := units.Element( unitIndex.GetValueAsNumber() );
|
output := sum( unit,UnitPeriod.astype( UnitPeriodTime ).PeriodTask_MP.NewSupply,np,
|
np.PeriodTask_MP().UnitPeriod().StartDate() >= localColumn.CustomDate() and
|
np.PeriodTask_MP().UnitPeriod().StartDate() < localColumn.CustomDate().StartOfNextMonth() and
|
np.PeriodTask_MP().UnitPeriod().Period_MP().TimeUnit() = "Day",
|
np.Quantity() );
|
output := sum( unit,StockingPoint_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod,pispip,
|
pispip.Period_MP().StartDate() >= localColumn.CustomDate() and
|
pispip.Period_MP().StartDate() < localColumn.CustomDate().StartOfNextMonth() and
|
pispip.Period_MP().TimeUnit() = "Day",
|
pispip.NewSupplyProductionQuantity());
|
}
|
}else{
|
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 := null( LocalCell_ScheduleSummary );
|
{
|
localCellHandle := localCellIndexTree.GetHandle( row.Name() + localColumn.CustomDate().AsQUILL() );
|
localCellIndex := guard( localCellIndexTree.Root().Child( localCellHandle ),null( NamedValue ));
|
if( isnull( localCellIndex )){
|
localCell := localRow.LocalCell( relnew,LocalCell_ScheduleSummary,LocalColumn := localColumn );
|
localCells.Add( localCell );
|
localCellIndexTree.Root().AddChild( localCellHandle , localCells.Size() - 1 );
|
}else{
|
localCell := localCells.Element( localCellIndex.GetValueAsNumber() );
|
}
|
}
|
|
if( not maxShiftPattern = "" ){
|
localCell.ShiftPattern( maxShiftPattern );
|
}
|
localCell.WorkingDay( localCell.WorkingDay() + workingDay );
|
localCell.Capacity( localCell.Capacity() + capacity );
|
localCell.Output( localCell.Output() + output );
|
}
|
}
|
|
traverse( localTable,LocalRow.LocalCell.astype( LocalCell_ScheduleSummary ),cell ){
|
cell.Capacity( cell.Capacity() / tables.Size() );
|
cell.Output( cell.Output() / tables.Size() );
|
}
|
|
//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;
|
*]
|
}
|