From 03f93088637930acbda3cd0b405114e0b00c13e4 Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期一, 30 九月 2024 17:29:00 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/VWED into dev

---
 _Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl |  164 ++++++++++++++++++++++++++----------------------------
 1 files changed, 80 insertions(+), 84 deletions(-)

diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl
index c37810c..90133e3 100644
--- a/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl
+++ b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl
@@ -13,9 +13,11 @@
     allunit                   := DLEngineLogisticsCostReport::GetDefaultAllUnit();
     ccunit                    := DLEngineLogisticsCostReport::GetDefaultCCUnit();
     dlunit                    := DLEngineLogisticsCostReport::GetDefaultDLUnit();
+    ccfactory                 := DLEngineLogisticsCostReport::GetCCFactory();
+    dlfactory                 := DLEngineLogisticsCostReport::GetDLFactory();
     //dlline                    := DLEngineLogisticsCostReport::GetStockingPointDLLine();
-    ccrent                    := DLEngineLogisticsCostReport::GetStockingPointCCRent();
-    dlrent                    := DLEngineLogisticsCostReport::GetStockingPointCCRent();
+    //ccrent                    := DLEngineLogisticsCostReport::GetStockingPointCCRent();
+    //dlrent                    := DLEngineLogisticsCostReport::GetStockingPointCCRent();
     
     startofplanning           := owner.StartOfPlanning().Date();
     //startofyear               := startofplanning.StartOfYear();
@@ -28,14 +30,74 @@
     products                  := construct( Product_MPs );
     
     table.GenerateColumn( owner );
+    //澶栫搴撲粨鍌ㄨ垂鐢細浠撳偍鏁伴噺/鍖呰瀹归噺*浠撳偍鍗曚环锛屽湪Actual inventories閲屽彇鍒伴暱鏄ュ绉熷簱/澶ц繛澶栫搴撹鍙戝姩鏈虹殑浠撳偍閲忥紝鏍规嵁鍙戝姩鏈哄彿鎵惧埌瀵瑰簲鐨凣eneration 鍜屾í绾靛埗锛屽湪鍙戝姩鏈烘垚鏈弬鏁拌〃閲屾壘鍒板搴旂殑浠撳偍鍗曚环鍜屽寘瑁呭閲忥紝鐢ㄥ叕寮忚绠楋紝鏈堝害杩涜姹囨��
+    //闀挎槬澶栫搴撳叆搴�/鍑哄簱璐圭敤锛屽ぇ杩炲彂鍔ㄦ満鐨勯暱鏄ュ绉熷簱鐨凬ew supply
+    traverse( owner, StockingPoint_MP, stockingpoint, stockingpoint.ID().EndsWith( '澶栫搴�' ) ){
+    //  unit                    := stockingpoint.Unit();
+    //  parentunits             := unit.GetAllParent();
+      //鏄惁灞炰簬闀挎槬澶栫搴�
+      isccrent                := stockingpoint.ID().StartsWith( '闀挎槬' ) or stockingpoint.ID().StartsWith( 'CC' );
+      //鏄惁灞炰簬澶ц繛鍙戝姩鏈虹殑闀挎槬澶栫搴�
+      isdltoccrent            := stockingpoint.ID().StartsWith( '澶ц繛鍙戝姩鏈虹殑闀挎槬' );
+      //鏄惁灞炰簬澶ц繛澶栫搴�
+      isdlrent                := stockingpoint.ID().StartsWith( '澶ц繛' ) or stockingpoint.ID().StartsWith( 'DL' );
+      if( isccrent or isdlrent ){
+        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();
+          if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
+            row               := table.GetRow( pisp.ProductID() );
+            enginecosts       := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() and engine.MLB_MQB() = product.MQBMLB() );
+            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
+              products.Add( pisp.Product_MP() );
+              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" );
+                column        := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
+                cell          := selectobject( row, Cell, cell, cell.Column() = column );
+                
+                if( isccrent or isdltoccrent){
+                  //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
+                  enginecost  := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date()
+                                                     and engine.Factory() = ccfactory );
+                   if( not isnull( enginecost ) ){
+                     quantity :=   [Number]pispip.NewSupplyQuantity();
+                     if( isccrent ){
+                       cost        := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
+                       cell.CCRentStorCost( cell.CCRentStorCost() + cost );
+                     }else{
+                       cell.CCRentQuantity( cell.CCRentQuantity() + quantity );
+                       //闀挎槬澶栫搴撳叆搴撹垂鐢細鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环
+                       entercost  := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
+                       //闀挎槬澶栫搴撳嚭搴撹垂鐢�: 鍑哄簱閲�/鍖呰瀹归噺*鍑哄簱鍗曚环
+                       outcost    := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
+                       cell.CCRentInCost( cell.CCRentInCost() + entercost );
+                       cell.CCRentOutOfCost( cell.CCRentOutOfCost() + outcost );
+                     }
+                   }
+                } else {
+                  //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
+                  enginecost     := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date()
+                                                     and engine.Factory() = dlfactory  );
+                   if( not isnull( enginecost ) ){
+                     cost        := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
+                     cell.DLRentStorCost( cell.DLRentStorCost() + cost );
+                   }
+                }
+              }   
+            }
+          }
+        }
+      }
+    }
     //鍦� trip plan閲屾壘鍒板ぇ杩炶閰嶇嚎杈瑰簱鍒板ぇ杩炲绉熷簱鐨勮繍杈撴暟閲�//澶ц繛鍘傚唴搴撳埌澶栫搴�
     traverse( owner, Unit.Lane.LaneLeg, laneleg ){
       //璧峰搴撳瓨鐐规槸鍚︽槸澶ц繛瑁呴厤绾胯竟搴�
-    //  originsp               := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.OriginStockingPointID() );
-      isdlspline             := laneleg.OriginStockingPointID().EndsWith( '鍘傚唴搴�' ) and ( laneleg.OriginStockingPointID().StartsWith( '澶ц繛' ) or laneleg.OriginStockingPointID().StartsWith( 'DL' ) );//table.IsInUnit( originsp, dlline );
+      isdlspline             := laneleg.OriginStockingPointID().EndsWith( '鍘傚唴搴�' ) and ( laneleg.OriginStockingPointID().StartsWith( '澶ц繛' ) or laneleg.OriginStockingPointID().StartsWith( 'DL' ) );
       //鐩殑鍦版槸鍚︽槸澶ц繛澶栫搴�
-    //  destisp                := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.DestinationStockingPointID() );
-      isdlrent               := laneleg.DestinationStockingPointID().EndsWith( '澶栫搴�' ) and ( laneleg.DestinationStockingPointID().StartsWith( '澶ц繛' ) or laneleg.DestinationStockingPointID().StartsWith( 'DL' ) );//table.IsInUnit( destisp, dlrent );
+      isdlrent               := laneleg.DestinationStockingPointID().EndsWith( '澶栫搴�' ) and ( laneleg.DestinationStockingPointID().StartsWith( '澶ц繛' ) or laneleg.DestinationStockingPointID().StartsWith( 'DL' ) );
       if( isdlspline and isdlrent ){
         traverse( laneleg, Trip, trip, trip.Departure().Date() < startofnextyear ){//鐢变簬闇�瑕佽�冭檻浜у搧杩愯緭lead time锛屾瘡涓湀鐨勬眹鎬绘暟鎹渶瑕佹帹杩熶袱澶╄繘琛岃绠�
           periodtime         := trip.Departure().StartOfMonth().Date();
@@ -54,7 +116,7 @@
               //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
               enginecost     := selectobject( enginecosts, Elements, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                    and engine.MLB_MQB() = product.MQBMLB()
-                                                   and engine.Factory() = dlunit  );
+                                                   and engine.Factory() = dlfactory  );
               //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
               transcost      := selectobject( transcosts, Elements, trans, trans.Origin() = laneleg.OriginStockingPointID() 
                                                   and trans.Destination() = laneleg.DestinationStockingPointID() 
@@ -66,29 +128,12 @@
                 cost         := ceil( ceil( quantity / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();//鍥涜垗浜斿叆
                 cell.WerkToDLRentTransCost( cell.WerkToDLRentTransCost() + cost );
               }
-    //          if( isccrent ){//鐩殑鍦版槸闀挎槬澶栫搴�
-    //            //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
-    //            enginecost   := selectobject( enginecosts, Elements, engine, engine.Generation().ToLower() = product.Generation().ToLower()
-    //                                               and engine.MLB_MQB() = product.MQBMLB()
-    //                                               and engine.Factory() = ccunit );
-    //            if( not isnull( enginecost ) ){
-    //              products.Add( product );
-    //              cell       := selectobject( row, Cell, cell, cell.Column() = column );
-    //              cell.CCRentQuantity( cell.CCRentQuantity() + quantity );
-    //              //闀挎槬澶栫搴撳叆搴撹垂鐢細鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环
-    //              entercost  := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
-    //              //闀挎槬澶栫搴撳嚭搴撹垂鐢�: 鍑哄簱閲�/鍖呰瀹归噺*鍑哄簱鍗曚环
-    //              outcost    := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
-    //              cell.CCRentEnterCost( cell.CCRentEnterCost() + entercost );
-    //              cell.CCRentOutCost( cell.CCRentOutCost() + outcost );
-    //            }
-    //          }
             }
           }
         }
       }
     }
-    //澶ц繛澶栫搴撳叆搴撹垂鐢細鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环锛屽叆搴撻噺绛変簬澶ц繛宸ュ巶璇ヤ骇鍝佷骇閲忓噺鍘诲彂寰�闀挎槬鐨勬暟閲�-newSupply
+    //澶ц繛澶栫搴撳叆搴撹垂鐢細鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环锛屽叆搴撻噺绛変簬澶ц繛宸ュ巶璇ヤ骇鍝佷骇閲忓噺鍘诲彂寰�闀挎槬(澶ц繛鐨勯暱鏄ュ绉熷簱锛夌殑鏁伴噺-newSupply
     traverse( owner, FinancialProductionSource, source, not source.IsImport() ){//璐㈠姟浜ч噺鎶ヨ〃闈炲鍏�
       traverse( source, FinancialProductionReport, report, not report.IsShow() ){//璐㈠姟浜ч噺鎶ヨ〃涓嶆樉绀�
         traverse( report, FinancialProductionRow, row, row.Unit() = dlunit and exists( row, FinancialProductionCell, cell, cell.Value() <> '0' and cell.FinancialProductionColumn().IsDay() ) ){//璐㈠姟浜ч噺鎶ヨ〃閲岀殑澶ц繛浜ч噺, 涓嶄负0
@@ -98,7 +143,7 @@
             //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
             enginecosts      := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
-                                                 and engine.Factory() = dlunit );
+                                                 and engine.Factory() = dlfactory );
             if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
               products.Add( product );
               ccrow          := table.GetRow( row.Name() );
@@ -126,7 +171,7 @@
             //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
             enginecosts      := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
-                                                 and engine.Factory() = dlunit );
+                                                 and engine.Factory() = dlfactory );
             if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
               products.Add( product );
               ccrow          := table.GetRow( row.Name() );
@@ -149,17 +194,15 @@
       product                 := selectobject( owner, Product_MP, product, product.ID() = tprow.ProductID() );
       productparents          := product.GetAllParent();
       if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
-        //璧峰搴撳瓨鐐规槸鍚︽槸澶ц繛
-        originsp               := selectobject( owner, StockingPoint_MP, sp, sp.ID() = tprow.SourceStockpoingPointID() );
-        isdl                   := table.IsInUnit( originsp, dlunit );
-        //鐩殑鍦板簱瀛樼偣鏄惁鏄暱鏄�
-        destisp                := selectobject( owner, StockingPoint_MP, sp, sp.ID() = tprow.TargetStockpoingPointID() );
-        iscc                   := table.IsInUnit( destisp, ccunit );
+        //璧峰搴撳瓨鐐规槸鍚︽槸澶ц繛(澶ц繛鍘傚唴搴擄級
+        isdl                   := tprow.SourceStockpoingPointID().EndsWith( '鍘傚唴搴�' ) and ( tprow.TargetStockpoingPointID().StartsWith( '澶ц繛' ) or tprow.TargetStockpoingPointID().StartsWith( 'DL' ) );
+        //鐩殑鍦板簱瀛樼偣鏄惁鏄暱鏄ワ紙闀挎槬澶栫搴擄級
+        iscc                   := tprow.TargetStockpoingPointID().EndsWith( '澶栫搴�' ) and ( tprow.TargetStockpoingPointID().StartsWith( '闀挎槬' ) or tprow.TargetStockpoingPointID().StartsWith( 'CC' ) );
         if( isdl and iscc ){
           //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
           enginecosts          := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
-                                                 and engine.Factory() = ccunit );
+                                                 and engine.Factory() = ccfactory );
           //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
           transcosts           := selectset( owner, LogisticsCostTransport, trans, trans.Origin() = tprow.SourceStockpoingPointID() 
                                                   and trans.Destination() = tprow.TargetStockpoingPointID() 
@@ -190,7 +233,7 @@
       salessegment            := forecast.SalesSegment_MP();
       parentsalessegments     := salessegment.GetAllParent();
       //鏄惁灞炰簬闀挎槬
-      iscc                    := salessegment.Name() = ccunit or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = ccunit );
+      iscc                    := salessegment.Name().StartsWith( 'Changechun' ) or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name().StartsWith( 'Changechun' ) );
       if( iscc ){
         product               := forecast.Product_MP();
         productparents        := product.GetAllParent();
@@ -198,7 +241,7 @@
           //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
           enginecosts         := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
-                                                 and engine.Factory() = ccunit );
+                                                 and engine.Factory() = ccfactory );
           if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
             products.Add( forecast.Product_MP() );
             row               := table.GetRow( forecast.ProductID() );
@@ -219,54 +262,7 @@
         }
       }
     }
-    //澶栫搴撲粨鍌ㄨ垂鐢細浠撳偍鏁伴噺/鍖呰瀹归噺*浠撳偍鍗曚环锛屽湪Actual inventories閲屽彇鍒伴暱鏄ュ绉熷簱/澶ц繛澶栫搴撹鍙戝姩鏈虹殑浠撳偍閲忥紝鏍规嵁鍙戝姩鏈哄彿鎵惧埌瀵瑰簲鐨凣eneration 鍜屾í绾靛埗锛屽湪鍙戝姩鏈烘垚鏈弬鏁拌〃閲屾壘鍒板搴旂殑浠撳偍鍗曚环鍜屽寘瑁呭閲忥紝鐢ㄥ叕寮忚绠楋紝鏈堝害杩涜姹囨��
-    traverse( owner, StockingPoint_MP, stockingpoint ){
-      unit                    := stockingpoint.Unit();
-      parentunits             := unit.GetAllParent();
-      //鏄惁灞炰簬闀挎槬澶栫搴�
-      isccrent                := stockingpoint.ID() = ccrent or unit.ID() = ccrent or exists( parentunits, Elements, punit, punit.ID() = ccrent );
-      //鏄惁灞炰簬澶ц繛澶栫搴�
-      isdlrent                := stockingpoint.ID() = dlrent or unit.ID() = dlrent or exists( parentunits, Elements, punit, punit.ID() = dlrent );
-      if( isccrent or isdlrent ){
-        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();
-          if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
-            row               := table.GetRow( pisp.ProductID() );
-            enginecosts       := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() and engine.MLB_MQB() = product.MQBMLB() );
-            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
-              products.Add( pisp.Product_MP() );
-              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" );
-                column        := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
-                cell          := selectobject( row, Cell, cell, cell.Column() = column );
-                
-                if( isccrent ){
-                  //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
-                  enginecost     := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date()
-                                                     and engine.Factory() = ccunit );
-                   if( not isnull( enginecost ) ){
-                     cost        := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
-                     cell.CCRentStorCost( cell.CCRentStorCost() + cost );
-                   }
-                } else {
-                  //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
-                  enginecost     := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date()
-                                                     and engine.Factory() = dlunit  );
-                   if( not isnull( enginecost ) ){
-                     cost        := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
-                     cell.DLRentStorCost( cell.DLRentStorCost() + cost );
-                   }
-                }
-              }   
-            }
-          }
-        }
-      }
-    }
+    
     rows := selectsortedset( table, Row, row, row.Name() );
     i    := 0;
     traverse( rows, Elements, e ){

--
Gitblit v1.9.3