From b3d5100ea886235b873e324e7f62d3e42a1f2176 Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期四, 17 十月 2024 11:39:32 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/VWED into dev-zlg

---
 _Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl b/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
index 9eb8dff..78add67 100644
--- a/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
+++ b/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
@@ -22,15 +22,8 @@
       // 鍒涘缓琛�
       ppr := select( macroPlan, PackagingPlanRow, tempPPR, tempPPR.ProductID() = pisp.ProductID() and tempPPR.Factory() = factory );
       if ( isnull( ppr ) ) {
-        ppr := macroPlan.PackagingPlanRow( relnew, ProductID := pisp.ProductID(), StockingPointID := pisp.StockingPointID(), Factory := factory, Category := guard( pisp.Product_MP().ParentID(), "" ) );
+        ppr := macroPlan.PackagingPlanRow( relnew, ProductID := pisp.ProductID(), Factory := factory, Category := guard( pisp.Product_MP().ParentID(), "" ) );
       }
-      
-      // 鍑哄彂鍦板簱瀛樼偣Trip
-      originTrips      := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation )      and
-                                     TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() ) );
-      // 鐩殑鍦板簱瀛樼偣Trip
-      destinationTrips := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation ) and
-                                     TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() ) );  
       
       // 寰幆pispippl
       traverse ( pisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispipl, not pispipl.IsPeriodFrozen() ) {
@@ -44,24 +37,32 @@
         cell := select( ppr, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = ppc );
         if ( isnull( cell ) ) {
           cell := ppr.PackagingPlanCell( relnew );
-          cell.NetDemand( pispipl.DependentDemandAndSalesDemandQuantity() - pispipl.NewSupplyQuantity() );
+          cell.NetDemand( pispipl.InventoryLevelEnd() + pispipl.NewSupplyQuantity() - pispipl.DependentDemandAndSalesDemandQuantity() );
           cell.EndingInventory( pispipl.InventoryLevelEnd() );
           cell.PackagingPlanColumn( relset, ppc );
         } else {
-          cell.NetDemand( cell.NetDemand() + ( pispipl.DependentDemandAndSalesDemandQuantity() - pispipl.NewSupplyQuantity() ) );
+          cell.NetDemand( cell.NetDemand() + ( pispipl.InventoryLevelEnd() + pispipl.NewSupplyQuantity() - pispipl.DependentDemandAndSalesDemandQuantity() ) );
           cell.EndingInventory( cell.EndingInventory() + pispipl.InventoryLevelEnd() );
         }
         
         // 璁剧疆璋冨嚭
-        outs := selectset( originTrips, Elements, tempT, tempT.Departure().Date() = pispipl.Start().Date() );
-        traverse ( outs, Elements.ProductInTrip, outPIT, outPIT.ProductID() = pisp.ProductID() ) {
-          cell.Out( cell.Out() + outPIT.Quantity() );
+        traverse ( pispipl, AsDeparturePISPIP, pit,
+                   pit.Quantity()                > 0                                                                         and
+                   pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation )      and
+                   TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() )
+                  ) 
+        {
+          cell.Out( cell.Out() + pit.Quantity() );
         }
         
         // 璁剧疆璋冭繘
-        transferIns := selectset( destinationTrips, Elements, tempT, tempT.Arrival().Date() = pispipl.Start().Date() );
-        traverse ( transferIns, Elements.ProductInTrip, tiPIT, tiPIT.ProductID() = pisp.ProductID() ) {
-          cell.TransferIn( cell.TransferIn() + tiPIT.Quantity() );
+        traverse ( pispipl, AsArrivalPISPIP, pit,
+                   pit.Quantity()              > 0                                                                           and
+                   pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation ) and
+                   TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() )
+                  ) 
+        {
+          cell.TransferIn( cell.TransferIn() + pit.Quantity() );
         }
         
         // 闀挎槬宸ュ巶鐗规畩鎯呭喌璁剧疆鍖呰搴撳瓨鍜岄潪鍖呰搴撳瓨
@@ -94,6 +95,7 @@
     Transaction::Transaction().Propagate( relation( PackagingPlanCell, Next ) );
     
     // 璁剧疆鍖呰&鎷嗗寘-鏁伴噺
+    PackagingPlanCell::SetPackagingAndUnpackingValues( macroPlan );
     //traverse ( macroPlan, PackagingPlanRow, ppr, ( ppr.ProductID() = "Windshield" and ppr.StockingPointID() = "Bosch" ) or ( ppr.ProductID() = "Windshield" and ppr.StockingPointID() = "Components (Spain)" ) ) {
     //  traverse ( ppr, PackagingPlanCell, ppc/*, ppc.StartDate() = Date::Construct( 2020, 4, 1 )*/ ) {
     //    // 璁剧疆鍖呰鏁伴噺

--
Gitblit v1.9.3