From 74ac81ac91be18a076a27ecee4045aac0d9b5ad9 Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期五, 17 一月 2025 08:17:33 +0800
Subject: [PATCH] 机加管线报表周度库存数据问题

---
 _Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl          |   23 +++--------------------
 _Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl |   31 +++++++++++++++++++++++++------
 2 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl b/_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl
index aacfb9e..65b4909 100644
--- a/_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl
+++ b/_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl
@@ -8,7 +8,7 @@
   TextBody:
   [*
     // 鐢勫叞楦� Jun-25-2024 (created)
-    startyearmonth          := search.MacroPlan().StartOfPlanning().StartOfMonth().Date();
+    //startyearmonth          := search.MacroPlan().StartOfPlanning().StartOfMonth().Date();
     table                   := selectobject( this, Source.Report, report, not report.IsShow() );
     //娓呯┖涔嬪墠瀛樺偍鐨勬樉绀烘暟鎹�
     this.Clear( search.TimeUnit(), search.StartDate(), search.EndDate() );
@@ -25,26 +25,9 @@
         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 );
-          beCCinventoryqty  := 0.0;
-          beDLinventoryqty  := 0.0;
-          if( not isnull( beforeinventory ) ){
-            beCCinventoryqty := beforeinventory.CCInventoryQty();
-            beDLinventoryqty := beforeinventory.DLInventoryQty();
-          }
-          ccinventoryqty    := beCCinventoryqty + maxinventory.CCProductionQty() - maxinventory.CCToDLDepartureQty() + maxinventory.DLToCCArrivalQty() - maxinventory.CCAssemblyPlanQty();
-          dlinventoryqty    := beDLinventoryqty + 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, 
@@ -60,11 +43,11 @@
         showcell            := column.Cell( relnew, CCAssemblyPlanQty  := ccassemblyplanqty, 
                                              CCProductionQty           := ccproductionqty, 
                                              CCTransferQty             := cctransferqty,
-                                             CCInventoryQty            := ccinventoryqty, 
+                                             CCInventoryQty            := maxinventory.CCInventoryQty(), 
                                              DLAssemblyPlanQty         := dlassemblyplanqty,
                                              DLProductionQty           := dlproductionqty, 
                                              DLTransferQty             := dltransferqty,
-                                             DLInventoryQty            := dlinventoryqty );
+                                             DLInventoryQty            := maxinventory.DLInventoryQty() );
         showrow.Cell( relinsert, showcell );
       
         sumcell.Add( showcell );
diff --git a/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl b/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
index 812c079..2b2e303 100644
--- a/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
@@ -9,6 +9,7 @@
     // 鐢勫叞楦� Jun-24-2024 (created)
     owner.FinancialProductionSource( relflush );
     startinventorydate        := owner.StartOfPlanning() - Duration::Days( 1 );
+    startyearmonth            := owner.StartOfPlanning().StartOfMonth().Date();
     productparent             := MachiningPipelineReport::GetDefaultProductParent();
     source                    := owner.MachiningPipelineSource( relnew, Name := MachiningPipelineReport::GetDefaultName() );
     table                     := source.Report( relnew, ID := source.Name(), Name := source.Name() );
@@ -140,12 +141,30 @@
       }
     }
     
-    //rows := selectsortedset( table, Row, row, row.Name() );
-    //i    := 0;
-    //traverse( rows, Elements, e ){
-    //  e.RowNr( i );
-    //  i := i + 1;
-    //}
+    traverse( table, Row, row ){
+      traverse( table, Column, column, column.TimeUnit() = Translations::MP_GlobalParameters_Day() ){
+        maxinventory        := selectobject( row, Cell, cell, cell.Column() = column );
+        ccinventoryqty      := 0.0;
+        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( row, Cell, c, c.Column() = beforecolumn );
+          beCCinventoryqty  := 0.0;
+          beDLinventoryqty  := 0.0;
+          if( not isnull( beforeinventory ) ){
+            beCCinventoryqty := beforeinventory.CCInventoryQty();
+            beDLinventoryqty := beforeinventory.DLInventoryQty();
+          }
+          ccinventoryqty    := beCCinventoryqty + maxinventory.CCProductionQty() - maxinventory.CCToDLDepartureQty() + maxinventory.DLToCCArrivalQty() - maxinventory.CCAssemblyPlanQty();
+          dlinventoryqty    := beDLinventoryqty + maxinventory.DLProductionQty() - maxinventory.DLToCCDepartureQty() + maxinventory.CCToDLArrivalQty() - maxinventory.DLAssemblyPlanQty();
+        }
+        maxinventory.CCInventoryQty( ccinventoryqty );
+        maxinventory.DLInventoryQty( dlinventoryqty );
+      }
+    }
     showtable.Generate( search, products );
   *]
 }

--
Gitblit v1.9.3