From 8870e507249378c76b63364603969ed6e706e1b6 Mon Sep 17 00:00:00 2001
From: admin <admin@admin.com>
Date: 星期四, 10 十月 2024 15:34:40 +0800
Subject: [PATCH] 包装计划优化

---
 _Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl      |   28 ++++++++++----
 _Main/BL/Type_PackagingPlanCell/Function_CalcPackagingInventory.qbl  |    8 ++-
 _Main/BL/Type_PackagingPlanCell/Attribute_CC_UnpackagedInventory.qbl |    8 ++++
 _Main/BL/Type_PackagingPlanCell/Attribute_CC_PackagingInventory.qbl  |    8 ++++
 _Main/BL/Type_TransferPlanCell/StaticMethod_GenerateReport.qbl       |    7 +++
 _Main/BL/Type_PackagingPlanCell/Function_CalcUnpackagedInventory.qbl |    3 +
 6 files changed, 49 insertions(+), 13 deletions(-)

diff --git a/_Main/BL/Type_PackagingPlanCell/Attribute_CC_PackagingInventory.qbl b/_Main/BL/Type_PackagingPlanCell/Attribute_CC_PackagingInventory.qbl
new file mode 100644
index 0000000..0cd9269
--- /dev/null
+++ b/_Main/BL/Type_PackagingPlanCell/Attribute_CC_PackagingInventory.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute CC_PackagingInventory
+{
+  #keys: '3[415754.0.351286657][415754.0.351286656][415754.0.351286658]'
+  Description: '闀挎槬宸ュ巶鍖呰搴撳瓨'
+  ValueType: Real
+}
diff --git a/_Main/BL/Type_PackagingPlanCell/Attribute_CC_UnpackagedInventory.qbl b/_Main/BL/Type_PackagingPlanCell/Attribute_CC_UnpackagedInventory.qbl
new file mode 100644
index 0000000..99356b8
--- /dev/null
+++ b/_Main/BL/Type_PackagingPlanCell/Attribute_CC_UnpackagedInventory.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute CC_UnpackagedInventory
+{
+  #keys: '3[415754.0.351197962][415754.0.351197961][415754.0.351197963]'
+  Description: '闀挎槬宸ュ巶闈炲寘瑁呭簱瀛�'
+  ValueType: Real
+}
diff --git a/_Main/BL/Type_PackagingPlanCell/Function_CalcPackagingInventory.qbl b/_Main/BL/Type_PackagingPlanCell/Function_CalcPackagingInventory.qbl
index 37445f4..628ac49 100644
--- a/_Main/BL/Type_PackagingPlanCell/Function_CalcPackagingInventory.qbl
+++ b/_Main/BL/Type_PackagingPlanCell/Function_CalcPackagingInventory.qbl
@@ -6,11 +6,13 @@
   [*
     // lihongji Jul-26-2024 (created)
     
-    value := this.InitialPackagingInventory() + guard( this.Previous().PackagingInventory()                 + 
-                                                       guard( this.Previous().Package(), 0.0 )              -  
+    value := ifexpr( this.PackagingPlanRow().Factory() = "闀挎槬宸ュ巶", this.CC_PackagingInventory(),
+                     this.InitialPackagingInventory() + guard( this.Previous().PackagingInventory()                 + 
+                                                       guard( this.Package(), 0.0 )                         -  
                                                        ifexpr( this.TransferIn() > 0.0, 0, this.Unpacking() ), 
                                                        0.0 )
-                                              - this.Out();
+                                              - this.Out()
+                    );
     
     this.PackagingInventory( value );
   *]
diff --git a/_Main/BL/Type_PackagingPlanCell/Function_CalcUnpackagedInventory.qbl b/_Main/BL/Type_PackagingPlanCell/Function_CalcUnpackagedInventory.qbl
index f1ca4e3..58cc55e 100644
--- a/_Main/BL/Type_PackagingPlanCell/Function_CalcUnpackagedInventory.qbl
+++ b/_Main/BL/Type_PackagingPlanCell/Function_CalcUnpackagedInventory.qbl
@@ -6,7 +6,8 @@
   [*
     // lihongji Jul-24-2024 (created)
     
-    value := guard( this.EndingInventory() - this.PackagingInventory(), 0.0 );
+    value := ifexpr( this.PackagingPlanRow().Factory() = "闀挎槬宸ュ巶", this.UnpackagedInventory(),
+                     guard( this.EndingInventory() - this.PackagingInventory(), 0.0 ) );
     
     this.UnpackagedInventory( value );
   *]
diff --git a/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl b/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
index bfdadff..9eb8dff 100644
--- a/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
+++ b/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
@@ -16,7 +16,8 @@
     traverse ( macroPlan, Product_MP.ProductInStockingPoint_MP, pisp, pisp.IsLeaf() and not pisp.IsSystem() and 
                ( pisp.StockingPointID().Regex( "CC" ) or pisp.StockingPointID().Regex( "DL" ) or pisp.StockingPointID().Regex( "澶ц繛" ) or pisp.StockingPointID().Regex( "闀挎槬" ) ) ) {
       // 褰撳墠pisp鎵�澶勫湴鐐�
-      factory := ifexpr( pisp.StockingPointID().Regex( "CC" ) or pisp.StockingPointID().Regex( "闀挎槬" ), "闀挎槬宸ュ巶", "澶ц繛宸ュ巶" );
+      factory             := ifexpr( pisp.StockingPointID().Regex( "CC" ) or pisp.StockingPointID().Regex( "闀挎槬" ), "闀挎槬宸ュ巶", "澶ц繛宸ュ巶" );
+      factoryAbbreviation := ifexpr( pisp.StockingPointID().Regex( "CC" ) or pisp.StockingPointID().Regex( "闀挎槬" ), "CC", "DL" );
       
       // 鍒涘缓琛�
       ppr := select( macroPlan, PackagingPlanRow, tempPPR, tempPPR.ProductID() = pisp.ProductID() and tempPPR.Factory() = factory );
@@ -25,11 +26,13 @@
       }
       
       // 鍑哄彂鍦板簱瀛樼偣Trip
-      originTrips      := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID() = pisp.StockingPointID() );
+      originTrips      := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation )      and
+                                     TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() ) );
       // 鐩殑鍦板簱瀛樼偣Trip
-      destinationTrips := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID() = pisp.StockingPointID() );
+      destinationTrips := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation ) and
+                                     TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() ) );  
       
-      // 鍒涘缓鍗曞厓鏍�
+      // 寰幆pispippl
       traverse ( pisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispipl, not pispipl.IsPeriodFrozen() ) {
         // 鍒涘缓鍒�
         ppc := select( macroPlan, PackagingPlanColumn, tempPPC, tempPPC.StartDate() = pispipl.Start().Date() );
@@ -51,14 +54,23 @@
         
         // 璁剧疆璋冨嚭
         outs := selectset( originTrips, Elements, tempT, tempT.Departure().Date() = pispipl.Start().Date() );
-        traverse ( outs, Elements, out ) {
-          cell.Out( cell.Out() + out.Quantity() );
+        traverse ( outs, Elements.ProductInTrip, outPIT, outPIT.ProductID() = pisp.ProductID() ) {
+          cell.Out( cell.Out() + outPIT.Quantity() );
         }
         
         // 璁剧疆璋冭繘
         transferIns := selectset( destinationTrips, Elements, tempT, tempT.Arrival().Date() = pispipl.Start().Date() );
-        traverse ( transferIns, Elements, ti ) {
-          cell.TransferIn( cell.TransferIn() + ti.Quantity() );
+        traverse ( transferIns, Elements.ProductInTrip, tiPIT, tiPIT.ProductID() = pisp.ProductID() ) {
+          cell.TransferIn( cell.TransferIn() + tiPIT.Quantity() );
+        }
+        
+        // 闀挎槬宸ュ巶鐗规畩鎯呭喌璁剧疆鍖呰搴撳瓨鍜岄潪鍖呰搴撳瓨
+        if ( factory = "闀挎槬宸ュ巶" ) {
+          if ( pisp.StockingPointID().Regex( "澶栫搴�" ) ) {
+            cell.CC_PackagingInventory( pispipl.InventoryLevelEnd() );
+          } else if ( pisp.StockingPointID().Regex( "绾胯竟搴�" ) ) {
+            cell.CC_UnpackagedInventory( pispipl.InventoryLevelEnd() );
+          }
         }
         
         // 璁剧疆鍓嶄竴澶╁簱瀛�
diff --git a/_Main/BL/Type_TransferPlanCell/StaticMethod_GenerateReport.qbl b/_Main/BL/Type_TransferPlanCell/StaticMethod_GenerateReport.qbl
index 73cbf58..b00f219 100644
--- a/_Main/BL/Type_TransferPlanCell/StaticMethod_GenerateReport.qbl
+++ b/_Main/BL/Type_TransferPlanCell/StaticMethod_GenerateReport.qbl
@@ -14,7 +14,12 @@
     // 鐢熸垚璋冩嫧璁″垝
     traverse ( macroPlan, Unit, u, u.HasCapacityTypeTransportQuantity() ) {
       traverse ( u, Lane.LaneLeg.Trip, t ) {
-        traverse ( t, ProductInTrip, pit, pit.Quantity() > 0.0 and exists( pit.Product_MP(), AllParent.AsParent, tempP, tempP.ID() = "鏈哄姞浠�" ) ) {
+        originFactory      := TransferPlanRow::IdentifyTheFactory( t.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() );      // 璧峰宸ュ巶
+        destinationFactory := TransferPlanRow::IdentifyTheFactory( t.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() ); // 鐩爣宸ュ巶
+        traverse ( t, ProductInTrip, pit, pit.Quantity() > 0.0                                           and // 鏁伴噺澶т簬0
+                   exists( pit.Product_MP(), AllParent.AsParent, tempP, tempP.ID() = "鏈哄姞浠�" )          and // 鍙彇鏈哄姞浠�
+                   originFactory                                                   <> destinationFactory     // 璧峰宸ュ巶涓嶈兘鍜岀洰鏍囧伐鍘備竴鑷�
+                  ) {
           // 鎵捐
           tpr := TransferPlanRow::FindTransferPlanRowTypeIndex( TransferPlanRow::IdentifyTheFactory( t.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ),
                                                                 TransferPlanRow::IdentifyTheFactory( t.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() ),

--
Gitblit v1.9.3