From 3a871621096a949fe8c897b89d9a66d1adb8e110 Mon Sep 17 00:00:00 2001
From: admin <admin@admin.com>
Date: 星期五, 25 十月 2024 13:20:00 +0800
Subject: [PATCH] 料架总数优化

---
 _Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/_Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl b/_Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl
index 40e0407..a95a5bc 100644
--- a/_Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl
+++ b/_Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl
@@ -42,12 +42,25 @@
         lct2 := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Product() = "鍙戝姩鏈烘枡鏋�" and tempLCT.Origin() = "澶ц繛澶栫搴�" and tempLCT.Destination() = "澶ц繛鍘傚唴搴�" );
         lct3 := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Product() = "鍙戝姩鏈烘枡鏋�" and tempLCT.Origin() = "CC 瀹㈡埛搴�" and tempLCT.Destination() = "CC 澶栫搴�" );
         
+        // 绌烘枡鏋舵瘮渚�
+        mrpc := select( macroPlan, MaterialRackProportionRow.MaterialRackProportionCell, tempMRPCell, tempMRPCell.MaterialRackProportionRow().Generation() = "澶ц繛澶栫搴�" and tempMRPCell.MaterialRackColumn().Month() = dlerc.StartDate().Month() );
+        
+        // 瀹㈡埛搴撴枡鏋舵�绘暟閲�
+        mrcc := select( macroPlan, MaterialRackCustomRow.MaterialRackCustomCell, tempMRCCell, tempMRCCell.MaterialRackCustomRow().Generation() = dlerr.Generation() and tempMRCCell.MaterialRackCustomRow().MLB_MQB() = dlerr.MLB_MQB() and tempMRCCell.MaterialRackColumn().Month() = dlerc.StartDate().Month() );
+        
         // 褰撳墠鏈堟湯鏈�鍚庝竴澶╂棩鏈�                
         lastDayOfThisMonth := dlerc.StartDate().StartOfNextMonth() - 1; 
         
         cell := dlerr.DL_EngineRackCell( relnew );
         
-        // 绌烘枡鏋舵暟閲忥細澶ц繛鍘傝浜у搧鐨勬枡鏋舵�绘暟閲� - 鍙戝姩鏈哄簱瀛� / 鍖呰瀹归噺锛堝悜涓婂彇鏁达級
+        // 鏂欐灦鎬绘暟閲�
+        mrtcell := select( macroPlan, MaterialRackTotalRow.MaterialRackTotalCell, tempMRTCell, 
+                           tempMRTCell.MaterialRackTotalRow().Generation() = dlerr.Generation()        and
+                           tempMRTCell.MaterialRackTotalRow().MLB_MQB()    = dlerr.MLB_MQB()           and
+                           tempMRTCell.MaterialRackColumn().Month()        = dlerc.StartDate().Month() );
+        cell.TotalQuantityOfMaterialRacks( mrtcell.Quantity() );
+       
+        // 澶ц繛澶栫搴撶┖鏂欐灦鏁伴噺锛氥��350bar MQB鏂欐灦鎬绘暟閲� - 鎵�鏈�350bar MQB鎬诲簱瀛� / 鍖呰瀹归噺 - 瀹㈡埛搴撴枡鏋舵暟閲忋��* 澶ц繛澶栫搴撶┖鏂欐灦姣斾緥
         plannedInventory := sum( macroPlan, Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod, tempPISPIP,
                                  tempPISPIP.ProductInStockingPoint_MP().Product_MP().IsLeaf()                                                                       and
                                  exists( tempPISPIP.ProductInStockingPoint_MP().Product_MP(), AllParent.AsParent, tempPMP, tempPMP.ID() =  "鍙戝姩鏈�" )               and
@@ -59,7 +72,7 @@
                                  tempPISPIP.PlannedInventoryLevelEnd() );
         cell.PackagingCapacity( guard( lce.PackagingCapacity(), 1 ) );
         cell.PlannedInventory( plannedInventory );
-        cell.NumberOfEmptyShelves( [Number] ( cell.TotalQuantityOfMaterialRacks() - guard( cell.PlannedInventory() / cell.PackagingCapacity(), 0 ) ) );
+        cell.NumberOfEmptyShelves( [Number] guard( ( cell.TotalQuantityOfMaterialRacks() - guard( cell.PlannedInventory() / cell.PackagingCapacity(), 0 ) - guard( mrcc.Quantity(), 0 ) ) * guard( mrpc.Quantity(), 1 ), 0 ) );
         
         // CC澶栫搴撳叆搴撹垂鐢細鍙戝姩鏈洪攢閲� / 鍖呰瀹归噺锛堝悜涓婂彇鏁达級* 鏂欐灦鍏ュ簱鍗曚环
         transportationQuantity1 := sum( macroPlan, SalesDemand.astype( Forecast ), tempF, 
@@ -118,6 +131,7 @@
         // DL澶栫搴撹繍杈撹垂鐢細鍙戝姩鏈鸿繍杈撻噺 / 鍖呰瀹归噺 / 瑁呰浇瀹归噺锛堝悜涓婂彇鏁达級* 鏂欐灦杩愯緭鍗曚环
         cell.DLExternalRentalWarehouseTransportationCosts( [Number] ( guard( inventoryQuantity / lce.PackagingCapacity() / lct2.LoadingCapacity(), 0 ) * guard( lct2.TransportPrice(), 1 ) ) );
         
+        // 澶ц繛澶栫搴撲粨鍌ㄨ垂鐢細銆�350bar MQB鏂欐灦鎬绘暟閲�-鎵�鏈�350bar MQB鎬诲簱瀛�/鍖呰瀹归噺-瀹㈡埛搴撴枡鏋舵暟閲忋��*澶ц繛澶栫搴撶┖鏂欐灦姣斾緥
         // DL澶栫搴撲粨鍌ㄨ垂鐢細鏂欐灦鎬绘暟閲� - 鍙戝姩鏈哄簱瀛� / 鍖呰瀹归噺锛堝悜涓婂彇鏁达級* 绌烘枡鏋朵粨鍌ㄥ崟浠�
         plannedInventory1 := sum( macroPlan, Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod, tempPISPIP,
                                   tempPISPIP.ProductInStockingPoint_MP().Product_MP().IsLeaf()                                                                       and
@@ -128,7 +142,7 @@
                                   tempPISPIP.Start().Date()                                                                              >= dlerc.StartDate()        and 
                                   tempPISPIP.End().Date()                                                                                <= lastDayOfThisMonth,
                                   tempPISPIP.PlannedInventoryLevelEnd() );
-        cell.DLRentalWarehouseStorageFees( [Number] ( guard( ( cell.TotalQuantityOfMaterialRacks() - plannedInventory1 ) / lce.PackagingCapacity(), 0 ) * guard( lcmr.StoragePrice(), 1 ) ) );
+        cell.DLRentalWarehouseStorageFees( [Number] guard( ( cell.TotalQuantityOfMaterialRacks() - guard( plannedInventory1  / lce.PackagingCapacity(), 0 ) - guard( mrcc.Quantity(), 0 ) ) * guard( mrpc.Quantity(), 1 ) * guard( lcmr.StoragePrice(), 1 ), 0 ) );
         
         // CC澶栫搴撴竻娲楄垂鐢細鍙戝姩鏈哄叆搴撻噺 / 鍖呰瀹归噺 * 鏂欐灦娓呮礂鍗曚环銆傚彂鍔ㄦ満鍏ュ簱閲忓彇鍙戝姩鏈洪攢閲忥紝鍖呰瀹归噺鍙栬嚜鍙戝姩鏈烘垚鏈〃銆傛枡鏋舵竻娲楀崟浠峰彇鏂欐灦鎴愭湰琛ㄣ��
         clearnQuantity := sum( macroPlan, SalesDemand.astype( Forecast ), tempF, 

--
Gitblit v1.9.3