From d30a8bbf3f46528e1773bce1a2065b2462b84a18 Mon Sep 17 00:00:00 2001
From: renhao <renhui.hao@capgemini.com>
Date: 星期四, 21 九月 2023 15:03:36 +0800
Subject: [PATCH] GlobalOTDTable修改

---
 _Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataRouting#576.qbl |    5 
 _Main/BL/Type_Global_MappingOperation/StaticMethod_FindMinSeq.qbl     |   17 ++
 _Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl          |    5 
 _Main/BL/Type_Forecast/StaticMethod_DoSync.qbl                        |    9 
 _Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpoint.qbl   |    2 
 _Main/BL/Type_MacroPlan/Method_MappingProductData.qbl                 |   11 +
 _Main/BL/Type_MacroPlan/Method_InitialUnitAndStockingPoint.qbl        |   86 -------------
 _Main/BL/Type_MacroPlan/Method_MappingBaseConversionFactorData.qbl    |    8 
 _Main/BL/Type_MacroPlan/Method_MappingForecastData.qbl                |    9 
 _Main/BL/Type_MacroPlan/Method_MappingInventoryValueAndCostData.qbl   |    6 
 _Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl            |   11 +
 _Main/BL/Type_BaseConversionFactor/StaticMethod_DoSync.qbl            |    9 
 _Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl                      |   53 ++++----
 _Main/BL/Type_MacroPlan/Method_MappingCustomerOrderData.qbl           |   13 +-
 _Main/BL/Type_UnitOfMeasure_MP/StaticMethod_DoSync.qbl                |    4 
 _Main/BL/Type_MacroPlan/StaticMethod_DoSync#618.qbl                   |    5 
 _Main/BL/Type_MacroPlan/Method_MappingUnitData.qbl                    |    9 
 _Main/BL/Type_CustomerOrder/StaticMethod_DoSync.qbl                   |    9 
 _Main/BL/Type_MacroPlan/Method_MappingProductInLaneData.qbl           |    6 
 _Main/BL/Type_MacroPlan/StaticMethod_DoSync.qbl                       |    5 
 _Main/BL/Type_SalesSegment_MP/StaticMethod_DoSync.qbl                 |    9 
 _Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl            |    6 
 _Main/BL/Type_MacroPlan/Method_MappingSalesSegmentData.qbl            |    9 
 _Main/BL/Type_MacroPlan/Method_MappingOperationData.qbl               |    9 
 _Main/BL/Type_InventoryValueAndCost/StaticMethod_DoSync.qbl           |    9 
 25 files changed, 143 insertions(+), 181 deletions(-)

diff --git a/_Main/BL/Type_BaseConversionFactor/StaticMethod_DoSync.qbl b/_Main/BL/Type_BaseConversionFactor/StaticMethod_DoSync.qbl
index 0ee5894..915e3c2 100644
--- a/_Main/BL/Type_BaseConversionFactor/StaticMethod_DoSync.qbl
+++ b/_Main/BL/Type_BaseConversionFactor/StaticMethod_DoSync.qbl
@@ -1,16 +1,17 @@
 Quintiq file version 2.0
 #parent: #root
 StaticMethod DoSync (
-  MacroPlan macroPlan
+  MacroPlan macroPlan,
+  GlobalOTDTable globalOTDTable
 )
 {
   Description: '鍗曟鍚屾'
   TextBody:
   [*
     // yypsybs Aug-17-2023 (created)
-    info( "Product Finished, Start BaseConversionFactor Data Broker" )
-    macroPlan.Broker_OTD_BaseConversionFactor().Execute();
+    //info( "Product Finished, Start BaseConversionFactor Data Broker" )
+    //macroPlan.Broker_OTD_BaseConversionFactor().Execute();
     info( "BaseConversionFactor Data Broker Finished, Start BaseConversionFactor Mapping" )
-    macroPlan.MappingBaseConversionFactorData();
+    macroPlan.MappingBaseConversionFactorData(globalOTDTable);
   *]
 }
diff --git a/_Main/BL/Type_CustomerOrder/StaticMethod_DoSync.qbl b/_Main/BL/Type_CustomerOrder/StaticMethod_DoSync.qbl
index ece7264..170d328 100644
--- a/_Main/BL/Type_CustomerOrder/StaticMethod_DoSync.qbl
+++ b/_Main/BL/Type_CustomerOrder/StaticMethod_DoSync.qbl
@@ -2,15 +2,16 @@
 #parent: #root
 StaticMethod DoSync (
   MacroPlan macroPlan,
-  Strings businessTypes
+  Strings businessTypes,
+  GlobalOTDTable globalOTDTable
 )
 {
   TextBody:
   [*
     // yypsybs Aug-17-2023 (created)
-    info( "Forecast Finished, Start CustomerOrder Data Broker" );
-    macroPlan.Broker_OTD_CustomerOrder().Execute();
+    //info( "Forecast Finished, Start CustomerOrder Data Broker" );
+    //macroPlan.Broker_OTD_CustomerOrder().Execute();
     info( "CustomerOrder Data Broker Finished, Start CustomerOrder Mapping" );
-    macroPlan.MappingCustomerOrderData( businessTypes );
+    macroPlan.MappingCustomerOrderData( businessTypes,globalOTDTable );
   *]
 }
diff --git a/_Main/BL/Type_Forecast/StaticMethod_DoSync.qbl b/_Main/BL/Type_Forecast/StaticMethod_DoSync.qbl
index 401e158..1fdba27 100644
--- a/_Main/BL/Type_Forecast/StaticMethod_DoSync.qbl
+++ b/_Main/BL/Type_Forecast/StaticMethod_DoSync.qbl
@@ -2,15 +2,16 @@
 #parent: #root
 StaticMethod DoSync (
   MacroPlan macroPlan,
-  Strings businessTypes
+  Strings businessTypes,
+  GlobalOTDTable globalOTDTable
 )
 {
   TextBody:
   [*
     // yypsybs Aug-17-2023 (created)
-    info( "OperationCost Finished, Start Forecast Data Broker" );
-    macroPlan.Broker_OTD_Forecast().Execute();
+    //info( "OperationCost Finished, Start Forecast Data Broker" );
+    //macroPlan.Broker_OTD_Forecast().Execute();
     info( "Forecast Data Broker Finished, Start Forecast Mapping" );
-    macroPlan.MappingForecastData( businessTypes );
+    macroPlan.MappingForecastData( businessTypes,globalOTDTable );
   *]
 }
diff --git a/_Main/BL/Type_Global_MappingOperation/StaticMethod_FindMinSeq.qbl b/_Main/BL/Type_Global_MappingOperation/StaticMethod_FindMinSeq.qbl
new file mode 100644
index 0000000..0a72c14
--- /dev/null
+++ b/_Main/BL/Type_Global_MappingOperation/StaticMethod_FindMinSeq.qbl
@@ -0,0 +1,17 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod FindMinSeq (
+  GlobalOTDTable globalOTDTable,
+  String orgCode,
+  String productId,
+  String processSection
+) as Number
+{
+  TextBody:
+  [*
+    // renhao Sep-20-2023 (created)
+    return guard (min( globalOTDTable, Global_MappingOperation, item, 
+                item.OrganCode() = orgCode and item.ProductID() = productId and item.ProcessSection() = processSection,
+                item.SequenceNumber() ), Number::MinNumber() );
+  *]
+}
diff --git a/_Main/BL/Type_InventoryValueAndCost/StaticMethod_DoSync.qbl b/_Main/BL/Type_InventoryValueAndCost/StaticMethod_DoSync.qbl
index 574ecd5..e210049 100644
--- a/_Main/BL/Type_InventoryValueAndCost/StaticMethod_DoSync.qbl
+++ b/_Main/BL/Type_InventoryValueAndCost/StaticMethod_DoSync.qbl
@@ -1,15 +1,16 @@
 Quintiq file version 2.0
 #parent: #root
 StaticMethod DoSync (
-  MacroPlan macroPlan
+  MacroPlan macroPlan,
+  GlobalOTDTable globalOTDTable
 )
 {
   TextBody:
   [*
     // yypsybs Aug-17-2023 (created)
-    info( "ActualPISPIP Finished, Start InventoryCost Data Broker" );
-    macroPlan.Broker_OTD_InventoryCost().Execute();
+    //info( "ActualPISPIP Finished, Start InventoryCost Data Broker" );
+    //macroPlan.Broker_OTD_InventoryCost().Execute();
     info( "InventoryCost Data Broker Finished, Start InventoryCost Mapping" );
-    macroPlan.MappingInventoryValueAndCostData();
+    macroPlan.MappingInventoryValueAndCostData(globalOTDTable);
   *]
 }
diff --git a/_Main/BL/Type_MacroPlan/Method_InitialUnitAndStockingPoint.qbl b/_Main/BL/Type_MacroPlan/Method_InitialUnitAndStockingPoint.qbl
index c71e147..ee48ee3 100644
--- a/_Main/BL/Type_MacroPlan/Method_InitialUnitAndStockingPoint.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_InitialUnitAndStockingPoint.qbl
@@ -7,88 +7,12 @@
     // Administrator Sep-1-2023 (created)
     
     //Set the Default values
-    unitofmeasurename := "PCS";
-    currencyid := "CNY";
-    startdate := Date::Date( 1900, 1, 1 );
-    enddate := Date::Date( 9999, 12, 31 );
-    capacitytype := "Transport quantity";
+    //unitofMeasureName := "PCS";
+    //currencyid := "CNY";
+    //startdate := Date::Date( 1900, 1, 1 );
+    //enddate := Date::Date( 9999, 12, 31 );
+    //capacitytype := "Transport quantity";
     
-    if( isnull( Unit::FindById( this, "绌鸿繍" ) ) ){
-      this.Unit( relnew, 
-                 ID := "绌鸿繍", 
-                 Name := "绌鸿繍", 
-                 UnitOfMeasureName := unitofmeasurename, 
-                 CurrencyID := currencyid, 
-                 StartDate := startdate, 
-                 EndDate := enddate, 
-                 CapacityType := capacitytype );
-      }
-    
-    if( isnull( Unit::FindById( this, "搴撳瓨浜嬪姟澶勭悊" ) ) ){
-      this.Unit( relnew, 
-                 ID := "搴撳瓨浜嬪姟澶勭悊", 
-                 Name := "搴撳瓨浜嬪姟澶勭悊", 
-                 UnitOfMeasureName := unitofmeasurename, 
-                 CurrencyID := currencyid, 
-                 StartDate := startdate, 
-                 EndDate := enddate, 
-                 CapacityType := capacitytype );
-    }
-    
-    unitofmeasurename := "PCS";
-    name := "鎵嬪姩鍒涘缓搴撳瓨鐐�";
-    currencyname := "CNY";
-    isplannedinfinite := false;
-    datestart := Date::Construct(1900, 1, 1) ;
-    dateend := Date::Construct(9999, 12, 31);
-    groupname := " ";
-    description := " ";
-    isfromdb := true;
-    
-    if( isnull( StockingPoint_MP::FindById( this, "F13_FG_STOCK" ) ) ){
-      StockingPoint_MP::Create( this, 
-                                "F13_FG_STOCK", 
-                                "F13", 
-                                name, 
-                                unitofmeasurename, 
-                                currencyname, 
-                                isplannedinfinite, 
-                                datestart, 
-                                dateend, 
-                                groupname, 
-                                description, 
-                                isfromdb );
-    }
-    
-    if( isnull( StockingPoint_MP::FindById( this, "H10_SA_STOCK" ) ) ){
-      StockingPoint_MP::Create( this, 
-                                "H10_SA_STOCK", 
-                                "H10", 
-                                name, 
-                                unitofmeasurename, 
-                                currencyname, 
-                                isplannedinfinite, 
-                                datestart, 
-                                dateend, 
-                                groupname, 
-                                description, 
-                                isfromdb );
-    }
-    
-    if( isnull( StockingPoint_MP::FindById( this, "Q10_FG_STOCK" ) ) ){
-      StockingPoint_MP::Create( this, 
-                                "Q10_FG_STOCK", 
-                                "Q10", 
-                                name, 
-                                unitofmeasurename, 
-                                currencyname, 
-                                isplannedinfinite, 
-                                datestart, 
-                                dateend, 
-                                groupname, 
-                                description, 
-                                isfromdb );
-    }
     
     existcurrency := Currency_MP::FindById( this, "CNY" );
     if( isnull( existcurrency ) ){
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl
index f9cd042..c6520fb 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl
@@ -2,21 +2,21 @@
 #parent: #root
 Method MappingActualPISPIPData (
   Strings businessTypes,
+  GlobalOTDTable globalOTDTable,
   Boolean nuclear
 )
 {
   TextBody:
   [*
     // renhao Aug-14-2023 (created)
-    date := Date :: Today();
-    listtodeal := selectset( this,MappingActualPISPIP,actual,true );
+    listtodeal := selectset( globalOTDTable,Global_MappingActualProductInStockingPointInPeriod,actual,actual.ActualInventoryLevelEnd() > 0 );
     totalcount := listtodeal.Size();
     info( "ActualPISPIP has " + totalcount.AsQUILL() + " rows in total" );
     
     count := 0;
     traverse( listtodeal,Elements,actual){
       count := count + 1;
-      if( count - [Number](count/100) * 100 = 0 or count = totalcount ){
+      if( count - [Number](count/1000) * 1000 = 0 or count = totalcount ){
         info( "Now is dealing with the " + count.AsQUILL() + "ActualPISPIP " + "( " + count.AsQUILL() + "/" + totalcount.AsQUILL() + " ) " + (count/totalcount*100).Round( 1 ).AsQUILL() + "%" );
         }
       product := select( this,MappingProduct,product,product.ID() = actual.ProductID() and product.KeyProduct() = nuclear,true);
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingBaseConversionFactorData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingBaseConversionFactorData.qbl
index f0a87c2..e0357c1 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingBaseConversionFactorData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingBaseConversionFactorData.qbl
@@ -1,19 +1,21 @@
 Quintiq file version 2.0
 #parent: #root
-Method MappingBaseConversionFactorData
+Method MappingBaseConversionFactorData (
+  GlobalOTDTable globalOTDTable
+)
 {
   Description: 'ETL鏁版嵁杞ā鍨嬫暟鎹�'
   TextBody:
   [*
     // yypsybs Aug-15-2023 (created)
-    traverse( this, MappingBaseConversionFactor, item ) {
+    traverse( globalOTDTable, Global_MappingConversionFactor, item ) {
       //濡傛灉ProductID涓嶄负绌猴紝涓斿尮閰嶄笉鍒癙roduct锛屽垯涓嶅垱寤猴紝杩斿洖涓虹┖
     //    info( item.ProductId().AsQUILL() );
         BaseConversionFactor::CreateOrUpdate( this, 
                                               item.SourceUnitOfMeasureName(), 
                                               item.TargetUnitOfMeasureName(), 
                                               item.IsEnabled(), 
-                                              item.ProductId(), 
+                                              item.ProductID(), 
                                               item.Factor() );
     }
   *]
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingCustomerOrderData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingCustomerOrderData.qbl
index 7ec0576..bee6304 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingCustomerOrderData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingCustomerOrderData.qbl
@@ -1,7 +1,8 @@
 Quintiq file version 2.0
 #parent: #root
 Method MappingCustomerOrderData (
-  Strings businessTypes
+  Strings businessTypes,
+  GlobalOTDTable globalOTDTable
 )
 {
   Description: 'ETL璁㈠崟棰勬祴'
@@ -9,15 +10,15 @@
   [*
     // yypsybs Aug-15-2023 (created)
     // 寰呭鐞嗘暟鎹�
-    listToDeal := construct( structured[MappingCustomerOrder] );
+    listToDeal := construct( Global_MappingCustomOrders );
     if( isnull( businessTypes ) or businessTypes.Size() = 0 ) {
-        listToDeal := selectset( this, MappingCustomerOrder, item, true );
+        listToDeal := selectset( globalOTDTable, Global_MappingCustomOrder, item, true );
     } else {
-        listToDeal := selectset( this, MappingCustomerOrder, item, businessTypes.Find( item.BusinessType() ) <> -1 );
+        listToDeal := selectset( globalOTDTable, Global_MappingCustomOrder, item, businessTypes.Find( item.BusinessType() ) <> -1 );
     }
     queryStartDate := guard( min( this, Period_MP, item, true, item.StartDate() ) - Duration::Days( 30 ), DateTime::MinDateTime() ).Date();
     queryEndDate := guard( max( this, Period_MP, item, true, item.EndDate() ), Date::MaxDate() );
-    listToDeal := selectset( listToDeal, Elements, item, item.OrderDate() >= queryStartDate /*and item.OrderDate() <= queryEndDate*/, not isnull( Product_MP::FindById( this, item.ProductID() ) ) and not isnull( StockingPoint_MP::FindById( this, item.StockPointID() ) ) and not isnull( SalesSegment_MP::FindByName( this, item.SalesSegmentName() ) ) );
+    listToDeal := selectset( listToDeal, Elements, item, item.OrderDate() >= queryStartDate /*and item.OrderDate() <= queryEndDate*/, not isnull( Product_MP::FindById( this, item.ProductID() ) ) and not isnull( StockingPoint_MP::FindById( this, item.StockingPointID() ) ) and not isnull( SalesSegment_MP::FindByName( this, item.SalesSegmentName() ) ) );
     
     totalcount := listToDeal.Size();
     info( "CustomerOrder has " + totalcount.AsQUILL() + " rows in total" );
@@ -35,7 +36,7 @@
       CustomerOrder::CreateOrUpdate( this, item.CurrencyID(), item.Customer(), item.CustomerID(), item.ID(), 
                                      item.OrderDate(), item.OrderID(), item.OrderLineID(), item.Price(), 
                                      priorityName, item.ProductID(), 
-                                     item.StockPointID(), 
+                                     item.StockingPointID(), 
                                      item.SalesSegmentName(), 
                                      item.Quantity(), item.UnitOfMeasureName(), item.OrderType(), item.IsAvailable());
     //  }else{
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
index ead549d..fd69c9c 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
@@ -2,7 +2,8 @@
 #parent: #root
 Method MappingExternalSupplyData (
   Strings businessTypes,
-  Boolean nuclear
+  Boolean nuclear,
+  GlobalOTDTable globalOTDTable
 )
 {
   TextBody:
@@ -10,7 +11,7 @@
     // renhao Aug-14-2023 (created)
     queryStartDate := guard( min( this, Period_MP, item, true, item.StartDate() ) - Duration::Days( 30 ), DateTime::MinDateTime() ).Date();
     queryEndDate := guard( max( this, Period_MP, item, true, item.EndDate() ), Date::MaxDate() );
-    listtodeal := selectset( this,MappingExternalSupply,externalSupply, externalSupply.UserQuantity()>0 and externalSupply.Date() >= queryStartDate /*and externalSupply.Date() <= queryEndDate*/);
+    listtodeal := selectset( globalOTDTable,Global_MappingInventorySupply,externalSupply, externalSupply.UserQuantity()>0 and externalSupply.Date() >= queryStartDate /*and externalSupply.Date() <= queryEndDate*/);
     totalcount := listtodeal.Size();
     description := "鍦ㄩ�斿湪鍒�";
     info( "ExternalSupply has " + totalcount.AsQUILL() + " rows in total" );
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingForecastData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingForecastData.qbl
index 47e8597..21b752b 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingForecastData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingForecastData.qbl
@@ -1,7 +1,8 @@
 Quintiq file version 2.0
 #parent: #root
 Method MappingForecastData (
-  Strings businessTypes
+  Strings businessTypes,
+  GlobalOTDTable globalOTDTable
 )
 {
   Description: 'ETL璁㈠崟棰勬祴'
@@ -9,11 +10,11 @@
   [*
     // yypsybs Aug-15-2023 (created)
     // 寰呭鐞嗘暟鎹�
-    listToDeal := construct( structured[MappingForecast] );
+    listToDeal := construct( Global_MappingForecasts );
     if( isnull( businessTypes ) or businessTypes.Size() = 0 ) {
-        listToDeal := selectset( this, MappingForecast, item, item.Quantity() > 0 );
+        listToDeal := selectset( globalOTDTable, Global_MappingForecast, item, item.Quantity() > 0 );
     } else {
-        listToDeal := selectset( this, MappingForecast, item, businessTypes.Find( item.BusinessType() ) <> -1 and item.Quantity()>0 );
+        listToDeal := selectset( globalOTDTable, Global_MappingForecast, item, businessTypes.Find( item.BusinessType() ) <> -1 and item.Quantity()>0 );
     }
     queryStartDate := guard( min( this, Period_MP, item, true, item.StartDate() ) - Duration::Days( 30 ), DateTime::MinDateTime() ).Date();
     queryEndDate := guard( max( this, Period_MP, item, true, item.EndDate() ), Date::MaxDate() );
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingInventoryValueAndCostData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingInventoryValueAndCostData.qbl
index 0789263..833d887 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingInventoryValueAndCostData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingInventoryValueAndCostData.qbl
@@ -1,11 +1,13 @@
 Quintiq file version 2.0
 #parent: #root
-Method MappingInventoryValueAndCostData
+Method MappingInventoryValueAndCostData (
+  GlobalOTDTable globalOTDTable
+)
 {
   TextBody:
   [*
     // yypsybs Aug-15-2023 (created)
-    listtodeal := selectset( this,MappingInventoryValueAndCost,item,true );
+    listtodeal := selectset( globalOTDTable,Global_MappingStockingPointCost,item,true );
     totalcount := listtodeal.Size();
     
     info( "InventoryCost has " + totalcount.AsQUILL() + " rows in total" );
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl
index b807827..ca35281 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl
@@ -3,7 +3,8 @@
 Method MappingOperationBOMData (
   Strings businessTypes,
   Boolean isKeyProduct,
-  Boolean createPurchaseSupplyMaterial
+  Boolean createPurchaseSupplyMaterial,
+  GlobalOTDTable globalOTDTable
 )
 {
   TextBody:
@@ -12,9 +13,9 @@
     
     keyProductList := construct( Strings );
     if( isKeyProduct ) {
-        keyProductList := selectuniquevalues( this, MappingProduct, item, item.ProductMajorType()="鎴愬搧" or item.ProductMajorType()="鍗婃垚鍝�", item.ID() );
+        keyProductList := selectuniquevalues( globalOTDTable, Global_MappingProduct_MP, item, item.ProductMajorType()="鎴愬搧" or item.ProductMajorType()="鍗婃垚鍝�", item.ID() );
     }
-    bomList := selectsortedset(  this, MappingBOM, item,
+    bomList := selectsortedset(  globalOTDTable, Global_MappingOperationBOM, item,
                                  ifexpr( isnull( businessTypes ) or businessTypes.Size() = 0, 
                                          true, 
     //                                     businessTypes.Difference( businessTypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0 )
@@ -61,9 +62,9 @@
                 if( not isnull( stockingPoint)){
                   if( isKeyProduct){
                       keyRows := selectset( routingRows,Elements,routingrow,keyProductList.Find( routingrow.ComponentCode())>=0);
-                      this.MappingOperationBOMDataRouting( routing,keyRows);
+                      this.MappingOperationBOMDataRouting( routing,globalOTDTable,keyRows);
                     }else{
-                      this.MappingOperationBOMDataRouting( routing,routingRows);
+                      this.MappingOperationBOMDataRouting( routing,globalOTDTable,routingRows);
                     }
                     
                 }
diff --git "a/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataRouting\043576.qbl" "b/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataRouting\043576.qbl"
index e661d1f..c661b69 100644
--- "a/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataRouting\043576.qbl"
+++ "b/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataRouting\043576.qbl"
@@ -2,7 +2,8 @@
 #parent: #root
 Method MappingOperationBOMDataRouting (
   Routing routing,
-  MappingBOMs routingRows
+  GlobalOTDTable globalOTDTable,
+  Global_MappingOperationBOMs routingRows
 )
 {
   TextBody:
@@ -15,7 +16,7 @@
         rows := selectset( routingRows, Elements, row, row.ProcessSection() = processSection );
         firstRow := rows.Element( 0 );
         // 鎵緊rgCode/productId/processSection鍖归厤涓攕equence鏈�灏忕殑涓�缁勬暟鎹�
-        minSeq := MappingOperation::FindMinSeq( this, firstRow.OrganCode(), firstRow.ProductCode(), processSection );
+        minSeq := Global_MappingOperation::FindMinSeq( globalOTDTable, firstRow.OrganCode(), firstRow.ProductCode(), processSection );
         routingStepId := processSection + "_" + [String]minSeq;
         // 鎵惧搴攔outingStep
         routingStep := RoutingStep::FindByName( routing, routingStepId );
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingOperationData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingOperationData.qbl
index 07e9838..397d6d4 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingOperationData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingOperationData.qbl
@@ -1,21 +1,22 @@
 Quintiq file version 2.0
 #parent: #root
 Method MappingOperationData (
-  Strings businessTypes
+  Strings businessTypes,
+  GlobalOTDTable globalOTDTable
 )
 {
   TextBody:
   [*
     // yypsybs Aug-18-2023 (created)
     // 鑾峰彇鏈夊簭鐨勫緟澶勭悊璁板綍
-    toDealList := construct( MappingOperations );
+    toDealList := construct( Global_MappingOperations ) ;
     if( not isnull( businessTypes ) and businessTypes.Size() > 0 ) {
-        toDealList := selectsortedset( this, MappingOperation, item, 
+        toDealList := selectsortedset( globalOTDTable, Global_MappingOperation, item, 
                                        businessTypes.Find( item.BusinessType() ) >= 0, 
     //                                   businessTypes.Difference( businessTypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0, 
                                        item.SequenceNumber() );
     } else {
-        toDealList := selectsortedset( this, MappingOperation, item, 
+        toDealList := selectsortedset( globalOTDTable, Global_MappingOperation, item, 
                                        true, 
                                        item.SequenceNumber() );
     }
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingProductData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingProductData.qbl
index 9a854ef..ab7398e 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingProductData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingProductData.qbl
@@ -2,6 +2,7 @@
 #parent: #root
 Method MappingProductData (
   Strings businesstypes,
+  GlobalOTDTable globalOTDTable,
   Boolean iskeyproduct
 )
 {
@@ -11,21 +12,21 @@
     // Administrator Aug-16-2023 (created)
     // list to deal
     info( "Get list to deal of product" );
-    listToDeal := construct( structured[MappingProduct] );
+    listToDeal := construct( Global_MappingProduct_MPs );
     
     if( isnull( businesstypes ) or businesstypes.Size() = 0 ) {
         if( iskeyproduct = true ){
-          listToDeal := selectset( this, MappingProduct, item, item.KeyProduct() = true );
+          listToDeal := selectset( globalOTDTable, Global_MappingProduct_MP, item, item.KeyProduct() = true );
           }
         else{
-          listToDeal := selectset( this, MappingProduct, item, true );
+          listToDeal := selectset( globalOTDTable, Global_MappingProduct_MP, item, true );
           }
     } else {
         if( iskeyproduct = true ){
-          listToDeal := selectset( this, MappingProduct, item, item.KeyProduct() = true and businesstypes.Find(  item.BusinessType()) >= 0 );
+          listToDeal := selectset( globalOTDTable, Global_MappingProduct_MP, item, item.KeyProduct() = true and businesstypes.Find(  item.BusinessType()) >= 0 );
          }
         else{
-          listToDeal := selectset( this, MappingProduct, item, businesstypes.Find(  item.BusinessType()) >= 0 );
+          listToDeal := selectset( globalOTDTable, Global_MappingProduct_MP, item, businesstypes.Find(  item.BusinessType()) >= 0 );
         }
     }
     totalcount := listToDeal.Size();
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingProductInLaneData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingProductInLaneData.qbl
index 2d63310..5052dc6 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingProductInLaneData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingProductInLaneData.qbl
@@ -1,13 +1,15 @@
 Quintiq file version 2.0
 #parent: #root
-Method MappingProductInLaneData
+Method MappingProductInLaneData (
+  GlobalOTDTable globalOTDTable
+)
 {
   Description: 'Get Product In Line data'
   TextBody:
   [*
     // Administrator Aug-17-2023 (created)
     // list to deal
-    listtodeal := selectset( this, MappingProductInLane, item ,true );
+    listtodeal := selectset( globalOTDTable, Global_MappingProductInLane, item ,true );
     totalcount := listtodeal.Size();
     info( "ProductInLane has " + totalcount.AsQUILL() + " rows in total" );
     
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingSalesSegmentData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingSalesSegmentData.qbl
index 5f5e1aa..cf459b5 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingSalesSegmentData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingSalesSegmentData.qbl
@@ -1,7 +1,8 @@
 Quintiq file version 2.0
 #parent: #root
 Method MappingSalesSegmentData (
-  Strings businessTypes
+  Strings businessTypes,
+  GlobalOTDTable globalOTDTable
 )
 {
   Description: 'ETL閿�鍞儴闂�'
@@ -9,11 +10,11 @@
   [*
     // yypsybs Aug-15-2023 (created)
     // 寰呭鐞嗘暟鎹�
-    listToDeal := construct( structured[MappingSalesSegment] );
+    listToDeal := construct( Global_MappingSalesSegment_MPs );
     if( isnull( businessTypes ) or businessTypes.Size() = 0 ) {
-        listToDeal := selectset( this, MappingSalesSegment, item, true );
+        listToDeal := selectset( globalOTDTable, Global_MappingSalesSegment_MP, item, true );
     } else {
-        listToDeal := selectset( this, MappingSalesSegment, item, businessTypes.Find( item.BusinessType() ) <> -1 );
+        listToDeal := selectset( globalOTDTable, Global_MappingSalesSegment_MP, item, businessTypes.Find( item.BusinessType() ) <> -1 );
     }
     //nameList := construct( structured[String] );
     //nameList := selectvalues( listToDeal, Elements, item, true, item.Name() );
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingUnitData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingUnitData.qbl
index 7c856ff..eeb6a49 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingUnitData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingUnitData.qbl
@@ -1,7 +1,8 @@
 Quintiq file version 2.0
 #parent: #root
 Method MappingUnitData (
-  Strings businesstypes
+  Strings businesstypes,
+  GlobalOTDTable globalOTDTable
 )
 {
   Description: 'Get unit data from operation mapping'
@@ -9,12 +10,12 @@
   [*
     // Administrator Aug-21-2023 (created)
     // list to deal
-    listtodeal := construct( structured[MappingOperation] );
+    listtodeal := construct( Global_MappingOperations);
     
     if( isnull( businesstypes ) or businesstypes.Size() = 0 ) {
-        listtodeal := selectset( this, MappingOperation, item, true );
+        listtodeal := selectset( globalOTDTable, Global_MappingOperation, item, true );
     } else {
-        listtodeal := selectset( this, MappingOperation, item, 
+        listtodeal := selectset( globalOTDTable, Global_MappingOperation, item, 
     //                             businesstypes.Difference( businesstypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0
                                  businesstypes.Find( item.BusinessType() ) >= 0
                                 );
diff --git "a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync\043618.qbl" "b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync\043618.qbl"
index c3d0398..9d29f63 100644
--- "a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync\043618.qbl"
+++ "b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync\043618.qbl"
@@ -4,7 +4,8 @@
   MacroPlan macroPlan,
   String businessTypeStr,
   Boolean isKeyProduct,
-  Boolean createPurchaseSupplyMaterial
+  Boolean createPurchaseSupplyMaterial,
+  GlobalOTDTable globalOTDTable
 )
 {
   Description: '鍗曟鍚屾'
@@ -15,6 +16,6 @@
     if( businessTypeStr.Length() > 0 ) {
         businessTypes := businessTypeStr.Tokenize( ',' );
     }
-    MacroPlan::DoSync( macroPlan, businessTypes, isKeyProduct, createPurchaseSupplyMaterial );
+    MacroPlan::DoSync( macroPlan, businessTypes, isKeyProduct, createPurchaseSupplyMaterial ,globalOTDTable);
   *]
 }
diff --git a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync.qbl b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync.qbl
index 4609620..49fac75 100644
--- a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync.qbl
+++ b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync.qbl
@@ -3,7 +3,8 @@
 StaticMethod DoSync (
   MacroPlan macroPlan,
   Boolean isKeyProduct,
-  Boolean createPurchaseSupplyMaterial
+  Boolean createPurchaseSupplyMaterial,
+  GlobalOTDTable globalOTDTable
 )
 {
   Description: '鍗曟鍚屾'
@@ -11,6 +12,6 @@
   [*
     // yypsybs Aug-17-2023 (created)
     businessTypes := construct( Strings );
-    MacroPlan::DoSync( macroPlan, businessTypes, isKeyProduct, createPurchaseSupplyMaterial );
+    MacroPlan::DoSync( macroPlan, businessTypes, isKeyProduct, createPurchaseSupplyMaterial ,globalOTDTable);
   *]
 }
diff --git a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
index 1375c53..a501d44 100644
--- a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
+++ b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
@@ -4,7 +4,8 @@
   MacroPlan macroPlan,
   Strings businessTypes,
   Boolean isKeyProduct,
-  Boolean createPurchaseSupplyMaterial
+  Boolean createPurchaseSupplyMaterial,
+  GlobalOTDTable globalOTDTable
 )
 {
   Description: '鍗曟鍚屾'
@@ -30,7 +31,7 @@
     UnitOfMeasure_MP::DoSync( macroPlan );
     
     // 閿�鍞儴闂�-2
-    SalesSegment_MP::DoSync( macroPlan, businessTypes );
+    SalesSegment_MP::DoSync( macroPlan, businessTypes,globalOTDTable );
     
     // 搴撳瓨鐐�-3
     info( "Sales Segment Finished, Start Get StockingPoint From Api" )
@@ -63,29 +64,29 @@
     macroPlan.ApiCurencyRatesData( data );
     
     // 浜у搧鐗╂枡-6
-    info( "Get CurrencyRates From Api Finished, Start Product Data Broker" )
-    macroPlan.Broker_OTD_Product().Execute();
+    //info( "Get CurrencyRates From Api Finished, Start Product Data Broker" )
+    //macroPlan.Broker_OTD_Product().Execute();
     info( "Product Data Broker Finished, Start Product Mapping" );
     //testproduct := construct( Strings );
-    macroPlan.MappingProductData( businessTypes, isKeyProduct );
+    macroPlan.MappingProductData( businessTypes, globalOTDTable,isKeyProduct );
     
     //鍗曚綅杞崲-7
-    BaseConversionFactor::DoSync( macroPlan );
+    BaseConversionFactor::DoSync( macroPlan ,globalOTDTable);
     
     // Unit-9 
     // 涓嶰peration涓�鍚屽鐞�
-    info( "BaseConversionFactor Finished, Start Operation Data Broker" );
-    macroPlan.Broker_OTD_Operation().Execute();
+    //info( "BaseConversionFactor Finished, Start Operation Data Broker" );
+    //macroPlan.Broker_OTD_Operation().Execute();
     info( "Operation Data Broker Finished, Start Unit Mapping" );
-    macroPlan.MappingUnitData( businessTypes );
+    macroPlan.MappingUnitData( businessTypes ,globalOTDTable);
     
     // 宸ヨ壓璺嚎 + BOM-9
     info( "Unit Finished, Start Operation Mapping" );
-    macroPlan.MappingOperationData( businessTypes );  
-    info( "Operation Finished, Start BOM Data Broker" );
-    macroPlan.Broker_OTD_BOM().Execute();
+    macroPlan.MappingOperationData( businessTypes ,globalOTDTable);  
+    //info( "Operation Finished, Start BOM Data Broker" );
+    //macroPlan.Broker_OTD_BOM().Execute();
     info( "BOM Data Broker Finished, Start BOM Mapping" );
-    macroPlan.MappingOperationBOMData( businessTypes, isKeyProduct, createPurchaseSupplyMaterial );
+    macroPlan.MappingOperationBOMData( businessTypes, isKeyProduct, createPurchaseSupplyMaterial,globalOTDTable );
     
     //杞﹂亾淇℃伅-10
     info( "BOM Finished, Start Get Lanes From Api" );
@@ -108,37 +109,35 @@
     macroPlan.ApiLaneLegsData( data );
     
     // 渚涘簲缃戠粶锛堣溅閬擄級-12
-    info( "Get Lanelegs From Api Finished, Start ProductInLane Data Broker" );
-    macroPlan.Broker_OTD_ProductInLane().Execute();
+    //info( "Get Lanelegs From Api Finished, Start ProductInLane Data Broker" );
+    //macroPlan.Broker_OTD_ProductInLane().Execute();
     info( "ProductInLane Data Broker Finished, Start ProductInLane Mapping" );
-    macroPlan.MappingProductInLaneData();
+    macroPlan.MappingProductInLaneData(globalOTDTable);
     
     // 鍦ㄥ簱搴撳瓨鏁版嵁-13
-    info( "ProductInLane Finished, Start ActualPISPIP Data Broker" );
-    macroPlan.Broker_OTD_ActualPISPIP().Execute();
+    //info( "ProductInLane Finished, Start ActualPISPIP Data Broker" );
+    //macroPlan.Broker_OTD_ActualPISPIP().Execute();
     info( "ActualPISPIP Data Broker Finished, Start ActualPISPIP Mapping" );
-    //macroPlan.MappingActualPISPIPData( businessTypes, true );
-    macroPlan.MappingActualPISPIPData( businessTypes, isKeyProduct );
+    macroPlan.MappingActualPISPIPData( businessTypes, globalOTDTable,isKeyProduct );
     
     // 鍦ㄩ�斿簱瀛�-14
-    info( "ActualPISPIP Finished, Start ExternalSupply Data Broker" );
-    macroPlan.Broker_OTD_ExternalSupply().Execute();
-    //macroPlan.MappingExternalSupplyData( businessTypes, true );
+    //info( "ActualPISPIP Finished, Start ExternalSupply Data Broker" );
+    //macroPlan.Broker_OTD_ExternalSupply().Execute();
     info( "ExternalSupply Data Broker Finished, Start ExternalSupply Mapping" );
-    macroPlan.MappingExternalSupplyData( businessTypes, isKeyProduct );
+    macroPlan.MappingExternalSupplyData( businessTypes, isKeyProduct ,globalOTDTable);
     
     // 搴撳瓨鎴愭湰-15
-    InventoryValueAndCost::DoSync( macroPlan );
+    InventoryValueAndCost::DoSync( macroPlan,globalOTDTable );
     
     // todo 鍒堕�犳垚鏈�-16
     info( "InventoryCost Finished, Start OperationCost Mapping" );
     //macroPlan.MappingOperationCostData( businessTypes );
     
     // 璁㈠崟棰勬祴-17
-    Forecast::DoSync( macroPlan, businessTypes );
+    Forecast::DoSync( macroPlan, businessTypes ,globalOTDTable);
     
     // 璁㈠崟闇�姹�-18
-    CustomerOrder::DoSync( macroPlan, businessTypes );
+    CustomerOrder::DoSync( macroPlan, businessTypes,globalOTDTable);
     
     //鍒犻櫎澶氫綑鎶ラ敊鏁版嵁-19
     macroPlan.DeleteSnaityCheck();
diff --git a/_Main/BL/Type_SalesSegment_MP/StaticMethod_DoSync.qbl b/_Main/BL/Type_SalesSegment_MP/StaticMethod_DoSync.qbl
index ef1ffae..cd9e1c1 100644
--- a/_Main/BL/Type_SalesSegment_MP/StaticMethod_DoSync.qbl
+++ b/_Main/BL/Type_SalesSegment_MP/StaticMethod_DoSync.qbl
@@ -2,15 +2,16 @@
 #parent: #root
 StaticMethod DoSync (
   MacroPlan macroPlan,
-  Strings businessTypes
+  Strings businessTypes,
+  GlobalOTDTable globalOTDTable
 )
 {
   TextBody:
   [*
     // yypsybs Aug-17-2023 (created)
-    info( "UnitOfMeasure_MP Finished, Start Sales Segment Data Broker" )
-    macroPlan.Broker_OTD_SalesSegment().Execute();
+    //info( "UnitOfMeasure_MP Finished, Start Sales Segment Data Broker" )
+    //macroPlan.Broker_OTD_SalesSegment().Execute();
     info( "Sales Segment Data Broker Finished, Start Sales Segment Mapping" )
-    macroPlan.MappingSalesSegmentData( businessTypes );
+    macroPlan.MappingSalesSegmentData( businessTypes,globalOTDTable );
   *]
 }
diff --git a/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpoint.qbl b/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpoint.qbl
index aff8971..857199b 100644
--- a/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpoint.qbl
+++ b/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpoint.qbl
@@ -33,7 +33,7 @@
       // Update
       result.Update( unitid, id, name, unitofmeasurename, currencyname, isplannedinfinite, datestart, dateend, groupname, description, isfromdb );
     };
-    
+    result.IsPlannedInfinite(true);
     return result;
   *]
 }
diff --git a/_Main/BL/Type_UnitOfMeasure_MP/StaticMethod_DoSync.qbl b/_Main/BL/Type_UnitOfMeasure_MP/StaticMethod_DoSync.qbl
index f5ea0a0..9894a2a 100644
--- a/_Main/BL/Type_UnitOfMeasure_MP/StaticMethod_DoSync.qbl
+++ b/_Main/BL/Type_UnitOfMeasure_MP/StaticMethod_DoSync.qbl
@@ -8,8 +8,8 @@
   TextBody:
   [*
     // yypsybs Aug-17-2023 (created)
-    info( "Inital Finished, Start UnitOfMeasure_MP Data Broker" )
-    macroPlan.Broker_OTD_UnitOfMeasure().Execute();
+    //info( "Inital Finished, Start UnitOfMeasure_MP Data Broker" )
+    //macroPlan.Broker_OTD_UnitOfMeasure().Execute();
     info( "UnitOfMeasure_MP Data Broker Finished, Start UnitOfMeasure_MP Mapping" )
     macroPlan.MappingUnitOfMeasureData();
   *]

--
Gitblit v1.9.3