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 ++++++++++++++++++++++++----
 _Main/BL/Type_ExportXMLManager/Method_Export.qbl                                                               |    2 
 _Main/UI/MacroPlannerWebApp/Component_FormAnnualPlanReport/Response_pExport_bExport_OnClick.def                |    2 
 _Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_Create.qbl                                                |   14 ++++++-
 _Main/BL/Type_LocalCell_ScheduleSummary#859/StaticMethod_AsyncExport.qbl                                       |    5 +-
 _Main/BL/Type_LocalCell_ScheduleSummary/Attribute_IsFristWeekData.qbl                                          |    7 +++
 _Main/UI/MacroPlannerWebApp/Component_FormScheduleSummaryReport/Response_PanelRibbon322_88_bExport_OnClick.def |   15 +++++++
 _Main/BL/Type_MP_Column/Function_CalcIndex.qbl                                                                 |    4 ++
 8 files changed, 91 insertions(+), 16 deletions(-)

diff --git a/_Main/BL/Type_ExportXMLManager/Method_Export.qbl b/_Main/BL/Type_ExportXMLManager/Method_Export.qbl
index c8ae706..ac0161e 100644
--- a/_Main/BL/Type_ExportXMLManager/Method_Export.qbl
+++ b/_Main/BL/Type_ExportXMLManager/Method_Export.qbl
@@ -11,7 +11,7 @@
       tableHandle := TableHandle::ImportXML( BinaryValue::Construct( this.FinalXML()));
     }onerror{
       this.Delete();
-      error( e );
+      error( e.GeneralInformation() );
     }
     tableGroupHandle.Add( tableHandle );
     binaryData := XLS::SaveTableGroupToBinaryData( tableGroupHandle, true );
diff --git "a/_Main/BL/Type_LocalCell_ScheduleSummary\043859/StaticMethod_AsyncExport.qbl" "b/_Main/BL/Type_LocalCell_ScheduleSummary\043859/StaticMethod_AsyncExport.qbl"
index 278275c..cb0c460 100644
--- "a/_Main/BL/Type_LocalCell_ScheduleSummary\043859/StaticMethod_AsyncExport.qbl"
+++ "b/_Main/BL/Type_LocalCell_ScheduleSummary\043859/StaticMethod_AsyncExport.qbl"
@@ -3,7 +3,8 @@
 StaticMethod AsyncExport (
   RecycleBin recycleBin,
   const constcontent LocalRows rows,
-  const constcontent LocalColumns columns
+  const constcontent LocalColumns columns,
+  const Strings attributeNames
 )
 {
   TextBody:
@@ -11,7 +12,7 @@
     // rislai Jun-20-2024 (created)
     sortColumns := selectsortedset( columns,Elements,column,true,column.Index());
     
-    attributeNames := LocalCell_ScheduleSummary::GetAttributeNames();
+    // attributeNames := LocalCell_ScheduleSummary::GetAttributeNames();
     
     columnstring := emit( "" );
     flag := true;
diff --git a/_Main/BL/Type_LocalCell_ScheduleSummary/Attribute_IsFristWeekData.qbl b/_Main/BL/Type_LocalCell_ScheduleSummary/Attribute_IsFristWeekData.qbl
new file mode 100644
index 0000000..002fadd
--- /dev/null
+++ b/_Main/BL/Type_LocalCell_ScheduleSummary/Attribute_IsFristWeekData.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute IsFristWeekData
+{
+  #keys: '3[414996.1.43574725][414996.1.43574724][414996.1.43574726]'
+  ValueType: Boolean
+}
diff --git a/_Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_Create.qbl b/_Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_Create.qbl
index cc699fc..3f4b090 100644
--- a/_Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_Create.qbl
+++ b/_Main/BL/Type_LocalCell_ScheduleSummary/StaticMethod_Create.qbl
@@ -15,7 +15,8 @@
     table := owner.MP_Table( relnew,Name := MP_Cell_ScheduleSummary::GetTableName());
     
     startDate := owner.StartOfPlanning().Date();
-    endDate := startDate + 7;
+    
+    endDate := maxselect( owner,Unit.UnitPeriod.astype( UnitPeriodTime ).Period_MP,period,period.TimeUnit() = Translations::MP_GlobalParameters_Day(),period.EndDate()).EndDate();
     
     columns := construct( MP_Columns );
     columnIndexTree := NamedValueTree::Create();
@@ -54,7 +55,14 @@
             capacity := workDay * throughput * workHours.Capacity().HoursAsReal()
           }
           
+          isFirstWeekData := true;
+          
+          if( column.CustomDate() > startDate + 7 ){
+            isFirstWeekData := false; 
+          }
+          
           row.MP_Cell( relnew,MP_Cell_ScheduleSummary,MP_Column := column,
+                       IsFristWeekData := isFirstWeekData,
                        ShiftPattern := unitPeriodTime.ShiftPatternName(),
                        WorkingDay := workDay,
                        Capacity := capacity,
@@ -62,7 +70,9 @@
         }
       }
     }
-    
+    traverse( table,MP_Column,column,column.MP_Cell( relsize ) = 0 ){
+      column.Delete(); 
+    }
     return table;
   *]
 }
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 );
        }
     }
     
diff --git a/_Main/BL/Type_MP_Column/Function_CalcIndex.qbl b/_Main/BL/Type_MP_Column/Function_CalcIndex.qbl
index 8319f34..2b7712e 100644
--- a/_Main/BL/Type_MP_Column/Function_CalcIndex.qbl
+++ b/_Main/BL/Type_MP_Column/Function_CalcIndex.qbl
@@ -12,9 +12,13 @@
     index := [String]year;
     if( month < 10 ){
       index := index + "0" + [String]month; 
+    }else{
+      index := index + [String]month; 
     }
     if( day < 10 ){
       index := index + "0" + [String]day; 
+    }else{
+      index := index + [String]day; 
     }
     
     
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormAnnualPlanReport/Response_pExport_bExport_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormAnnualPlanReport/Response_pExport_bExport_OnClick.def
index 0f71325..31bd86a 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormAnnualPlanReport/Response_pExport_bExport_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormAnnualPlanReport/Response_pExport_bExport_OnClick.def
@@ -11,7 +11,7 @@
     [*
       rows := selectset( dhComparisonData854.Data(),LocalRow,row,exists( dhFinelProduct.Data(),Elements,entity,entity.ID() = row.ProductID()) and exists( dhFinelStockingPoint.Data(),Elements,entity,entity.DisplayName() = row.StockingPointID())); 
       columns := selectset( dhComparisonData854.Data(),LocalColumn,column,dhStartDate.Data() <= column.Date() and dhEndDate.Data() > column.Date() );
-      LocalCell_ScheduleSummary::AsyncExport( RecycleBin,rows,columns );
+      LocalCell_Default::AsyncExport( RecycleBin,rows,columns );
       //Application.Download( "浜у嚭瀵煎叆妯℃澘.xlsx",data.AsBinaryData() );
     *]
     GroupServerCalls: false
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormScheduleSummaryReport/Response_PanelRibbon322_88_bExport_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormScheduleSummaryReport/Response_PanelRibbon322_88_bExport_OnClick.def
index 71cef3e..954011e 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormScheduleSummaryReport/Response_PanelRibbon322_88_bExport_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormScheduleSummaryReport/Response_PanelRibbon322_88_bExport_OnClick.def
@@ -11,7 +11,20 @@
     [*
       rows := selectset( dhComparisonData854.Data(),LocalRow,row,exists( dhFinelEntity.Data(),Elements,entity,entity.DisplayName() = row.Name() ));
       columns := selectset( dhComparisonData854.Data(),LocalColumn,column,dhStartDate.Data() <= column.Date() and dhEndDate.Data() > column.Date() );
-      LocalCell_ScheduleSummary::AsyncExport( RecycleBin,rows,columns );
+      attrbutes := construct( Strings );
+      if( cbShiftPlan.Checked() ){
+        attrbutes.Add( "ShiftPattern" ); 
+      }
+      if( cbWorkday.Checked() ){
+        attrbutes.Add( "WorkingDay" ); 
+      }
+      if( cbCapacity.Checked() ){
+        attrbutes.Add( "Capacity" ); 
+      }
+      if( cbOutput.Checked() ){
+        attrbutes.Add( "Output" ); 
+      } 
+      LocalCell_ScheduleSummary::AsyncExport( RecycleBin,rows,columns ,attrbutes );
       //Application.Download( "浜у嚭瀵煎叆妯℃澘.xlsx",data.AsBinaryData() );
     *]
     GroupServerCalls: false

--
Gitblit v1.9.3