From 8271787feb2fc9e74a4e814bd43f93aef91a1f54 Mon Sep 17 00:00:00 2001
From: admin <admin@admin.com>
Date: 星期四, 10 十月 2024 19:54:03 +0800
Subject: [PATCH] 长春料架优化

---
 /dev/null                                                   |   13 ------
 _Main/BL/Type_CC_EngineRackCell/StaticMethod_CreateData.qbl |   53 +++++++++++++++++++++++++-
 _Main/BL/Type_CC_EngineRackCell/StaticMethod_Export.qbl     |    4 +-
 _Main/BL/Type_CC_EngineRackRow/Attribute_Index.qbl          |    7 +++
 4 files changed, 60 insertions(+), 17 deletions(-)

diff --git a/_Main/BL/Type_CC_EngineRackCell/Function_CalcEstimatedTotalCost.qbl b/_Main/BL/Type_CC_EngineRackCell/Function_CalcEstimatedTotalCost.qbl
deleted file mode 100644
index 1c8e4cb..0000000
--- a/_Main/BL/Type_CC_EngineRackCell/Function_CalcEstimatedTotalCost.qbl
+++ /dev/null
@@ -1,17 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Function CalcEstimatedTotalCost
-{
-  TextBody:
-  [*
-    // lihongji Oct-9-2024 (created)
-    
-    value := this.StorageFeesForRentedWarehouses()             + 
-             this.OutboundExpensesForRentedWarehouses()        + 
-             this.ExternalRentalWarehouseTransportationCosts() + 
-             this.RentalWarehouseStorageFees()                 +
-             this.CleaningCost()
-    
-    this.EstimatedTotalCost( value );
-  *]
-}
diff --git a/_Main/BL/Type_CC_EngineRackCell/Function_CalcNumberOfEmptyShelves.qbl b/_Main/BL/Type_CC_EngineRackCell/Function_CalcNumberOfEmptyShelves.qbl
deleted file mode 100644
index 8970d55..0000000
--- a/_Main/BL/Type_CC_EngineRackCell/Function_CalcNumberOfEmptyShelves.qbl
+++ /dev/null
@@ -1,13 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Function CalcNumberOfEmptyShelves
-{
-  TextBody:
-  [*
-    // vwedadmin Aug-20-2024 (created)
-    
-    value := guard( [Number] ( this.TotalQuantityOfMaterialRacks() - ( this.PlannedInventory() / this.PackagingCapacity() ) ), 0 );
-    
-    this.NumberOfEmptyShelves( value );
-  *]
-}
diff --git a/_Main/BL/Type_CC_EngineRackCell/Function_CalcRentalWarehouseStorageFees.qbl b/_Main/BL/Type_CC_EngineRackCell/Function_CalcRentalWarehouseStorageFees.qbl
deleted file mode 100644
index 12e3b4c..0000000
--- a/_Main/BL/Type_CC_EngineRackCell/Function_CalcRentalWarehouseStorageFees.qbl
+++ /dev/null
@@ -1,13 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Function CalcRentalWarehouseStorageFees
-{
-  TextBody:
-  [*
-    // vwedadmin Aug-25-2024 (created)
-    
-    value := guard( ( this.TotalQuantityOfMaterialRacks() - [Number]( this.PlannedInventory() / this.PackagingCapacity() ) ) * this.UnitPriceOfEmptyShelfStorage(), 0 );
-    
-    this.RentalWarehouseStorageFees( value );
-  *]
-}
diff --git a/_Main/BL/Type_CC_EngineRackCell/Function_CalcTotalCost.qbl b/_Main/BL/Type_CC_EngineRackCell/Function_CalcTotalCost.qbl
deleted file mode 100644
index 06eaa74..0000000
--- a/_Main/BL/Type_CC_EngineRackCell/Function_CalcTotalCost.qbl
+++ /dev/null
@@ -1,13 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Function CalcTotalCost
-{
-  TextBody:
-  [*
-    // lihongji Oct-9-2024 (created)
-    
-    value := this.EstimatedTotalCost() * this.Coefficient();
-    
-    this.TotalCost( value );
-  *]
-}
diff --git a/_Main/BL/Type_CC_EngineRackCell/StaticMethod_CreateData.qbl b/_Main/BL/Type_CC_EngineRackCell/StaticMethod_CreateData.qbl
index 9a3cdd1..aa152d7 100644
--- a/_Main/BL/Type_CC_EngineRackCell/StaticMethod_CreateData.qbl
+++ b/_Main/BL/Type_CC_EngineRackCell/StaticMethod_CreateData.qbl
@@ -9,12 +9,21 @@
     macroPlan.CC_EngineRackRow( relflush );
     macroPlan.CC_EngineRackColumn( relflush );
     
+    sumNumberOfEmptyShelves                       := 0.0;
+    sumStorageFeesForRentedWarehouses             := 0.0;
+    sumOutboundExpensesForRentedWarehouses        := 0.0;
+    sumExternalRentalWarehouseTransportationCosts := 0.0;
+    sumRentalWarehouseStorageFees                 := 0.0;
+    sumCleaningCost                               := 0.0;
+    sumEstimatedTotalCost                         := 0.0;
+    sumTotalCost                                  := 0.0;
+    
     // 鍒涘缓琛�
     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 ) {
       traverse ( mqbmlbs, Elements, m ) {
-        macroPlan.CC_EngineRackRow( relnew, Generation := g, MLB_MQB := m );
+        macroPlan.CC_EngineRackRow( relnew, Generation := g, MLB_MQB := m, Index := 1  );
       }
     }
     
@@ -56,6 +65,8 @@
                                  tempPISPIP.PlannedInventoryLevelEnd() );
         cell.PackagingCapacity( guard( lce.PackagingCapacity(), 1 ) );
         cell.PlannedInventory( plannedInventory );
+        cell.NumberOfEmptyShelves( guard( [Number] ( cell.TotalQuantityOfMaterialRacks() - ( plannedInventory / lce.PackagingCapacity() ) ), 0 ) );
+        sumNumberOfEmptyShelves := sumNumberOfEmptyShelves + cell.NumberOfEmptyShelves();
         
         // 澶栫搴撳叆搴撹垂鐢紙鍙戝姩鏈洪攢閲� / 鍖呰瀹归噺[鍚戜笂鍙栨暣] * 鏂欐灦鍏ュ簱鍗曚环锛�
         engineSales := sum( macroPlan, FSImportData, tempFSID, 
@@ -65,8 +76,8 @@
                             tempFSID.StartDate().Year()  = ccerc.StartDate().Year()                      and
                             tempFSID.StartDate().Month() = ccerc.StartDate().Month(),
                             tempFSID.Quantity() );
-        
         cell.StorageFeesForRentedWarehouses( [Number] ( engineSales / guard( lce.PackagingCapacity(), 1 ) * guard( lcmr.WarehousingPrice(), 1 ) ) );
+        sumStorageFeesForRentedWarehouses := sumStorageFeesForRentedWarehouses + cell.StorageFeesForRentedWarehouses();
              
         // 澶栫搴撳嚭搴撹垂鐢紙鍙戝姩鏈轰骇閲� / 鍖呰瀹归噺[鍚戜笂鍙栨暣] * 鏂欐灦鍑哄簱鍗曚环锛�
         engineProductions := sum( macroPlan, FPImportData, tempFPID, 
@@ -77,6 +88,7 @@
                                   tempFPID.StartDate().Month() = ccerc.StartDate().Month(),
                                   tempFPID.Quantity() );
         cell.OutboundExpensesForRentedWarehouses( [Number] ( engineProductions / guard( lce.PackagingCapacity(), 1 ) ) * guard( lcmr.OutboundPrice(), 1 ) );
+        sumOutboundExpensesForRentedWarehouses := sumOutboundExpensesForRentedWarehouses + cell.OutboundExpensesForRentedWarehouses();
         
         // 澶栫搴撹繍杈撹垂鐢細鍙戝姩鏈鸿繍杈撻噺 / 鍖呰瀹归噺 / 瑁呰浇瀹归噺锛堝悜涓婂彇鏁达級 * 鏂欐灦杩愯緭鍗曚环
         transportationQuantity := sum( macroPlan, Unit.Lane.LaneLeg.Trip.ProductInTrip, tempPIT, 
@@ -90,15 +102,52 @@
                                       );
     //    info( "鏃堕棿锛�", ccerc.StartDate().Format( "Y-M2-D2" ), "    杩愯緭鏁版嵁锛�", transportationQuantity, "     杩愯緭鍗曚环锛�", lct.TransportPrice() );
         cell.ExternalRentalWarehouseTransportationCosts( transportationQuantity / guard( lce.PackagingCapacity(), 1 ) / guard( lct.LoadingCapacity(), 1 ) * guard( lct.TransportPrice(), 1 ) );
+        sumExternalRentalWarehouseTransportationCosts := sumExternalRentalWarehouseTransportationCosts + cell.ExternalRentalWarehouseTransportationCosts();
              
         // 澶栫搴撲粨鍌ㄨ垂鐢細鏂欐灦鎬绘暟閲� - 鍙戝姩鏈哄簱瀛� / 鍖呰瀹归噺锛堝悜涓婂彇鏁达級锛屽啀涔樹互绌烘枡鏋朵粨鍌ㄥ崟浠峰緱鍒扮┖鏂欐灦浠撳偍璐圭敤銆傚彂鍔ㄦ満搴撳瓨鍙朅ctual inventories閲屽彇鍒伴暱鏄ュ绉熷簱璇ュ彂鍔ㄦ満鐨勪粨鍌ㄩ噺锛屾枡鏋舵�绘暟閲忛渶瑕佹墜鍔ㄧ淮鎶ゃ��
         cell.UnitPriceOfEmptyShelfStorage( lcmr.StoragePrice() );
+        cell.RentalWarehouseStorageFees( guard( ( cell.TotalQuantityOfMaterialRacks() - [Number]( plannedInventory / lce.PackagingCapacity() ) ) * lcmr.StoragePrice(), 0 ) );
+        sumRentalWarehouseStorageFees := sumRentalWarehouseStorageFees + cell.RentalWarehouseStorageFees();
         
         // 娓呮礂璐圭敤锛氬彂鍔ㄦ満鍏ュ簱閲� / 鍖呰瀹归噺 * 鏂欐灦娓呮礂鍗曚环銆傚彂鍔ㄦ満鍏ュ簱閲忓彇鍙戝姩鏈洪攢閲忥紝鍖呰瀹归噺鍙栬嚜鍙戝姩鏈烘垚鏈〃銆傛枡鏋舵竻娲楀崟浠峰彇鏂欐灦鎴愭湰琛ㄣ��
         cell.CleaningCost( engineSales / guard( lce.PackagingCapacity(), 1 ) * lcmr.CleanPrice() );
+        sumCleaningCost := sumCleaningCost + cell.CleaningCost();
+        
+        // 棰勮鎬昏垂鐢�
+        cell.EstimatedTotalCost( cell.StorageFeesForRentedWarehouses()             + 
+                                 cell.OutboundExpensesForRentedWarehouses()        + 
+                                 cell.ExternalRentalWarehouseTransportationCosts() + 
+                                 cell.RentalWarehouseStorageFees()                 +
+                                 cell.CleaningCost()
+                                );
+        sumEstimatedTotalCost := sumEstimatedTotalCost + cell.EstimatedTotalCost();
+                                
+        // 绯绘暟
+        cell.Coefficient( 1 );
+        
+        // 鎬昏垂鐢�
+        cell.TotalCost( cell.EstimatedTotalCost() * cell.Coefficient() );
+        sumTotalCost := sumTotalCost + cell.TotalCost();
         
         cell.CC_EngineRackColumn( relset, ccerc );
       }
     }
+    
+    // 鍒涘缓SUM琛�
+    sumR := macroPlan.CC_EngineRackRow( relnew, Generation := "SUM", MLB_MQB := "", Index := 2 );
+    traverse ( macroPlan, CC_EngineRackColumn, ccerc ) {
+      cell := sumR.CC_EngineRackCell( relnew );
+      
+      cell.NumberOfEmptyShelves( sumNumberOfEmptyShelves );
+      cell.StorageFeesForRentedWarehouses( sumStorageFeesForRentedWarehouses );
+      cell.OutboundExpensesForRentedWarehouses( sumOutboundExpensesForRentedWarehouses );
+      cell.ExternalRentalWarehouseTransportationCosts( sumExternalRentalWarehouseTransportationCosts );
+      cell.RentalWarehouseStorageFees( sumRentalWarehouseStorageFees );
+      cell.CleaningCost( sumCleaningCost );
+      cell.EstimatedTotalCost( sumEstimatedTotalCost );
+      cell.TotalCost( sumTotalCost );
+      
+      cell.CC_EngineRackColumn( relset, ccerc );
+    }
   *]
 }
diff --git a/_Main/BL/Type_CC_EngineRackCell/StaticMethod_Export.qbl b/_Main/BL/Type_CC_EngineRackCell/StaticMethod_Export.qbl
index 8ce70a3..1d83bd4 100644
--- a/_Main/BL/Type_CC_EngineRackCell/StaticMethod_Export.qbl
+++ b/_Main/BL/Type_CC_EngineRackCell/StaticMethod_Export.qbl
@@ -12,7 +12,7 @@
     tableElement := xmlDOM.GetElementByTagName( "table", 0 );
     
     // 绗竴鍒楋紙鍚嶇О锛�
-    cerrs       := selectsortedset( macroPlan, CC_EngineRackRow, tempCERR, true, tempCERR.Name() );
+    cerrs       := selectsortedset( macroPlan, CC_EngineRackRow, tempCERR, true, tempCERR.Index(), tempCERR.Name() );
     firstColumn := xmlDOM.CreateElement( "column" );
     firstName   := xmlDOM.CreateElement( "name" );
     firstType   := xmlDOM.CreateElement( "type" );
@@ -63,7 +63,7 @@
       cellType.TextContent( "Number" );
       cellColumn.AppendChild( cellName );
       cellColumn.AppendChild( cellType );
-      cells := selectsortedset( cerc, CC_EngineRackCell, tempCELL, true, tempCELL.CC_EngineRackRow().Name() );
+      cells := selectsortedset( cerc, CC_EngineRackCell, tempCELL, true, tempCELL.CC_EngineRackRow().Index(), tempCELL.CC_EngineRackRow().Name() );
       traverse ( cells, Elements, c ) {
         cell := xmlDOM.CreateElement( "cell" );
         cell.SetAttribute( "value", [String]c.TotalQuantityOfMaterialRacks().Round( 0 ) ); // 鏂欐灦鎬绘暟閲�
diff --git a/_Main/BL/Type_CC_EngineRackRow/Attribute_Index.qbl b/_Main/BL/Type_CC_EngineRackRow/Attribute_Index.qbl
new file mode 100644
index 0000000..7a6c5ba
--- /dev/null
+++ b/_Main/BL/Type_CC_EngineRackRow/Attribute_Index.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute Index
+{
+  #keys: '3[415754.0.356027162][415754.0.356027161][415754.0.356027163]'
+  ValueType: Number
+}

--
Gitblit v1.9.3