From c34ffd86b7001f7ea39aa33f8c938a2c1b5a22ac Mon Sep 17 00:00:00 2001
From: admin <admin@admin.com>
Date: 星期四, 17 十月 2024 17:00:02 +0800
Subject: [PATCH] 机加物流成本优化

---
 _Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl |   77 ++++++++++++++++++++------------------
 1 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl b/_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl
index 038ccac..11848c7 100644
--- a/_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl
+++ b/_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl
@@ -10,72 +10,77 @@
     macroPlan.MachineLogisticsCostReportRow( relflush );
     macroPlan.MachineLogisticsCostReportColumn( relflush );
     
-    // 鍒濆鍖栦竴骞存暟鎹垪
+    // 鍒涘缓琛�
+    categories := selectuniquevalues( macroPlan, Product_MP, tempPMP, tempPMP.IsLeaf()                           and
+                                      exists( tempPMP, AllParent.AsParent, tempPMP1, tempPMP1.ID() = "鏈哄姞浠�" ),  
+                                      tempPMP.ParentID() );
+    traverse ( categories, Elements, c ) {
+      macroPlan.MachineLogisticsCostReportRow( relnew, Factory := "澶ц繛宸ュ巶", Category := c  );
+      macroPlan.MachineLogisticsCostReportRow( relnew, Factory := "闀挎槬宸ュ巶", Category := c );
+    }
+    
+    // 鍒涘缓鍒�
     indexDate := macroPlan.StartOfPlanning().Date().StartOfMonth();
     for ( i := 0; i < 12; i++ ) {
       macroPlan.MachineLogisticsCostReportColumn( relnew, StartDate := indexDate );
       indexDate := indexDate.StartOfNextMonth();
     }
     
-    // 鎵惧嚭鎵�鏈夊ぇ绫伙紝鍒涘缓鏁版嵁
-    categories := selectuniquevalues( macroPlan, PackagingPlanRow, tempPPR, true, tempPPR.Category() );
-    
-    traverse ( categories, Elements, c ) {
+    // 鍒涘缓鍗曞厓鏍�
+    traverse ( macroPlan, MachineLogisticsCostReportRow, mlcrr ) { // 寰幆琛�
+      info( "褰撳墠閬嶅巻鐨勮锛�", mlcrr.Factory(), " ", mlcrr.Category() );
+      traverse ( macroPlan, MachineLogisticsCostReportColumn, mlcrc ) { // 寰幆鍒�
       
-      // 鏈哄姞鎴愭湰鍙傛暟
-      lcm := select( macroPlan, LogisticsCostMachining, tempLCM, tempLCM.Factory() = factory and tempLCM.Product() = c );
-      
-      // 杩愯緭鎴愭湰鍙傛暟
-      lct := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Origin()      = ifexpr( factory = "澶ц繛宸ュ巶", "CC", "DL" ) and
-                                                                 tempLCT.Destination() = ifexpr( factory = "澶ц繛宸ュ巶", "DL", "CC" ) and
-                                                                 tempLCT.Product()     = c );
-       
-      // 鍒濆鍖栨満鍔犳垚鏈弬鏁版姤琛ㄨ
-      mlcrr := macroPlan.MachineLogisticsCostReportRow( relnew, Category := c, Factory := factory );
-      
-      // 寰幆鎵�鏈夋椂闂村垪鍒涘缓鏁版嵁                                         
-      traverse ( macroPlan, MachineLogisticsCostReportColumn, mlcrc ) {
-        cell := mlcrr.MachineLogisticsCostReportCell( relnew );
+        // 鏈哄姞鎴愭湰鍙傛暟
+        lcm  := select( macroPlan, LogisticsCostMachining, tempLCM, tempLCM.Factory() = mlcrr.Factory() and tempLCM.Product() = mlcrr.Category()
+                        and tempLCM.StartDate() <= mlcrc.StartDate() and tempLCM.EndDate() >= mlcrc.StartDate().StartOfNextMonth() );
         
+        // 杩愯緭鎴愭湰鍙傛暟
+         
+        // 褰撳墠鏈堟湯鏈�鍚庝竴澶╂棩鏈�                
+        lastDayOfThisMonth := mlcrc.StartDate().StartOfNextMonth() - 1; 
+        
+        cell := mlcrr.MachineLogisticsCostReportCell( relnew );
+          
         // 璁剧疆鍖呰璐圭敤锛堝寘瑁呴噺 * 鍖呰鍗曚环锛�
         packageQuantity := sum( macroPlan, PackagingPlanRow.PackagingPlanCell, tempPPC, 
-                                tempPPC.PackagingPlanRow().Category()             = c                         and
+                                tempPPC.PackagingPlanRow().Category()             = mlcrr.Category()          and
                                 tempPPC.PackagingPlanRow().Factory()              = 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 ) );
-        
+        cell.PackingCharges( packageQuantity * guard( lcm.PackagePrice(), 1 ) );
+          
         // 璁剧疆鎷嗗寘璐圭敤锛堟媶鍖呴噺 * 鎷嗗寘鍗曚环锛�
         unpackingQuantity := sum( macroPlan, PackagingPlanRow.PackagingPlanCell, tempPPC, 
-                                  tempPPC.PackagingPlanRow().Category()             = c                         and
+                                  tempPPC.PackagingPlanRow().Category()             = mlcrr.Category()          and
                                   tempPPC.PackagingPlanRow().Factory()              = 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.UnpackingCost( unpackingQuantity * guard( lcm.UnpackingPrice(), 1 ) );
+          
         // 璁剧疆缂撳啿绾歌垂鐢紙鍖呰绫� * 缂撳啿绾稿崟浠凤級
-    //    cell.BufferPaperCost( packageQuantity * guard( lcm.BufferPaperPrice(), 1 ) );
-        
-        // 璁剧疆鏈ㄧ鍗曚环
-    //    cell.UnitPriceOfWoodenCrate( guard( lcm.WoodenCratePrice(), 1 ) );
-        
+        cell.BufferPaperCost( packageQuantity * guard( lcm.BufferPaperPrice(), 1 ) );
+          
+          // 璁剧疆鏈ㄧ鍗曚环
+        cell.WoodenCratePriceReal( guard( lcm.WoodenCratePrice(), 1 ) );
+          
         // 璁剧疆璋冩嫧璐圭敤锛堣皟鎷ㄦ暟閲� / 鍖呰瀹归噺 / 瑁呰浇瀹归噺 * 杩愯緭鍗曚环锛�
         transferQuantity := sum( macroPlan, TransferPlanRow.TransferPlanCell, tempTPC,
-                                 tempTPC.TransferPlanRow().Category()              = c                                                      and
+                                 tempTPC.TransferPlanRow().Category()              = mlcrr.Category()                                       and
                                  tempTPC.TransferPlanRow().Name()                  = ifexpr( factory = "澶ц繛宸ュ巶", "CC to DL", "DL to CC" ) and
                                  tempTPC.TransferPlanColumn().ColumnDate().Year()  = mlcrc.StartDate().Year()                               and
                                  tempTPC.TransferPlanColumn().ColumnDate().Month() = mlcrc.StartDate().Month(),
                                  [Number]tempTPC.Value() );
     //    cell.TransferCost( 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.StorageFeesForRentedWarehouses( packageQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.WarehousingPrice(), 1 ) );
+          
         // 澶栫搴撳嚭搴撹垂鐢紙鍑哄簱閲廩鎷嗗寘閲廬 / 鍖呰瀹归噺 * 鍑哄簱鍗曚环锛�
-    //    cell.OutboundExpensesForRentedWarehouses( unpackingQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.OutboundPrice(), 1 ) );
-        
+      //  cell.OutboundExpensesForRentedWarehouses( unpackingQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.OutboundPrice(), 1 ) );
+          
         // 澶栫搴撹繍杈撹垂鐢紙杩愯緭鏁伴噺 / 鍖呰瀹归噺 / 瑁呰浇瀹归噺 * 杩愯緭鍗曚环锛�
         
         cell.MachineLogisticsCostReportColumn( relset, mlcrc );

--
Gitblit v1.9.3