From 417f02834f331ea468d87add2a6143597c83648b Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期三, 18 九月 2024 16:18:46 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/VWED into dev-zlg

---
 _Main/BL/Type_OfflinePlanRow/Method_Filter.qbl                                                                 |   17 ++++++++
 _Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Response_pHeader_bDeductionOfReplacementLoss_OnClick.def |   13 ++++++
 _Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Component_MatrixEditor951.def                            |    2 +
 _Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Component_pHeader.def                                    |    2 
 _Main/BL/Type_OfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl                                              |    4 +
 _Main/BL/Type_OfflinePlanCell/StaticMethod_DeductionOfReplacementLoss.qbl                                      |   54 +++++++++++++++++++++++++++
 6 files changed, 90 insertions(+), 2 deletions(-)

diff --git a/_Main/BL/Type_OfflinePlanCell/StaticMethod_DeductionOfReplacementLoss.qbl b/_Main/BL/Type_OfflinePlanCell/StaticMethod_DeductionOfReplacementLoss.qbl
new file mode 100644
index 0000000..b1ee27d
--- /dev/null
+++ b/_Main/BL/Type_OfflinePlanCell/StaticMethod_DeductionOfReplacementLoss.qbl
@@ -0,0 +1,54 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod DeductionOfReplacementLoss (
+  MacroPlan macroPlan,
+  OfflinePlanTable opt
+)
+{
+  TextBody:
+  [*
+    // 淇濆瓨涓婁竴浠藉瓨妗�
+    newOPT := OfflinePlanCell::SaveAsDraft( macroPlan, opt );
+    
+    // 鎵ц鎹㈠瀷鎹熷け
+    allProductionLines := selectuniquevalues( newOPT, OfflinePlanRow, tempORR, true, tempORR.ProductionLine() );
+    
+    traverse ( allProductionLines, Elements, pl ) {
+      oprs := selectset( newOPT, OfflinePlanRow, tempORT, tempORT.ProductionLine() = pl and ( tempORT.Type() = "1" or tempORT.Type() = "2" ) );
+      
+      traverse ( newOPT, OfflinePlanColumn, opc, opc.ColumnDate() = macroPlan.StartOfPlanning().Date() ) {
+        for ( i := 1; i < 10; i++ ) {
+          firstOrderCell  := select( oprs, Elements.OfflinePlanCell, tempOPC, tempOPC.OfflinePlanColumn() = opc and tempOPC.Value() = ( "#" + i.Format( "N(LPad0(2))" ) ) );
+          secondOrderCell := select( oprs, Elements.OfflinePlanCell, tempOPC, tempOPC.OfflinePlanColumn() = opc and tempOPC.Value() = ( "#" + ( i + 1 ).Format( "N(LPad0(2))" ) ) );
+          // 鎹㈠瀷鎹熷け鍙傛暟
+          cls        := select( macroPlan, ChangeLossSetting, tempCLS, 
+                                guard( tempCLS.ProductFirst().ID()  = firstOrderCell.OfflinePlanRow().ProductID() , false ) and
+                                guard( tempCLS.ProductSecond().ID() = secondOrderCell.OfflinePlanRow().ProductID(), false ) and
+                                guard( tempCLS.StartDate()          <= opc.ColumnDate()                           , false ) and
+                                guard( tempCLS.EndDate()            >= opc.ColumnDate()                           , false )
+                               );
+          if ( not isnull( firstOrderCell ) and not isnull( secondOrderCell ) and not isnull( cls ) ) {
+            firstQuantityCell := select( oprs, Elements.OfflinePlanCell, tempOPC, 
+                                         tempOPC.OfflinePlanColumn() = opc     and 
+                                         tempOPC.OfflinePlanRow().Type() = "1" and 
+                                         tempOPC.OfflinePlanRow().ProductID() = firstOrderCell.OfflinePlanRow().ProductID()
+                                        );
+            firstQuantityCell.Value( [String] ( [Number]firstQuantityCell.Value() - cls.ChangeLossNr() ) );                 
+    //        info( "褰撳墠搴忓彿锛�", i, "    鍗曞厓鏍肩殑鍊硷細", firstCell.Value(), "    浜у搧鍚嶏細", firstCell.OfflinePlanRow().ProductID(),
+    //              "涓嬩竴涓簭鍙凤細", i + 1, "    鍗曞厓鏍肩殑鍊硷細", secondCell.Value(), "    浜у搧鍚嶏細", secondCell.OfflinePlanRow().ProductID() );
+          }
+        }
+      }
+    }
+    
+    // 閲嶇疆鎬昏琛�
+    totalOPRs := selectset( newOPT, OfflinePlanRow, tempOPR, tempOPR.Type() = "3" );
+    traverse ( newOPT, OfflinePlanColumn, opc, opc.OfflinePlanCell( relsize ) > 0 and opc.ColumnDate() >= macroPlan.StartOfPlanning().Date() ) {
+      traverse ( totalOPRs, Elements, totalOPR ) {
+        total     := sum( opc, OfflinePlanCell, tempOPC, tempOPC.OfflinePlanRow().ProductionLine() = totalOPR.ProductionLine() and tempOPC.OfflinePlanRow().Type() = "1", [Real]tempOPC.Value() );
+        totalCell := select( totalOPR, OfflinePlanCell, tempOPC, tempOPC.OfflinePlanColumn() = opc );
+        totalCell.Value( [String]total );
+      }
+    }
+  *]
+}
diff --git a/_Main/BL/Type_OfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl b/_Main/BL/Type_OfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl
index 0e5721d..41f3317 100644
--- a/_Main/BL/Type_OfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl
+++ b/_Main/BL/Type_OfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl
@@ -11,7 +11,9 @@
     opt := macroPlan.OfflinePlanTable( relnew, SaveDateTime := DateTime::ActualTime() );
     
     // 鐢熸垚涓嬬嚎璁″垝琛�
-    traverse ( macroPlan, Unit, u, u.HasCapacityTypeTime() /*and u.Name() = "Body in White Line 1"*/ ) {
+    traverse ( macroPlan, Unit, u, u.HasCapacityTypeTime() 
+               and u.Name() = "eMotor Assy (France)" // 娴嬭瘯鏃跺彲浠ヨ繃婊�
+              ) {
       // 鍒涘缓浜х嚎琛�
       opt.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "", Type := "0" );
       
diff --git a/_Main/BL/Type_OfflinePlanRow/Method_Filter.qbl b/_Main/BL/Type_OfflinePlanRow/Method_Filter.qbl
new file mode 100644
index 0000000..d5e399d
--- /dev/null
+++ b/_Main/BL/Type_OfflinePlanRow/Method_Filter.qbl
@@ -0,0 +1,17 @@
+Quintiq file version 2.0
+#parent: #root
+Method Filter (
+  Entitys entitys
+) declarative remote as Boolean
+{
+  TextBody:
+  [*
+    flag := false;
+    
+    traverse ( entitys, Elements.astype( Unit ), u, not flag ) {
+      flag := u.Name() = this.ProductionLine();
+    }
+    
+    return flag;
+  *]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Component_MatrixEditor951.def b/_Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Component_MatrixEditor951.def
index c0791c3..463493b 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Component_MatrixEditor951.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Component_MatrixEditor951.def
@@ -45,6 +45,8 @@
           Properties:
           [
             DataType: 'OfflinePlanTable'
+            FilterArguments: 'entities:QLibMacroPlannerWebUI::ApplicationMacroPlanner.DataHolderCheckedEntities'
+            FixedFilter: 'object.Filter( entities )'
             Source: 'dhOfflinePlanTable'
             Taborder: 0
             Transformation: 'OfflinePlanRow'
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Component_pHeader.def b/_Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Component_pHeader.def
index a1900d3..a935cd4 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Component_pHeader.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Component_pHeader.def
@@ -11,7 +11,7 @@
       BaseType: 'WebButton'
       Properties:
       [
-        Label: 'Refresh'
+        Image: 'REFRESH'
         Taborder: 0
       ]
     }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Response_pHeader_bDeductionOfReplacementLoss_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Response_pHeader_bDeductionOfReplacementLoss_OnClick.def
index b426c30..16a2713 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Response_pHeader_bDeductionOfReplacementLoss_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormOfflinePlan/Response_pHeader_bDeductionOfReplacementLoss_OnClick.def
@@ -5,8 +5,21 @@
   #keys: '[413988.0.1297973984]'
   CanBindMultiple: false
   DefinitionID: 'Responsedef_WebButton_OnClick'
+  Precondition:
+  [*
+    return not isnull( MacroPlan );
+  *]
   QuillAction
   {
+    Body:
+    [*
+      OfflinePlanCell::DeductionOfReplacementLoss( MacroPlan, dhOfflinePlanTable.Data() );
+      
+      opt := maxselect( MacroPlan, OfflinePlanTable, tempOPT, true, tempOPT.SaveDateTime() );
+      dhOfflinePlanTable.Data( opt );
+      
+      WebMessageBox::Success( Translations::A_VWED_Success() );
+    *]
     GroupServerCalls: false
   }
 }

--
Gitblit v1.9.3