From aefafd2142478d4fb07d6b8b45c3047e247389e0 Mon Sep 17 00:00:00 2001
From: hongji.li <hongji.a.li@capgemini.com>
Date: 星期五, 03 十一月 2023 16:31:17 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/TIANMA_JITUAN into dev_lhj

---
 _Main/BL/Type_Global_MappingLaneLeg/StaticMethod_SynchronizeMacroPlanData.qbl                              |   35 --
 _Main/BL/Type_ProductInLane/StaticMethod_FindById.qbl                                                      |   16 +
 _Main/BL/Type_Global_MappingUnitOfMeasure_MP/StaticMethod_SynchronizeMacroPlanData.qbl                     |   24 +-
 _Main/BL/Type_LaneLeg/StaticMethod_CreateLaneLegFromJson.qbl                                               |    3 
 _Main/BL/Type_Global_MappingCurrency_MP/StaticMethod_SynchronizeMacroPlanData.qbl                          |   20 -
 _Main/BL/Type_Global_MappingOperationBOM/StaticMethod_SynchronizeMacroPlanData.qbl                         |    5 
 _Main/BL/Type_MacroPlan/Method_ApiLaneLegsData.qbl                                                         |    3 
 _Main/BL/Type_Currency_MP/StaticMethod_CreateFromMapping.qbl                                               |   27 ++
 _Main/BL/Type_Global_MappingStockingPoint_MP/StaticMethod_SynchronizeMacroPlanData.qbl                     |   20 -
 _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                    |    6 
 _Main/BL/Type_StockingPoint_MP/StaticMethod_CreateFromMapping.qbl                                          |   28 ++
 _Main/BL/Type_Global_MappingUnitCost/StaticMethod_SynchronizeMacroPlanData.qbl                             |    5 
 _Main/BL/Type_Global_MappingProductInLane/StaticMethod_SynchronizeMacroPlanData.qbl                        |    6 
 _Main/BL/Type_MacroPlan/Method_DoASyncMappingExternalSupplyData.qbl                                        |    2 
 _Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl                                                           |    4 
 _Main/BL/Type_Global_MappingForecast/StaticMethod_SynchronizeMacroPlanData.qbl                             |    5 
 _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_ProductInLane/StaticMethod_CreateOrUpdate.qbl                                                |    6 
 _Main/BL/Type_PriorityResult/StaticMethod_CalculateScore.qbl                                               |    2 
 _Main/BL/Type_Global_MappingCustomOrder/StaticMethod_SynchronizeMacroPlanData.qbl                          |    7 
 _Main/BL/Type_Global_MappingOperation/StaticMethod_SynchronizeMacroPlanData.qbl                            |    5 
 _Main/BL/Type_Global_MappingConversionFactor/StaticMethod_SynchronizeMacroPlanData.qbl                     |    5 
 _Main/BL/Type_InventoryValueAndCost/StaticMethod_CreateOrUpdate.qbl                                        |    8 
 _Main/BL/Type_Global_MappingSalesSegment_MP/StaticMethod_SynchronizeMacroPlanData.qbl                      |    5 
 _Main/BL/Type_MacroPlan/Method_DoASyncMappingCustomerOrderData.qbl                                         |    2 
 _Main/UI/MacroPlannerWebApp/Component_FormInterfaceTest/_ROOT_Component_FormInterfaceTest.def              |   10 
 _Main/BL/Type_MacroPlan/StaticMethod_DoASync#253.qbl                                                       |   59 +---
 _Main/BL/Type_Global_MappingProduct_MP/StaticMethod_SynchronizeMacroPlanData.qbl                           |    5 
 _Main/BL/Type_LaneLeg/StaticMethod_FindByIdAndLane.qbl                                                     |   17 +
 _Main/BL/Type_InventoryValueAndCost/StaticMethod_FindById.qbl                                              |    3 
 _Main/BL/Type_Global_MappingActualProductInStockingPointInPeriod/StaticMethod_SynchronizeMacroPlanData.qbl |    5 
 _Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateCurrencyRateFromJson.qbl                                  |    3 
 _Main/BL/Type_Global_MappingLane/StaticMethod_SynchronizeMacroPlanData.qbl                                 |   52 ----
 _Main/BL/Type_MacroPlan/Method_ApiCurencyRatesData.qbl                                                     |    3 
 _Main/BL/Type_Lane/StaticMethod_CreateLaneFromJson.qbl                                                     |    2 
 _Main/BL/Type_Lane/StaticMethod_FindByIdAndUnit.qbl                                                        |   16 +
 _Main/BL/Type_Currency_MP/StaticMethod_CreateCurrency.qbl                                                  |    2 
 _Main/BL/Type_LaneLeg/StaticMethod_CreateFromMapping.qbl                                                   |   42 +++
 _Main/BL/Type_Global_MappingCurrencyRate_MP/StaticMethod_SynchronizeMacroPlanData.qbl                      |   20 -
 /dev/null                                                                                                  |    6 
 _Main/BL/Type_GlobalDTOTable/Method_SynchronizeDataToMacroPlan#127.qbl                                     |    8 
 _Main/BL/Type_Global_MappingInventorySupply/StaticMethod_SynchronizeMacroPlanData.qbl                      |    5 
 _Main/BL/Type_Lane/StaticMethod_CreasteFromMapping.qbl                                                     |   59 +++++
 _Main/BL/Type_CurrencyRate_MP/StaticMethod_CreateFromMapping.qbl                                           |   27 ++
 _Main/BL/Type_BaseConversionFactor/StaticMethod_CreateOrUpdate.qbl                                         |   14 +
 50 files changed, 413 insertions(+), 243 deletions(-)

diff --git a/_Main/BL/Type_BaseConversionFactor/StaticMethod_CreateOrUpdate.qbl b/_Main/BL/Type_BaseConversionFactor/StaticMethod_CreateOrUpdate.qbl
index cd44e09..2e4ee74 100644
--- a/_Main/BL/Type_BaseConversionFactor/StaticMethod_CreateOrUpdate.qbl
+++ b/_Main/BL/Type_BaseConversionFactor/StaticMethod_CreateOrUpdate.qbl
@@ -26,6 +26,20 @@
       if( productId <> "" ) {
         product := Product_MP::FindById( macroPlan, productId );
       }else{
+    //    info( productId );
+    //    cf := select( source,
+    //              AsSourceUnitOfMeasure,
+    //              cf,
+    //              ( cf.TargetUnitOfMeasure() = target
+    //                or cf.TargetUnitOfMeasure() = source )
+    //              and cf.Product_MP() = product
+    //              );
+    //    info( isnull( cf ) );
+    //    info( "sourceuomname: " + cf.astype( BaseConversionFactor ).SourceUnitOfMeasureName() );
+    //    info( "targetuomname: " + target.Name() );
+    //    info( "cf.targetuomname: " + cf.astype( BaseConversionFactor ).TargetUnitOfMeasureName() );
+    //    info( "productid: " + guard( product.ID(), "" ) );
+    //    info( "cf.product: " + cf.astype( BaseConversionFactor ).ProductID() );
         result := BaseConversionFactor::CreateUpdate( source, target, factor, product, isEnable )
       }
     
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..254563a 100644
--- "a/_Main/BL/Type_GlobalDTOTable/Method_SynchronizeDataToMacroPlan\043127.qbl"
+++ "b/_Main/BL/Type_GlobalDTOTable/Method_SynchronizeDataToMacroPlan\043127.qbl"
@@ -50,11 +50,11 @@
     macroPlan.InitialUnitAndStockingPoint();
     
     if ( isUnitOfMeasure_MP ) {
-      Global_MappingUnitOfMeasure_MP::SynchronizeMacroPlanData( this, macroPlan );
+      Global_MappingUnitOfMeasure_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser );
     }
     
     if ( isCustomOrder ) {
-      Global_MappingCustomOrder::SynchronizeMacroPlanData( this, macroPlan, executionUser );
+      Global_MappingCustomOrder::SynchronizeMacroPlanData( this, macroPlan, businessTypes, organcodelist, executionUser );
     }
     
     if ( isForeacst ) {
@@ -82,7 +82,7 @@
     }
     
     if ( isProductInLane ) {
-      Global_MappingProductInLane::SynchronizeMacroPlanData( this, macroPlan, executionUser );
+      Global_MappingProductInLane::SynchronizeMacroPlanData( this, macroPlan, businessTypes, executionUser );
     }
     
     if ( isAIPISPIP ) {
@@ -94,7 +94,7 @@
     }
     
     if ( isStockingPointCost ) {
-      Global_MappingStockingPointCost::SynchronizeMacroPlanData( this, macroPlan, executionUser );
+      Global_MappingStockingPointCost::SynchronizeMacroPlanData( this, macroPlan, businessTypes, executionUser );
     }
     
     if ( isOperationCost ) {
diff --git a/_Main/BL/Type_Global_MappingActualProductInStockingPointInPeriod/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingActualProductInStockingPointInPeriod/StaticMethod_SynchronizeMacroPlanData.qbl
index 984a0eb..ad249d7 100644
--- a/_Main/BL/Type_Global_MappingActualProductInStockingPointInPeriod/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingActualProductInStockingPointInPeriod/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -12,14 +12,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾瀹為檯搴撳瓨鏁版嵁",
+                                                                       BrokerName := "鍚屾瀹為檯搴撳瓨鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..51aa067 100644
--- a/_Main/BL/Type_Global_MappingConversionFactor/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingConversionFactor/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -9,14 +9,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾鍗曚綅杞崲鏁版嵁",
+                                                                       BrokerName := "鍚屾鍗曚綅杞崲鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..e30d9ef 100644
--- a/_Main/BL/Type_Global_MappingCurrencyRate_MP/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingCurrencyRate_MP/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -9,29 +9,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾璐у竵姹囩巼鏁版嵁",
+                                                                       BrokerName := "鍚屾璐у竵姹囩巼鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..31f2109 100644
--- a/_Main/BL/Type_Global_MappingCurrency_MP/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingCurrency_MP/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -9,29 +9,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾璐у竵鏁版嵁",
+                                                                       BrokerName := "鍚屾璐у竵鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..7e2f51f 100644
--- a/_Main/BL/Type_Global_MappingCustomOrder/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingCustomOrder/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -3,20 +3,23 @@
 StaticMethod SynchronizeMacroPlanData (
   GlobalOTDTable globalOTDTable,
   MacroPlan macroPlan,
+  Strings businessTypes,
+  Strings organcodelist,
   String executionUser
 )
 {
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾璁㈠崟鏁版嵁",
+                                                                       BrokerName := "鍚屾璁㈠崟鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..cb14755 100644
--- a/_Main/BL/Type_Global_MappingForecast/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingForecast/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -11,14 +11,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾棰勬祴鏁版嵁",
+                                                                       BrokerName := "鍚屾棰勬祴鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..7de7b35 100644
--- a/_Main/BL/Type_Global_MappingInventorySupply/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingInventorySupply/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -12,14 +12,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾鍦ㄩ�斿簱瀛樻暟鎹�",
+                                                                       BrokerName := "鍚屾鍦ㄩ�斿簱瀛樻暟鎹�",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..6cfc45e 100644
--- a/_Main/BL/Type_Global_MappingLane/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingLane/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -9,61 +9,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾杞﹂亾鏁版嵁",
+                                                                       BrokerName := "鍚屾杞﹂亾鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..dacd193 100644
--- a/_Main/BL/Type_Global_MappingLaneLeg/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingLaneLeg/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -9,44 +9,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾杞﹂亾璺嚎鏁版嵁",
+                                                                       BrokerName := "鍚屾杞﹂亾璺嚎鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..59d2808 100644
--- a/_Main/BL/Type_Global_MappingOperation/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingOperation/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -11,14 +11,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾宸ヨ壓璺嚎鏁版嵁",
+                                                                       BrokerName := "鍚屾宸ヨ壓璺嚎鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..86e1e89 100644
--- a/_Main/BL/Type_Global_MappingOperationBOM/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingOperationBOM/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -13,14 +13,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾BOM鏁版嵁",
+                                                                       BrokerName := "鍚屾BOM鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..00eddb8 100644
--- a/_Main/BL/Type_Global_MappingProductInLane/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingProductInLane/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -3,20 +3,22 @@
 StaticMethod SynchronizeMacroPlanData (
   GlobalOTDTable globalOTDTable,
   MacroPlan macroPlan,
+  Strings businessTypes,
   String executionUser
 )
 {
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾杩愯緭璺嚎浜у搧鏁版嵁",
+                                                                       BrokerName := "鍚屾杩愯緭璺嚎浜у搧鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..47d8f21 100644
--- a/_Main/BL/Type_Global_MappingProduct_MP/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingProduct_MP/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -11,14 +11,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾浜у搧鏁版嵁",
+                                                                       BrokerName := "鍚屾浜у搧鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..636f6a8 100644
--- a/_Main/BL/Type_Global_MappingSalesSegment_MP/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingSalesSegment_MP/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -10,14 +10,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾閿�鍞儴闂ㄦ暟鎹�",
+                                                                       BrokerName := "鍚屾閿�鍞儴闂ㄦ暟鎹�",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..adfe937 100644
--- a/_Main/BL/Type_Global_MappingStockingPointCost/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingStockingPointCost/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -3,20 +3,22 @@
 StaticMethod SynchronizeMacroPlanData (
   GlobalOTDTable globalOTDTable,
   MacroPlan macroPlan,
+  Strings businessTypes,
   String executionUser
 )
 {
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾搴撳瓨鎴愭湰鏁版嵁",
+                                                                       BrokerName := "鍚屾搴撳瓨鎴愭湰鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..a388711 100644
--- a/_Main/BL/Type_Global_MappingStockingPoint_MP/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingStockingPoint_MP/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -9,29 +9,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾搴撳瓨鐐规暟鎹�",
+                                                                       BrokerName := "鍚屾搴撳瓨鐐规暟鎹�",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..2b7b644 100644
--- a/_Main/BL/Type_Global_MappingUnitCost/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingUnitCost/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -11,14 +11,15 @@
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name        := "鍚屾鍒堕�犳垚鏈暟鎹�",
+                                                                       BrokerName := "鍚屾鍒堕�犳垚鏈暟鎹�",
+                                                                       ExecutionStatus := "InOperation",
                                                                        IsSuccess   := true,
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
       
     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..30bfa48 100644
--- a/_Main/BL/Type_Global_MappingUnitOfMeasure_MP/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingUnitOfMeasure_MP/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -2,30 +2,30 @@
 #parent: #root
 StaticMethod SynchronizeMacroPlanData (
   GlobalOTDTable globalOTDTable,
-  MacroPlan macroPlan
+  MacroPlan macroPlan,
+  String executionUser
 )
 {
   TextBody:
   [*
     global_BrokerExecuteLog := globalOTDTable.Global_BrokerExecuteLog( relnew,
-                                                                       Name := "鍚屾鍗曚綅鏁版嵁",
-                                                                       IsSuccess := true
+                                                                       BrokerName := "鍚屾鍗曚綅鏁版嵁",
+                                                                       ExecutionStatus := "InOperation",
+                                                                       IsSuccess   := true,
+                                                                       ExecuteUser := executionUser
                                                                       );
                                             
     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);
+      
+      global_BrokerExecuteLog.ExecutionStatus( "Complete" );
+      global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
     } onerror {
       global_BrokerExecuteLog.IsSuccess( false );
       global_BrokerExecuteLog.ErrorNo( e.ErrorNr() );
       global_BrokerExecuteLog.ErrorMessage( e.GeneralInformation() );
+      global_BrokerExecuteLog.ErrorDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
+      global_BrokerExecuteLog.ExecutionStatus( "Complete" );
     }
   *]
 }
diff --git a/_Main/BL/Type_InventoryValueAndCost/StaticMethod_CreateOrUpdate.qbl b/_Main/BL/Type_InventoryValueAndCost/StaticMethod_CreateOrUpdate.qbl
index 4116cce..9dec2cd 100644
--- a/_Main/BL/Type_InventoryValueAndCost/StaticMethod_CreateOrUpdate.qbl
+++ b/_Main/BL/Type_InventoryValueAndCost/StaticMethod_CreateOrUpdate.qbl
@@ -32,16 +32,16 @@
     //if( isnull( account ) ) {
     //    error( "account not found" );  
     //}
-    result := InventoryValueAndCost::FindById( macroPlan, stockingPointId,productId,start,id );
+    result := InventoryValueAndCost::FindById( macroPlan, stockingPointId, productId, start, id );
     if( not isnull( product) and not isnull( stockingPoint) and not isnull( account)){
       if( isnull( result ) ) {
         result := InventoryValueAndCost::Create( id, product, stockingPoint, account, costDriver, start, cost, true ).astype( InventoryValueAndCost );
       } else if( result.ProductID() <> productId ) {
         info( "cannot change product of inventory value and cost" )
       } 
-    //  else {
-    //    result.Update( account, costDriver, start, account.DefaultTimeUnit(), account.DefaultLengthOfTime(), cost, true );
-    //  }
+      else {
+        result.Update( account, costDriver, start, account.DefaultTimeUnit(), account.DefaultLengthOfTime(), cost, true );
+      }
     }
     
     return result;
diff --git a/_Main/BL/Type_InventoryValueAndCost/StaticMethod_FindById.qbl b/_Main/BL/Type_InventoryValueAndCost/StaticMethod_FindById.qbl
index 133145d..e49e111 100644
--- a/_Main/BL/Type_InventoryValueAndCost/StaticMethod_FindById.qbl
+++ b/_Main/BL/Type_InventoryValueAndCost/StaticMethod_FindById.qbl
@@ -12,6 +12,9 @@
   [*
     // yypsybs Aug-16-2023 (created)
     value := select( macroPlan, Product_MP.InventoryValueAndCost, item, true, item.ProductID()=productId and item.StockingPointID() = stockPointId and item.Start() = start );
+    if( isnull( value ) ){
+      value := select( macroPlan, Product_MP.InventoryValueAndCost, item, true, item.ID() = id );
+      }
     return value;
   *]
 }
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/DefaultValue_BusinessType.qbl b/_Main/BL/Type_MacroPlan/DefaultValue_BusinessType.qbl
deleted file mode 100644
index 1672b03..0000000
--- a/_Main/BL/Type_MacroPlan/DefaultValue_BusinessType.qbl
+++ /dev/null
@@ -1,6 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-DefaultValue
-{
-  TargetAttribute: BusinessType
-}
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..70b4b76 100644
--- "a/_Main/BL/Type_MacroPlan/StaticMethod_DoASync\043253.qbl"
+++ "b/_Main/BL/Type_MacroPlan/StaticMethod_DoASync\043253.qbl"
@@ -17,6 +17,8 @@
     info( "Prepare to do sync" )
     info( "Get organ code list" )
     businessTypeName := businessType.BusinessTypeName().Tokenize( "," );
+    macroPlan.BusinessType( businessType.BusinessTypeName() );
+    
     organcodelist := selectvalues( businessType, OrganCode, organ, true, organ.OrganCodeName() );
     
     if( organcodelist.Size() = 0 ){
@@ -44,34 +46,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 +83,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_PriorityResult/StaticMethod_CalculateScore.qbl b/_Main/BL/Type_PriorityResult/StaticMethod_CalculateScore.qbl
index 9794c76..dbd5fae 100644
--- a/_Main/BL/Type_PriorityResult/StaticMethod_CalculateScore.qbl
+++ b/_Main/BL/Type_PriorityResult/StaticMethod_CalculateScore.qbl
@@ -35,7 +35,7 @@
                 // 鎴彇鎺夊凡缁忚绠楃殑浼樺厛绾у洜瀛� 閫掑綊璁$畻
                 remindFormula := PriorityResult::GetRemindFormula( remindFormula,macroPlan);
                 score := score + PriorityResult::CalculateScore( remindFormula,customerOrder,businessType,macroPlan,score,globalOTDTable);
-            }else if( remindFormula.StartsWith( "*" ) ){
+            }else if( remindFormula.StartsWith( "x" ) ){
                 remindFormula := remindFormula.SubString( 1,remindFormula.Length()-1);
                 score := PriorityResult::GetDetailsValue( customerOrder,remindFormula,macroPlan,globalOTDTable);
                 score := lastScore * score;
diff --git a/_Main/BL/Type_ProductInLane/StaticMethod_CreateOrUpdate.qbl b/_Main/BL/Type_ProductInLane/StaticMethod_CreateOrUpdate.qbl
index 0359b3f..8fd36c2 100644
--- a/_Main/BL/Type_ProductInLane/StaticMethod_CreateOrUpdate.qbl
+++ b/_Main/BL/Type_ProductInLane/StaticMethod_CreateOrUpdate.qbl
@@ -15,15 +15,15 @@
     
     // Get product&line
     product :=  Product_MP::FindById( owner, productid );
-    line :=  Lane::FindLaneTypeIndex( lineid );
+    line :=  Lane::FindById( owner, lineid );
     
     if( not isnull( product) and not isnull( line)){
-      productinline := ProductInLane::FindProductInLaneTypeIndex( lineid, productid );
+      productinline := ProductInLane::FindById( owner, productid, lineid );
     
       if( isnull( productinline ) ){
       ProductInLane::Create( product, line, isexcluded, isfromdb );
       }else{
-       productinline.Update( productid, lineid, isexcluded, isfromdb );
+        productinline.Update( lineid, productid, isexcluded, isfromdb );
         }
     }
   *]
diff --git a/_Main/BL/Type_ProductInLane/StaticMethod_FindById.qbl b/_Main/BL/Type_ProductInLane/StaticMethod_FindById.qbl
new file mode 100644
index 0000000..e0065ed
--- /dev/null
+++ b/_Main/BL/Type_ProductInLane/StaticMethod_FindById.qbl
@@ -0,0 +1,16 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod FindById (
+  MacroPlan mp,
+  String id,
+  String laneid
+) as ProductInLane
+{
+  TextBody:
+  [*
+    // yy 2023-11-01
+    result := select( mp, Product_MP.ProductInLane, pil, true, pil.ProductID() = id and pil.LaneID() = laneid );
+    
+    return result;
+  *]
+}
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