From 2216fba3cc0585064f370ae8348bf6b90ef99e5a Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期二, 03 九月 2024 18:03:34 +0800
Subject: [PATCH] 修复一些bug

---
 _Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_CreateFullTable.qbl |   40 ++++++++++++++++++++++++++++++++--------
 1 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/_Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_CreateFullTable.qbl b/_Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_CreateFullTable.qbl
index 7da96f0..8c27522 100644
--- a/_Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_CreateFullTable.qbl
+++ b/_Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_CreateFullTable.qbl
@@ -42,6 +42,15 @@
     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();
@@ -63,14 +72,27 @@
                               cell.MP_Column().CustomDate() >= localColumn.CustomDate() and 
                               cell.MP_Column().CustomDate() < localColumn.CustomDate().StartOfNextMonth() );
           
-          output := 0.0;
+          isFuture := owner.StartOfPlanning().Date() >= localColumn.CustomDate();
           
-          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();
+          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.PeriodTask_MP.NewSupply,np,
+                             np.PeriodTask_MP().UnitPeriod().StartDate() >= localColumn.CustomDate() and 
+                             np.PeriodTask_MP().UnitPeriod().StartDate() < localColumn.CustomDate(),
+                             np.Quantity() );
+            }
+          }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 := "";
@@ -115,7 +137,9 @@
             }
           }
           
-          localCell.ShiftPattern( maxShiftPattern );
+          if( not maxShiftPattern = "" ){
+            localCell.ShiftPattern( maxShiftPattern );
+          }
           localCell.WorkingDay( localCell.WorkingDay() + workingDay );
           localCell.Capacity( localCell.Capacity() + capacity );
           localCell.Output( localCell.Output() + output );

--
Gitblit v1.9.3