From b3b09d31287fc40eecc28d78575ba0bd1d8b03ea Mon Sep 17 00:00:00 2001
From: lihongji <3117313295@qq.com>
Date: 星期五, 18 十月 2024 14:28:19 +0800
Subject: [PATCH] 包装计划优化

---
 _Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl |   79 ++++++++++++++++++++++++---------------
 1 files changed, 48 insertions(+), 31 deletions(-)

diff --git a/_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl b/_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl
index 684958f..dac2ffe 100644
--- a/_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl
+++ b/_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl
@@ -36,43 +36,39 @@
         
         // 杩愯緭鎴愭湰鍙傛暟
         lct  := select( macroPlan, LogisticsCostTransport, tempLCT, 
-                        tempLCT.Product()     = mlcrr.Category()                                      and 
-                        tempLCT.Origin()      = mlcrr.Factory() + " " + mlcrr.Category() + "澶栫搴�"   and 
-                        tempLCT.Destination() = mlcrr.Factory() + " " + mlcrr.Category() + "绾胯竟搴�" );
-        lct1 := select( macroPlan, LogisticsCostTransport, tempLCT, 
-                        tempLCT.Product()     = mlcrr.Category()                                                   and 
-                        tempLCT.Origin()      = ifexpr( mlcrr.Factory() = "澶ц繛宸ュ巶", "澶ц繛鍘傚唴搴�", "CC 鍘傚唴搴�" ) and 
-                        tempLCT.Destination() = ifexpr( mlcrr.Factory() = "澶ц繛宸ュ巶", "澶ц繛澶栫搴�", "闀挎槬澶栫搴�" ) );
-                        
-         // 褰撳墠鏈堟湯鏈�鍚庝竴澶╂棩鏈�                
-        lastDayOfThisMonth := mlcrc.StartDate().StartOfNextMonth() - 1; 
-        
+                        tempLCT.Product()     = mlcrr.Category()                                                                                                                         and
+                        tempLCT.Origin()      = ifexpr( mlcrr.Category() = "AGW", "DL AGW", ifexpr( mlcrr.Factory() = "澶ц繛宸ュ巶", "DL", "CC" ) + " " + mlcrr.Category() + "澶栫搴�" )     and
+                        tempLCT.Destination() = ifexpr( mlcrr.Category() = "AGW", "CC AGW搴撴埧", ifexpr( mlcrr.Factory() = "澶ц繛宸ュ巶", "DL", "CC" ) + " " + mlcrr.Category() + "绾胯竟搴�" ) );
+
+         // 褰撳墠鏈堟湯鏈�鍚庝竴澶╂棩鏈�
+        lastDayOfThisMonth := mlcrc.StartDate().StartOfNextMonth() - 1;
+
         cell := mlcrr.MachineLogisticsCostReportCell( relnew );
-          
+
         // 璁剧疆鍖呰璐圭敤锛堝寘瑁呴噺 * 鍖呰鍗曚环锛�
-        packageQuantity := sum( macroPlan, PackagingPlanRow.PackagingPlanCell, tempPPC, 
+        packageQuantity := sum( macroPlan, PackagingPlanRow.PackagingPlanCell, tempPPC,
                                 tempPPC.PackagingPlanRow().Category()             = mlcrr.Category()          and
                                 tempPPC.PackagingPlanRow().Factory()              = mlcrr.Factory()           and
                                 tempPPC.PackagingPlanColumn().StartDate().Year()  = mlcrc.StartDate().Year()  and
                                 tempPPC.PackagingPlanColumn().StartDate().Month() = mlcrc.StartDate().Month(),
                                 tempPPC.Package() );
         cell.PackingCharges( packageQuantity * guard( lcm.PackagePrice(), 1 ) );
-          
+
         // 璁剧疆鎷嗗寘璐圭敤锛堟媶鍖呴噺 * 鎷嗗寘鍗曚环锛�
-        unpackingQuantity := sum( macroPlan, PackagingPlanRow.PackagingPlanCell, tempPPC, 
+        unpackingQuantity := sum( macroPlan, PackagingPlanRow.PackagingPlanCell, tempPPC,
                                   tempPPC.PackagingPlanRow().Category()             = mlcrr.Category()          and
                                   tempPPC.PackagingPlanRow().Factory()              = mlcrr.Factory()           and
                                   tempPPC.PackagingPlanColumn().StartDate().Year()  = mlcrc.StartDate().Year()  and
                                   tempPPC.PackagingPlanColumn().StartDate().Month() = mlcrc.StartDate().Month(),
                                   tempPPC.Unpacking() );
         cell.UnpackingCost( unpackingQuantity * guard( lcm.UnpackingPrice(), 1 ) );
-          
+
         // 璁剧疆缂撳啿绾歌垂鐢紙鍖呰绫� * 缂撳啿绾稿崟浠凤級
         cell.BufferPaperCost( packageQuantity * guard( lcm.BufferPaperPrice(), 1 ) );
-          
+
           // 璁剧疆鏈ㄧ鍗曚环
         cell.WoodenCratePriceReal( guard( lcm.WoodenCratePrice(), 1 ) );
-          
+
         // 璁剧疆璋冩嫧璐圭敤锛堣皟鎷ㄦ暟閲� / 鍖呰瀹归噺 / 瑁呰浇瀹归噺 * 杩愯緭鍗曚环锛�
         transferQuantity := sum( macroPlan, TransferPlanRow.TransferPlanCell, tempTPC,
                                  tempTPC.TransferPlanRow().Category()                      = mlcrr.Category()                                               and
@@ -80,25 +76,35 @@
                                  guard( tempTPC.TransferPlanColumn().ColumnDate().Year()   = mlcrc.StartDate().Year(), false )                              and
                                  guard(  tempTPC.TransferPlanColumn().ColumnDate().Month() = mlcrc.StartDate().Month(), false ),
                                  [Number]tempTPC.Value() );
-        cell.TransferCost( transferQuantity / guard( lcm.PackagingCapacity(), 1 ) / guard( lct.LoadingCapacity(), 1 ) * guard( lct.TransportPrice(), 1 ) );
-          
+        cell.TransferCost( [Number] ( [Number] ( transferQuantity / guard( lcm.PackagingCapacity(), 1 ) ) / guard( lct.LoadingCapacity(), 1 ) ) * guard( lct.TransportPrice(), 1 ) );
+
         // 澶栫搴撳叆搴撹垂鐢紙鍏ュ簱閲廩鍖呰閲廬 / 鍖呰瀹归噺 * 鍏ュ簱鍗曚环锛�
         cell.StorageFeesForRentedWarehouses( packageQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.WarehousingPrice(), 1 ) );
-          
+
         // 澶栫搴撳嚭搴撹垂鐢紙鍑哄簱閲廩鎷嗗寘閲廬 / 鍖呰瀹归噺 * 鍑哄簱鍗曚环锛�
         cell.OutboundExpensesForRentedWarehouses( unpackingQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.OutboundPrice(), 1 ) );
-          
+
         // 澶栫搴撹繍杈撹垂鐢紙杩愯緭鏁伴噺 / 鍖呰瀹归噺 / 瑁呰浇瀹归噺 * 杩愯緭鍗曚环锛�
-        transportationQuantity := sum( macroPlan, Unit.Lane.LaneLeg.Trip.ProductInTrip, tempPIT, 
-                                       tempPIT.Product_MP().ParentID()                                                  =  mlcrr.Category()   and
-                                       tempPIT.Trip().Departure().Date()                                                >= mlcrc.StartDate()  and
-                                       tempPIT.Trip().Arrival().Date()                                                  <= lastDayOfThisMonth and
-                                       tempPIT.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID()      = "CC 鍘傚唴搴�"         and
-                                       tempPIT.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID() = "闀挎槬澶栫搴�",
+        transportationQuantity := sum( macroPlan, Unit.Lane.LaneLeg.Trip.ProductInTrip, tempPIT,
+                                       tempPIT.Product_MP().ParentID()                                                  =  mlcrr.Category()                                                                       and
+                                       tempPIT.Trip().Departure().Date()                                                >= mlcrc.StartDate()                                                                      and
+                                       tempPIT.Trip().Arrival().Date()                                                  <= lastDayOfThisMonth                                                                     and
+                                       tempPIT.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID()      =  ifexpr( mlcrr.Factory() = "澶ц繛宸ュ巶", "DL", "CC" ) + " " + mlcrr.Category() + "绾胯竟搴�" and
+                                       tempPIT.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID() =  ifexpr( mlcrr.Factory() = "澶ц繛宸ュ巶", "DL", "CC" ) + " " + mlcrr.Category() + "澶栫搴�",
                                        tempPIT.Quantity()
                                       );
-        cell.ExternalRentalWarehouseTransportationCosts( transportationQuantity / guard( lcm.PackagingCapacity(), 1 ) / guard( lct1.LoadingCapacity(), 1 ) * guard( lct1.TransportPrice(), 1 ) );
-        
+        transportationQuantity := transportationQuantity +
+                                  sum( macroPlan, Unit.Lane.LaneLeg.Trip.ProductInTrip, tempPIT,
+                                       tempPIT.Product_MP().ParentID()                                                  =  mlcrr.Category()                                                                       and
+                                       tempPIT.Trip().Departure().Date()                                                >= mlcrc.StartDate()                                                                      and
+                                       tempPIT.Trip().Arrival().Date()                                                  <= lastDayOfThisMonth                                                                     and
+                                       tempPIT.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID()      =  ifexpr( mlcrr.Factory() = "澶ц繛宸ュ巶", "DL", "CC" ) + " " + mlcrr.Category() + "澶栫搴�" and
+                                       tempPIT.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID() =  ifexpr( mlcrr.Factory() = "澶ц繛宸ュ巶", "DL", "CC" ) + " " + mlcrr.Category() + "绾胯竟搴�",
+                                       tempPIT.Quantity()
+                                      );
+
+        cell.ExternalRentalWarehouseTransportationCosts( transportationQuantity / guard( lcm.PackagingCapacity(), 1 ) / guard( lct.LoadingCapacity(), 1 ) * guard( lct.TransportPrice(), 1 ) );
+
         // 澶栫搴撲粨鍌ㄨ垂鐢細浠撳偍鏁伴噺/鍖呰瀹归噺*浠撳偍鍗曚环
         plannedInventory := sum( macroPlan, Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod, tempPISPIP,
                                  tempPISPIP.ProductInStockingPoint_MP().Product_MP().IsLeaf()                                                                 and
@@ -106,9 +112,20 @@
                                  tempPISPIP.ProductInStockingPoint_MP().Product_MP().ParentID()                                         =  mlcrr.Category()   and
                                  tempPISPIP.Start().Date()                                                                              >= mlcrc.StartDate()  and
                                  tempPISPIP.End().Date()                                                                                <= lastDayOfThisMonth and
-                                 tempPISPIP.ProductInStockingPoint_MP().StockingPointID()                                               =  ifexpr( mlcrr.Factory() = "澶ц繛宸ュ巶", "澶ц繛澶栫搴�", "闀挎槬澶栫搴�" ),
+                                 tempPISPIP.ProductInStockingPoint_MP().StockingPointID()                                               =  ifexpr( mlcrr.Factory() = "澶ц繛宸ュ巶", "DL", "CC" ) + " " + mlcrr.Category() + "澶栫搴�",
                                  tempPISPIP.PlannedInventoryLevelEnd() );
         cell.RentalWarehouseStorageFees( plannedInventory / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.StoragePrice(), 1 ) );
+
+        // 棰勮鎬昏垂鐢�
+        cell.EstimatedTotalCost( cell.PackingCharges() + cell.UnpackingCost() + cell.BufferPaperCost() + cell.WoodenCrateCost() + cell.TransferCost() +
+                                 cell.StorageFeesForRentedWarehouses() + cell.OutboundExpensesForRentedWarehouses() + cell.ExternalRentalWarehouseTransportationCosts() +
+                                 cell.RentalWarehouseStorageFees() );
+
+        // 绯绘暟
+        cell.Coefficient( 1.05 );
+
+        // 鎬昏垂鐢�
+        cell.TotalCost( cell.EstimatedTotalCost() * cell.Coefficient() );
         
         cell.MachineLogisticsCostReportColumn( relset, mlcrc );
       }

--
Gitblit v1.9.3