From 3ef592a0cd20ce531526b3ecbe73c3e0f31838b0 Mon Sep 17 00:00:00 2001
From: lihongji <3117313295@qq.com>
Date: 星期三, 18 九月 2024 16:13:23 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 _Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl |  119 +++++++++++++++++++++++++++++++++--------------------------
 1 files changed, 67 insertions(+), 52 deletions(-)

diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
index 42c2471..8a22432 100644
--- a/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
@@ -29,23 +29,27 @@
     //澶栫搴撳叆搴撹垂鐢細鍙栬嚜璐㈠姟浜ч噺鎶ヨ〃鐨勪骇閲忥紝鍦ㄤ骇鍝佽〃鏍规嵁鍙戝姩鏈哄彿鎵惧埌瀵瑰簲鐨凣eneration 鍜屾í绾靛埗锛屽湪鍙戝姩鏈烘垚鏈弬鏁拌〃閲屾壘鍒板搴旂殑鍖呰瀹归噺鍜屽叆搴撳崟浠凤紝鐢ㄥ叕寮忚绠楋紝鏈堝害杩涜姹囨��
     traverse( owner, FinancialProductionSource, source, not source.IsImport() ){//璐㈠姟浜ч噺鎶ヨ〃闈炲鍏�
       traverse( source, FinancialProductionReport, report, not report.IsShow() ){//璐㈠姟浜ч噺鎶ヨ〃涓嶆樉绀�
-        traverse( report, FinancialProductionRow, row, row.Unit() = ccunit and exists( row, FinancialProductionCell, cell, cell.Value() <> '0' ) ){//璐㈠姟浜ч噺鎶ヨ〃閲岀殑闀挎槬浜ч噺, 涓嶄负0
+        traverse( report, FinancialProductionRow, row, row.Unit() = ccunit and exists( row, FinancialProductionCell, cell, cell.Value() <> '0' and cell.FinancialProductionColumn().IsDay() ) ){//璐㈠姟浜ч噺鎶ヨ〃閲岀殑闀挎槬浜ч噺, 涓嶄负0
           product             := row.Product_MP();
           productparents      := product.GetAllParent();
           if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
             //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-            enginecost          := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
+            enginecosts       := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
                                                  and engine.Factory() = ccunit );
-            if( not isnull( enginecost ) ){
-              ccrow               := table.GetRow( row.Name() );
+            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
+              ccrow           := table.GetRow( row.Name() );
               products.Add( product );
-              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 );
+              traverse( row, FinancialProductionCell, cell, cell.Value() <> '0' and cell.FinancialProductionColumn().IsDay() ){
+                cellcolumn    := cell.FinancialProductionColumn();
+                enginecost    := selectobject( enginecosts, Elements, engine, engine.StartDate() <= cellcolumn.Period() and engine.EndDate() >= cellcolumn.Period() );
+                if( not isnull( enginecost ) ){
+                  //鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环锛屽叆搴撻噺绛変簬闀挎槬浜ч噺
+                  quantity          := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
+                  column            := selectobject( table, Column, column, column.Name() = cell.FinancialProductionColumn().Name() );
+                  //澶栫搴撳叆搴撹垂鐢�
+                  ccrow.SetRentEnterCost( column, quantity );
+                }
               }
             }
           }
@@ -55,23 +59,27 @@
     //澶栫搴撳嚭搴撹垂鐢細鍑哄簱閲忕瓑浜庨暱鏄ラ攢閲忥紝鍙栬嚜璐㈠姟閿�閲忔姤琛ㄧ殑閿�閲忥紝鍦ㄤ骇鍝佽〃鏍规嵁鍙戝姩鏈哄彿鎵惧埌瀵瑰簲鐨凣eneration 鍜屾í绾靛埗锛屽湪鍙戝姩鏈烘垚鏈弬鏁拌〃閲屾壘鍒板搴旂殑鍖呰瀹归噺鍜屽嚭搴撳崟浠凤紝鐢ㄥ叕寮忚绠楋紝鏈堝害杩涜姹囨��
     traverse( owner, FinancialSalesSource, source, not source.IsImport() ){//璐㈠姟閿�閲忔姤琛ㄩ潪瀵煎叆
       traverse( source, FinancialSalesReport, report, not report.IsShow() ){//璐㈠姟閿�閲忔姤琛ㄤ笉鏄剧ず
-        traverse( report, FinancialSalesRow, row, row.Unit() = ccunit and exists( row, FinancialSalesCell, cell, cell.Value() <> '0' ) ){//璐㈠姟閿�閲忔姤琛ㄩ噷鐨勯暱鏄ヤ骇閲�, 涓嶄负0
+        traverse( report, FinancialSalesRow, row, row.Unit() = ccunit and exists( row, FinancialSalesCell, cell, cell.Value() <> '0' and cell.FinancialSalesColumn().IsDay() ) ){//璐㈠姟閿�閲忔姤琛ㄩ噷鐨勯暱鏄ヤ骇閲�, 涓嶄负0
           product             := row.Product_MP();
           productparents      := product.GetAllParent();
           if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
             //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-            enginecost          := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
+            enginecosts       := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
                                                  and engine.Factory() = ccunit );
-            if( not isnull( enginecost ) ){
-              ccrow               := table.GetRow( row.Name() );
+            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
+              ccrow           := table.GetRow( row.Name() );
               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 );
+              traverse( row, FinancialSalesCell, cell, cell.Value() <> '0' and cell.FinancialSalesColumn().IsDay() ){
+                cellcolumn    := cell.FinancialSalesColumn();
+                enginecost    := selectobject( enginecosts, Elements, engine, engine.StartDate() <= cellcolumn.Period() and engine.EndDate() >= cellcolumn.Period() );
+                if( not isnull( enginecost ) ){
+                  //鍑哄簱閲�/鍖呰瀹归噺*鍑哄簱鍗曚环锛屽叆搴撻噺绛変簬闀挎槬閿�閲�
+                  quantity    := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
+                  column      := selectobject( table, Column, column, column.Name() = cell.FinancialSalesColumn().Name() );
+                  //澶栫搴撳嚭搴撹垂鐢�
+                  ccrow.SetRentOutCost( column, quantity );
+                }
               }
             }
           }
@@ -92,25 +100,29 @@
           periodname         := periodtime.Format( "M2/D2/Y" );
           
           column             := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
-          traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 ){
-            product          := pit.Product_MP();
-            productparents   := product.GetAllParent();
-            if( exists( productparents, Elements, e, e.ID() = produtparent ) ){////鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
-              //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
-              enginecost       := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower()
-                                                 and engine.MLB_MQB() = product.MQBMLB()
-                                                 and engine.Factory() = ccunit );
-              //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
-              transcost        := selectobject( owner, LogisticsCostTransport, trans, trans.Origin() = ccline 
-                                                and trans.Destination() = ccrent 
-                                                and exists( productparents, Elements, e, ifexpr( trans.Product().FindString( '鍙戝姩鏈�', 0 ) >= 0, e.ID() = produtparent,  e.ID() = trans.Product() ) ) );
-              if( not isnull( enginecost ) and not isnull( transcost ) ){
-                row              := table.GetRow( pit.ProductID() );
-                products.Add( product );
-                //杩愯緭鏁伴噺/鍖呰瀹归噺/瑁呰浇瀹归噺*杩愯緭鍗曚环
-                quantity       := ceil( ceil( [Number]pit.Quantity() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();//鍥涜垗浜斿叆
-                
-                row.SetFactoryToRentTransCost( column, quantity );
+          enginecosts        := selectset( owner, LogisticsCostEngine, engine, engine.StartDate() <= trip.Arrival().Date() and engine.EndDate() >= trip.Arrival().Date() );
+          transcosts         := selectset( owner, LogisticsCostTransport, trans, trans.StartDate() <= trip.Arrival().Date() and trans.EndDate() >= trip.Arrival().Date() );
+          if( not isnull( enginecosts ) and enginecosts.Size() > 0 and not isnull( transcosts ) and transcosts.Size() > 0 ){
+            traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 ){
+              product          := pit.Product_MP();
+              productparents   := product.GetAllParent();
+              if( exists( productparents, Elements, e, e.ID() = produtparent ) ){////鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
+                //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
+                enginecost     := selectobject( enginecosts, Elements, engine, engine.Generation().ToLower() = product.Generation().ToLower()
+                                                   and engine.MLB_MQB() = product.MQBMLB()
+                                                   and engine.Factory() = ccunit );
+                //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
+                transcost      := selectobject( transcosts, Elements, trans, trans.Origin() = ccline 
+                                                  and trans.Destination() = ccrent 
+                                                  and exists( productparents, Elements, e, ifexpr( trans.Product().FindString( '鍙戝姩鏈�', 0 ) >= 0, e.ID() = produtparent,  e.ID() = trans.Product() ) ) );
+                if( not isnull( enginecost ) and not isnull( transcost ) ){
+                  row          := table.GetRow( pit.ProductID() );
+                  products.Add( product );
+                  //杩愯緭鏁伴噺/鍖呰瀹归噺/瑁呰浇瀹归噺*杩愯緭鍗曚环
+                  quantity     := ceil( ceil( [Number]pit.Quantity() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();//鍥涜垗浜斿叆
+                  
+                  row.SetFactoryToRentTransCost( column, quantity );
+                }
               }
             }
           }
@@ -120,30 +132,33 @@
     //澶栫搴撲粨鍌ㄨ垂鐢細浠撳偍鏁伴噺/鍖呰瀹归噺*浠撳偍鍗曚环锛屽湪Actual inventories閲屽彇鍒伴暱鏄ュ绉熷簱璇ュ彂鍔ㄦ満鐨勪粨鍌ㄩ噺锛屾牴鎹彂鍔ㄦ満鍙锋壘鍒板搴旂殑Generation 鍜屾í绾靛埗锛屽湪鍙戝姩鏈烘垚鏈弬鏁拌〃閲屾壘鍒板搴旂殑浠撳偍鍗曚环鍜屽寘瑁呭閲忥紝鐢ㄥ叕寮忚绠楋紝鏈堝害杩涜姹囨��
     traverse( owner, StockingPoint_MP, stockingpoint ){
       //鏄惁灞炰簬闀挎槬澶栫搴�
-      isccrent               := table.IsInUnit( stockingpoint, ccrent );
+      isccrent                 := table.IsInUnit( stockingpoint, ccrent );
       if( isccrent ){
         traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() 
                   and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ) ){
           //鑾峰彇琛�
-          product            := pisp.Product_MP();
-          productparents     := product.GetAllParent();
+          product              := pisp.Product_MP();
+          productparents       := product.GetAllParent();
           if( exists( productparents, Elements, e, e.ID() = produtparent ) ){////鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
             //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-            enginecost         := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
+            enginecosts        := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
                                                  and engine.Factory() = ccunit );
-            if( not isnull( enginecost ) ){
-              row                := table.GetRow( pisp.ProductID() );
+            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
+              row              := table.GetRow( pisp.ProductID() );
               products.Add( product );
               //褰損roduct planning鐨勬棩鏈熷尯闂村湪闇�瑕佺殑鏃ユ湡鍖洪棿鍐� 
               traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ){
-                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 );
+                enginecost     := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date() );
+                if( not isnull( enginecost ) ){
+                  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