From b891692b0006fbe8805a97580a1fa70c6736a72e Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期五, 01 十一月 2024 16:24:50 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/VWED into dev

---
 _Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl |   75 +++++++++++++++++++++++++++----------
 1 files changed, 55 insertions(+), 20 deletions(-)

diff --git a/_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl b/_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl
index ceb56aa..353f594 100644
--- a/_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl
+++ b/_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl
@@ -8,32 +8,67 @@
   TextBody:
   [*
     // 鐢勫叞楦� Jun-25-2024 (created)
-    table      := selectobject( this, Source.Report, report, not report.IsShow() );
+    startyearmonth          := search.MacroPlan().StartOfPlanning().StartOfMonth().Date();
+    table                   := selectobject( this, Source.Report, report, not report.IsShow() );
     //娓呯┖涔嬪墠瀛樺偍鐨勬樉绀烘暟鎹�
     this.Clear( search.TimeUnit(), search.StartDate(), search.EndDate() );
     //杩囨护鍚庣殑浜у搧id
-    productids := selectuniquevalues( products, Elements, product, true, product.ID() );
-    sumrow     := this.Row( relnew, Name := 'SUM', RowNr := table.Row( relsize ) );
+    productids              := selectuniquevalues( products, Elements, product, true, product.ID() );
+    sumrow                  := this.Row( relnew, Name := 'SUM', RowNr := table.Row( relsize ) );
     traverse( table, Row, row, productids.Find( row.Name() ) >= 0 ){
-      showrow := this.Row( relnew, Name := row.Name(), RowNr := row.RowNr() );
-      
-      traverse( row, Cell, cell, cell.Column().TimeUnit() = search.TimeUnit() ){
-        column   := selectobject( this, Column, column, column.StartDate() = cell.Column().StartDate() and column.TimeUnit() = search.TimeUnit() );
-        
-        if( not isnull( column ) ){
-          sumcell  := selectobject( column, Cell, c, c.Row() = sumrow );
-          if( isnull( sumcell ) ){
-            sumcell := MachiningPipelineCell::Initialize( column );
-            sumrow.Cell( relinsert, sumcell );
-          }
-          
-          showcell := cell.Copy( column );
-          showrow.Cell( relinsert, showcell );
-      
-          sumcell.Add( cell );
-    
+      showrow               := this.Row( relnew, Name := row.Name(), RowNr := row.RowNr() );
+      traverse( this, Column, column ){
+        daycells            := selectset( row, Cell, cell, cell.Column().TimeUnit() = Translations::MP_GlobalParameters_Day() and
+                                            cell.Column().StartDate() >= column.StartDate() and 
+                                            cell.Column().StartDate() <= column.EndDate() );
+        maxinventory        := maxobject( daycells, Elements, e, e.Column().StartDate() );
+        ccassemblyplanqty   := sum( daycells, Elements, cell, cell.CCAssemblyPlanQty() );
+        ccproductionqty     := sum( daycells, Elements, cell, cell.CCProductionQty() );
+        cctransferqty       := sum( daycells, Elements, cell, cell.CCTransferQty() );
+        ccinventoryqty      := 0.0;
+        dlassemblyplanqty   := sum( daycells, Elements, cell, cell.DLAssemblyPlanQty() );
+        dlproductionqty     := sum( daycells, Elements, cell, cell.DLProductionQty() );
+        dltransferqty       := sum( daycells, Elements, cell, cell.DLTransferQty() );
+        dlinventoryqty      := 0.0;
+        if( column.StartDate() = startyearmonth ){//褰撴棩鏈熸槸璁″垝寮�濮嬬涓�涓湀鏃讹紝璁$畻搴撳瓨鏄疄闄呭簱瀛�
+          ccinventoryqty    := row.CCInventoryQty() + maxinventory.CCProductionQty() - maxinventory.CCToDLDepartureQty() + maxinventory.DLToCCArrivalQty() - maxinventory.CCAssemblyPlanQty();
+          dlinventoryqty    := row.DLInventoryQty() + maxinventory.DLProductionQty() - maxinventory.DLToCCDepartureQty() + maxinventory.CCToDLArrivalQty() - maxinventory.DLAssemblyPlanQty();
+        }else{
+          beforecolumn      := column.PreviousColumn();
+          beforeinventory   := selectobject( showrow, Cell, c, c.Column() = beforecolumn );
+          ccinventoryqty    := beforeinventory.CCInventoryQty() + maxinventory.CCProductionQty() - maxinventory.CCToDLDepartureQty() + maxinventory.DLToCCArrivalQty() - maxinventory.CCAssemblyPlanQty();
+          dlinventoryqty    := beforeinventory.DLInventoryQty() + maxinventory.DLProductionQty() - maxinventory.DLToCCDepartureQty() + maxinventory.DLToCCDepartureQty() - maxinventory.DLAssemblyPlanQty();
         }
+        sumcell  := selectobject( column, Cell, c, c.Row() = sumrow );
+        if( isnull( sumcell ) ){
+          sumcell           := column.Cell( relnew, CCAssemblyPlanQty  := 0, 
+                                             CCProductionQty           := 0, 
+                                             CCTransferQty             := 0,
+                                             CCInventoryQty            := 0, 
+                                             DLAssemblyPlanQty         := 0,
+                                             DLProductionQty           := 0, 
+                                             DLTransferQty             := 0,
+                                             DLInventoryQty            := 0 );
+          sumrow.Cell( relinsert, sumcell );
+        }
+        showcell            := column.Cell( relnew, CCAssemblyPlanQty  := ccassemblyplanqty, 
+                                             CCProductionQty           := ccproductionqty, 
+                                             CCTransferQty             := cctransferqty,
+                                             CCInventoryQty            := ccinventoryqty, 
+                                             DLAssemblyPlanQty         := dlassemblyplanqty,
+                                             DLProductionQty           := dlproductionqty, 
+                                             DLTransferQty             := dltransferqty,
+                                             DLInventoryQty            := dlinventoryqty );
+        showrow.Cell( relinsert, showcell );
+      
+        sumcell.Add( showcell );
       }
     }
+    rows                    := selectsortedset( this, Row, row, row.Name(), row.RowNr() );
+    i                       := 0;
+    traverse( rows, Elements, e ){
+      e.RowNr( i );
+      i                     := i + 1;
+    }
   *]
 }

--
Gitblit v1.9.3