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_MachiningPipelineSource0/StaticMethod_Initialize.qbl |  110 +++++++++++++++++++++++++++++++++----------------------
 1 files changed, 66 insertions(+), 44 deletions(-)

diff --git a/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl b/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
index 5776315..23633d0 100644
--- a/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
@@ -8,6 +8,7 @@
   [*
     // 鐢勫叞楦� Jun-24-2024 (created)
     owner.FinancialProductionSource( relflush );
+    productparent             := MachiningPipelineReport::GetDefaultProductParent();
     ccunit                    := MachiningPipelineReport::GetDefaultCCUnit();
     dlunit                    := MachiningPipelineReport::GetDefaultDLUnit();
     //allunit                   := EnginePipelineReport::GetDefaultAllUnit();
@@ -39,39 +40,48 @@
       //鏄惁灞炰簬澶ц繛鏈哄姞浜х嚎
       isdlproduction          := unit.ID() = MachiningPipelineReport::GetDefaultDLProductionUnit() or exists( parentunits, Elements, punit, punit.ID() = MachiningPipelineReport::GetDefaultDLProductionUnit() );
       if( iscc or isdl ){
-        traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() and not pisp.IsSystem() ){
-          row := table.GetRow( pisp.ProductID() );
-          
-          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 ) ) ){
+          pispips             := selectsortedset( 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 ), pispip.Start() );
           traverse( pispips, Elements, pispip ){
+            supplyquantity    := [Number]pispip.NewSupplyQuantity();//鍥涜垗浜斿叆
             //澶�
-            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() );
             
             //瑁呴厤绾�
             if( isccassemnly or isdlassemnly ){
-              row.SetCellAssemblyValue( daycolumn, isccassemnly, supplyquantity );
-              row.SetCellAssemblyValue( weekcolumn, isccassemnly, supplyquantity );
+              if( isccassemnly ){
+                daycolumn.CCAssemblyPlanQty( daycolumn.CCAssemblyPlanQty() + supplyquantity );
+                weekcolumn.CCAssemblyPlanQty( weekcolumn.CCAssemblyPlanQty() + supplyquantity );
+              } else {
+                daycolumn.DLAssemblyPlanQty( daycolumn.DLAssemblyPlanQty() + supplyquantity );
+                weekcolumn.DLAssemblyPlanQty( weekcolumn.DLAssemblyPlanQty() + supplyquantity );
+              } 
             }
             
-            //鏈哄姞绾�
-            if( isccproduction or isdlproduction ){
-              row.SetCellProductionValue( daycolumn, isccproduction, supplyquantity );
-              row.SetCellProductionValue( weekcolumn, isccproduction, supplyquantity );
-            }
-            //搴撳瓨
-            if( iscc or isdl ){
-              row.SetCellInventoryValue( daycolumn, iscc, inventoryquantity );
-              if( pispip.Start() = weekstart + Duration::Days( 6 ) or pispip.Period_MP() = endperiod ){
-                weekstart         := ( weekstart + Duration::Days( 7 ) ).Date();
-                row.SetCellInventoryValue( weekcolumn, iscc, inventoryquantity );
+            product           := pisp.Product_MP();
+            productparents    := product.GetAllParent();
+            if( exists( productparents, Elements, e, e.ID() = productparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
+              row             := table.GetRow( pisp.ProductID() );
+              products.Add( pisp.Product_MP() );
+    
+              inventoryquantity:= [Number]pispip.PlannedInventoryLevelEnd();//鍥涜垗浜斿叆
+              
+              //鏈哄姞绾�
+              if( isccproduction or isdlproduction ){
+                row.SetCellProductionValue( daycolumn, isccproduction, [Real]supplyquantity );
+                row.SetCellProductionValue( weekcolumn, isccproduction, [Real]supplyquantity );
+              }
+              //搴撳瓨
+              if( iscc or isdl ){
+                row.SetCellInventoryValue( daycolumn, iscc, [Real]inventoryquantity );
+                if( weekcolumn.EndDate() = pispip.Start().Date() or pispip.Period_MP() = endperiod ){
+                  row.SetCellInventoryValue( weekcolumn, iscc, [Real]inventoryquantity );
+                }
               }
             }
           }
@@ -80,25 +90,33 @@
     }
     
     //鐢熸垚璋冩嫧鏁版嵁
-    traverse( owner, TransferPlanRow, tprow, ( tprow.SourceStockpoingPointID() = 'CC' and tprow.TargetStockpoingPointID() = 'DL' ) or ( tprow.SourceStockpoingPointID() = 'DL' and tprow.TargetStockpoingPointID() = 'CC' ) ){
-      row := selectobject( table, Row, row, row.Name() = tprow.Name() );
-      traverse( table, Column, column ){
-        cell := selectobject( row, Cell, cell, cell.Column() = column );
-        if( column.TimeUnit() = Translations::MP_GlobalParameters_Day() ){
-          tpcell := selectobject( tprow, TransferPlanCell, tpcell, tpcell.TransferPlanColumn().ColumnDate() = column.Period() );
-          if( tprow.SourceStockpoingPointID() = 'CC' and tprow.TargetStockpoingPointID() = 'DL' ){
-            cell.CCTransferQty( [Real]tpcell.Value() );
-          }else if( tprow.SourceStockpoingPointID() = 'DL' and tprow.TargetStockpoingPointID() = 'CC' ){
-            cell.DLTransferQty( [Real]tpcell.Value() );
-          }
-        }else if( column.TimeUnit() = Translations::MP_GlobalParameters_Week() ){
-          period := column.Period() + Duration::Days( 6 );
-          tpcell := selectobject( tprow, TransferPlanCell, tpcell, tpcell.TransferPlanColumn().ColumnDate() = period.Date() );
-          
-          if( tprow.SourceStockpoingPointID() = 'CC' and tprow.TargetStockpoingPointID() = 'DL' ){
-            cell.CCTransferQty( [Real]tpcell.Value() );
-          }else if( tprow.SourceStockpoingPointID() = 'DL' and tprow.TargetStockpoingPointID() = 'CC' ){
-            cell.DLTransferQty( [Real]tpcell.Value() );
+    traverse( owner, TransferPlanRow, tprow ){
+      product               := selectobject( owner, Product_MP, product, product.ID() = tprow.ProductID() );
+      productparents        := product.GetAllParent();
+      if( exists( productparents, Elements, e, e.ID() = productparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
+        //璧峰搴撳瓨鐐规槸鍚︽槸澶ц繛or闀挎槬
+        originsp              := selectobject( owner, StockingPoint_MP, sp, sp.ID() = tprow.SourceStockpoingPointID() );
+        originunit            := originsp.Unit();
+        originparentunits     := originunit.GetAllParent();
+        originiscc            := originsp.ID() = ccunit or originunit.ID() = ccunit or exists( originparentunits, Elements, punit, punit.ID() = ccunit );
+        originisdl            := originsp.ID() = dlunit or originunit.ID() = dlunit or exists( originparentunits, Elements, punit, punit.ID() = dlunit );
+        //鐩殑鍦版槸鍚︽槸闀挎槬澶栫搴�
+        destisp               := selectobject( owner, StockingPoint_MP, sp, sp.ID() = tprow.TargetStockpoingPointID() );
+        destiunit             := destisp.Unit();
+        destiparentunits      := destiunit.GetAllParent();
+        destiiscc             := destisp.ID() = ccunit or destiunit.ID() = ccunit or exists( destiparentunits, Elements, punit, punit.ID() = ccunit );
+        destiisdl             := destisp.ID() = dlunit or destiunit.ID() = dlunit or exists( destiparentunits, Elements, punit, punit.ID() = dlunit );
+        if( ( originiscc and destiisdl ) or ( originisdl and destiiscc ) ){
+          row := table.GetRow( tprow.ProductID() );
+          traverse( tprow, TransferPlanCell, tpcell, tpcell.TransferPlanColumn().ColumnDate() <> Date::MinDate() ){
+            //澶�
+            daycolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), tpcell.TransferPlanColumn().ColumnDate() );
+            //鍛�
+            weekcolumn       := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), tpcell.TransferPlanColumn().ColumnDate() );
+            quantity         := [Real]tpcell.Value();//鍥涜垗浜斿叆
+            
+            row.SetCellTransferValue( daycolumn, ( originiscc and destiisdl ), quantity );
+            row.SetCellTransferValue( weekcolumn, ( originiscc and destiisdl ), quantity );
           }
         }
       }
@@ -108,6 +126,10 @@
     i    := 0;
     traverse( rows, Elements, e ){
       e.RowNr( i );
+      traverse( e, Cell, cell ){
+        cell.CCAssemblyPlanQty( cell.Column().CCAssemblyPlanQty() );
+        cell.DLAssemblyPlanQty( cell.Column().DLAssemblyPlanQty() );
+      }
       i := i + 1;
     }
     showtable.Generate( search, products );

--
Gitblit v1.9.3