From f6aa411801444444fd0216322d96c2e2f3bed9c7 Mon Sep 17 00:00:00 2001
From: admin <admin@admin.com>
Date: 星期二, 22 十月 2024 17:28:11 +0800
Subject: [PATCH] 连续排产优化

---
 _Main/BL/Type_WholeShift/Method_ContinuousProductionScheduling.qbl |   12 ++++++++----
 _Main/BL/Type_WholeShift/Method_MobileCycleTask.qbl                |   13 ++++++++++++-
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/_Main/BL/Type_WholeShift/Method_ContinuousProductionScheduling.qbl b/_Main/BL/Type_WholeShift/Method_ContinuousProductionScheduling.qbl
index b00d481..a430caf 100644
--- a/_Main/BL/Type_WholeShift/Method_ContinuousProductionScheduling.qbl
+++ b/_Main/BL/Type_WholeShift/Method_ContinuousProductionScheduling.qbl
@@ -17,7 +17,8 @@
     
     
     while ( needHandleUPTBs.Size() > 0 ) {
-      debuginfo( "-------------------------------------------", "姝e湪澶勭悊鐨勫懆寮�濮嬫椂闂达細", indexStartDate.Format( "Y-M2-D2" ), "    澶勭悊鐨勪釜鏁帮細", needHandleUPTBs.Size() );
+      debuginfo( "-------------------------------------------", "姝e湪澶勭悊鐨勫懆寮�濮嬫椂闂达細", indexStartDate.Format( "Y-M2-D2" ), 
+                 "    姝e湪澶勭悊鐨勫懆缁撴潫鏃堕棿锛�", ( indexStartDate.StartOfNextWeek() - 1 ).Format( "Y-M2-D2" ), "    澶勭悊鐨勪釜鏁帮細", needHandleUPTBs.Size() );
       
       // 闇�瑕佸鐞嗘爣蹇�
       needHandleFlag := false;
@@ -51,14 +52,17 @@
         // 闇�瑕佸鐞嗙殑UPTB鐨勬渶澶ф椂闂�
         handleIndexEndDate   := maxobject( needHandleUPTBs, Elements, tempUPTB, true, tempUPTB.StartDate() ).StartDate();
         
-        debuginfo( "闇�瑕佸鐞嗙殑鍛ㄥ紑濮嬫椂闂达細", indexStartDate.Format( "Y-M2-D2" ), "    闇�瑕佸鐞嗙殑鍛ㄧ粨鏉熸椂闂达細", handleIndexEndDate.Format( "Y-M2-D2" ), 
-                   "    绗竴娆″嚭鐜颁骇鑳界殑鏃ユ湡锛�", firstAppearCapacityDate1.Format( "Y-M2-D2" ) );
+    //    debuginfo( "闇�瑕佸鐞嗙殑鍛ㄥ紑濮嬫椂闂达細", indexStartDate.Format( "Y-M2-D2" ), "    闇�瑕佸鐞嗙殑鍛ㄧ粨鏉熸椂闂达細", handleIndexEndDate.Format( "Y-M2-D2" ), 
+    //               "    绗竴娆″嚭鐜颁骇鑳界殑鏃ユ湡锛�", firstAppearCapacityDate1.Format( "Y-M2-D2" ) );
         needFillUPTB := select( needHandleUPTBs, Elements, tempUPTB, tempUPTB.StartDate() = handleIndexStartDate );
         
-        while ( needFillUPTB.UsedCapacity().HoursAsReal() <= 0.0 and handleIndexStartDate <= handleIndexEndDate ) {
+        while ( guard( needFillUPTB.UsedCapacity().HoursAsReal(), -1 ) <= 0.0 and handleIndexStartDate <= handleIndexEndDate ) {
           targetUPTB := minselect( needHandleUPTBs, Elements, tempUPTB, tempUPTB.StartDate() > handleIndexStartDate and tempUPTB.UsedCapacity().HoursAsReal() > 0.0, tempUPTB.StartDate() );
           
           // 绉诲姩鍛ㄦ湡浠诲姟
+          if ( not isnull( needFillUPTB ) and not isnull( targetUPTB ) ) {
+            this.MobileCycleTask( needFillUPTB, targetUPTB );
+          }
           
           handleIndexStartDate := handleIndexStartDate + 1;
           needFillUPTB         := select( needHandleUPTBs, Elements, tempUPTB, tempUPTB.StartDate() = handleIndexStartDate );
diff --git a/_Main/BL/Type_WholeShift/Method_MobileCycleTask.qbl b/_Main/BL/Type_WholeShift/Method_MobileCycleTask.qbl
index 9e4fe66..e561a1a 100644
--- a/_Main/BL/Type_WholeShift/Method_MobileCycleTask.qbl
+++ b/_Main/BL/Type_WholeShift/Method_MobileCycleTask.qbl
@@ -8,6 +8,17 @@
   Description: '杩炵画鐢熶骇锛岀Щ鍔ㄤ袱涓懆鏈熶换鍔�'
   TextBody:
   [*
-    // vwedadmin Oct-22-2024 (created)
+    debuginfo( "闇�瑕佸~鍏呯殑鏃ユ湡锛�", fillUPTB.StartDate().Format( "Y-M2-D2" ), "    鐩爣琚彇鏁版棩鏈燂細", targetUPTB.StartDate().Format( "Y-M2-D2" ) );
+    
+    // 鍒ゆ柇鍙敤浜ц兘鏄惁涓�鑷�
+    if ( fillUPTB.BaseAvailableCapacity().HoursAsReal() = targetUPTB.BaseAvailableCapacity().HoursAsReal() ) {
+      traverse ( targetUPTB, PeriodTaskOperation, pto ) {
+        PeriodTaskOperation::Create( pto.Operation(), fillUPTB, pto.Quantity(), false );
+      }
+      
+      PeriodTaskOperation::Delete( selectset( targetUPTB, PeriodTaskOperation, tempPTO, true ) );
+    }
+    
+    Transaction::Transaction().Propagate();
   *]
 }

--
Gitblit v1.9.3