From 5100e320ebf1a9de84ce7817ddf57187c130a7bf Mon Sep 17 00:00:00 2001
From: admin <admin@admin.com>
Date: 星期五, 11 十月 2024 13:33:44 +0800
Subject: [PATCH] 大连料架优化

---
 _Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl |   83 ++++++++++++++++++-----------------------
 1 files changed, 37 insertions(+), 46 deletions(-)

diff --git a/_Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl b/_Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl
index 122f650..bffbb04 100644
--- a/_Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl
+++ b/_Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl
@@ -40,6 +40,7 @@
         // 杩愯緭鎴愭湰鍙傛暟
         lct1 := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Product() = "鍙戝姩鏈烘枡鏋�" and tempLCT.Origin() = "闀挎槬澶栫搴�" and tempLCT.Destination() = "DL 鍘傚唴搴�" );
         lct2 := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Product() = "鍙戝姩鏈烘枡鏋�" and tempLCT.Origin() = "澶ц繛澶栫搴�" and tempLCT.Destination() = "DL 鍘傚唴搴�" );
+        lct3 := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Product() = "鍙戝姩鏈烘枡鏋�" and tempLCT.Origin() = "CC 瀹㈡埛搴�" and tempLCT.Destination() = "CC 澶栫搴�" );
         
         // 褰撳墠鏈堟湯鏈�鍚庝竴澶╂棩鏈�                
         lastDayOfThisMonth := dlerc.StartDate().StartOfNextMonth() - 1; 
@@ -48,27 +49,25 @@
         
         // 绌烘枡鏋舵暟閲忥細澶ц繛鍘傝浜у搧鐨勬枡鏋舵�绘暟閲� - 鍙戝姩鏈哄簱瀛� / 鍖呰瀹归噺锛堝悜涓婂彇鏁达級
         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
-                                 tempPISPIP.ProductInStockingPoint_MP().StockingPointID()                                               =  "澶ц繛澶栫搴�"       and
-                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().Generation()                                       =  dlerr.Generation() and
-                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().MQBMLB()                                           =  dlerr.MLB_MQB()    and
-                                 tempPISPIP.Start().Date()                                                                              >= dlerc.StartDate()  and 
+                                 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()                                       =  dlerr.Generation()       and
+                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().MQBMLB()                                           =  dlerr.MLB_MQB()          and
+                                 tempPISPIP.Start().Date()                                                                              >= dlerc.StartDate()        and 
                                  tempPISPIP.End().Date()                                                                                <= lastDayOfThisMonth,
                                  tempPISPIP.PlannedInventoryLevelEnd() );
         cell.PackagingCapacity( guard( lce.PackagingCapacity(), 1 ) );
         cell.PlannedInventory( plannedInventory );
         
         // CC澶栫搴撳叆搴撹垂鐢細鍙戝姩鏈洪攢閲� / 鍖呰瀹归噺锛堝悜涓婂彇鏁达級* 鏂欐灦鍏ュ簱鍗曚环
-        transportationQuantity1 := sum( macroPlan, Unit.Lane.LaneLeg.Trip.ProductInTrip, tempPIT, 
-                                        tempPIT.Product_MP().Generation()                                                =  dlerr.Generation() and
-                                        tempPIT.Product_MP().MQBMLB()                                                    =  dlerr.MLB_MQB()    and
-                                        tempPIT.Trip().Departure().Date()                                                >= dlerc.StartDate()  and
-                                        tempPIT.Trip().Arrival().Date()                                                  <= lastDayOfThisMonth and
-                                        tempPIT.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID()      = "DL 鍘傚唴搴�"         and
-                                        tempPIT.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID() = "闀挎槬澶栫搴�",
-                                        tempPIT.Quantity()
-                                       );
+        transportationQuantity1 := sum( macroPlan, SalesDemand.astype( Forecast ), tempF, 
+                                        tempF.Product_MP().Generation() =  dlerr.Generation()       and
+                                        tempF.Product_MP().MQBMLB()     =  dlerr.MLB_MQB()          and
+                                        tempF.StockingPointID()         =  "澶ц繛鍙戝姩鏈虹殑闀挎槬澶栫搴�" and
+                                        tempF.StartDate()               >= dlerc.StartDate()        and
+                                        tempF.EndDate()                 <= lastDayOfThisMonth,
+                                        tempF.FulfilledQuantity() );
         cell.CCStorageFeesForRentedWarehouses( [Number] ( guard( transportationQuantity1 / lce.PackagingCapacity(), 0 ) * lcmr.WarehousingPrice() ) );
         
         // CC澶栫搴撳嚭搴撹垂鐢細鍙戝姩鏈洪攢閲� / 鍖呰瀹归噺锛堝悜涓婂彇鏁达級* 鏂欐灦鍑哄簱鍗曚环
@@ -79,49 +78,41 @@
         
         // CC闀块�旇繍杈撹垂鐢細璋冩嫧鏁伴噺 / 鍖呰瀹归噺 / 瑁呰浇瀹归噺 * 鏂欐灦杩愯緭鍗曚环
         transportationQuantity2 := sum( macroPlan, Unit.Lane.LaneLeg.Trip.ProductInTrip, tempPIT, 
-                                        tempPIT.Product_MP().Generation()                                                =  dlerr.Generation() and
-                                        tempPIT.Product_MP().MQBMLB()                                                    =  dlerr.MLB_MQB()    and
-                                        tempPIT.Trip().Departure().Date()                                                >= dlerc.StartDate()  and
-                                        tempPIT.Trip().Arrival().Date()                                                  <= lastDayOfThisMonth and
-                                        tempPIT.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID()      = "闀挎槬澶栫搴�"        and
-                                        tempPIT.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID() = "DL 鍘傚唴搴�",
+                                        tempPIT.Product_MP().Generation()                                                =  dlerr.Generation()      and
+                                        tempPIT.Product_MP().MQBMLB()                                                    =  dlerr.MLB_MQB()         and
+                                        tempPIT.Trip().Departure().Date()                                                >= dlerc.StartDate()       and
+                                        tempPIT.Trip().Arrival().Date()                                                  <= lastDayOfThisMonth      and
+                                        tempPIT.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID()      = "DL 鍘傚唴搴�"              and
+                                        tempPIT.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID() = "澶ц繛鍙戝姩鏈虹殑闀挎槬澶栫搴�",
                                         tempPIT.Quantity()
                                        );
         cell.CCLineHaulCost( [Number] ( guard( transportationQuantity2 / lce.PackagingCapacity() / lct1.LoadingCapacity(), 0 ) * guard( lct1.TransportPrice(), 1 ) ) );
         
-        // CC鐭�旇繍杈撹垂鐢細CC瀹㈡埛鍒癈C澶栫搴�
+        // CC鐭�旇繍杈撹垂鐢細璋冩嫧鏁伴噺 / 鍖呰瀹归噺 / 瑁呰浇瀹归噺 * 鏂欐灦杩愯緭鍗曚环
+        cell.CCShortDistanceTransportationCosts( [Number] ( guard( transportationQuantity1 / lce.PackagingCapacity() / lct3.LoadingCapacity(), 0 ) * guard( lct3.TransportPrice(), 1 ) ) )
         
         // DL澶栫搴撳叆搴撹垂鐢細鍙戝姩鏈哄叆搴撻噺 / 鍖呰瀹归噺锛堝悜涓婂彇鏁达級* 鏂欐灦鍏ュ簱鍗曚环
-        engineProductions := sum( macroPlan, FPImportData, tempFPID, 
-                                  tempFPID.Unit()              = FinancialProductionReport::GetDefaultDLUnit() and
-                                  tempFPID.Generation()        = dlerr.Generation()                            and
-                                  tempFPID.MqbMlb()            = dlerr.MLB_MQB()                               and
-                                  tempFPID.StartDate().Year()  = dlerc.StartDate().Year()                      and
-                                  tempFPID.StartDate().Month() = dlerc.StartDate().Month(),
-                                  tempFPID.Quantity() );
+        engineProductions := sum( macroPlan, SalesDemand.astype( Forecast ), tempF, 
+                                  tempF.Product_MP().Generation() =  dlerr.Generation()       and
+                                  tempF.Product_MP().MQBMLB()     =  dlerr.MLB_MQB()          and
+                                  tempF.StockingPointID()         =  "澶ц繛澶栫搴�"             and
+                                  tempF.StartDate()               >= dlerc.StartDate()        and
+                                  tempF.EndDate()                 <= lastDayOfThisMonth,
+                                  tempF.FulfilledQuantity() );
         cell.DLStorageFeesForRentedWarehouses( [Number] ( guard( ( engineProductions - transportationQuantity1 ) / lce.PackagingCapacity(), 0 ) * guard( lcmr.WarehousingPrice(), 1 ) ) );
         
         // DL澶栫搴撳嚭搴撹垂鐢細鍙戝姩鏈哄嚭搴撻噺 / 鏂欐灦瀹归噺锛堝悜涓婂彇鏁达級* 鏂欐灦鍑哄簱鍗曚环
-        engineSales := sum( macroPlan, FSImportData, tempFSID, 
-                            tempFSID.Unit()              = FinancialProductionReport::GetDefaultCCUnit() and
-                            tempFSID.Generation()        = dlerr.Generation()                            and
-                            tempFSID.MqbMlb()            = dlerr.MLB_MQB()                               and
-                            tempFSID.StartDate().Year()  = dlerc.StartDate().Year()                      and
-                            tempFSID.StartDate().Month() = dlerc.StartDate().Month(),
-                            tempFSID.Quantity() );
+        engineSales := sum( macroPlan, Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), tempPISPIPPL,
+                            tempPISPIPPL.ProductInStockingPoint_MP().Product_MP().Generation() = dlerr.Generation()  and
+                            tempPISPIPPL.ProductInStockingPoint_MP().Product_MP().MQBMLB()     = dlerr.MLB_MQB()     and
+                            tempPISPIPPL.ProductInStockingPoint_MP().StockingPointID()         = "澶ц繛澶栫搴�"        and
+                            tempPISPIPPL.Start().Date()                                        >= dlerc.StartDate()  and
+                            tempPISPIPPL.End().Date()                                          <= lastDayOfThisMonth,
+                            tempPISPIPPL.NewSupplyQuantity() );
         cell.DLOutboundExpensesForRentedWarehouses( [Number] ( guard( ( engineSales - transportationQuantity1 ) / lce.PackagingCapacity(), 0 ) * guard( lcmr.OutboundPrice(), 1 ) ) );
         
         // DL澶栫搴撹繍杈撹垂鐢細鍙戝姩鏈鸿繍杈撻噺 / 鍖呰瀹归噺 / 瑁呰浇瀹归噺锛堝悜涓婂彇鏁达級* 鏂欐灦杩愯緭鍗曚环
-        transportationQuantity3 := sum( macroPlan, Unit.Lane.LaneLeg.Trip.ProductInTrip, tempPIT, 
-                                        tempPIT.Product_MP().Generation()                                                =  dlerr.Generation() and
-                                        tempPIT.Product_MP().MQBMLB()                                                    =  dlerr.MLB_MQB()    and
-                                        tempPIT.Trip().Departure().Date()                                                >= dlerc.StartDate()  and
-                                        tempPIT.Trip().Arrival().Date()                                                  <= lastDayOfThisMonth and
-                                        tempPIT.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID()      = "澶ц繛澶栫搴�"        and
-                                        tempPIT.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID() = "DL 鍘傚唴搴�",
-                                        tempPIT.Quantity()
-                                       );
-        cell.DLExternalRentalWarehouseTransportationCosts( [Number] ( guard( transportationQuantity3 / lce.PackagingCapacity() / lct2.LoadingCapacity(), 0 ) * guard( lct2.TransportPrice(), 1 ) ) );
+        cell.DLExternalRentalWarehouseTransportationCosts( [Number] ( guard( engineSales / lce.PackagingCapacity() / lct2.LoadingCapacity(), 0 ) * guard( lct2.TransportPrice(), 1 ) ) );
         
         // DL澶栫搴撲粨鍌ㄨ垂鐢細鏂欐灦鎬绘暟閲� - 鍙戝姩鏈哄簱瀛� / 鍖呰瀹归噺锛堝悜涓婂彇鏁达級* 绌烘枡鏋朵粨鍌ㄥ崟浠�
         cell.DLRentalWarehouseStorageFees( [Number] ( guard( ( cell.TotalQuantityOfMaterialRacks() - plannedInventory ) / lce.PackagingCapacity(), 0 ) * guard( lcmr.StoragePrice(), 1 ) ) );

--
Gitblit v1.9.3