From bcd7eb876bff759f6aef96f1014b0bca7a3322ff Mon Sep 17 00:00:00 2001
From: rislai <risheng.lai@capgemini.com>
Date: 星期五, 16 八月 2024 15:53:14 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/VWED into dev

---
 _Main/BL/Type_EnginePipelineSource/StaticMethod_Initialize.qbl |   64 +++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/_Main/BL/Type_EnginePipelineSource/StaticMethod_Initialize.qbl b/_Main/BL/Type_EnginePipelineSource/StaticMethod_Initialize.qbl
index b18fbac..f9e39e3 100644
--- a/_Main/BL/Type_EnginePipelineSource/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_EnginePipelineSource/StaticMethod_Initialize.qbl
@@ -8,8 +8,13 @@
   [*
     // 鐢勫叞楦� Jun-24-2024 (created)
     owner.EnginePipelineSource( relflush );
-    ccunit                    := EnginePipelineReport::GetDefaultCCUnit();
-    dlunit                    := EnginePipelineReport::GetDefaultDLUnit();
+    //ccunit                    := EnginePipelineReport::GetDefaultCCUnit();
+    //dlunit                    := EnginePipelineReport::GetDefaultDLUnit();
+    productparent             := EnginePipelineReport::GetDefaultProductParent();
+    ccalineunit               := EnginePipelineReport::GetDefaultCCALineUnit();
+    dlalienunit               := EnginePipelineReport::GetDefaultDLALineUnit()
+    ccmplineunit              := EnginePipelineReport::GetDefaultCCMPLineUnit()
+    dlmplineunit              := EnginePipelineReport::GetDefaultDLMPLineUnit();
     //allunit                   := EnginePipelineReport::GetDefaultAllUnit();
     source                    := owner.EnginePipelineSource( relnew, Name := EnginePipelineReport::GetDefaultName() );
     table                     := source.Report( relnew, ID := source.Name(), Name := source.Name() );
@@ -27,55 +32,62 @@
       unit                    := stockingpoint.Unit();
       parentunits             := unit.GetAllParent();
       //鏄惁灞炰簬闀挎槬宸ュ巶
-      iscc                    := unit.ID() = ccunit or exists( parentunits, Elements, punit, punit.ID() = ccunit );
+      iscc         := unit.ID() = ccalineunit or unit.ID() = ccmplineunit or exists( parentunits, Elements, punit, punit.ID() = ccalineunit or punit.ID() = ccmplineunit );
       //鏄惁灞炰簬澶ц繛宸ュ巶
-      isdl                    := unit.ID() = dlunit or exists( parentunits, Elements, punit, punit.ID() = dlunit );
+      isdl         := unit.ID() = dlalienunit or unit.ID() = dlmplineunit  or exists( parentunits, Elements, punit, punit.ID() = dlalienunit or punit.ID() = dlmplineunit );
       
-      traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() and not pisp.IsSystem() ){
-        weekstart             := owner.StartOfPlanning().Date();
-        pispips               := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() 
-                                                  and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day(), pispip.Start() );
+      traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() and not pisp.IsSystem() 
+                and exists( pisp.Product_MP().GetAllParent(), Elements, e, e.ID() = productparent ) 
+                and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day() and ( pispip.NewSupplyQuantity() <> 0 or pispip.PlannedInventoryLevelEnd() <> 0 ) ) ){
+        weekstart           := owner.StartOfPlanning().Date();
+        pispips             := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() 
+                                                    and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day(), pispip.Start() );
         row := table.GetRow( pisp.ProductID() );
         traverse( pispips, Elements, pispip ){
           //澶�
-          daycolumn           := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), pispip.Start().Date() );
+          daycolumn         := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), pispip.Start().Date() );
           //鍛�
-          weekcolumn          := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), weekstart );
-          supplyquantity      := [Real]ceil( pispip.NewSupplyQuantity() );//鍚戜笂鍙栨暣
-          inventoryquantity   := [Real]ceil( pispip.PlannedInventoryLevelEnd() );//鍚戜笂鍙栨暣
+          weekcolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(),  pispip.Start().Date() );
+          supplyquantity    := [Number]pispip.NewSupplyQuantity();//鍥涜垗浜斿叆
+          inventoryquantity := [Number]pispip.PlannedInventoryLevelEnd();//鍥涜垗浜斿叆
           //浜ч噺鏄姞鎬�
           if( iscc or isdl ){
-            row.SetCellProductionValue( daycolumn, iscc, supplyquantity );
-            row.SetCellProductionValue( weekcolumn, iscc, supplyquantity );
+            row.SetCellProductionValue( daycolumn, iscc, [Real]supplyquantity );
+            row.SetCellProductionValue( weekcolumn, iscc, [Real]supplyquantity );
           }
           //搴撳瓨闇�瑕佸彇鏈�鍚庝竴澶�
-          row.SetCellInventoryValue( daycolumn, pispip.PlannedInventoryLevelEnd() );
-    
+          row.SetCellInventoryValue( daycolumn, [Real]inventoryquantity );
+      
           if( pispip.Start() = weekstart + Duration::Days( 6 ) or pispip.Period_MP() = endperiod ){
-            weekstart         := ( weekstart + Duration::Days( 7 ) ).Date();
-            
-            row.SetCellInventoryValue( weekcolumn, inventoryquantity );
+            weekstart       := ( weekstart + Duration::Days( 7 ) ).Date();
+              
+            row.SetCellInventoryValue( weekcolumn, [Real]inventoryquantity );
           } 
         }
       }
     }
     
     //鐢熸垚闇�姹傛暟鎹�
-    traverse( owner, SalesDemand.astype( Forecast ), forecast ){
-      row                   := table.GetRow( forecast.ProductID() );
-      weekstart             := owner.StartOfPlanning().Date();
-      traverse( forecast, PlanningSalesDemandInPeriod, psdip ){
+    traverse( owner, SalesDemand.astype( Forecast ), forecast, not isnull( forecast.SalesSegment_MP() ) and forecast.StartDate() < endperiod.StartDate() and forecast.Quantity() <> 0 
+              and exists( forecast.Product_MP().GetAllParent(), Elements, e, e.ID() = productparent )
+              and exists( forecast, PlanningSalesDemandInPeriod, psdip, psdip.Quantity() <> 0 ) ){
+      row                 := table.GetRow( forecast.ProductID() );
+    //  weekstart           := owner.StartOfPlanning().Date();
+      traverse( forecast, PlanningSalesDemandInPeriod, psdip, psdip.Quantity() <> 0 ){
         //澶�
-        daycolumn           := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), psdip.StartDate() );
+        daycolumn         := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), psdip.StartDate() );
         //鍛�
-        weekcolumn          := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), weekstart );
-        
+        weekcolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), psdip.StartDate() );
+          
         if( not isnull( daycolumn ) ){
           row.SetCellDemandValue( daycolumn, forecast.SalesSegmentName(), forecast.Quantity() );
         }
         if( not isnull( weekcolumn ) ){
           row.SetCellDemandValue( weekcolumn, forecast.SalesSegmentName(), forecast.Quantity() );
         }
+    //    if( psdip.StartDate() = ( weekstart + Duration::Days( 6 ) ).Date() or psdip.PeriodStart() = endperiod.StartDate() ){
+    //      weekstart       := ( weekstart + Duration::Days( 7 ) ).Date();
+    //    } 
       }
     }
     

--
Gitblit v1.9.3