From 56c0e837d2caae5f6a9ecda085715d6e29757ece Mon Sep 17 00:00:00 2001
From: Kevin Kok Khah Whey <khahwhey.kok@3ds.com>
Date: 星期三, 27 九月 2023 18:45:27 +0800
Subject: [PATCH] Kevin: Added test method and modified GlobalOTDTable.SetIsLinkedWithFinishedGoodAttributes method.

---
 _Main/BL/Type_Global_MappingProduct_MP/Method_SetIsLinkedWithFinishedGoodAttributes_Recursive.qbl                               |   14 +++++++++++---
 _Main/BL/Type_GlobalDTOTable/Method_Test.qbl                                                                                    |    9 +++++++++
 _Main/BL/Type_GlobalDTOTable/Method_SetIsLinkedWithFinishedGoodAttributes.qbl                                                   |    8 ++++++--
 _Main/BL/Type_Global_MappingProduct_MP/Attribute_BOMCount.qbl                                                                   |    8 ++++++++
 _Main/UI/MacroPlanner/Component_ApplicationLibMacroPlanner/Response_TIANMA_JITUAN_mbMainMenu_MenuGlobalOTDTableTest_OnClick.def |   12 ++++++++++++
 _Main/UI/MacroPlanner/Component_ApplicationLibMacroPlanner/Component_mbMainMenu.def                                             |    5 +++++
 6 files changed, 51 insertions(+), 5 deletions(-)

diff --git a/_Main/BL/Type_GlobalDTOTable/Method_SetIsLinkedWithFinishedGoodAttributes.qbl b/_Main/BL/Type_GlobalDTOTable/Method_SetIsLinkedWithFinishedGoodAttributes.qbl
index 6aedc24..5a4ba17 100644
--- a/_Main/BL/Type_GlobalDTOTable/Method_SetIsLinkedWithFinishedGoodAttributes.qbl
+++ b/_Main/BL/Type_GlobalDTOTable/Method_SetIsLinkedWithFinishedGoodAttributes.qbl
@@ -30,12 +30,16 @@
     traverse( this, Global_MappingProduct_MP, product,
               product.ProductMajorType() = "鎴愬搧" )
     {
+      uniquebomids := construct( Strings );
+      product.IsLinkedWithFinishedGood( false );
       product.SetIsLinkedWithFinishedGoodAttributes_Recursive( 0, // depth
                                                                100, // maxdepth
                                                                productspool,
                                                                operationspool,
-                                                               operationbomspool );
-      
+                                                               operationbomspool,
+                                                               uniquebomids );
+      uniquebomids := uniquebomids.Unique();
+      product.BOMCount( uniquebomids.Size() );
     }
   *]
 }
diff --git a/_Main/BL/Type_GlobalDTOTable/Method_Test.qbl b/_Main/BL/Type_GlobalDTOTable/Method_Test.qbl
new file mode 100644
index 0000000..26e43f9
--- /dev/null
+++ b/_Main/BL/Type_GlobalDTOTable/Method_Test.qbl
@@ -0,0 +1,9 @@
+Quintiq file version 2.0
+#parent: #root
+Method Test
+{
+  TextBody:
+  [*
+    // KKO2 Sep-27-2023 (created)
+  *]
+}
diff --git a/_Main/BL/Type_Global_MappingProduct_MP/Attribute_BOMCount.qbl b/_Main/BL/Type_Global_MappingProduct_MP/Attribute_BOMCount.qbl
new file mode 100644
index 0000000..1916cbd
--- /dev/null
+++ b/_Main/BL/Type_Global_MappingProduct_MP/Attribute_BOMCount.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute BOMCount
+{
+  #keys: '3[157968.0.1161166085][157968.0.1161166084][157968.0.1161166086]'
+  Description: 'Number of unique BOM used to produce this finished good.'
+  ValueType: Number
+}
diff --git a/_Main/BL/Type_Global_MappingProduct_MP/Method_SetIsLinkedWithFinishedGoodAttributes_Recursive.qbl b/_Main/BL/Type_Global_MappingProduct_MP/Method_SetIsLinkedWithFinishedGoodAttributes_Recursive.qbl
index 4c9b813..f0425fa 100644
--- a/_Main/BL/Type_Global_MappingProduct_MP/Method_SetIsLinkedWithFinishedGoodAttributes_Recursive.qbl
+++ b/_Main/BL/Type_Global_MappingProduct_MP/Method_SetIsLinkedWithFinishedGoodAttributes_Recursive.qbl
@@ -5,7 +5,8 @@
   Number maxdepth,
   Global_MappingProduct_MPs productspool,
   Global_MappingOperations operationspool,
-  Global_MappingOperationBOMs operationbomspool
+  Global_MappingOperationBOMs operationbomspool,
+  output Strings uniquebomids_o
 )
 {
   Description: 'Method to traverse the supply chain recursively to determine if there are any products that are not used to produce finished goods.'
@@ -13,6 +14,11 @@
   [*
     if( not this.IsLinkedWithFinishedGood() )
     {
+      if( this.ProductMajorType() <> "鎴愬搧" )
+      {
+        uniquebomids_o.Add( this.ID() );
+      }
+      
       depth := depth + 1;
       this.IsLinkedWithFinishedGood( true );
       
@@ -50,7 +56,8 @@
                                                                                 maxdepth,
                                                                                 productspool,
                                                                                 operationspool,
-                                                                                operationbomspool );
+                                                                                operationbomspool,
+                                                                                uniquebomids_o );
             }
             
             if( operationbom.AlternativeMaterialCode() <> ""
@@ -66,7 +73,8 @@
                                                                                     maxdepth,
                                                                                     productspool,
                                                                                     operationspool,
-                                                                                    operationbomspool );
+                                                                                    operationbomspool,
+                                                                                    uniquebomids_o );
               }
             }
           }
diff --git a/_Main/UI/MacroPlanner/Component_ApplicationLibMacroPlanner/Component_mbMainMenu.def b/_Main/UI/MacroPlanner/Component_ApplicationLibMacroPlanner/Component_mbMainMenu.def
index 7aa83c9..4ad9e84 100644
--- a/_Main/UI/MacroPlanner/Component_ApplicationLibMacroPlanner/Component_mbMainMenu.def
+++ b/_Main/UI/MacroPlanner/Component_ApplicationLibMacroPlanner/Component_mbMainMenu.def
@@ -13,6 +13,10 @@
           [
             Component MenuSpecial #extension
             {
+              Children:
+              [
+                Component MenuGlobalOTDTableTest { #keys: '[157968.0.1170224128]' BaseType: 'Menu' Properties: [ Image: 'DUDE2' Text: 'GlobalOTDTable Test' ] }
+              ]
               Properties:
               [
                 ModeledStringList ChildOrdering
@@ -30,6 +34,7 @@
                   c: MenuTest
                   c: MenuScenarioManagerTest
                   c: MenuMPDomainHandlerTest
+                  c: MenuGlobalOTDTableTest
                   c: MenuRemoveHistory
                   c: Menu46
                   c: MenuRefresh
diff --git a/_Main/UI/MacroPlanner/Component_ApplicationLibMacroPlanner/Response_TIANMA_JITUAN_mbMainMenu_MenuGlobalOTDTableTest_OnClick.def b/_Main/UI/MacroPlanner/Component_ApplicationLibMacroPlanner/Response_TIANMA_JITUAN_mbMainMenu_MenuGlobalOTDTableTest_OnClick.def
new file mode 100644
index 0000000..9596987
--- /dev/null
+++ b/_Main/UI/MacroPlanner/Component_ApplicationLibMacroPlanner/Response_TIANMA_JITUAN_mbMainMenu_MenuGlobalOTDTableTest_OnClick.def
@@ -0,0 +1,12 @@
+Quintiq file version 2.0
+#parent: mbMainMenu/MenuGlobalOTDTableTest
+Response OnClick () id:Response_TIANMA_JITUAN_mbMainMenu_MenuGlobalOTDTableTest_OnClick
+{
+  #keys: '[157968.0.1170224134]'
+  Body:
+  [*
+    // Run GlobalOTDTable test method
+    GlobalOTDTable.Test();
+  *]
+  DefinitionID: 'Responsedef_Menu_OnClick'
+}

--
Gitblit v1.9.3