From e8619d825e5f09daf129b4847bf2bf4e660d40c5 Mon Sep 17 00:00:00 2001
From: yunchai <yunying.chai@capgemini.com>
Date: 星期四, 12 十月 2023 09:29:21 +0800
Subject: [PATCH] Merge remote-tracking branch 'refs/remotes/origin/dev'

---
 _Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
index 875645b..5178d37 100644
--- a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
+++ b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
@@ -15,11 +15,26 @@
     // 甯佺鍜屽竵绉嶆眹鐜�
     //Currency_MP::CreateCurrencyFromJson( macroPlan, jsonDataRow );
     info( "Prepare to do sync" )
+    info( "Get organ code list" )
+    organcodelist := selectvalues( globalOTDTable, Global_MappingOperationBOM, bom,true, bom.OrganCode() );
     if( not isnull( businessTypes ) and businessTypes.Size() > 0 ) {
         traverse( businessTypes, Elements, item ) {
             info( "Business type : " + item )  
         }
+        organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, businessTypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() );
     }
+    else{
+      if( businessTypes.Size() = 0 ){
+        if( not isnull( selectset( globalOTDTable, BusinessType, b, b.BusinessTypeName() = "" ) ) ){
+          organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, organ.BusinessType().BusinessTypeName() = "", organ.OrganCodeName() );
+          }
+        }
+      }
+    
+    if( organcodelist.Size() = 0 ){
+      organcodelist := selectvalues( globalOTDTable, Global_MappingOperationBOM, bom,true, bom.OrganCode() );
+      }
+    
     info( "KeyProduct : " + [String]isKeyProduct )
     info( "Create purchase supply material : " + [String]createPurchaseSupplyMaterial )
     
@@ -38,7 +53,7 @@
     //info( "BaseConversionFactor Finished, Start Operation Data Broker" );
     //macroPlan.Broker_OTD_Operation().Execute();
     info( "Operation Data Broker Finished, Start Unit Mapping" );
-    macroPlan.MappingUnitData( businessTypes ,globalOTDTable);
+    macroPlan.MappingUnitData( businessTypes ,globalOTDTable, organcodelist);
     
     // 搴撳瓨鐐�-3
     info( "Sales Segment Finished, Start Get StockingPoint From Api" )
@@ -82,11 +97,11 @@
     
     // 宸ヨ壓璺嚎 + BOM-9
     info( "Unit Finished, Start Operation Mapping" );
-    macroPlan.MappingOperationData( businessTypes ,globalOTDTable);  
+    macroPlan.MappingOperationData( businessTypes ,globalOTDTable, organcodelist );  
     //info( "Operation Finished, Start BOM Data Broker" );
     //macroPlan.Broker_OTD_BOM().Execute();
     info( "BOM Data Broker Finished, Start BOM Mapping" );
-    macroPlan.MappingOperationBOMData( businessTypes, isKeyProduct, createPurchaseSupplyMaterial,globalOTDTable );
+    macroPlan.MappingOperationBOMData( businessTypes, isKeyProduct, createPurchaseSupplyMaterial,globalOTDTable, organcodelist );
     
     //杞﹂亾淇℃伅-10
     info( "BOM Finished, Start Get Lanes From Api" );
@@ -118,26 +133,26 @@
     //info( "ProductInLane Finished, Start ActualPISPIP Data Broker" );
     //macroPlan.Broker_OTD_ActualPISPIP().Execute();
     info( "ActualPISPIP Data Broker Finished, Start ActualPISPIP Mapping" );
-    macroPlan.MappingActualPISPIPData( businessTypes, globalOTDTable,isKeyProduct );
+    macroPlan.MappingActualPISPIPData( businessTypes, globalOTDTable,isKeyProduct, organcodelist );
     
     // 鍦ㄩ�斿簱瀛�-14
     //info( "ActualPISPIP Finished, Start ExternalSupply Data Broker" );
     //macroPlan.Broker_OTD_ExternalSupply().Execute();
     info( "ExternalSupply Data Broker Finished, Start ExternalSupply Mapping" );
-    macroPlan.MappingExternalSupplyData( businessTypes, isKeyProduct ,globalOTDTable);
+    macroPlan.MappingExternalSupplyData( businessTypes, isKeyProduct ,globalOTDTable, organcodelist );
     
     // 搴撳瓨鎴愭湰-15
     InventoryValueAndCost::DoSync( macroPlan,globalOTDTable );
     
     // todo 鍒堕�犳垚鏈�-16
     info( "InventoryCost Finished, Start OperationCost Mapping" );
-    macroPlan.MappingOperationCostData( globalOTDTable, businessTypes );
+    macroPlan.MappingOperationCostData( globalOTDTable, businessTypes, organcodelist );
     
     // 璁㈠崟棰勬祴-17
-    Forecast::DoSync( macroPlan, businessTypes ,globalOTDTable);
+    Forecast::DoSync( macroPlan, businessTypes, globalOTDTable, organcodelist );
     
     // 璁㈠崟闇�姹�-18
-    CustomerOrder::DoSync( macroPlan, businessTypes, globalOTDTable);
+    CustomerOrder::DoSync( macroPlan, businessTypes, globalOTDTable, organcodelist );
     
     //鍒犻櫎澶氫綑鎶ラ敊鏁版嵁-19
     macroPlan.DeleteSnaityCheck();

--
Gitblit v1.9.3