From 60e4bc4033a047e614a1f98d8b289bf9fcd2e8d4 Mon Sep 17 00:00:00 2001
From: lihongji <3117313295@qq.com>
Date: 星期一, 14 十月 2024 18:28:11 +0800
Subject: [PATCH] 下线计划优化

---
 _Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Component_MatrixEditor515.def                                                     |   11 ++
 _Main/UI/MacroPlannerWebApp/Component_FormProductionPlan/Component_MatrixEditorPISPIP.def                                                  |   10 ++
 _Main/BL/Type_NewOfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl                                                                       |    2 
 _Main/UI/MacroPlannerWebApp/Component_FormProductionPlan/_ROOT_Component_FormProductionPlan.def                                            |   10 ++
 _Main/BL/Type_NewOfflinePlanCell/StaticMethod_SynchronizeToNewSupply.qbl                                                                   |   36 +++++++
 _Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Component_abgSecondDevelopmentPlan.def                                       |    1 
 _Main/UI/MacroPlannerWebApp/Component_FormProductionPlan/Component_PanelMatrix.def                                                         |    8 +
 _Main/BL/Type_NewOfflinePlanCell/Method_GetNewOfflinePlanMatrixTooltip.qbl                                                                 |   19 +++
 _Main/BL/Type_NewOfflinePlanRow/Attribute_OperationID.qbl                                                                                  |    7 +
 _Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Response_pHeader_bConfirm_OnClick.def                                             |    4 
 _Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Response_pHeader_bDeductChangeoverLoss_OnClick.def                                |    5 +
 _Main/BL/Type_NewOfflinePlanCell/StaticMethod_DeductionOfReplacementLoss.qbl                                                               |   56 +++++++++++
 _Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_mOfflinePlanInterface_OnClick.def |   23 ++++
 _Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Component_ContextMenuInterface.def                                           |   11 ++
 _Main/UI/MacroPlannerWebApp/Views/NewOfflinePlan.vw                                                                                        |   50 ---------
 15 files changed, 204 insertions(+), 49 deletions(-)

diff --git a/_Main/BL/Type_NewOfflinePlanCell/Method_GetNewOfflinePlanMatrixTooltip.qbl b/_Main/BL/Type_NewOfflinePlanCell/Method_GetNewOfflinePlanMatrixTooltip.qbl
new file mode 100644
index 0000000..593455b
--- /dev/null
+++ b/_Main/BL/Type_NewOfflinePlanCell/Method_GetNewOfflinePlanMatrixTooltip.qbl
@@ -0,0 +1,19 @@
+Quintiq file version 2.0
+#parent: #root
+Method GetNewOfflinePlanMatrixTooltip () declarative remote as String
+{
+  TextBody:
+  [*
+    tooltip := '<table>';
+    
+    tooltip := tooltip 
+                 + '<tr><td><b>鎬婚噺锛�</b></td><td>'         + [String]this.Total().TotalQuantity() + '</td></tr>'
+                 + '<tr><td><b>鐝鍚嶏細</b></td><td>'       + this.Total().ShiftPatternName()      + '</td></tr>'
+                 + '<tr><td><b>鐝寮�濮嬫椂闂达細</b></td><td>' + this.Total().ShiftPatternStart()     + '</td></tr>'
+                 + '<tr><td><b>鐝缁撴潫鏃堕棿锛�</b></td><td>' + this.Total().ShiftPatternEnd()       + '</td></tr>';
+    
+    tooltip := tooltip + '</table>'; 
+    
+    return tooltip;
+  *]
+}
diff --git a/_Main/BL/Type_NewOfflinePlanCell/StaticMethod_DeductionOfReplacementLoss.qbl b/_Main/BL/Type_NewOfflinePlanCell/StaticMethod_DeductionOfReplacementLoss.qbl
new file mode 100644
index 0000000..6b23ce9
--- /dev/null
+++ b/_Main/BL/Type_NewOfflinePlanCell/StaticMethod_DeductionOfReplacementLoss.qbl
@@ -0,0 +1,56 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod DeductionOfReplacementLoss (
+  MacroPlan macroPlan,
+  NewOfflinePlanTable nopt
+)
+{
+  TextBody:
+  [*
+    // 淇濆瓨涓婁竴浠藉瓨妗�
+    newNOPT := NewOfflinePlanCell::SaveAsDraft( macroPlan, nopt );
+    
+    // 鎵ц鎹㈠瀷鎹熷け
+    allProductionLines := selectuniquevalues( newNOPT, NewOfflinePlanRow, tempNOPR, true, tempNOPR.ProductionLine() );
+    
+    traverse ( allProductionLines, Elements, pl
+    //           , pl = "eMotor Assy (France)" 
+             ) 
+    {
+      // 涓嬬嚎璁″垝褰撳墠浜х嚎涓嬬殑琛�
+      noprs      := selectset( newNOPT, NewOfflinePlanRow, tempNOPR, tempNOPR.ProductionLine() = pl and tempNOPR.Type() = "1" );
+      
+      // 涓婁竴涓敓浜х殑浜у搧Cell
+      preNOPCell := null( NewOfflinePlanCell );
+      
+      traverse ( newNOPT, NewOfflinePlanColumn, nopc
+    //             , nopc.StartDate() >= macroPlan.StartOfPlanning().Date() and nopc.StartDate() <= Date::Construct( 2024, 4, 17 ) // 娴嬭瘯鏃跺彲浠ヨ繃婊ゆ椂闂�
+               ) 
+      {         
+        for ( i := 1; i < 10; i++ ) {
+          nopcell := select( noprs, Elements.NewOfflinePlanCell, tempNOPC, tempNOPC.NewOfflinePlanColumn() = nopc and tempNOPC.OrderNr() = i );
+          // 鎹㈠瀷鎹熷け鍙傛暟
+          cls     := select( macroPlan, ChangeLossSetting, tempCLS, 
+                             tempCLS.ProductFirst().ID()  = guard( preNOPCell.NewOfflinePlanRow().ProductID(), "" ) and
+                             tempCLS.ProductSecond().ID() = guard( nopcell.NewOfflinePlanRow().ProductID(), "" )    and
+                             tempCLS.StartDate()          <= nopc.StartDate()                                       and
+                             tempCLS.EndDate()            >= nopc.StartDate()                       
+                            );
+    
+          // 鎵e噺鎹㈠瀷鎹熷け
+          if ( not isnull( preNOPCell ) and not isnull( nopcell ) and not isnull( cls ) ) {
+            preNOPCell.Quantity( preNOPCell.Quantity() - cls.ChangeLossNumber() );                 
+    //        info( "褰撳墠鍒楁椂闂达細", nopc.StartDate().Format( "Y-M2-D2" ), 
+    //              "    涓婁竴涓骇鍝佸綋鍓嶅簭鍙凤細", preNOPCell.Order(), "    涓婁竴涓骇鍝佹暟閲忥細", preNOPCell.Quantity(), "    涓婁竴涓骇鍝佸悕锛�", preNOPCell.NewOfflinePlanRow().ProductID(),
+    //              "    褰撳墠浜у搧搴忓彿锛�"      , nopcell.Order()   , "    褰撳墠浜у搧鏁伴噺锛�"     , nopcell.Quantity(), "    褰撳墠浜у搧鍚嶏細"  , nopcell.NewOfflinePlanRow().ProductID() );
+          }
+          
+          // 璁剧疆涓婁竴涓敓浜х殑浜у搧Cell
+          if ( not isnull( nopcell ) ) {
+            preNOPCell := nopcell;
+          }
+        }
+      }
+    }
+  *]
+}
diff --git a/_Main/BL/Type_NewOfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl b/_Main/BL/Type_NewOfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl
index a018b69..5718ef8 100644
--- a/_Main/BL/Type_NewOfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl
+++ b/_Main/BL/Type_NewOfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl
@@ -41,7 +41,7 @@
           // 鐢熸垚涓嬬嚎璁″垝銆愪骇绾挎槑缁嗐�戣
           detailedNOPR   := select( nopt, NewOfflinePlanRow, tempNOPR, tempNOPR.ProductionLine() = u.ID() and tempNOPR.ProductID() = pisp.ProductID() and tempNOPR.Type() = "1" );
           if ( isnull( detailedNOPR ) ) {
-            detailedNOPR := nopt.NewOfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := pisp.ProductID(), Type := "1" );
+            detailedNOPR := nopt.NewOfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := pisp.ProductID(), Type := "1", OperationID := o.ID() );
           }
           
           // 鐢熸垚涓嬬嚎璁″垝鍒�
diff --git a/_Main/BL/Type_NewOfflinePlanCell/StaticMethod_SynchronizeToNewSupply.qbl b/_Main/BL/Type_NewOfflinePlanCell/StaticMethod_SynchronizeToNewSupply.qbl
new file mode 100644
index 0000000..1ce7d37
--- /dev/null
+++ b/_Main/BL/Type_NewOfflinePlanCell/StaticMethod_SynchronizeToNewSupply.qbl
@@ -0,0 +1,36 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod SynchronizeToNewSupply (
+  MacroPlan macroPlan,
+  NewOfflinePlanTable nopt
+)
+{
+  TextBody:
+  [*
+    traverse ( nopt, NewOfflinePlanRow.NewOfflinePlanCell, cell, 
+               cell.NewOfflinePlanRow().Type() = "1" and cell.Quantity() > 0.0 
+    //           and cell.NewOfflinePlanRow().ProductionLine() = "eMotor Assy (France)" and cell.NewOfflinePlanColumn().StartDate() = Date::Construct( 2020, 4, 4 )
+             ) 
+    {
+     pto := select( macroPlan, Unit.Operation.PeriodTaskOperation, tempPTO,
+                    exists( tempPTO, NewSupply, tempNS, tempNS.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP().ProductID() = cell.NewOfflinePlanRow().ProductID() ) and
+                    tempPTO.Operation().UnitID() = cell.NewOfflinePlanRow().ProductionLine()                                                                                                 and
+                    tempPTO.Start().Date()       = cell.NewOfflinePlanColumn().StartDate() );
+      if ( isnull( pto ) ) {
+        o  := select( macroPlan, Unit.Operation, tempO, tempO.ID() = cell.NewOfflinePlanRow().OperationID() );
+        up := select( macroPlan, Unit.UnitPeriod, tempUP, tempUP.UnitID() = cell.NewOfflinePlanRow().ProductionLine() and tempUP.StartDate() = cell.NewOfflinePlanColumn().StartDate() );
+        if ( not isnull( o ) and not isnull( up ) ) {
+          PeriodTaskOperation::Create( o, up, cell.Quantity(), false );
+        }
+      } else {
+        if ( [Number]cell.Quantity() <> [Number]pto.Quantity() ) {
+          pto.Update( cell.Quantity(), false );
+        }
+      }
+      
+      
+      
+      
+    }
+  *]
+}
diff --git a/_Main/BL/Type_NewOfflinePlanRow/Attribute_OperationID.qbl b/_Main/BL/Type_NewOfflinePlanRow/Attribute_OperationID.qbl
new file mode 100644
index 0000000..0845fa7
--- /dev/null
+++ b/_Main/BL/Type_NewOfflinePlanRow/Attribute_OperationID.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute OperationID
+{
+  #keys: '3[413988.0.1695608112][413988.0.1695608111][413988.0.1695608113]'
+  ValueType: String
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Component_ContextMenuInterface.def b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Component_ContextMenuInterface.def
index 3bde815..6807e36 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Component_ContextMenuInterface.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Component_ContextMenuInterface.def
@@ -124,6 +124,17 @@
         Title: 'Inventory report'
       ]
     }
+    Component mOfflinePlanInterface
+    {
+      #keys: '[413988.0.1697411489]'
+      BaseType: 'WebMenu'
+      Properties:
+      [
+        Image: 'WIND_ENGINE_OFFSHORE'
+        Taborder: 11
+        Title: '涓嬬嚎璁″垝'
+      ]
+    }
   ]
   Properties:
   [
diff --git a/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Component_abgSecondDevelopmentPlan.def b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Component_abgSecondDevelopmentPlan.def
index 8a7c394..65f45f0 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Component_abgSecondDevelopmentPlan.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Component_abgSecondDevelopmentPlan.def
@@ -34,6 +34,7 @@
         Image: 'LIGHTBULB'
         Label: 'Output plan'
         Taborder: 1
+        Visible: false
       ]
     }
     Component bAssemblyOnlinePlan
diff --git a/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_mOfflinePlanInterface_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_mOfflinePlanInterface_OnClick.def
new file mode 100644
index 0000000..0e7644b
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_mOfflinePlanInterface_OnClick.def
@@ -0,0 +1,23 @@
+Quintiq file version 2.0
+#parent: ContextMenuInterface/mOfflinePlanInterface
+Response OnClick () id:Response_MacroPlanner_ContextMenuInterface_mOfflinePlanInterface_OnClick
+{
+  #keys: '[413988.0.1697411525]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebMenu_OnClick'
+  Precondition:
+  [*
+    return not isnull( MacroPlan ) and not isnull( InterfaceDataset );
+  *]
+  QuillAction
+  {
+    Body:
+    [*
+      // 瀛樻。
+      NewOfflinePlanCell::InterfaceArchive( MacroPlan, InterfaceDataset );
+      
+      WebMessageBox::Success( Translations::A_VWED_Success() );
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Component_MatrixEditor515.def b/_Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Component_MatrixEditor515.def
index fbd9bc5..1d48179 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Component_MatrixEditor515.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Component_MatrixEditor515.def
@@ -86,6 +86,17 @@
     }
     #child: matrixEditorActionBarPage623
     #child: matrixeditorContextMenu229
+    Component UserConfigurableInformation675
+    {
+      #keys: '[413988.0.1697329605]'
+      BaseType: 'WebUserConfigurableInformation'
+      Properties:
+      [
+        ObjectType: 'NewOfflinePlanCell'
+        Taborder: 5
+        Tooltip: 'VALUE( object.GetNewOfflinePlanMatrixTooltip() )'
+      ]
+    }
   ]
   Properties:
   [
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Response_pHeader_bConfirm_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Response_pHeader_bConfirm_OnClick.def
index fe7c4a0..e3789bd 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Response_pHeader_bConfirm_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Response_pHeader_bConfirm_OnClick.def
@@ -13,8 +13,8 @@
   {
     Body:
     [*
-      // 瀛樻。
-      NewOfflinePlanCell::InterfaceArchive( MacroPlan, InterfaceDataset );
+      // 鍚屾鍒板懆鏈熶换鍔�
+      NewOfflinePlanCell::SynchronizeToNewSupply( MacroPlan, dhNewOfflinePlanTable.Data() );
       
       // 璁剧疆鎸夐挳锛堥櫎涓嬭浇锛変笉鍙敤
       MacroPlan.A_PreviousScenaioName( MacroPlan.ScenarioName() );
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Response_pHeader_bDeductChangeoverLoss_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Response_pHeader_bDeductChangeoverLoss_OnClick.def
index a054df7..31f00c2 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Response_pHeader_bDeductChangeoverLoss_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormNewOfflinePlan/Response_pHeader_bDeductChangeoverLoss_OnClick.def
@@ -13,6 +13,11 @@
   {
     Body:
     [*
+      NewOfflinePlanCell::DeductionOfReplacementLoss( MacroPlan, dhNewOfflinePlanTable.Data() );
+      
+      opt := maxselect( MacroPlan, NewOfflinePlanTable, tempNOPT, true, tempNOPT.SaveDateTime() );
+      dhNewOfflinePlanTable.Data( opt );
+      
       WebMessageBox::Success( Translations::A_VWED_Success() );
     *]
     GroupServerCalls: false
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormProductionPlan/Component_MatrixEditorPISPIP.def b/_Main/UI/MacroPlannerWebApp/Component_FormProductionPlan/Component_MatrixEditorPISPIP.def
new file mode 100644
index 0000000..baef54d
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormProductionPlan/Component_MatrixEditorPISPIP.def
@@ -0,0 +1,10 @@
+Quintiq file version 2.0
+Component MatrixEditorPISPIP #extension
+{
+  Children:
+  [
+    Component UserConfigurableInformationMatrixEditorPISPIP #extension
+    {
+    }
+  ]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormProductionPlan/Component_PanelMatrix.def b/_Main/UI/MacroPlannerWebApp/Component_FormProductionPlan/Component_PanelMatrix.def
new file mode 100644
index 0000000..8186e86
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormProductionPlan/Component_PanelMatrix.def
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+Component PanelMatrix #extension
+{
+  Children:
+  [
+    #child: MatrixEditorPISPIP
+  ]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormProductionPlan/_ROOT_Component_FormProductionPlan.def b/_Main/UI/MacroPlannerWebApp/Component_FormProductionPlan/_ROOT_Component_FormProductionPlan.def
new file mode 100644
index 0000000..b8c746a
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormProductionPlan/_ROOT_Component_FormProductionPlan.def
@@ -0,0 +1,10 @@
+Quintiq file version 2.0
+#root
+#parent: LibMacroPlannerWebUI
+OrphanComponent FormProductionPlan #extension
+{
+  Children:
+  [
+    #child: PanelMatrix
+  ]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Views/NewOfflinePlan.vw b/_Main/UI/MacroPlannerWebApp/Views/NewOfflinePlan.vw
index bcd0a9f..31f8d84 100644
--- a/_Main/UI/MacroPlannerWebApp/Views/NewOfflinePlan.vw
+++ b/_Main/UI/MacroPlannerWebApp/Views/NewOfflinePlan.vw
@@ -30,7 +30,7 @@
           FormNewOfflinePlan_MatrixEditor515
           {
             gridColor: '#c4c4c4'
-            totalHeaderWidth: 511
+            totalHeaderWidth: 507
             attributeHeaderWidthRatio: 0.6
             nameHeaderWidthRatio: 0.4
             columnWidth: 100
@@ -50,7 +50,7 @@
                       type: 'MatrixEditorWebApiCellDataModelInterest'
                       index: 0
                       rowsubtotal: ''
-                      columnsubtotal: 'sum'
+                      columnsubtotal: ''
                       attribute: 'Quantity'
                     }
                     attribute_Order
@@ -87,7 +87,7 @@
           FormNewOfflinePlan_MatrixEditor583
           {
             gridColor: '#c4c4c4'
-            totalHeaderWidth: 510
+            totalHeaderWidth: 509
             attributeHeaderWidthRatio: 0.6
             nameHeaderWidthRatio: 0.4
             columnWidth: 100
@@ -155,48 +155,6 @@
           }
         }
       }
-      form_FormGeneralSettings
-      {
-        title: 'General Settings'
-        shown: true
-        componentID: 'FormGeneralSettings'
-        layout
-        {
-          mode: 'dockright'
-          index: 0
-        }
-        components
-        {
-          FormGeneralSettings_PanelContent
-          {
-            sizeRatio: 1
-          }
-          FormGeneralSettings_PanelGeneralParameter
-          {
-            sizeRatio: 1
-          }
-          FormGeneralSettings_PanelLeadTimeDependent
-          {
-            sizeRatio: 1
-          }
-          FormGeneralSettings_PanelShelfLife
-          {
-            sizeRatio: 1
-          }
-          FormGeneralSettings_PanelSustainability
-          {
-            sizeRatio: 1
-          }
-          FormGeneralSettings_PanelForecastNetting
-          {
-            sizeRatio: 1
-          }
-          FormGeneralSettings_PanelActions
-          {
-            sizeRatio: 1
-          }
-        }
-      }
     }
     userconfigurableinformation
     {
@@ -204,7 +162,7 @@
     page: ''
     group: ''
     index: 0
-    image: 'CHART_DONUT'
+    image: 'BEAR'
     description: ''
   }
   formatversion: 2

--
Gitblit v1.9.3