From b2a7528d89d6e01276b2667f6620ee709ac3281b Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期四, 29 八月 2024 16:56:00 +0800
Subject: [PATCH] 修复计划汇总报表的一些bug

---
 _Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_CreateFullTable.qbl |   58 +++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/_Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_CreateFullTable.qbl b/_Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_CreateFullTable.qbl
index 557d70d..7da96f0 100644
--- a/_Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_CreateFullTable.qbl
+++ b/_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 );
        }
     }
     

--
Gitblit v1.9.3