From f6a108e67cf221fe34a2338a44c9cb7894c9e07e Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期二, 13 八月 2024 18:38:46 +0800
Subject: [PATCH] 大连发动机物流成本报表

---
 _Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl |  118 ++++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 80 insertions(+), 38 deletions(-)

diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
index a7bf76a..97e6ea2 100644
--- a/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
@@ -30,14 +30,25 @@
       traverse( source, FinancialProductionReport, report, not report.IsShow() ){//璐㈠姟浜ч噺鎶ヨ〃涓嶆樉绀�
         traverse( report, FinancialProductionRow, row, row.Unit() = ccunit and exists( row, FinancialProductionCell, cell, cell.Value() <> '0' ) ){//璐㈠姟浜ч噺鎶ヨ〃閲岀殑闀挎槬浜ч噺, 涓嶄负0
           ccrow               := table.GetRow( row.Name() );
-          //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-          enginecost          := selectobject( owner, LogisticsCostEngine, engine, engine.Product() = row.Name() );
-          traverse( row, FinancialProductionCell, cell, cell.Value() <> '0' ){
-            //鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环锛屽叆搴撻噺绛変簬闀挎槬浜ч噺
-            quantity          := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
-            column            := selectobject( table, Column, column, column.Name() = cell.FinancialProductionColumn().Name() );
-            //澶栫搴撳叆搴撹垂鐢�
-            ccrow.SetRentEnterCost( column, quantity );
+          product             := row.Product_MP();
+          products.Add( product );
+          productparents      := product.GetAllParent();
+          if( exists( productparents, Elements, e, e.ID() = '鍙戝姩鏈�' ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
+            //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
+            enginecost          := selectobject( owner, LogisticsCostEngine, engine, engine.Generation() = product.Generation() 
+                                                 and engine.MLB_MQB() = product.MQBMLB()
+                                                 and engine.Factory() = ccunit
+                                                 and exists( productparents, Elements, e, e.ID() = engine.Product() ) );
+            if( not isnull( enginecost ) ){
+              product             := row.Product_MP();
+              traverse( row, FinancialProductionCell, cell, cell.Value() <> '0' ){
+                //鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环锛屽叆搴撻噺绛変簬闀挎槬浜ч噺
+                quantity          := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
+                column            := selectobject( table, Column, column, column.Name() = cell.FinancialProductionColumn().Name() );
+                //澶栫搴撳叆搴撹垂鐢�
+                ccrow.SetRentEnterCost( column, quantity );
+              }
+            }
           }
         }
       }
@@ -47,14 +58,24 @@
       traverse( source, FinancialSalesReport, report, not report.IsShow() ){//璐㈠姟閿�閲忔姤琛ㄤ笉鏄剧ず
         traverse( report, FinancialSalesRow, row, row.Unit() = ccunit and exists( row, FinancialSalesCell, cell, cell.Value() <> '0' ) ){//璐㈠姟閿�閲忔姤琛ㄩ噷鐨勯暱鏄ヤ骇閲�, 涓嶄负0
           ccrow               := table.GetRow( row.Name() );
-          //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-          enginecost          := selectobject( owner, LogisticsCostEngine, engine, engine.Product() = row.Name() );
-          traverse( row, FinancialSalesCell, cell, cell.Value() <> '0' ){
-            //鍑哄簱閲�/鍖呰瀹归噺*鍑哄簱鍗曚环锛屽叆搴撻噺绛変簬闀挎槬閿�閲�
-            quantity          := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
-            column            := selectobject( table, Column, column, column.Name() = cell.FinancialSalesColumn().Name() );
-            //澶栫搴撳嚭搴撹垂鐢�
-            ccrow.SetRentOutCost( column, quantity );
+          product             := row.Product_MP();
+          productparents      := product.GetAllParent();
+          if( exists( productparents, Elements, e, e.ID() = '鍙戝姩鏈�' ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
+            //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
+            enginecost          := selectobject( owner, LogisticsCostEngine, engine, engine.Generation() = product.Generation() 
+                                                 and engine.MLB_MQB() = product.MQBMLB()
+                                                 and engine.Factory() = ccunit 
+                                                 and exists( productparents, Elements, e, e.ID() = engine.Product() ) );
+            if( not isnull( enginecost ) ){
+              products.Add( product );
+              traverse( row, FinancialSalesCell, cell, cell.Value() <> '0' ){
+                //鍑哄簱閲�/鍖呰瀹归噺*鍑哄簱鍗曚环锛屽叆搴撻噺绛変簬闀挎槬閿�閲�
+                quantity          := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
+                column            := selectobject( table, Column, column, column.Name() = cell.FinancialSalesColumn().Name() );
+                //澶栫搴撳嚭搴撹垂鐢�
+                ccrow.SetRentOutCost( column, quantity );
+              }
+            }
           }
         }
       }
@@ -75,14 +96,26 @@
           column             := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
           traverse( trip, ProductInTrip, pit, pit.Quantity() = 0 ){
             row              := table.GetRow( pit.ProductID() );
-            //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
-            enginecost       := selectobject( owner, LogisticsCostEngine, engine, engine.Product() = row.Name() );
-            //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
-            transcost        := selectobject( owner, LogisticsCostTransport, trans, trans.Product() = row.Name() );
-            //杩愯緭鏁伴噺/鍖呰瀹归噺/瑁呰浇瀹归噺*杩愯緭鍗曚环
-            quantity         := ceil( ceil( [Number]pit.Quantity() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();//鍥涜垗浜斿叆
-            
-            row.SetFactoryToRentTransCost( column, quantity );
+            product          := pit.Product_MP();
+            productparents   := product.GetAllParent();
+            if( exists( productparents, Elements, e, e.ID() = '鍙戝姩鏈�' ) ){////鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
+              //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
+              enginecost       := selectobject( owner, LogisticsCostEngine, engine, engine.Generation() = product.Generation() 
+                                                 and engine.MLB_MQB() = product.MQBMLB()
+                                                 and engine.Factory() = ccunit 
+                                                 and exists( productparents, Elements, e, e.ID() = engine.Product() ) );
+              //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
+              transcost        := selectobject( owner, LogisticsCostTransport, trans, trans.Origin() = ccline 
+                                                and trans.Destination() = ccrent 
+                                                and exists( productparents, Elements, e, e.ID() = trans.Product() ) );
+              if( not isnull( enginecost ) and not isnull( transcost ) ){
+                products.Add( product );
+                //杩愯緭鏁伴噺/鍖呰瀹归噺/瑁呰浇瀹归噺*杩愯緭鍗曚环
+                quantity       := ceil( ceil( [Number]pit.Quantity() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();//鍥涜垗浜斿叆
+                
+                row.SetFactoryToRentTransCost( column, quantity );
+              }
+            }
           }
         }
       }
@@ -94,21 +127,30 @@
       if( isccrent ){
         traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() ){
           //鑾峰彇琛�
+          product            := pisp.Product_MP();
+          productparents     := product.GetAllParent();
           row                := table.GetRow( pisp.ProductID() );
-          //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-          enginecost         := selectobject( owner, LogisticsCostEngine, engine, engine.Product() = row.Name() );
-          products.Add( pisp.Product_MP() );
-          //褰損roduct planning鐨勬棩鏈熷尯闂村湪闇�瑕佺殑鏃ユ湡鍖洪棿鍐� 
-          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear
-                    ){
-            periodtime := pispip.Start().StartOfMonth().Date();
-            periodname := periodtime.Format( "M2/D2/Y" );
-            quantity   := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
-            
-            column := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
-            
-            row.SetRentStorageCost( column, quantity );
-          }    
+          if( exists( productparents, Elements, e, e.ID() = '鍙戝姩鏈�' ) ){////鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
+            //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
+            enginecost         := selectobject( owner, LogisticsCostEngine, engine, engine.Generation() = product.Generation() 
+                                                 and engine.MLB_MQB() = product.MQBMLB()
+                                                 and engine.Factory() = ccunit 
+                                                 and exists( productparents, Elements, e, e.ID() = engine.Product() ) );
+            if( not isnull( enginecost ) ){
+              products.Add( product );
+              //褰損roduct planning鐨勬棩鏈熷尯闂村湪闇�瑕佺殑鏃ユ湡鍖洪棿鍐� 
+              traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear
+                        ){
+                periodtime := pispip.Start().StartOfMonth().Date();
+                periodname := periodtime.Format( "M2/D2/Y" );
+                quantity   := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
+                
+                column := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
+                
+                row.SetRentStorageCost( column, quantity );
+              }    
+            }
+          }
         }
       }
     }

--
Gitblit v1.9.3