lazhen
2024-08-30 63de54ec601c2b1c6c62b011442458d963ef9036
_Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_CreateFullTable.qbl
@@ -35,12 +35,33 @@
       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() );
    
    localRows := construct( LocalRows );
    localRowIndexTree := NamedValueTree::Create();
    localCells := construct( LocalCell_ScheduleSummarys );
    localCellIndexTree := NamedValueTree::Create();
    //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,cell.MP_Column().CustomDate() >= localColumn.CustomDate() and cell.MP_Column().CustomDate() < localColumn.CustomDate().StartOfNextMonth() );
          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() );
          
          output := 0.0;
          
@@ -61,7 +82,15 @@
          traverse( cells,Elements,cell ){
             workingDay := workingDay + cell.WorkingDay();
             capacity := capacity + cell.Capacity();
    //         shiftPatternHanlde := shiftPatternCount.GetHandle( cell.ShiftPattern() );
    //         shiftPatternCountValue := guard( shiftPatternCount.Root().Child( shiftPatternHanlde ),null( NamedValue ));
    //         if( isnull( shiftPatternCountValue )){
    //           shiftPatternCount.Root().AddChild( shiftPatternHanlde,1 );
    //         }else{
    //           shiftPatternCountValue.SetValue( shiftPatternCountValue.GetValueAsNumber() + 1 );
    //         }
             if( maxShiftPattern <> cell.ShiftPattern() ){
               if( maxShiftPatternCount = 0 ){
                  maxShiftPattern := cell.ShiftPattern();
@@ -73,12 +102,23 @@
                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() );
            }
          }
          
          localCell := localRow.LocalCell( relnew,LocalCell_ScheduleSummary,LocalColumn := localColumn );
          localCell.ShiftPattern( maxShiftPattern );
          localCell.WorkingDay( workingDay );
          localCell.Capacity( capacity );
          localCell.Output( output );
          localCell.WorkingDay( localCell.WorkingDay() + workingDay );
          localCell.Capacity( localCell.Capacity() + capacity );
          localCell.Output( localCell.Output() + output );
       }
    }