From f02b0d3f28293029ab1da8220e7a984de8dea645 Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期三, 09 十月 2024 17:53:55 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/VWED into dev

---
 _Main/BL/Type_CC_EngineRackCell/StaticMethod_CreateData.qbl |   80 ++++++++++++++++++++++++----------------
 1 files changed, 48 insertions(+), 32 deletions(-)

diff --git a/_Main/BL/Type_CC_EngineRackCell/StaticMethod_CreateData.qbl b/_Main/BL/Type_CC_EngineRackCell/StaticMethod_CreateData.qbl
index f05cadc..f17862c 100644
--- a/_Main/BL/Type_CC_EngineRackCell/StaticMethod_CreateData.qbl
+++ b/_Main/BL/Type_CC_EngineRackCell/StaticMethod_CreateData.qbl
@@ -12,8 +12,8 @@
     // 鍒涘缓琛�
     genrations := selectuniquevalues( macroPlan, Product_MP, tempPMP, tempPMP.Generation().TrimBoth() <> "", tempPMP.Generation() );
     mqbmlbs    := selectuniquevalues( macroPlan, Product_MP, tempPMP, tempPMP.MQBMLB().TrimBoth() <> "", tempPMP.MQBMLB() );
-    traverse ( genrations, Elements, g, g.ToUpper() = "EVO5" or g.ToUpper() = "GEN3" ) {
-      traverse ( mqbmlbs, Elements, m, m.ToUpper() = "MLB" or m.ToUpper() = "MQB" ) {
+    traverse ( genrations, Elements, g ) {
+      traverse ( mqbmlbs, Elements, m ) {
         macroPlan.CC_EngineRackRow( relnew, Generation := g, MLB_MQB := m );
       }
     }
@@ -26,58 +26,74 @@
     }
     
     // 鍒涘缓鍗曞厓鏍�
-    traverse ( macroPlan, CC_EngineRackRow, ccerr ) {
-      
-      // 鍙戝姩鏈烘垚鏈弬鏁�
-      lce  := select( macroPlan, LogisticsCostEngine, tempLCE, tempLCE.Generation() = ccerr.Generation() and tempLCE.MLB_MQB() = ccerr.MLB_MQB() and tempLCE.Factory() = "闀挎槬宸ュ巶" );
-      
-      // 鏂欐灦鎴愭湰鍙傛暟
-      lcmr := select( macroPlan, LogisticsCostMaterialRack, tempLCMR, tempLCMR.Factory() = "闀挎槬宸ュ巶" );
-      
-      traverse ( macroPlan, CC_EngineRackColumn, ccerc ) {
+    traverse ( macroPlan, CC_EngineRackRow, ccerr ) { // 寰幆琛�
+      info( "褰撳墠閬嶅巻鐨勮锛�", ccerr.Generation(), " ", ccerr.MLB_MQB() );
+      traverse ( macroPlan, CC_EngineRackColumn, ccerc ) { // 寰幆鍒�
+        // 鍙戝姩鏈烘垚鏈弬鏁�
+        lce  := select( macroPlan, LogisticsCostEngine, tempLCE, tempLCE.Generation() = ccerr.Generation() and tempLCE.MLB_MQB() = ccerr.MLB_MQB() and tempLCE.Factory() = "闀挎槬宸ュ巶" 
+                        and tempLCE.StartDate() <= ccerc.StartDate() and tempLCE.EndDate() >= ccerc.StartDate().StartOfNextMonth() );
+        
+        // 鏂欐灦鎴愭湰鍙傛暟
+        lcmr := select( macroPlan, LogisticsCostMaterialRack, tempLCMR, tempLCMR.Factory() = "闀挎槬宸ュ巶" 
+                        and tempLCMR.StartDate() <= ccerc.StartDate() and tempLCMR.EndDate() >= ccerc.StartDate().StartOfNextMonth() );
+                        
+        // 杩愯緭鎴愭湰鍙傛暟
+        lct  := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Product() = "鍙戝姩鏈�" and tempLCT.Origin() = "CC 鍘傚唴搴�" and tempLCT.Destination() = "闀挎槬澶栫搴�" );
+        
+        // 褰撳墠鏈堟湯鏈�鍚庝竴澶╂棩鏈�                
+        lastDayOfThisMonth := ccerc.StartDate().StartOfNextMonth() - 1; 
+        
         cell := ccerr.CC_EngineRackCell( relnew );
         
         // 绌烘枡鏋舵暟閲忥紙闀挎槬鍘傝浜у搧鐨勬枡鏋舵�绘暟閲� - 鍙戝姩鏈哄簱瀛� / 鍖呰瀹归噺 锛�
-        lastDayOfThisMonth := ccerc.StartDate().StartOfNextMonth() - 1;
         plannedInventory := sum( macroPlan, Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod, tempPISPIP,
-                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().IsLeaf()                          and
-                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().ParentID()   = "浜ф垚鍝�"           and
-                                 tempPISPIP.ProductInStockingPoint_MP().StockingPointID()         = "闀挎槬澶栫搴�"       and
-                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().Generation() = ccerr.Generation() and
-                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().MQBMLB()     = ccerr.MLB_MQB()    and
-                                 tempPISPIP.Start().Date()                                                  = lastDayOfThisMonth,
+                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().IsLeaf()                                                                and
+                                 exists( tempPISPIP.ProductInStockingPoint_MP().Product_MP(), AllParent.AsParent, tempPMP, tempPMP.ID() = "鍙戝姩鏈�" )         and
+                                 tempPISPIP.ProductInStockingPoint_MP().StockingPointID()                                               = "闀挎槬澶栫搴�"       and
+                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().Generation()                                       = ccerr.Generation() and
+                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().MQBMLB()                                           = ccerr.MLB_MQB()    and
+                                 tempPISPIP.Start().Date()                                                                              = lastDayOfThisMonth,
                                  tempPISPIP.PlannedInventoryLevelEnd() );
-        cell.PackagingCapacity( guard( lce.PackagingCapacity(), 0 ) );
+        cell.PackagingCapacity( guard( lce.PackagingCapacity(), 1 ) );
         cell.PlannedInventory( plannedInventory );
         
         // 澶栫搴撳叆搴撹垂鐢紙鍙戝姩鏈洪攢閲� / 鍖呰瀹归噺[鍚戜笂鍙栨暣] * 鏂欐灦鍏ュ簱鍗曚环锛�
         engineSales := sum( macroPlan, FSImportData, tempFSID, 
-                            tempFSID.Unit()              = "闀挎槬宸ュ巶"               and
-                            tempFSID.Generation()        = ccerr.Generation()       and
-                            tempFSID.MqbMlb()            = ccerr.MLB_MQB()          and
-                            tempFSID.StartDate().Year()  = ccerc.StartDate().Year() and
+                            tempFSID.Unit()              = FinancialProductionReport::GetDefaultCCUnit() and
+                            tempFSID.Generation()        = ccerr.Generation()                            and
+                            tempFSID.MqbMlb()            = ccerr.MLB_MQB()                               and
+                            tempFSID.StartDate().Year()  = ccerc.StartDate().Year()                      and
                             tempFSID.StartDate().Month() = ccerc.StartDate().Month(),
                             tempFSID.Quantity() );
-        cell.StorageFeesForRentedWarehouses( guard( [Number] ( engineSales / guard( lce.PackagingCapacity(), 0 ) ) * guard( lcmr.WarehousingPrice(), 0 ), 0 ) );
+        cell.StorageFeesForRentedWarehouses( [Number] ( engineSales / guard( lce.PackagingCapacity(), 1 ) * guard( lcmr.WarehousingPrice(), 1 ) ) );
              
         // 澶栫搴撳嚭搴撹垂鐢紙鍙戝姩鏈轰骇閲� / 鍖呰瀹归噺[鍚戜笂鍙栨暣] * 鏂欐灦鍑哄簱鍗曚环锛�
         engineProductions := sum( macroPlan, FPImportData, tempFPID, 
-                                  tempFPID.Unit()              = "闀挎槬宸ュ巶"               and
-                                  tempFPID.Generation()        = ccerr.Generation()       and
-                                  tempFPID.MqbMlb()            = ccerr.MLB_MQB()          and
-                                  tempFPID.StartDate().Year()  = ccerc.StartDate().Year() and
+                                  tempFPID.Unit()              = FinancialProductionReport::GetDefaultCCUnit() and
+                                  tempFPID.Generation()        = ccerr.Generation()                            and
+                                  tempFPID.MqbMlb()            = ccerr.MLB_MQB()                               and
+                                  tempFPID.StartDate().Year()  = ccerc.StartDate().Year()                      and
                                   tempFPID.StartDate().Month() = ccerc.StartDate().Month(),
                                   tempFPID.Quantity() );
-        cell.OutboundExpensesForRentedWarehouses( guard( [Number] ( engineProductions / guard( lce.PackagingCapacity(), 0 ) ) * guard( lcmr.OutboundPrice(), 0 ), 0 ) );
+        cell.OutboundExpensesForRentedWarehouses( [Number] ( engineProductions / guard( lce.PackagingCapacity(), 1 ) ) * guard( lcmr.OutboundPrice(), 1 ) );
         
         // 澶栫搴撹繍杈撹垂鐢細鍙戝姩鏈鸿繍杈撻噺 / 鍖呰瀹归噺 / 瑁呰浇瀹归噺锛堝悜涓婂彇鏁达級 * 鏂欐灦杩愯緭鍗曚环
-        
-        
+        transportationQuantity := sum( macroPlan, Unit.Lane.LaneLeg.Trip.ProductInTrip, tempPIT, 
+                                       tempPIT.Product_MP().Generation()                                                =  ccerr.Generation() and
+                                       tempPIT.Product_MP().MQBMLB()                                                    =  ccerr.MLB_MQB()    and
+                                       tempPIT.Trip().Departure().Date()                                                >= ccerc.StartDate()  and
+                                       tempPIT.Trip().Arrival().Date()                                                  <= lastDayOfThisMonth and
+                                       tempPIT.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID()      = "CC 鍘傚唴搴�"         and
+                                       tempPIT.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID() = "闀挎槬澶栫搴�",
+                                       tempPIT.Quantity()
+                                      );
+        cell.ExternalRentalWarehouseTransportationCosts( transportationQuantity / guard( lce.PackagingCapacity(), 1 ) / guard( lct.LoadingCapacity(), 1 ) * guard( lct.TransportPrice(), 1 ) );
+             
         // 澶栫搴撲粨鍌ㄨ垂鐢細鏂欐灦鎬绘暟閲� - 鍙戝姩鏈哄簱瀛� / 鍖呰瀹归噺锛堝悜涓婂彇鏁达級锛屽啀涔樹互绌烘枡鏋朵粨鍌ㄥ崟浠峰緱鍒扮┖鏂欐灦浠撳偍璐圭敤銆傚彂鍔ㄦ満搴撳瓨鍙朅ctual inventories閲屽彇鍒伴暱鏄ュ绉熷簱璇ュ彂鍔ㄦ満鐨勪粨鍌ㄩ噺锛屾枡鏋舵�绘暟閲忛渶瑕佹墜鍔ㄧ淮鎶ゃ��
         cell.UnitPriceOfEmptyShelfStorage( lcmr.StoragePrice() );
         
         // 娓呮礂璐圭敤锛氬彂鍔ㄦ満鍏ュ簱閲� / 鍖呰瀹归噺 * 鏂欐灦娓呮礂鍗曚环銆傚彂鍔ㄦ満鍏ュ簱閲忓彇鍙戝姩鏈洪攢閲忥紝鍖呰瀹归噺鍙栬嚜鍙戝姩鏈烘垚鏈〃銆傛枡鏋舵竻娲楀崟浠峰彇鏂欐灦鎴愭湰琛ㄣ��
-        cell.CleaningCost( guard( engineSales / guard( lce.PackagingCapacity(), 0 ) * lcmr.CleanPrice(), 0 ) );
+        cell.CleaningCost( engineSales / guard( lce.PackagingCapacity(), 1 ) * lcmr.CleanPrice() );
         
         cell.CC_EngineRackColumn( relset, ccerc );
       }

--
Gitblit v1.9.3