From 83ec31b01a61d9a6bc74933572991469eeea4d44 Mon Sep 17 00:00:00 2001
From: admin <admin@admin.com>
Date: 星期一, 11 十一月 2024 19:33:19 +0800
Subject: [PATCH] 包装计划优化

---
 _Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl |  103 ++-------------------------------------------------
 1 files changed, 4 insertions(+), 99 deletions(-)

diff --git a/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl b/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
index 9408e3a..dc2965f 100644
--- a/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
+++ b/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
@@ -6,110 +6,15 @@
 {
   TextBody:
   [*
-    macroPlan.PackagingPlanRow( relflush );
-    macroPlan.PackagingPlanColumn( relflush );
-    
-    // 鍒涘缓璁″垝鍓嶄竴澶╁垪
-    planPre     := macroPlan.PackagingPlanColumn( relnew, StartDate := macroPlan.StartOfPlanning().Date() - 1 );
-    
-    // 鐢熸垚鎶ヨ〃
-    traverse ( macroPlan, Product_MP.ProductInStockingPoint_MP, pisp, pisp.IsLeaf() and not pisp.IsSystem() and 
-               ( pisp.StockingPointID().Regex( "CC" ) or pisp.StockingPointID().Regex( "DL" ) or pisp.StockingPointID().Regex( "澶ц繛" ) or pisp.StockingPointID().Regex( "闀挎槬" ) ) ) {
-      // 褰撳墠pisp鎵�澶勫湴鐐�
-      factory             := ifexpr( pisp.StockingPointID().Regex( "CC" ) or pisp.StockingPointID().Regex( "闀挎槬" ), "闀挎槬宸ュ巶", "澶ц繛宸ュ巶" );
-      factoryAbbreviation := ifexpr( pisp.StockingPointID().Regex( "CC" ) or pisp.StockingPointID().Regex( "闀挎槬" ), "CC", "DL" );
-      
-      // 鍒涘缓琛�
-      ppr := select( macroPlan, PackagingPlanRow, tempPPR, tempPPR.ProductID() = pisp.ProductID() and tempPPR.Factory() = factory );
-      if ( isnull( ppr ) ) {
-        ppr := macroPlan.PackagingPlanRow( relnew, ProductID := pisp.ProductID(), Factory := factory, Category := guard( pisp.Product_MP().ParentID(), "" ) );
-      }
-      
-      // 寰幆pispippl
-      traverse ( pisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispipl, not pispipl.IsPeriodFrozen() ) {
-        // 鍒涘缓鍒�
-        ppc := select( macroPlan, PackagingPlanColumn, tempPPC, tempPPC.StartDate() = pispipl.Start().Date() );
-        if ( isnull( ppc ) ) {
-          ppc := macroPlan.PackagingPlanColumn( relnew, StartDate := pispipl.Start().Date() );
-        }
-        
-        // 鍒涘缓鍗曞厓鏍�
-        cell := select( ppr, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = ppc );
-        if ( isnull( cell ) ) {
-          cell := ppr.PackagingPlanCell( relnew ); 
-          cell.PackagingPlanColumn( relset, ppc );
-        }
-        
-        // 璁剧疆璋冨嚭
-        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() );
-        }
-        
-        // 璁剧疆璋冭繘
-        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() );
-        }
-        
-        // 澶ц繛宸ュ巶璁剧疆鍊�
-        if ( factory = "澶ц繛宸ュ巶" ) {
-          // 鍑�闇�姹�&鍓╀綑搴撳瓨&渚涘簲閲�
-          cell.NetDemand( cell.NetDemand() + pispipl.DependentDemandAndSalesDemandQuantity() );
-          cell.EndingInventory( cell.EndingInventory() + pispipl.InventoryLevelEnd() );
-        }
-        
-        // 闀挎槬宸ュ巶璁剧疆鍊�
-        if ( factory = "闀挎槬宸ュ巶" ) {
-          // 鍓╀綑搴撳瓨&渚涘簲閲�
-          cell.EndingInventory( cell.EndingInventory() + pispipl.InventoryLevelEnd() );
-          
-          // 鍑�闇�姹傘�愬彧鍙栫嚎杈瑰簱銆�&鍖呰搴撳瓨&闈炲寘瑁呭簱瀛�
-          if ( pisp.StockingPointID().Regex( "澶栫搴�" ) ) {
-            cell.CC_PackagingInventory( pispipl.InventoryLevelEnd() );
-          } else if ( pisp.StockingPointID().Regex( "绾胯竟搴�" ) ) {
-            cell.CC_UnpackagedInventory( pispipl.InventoryLevelEnd() );
-            cell.NetDemand( cell.NetDemand() + pispipl.DependentDemandAndSalesDemandQuantity() );
-          }
-        }
-        
-        // 璁剧疆New Supply锛岀函鐢熶骇鍊�
-        traverse ( pispipl, NewSupply, ns, ns.PeriodTask_MP().istype( PeriodTaskOperation ) ) {
-          cell.NewSupply( cell.NewSupply() + ns.Quantity() );
-        }
-        
-        // 璁剧疆鍓嶄竴澶╁簱瀛�
-        if ( pispipl.Start().Date() = macroPlan.StartOfPlanning().Date() ) {
-          prePISPIPL  := pispipl.PreviousPlanningPISPIP().astype( ProductInStockingPointInPeriodPlanningLeaf ); // 鍓嶄竴涓猵ispippl
-          // 鍒涘缓璁″垝鍓嶄竴澶╂牸瀛�
-          preCell := select( ppr, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = planPre );
-          if ( isnull( preCell ) ) {
-            preCell := ppr.PackagingPlanCell( relnew );
-            preCell.EndingInventory( prePISPIPL.InventoryLevelEnd() );
-            preCell.PackagingPlanColumn( relset, planPre );
-          } else {
-            preCell.EndingInventory( preCell.EndingInventory() + prePISPIPL.InventoryLevelEnd() );
-          }
-        }
-      }
-    }
-    
-    Transaction::Transaction().Propagate( attribute( PackagingPlanRow, FactoryAbbreviation ) );
-    PackagingPlanCell::CalculationPackagingPlanProperties();
-    Transaction::Transaction().Propagate( relation( PackagingPlanCell, Next ) );
+    // 鍒涘缓鏁版嵁
+    PackagingPlanCell::CreateData( macroPlan );
     
     // 璁剧疆鍖呰&鎷嗗寘-鏁伴噺锛堝ぇ杩炲伐鍘傦級
     PackagingPlanCell::SetPackagingAndUnpackingValuesDL( macroPlan );
+    
     // 璁剧疆鍖呰&鎷嗗寘-鏁伴噺锛堥暱鏄ュ伐鍘傦級
     PackagingPlanCell::SetPackagingAndUnpackingValuesCC( 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