From d4d53b863bec6b836baff0f6f50131d8223cca4d Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期二, 27 八月 2024 10:52:01 +0800
Subject: [PATCH] 装配上线计划+机加下线计划筛选

---
 _Main/BL/Type_AOnlineAndMOfflinePlanMS64/StaticMethod_GenerateData.qbl                                                                         |    8 +-
 /dev/null                                                                                                                                      |    8 --
 _Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_MenuAOnlineAndMOfflinePlanMS64_On.def |    2 
 _Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Method_New.def                                                                          |   14 ++++
 _Main/BL/Type_AOnlineAndMOfflinePlanPIR/Attribute_ZPPPSCode.qbl                                                                                |    7 ++
 _Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Method_OnOk.def                                                                         |   18 +++---
 _Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSPIR/Component_pnlLeft.def                                                                    |   16 ++++
 _Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_MenuIAOnlineAndMOfflinePlanPIR_On.def |    2 
 _Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSPIR/Method_New.def                                                                           |   14 ++++
 _Main/BL/Type_AOnlineAndMOfflinePlanPIR/StaticMethod_GenerateData.qbl                                                                          |   38 +++++++++---
 _Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Component_pnlLeft#88.def                                                                |   44 +++++++++++++-
 11 files changed, 132 insertions(+), 39 deletions(-)

diff --git a/_Main/BL/Type_AOnlineAndMOfflinePlanMS64/Attribute_Product.qbl b/_Main/BL/Type_AOnlineAndMOfflinePlanMS64/Attribute_Product.qbl
deleted file mode 100644
index 775fd68..0000000
--- a/_Main/BL/Type_AOnlineAndMOfflinePlanMS64/Attribute_Product.qbl
+++ /dev/null
@@ -1,8 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Attribute Product
-{
-  #keys: '3[415136.0.1039640197][415136.0.1039640196][415136.0.1039640198]'
-  Description: '鐗╂枡鍙�'
-  ValueType: String
-}
diff --git a/_Main/BL/Type_AOnlineAndMOfflinePlanMS64/StaticMethod_GenerateData.qbl b/_Main/BL/Type_AOnlineAndMOfflinePlanMS64/StaticMethod_GenerateData.qbl
index dcee82a..8c5280d 100644
--- a/_Main/BL/Type_AOnlineAndMOfflinePlanMS64/StaticMethod_GenerateData.qbl
+++ b/_Main/BL/Type_AOnlineAndMOfflinePlanMS64/StaticMethod_GenerateData.qbl
@@ -5,8 +5,8 @@
   String werk,
   Date startdate,
   Date enddate,
-  const MacroPlan macroplanfrom,
-  const MacroPlan macroplanto,
+  String versionfrom,
+  String versionto,
   Boolean versionflag,
   const Product_MPs products,
   String executor
@@ -37,8 +37,8 @@
                                                       , Success := true
                                                       );
     ms64                   := owner.AOnlineAndMOfflinePlanMS64( relnew, Werk := werk, StartDate := startdate, EndDate := enddate
-                                                                , VersionFrom := macroplanfrom.ScenarioName()
-                                                                , VersionTo := macroplanto.ScenarioName(), IsActive := versionflag );
+                                                                , VersionFrom := versionfrom
+                                                                , VersionTo := versionto, IsActive := versionflag );
     loginfo.AOnlineAndMOfflinePlanMS64( relinsert, ms64 );
     traverse( products, Elements, product, product.IsLeaf() ){
       ms64.MS64Data( relnew, Product := product.ID() );
diff --git a/_Main/BL/Type_AOnlineAndMOfflinePlanPIR/Attribute_ZPPPSCode.qbl b/_Main/BL/Type_AOnlineAndMOfflinePlanPIR/Attribute_ZPPPSCode.qbl
new file mode 100644
index 0000000..3f24b51
--- /dev/null
+++ b/_Main/BL/Type_AOnlineAndMOfflinePlanPIR/Attribute_ZPPPSCode.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute ZPPPSCode
+{
+  #keys: '3[415136.0.1046220023][415136.0.1046220022][415136.0.1046220024]'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_AOnlineAndMOfflinePlanPIR/StaticMethod_GenerateData.qbl b/_Main/BL/Type_AOnlineAndMOfflinePlanPIR/StaticMethod_GenerateData.qbl
index 41dcfab..7a835d1 100644
--- a/_Main/BL/Type_AOnlineAndMOfflinePlanPIR/StaticMethod_GenerateData.qbl
+++ b/_Main/BL/Type_AOnlineAndMOfflinePlanPIR/StaticMethod_GenerateData.qbl
@@ -23,6 +23,7 @@
       owner.AOnlineAndMOfflinePlanPIR( relflush );
     }
     nowdate                := DateTime::ActualTime();
+    productids             := construct( Strings );
     loginfo                := owner.InterfaceLoginfo( relnew, ExecuteUser := executor
                                                       , Name := Translations::InterfaceDataset_AOnlineAndMOfflinePlanPIR_Name()
                                                       , InterfaceDateTime := nowdate
@@ -33,11 +34,15 @@
                                                       , ReturnMsg := 'Success'
                                                       , Success := true
                                                       );
-    pir                    := owner.AOnlineAndMOfflinePlanPIR( relnew, Werk := werk, Version := macroplan.ScenarioName(), StartDate := startdate, EndDate := enddate );
+    pir                    := owner.AOnlineAndMOfflinePlanPIR( relnew, ZPPPSCode := OS::GenerateGUIDAsString(), Werk := werk, Version := macroplan.ScenarioName(), StartDate := startdate, EndDate := enddate );
     loginfo.AOnlineAndMOfflinePlanPIR( relinsert, pir );
-    traverse( macroplan, AssemblyOnlinePlanColumn, column ){
-      traverse( column, AssemblyOnlinePlanCell, cell, cell.Value() <> '' and cell.AssemblyOnlinePlanRow().RowNr() = '1' ){
+    traverse( macroplan, AssemblyOnlinePlanColumn, column, column.ColumnDate() >= startdate and column.ColumnDate() <= enddate ){
+      traverse( column, AssemblyOnlinePlanCell, cell, ( werk = 'All' or cell.AssemblyOnlinePlanRow().ProductionLine().FindString( werk, 0 ) > -1 )
+                and cell.AssemblyOnlinePlanRow().RowNr() = '1' ){
         quantityrow        := cell.AssemblyOnlinePlanRow();
+        if( not exists( productids, Elements, e, e = quantityrow.ProductID() ) ){
+          productids.Add( quantityrow.ProductID() );
+        }
     
         pir.PIRData( relnew, Product           := quantityrow.ProductID()
                      , PlanningDate            := column.ColumnDate()
@@ -46,14 +51,29 @@
     }
     
     traverse( macroplan, OfflinePlanTable, table ){
-      traverse( table, OfflinePlanColumn, column ){
-        traverse( column, OfflinePlanCell, cell, cell.Value() <> '' 
+      traverse( table, OfflinePlanColumn, column, column.ColumnDate() >= startdate and column.ColumnDate() <= enddate ){
+        traverse( column, OfflinePlanCell, cell, ( werk = 'All' or cell.OfflinePlanRow().ProductionLine().FindString( werk, 0 ) > -1 )
                   and ( cell.OfflinePlanRow().ProductionLine() <> 'DL_MOMO' or cell.OfflinePlanRow().ProductionLine() <> 'CC_MOMO' ) ){
           row              := cell.OfflinePlanRow();
-          
-          pir.PIRData( relnew, Product         := row.ProductID()
-                     , PlanningDate            := column.ColumnDate()
-                     , PlanningQty             := [Number]cell.Value());
+          if( not exists( productids, Elements, e, e = row.ProductID() ) ){
+            productids.Add( row.ProductID() );
+          }
+          pirdata          := selectobject(  pir, PIRData, pirdata, pirdata.Product() = row.ProductID() and pirdata.PlanningDate() = column.ColumnDate() );
+          if( isnull( pir ) ){
+            pirdata          := pir.PIRData( relnew, Product         := row.ProductID()
+                                             , PlanningDate            := column.ColumnDate()
+                                             , PlanningQty             := 0 );
+          }
+          pirdata.PlanningQty( pirdata.PlanningQty() + [Number]cell.Value() );
+        }
+      }
+    }
+    traverse( productids, Elements, e ){
+      for( date := startdate.StartOfWeek(); date <= enddate; date := ( date + Duration::Days( 1 ) ).Date() ){
+        if( not exists( pir, PIRData, pirdata, pirdata.Product() = e and pirdata.PlanningDate() = date ) ){
+          pir.PIRData( relnew, Product         := e
+                     , PlanningDate            := date
+                     , PlanningQty             := 0 );
         }
       }
     }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_MenuAOnlineAndMOfflinePlanMS64_On.def b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_MenuAOnlineAndMOfflinePlanMS64_On.def
index 12fa1c6..da07b97 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_MenuAOnlineAndMOfflinePlanMS64_On.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_MenuAOnlineAndMOfflinePlanMS64_On.def
@@ -14,7 +14,7 @@
     Body:
     [*
       dlg := construct( DialogZEDPPSMS64 );
-      ApplicationMacroPlanner.ShowFormModal( dlg );
+      dlg.New();
     *]
     GroupServerCalls: false
   }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_MenuIAOnlineAndMOfflinePlanPIR_On.def b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_MenuIAOnlineAndMOfflinePlanPIR_On.def
index 32ccaf6..e9ee4cf 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_MenuIAOnlineAndMOfflinePlanPIR_On.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_ContextMenuInterface_MenuIAOnlineAndMOfflinePlanPIR_On.def
@@ -15,7 +15,7 @@
     [*
       dlg := construct( DialogZEDPPSPIR );
       //dlg.Title( Translations::InterfaceDataset_AssemblyOnlinePlanPPPSPush_Name() );
-      ApplicationMacroPlanner.ShowFormModal( dlg );
+      dlg.New();
       //dlg.New( Translations::InterfaceDataset_AssemblyOnlinePlanPPPSPush_Name() );
     *]
     GroupServerCalls: false
diff --git "a/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Component_pnlLeft\04388.def" "b/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Component_pnlLeft\04388.def"
index 31cbf69..48c5652 100644
--- "a/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Component_pnlLeft\04388.def"
+++ "b/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Component_pnlLeft\04388.def"
@@ -13,6 +13,7 @@
       [
         Label: '宸ュ巶浠g爜'
         Taborder: 0
+        Visible: false
       ]
     }
     Component dsStartDate
@@ -22,7 +23,7 @@
       Properties:
       [
         Label: '寮�濮嬫棩鏈�'
-        Taborder: 1
+        Taborder: 2
       ]
     }
     Component dsEndDate
@@ -32,7 +33,7 @@
       Properties:
       [
         Label: '缁撴潫鏃ユ湡'
-        Taborder: 2
+        Taborder: 3
       ]
     }
     Component cbActiveVersion
@@ -43,7 +44,7 @@
       [
         Checked: true
         Label: '鏄惁婵�娲荤増鏈�'
-        Taborder: 5
+        Taborder: 8
       ]
     }
     Component ddlOriginMacroPlan
@@ -70,7 +71,8 @@
       [
         DisplayField: 'Name'
         Label: '浠庣増鏈�'
-        Taborder: 3
+        Taborder: 4
+        Visible: false
       ]
     }
     Component ddlDestinationMacroPlan
@@ -97,7 +99,39 @@
       [
         DisplayField: 'Name'
         Label: '鍒扮増鏈�'
-        Taborder: 4
+        Taborder: 6
+        Visible: false
+      ]
+    }
+    Component efVersionFrom
+    {
+      #keys: '[415136.0.1047640864]'
+      BaseType: 'WebEditField'
+      Properties:
+      [
+        Label: '浠庣増鏈�'
+        Taborder: 5
+      ]
+    }
+    Component efVersionTo
+    {
+      #keys: '[415136.0.1047640919]'
+      BaseType: 'WebEditField'
+      Properties:
+      [
+        Label: '鍒扮増鏈�'
+        Taborder: 7
+      ]
+    }
+    Component ddslFactory
+    {
+      #keys: '[415136.0.1047641023]'
+      BaseType: 'WebDropDownStringList'
+      Properties:
+      [
+        Label: '宸ュ巶浠g爜'
+        Strings: 'All;DL;CC'
+        Taborder: 1
       ]
     }
   ]
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Method_New.def b/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Method_New.def
new file mode 100644
index 0000000..95934c9
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Method_New.def
@@ -0,0 +1,14 @@
+Quintiq file version 2.0
+#parent: #root
+Method New () id:Method_DialogZEDPPSMS64_New
+{
+  #keys: '[415136.0.1047779759]'
+  Body:
+  [*
+    // To create a new product
+    dsStartDate.Date( Date::ActualDate() );
+    dsEndDate.Date( Date::ActualDate() );
+    
+    ApplicationMacroPlanner.ShowFormModal( this );
+  *]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Method_OnOk.def b/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Method_OnOk.def
index fd72dbf..17d686c 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Method_OnOk.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSMS64/Method_OnOk.def
@@ -6,18 +6,18 @@
   Body:
   [*
     Form.ApplyChanges();
-    componentmds    := ApplicationScope.ComponentMDS();
-    mdsinstanceF    := select( componentmds, ComponentMDSKinds.ComponentMDSInstances, m, m.MDSID().MDSKey() = ddlOriginMacroPlan.Data().DatasetMDSID() );
-    handleF         := mdsinstanceF.GetMDSHandle()
-    macroplanF      := handleF.AsMacroPlan();
-    
-    mdsinstanceT    := select( componentmds, ComponentMDSKinds.ComponentMDSInstances, m, m.MDSID().MDSKey() = ddlDestinationMacroPlan.Data().DatasetMDSID() );
-    handleT         := mdsinstanceT.GetMDSHandle()
-    macroplanT      := handleT.AsMacroPlan();
+    //componentmds    := ApplicationScope.ComponentMDS();
+    //mdsinstanceF    := select( componentmds, ComponentMDSKinds.ComponentMDSInstances, m, m.MDSID().MDSKey() = ddlOriginMacroPlan.Data().DatasetMDSID() );
+    //handleF         := mdsinstanceF.GetMDSHandle()
+    //macroplanF      := handleF.AsMacroPlan();
+    //
+    //mdsinstanceT    := select( componentmds, ComponentMDSKinds.ComponentMDSInstances, m, m.MDSID().MDSKey() = ddlDestinationMacroPlan.Data().DatasetMDSID() );
+    //handleT         := mdsinstanceT.GetMDSHandle()
+    //macroplanT      := handleT.AsMacroPlan();
     
     currentuser     := QuintiqUser::CurrentUser().DisplayName();
     
-    AOnlineAndMOfflinePlanMS64::GenerateData( InterfaceDataset, efFactory.Text(), dsStartDate.Date(), dsEndDate.Date(), macroplanF, macroplanT, cbActiveVersion.Checked(), dhProducts.Data(), currentuser );
+    AOnlineAndMOfflinePlanMS64::GenerateData( InterfaceDataset, efFactory.Text(), dsStartDate.Date(), dsEndDate.Date(), efVersionFrom.Text(), efVersionTo.Text(), cbActiveVersion.Checked(), dhProducts.Data(), currentuser );
     
     Form.Close();
   *]
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSPIR/Component_pnlLeft.def b/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSPIR/Component_pnlLeft.def
index 0b21eb4..8940313 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSPIR/Component_pnlLeft.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSPIR/Component_pnlLeft.def
@@ -13,6 +13,7 @@
       [
         Label: '宸ュ巶浠g爜'
         Taborder: 0
+        Visible: false
       ]
     }
     Component dsStartDate id:dsStartDate_60
@@ -22,7 +23,7 @@
       Properties:
       [
         Label: '璁″垝寮�濮嬫椂闂�'
-        Taborder: 2
+        Taborder: 3
       ]
     }
     Component dsEndDate id:dsEndDate_236
@@ -32,7 +33,7 @@
       Properties:
       [
         Label: '璁″垝缁撴潫鏃堕棿'
-        Taborder: 3
+        Taborder: 4
       ]
     }
     Component ddlMacroPlan
@@ -59,6 +60,17 @@
       [
         DisplayField: 'Name'
         Label: '鐗堟湰'
+        Taborder: 2
+      ]
+    }
+    Component ddslFactory id:ddslFactory_424
+    {
+      #keys: '[415136.0.1047641312]'
+      BaseType: 'WebDropDownStringList'
+      Properties:
+      [
+        Label: '宸ュ巶浠g爜'
+        Strings: 'All;DL;CC'
         Taborder: 1
       ]
     }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSPIR/Method_New.def b/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSPIR/Method_New.def
new file mode 100644
index 0000000..d283c1c
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogZEDPPSPIR/Method_New.def
@@ -0,0 +1,14 @@
+Quintiq file version 2.0
+#parent: #root
+Method New () id:Method_DialogZEDPPSPIR_New
+{
+  #keys: '[415136.0.1047779645]'
+  Body:
+  [*
+    // To create a new product
+    dsStartDate.Date( Date::ActualDate() );
+    dsEndDate.Date( Date::ActualDate() );
+    
+    ApplicationMacroPlanner.ShowFormModal( this );
+  *]
+}

--
Gitblit v1.9.3