From 618b16e7933c49d977a4df19f756250b80d43c0d Mon Sep 17 00:00:00 2001
From: yanyuan <yuan.yan@capgemini.com>
Date: 星期二, 31 十月 2023 18:09:58 +0800
Subject: [PATCH] Fix some bug

---
 _Main/BL/Type_Global_MappingLaneLeg/StaticMethod_SynchronizeMacroPlanData.qbl                              |   32 --
 _Main/BL/Type_Global_MappingUnitOfMeasure_MP/StaticMethod_SynchronizeMacroPlanData.qbl                     |   10 
 _Main/BL/Type_LaneLeg/StaticMethod_CreateLaneLegFromJson.qbl                                               |    3 
 _Main/BL/Type_MacroPlan/Method_DoASyncMappingCustomerOrderData.qbl                                         |    2 
 _Main/BL/Type_Global_MappingCurrency_MP/StaticMethod_SynchronizeMacroPlanData.qbl                          |   17 -
 _Main/UI/MacroPlannerWebApp/Component_FormInterfaceTest/_ROOT_Component_FormInterfaceTest.def              |   10 
 _Main/BL/Type_MacroPlan/StaticMethod_DoASync#253.qbl                                                       |   57 +---
 _Main/BL/Type_Global_MappingOperationBOM/StaticMethod_SynchronizeMacroPlanData.qbl                         |    2 
 _Main/BL/Type_MacroPlan/Method_ApiLaneLegsData.qbl                                                         |    3 
 _Main/BL/Type_Global_MappingProduct_MP/StaticMethod_SynchronizeMacroPlanData.qbl                           |    2 
 _Main/BL/Type_LaneLeg/StaticMethod_FindByIdAndLane.qbl                                                     |   17 +
 _Main/BL/Type_Currency_MP/StaticMethod_CreateFromMapping.qbl                                               |   27 ++
 _Main/BL/Type_Global_MappingStockingPoint_MP/StaticMethod_SynchronizeMacroPlanData.qbl                     |   17 -
 _Main/BL/Type_Global_MappingActualProductInStockingPointInPeriod/StaticMethod_SynchronizeMacroPlanData.qbl |    2 
 _Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateCurrencyRateFromJson.qbl                                  |    3 
 _Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpoint.qbl                                        |    2 
 _Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateCurrencyRate.qbl                                          |    5 
 _Main/BL/Type_Global_MappingStockingPointCost/StaticMethod_SynchronizeMacroPlanData.qbl                    |    3 
 _Main/BL/Type_Global_MappingLane/StaticMethod_SynchronizeMacroPlanData.qbl                                 |   49 ----
 _Main/BL/Type_MacroPlan/Method_ApiCurencyRatesData.qbl                                                     |    3 
 _Main/BL/Type_StockingPoint_MP/StaticMethod_CreateFromMapping.qbl                                          |   28 ++
 _Main/BL/Type_Global_MappingUnitCost/StaticMethod_SynchronizeMacroPlanData.qbl                             |    2 
 _Main/BL/Type_Lane/StaticMethod_CreateLaneFromJson.qbl                                                     |    2 
 _Main/BL/Type_Global_MappingProductInLane/StaticMethod_SynchronizeMacroPlanData.qbl                        |    3 
 _Main/BL/Type_Lane/StaticMethod_FindByIdAndUnit.qbl                                                        |   16 +
 _Main/BL/Type_MacroPlan/Method_DoASyncMappingExternalSupplyData.qbl                                        |    2 
 _Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl                                                           |    4 
 _Main/BL/Type_Global_MappingForecast/StaticMethod_SynchronizeMacroPlanData.qbl                             |    2 
 _Main/BL/Type_Currency_MP/StaticMethod_CreateCurrency.qbl                                                  |    2 
 _Main/BL/Type_LaneLeg/StaticMethod_CreateFromMapping.qbl                                                   |   42 +++
 _Main/BL/Type_Lane/StaticMethod_FindById.qbl                                                               |   15 +
 _Main/BL/Type_Lane/StaticMethod_CreateLane.qbl                                                             |    3 
 _Main/BL/Type_CurrencyRate_MP/StaticMethod_FindByIdAndStart.qbl                                            |   17 +
 _Main/BL/Type_LaneLeg/StaticMethod_CreateLaneleg.qbl                                                       |    7 
 _Main/BL/Type_Global_MappingCurrencyRate_MP/StaticMethod_SynchronizeMacroPlanData.qbl                      |   17 -
 _Main/BL/Type_GlobalDTOTable/Method_SynchronizeDataToMacroPlan#127.qbl                                     |  146 ++++++------
 _Main/BL/Type_Global_MappingCustomOrder/StaticMethod_SynchronizeMacroPlanData.qbl                          |    4 
 _Main/BL/Type_Global_MappingInventorySupply/StaticMethod_SynchronizeMacroPlanData.qbl                      |    2 
 _Main/BL/Type_Lane/StaticMethod_CreasteFromMapping.qbl                                                     |   59 ++++
 _Main/BL/Type_Global_MappingOperation/StaticMethod_SynchronizeMacroPlanData.qbl                            |    2 
 _Main/BL/Type_Global_MappingConversionFactor/StaticMethod_SynchronizeMacroPlanData.qbl                     |    2 
 _Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateFromMapping.qbl                                           |   27 ++
 _Main/BL/Type_Global_MappingSalesSegment_MP/StaticMethod_SynchronizeMacroPlanData.qbl                      |    2 
 43 files changed, 395 insertions(+), 277 deletions(-)

diff --git a/_Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateCurrencyRate.qbl b/_Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateCurrencyRate.qbl
index b3244e0..272b16c 100644
--- a/_Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateCurrencyRate.qbl
+++ b/_Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateCurrencyRate.qbl
@@ -1,6 +1,7 @@
 Quintiq file version 2.0
 #parent: #root
 StaticMethod CreateCurrencyRate (
+  MacroPlan mp,
   String currencyid,
   Date start,
   Real rate
@@ -11,10 +12,10 @@
   [*
     // Administrator Jul-19-2023 (created)
     isfromdb := true;
-    currency := Currency_MP::FindCurrencyTypeIndex( currencyid );
+    currency := Currency_MP::FindById( mp, currencyid );
     
     //create new currency
-    result := CurrencyRate_MP::FindCurrencyRateTypeIndex( currencyid, start );
+    result := CurrencyRate_MP::FindByIdAndStart( currency, currencyid, start );
     
     if( isnull( result ) )
     {
diff --git a/_Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateCurrencyRateFromJson.qbl b/_Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateCurrencyRateFromJson.qbl
index 67cd2c8..97a01d2 100644
--- a/_Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateCurrencyRateFromJson.qbl
+++ b/_Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateCurrencyRateFromJson.qbl
@@ -1,6 +1,7 @@
 Quintiq file version 2.0
 #parent: #root
 StaticMethod CreateCurrencyRateFromJson (
+  MacroPlan mp,
   JSON datarow
 ) as CurrencyRate_MP
 {
@@ -16,7 +17,7 @@
     day := [Number]startstring.SubString( 8, 2 );
     
     start := Date::Construct( years, month, day );
-    result := CurrencyRate_MP::CreateCurrencyRate( currencyid, start, rate );
+    result := CurrencyRate_MP::CreateCurrencyRate( mp, currencyid, start, rate );
     
     return result;
   *]
diff --git a/_Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateFromMapping.qbl b/_Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateFromMapping.qbl
new file mode 100644
index 0000000..82dc0fa
--- /dev/null
+++ b/_Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateFromMapping.qbl
@@ -0,0 +1,27 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CreateFromMapping (
+  const GlobalOTDTable globalOTDTable,
+  MacroPlan macroPlan
+)
+{
+  TextBody:
+  [*
+    // Administrator Oct-31-2023 (created)
+    updates := construct( CurrencyRate_MPs );
+    traverse( globalOTDTable, Global_MappingCurrencyRate_MP, gcr, true )
+    {
+      a := CurrencyRate_MP::CreateCurrencyRate( macroPlan, gcr.CurrencyID(), gcr.Start(), gcr.Rate() );
+      updates.Add( a );
+      }
+    origindataset := selectset( macroPlan, Currency_MP.CurrencyRate_MP, cr, true );
+    obsoletes := origindataset.Difference( updates );
+    // delete obsoleted
+    difflength := obsoletes.Size();
+    for( j:=0; j<difflength; j++ )
+    {
+      obsolete := obsoletes.Element( j );
+      obsolete.Delete();
+      }
+  *]
+}
diff --git a/_Main/BL/Type_CurrencyRate_MP/StaticMethod_FindByIdAndStart.qbl b/_Main/BL/Type_CurrencyRate_MP/StaticMethod_FindByIdAndStart.qbl
new file mode 100644
index 0000000..2c39de8
--- /dev/null
+++ b/_Main/BL/Type_CurrencyRate_MP/StaticMethod_FindByIdAndStart.qbl
@@ -0,0 +1,17 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod FindByIdAndStart (
+  Currency_MP owner,
+  String id,
+  Date start
+) as CurrencyRate_MP
+{
+  TextBody:
+  [*
+    // yypsybs Aug-14-2023 (created)
+    
+    result := select(  owner, CurrencyRate_MP, item, true, item.CurrencyID() = id and item.Start() = start );
+    
+    return result;
+  *]
+}
diff --git a/_Main/BL/Type_Currency_MP/StaticMethod_CreateCurrency.qbl b/_Main/BL/Type_Currency_MP/StaticMethod_CreateCurrency.qbl
index ade128e..155abb3 100644
--- a/_Main/BL/Type_Currency_MP/StaticMethod_CreateCurrency.qbl
+++ b/_Main/BL/Type_Currency_MP/StaticMethod_CreateCurrency.qbl
@@ -16,7 +16,7 @@
     isfromdb := true;
     
     //create new currency
-    result := Currency_MP::FindCurrencyTypeIndex( id );
+    result := Currency_MP::FindById( mp, id );
     
     if( isnull( result ) )
     {
diff --git a/_Main/BL/Type_Currency_MP/StaticMethod_CreateFromMapping.qbl b/_Main/BL/Type_Currency_MP/StaticMethod_CreateFromMapping.qbl
new file mode 100644
index 0000000..dbda48a
--- /dev/null
+++ b/_Main/BL/Type_Currency_MP/StaticMethod_CreateFromMapping.qbl
@@ -0,0 +1,27 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CreateFromMapping (
+  const GlobalOTDTable globalOTDTable,
+  MacroPlan macroPlan
+)
+{
+  TextBody:
+  [*
+    // Administrator Oct-31-2023 (created)
+    updates := construct( Currency_MPs );
+    traverse( globalOTDTable, Global_MappingCurrency_MP, gc, true )
+    {
+      a := Currency_MP::CreateCurrency( macroPlan, gc.ID(), gc.Name(), " ", gc.IsBase() );
+      updates.Add( a );
+      }
+    origindataset := selectset( macroPlan, Currency_MP, c, true );
+    obsoletes := origindataset.Difference( updates );
+    // delete obsoleted
+    difflength := obsoletes.Size();
+    for( j:=0; j<difflength; j++ )
+    {
+      obsolete := obsoletes.Element( j );
+      obsolete.Delete();
+      }
+  *]
+}
diff --git "a/_Main/BL/Type_GlobalDTOTable/Method_SynchronizeDataToMacroPlan\043127.qbl" "b/_Main/BL/Type_GlobalDTOTable/Method_SynchronizeDataToMacroPlan\043127.qbl"
index 66ff081..007623c 100644
--- "a/_Main/BL/Type_GlobalDTOTable/Method_SynchronizeDataToMacroPlan\043127.qbl"
+++ "b/_Main/BL/Type_GlobalDTOTable/Method_SynchronizeDataToMacroPlan\043127.qbl"
@@ -48,77 +48,79 @@
       }
     
     macroPlan.InitialUnitAndStockingPoint();
-    
-    if ( isUnitOfMeasure_MP ) {
-      Global_MappingUnitOfMeasure_MP::SynchronizeMacroPlanData( this, macroPlan );
-    }
-    
-    if ( isCustomOrder ) {
-      Global_MappingCustomOrder::SynchronizeMacroPlanData( this, macroPlan, executionUser );
-    }
-    
-    if ( isForeacst ) {
-      Global_MappingForecast::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist );
-    }
-    
-    if ( isSalesSegment_MP ) {
-      Global_MappingSalesSegment_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes );
-    }
-    
-    if ( isProduct_MP ) {
-      Global_MappingProduct_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, macroPlan.IsKeyProduct() );
-    }
-    
-    if ( isConversionFactor ) {
-      Global_MappingConversionFactor::SynchronizeMacroPlanData( this, macroPlan, executionUser );
-    }
-    
-    if ( isOperation ) {
-      Global_MappingOperation::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist );
-    }
-    
-    if ( isOperationBOM ) {
-      Global_MappingOperationBOM::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist, macroPlan.IsKeyProduct(), macroPlan.CreatePurchaseSupplyMaterial() );
-    }
-    
-    if ( isProductInLane ) {
-      Global_MappingProductInLane::SynchronizeMacroPlanData( this, macroPlan, executionUser );
-    }
-    
-    if ( isAIPISPIP ) {
-      Global_MappingActualProductInStockingPointInPeriod::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist, macroPlan.IsKeyProduct() );
-    }
-    
-    if ( isInventorySupply ) {
-      Global_MappingInventorySupply::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist, macroPlan.IsKeyProduct() );
-    }
-    
-    if ( isStockingPointCost ) {
-      Global_MappingStockingPointCost::SynchronizeMacroPlanData( this, macroPlan, executionUser );
-    }
-    
-    if ( isOperationCost ) {
-      Global_MappingOperationCost::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist );
-    }
-    
-    if ( isStockingPoint_MP ) {
-      Global_MappingStockingPoint_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser );
-    }
-    
-    if ( isCurrency_MP ) {
-      Global_MappingCurrency_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser );
-    }
-    
-    if ( isCurrencyRate_MP ) {
-      Global_MappingCurrencyRate_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser );
-    }
-    
-    if ( isLane ) {
-      Global_MappingLane::SynchronizeMacroPlanData( this, macroPlan, executionUser );
-    }
-    
-    if ( isLaneLeg ) {
-      Global_MappingLaneLeg::SynchronizeMacroPlanData( this, macroPlan, executionUser );
-    }
+    info( macroPlan.BusinessType() );
+    info( organcodelist.Element( 0 ) );
+    //
+    //if ( isUnitOfMeasure_MP ) {
+    //  Global_MappingUnitOfMeasure_MP::SynchronizeMacroPlanData( this, macroPlan );
+    //}
+    //
+    //if ( isCustomOrder ) {
+    //  Global_MappingCustomOrder::SynchronizeMacroPlanData( this, macroPlan, businessTypes, organcodelist, executionUser );
+    //}
+    //
+    //if ( isForeacst ) {
+    //  Global_MappingForecast::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist );
+    //}
+    //
+    //if ( isSalesSegment_MP ) {
+    //  Global_MappingSalesSegment_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes );
+    //}
+    //
+    //if ( isProduct_MP ) {
+    //  Global_MappingProduct_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, macroPlan.IsKeyProduct() );
+    //}
+    //
+    //if ( isConversionFactor ) {
+    //  Global_MappingConversionFactor::SynchronizeMacroPlanData( this, macroPlan, executionUser );
+    //}
+    //
+    //if ( isOperation ) {
+    //  Global_MappingOperation::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist );
+    //}
+    //
+    //if ( isOperationBOM ) {
+    //  Global_MappingOperationBOM::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist, macroPlan.IsKeyProduct(), macroPlan.CreatePurchaseSupplyMaterial() );
+    //}
+    //
+    //if ( isProductInLane ) {
+    //  Global_MappingProductInLane::SynchronizeMacroPlanData( this, macroPlan, businessTypes, executionUser );
+    //}
+    //
+    //if ( isAIPISPIP ) {
+    //  Global_MappingActualProductInStockingPointInPeriod::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist, macroPlan.IsKeyProduct() );
+    //}
+    //
+    //if ( isInventorySupply ) {
+    //  Global_MappingInventorySupply::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist, macroPlan.IsKeyProduct() );
+    //}
+    //
+    //if ( isStockingPointCost ) {
+    //  Global_MappingStockingPointCost::SynchronizeMacroPlanData( this, macroPlan, businessTypes, executionUser );
+    //}
+    //
+    //if ( isOperationCost ) {
+    //  Global_MappingOperationCost::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist );
+    //}
+    //
+    //if ( isStockingPoint_MP ) {
+    //  Global_MappingStockingPoint_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser );
+    //}
+    //
+    //if ( isCurrency_MP ) {
+    //  Global_MappingCurrency_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser );
+    //}
+    //
+    //if ( isCurrencyRate_MP ) {
+    //  Global_MappingCurrencyRate_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser );
+    //}
+    //
+    //if ( isLane ) {
+    //  Global_MappingLane::SynchronizeMacroPlanData( this, macroPlan, executionUser );
+    //}
+    //
+    //if ( isLaneLeg ) {
+    //  Global_MappingLaneLeg::SynchronizeMacroPlanData( this, macroPlan, executionUser );
+    //}
   *]
 }
diff --git a/_Main/BL/Type_Global_MappingActualProductInStockingPointInPeriod/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingActualProductInStockingPointInPeriod/StaticMethod_SynchronizeMacroPlanData.qbl
index 984a0eb..12c950a 100644
--- a/_Main/BL/Type_Global_MappingActualProductInStockingPointInPeriod/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingActualProductInStockingPointInPeriod/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -19,7 +19,7 @@
                                             
       
     try {
-      macroPlan.MappingActualPISPIPData( businessTypes, globalOTDTable, isKeyProduct, organcodelist );
+      macroPlan.DoASyncMappingActualPISPIPData( businessTypes, globalOTDTable, isKeyProduct, organcodelist );
       
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
diff --git a/_Main/BL/Type_Global_MappingConversionFactor/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingConversionFactor/StaticMethod_SynchronizeMacroPlanData.qbl
index 9467117..7147599 100644
--- a/_Main/BL/Type_Global_MappingConversionFactor/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingConversionFactor/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -16,7 +16,7 @@
                                             
       
     try {
-      macroPlan.MappingBaseConversionFactorData(globalOTDTable);
+      macroPlan.DoASyncMappingBaseConversionFactorData(globalOTDTable);
       
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
diff --git a/_Main/BL/Type_Global_MappingCurrencyRate_MP/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingCurrencyRate_MP/StaticMethod_SynchronizeMacroPlanData.qbl
index 5913ebe..c42db35 100644
--- a/_Main/BL/Type_Global_MappingCurrencyRate_MP/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingCurrencyRate_MP/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -16,22 +16,7 @@
                                             
       
     try {
-      updates := construct( CurrencyRate_MPs );
-      traverse( globalOTDTable, Global_MappingCurrencyRate_MP, gcr, true )
-      {
-        a := CurrencyRate_MP::CreateCurrencyRate( gcr.CurrencyID(), gcr.Start(), gcr.Rate() );
-        updates.Add( a );
-        }
-      origindataset := selectset( macroPlan, Currency_MP.CurrencyRate_MP, cr, true );
-      obsoletes := origindataset.Difference( updates );
-      // delete obsoleted
-      difflength := obsoletes.Size();
-      for( j:=0; j<difflength; j++ )
-      {
-        obsolete := obsoletes.Element( j );
-        obsolete.Delete();
-        }
-      
+      CurrencyRate_MP::CreateFromMapping( globalOTDTable, macroPlan );
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
     } onerror {
diff --git a/_Main/BL/Type_Global_MappingCurrency_MP/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingCurrency_MP/StaticMethod_SynchronizeMacroPlanData.qbl
index 38ac6bb..94f4a07 100644
--- a/_Main/BL/Type_Global_MappingCurrency_MP/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingCurrency_MP/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -16,22 +16,7 @@
                                             
       
     try {
-      updates := construct( Currency_MPs );
-      traverse( globalOTDTable, Global_MappingCurrency_MP, gc, true )
-      {
-        a := Currency_MP::CreateCurrency( macroPlan, gc.ID(), gc.Name(), " ", gc.IsBase() );
-        updates.Add( a );
-        }
-      origindataset := selectset( macroPlan, Currency_MP, c, true );
-      obsoletes := origindataset.Difference( updates );
-      // delete obsoleted
-      difflength := obsoletes.Size();
-      for( j:=0; j<difflength; j++ )
-      {
-        obsolete := obsoletes.Element( j );
-        obsolete.Delete();
-        }
-      
+      Currency_MP::CreateFromMapping( globalOTDTable, macroPlan );
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
     } onerror {
diff --git a/_Main/BL/Type_Global_MappingCustomOrder/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingCustomOrder/StaticMethod_SynchronizeMacroPlanData.qbl
index 9a69cf5..b4df4f3 100644
--- a/_Main/BL/Type_Global_MappingCustomOrder/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingCustomOrder/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -3,6 +3,8 @@
 StaticMethod SynchronizeMacroPlanData (
   GlobalOTDTable globalOTDTable,
   MacroPlan macroPlan,
+  Strings businessTypes,
+  Strings organcodelist,
   String executionUser
 )
 {
@@ -16,7 +18,7 @@
                                             
       
     try {
-      Global_MappingCustomOrder::CreateCustomOrder( globalOTDTable, macroPlan );
+      macroPlan.DoASyncMappingCustomerOrderData( businessTypes, globalOTDTable, organcodelist );
       
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
diff --git a/_Main/BL/Type_Global_MappingForecast/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingForecast/StaticMethod_SynchronizeMacroPlanData.qbl
index ef72e85..3b437f4 100644
--- a/_Main/BL/Type_Global_MappingForecast/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingForecast/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -18,7 +18,7 @@
                                             
       
     try {
-      macroPlan.MappingForecastData( businessTypes, globalOTDTable, organcodelist );
+      macroPlan.DoASyncMappingForecastData( businessTypes, globalOTDTable, organcodelist );
       
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
diff --git a/_Main/BL/Type_Global_MappingInventorySupply/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingInventorySupply/StaticMethod_SynchronizeMacroPlanData.qbl
index 06d00c5..9a8c68c 100644
--- a/_Main/BL/Type_Global_MappingInventorySupply/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingInventorySupply/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -19,7 +19,7 @@
                                             
       
     try {
-      macroPlan.MappingExternalSupplyData( businessTypes, isKeyProduct ,globalOTDTable, organcodelist );
+      macroPlan.DoASyncMappingExternalSupplyData( businessTypes, isKeyProduct, globalOTDTable, organcodelist );
       
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
diff --git a/_Main/BL/Type_Global_MappingLane/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingLane/StaticMethod_SynchronizeMacroPlanData.qbl
index 60224b2..2f0d00e 100644
--- a/_Main/BL/Type_Global_MappingLane/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingLane/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -16,54 +16,7 @@
                                             
       
     try {
-      updates := construct( Lanes );
-      traverse( globalOTDTable, Global_MappingLane, gl, true )
-      {
-        id := gl.ID();
-        unitid := gl.UnitID();
-        name := gl.Name();
-        userleadtime := gl.UserLeadTime();
-        processingtime := Duration::Zero();
-        
-        unitofmeasurename := "PCS";
-        currencyid := "CNY";
-        startdate := Date::Date( 1900, 1, 1 );
-        enddate := Date::Date( 9999, 12, 31 );
-        capacitytype := "Transport quantity";
-        if( userleadtime.Length() = 0 )
-        {
-          processingtime := Duration::Zero(); 
-          }
-        else
-        {
-          processingtime := Duration::Hours( [Number]userleadtime );
-          };
-        
-        unit := Unit::FindUnitTypeIndex( unitid );
-        if( isnull( unit)){
-          unit :=macroPlan.Unit( relnew, 
-                                 ID := unitid, 
-                                 Name := unitid, 
-                                 UnitOfMeasureName := unitofmeasurename, 
-                                 CurrencyID := currencyid, 
-                                 StartDate := startdate, 
-                                 EndDate := enddate, 
-                                 CapacityType := capacitytype );
-        }
-        
-        a := Lane::CreateLane( unit, id, name, processingtime);
-        updates.Add( a );
-        }
-      origindataset := selectset( macroPlan, Unit.Lane, l, true );
-      obsoletes := origindataset.Difference( updates );
-      // delete obsoleted
-      difflength := obsoletes.Size();
-      for( j:=0; j<difflength; j++ )
-      {
-        obsolete := obsoletes.Element( j );
-        obsolete.Delete();
-        }
-      
+      Lane::CreasteFromMapping( globalOTDTable, macroPlan );
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
     } onerror {
diff --git a/_Main/BL/Type_Global_MappingLaneLeg/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingLaneLeg/StaticMethod_SynchronizeMacroPlanData.qbl
index d1743ec..ba3f97e 100644
--- a/_Main/BL/Type_Global_MappingLaneLeg/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingLaneLeg/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -16,37 +16,7 @@
                                             
       
     try {
-      updates := construct( LaneLegs );
-      traverse( globalOTDTable, Global_MappingLaneLeg, gll, true )
-      {
-        processingtime := Duration::Zero();
-        hasprocessingtime := true;
-        userleadtime := gll.UserLeadTime();
-        if( userleadtime.Length() = 0 )
-        {
-          hasprocessingtime := false;
-          processingtime := Duration::Zero(); 
-          }
-        else
-        {
-          hasprocessingtime := true;
-          processingtime := Duration::Hours( [Number]userleadtime );
-          };
-        
-        lane := Lane::FindLaneTypeIndex( gll.LaneID() );
-        a := LaneLeg::CreateLaneleg(lane, gll.LaneID(), gll.OriginStockingPointID(), gll.DestinationStockingPointID(), gll.Name(), hasprocessingtime, processingtime);
-        updates.Add( a );
-        }
-      origindataset := selectset( macroPlan, Unit.Lane.LaneLeg, ll, true );
-      obsoletes := origindataset.Difference( updates );
-      // delete obsoleted
-      difflength := obsoletes.Size();
-      for( j:=0; j<difflength; j++ )
-      {
-        obsolete := obsoletes.Element( j );
-        obsolete.Delete();
-        }
-      
+      LaneLeg::CreateFromMapping( globalOTDTable, macroPlan );
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
     } onerror {
diff --git a/_Main/BL/Type_Global_MappingOperation/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingOperation/StaticMethod_SynchronizeMacroPlanData.qbl
index 6a663dd..1a44c1c 100644
--- a/_Main/BL/Type_Global_MappingOperation/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingOperation/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -18,7 +18,7 @@
                                             
       
     try {
-      macroPlan.MappingOperationData( businessTypes ,globalOTDTable, organcodelist );  
+      macroPlan.DoASyncMappingOperationData( businessTypes, globalOTDTable, organcodelist ); 
       
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
diff --git a/_Main/BL/Type_Global_MappingOperationBOM/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingOperationBOM/StaticMethod_SynchronizeMacroPlanData.qbl
index 3198fd5..41ade06 100644
--- a/_Main/BL/Type_Global_MappingOperationBOM/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingOperationBOM/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -20,7 +20,7 @@
                                             
       
     try {
-      macroPlan.MappingOperationBOMData( businessTypes, isKeyProduct, createPurchaseSupplyMaterial, globalOTDTable, organcodelist );
+      macroPlan.DoASyncMappingOperationBOMData( businessTypes, isKeyProduct, createPurchaseSupplyMaterial, globalOTDTable, organcodelist );
       
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
diff --git a/_Main/BL/Type_Global_MappingProductInLane/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingProductInLane/StaticMethod_SynchronizeMacroPlanData.qbl
index 9e722b5..1d10ded 100644
--- a/_Main/BL/Type_Global_MappingProductInLane/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingProductInLane/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -3,6 +3,7 @@
 StaticMethod SynchronizeMacroPlanData (
   GlobalOTDTable globalOTDTable,
   MacroPlan macroPlan,
+  Strings businessTypes,
   String executionUser
 )
 {
@@ -16,7 +17,7 @@
                                             
       
     try {
-      macroPlan.MappingProductInLaneData(globalOTDTable);
+      macroPlan.DoASyncMappingProductInLaneData( globalOTDTable, businessTypes );
       
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
diff --git a/_Main/BL/Type_Global_MappingProduct_MP/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingProduct_MP/StaticMethod_SynchronizeMacroPlanData.qbl
index 8c10d2f..5978c66 100644
--- a/_Main/BL/Type_Global_MappingProduct_MP/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingProduct_MP/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -18,7 +18,7 @@
                                             
       
     try {
-      macroPlan.MappingProductData( businessTypes, globalOTDTable,isKeyProduct );
+      macroPlan.DoASyncMappingProductData( businessTypes, globalOTDTable, isKeyProduct );
       
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
diff --git a/_Main/BL/Type_Global_MappingSalesSegment_MP/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingSalesSegment_MP/StaticMethod_SynchronizeMacroPlanData.qbl
index fc881d2..f8eab75 100644
--- a/_Main/BL/Type_Global_MappingSalesSegment_MP/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingSalesSegment_MP/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -17,7 +17,7 @@
                                             
       
     try {
-      macroPlan.MappingSalesSegmentData( businessTypes, globalOTDTable );
+      macroPlan.DoASyncMappingSalesSegmentData( businessTypes, globalOTDTable );
       
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
diff --git a/_Main/BL/Type_Global_MappingStockingPointCost/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingStockingPointCost/StaticMethod_SynchronizeMacroPlanData.qbl
index df0cc31..e0a583a 100644
--- a/_Main/BL/Type_Global_MappingStockingPointCost/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingStockingPointCost/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -3,6 +3,7 @@
 StaticMethod SynchronizeMacroPlanData (
   GlobalOTDTable globalOTDTable,
   MacroPlan macroPlan,
+  Strings businessTypes,
   String executionUser
 )
 {
@@ -16,7 +17,7 @@
                                             
       
     try {
-      macroPlan.MappingInventoryValueAndCostData(globalOTDTable);
+      macroPlan.DoASyncMappingInventoryValueAndCostData( globalOTDTable, businessTypes );
       
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
diff --git a/_Main/BL/Type_Global_MappingStockingPoint_MP/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingStockingPoint_MP/StaticMethod_SynchronizeMacroPlanData.qbl
index 7db4814..3ee5b0b 100644
--- a/_Main/BL/Type_Global_MappingStockingPoint_MP/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingStockingPoint_MP/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -16,22 +16,7 @@
                                             
       
     try {
-      updates := construct( StockingPoint_MPs );
-      traverse( globalOTDTable, Global_MappingStockingPoint_MP, sp, true )
-      {
-        a := StockingPoint_MP::CreateStockingpoint( macroPlan, sp.ID(), sp.UnitID(), sp.Name() );
-        updates.Add( a );
-        }
-      origindataset := selectset( macroPlan, StockingPoint_MP, sp, true );
-      obsoletes := origindataset.Difference( updates );
-      // delete obsoleted
-      difflength := obsoletes.Size();
-      for( j:=0; j<difflength; j++ )
-      {
-        obsolete := obsoletes.Element( j );
-        obsolete.Delete();
-        }
-      
+      StockingPoint_MP::CreateFromMapping( globalOTDTable, macroPlan );
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
     } onerror {
diff --git a/_Main/BL/Type_Global_MappingUnitCost/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingUnitCost/StaticMethod_SynchronizeMacroPlanData.qbl
index 8f08b84..ff5d6bb 100644
--- a/_Main/BL/Type_Global_MappingUnitCost/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingUnitCost/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -18,7 +18,7 @@
                                             
       
     try {
-      macroPlan.MappingOperationCostData( globalOTDTable, businessTypes, organcodelist );
+      macroPlan.DoASyncMappingOperationCostData( globalOTDTable, businessTypes, organcodelist );
       
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
diff --git a/_Main/BL/Type_Global_MappingUnitOfMeasure_MP/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingUnitOfMeasure_MP/StaticMethod_SynchronizeMacroPlanData.qbl
index d31811e..5c7cf69 100644
--- a/_Main/BL/Type_Global_MappingUnitOfMeasure_MP/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingUnitOfMeasure_MP/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -13,15 +13,7 @@
                                                                       );
                                             
     try {
-      traverse ( globalOTDTable, Global_MappingUnitOfMeasure_MP, gmuommp ) {
-        unitOfMeasure_MP := select( macroPlan, UnitOfMeasure_MP, tempUOMMP, tempUOMMP.Name() = gmuommp.Name() );
-        if ( isnull( unitOfMeasure_MP ) ) {  
-          unitOfMeasure_MP := UnitOfMeasure_MP::Create( macroPlan, gmuommp.Name(), false, false );
-        }
-        if ( gmuommp.IsDefault() ) {
-          unitOfMeasure_MP.SetAsDefault();
-        }
-      }
+      macroPlan.DoASyncMappingUnitOfMeasureData(globalOTDTable);
     } onerror {
       global_BrokerExecuteLog.IsSuccess( false );
       global_BrokerExecuteLog.ErrorNo( e.ErrorNr() );
diff --git a/_Main/BL/Type_Lane/StaticMethod_CreasteFromMapping.qbl b/_Main/BL/Type_Lane/StaticMethod_CreasteFromMapping.qbl
new file mode 100644
index 0000000..ab95433
--- /dev/null
+++ b/_Main/BL/Type_Lane/StaticMethod_CreasteFromMapping.qbl
@@ -0,0 +1,59 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CreasteFromMapping (
+  const GlobalOTDTable globalOTDTable,
+  MacroPlan macroPlan
+)
+{
+  TextBody:
+  [*
+    // Administrator Oct-31-2023 (created)
+    updates := construct( Lanes );
+    traverse( globalOTDTable, Global_MappingLane, gl, true )
+    {
+      id := gl.ID();
+      unitid := gl.UnitID();
+      name := gl.Name();
+      userleadtime := gl.UserLeadTime();
+      processingtime := Duration::Zero();
+      
+      unitofmeasurename := "PCS";
+      currencyid := "CNY";
+      startdate := Date::Date( 1900, 1, 1 );
+      enddate := Date::Date( 9999, 12, 31 );
+      capacitytype := "Transport quantity";
+      if( userleadtime.Length() = 0 )
+      {
+        processingtime := Duration::Zero(); 
+        }
+      else
+      {
+        processingtime := Duration::Hours( [Number]userleadtime );
+        };
+      
+      unit := Unit::FindById( macroPlan, unitid );
+      if( isnull( unit)){
+        unit :=macroPlan.Unit( relnew, 
+                               ID := unitid, 
+                               Name := unitid, 
+                               UnitOfMeasureName := unitofmeasurename, 
+                               CurrencyID := currencyid, 
+                               StartDate := startdate, 
+                               EndDate := enddate, 
+                               CapacityType := capacitytype );
+      }
+      
+      a := Lane::CreateLane( macroPlan, unit, id, name, processingtime);
+      updates.Add( a );
+      }
+    origindataset := selectset( macroPlan, Unit.Lane, l, true );
+    obsoletes := origindataset.Difference( updates );
+    // delete obsoleted
+    difflength := obsoletes.Size();
+    for( j:=0; j<difflength; j++ )
+    {
+      obsolete := obsoletes.Element( j );
+      obsolete.Delete();
+      }
+  *]
+}
diff --git a/_Main/BL/Type_Lane/StaticMethod_CreateLane.qbl b/_Main/BL/Type_Lane/StaticMethod_CreateLane.qbl
index 64c72eb..286b75f 100644
--- a/_Main/BL/Type_Lane/StaticMethod_CreateLane.qbl
+++ b/_Main/BL/Type_Lane/StaticMethod_CreateLane.qbl
@@ -1,6 +1,7 @@
 Quintiq file version 2.0
 #parent: #root
 StaticMethod CreateLane (
+  MacroPlan mp,
   Unit unit,
   String id,
   String name,
@@ -19,7 +20,7 @@
     isfromdb := true;
     
     //create new stockingpoint
-    result := Lane::FindLaneTypeIndex( id );
+    result := Lane::FindById( mp, id );
     
     if( isnull( result ) )
     {
diff --git a/_Main/BL/Type_Lane/StaticMethod_CreateLaneFromJson.qbl b/_Main/BL/Type_Lane/StaticMethod_CreateLaneFromJson.qbl
index 060eabc..d4e9b77 100644
--- a/_Main/BL/Type_Lane/StaticMethod_CreateLaneFromJson.qbl
+++ b/_Main/BL/Type_Lane/StaticMethod_CreateLaneFromJson.qbl
@@ -40,7 +40,7 @@
                    EndDate := enddate );
     }
     
-    result := Lane::CreateLane( unit, id, name, processingtime);
+    result := Lane::CreateLane( macroplan, unit, id, name, processingtime);
     
     return result;
   *]
diff --git a/_Main/BL/Type_Lane/StaticMethod_FindById.qbl b/_Main/BL/Type_Lane/StaticMethod_FindById.qbl
new file mode 100644
index 0000000..05cf40a
--- /dev/null
+++ b/_Main/BL/Type_Lane/StaticMethod_FindById.qbl
@@ -0,0 +1,15 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod FindById (
+  MacroPlan mp,
+  String id
+) as Lane
+{
+  TextBody:
+  [*
+    // yypsybs Aug-14-2023 (created)
+    result := select( mp, Unit.Lane, lane, true, lane.ID() = id );
+    
+    return result;
+  *]
+}
diff --git a/_Main/BL/Type_Lane/StaticMethod_FindByIdAndUnit.qbl b/_Main/BL/Type_Lane/StaticMethod_FindByIdAndUnit.qbl
new file mode 100644
index 0000000..b60c9e4
--- /dev/null
+++ b/_Main/BL/Type_Lane/StaticMethod_FindByIdAndUnit.qbl
@@ -0,0 +1,16 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod FindByIdAndUnit (
+  Unit unit,
+  String id
+) as Lane
+{
+  TextBody:
+  [*
+    // yypsybs Aug-14-2023 (created)
+    
+    result := select(  unit, Lane, item, true, item.ID() = id );
+    
+    return result;
+  *]
+}
diff --git a/_Main/BL/Type_LaneLeg/StaticMethod_CreateFromMapping.qbl b/_Main/BL/Type_LaneLeg/StaticMethod_CreateFromMapping.qbl
new file mode 100644
index 0000000..f15c486
--- /dev/null
+++ b/_Main/BL/Type_LaneLeg/StaticMethod_CreateFromMapping.qbl
@@ -0,0 +1,42 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CreateFromMapping (
+  const GlobalOTDTable globalOTDTable,
+  MacroPlan macroPlan
+)
+{
+  TextBody:
+  [*
+    // Administrator Oct-31-2023 (created)
+    updates := construct( LaneLegs );
+    traverse( globalOTDTable, Global_MappingLaneLeg, gll, true )
+    {
+      processingtime := Duration::Zero();
+      hasprocessingtime := true;
+      userleadtime := gll.UserLeadTime();
+      if( userleadtime.Length() = 0 )
+      {
+        hasprocessingtime := false;
+        processingtime := Duration::Zero(); 
+        }
+      else
+      {
+        hasprocessingtime := true;
+        processingtime := Duration::Hours( [Number]userleadtime );
+        };
+      
+      lane := Lane::FindById( macroPlan, gll.LaneID() );
+      a := LaneLeg::CreateLaneleg( macroPlan, lane, gll.LaneID(), gll.OriginStockingPointID(), gll.DestinationStockingPointID(), gll.Name(), hasprocessingtime, processingtime);
+      updates.Add( a );
+      }
+    origindataset := selectset( macroPlan, Unit.Lane.LaneLeg, ll, true );
+    obsoletes := origindataset.Difference( updates );
+    // delete obsoleted
+    difflength := obsoletes.Size();
+    for( j:=0; j<difflength; j++ )
+    {
+      obsolete := obsoletes.Element( j );
+      obsolete.Delete();
+      }
+  *]
+}
diff --git a/_Main/BL/Type_LaneLeg/StaticMethod_CreateLaneLegFromJson.qbl b/_Main/BL/Type_LaneLeg/StaticMethod_CreateLaneLegFromJson.qbl
index ed77c9e..021a0f6 100644
--- a/_Main/BL/Type_LaneLeg/StaticMethod_CreateLaneLegFromJson.qbl
+++ b/_Main/BL/Type_LaneLeg/StaticMethod_CreateLaneLegFromJson.qbl
@@ -1,6 +1,7 @@
 Quintiq file version 2.0
 #parent: #root
 StaticMethod CreateLaneLegFromJson (
+  MacroPlan mp,
   JSON datarow
 ) as LaneLeg
 {
@@ -29,7 +30,7 @@
     
     lane := Lane::FindLaneTypeIndex( laneid );
     
-    result := LaneLeg::CreateLaneleg(lane, laneid, originstockingpointid, destinationstockingpointid, name, hasprocessingtime, processingtime);
+    result := LaneLeg::CreateLaneleg( mp, lane, laneid, originstockingpointid, destinationstockingpointid, name, hasprocessingtime, processingtime);
     
     return result;
   *]
diff --git a/_Main/BL/Type_LaneLeg/StaticMethod_CreateLaneleg.qbl b/_Main/BL/Type_LaneLeg/StaticMethod_CreateLaneleg.qbl
index c72fe3d..6ca8d7e 100644
--- a/_Main/BL/Type_LaneLeg/StaticMethod_CreateLaneleg.qbl
+++ b/_Main/BL/Type_LaneLeg/StaticMethod_CreateLaneleg.qbl
@@ -1,6 +1,7 @@
 Quintiq file version 2.0
 #parent: #root
 StaticMethod CreateLaneleg (
+  MacroPlan mp,
   Lane lane,
   String laneid,
   String originstockingpointid,
@@ -25,16 +26,16 @@
     isfromdb := true;
     
     //create new stockingpoint
-    originstockingpoint := StockingPoint_MP::FindStockingPointTypeIndex( originstockingpointid );
+    originstockingpoint := StockingPoint_MP::FindById( mp, originstockingpointid );
     lane.AddStockingPoint( originstockingpoint, true, isfromdb );
     Transaction::Transaction().Propagate();
     
-    destinationstockingpoint := StockingPoint_MP::FindStockingPointTypeIndex( destinationstockingpointid );
+    destinationstockingpoint := StockingPoint_MP::FindById( mp, destinationstockingpointid );
     lane.AddStockingPoint( destinationstockingpoint, false, isfromdb );
     
     Transaction::Transaction().Propagate();
     
-    result := LaneLeg::FindLaneLegTypeIndex( laneid, originstockingpointid, destinationstockingpointid );
+    result := LaneLeg::FindByIdAndLane( lane, originstockingpointid, destinationstockingpointid );
     
     if( isnull( result ) )
     {
diff --git a/_Main/BL/Type_LaneLeg/StaticMethod_FindByIdAndLane.qbl b/_Main/BL/Type_LaneLeg/StaticMethod_FindByIdAndLane.qbl
new file mode 100644
index 0000000..a6a90ec
--- /dev/null
+++ b/_Main/BL/Type_LaneLeg/StaticMethod_FindByIdAndLane.qbl
@@ -0,0 +1,17 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod FindByIdAndLane (
+  Lane lane,
+  String originstockingpointid,
+  String destinationstockingpointid
+) as LaneLeg
+{
+  TextBody:
+  [*
+    // yypsybs Aug-14-2023 (created)
+    
+    result := select(  lane, LaneLeg, item, true, item.OriginStockingPointID() = originstockingpointid and item.DestinationStockingPointID() = destinationstockingpointid );
+    
+    return result;
+  *]
+}
diff --git a/_Main/BL/Type_MacroPlan/Method_ApiCurencyRatesData.qbl b/_Main/BL/Type_MacroPlan/Method_ApiCurencyRatesData.qbl
index 9f5c492..e4ee8c5 100644
--- a/_Main/BL/Type_MacroPlan/Method_ApiCurencyRatesData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_ApiCurencyRatesData.qbl
@@ -1,6 +1,7 @@
 Quintiq file version 2.0
 #parent: #root
 Method ApiCurencyRatesData (
+  MacroPlan mp,
   JSON data
 )
 {
@@ -14,7 +15,7 @@
     for( i:=0; i<data_length; i++ )
     {
       datarow := data.Get( i );
-      a := CurrencyRate_MP::CreateCurrencyRateFromJson( datarow );
+      a := CurrencyRate_MP::CreateCurrencyRateFromJson( mp, datarow );
       updates.Add( a );
       }
     origindataset := selectset( this, Currency_MP.CurrencyRate_MP, cr, true );
diff --git a/_Main/BL/Type_MacroPlan/Method_ApiLaneLegsData.qbl b/_Main/BL/Type_MacroPlan/Method_ApiLaneLegsData.qbl
index 450d6ae..c3e7b0c 100644
--- a/_Main/BL/Type_MacroPlan/Method_ApiLaneLegsData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_ApiLaneLegsData.qbl
@@ -1,6 +1,7 @@
 Quintiq file version 2.0
 #parent: #root
 Method ApiLaneLegsData (
+  MacroPlan mp,
   JSON data
 )
 {
@@ -14,7 +15,7 @@
     for( i:=0; i<data_length; i++ )
     {
       datarow := data.Get( i );
-      a := LaneLeg::CreateLaneLegFromJson( datarow );
+      a := LaneLeg::CreateLaneLegFromJson( mp, datarow );
       updates.Add( a );
       }
     origindataset := selectset( this, Unit.Lane.LaneLeg, ll, true );
diff --git a/_Main/BL/Type_MacroPlan/Method_DoASyncMappingCustomerOrderData.qbl b/_Main/BL/Type_MacroPlan/Method_DoASyncMappingCustomerOrderData.qbl
index e56a4f7..16ec956 100644
--- a/_Main/BL/Type_MacroPlan/Method_DoASyncMappingCustomerOrderData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_DoASyncMappingCustomerOrderData.qbl
@@ -22,7 +22,7 @@
                                  ( organcodelist.Find( item.StockingPointID().SubString( 0, 3 ) ) >= 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() );
+    //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.StockingPointID() ) ) and not isnull( SalesSegment_MP::FindByName( this, item.SalesSegmentName() ) ) );
     
     totalcount := listToDeal.Size();
diff --git a/_Main/BL/Type_MacroPlan/Method_DoASyncMappingExternalSupplyData.qbl b/_Main/BL/Type_MacroPlan/Method_DoASyncMappingExternalSupplyData.qbl
index ad47aed..6b2f316 100644
--- a/_Main/BL/Type_MacroPlan/Method_DoASyncMappingExternalSupplyData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_DoASyncMappingExternalSupplyData.qbl
@@ -11,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() );
+    //queryEndDate := guard( max( this, Period_MP, item, true, item.EndDate() ), Date::MaxDate() );
     
     listtodeal := construct( Global_MappingInventorySupplys, constcontent );
     if ( businessTypes.Size() > 0 ) {
diff --git "a/_Main/BL/Type_MacroPlan/StaticMethod_DoASync\043253.qbl" "b/_Main/BL/Type_MacroPlan/StaticMethod_DoASync\043253.qbl"
index 0c397f4..bdf837d 100644
--- "a/_Main/BL/Type_MacroPlan/StaticMethod_DoASync\043253.qbl"
+++ "b/_Main/BL/Type_MacroPlan/StaticMethod_DoASync\043253.qbl"
@@ -44,34 +44,23 @@
     macroPlan.DoASyncMappingUnitData( businessTypeName ,globalOTDTable, organcodelist);
     
     // 搴撳瓨鐐�-3
-    info( "Sales Segment Finished, Start Get StockingPoint From Api" )
-    parameter := select( globalOTDTable, GlobalParameters, param, param.AttributeName() = "StockingPoint" );
-    postrequestbody := parameter.PostRequestBody();
-    address := parameter.Address();
-    url := parameter.AttributeValue();
-    port := [Number]parameter.Port();
-    data := macroPlan.ApiResponesCheck( address, url, port, postrequestbody );
-    macroPlan.ApiStockingPointData( data );
+    info( "Sales Segment Finished, Start Get StockingPoint From Mapping" )
+    StockingPoint_MP::CreateFromMapping( globalOTDTable, macroPlan );
+    //parameter := select( globalOTDTable, GlobalParameters, param, param.AttributeName() = "StockingPoint" );
+    //postrequestbody := parameter.PostRequestBody();
+    //address := parameter.Address();
+    //url := parameter.AttributeValue();
+    //port := [Number]parameter.Port();
+    //data := macroPlan.ApiResponesCheck( address, url, port, postrequestbody );
+    //macroPlan.ApiStockingPointData( data );
     
     // 璐у竵淇℃伅-4
-    info( "Get StockingPoint From Api Finished, Start Get CurrencyInfo From Api" )
-    parameter := select( globalOTDTable, GlobalParameters, param, param.AttributeName() = "CurrencyInfo" );
-    postrequestbody := parameter.PostRequestBody();
-    address := parameter.Address();
-    url := parameter.AttributeValue();
-    port := [Number]parameter.Port();
-    data := macroPlan.ApiResponesCheck( address, url, port, postrequestbody );
-    macroPlan.ApiCurenciesData( data );
+    info( "Get StockingPoint From Api Finished, Start Get CurrencyInfo From Mapping" )
+    Currency_MP::CreateFromMapping( globalOTDTable, macroPlan );
     
     //璐у竵姹囩巼淇℃伅-5
-    info( "Get CurrencyInfo From Api Finished, Start Get CurrencyRates From Api" )
-    parameter := select( globalOTDTable, GlobalParameters, param, param.AttributeName() = "CurrencyRates" );
-    postrequestbody := parameter.PostRequestBody();
-    address := parameter.Address();
-    url := parameter.AttributeValue();
-    port := [Number]parameter.Port();
-    data := macroPlan.ApiResponesCheck( address, url, port, postrequestbody );
-    macroPlan.ApiCurencyRatesData( data );
+    info( "Get CurrencyInfo From Api Finished, Start Get CurrencyRates From Mapping" )
+    CurrencyRate_MP::CreateFromMapping( globalOTDTable, macroPlan );
     
     // 浜у搧鐗╂枡-6
     //info( "Get CurrencyRates From Api Finished, Start Product Data Broker" )
@@ -92,24 +81,12 @@
     macroPlan.DoASyncMappingOperationBOMData( businessTypeName, isKeyProduct, createPurchaseSupplyMaterial,globalOTDTable, organcodelist );
     
     //杞﹂亾淇℃伅-10
-    info( "BOM Finished, Start Get Lanes From Api" );
-    parameter := select( globalOTDTable, GlobalParameters, param, param.AttributeName() = "Lanes" );
-    postrequestbody := parameter.PostRequestBody();
-    address := parameter.Address();
-    url := parameter.AttributeValue();
-    port := [Number]parameter.Port();
-    data := macroPlan.ApiResponesCheck( address, url, port, postrequestbody );
-    macroPlan.ApiLanesData( data );
+    info( "BOM Finished, Start Get Lanes From Mapping" );
+    Lane::CreasteFromMapping( globalOTDTable, macroPlan );
     
     //杞﹂亾杩愯緭娈�-11
-    info( "Get Lanes From Api Finished, Start Get LaneLegs From Api" );
-    parameter := select( globalOTDTable, GlobalParameters, param, param.AttributeName() = "LaneLegs" );
-    postrequestbody := parameter.PostRequestBody();
-    address := parameter.Address();
-    url := parameter.AttributeValue();
-    port := [Number]parameter.Port();
-    data := macroPlan.ApiResponesCheck( address, url, port, postrequestbody );
-    macroPlan.ApiLaneLegsData( data );
+    info( "Get Lanes From Api Finished, Start Get LaneLegs From Mapping" );
+    LaneLeg::CreateFromMapping( globalOTDTable, macroPlan );
     
     // 渚涘簲缃戠粶锛堣溅閬擄級-12
     //info( "Get Lanelegs From Api Finished, Start ProductInLane Data Broker" );
diff --git a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
index 8cb5656..25df795 100644
--- a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
+++ b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
@@ -71,7 +71,7 @@
     url := "/otdService/https/GetCurrencyRatesInfo";
     port := 443;
     data := macroPlan.ApiResponesCheck( address, url, port, postrequestbody );
-    macroPlan.ApiCurencyRatesData( data );
+    macroPlan.ApiCurencyRatesData( macroPlan, data );
     
     // 浜у搧鐗╂枡-6
     //info( "Get CurrencyRates From Api Finished, Start Product Data Broker" )
@@ -109,7 +109,7 @@
     url := "/otdService/https/GetLaneLegsInfo";
     port := 443;
     data := macroPlan.ApiResponesCheck( address, url, port, postrequestbody );
-    macroPlan.ApiLaneLegsData( data );
+    macroPlan.ApiLaneLegsData( macroPlan, data );
     
     // 渚涘簲缃戠粶锛堣溅閬擄級-12
     //info( "Get Lanelegs From Api Finished, Start ProductInLane Data Broker" );
diff --git a/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateFromMapping.qbl b/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateFromMapping.qbl
new file mode 100644
index 0000000..f56738d
--- /dev/null
+++ b/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateFromMapping.qbl
@@ -0,0 +1,28 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CreateFromMapping (
+  const GlobalOTDTable globalOTDTable,
+  MacroPlan macroPlan
+)
+{
+  Description: '浠巑apping琛ㄥ垱寤哄簱瀛樼偣'
+  TextBody:
+  [*
+    // Administrator Oct-31-2023 (created)
+    updates := construct( StockingPoint_MPs );
+    traverse( globalOTDTable, Global_MappingStockingPoint_MP, sp, true )
+    {
+      a := StockingPoint_MP::CreateStockingpoint( macroPlan, sp.ID(), sp.UnitID(), sp.Name() );
+      updates.Add( a );
+      }
+    origindataset := selectset( macroPlan, StockingPoint_MP, sp, true );
+    obsoletes := origindataset.Difference( updates );
+    // delete obsoleted
+    difflength := obsoletes.Size();
+    for( j:=0; j<difflength; j++ )
+    {
+      obsolete := obsoletes.Element( j );
+      obsolete.Delete();
+      }
+  *]
+}
diff --git a/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpoint.qbl b/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpoint.qbl
index 857199b..3e2a601 100644
--- a/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpoint.qbl
+++ b/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpoint.qbl
@@ -22,7 +22,7 @@
     isfromdb := true;
     
     //create new stockingpoint
-    result := StockingPoint_MP::FindStockingPointTypeIndex( id );
+    result := StockingPoint_MP::FindById( mp, id );
     
     if( isnull( result ) )
     {
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormInterfaceTest/_ROOT_Component_FormInterfaceTest.def b/_Main/UI/MacroPlannerWebApp/Component_FormInterfaceTest/_ROOT_Component_FormInterfaceTest.def
index 087a1e2..97b6783 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormInterfaceTest/_ROOT_Component_FormInterfaceTest.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormInterfaceTest/_ROOT_Component_FormInterfaceTest.def
@@ -23,6 +23,16 @@
         Taborder: 0
       ]
     }
+    Component DataHolderInterfaceTest
+    {
+      #keys: '[414502.0.443241895]'
+      BaseType: 'WebDataHolder'
+      Databinding: 'Scenario'
+      Properties:
+      [
+        Taborder: 7
+      ]
+    }
   ]
   Properties:
   [

--
Gitblit v1.9.3