From 5be1a4f56ab08d96dfae922ef4eb2ce74a7fabeb Mon Sep 17 00:00:00 2001
From: hongji.li <hongji.a.li@capgemini.com>
Date: 星期三, 13 九月 2023 10:55:09 +0800
Subject: [PATCH] Merge branch 'dev_release' into dev

---
 _Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl                                   |   20 ++--
 _Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpointFromJson.qbl        |    2 
 _Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataRouting#576.qbl              |    2 
 _Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl                       |    5 
 _var/_Main/ModelSettings/Common/Development/_ROOT_Role_Development.properties      |    8 +-
 _Main/BL/Type_Lane/StaticMethod_CreateLane.qbl                                     |    2 
 _Main/BL/Type_MacroPlan/Method_MappingUnitData.qbl                                 |    7 +
 _Main/BL/Type_ProductInLane/StaticMethod_CreateOrUpdate.qbl                        |    8 +
 _Main/BL/Type_InventoryValueAndCost/StaticMethod_FindById.qbl                      |    5 +
 _Main/BL/Type_MacroPlan/Method_MappingProductInLaneData.qbl                        |    4 
 _Main/BL/Type_MacroPlan/Method_MappingProductData.qbl                              |    4 
 _Main/BL/Type_InventoryValueAndCost/StaticMethod_CreateOrUpdate.qbl                |   34 ++++---
 _Main/BL/Type_MacroPlan/Method_InitialUnitAndStockingPoint.qbl                     |    2 
 _Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl                         |    2 
 _Main/BL/Type_MacroPlan/Method_MappingInventoryValueAndCostData.qbl                |   23 +++--
 _Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl                         |   15 ++-
 _Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataSupplyPurchase.qbl           |   23 +++--
 _Main/BL/EDI/Broker_Broker_OTD_Product.qbl                                         |    1 
 _Main/BL/Type_ActualProductInStockingPointInPeriod/StaticMethod_CreateOrUpdate.qbl |    4 
 _Main/BL/Type_Forecast/StaticMethod_CreateOrUpdate.qbl                             |    2 
 _Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl                        |    2 
 _Main/BL/Type_CustomerOrder/StaticMethod_CreateOrUpdate.qbl                        |   22 ++--
 _Main/BL/Type_MacroPlan/Method_MappingOperationData.qbl                            |   19 ++--
 23 files changed, 119 insertions(+), 97 deletions(-)

diff --git a/_Main/BL/EDI/Broker_Broker_OTD_Product.qbl b/_Main/BL/EDI/Broker_Broker_OTD_Product.qbl
index 3da4e20..15ca8ab 100644
--- a/_Main/BL/EDI/Broker_Broker_OTD_Product.qbl
+++ b/_Main/BL/EDI/Broker_Broker_OTD_Product.qbl
@@ -38,6 +38,7 @@
       OthersMayFlushTable: true
       OthersMayInsertRow: true
       Parameters: '/owner="TIANMA"'
+      PrimaryKeyColumns: BUSINESSTYPE
       PrimaryKeyColumns: ID
       RecordModificationHintStrategy: 'None'
       EDIODBCLinkColumn BUSINESSTYPE
diff --git a/_Main/BL/Type_ActualProductInStockingPointInPeriod/StaticMethod_CreateOrUpdate.qbl b/_Main/BL/Type_ActualProductInStockingPointInPeriod/StaticMethod_CreateOrUpdate.qbl
index 0c2492f..95d364e 100644
--- a/_Main/BL/Type_ActualProductInStockingPointInPeriod/StaticMethod_CreateOrUpdate.qbl
+++ b/_Main/BL/Type_ActualProductInStockingPointInPeriod/StaticMethod_CreateOrUpdate.qbl
@@ -12,7 +12,7 @@
   TextBody:
   [*
     // Administrator Sep-6-2023 (created)
-    date := Date :: Today();
+    date := owner.StartOfPlanning().Date()-1;
     actualpispip := ActualProductInStockingPointInPeriod::FindActualProductInStockingPointInPeriodTypeIndex( productid, stockingpointid, date, manufactureddate );
     
     if( isnull( actualpispip ) ){
@@ -25,7 +25,7 @@
                                                     manufactureddate,
                                                     true);
       }else{
-        actualpispip.Update( actualinventorylevelend, description, true );
+        actualpispip.Update(  actualinventorylevelend+actualpispip.ActualInventoryLevelEnd(), description, true );
         }
   *]
 }
diff --git a/_Main/BL/Type_CustomerOrder/StaticMethod_CreateOrUpdate.qbl b/_Main/BL/Type_CustomerOrder/StaticMethod_CreateOrUpdate.qbl
index d1d98d9..e885859 100644
--- a/_Main/BL/Type_CustomerOrder/StaticMethod_CreateOrUpdate.qbl
+++ b/_Main/BL/Type_CustomerOrder/StaticMethod_CreateOrUpdate.qbl
@@ -27,7 +27,7 @@
     product := Product_MP::FindById( macroPlan, productId );
     salesSegment := SalesSegment_MP::FindByName( macroPlan, salesSegmentName );
     stockingPoint := StockingPoint_MP::FindById(  macroPlan, stockingPointId );
-    currency := Currency_MP::FindById( macroPlan, currencyId );
+    //currency := Currency_MP::FindById( macroPlan, currencyId );
     unitOfMeasure := null( UnitOfMeasure_MP )
     priority := null( Priority );
     if( unitOfMeasureName <> "" ) {
@@ -38,32 +38,32 @@
     }
     // 妫�鏌ヤ緷璧栭」
     if( isnull( product) ) {
-        error( "product not found" );  
+        info( "product not found" );  
     }
     if( isnull( salesSegment) ) {
-        error( "sales segment not found" );  
+        info( "sales segment not found" );  
     }
     if( isnull( stockingPoint) ) {
-        error( "stock point not found" );  
+        info( "stock point not found" );  
     }
-    if( isnull( currency) ) {
-        error( "currency not found" );  
-    }
+    //if( isnull( currency) ) {
+    //    error( "currency not found" );  
+    //}
     if( unitOfMeasureName <> "" and isnull( unitOfMeasure) ) {
-        error( "unit of measure not found" );  
+        info( "unit of measure not found" );  
     }
     if( priorityName <> "" and isnull( stockingPoint) ) {
-        error( "priority not found" );  
+        info( "priority not found" );  
     }
     // 鏂板/鏇存柊
     result := CustomerOrder::FindById( macroPlan, id );
     if( isnull( result ) ) {
         CustomerOrder::Create( product, stockingPoint, id, orderDate, quantity, price, 
-                               priorityName, salesSegmentName, currency.Name(), unitOfMeasureName, 
+                               priorityName, salesSegmentName, currencyId, unitOfMeasureName, 
                                false, customerName, customerId, orderId, orderLineId, true, true, true );
     } else {
         result.Update( product, stockingPoint, orderDate, quantity, price, 
-                       priorityName, salesSegmentName, currency.Name(), unitOfMeasureName, 
+                       priorityName, salesSegmentName, currencyId, unitOfMeasureName, 
                        false, customerName, customerId, orderId, orderLineId, true, true, true );
     }
     return result;
diff --git a/_Main/BL/Type_Forecast/StaticMethod_CreateOrUpdate.qbl b/_Main/BL/Type_Forecast/StaticMethod_CreateOrUpdate.qbl
index 3c09ae6..a5c8eb8 100644
--- a/_Main/BL/Type_Forecast/StaticMethod_CreateOrUpdate.qbl
+++ b/_Main/BL/Type_Forecast/StaticMethod_CreateOrUpdate.qbl
@@ -55,7 +55,7 @@
     if( isnull( result) ) {
         result := Forecast::Create( product, stockingPoint, id, 
                                     startDate, endDate, quantity, price, 
-                                    priorityName, salesSegmentName, guard( currency.Name(), "" ), unitOfMeasureName, 
+                                    priorityName, salesSegmentName, currencyId, unitOfMeasureName, 
                                     0.0, false, true );
     } else {
         result.Update( product, stockingPoint, 
diff --git a/_Main/BL/Type_InventoryValueAndCost/StaticMethod_CreateOrUpdate.qbl b/_Main/BL/Type_InventoryValueAndCost/StaticMethod_CreateOrUpdate.qbl
index 4c0470e..4116cce 100644
--- a/_Main/BL/Type_InventoryValueAndCost/StaticMethod_CreateOrUpdate.qbl
+++ b/_Main/BL/Type_InventoryValueAndCost/StaticMethod_CreateOrUpdate.qbl
@@ -23,23 +23,27 @@
     product := Product_MP::FindById( macroPlan, productId );
     stockingPoint := StockingPoint_MP::FindById( macroPlan, stockingPointId );
     account := Account_MP::FindByName( macroPlan, accountName );
-    if( isnull( product ) ) {
-        error( "product not found" );  
-    }
-    if( isnull( stockingPoint ) ) {
-        error( "stocking point not found" );  
-    }
-    if( isnull( account ) ) {
-        error( "account not found" );  
-    }
-    result := InventoryValueAndCost::FindById( macroPlan, id );
-    if( isnull( result ) ) {
+    //if( isnull( product ) ) {
+    //    error( "product not found" );  
+    //}
+    //if( isnull( stockingPoint ) ) {
+    //    error( "stocking point not found" );  
+    //}
+    //if( isnull( account ) ) {
+    //    error( "account not found" );  
+    //}
+    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 ) {
-        error( "cannot change product of inventory value and cost" )
-    } else {
-        result.Update( account, costDriver, start, account.DefaultTimeUnit(), account.DefaultLengthOfTime(), cost, true );
+      } 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 );
+    //  }
     }
+    
     return result;
   *]
 }
diff --git a/_Main/BL/Type_InventoryValueAndCost/StaticMethod_FindById.qbl b/_Main/BL/Type_InventoryValueAndCost/StaticMethod_FindById.qbl
index b0dc53e..133145d 100644
--- a/_Main/BL/Type_InventoryValueAndCost/StaticMethod_FindById.qbl
+++ b/_Main/BL/Type_InventoryValueAndCost/StaticMethod_FindById.qbl
@@ -2,13 +2,16 @@
 #parent: #root
 StaticMethod FindById (
   MacroPlan macroPlan,
+  String productId,
+  String stockPointId,
+  Date start,
   String id
 ) as InventoryValueAndCost
 {
   TextBody:
   [*
     // yypsybs Aug-16-2023 (created)
-    value := select( macroPlan, Product_MP.InventoryValueAndCost, item, true, item.ID() = id );
+    value := select( macroPlan, Product_MP.InventoryValueAndCost, item, true, item.ProductID()=productId and item.StockingPointID() = stockPointId and item.Start() = start );
     return value;
   *]
 }
diff --git a/_Main/BL/Type_Lane/StaticMethod_CreateLane.qbl b/_Main/BL/Type_Lane/StaticMethod_CreateLane.qbl
index d78931a..64c72eb 100644
--- a/_Main/BL/Type_Lane/StaticMethod_CreateLane.qbl
+++ b/_Main/BL/Type_Lane/StaticMethod_CreateLane.qbl
@@ -12,7 +12,7 @@
   [*
     // Administrator Jul-12-2023 (created)
     //Set default value
-    isenabled := false;
+    isenabled := true;
     datestart := Date::Construct(1900, 1, 1) ;
     dateend := Date::Construct(9999, 12, 31);
     standardleadtime := Duration::Zero();
diff --git a/_Main/BL/Type_MacroPlan/Method_InitialUnitAndStockingPoint.qbl b/_Main/BL/Type_MacroPlan/Method_InitialUnitAndStockingPoint.qbl
index b8b0705..d030255 100644
--- a/_Main/BL/Type_MacroPlan/Method_InitialUnitAndStockingPoint.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_InitialUnitAndStockingPoint.qbl
@@ -11,7 +11,7 @@
     currencyid := "CNY";
     startdate := Date::Date( 1900, 1, 1 );
     enddate := Date::Date( 9999, 12, 31 );
-    capacitytype := "Infinite";
+    capacitytype := "Transport quantity";
     
     if( isnull( Unit::FindById( this, "绌鸿繍" ) ) ){
       this.Unit( relnew, 
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl
index 87cbdf3..f9cd042 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl
@@ -9,7 +9,7 @@
   [*
     // renhao Aug-14-2023 (created)
     date := Date :: Today();
-    listtodeal := selectset( this,MappingActualPISPIP,actual,not isnull( Product_MP::FindById( this, actual.ProductID() ) ) );
+    listtodeal := selectset( this,MappingActualPISPIP,actual,true );
     totalcount := listtodeal.Size();
     info( "ActualPISPIP has " + totalcount.AsQUILL() + " rows in total" );
     
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
index 7295bad..ea2ad61 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
@@ -9,15 +9,14 @@
   [*
     // renhao Aug-14-2023 (created)
     
-    listtodeal := selectset( this,MappingExternalSupply,externalSupply, 
-                             not isnull( StockingPoint_MP::FindById( this, externalSupply.StockingPointID() ) ) and not isnull( Product_MP::FindById( this, externalSupply.ProductID() ) ) );
+    listtodeal := selectset( this,MappingExternalSupply,externalSupply, true );
     totalcount := listtodeal.Size();
     info( "ExternalSupply has " + totalcount.AsQUILL() + " rows in total" );
     
     count := 0;
     traverse( listtodeal,Elements,externalSupply){
       count := count + 1;
-      if( count - [Number](count/100) * 100 = 0 or count = totalcount ){
+      if( count - [Number](count/1000) * 1000 = 0 or count = totalcount ){
         info( "Now is dealing with the " + count.AsQUILL() + "ExternalSupply " + "( " + count.AsQUILL() + "/" + totalcount.AsQUILL() + " ) " + (count/totalcount*100).Round( 1 ).AsQUILL() + "%" );
         }
       product := select( this,MappingProduct,product,product.ID() = externalSupply.ProductID() and product.KeyProduct() = nuclear,true);
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingInventoryValueAndCostData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingInventoryValueAndCostData.qbl
index 2138aae..0789263 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingInventoryValueAndCostData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingInventoryValueAndCostData.qbl
@@ -5,23 +5,26 @@
   TextBody:
   [*
     // yypsybs Aug-15-2023 (created)
-    listtodeal := selectset( this,MappingInventoryValueAndCost,item,not isnull( Product_MP::FindById( this, item.ProductID() ) ), not isnull( StockingPoint_MP::FindById( this, item.StockingPointID() ) ) );
+    listtodeal := selectset( this,MappingInventoryValueAndCost,item,true );
     totalcount := listtodeal.Size();
+    
     info( "InventoryCost has " + totalcount.AsQUILL() + " rows in total" );
     
     count := 0;
     traverse( listtodeal, Elements, item ) {
-      count := count + 1;
-      if( count - [Number](count/100) * 100 = 0 or count = totalcount ){
-        info( "Now is dealing with the " + count.AsQUILL() + "InventoryCost " + "( " + count.AsQUILL() + "/" + totalcount.AsQUILL() + " ) " + (count/totalcount*100).Round( 1 ).AsQUILL() + "%" );
+        count := count + 1;
+        if( count - [Number](count/1000) * 1000 = 0 or count = totalcount ){
+          info( "Now is dealing with the " + count.AsQUILL() + "InventoryCost " + "( " + count.AsQUILL() + "/" + totalcount.AsQUILL() + " ) " + (count/totalcount*100).Round( 1 ).AsQUILL() + "%" );
         }
-      if( not isnull( Product_MP::FindById( this, item.ProductID() ) ) ){
-          InventoryValueAndCost::CreateOrUpdate( this, item.ID(), item.ProductID(), 
+        
+        InventoryValueAndCost::CreateOrUpdate( this, item.ID(), item.ProductID(), 
                                                  item.StockingPointID(), 
-                                                 item.AccountName(), item.CostDriver(), item.Start(), item.Cost() );
-      }else{
-        info( "invaild product: " + item.ProductID().AsQUILL() );
-        }
+                                                 item.AccountName(), item.CostDriver(), item.Start(), item.Cost());
+    //  if( not isnull( Product_MP::FindProductTypeIndex( item.ProductID() ) )  and not isnull( StockingPoint_MP :: FindStockingPointTypeIndex( item.StockingPointID()))){
+    //      
+    //  }else{
+    //    info( "invaild product: " + item.ProductID().AsQUILL() );
+    //    }
     }
   *]
 }
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl
index 93b5707..892f5ef 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl
@@ -17,7 +17,8 @@
     bomList := selectsortedset(  this, MappingBOM, item,
                                  ifexpr( isnull( businessTypes ) or businessTypes.Size() = 0, 
                                          true, 
-                                         businessTypes.Difference( businessTypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0 )
+    //                                     businessTypes.Difference( businessTypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0 )
+                                         businessTypes.Find( item.BusinessType() ) >= 0 )
                                  and ifexpr( isKeyProduct, 
                                              keyProductList.Size() > 0 and keyProductList.Find( item.ComponentCode() ) >= 0,
                                              true ),
@@ -28,19 +29,19 @@
         routingRows := selectset( bomList, Elements, item, true, routingId = item.OrganCode() + "_" + item.ProductCode() );
         if( routingRows.Size() > 0 ) {
             firstRow := routingRows.Element( 0 );
-            stockingPointId := firstRow.OrganCode()  + "_" + firstRow.ProductType() + "_STOCK";
-            inputStockingPointId := firstRow.OrganCode()  + "_" + firstRow.ComponentType() + "_STOCK";
+            stockingPointId := firstRow.OrganCode()  + "_" + firstRow.ProductType() + "_Stock";
+            inputStockingPointId := firstRow.OrganCode()  + "_" + firstRow.ComponentType() + "_Stock";
             // ========妫�鏌�========
-            product := Product_MP::FindById( this, firstRow.ProductCode() );
+            product := Product_MP::FindProductTypeIndex( firstRow.ProductCode() );
             if( not isnull( product ) ) {
     //              error( "product : " + firstRow.ProductCode() + " not found" );
-              stockingPoint := StockingPoint_MP::FindById( this, stockingPointId );
-              inputStockingPoint := StockingPoint_MP::FindById( this, inputStockingPointId );
+              stockingPoint := StockingPoint_MP::FindStockingPointTypeIndex( stockingPointId );
+              inputStockingPoint := StockingPoint_MP::FindStockingPointTypeIndex(  inputStockingPointId );
     //          info( stockingPointId.AsQUILL() );
       //        if( isnull( stockingPoint ) ) {
       //            error( "stockingPoint : " + stockingPointId + " not found" );
       //        }
-              routing := Routing::FindById( this, routingId );
+              routing := Routing::FindRoutingTypeIndex(  routingId );
               if( not isnull( routing ) ) {
     //              error( "routing : " + routingId + " not found" );
                 // ========澶勭悊杈撳嚭========
diff --git "a/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataRouting\043576.qbl" "b/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataRouting\043576.qbl"
index 03a3858..059c6c9 100644
--- "a/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataRouting\043576.qbl"
+++ "b/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataRouting\043576.qbl"
@@ -67,7 +67,7 @@
                         alterProd := Product_MP::FindById( this, alterRow.AlternativeMaterialCode() );
                         if( not isnull( alterProd ) ) {
         //                    error( "alterProd : " + alterRow.AlternativeMaterialCode() + " not found" );
-                          stockingPointIdAlter := alterRow.OrganCode()  + "_" + alterRow.ProductType() + "_STOCK";
+                          stockingPointIdAlter := alterRow.OrganCode()  + "_" + alterRow.ProductType() + "_Stock";
                           stockingPointAlter := StockingPoint_MP::FindById( this, stockingPointIdAlter );
                           if( isnull( stockingPointAlter ) ) {
                               error( "stockingPoint : " + stockingPointIdAlter + " not found" );
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataSupplyPurchase.qbl b/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataSupplyPurchase.qbl
index ab499a8..6a24698 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataSupplyPurchase.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataSupplyPurchase.qbl
@@ -18,28 +18,35 @@
     routingStep := RoutingStep::Create( routing, routingStepName, "", true );
     product := Product_MP::FindById( this, productId );
     if( isnull( product ) ) {
-        error( "product : " + productId + " not found" );
+        info(  "product : " + productId + " not found" );
     }
     stockingPointId := orgCode + "_" + productType + "_Stock";
     stockingPoint := StockingPoint_MP::FindById( this, stockingPointId );
     if( isnull( stockingPoint ) ) {
-        error( "stockingPoint : " + stockingPointId + " not found" );
+        info( "stockingPoint : " + stockingPointId + " not found" );
     }
-    unit := Unit::FindById( this, unitId );
-    if( isnull( unit ) ) {
+    
+    if( not isnull( product) and not isnull( stockingPoint)){
+      unit := Unit::FindById( this, unitId );
+      if( isnull( unit ) ) {
         unit := this.Unit( relnew, 
                           ID := unitId, Name := unitId, CapacityType := "Infinite",
                           DefaultGridX := 0, DefaultGridY := 0,
                           IsManuallyConfigured := false,
                           Currency_MP := this.BaseCurrency(), UnitOfMeasure_MP := this.DefaultUnitOfMeasure() );
-    }
+      }
     // Operation
-    operation := Operation::Create( operationId, unit, operationId, routingStep, 
+      operation := Operation::FindOperationTypeIndex( operationId);
+      if( isnull( operation)){
+        operation := Operation::Create( operationId, unit, operationId, routingStep, 
                                     Duration::Zero(), Duration::Zero(), 1.0, false, 
                                     Real::MinReal(), false, Real::MaxReal(), 
                                     0.0, 0.0, false, true );
     // OperaionBom
-    operation.CreateOperationBOM( product, stockingPoint, false, true );
-    operation.GetOperationBOM( product.ID(), stockingPoint.ID(), false ).Quantity( 1 );
+        operation.CreateOperationBOM( product, stockingPoint, false, true );
+        operation.GetOperationBOM( product.ID(), stockingPoint.ID(), false ).Quantity( 1 );
+      }
+      
+    }
   *]
 }
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl
index 3a315d0..98be129 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl
@@ -38,7 +38,7 @@
     // Get the operation cost data
     traverse( listtodealwithmaxsn, Elements, item ){
       count := count + 1;
-      if( count - [Number](count/100) * 100 = 0 or count = totalcount ){
+      if( count - [Number](count/1000) * 1000 = 0 or count = totalcount ){
         info( "Now is dealing with the " + count.AsQUILL() + "OperationCost " + "( " + count.AsQUILL() + "/" + totalcount.AsQUILL() + " ) " + (count/totalcount*100).Round( 1 ).AsQUILL() + "%" );
         }
       id := item.OrganCode() + "_" + item.ProductID() + "_" + item.ProcessSection() + "_" + item.Line();
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingOperationData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingOperationData.qbl
index a3a19ed..07e9838 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingOperationData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingOperationData.qbl
@@ -11,8 +11,8 @@
     toDealList := construct( MappingOperations );
     if( not isnull( businessTypes ) and businessTypes.Size() > 0 ) {
         toDealList := selectsortedset( this, MappingOperation, item, 
-    //                                   businessTypes.Find( item.BusinessType() ) >= 0, 
-                                       businessTypes.Difference( businessTypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0, 
+                                       businessTypes.Find( item.BusinessType() ) >= 0, 
+    //                                   businessTypes.Difference( businessTypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0, 
                                        item.SequenceNumber() );
     } else {
         toDealList := selectsortedset( this, MappingOperation, item, 
@@ -26,7 +26,7 @@
         routingId := item.OrganCode() + "_" + item.ProductID();
         unitId := item.OrganCode() + "_" + item.PlantName() + "_" + item.ProcessSection();
         routingStepName := item.ProcessSection() + "_" + [String]item.SequenceNumber();
-        operationId := item.OrganCode() + "_" + item.ProductID() + "_" + item.ProcessSection();
+        operationId := item.OrganCode() + "_" + item.ProductID() + "_" + item.ProcessSection()+"_" + [String]item.SequenceNumber();
     //    info( "========" )
     //    info( "routingId:" + routingId );
     //    info( "unitId:" + unitId );
@@ -51,15 +51,16 @@
         if( isnull( routingStep ) ) {
             routingStep := RoutingStep::Create( routing, routingStepName, "", true );
         }
-        // UnitOfMeasure
-        unitOfMeasure := UnitOfMeasure_MP::FindByName( this, item.UnitOfMeasureName() );
-        if( isnull( unitOfMeasure ) ) {
-            error( "unit of measure [" + item.UnitOfMeasureName() + "] not found for routing [" + routingId + "]" );
-        }
+        
         // Unit
         unit := Unit::FindById( this, unitId );
         if( isnull( unit ) ) {
-            unit := this.Unit( relnew, 
+          // UnitOfMeasure
+        unitOfMeasure := UnitOfMeasure_MP::FindByName( this, item.UnitOfMeasureName() );
+          if( isnull( unitOfMeasure ) ) {
+              info( "unit of measure [" + item.UnitOfMeasureName() + "] not found for routing [" + routingId + "]" );
+          }
+           unit := this.Unit( relnew, 
                               ID := unitId, Name := unitId, CapacityType := "Infinite",
                               DefaultGridX := 0, DefaultGridY := 0,
                               IsManuallyConfigured := false,
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingProductData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingProductData.qbl
index cb6a99d..fa5aa3b 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingProductData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingProductData.qbl
@@ -22,10 +22,10 @@
           }
     } else {
         if( iskeyproduct = true ){
-          listToDeal := selectset( this, MappingProduct, item, item.KeyProduct() = true, businesstypes.Difference( businesstypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0 );
+          listToDeal := selectset( this, MappingProduct, item, item.KeyProduct() = true,  businesstypes.Find(  item.BusinessType()) > 0 );
           }
         else{
-        listToDeal := selectset( this, MappingProduct, item, businesstypes.Difference( businesstypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0 );
+        listToDeal := selectset( this, MappingProduct, item, businesstypes.Find(  item.BusinessType()) > 0 );
         }
     }
     totalcount := listToDeal.Size();
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingProductInLaneData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingProductInLaneData.qbl
index 2bd20a4..2d63310 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingProductInLaneData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingProductInLaneData.qbl
@@ -7,7 +7,7 @@
   [*
     // Administrator Aug-17-2023 (created)
     // list to deal
-    listtodeal := selectset( this, MappingProductInLane, item, not isnull( Product_MP::FindById( this, item.ProductID() ) ), not isnull( Lane::FindLaneTypeIndex( item.LineID() ) ) );
+    listtodeal := selectset( this, MappingProductInLane, item ,true );
     totalcount := listtodeal.Size();
     info( "ProductInLane has " + totalcount.AsQUILL() + " rows in total" );
     
@@ -15,7 +15,7 @@
     // Create ProductInLane
     traverse( listtodeal, Elements, item ){
       count := count + 1;
-      if( count - [Number](count/100) * 100 = 0 or count = totalcount ){
+      if( count - [Number](count/1000) * 1000 = 0 or count = totalcount ){
         info( "Now is dealing with the " + count.AsQUILL() + "ProductInLane " + "( " + count.AsQUILL() + "/" + totalcount.AsQUILL() + " ) " + (count/totalcount*100).Round( 1 ).AsQUILL() + "%" );
         }
       ProductInLane::CreateOrUpdate( this, item.ProductID(), item.LineID() );
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingUnitData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingUnitData.qbl
index fa613b6..b5618c6 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingUnitData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingUnitData.qbl
@@ -15,13 +15,14 @@
         listtodeal := selectset( this, MappingOperation, item, true );
     } else {
         listtodeal := selectset( this, MappingOperation, item, 
-                                 businesstypes.Difference( businesstypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0
-                                  );
+    //                             businesstypes.Difference( businesstypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0
+                                 businesstypes.Find( item.BusinessType() ) >= 0
+                                );
     }
     
     //Set the Default values
     unitofmeasurename := "PCS";
-    capacitytype := "Infinite";
+    capacitytype := "Transport quantity";
     
     // Get the root data
     Unit::CreateOrUpdate( this, 
diff --git a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
index dc5d8d6..fe4e7a1 100644
--- a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
+++ b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
@@ -67,7 +67,7 @@
     macroPlan.Broker_OTD_Product().Execute();
     info( "Product Data Broker Finished, Start Product Mapping" );
     //testproduct := construct( Strings );
-    macroPlan.MappingProductData( businessTypes, false );
+    macroPlan.MappingProductData( businessTypes, isKeyProduct );
     
     //鍗曚綅杞崲-7
     BaseConversionFactor::DoSync( macroPlan );
@@ -107,31 +107,31 @@
     data := macroPlan.ApiResponesCheck( address, url, port, postrequestbody );
     macroPlan.ApiLaneLegsData( data );
     
-    //// 渚涘簲缃戠粶锛堣溅閬擄級-12
-    //info( "Get Lanelegs From Api Finished, Start ProductInLane Data Broker" );
-    //macroPlan.Broker_OTD_ProductInLane().Execute();
-    //info( "ProductInLane Data Broker Finished, Start ProductInLane Mapping" );
-    //macroPlan.MappingProductInLaneData();
+    // 渚涘簲缃戠粶锛堣溅閬擄級-12
+    info( "Get Lanelegs From Api Finished, Start ProductInLane Data Broker" );
+    macroPlan.Broker_OTD_ProductInLane().Execute();
+    info( "ProductInLane Data Broker Finished, Start ProductInLane Mapping" );
+    macroPlan.MappingProductInLaneData();
     
     // 鍦ㄥ簱搴撳瓨鏁版嵁-13
     info( "ProductInLane Finished, Start ActualPISPIP Data Broker" );
     macroPlan.Broker_OTD_ActualPISPIP().Execute();
     info( "ActualPISPIP Data Broker Finished, Start ActualPISPIP Mapping" );
     //macroPlan.MappingActualPISPIPData( businessTypes, true );
-    macroPlan.MappingActualPISPIPData( businessTypes, false );
+    macroPlan.MappingActualPISPIPData( businessTypes, isKeyProduct );
     
     // 鍦ㄩ�斿簱瀛�-14
     info( "ActualPISPIP Finished, Start ExternalSupply Data Broker" );
     macroPlan.Broker_OTD_ExternalSupply().Execute();
     //macroPlan.MappingExternalSupplyData( businessTypes, true );
     info( "ExternalSupply Data Broker Finished, Start ExternalSupply Mapping" );
-    macroPlan.MappingExternalSupplyData( businessTypes, false );
+    macroPlan.MappingExternalSupplyData( businessTypes, isKeyProduct );
     
     // 搴撳瓨鎴愭湰-15
     InventoryValueAndCost::DoSync( macroPlan );
     
-    //// todo 鍒堕�犳垚鏈�-16
-    //info( "InventoryCost Finished, Start OperationCost Mapping" );
+    // todo 鍒堕�犳垚鏈�-16
+    info( "InventoryCost Finished, Start OperationCost Mapping" );
     //macroPlan.MappingOperationCostData( businessTypes );
     
     // 璁㈠崟棰勬祴-17
diff --git a/_Main/BL/Type_ProductInLane/StaticMethod_CreateOrUpdate.qbl b/_Main/BL/Type_ProductInLane/StaticMethod_CreateOrUpdate.qbl
index 0db749e..0359b3f 100644
--- a/_Main/BL/Type_ProductInLane/StaticMethod_CreateOrUpdate.qbl
+++ b/_Main/BL/Type_ProductInLane/StaticMethod_CreateOrUpdate.qbl
@@ -17,12 +17,14 @@
     product :=  Product_MP::FindById( owner, productid );
     line :=  Lane::FindLaneTypeIndex( lineid );
     
-    productinline := ProductInLane::FindProductInLaneTypeIndex( lineid, productid );
+    if( not isnull( product) and not isnull( line)){
+      productinline := ProductInLane::FindProductInLaneTypeIndex( lineid, productid );
     
-    if( isnull( productinline ) ){
+      if( isnull( productinline ) ){
       ProductInLane::Create( product, line, isexcluded, isfromdb );
       }else{
-        productinline.Update( productid, lineid, isexcluded, isfromdb );
+       productinline.Update( productid, lineid, isexcluded, isfromdb );
         }
+    }
   *]
 }
diff --git a/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpointFromJson.qbl b/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpointFromJson.qbl
index 1859d28..e4dae0e 100644
--- a/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpointFromJson.qbl
+++ b/_Main/BL/Type_StockingPoint_MP/StaticMethod_CreateStockingpointFromJson.qbl
@@ -9,7 +9,7 @@
   TextBody:
   [*
     // Administrator Jul-7-2023 (created)
-    id := datarow.Get( "id" ).GetString()+"_STOCK";
+    id := datarow.Get( "id" ).GetString();
     unitid := datarow.Get( "unitid" ).GetString();
     name := datarow.Get( "name" ).GetString();
     
diff --git a/_var/_Main/ModelSettings/Common/Development/_ROOT_Role_Development.properties b/_var/_Main/ModelSettings/Common/Development/_ROOT_Role_Development.properties
index 5ecdbaf..2ba12ee 100644
--- a/_var/_Main/ModelSettings/Common/Development/_ROOT_Role_Development.properties
+++ b/_var/_Main/ModelSettings/Common/Development/_ROOT_Role_Development.properties
@@ -461,7 +461,7 @@
 domainmodel.mdsstoragedefinitionmanager=template:domainmodel.mdsstoragedefinitionmanager
 domainmodel.mdsstoragedefinitionmanager.audittrailenabled=false
 domainmodel.mdsstoragedefinitionmanager.audittraillocation=
-domainmodel.mdsstoragedefinitionmanager.databaseenabled=false
+domainmodel.mdsstoragedefinitionmanager.databaseenabled=true
 domainmodel.mdsstoragedefinitionmanager.datasetstoredatasource=MacroPlanner
 domainmodel.mdsstoragedefinitionmanager.datasetstoreenabled=false
 domainmodel.mdsstoragedefinitionmanager.datasetstoreislocal=false
@@ -475,11 +475,11 @@
 domainmodel.mdsstoragedefinitionmanager.name=dbodbc1
 domainmodel.mdsstoragedefinitionmanager.ociconnectionbasichost=10.110.14.50
 domainmodel.mdsstoragedefinitionmanager.ociconnectionbasicport=1521
-domainmodel.mdsstoragedefinitionmanager.ociconnectionbasicservice=totddb
+domainmodel.mdsstoragedefinitionmanager.ociconnectionbasicservice=totddb_jtmb
 domainmodel.mdsstoragedefinitionmanager.ociconnectiontnsname=totddb
 domainmodel.mdsstoragedefinitionmanager.ociconnectiontype=Basic
-domainmodel.mdsstoragedefinitionmanager.parameters=/datasource=MacroPlannerInternalDB /user=otd
-domainmodel.mdsstoragedefinitionmanager.password=1 65BA9039C6C6A82BFEAA7408A8F96867 d5a0fc9a-a372-4807-9f03-34bcf85e582d
+domainmodel.mdsstoragedefinitionmanager.parameters=/datasource=MacroPlannerInternalDB /user=OTDJTMBUSER
+domainmodel.mdsstoragedefinitionmanager.password=1 463752FBAC1C9172263ADBF875F4CBF3 d5a0fc9a-a372-4807-9f03-34bcf85e582d
 domainmodel.soapclientinterfacedefinition.interface.libdef_soapclients=template:domainmodel.soapclientinterfacedefinition
 domainmodel.soapclientinterfacedefinition.interface.libdef_soapclients.datasetkind=
 domainmodel.soapclientinterfacedefinition.interface.libdef_soapclients.datasetname=

--
Gitblit v1.9.3