From f3dec8f5b480474c9a3b2ea0fabb0f6b9fdc0423 Mon Sep 17 00:00:00 2001
From: renhao <renhui.hao@capgemini.com>
Date: 星期五, 13 十月 2023 17:11:34 +0800
Subject: [PATCH] Merge branch 'dev'

---
 _Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl |  135 ++++++++++++++++++++++++++++-----------------
 1 files changed, 84 insertions(+), 51 deletions(-)

diff --git a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
index c60c9a8..5178d37 100644
--- a/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
+++ b/_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
@@ -4,7 +4,8 @@
   MacroPlan macroPlan,
   Strings businessTypes,
   Boolean isKeyProduct,
-  Boolean createPurchaseSupplyMaterial
+  Boolean createPurchaseSupplyMaterial,
+  GlobalOTDTable globalOTDTable
 )
 {
   Description: '鍗曟鍚屾'
@@ -14,24 +15,48 @@
     // 甯佺鍜屽竵绉嶆眹鐜�
     //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 )
+    
     // 鍒濆鎹�-0
-    info( "Initial" );
+    info( "Start Initial" );
     macroPlan.InitialUnitAndStockingPoint();
+    
     // 鍗曚綅-1
-    info( "UnitOfMeasure_MP::DoSync" )
-    UnitOfMeasure_MP::DoSync( macroPlan );
+    UnitOfMeasure_MP::DoSync( globalOTDTable,macroPlan );
+    
     // 閿�鍞儴闂�-2
-    info( "SalesSegment::DoSync" )
-    SalesSegment_MP::DoSync( macroPlan, businessTypes );
+    SalesSegment_MP::DoSync( macroPlan, businessTypes,globalOTDTable );
+    
+    // Unit-9 
+    // 涓嶰peration涓�鍚屽鐞�
+    //info( "BaseConversionFactor Finished, Start Operation Data Broker" );
+    //macroPlan.Broker_OTD_Operation().Execute();
+    info( "Operation Data Broker Finished, Start Unit Mapping" );
+    macroPlan.MappingUnitData( businessTypes ,globalOTDTable, organcodelist);
+    
     // 搴撳瓨鐐�-3
-    info( "StockingPoint::DoSync" )
+    info( "Sales Segment Finished, Start Get StockingPoint From Api" )
     bodynumber := "2";
     postrequestbody := macroPlan.ApiBuildPostRequestBody( bodynumber );
     address := "api-uat-sgc.tianma.cn";
@@ -39,8 +64,9 @@
     port := 443;
     data := macroPlan.ApiResponesCheck( address, url, port, postrequestbody );
     macroPlan.ApiStockingPointData( data );
+    
     // 璐у竵淇℃伅-4
-    info( "Currencies::DoSync" )
+    info( "Get StockingPoint From Api Finished, Start Get CurrencyInfo From Api" )
     bodynumber := "1";
     postrequestbody := macroPlan.ApiBuildPostRequestBody( bodynumber );
     address := "api-uat-sgc.tianma.cn";
@@ -48,8 +74,9 @@
     port := 443;
     data := macroPlan.ApiResponesCheck( address, url, port, postrequestbody );
     macroPlan.ApiCurenciesData( data );
+    
     //璐у竵姹囩巼淇℃伅-5
-    info( "CurrencyRates::DoSync" )
+    info( "Get CurrencyInfo From Api Finished, Start Get CurrencyRates From Api" )
     bodynumber := "5";
     postrequestbody := macroPlan.ApiBuildPostRequestBody( bodynumber );
     address := "api-uat-sgc.tianma.cn";
@@ -59,28 +86,25 @@
     macroPlan.ApiCurencyRatesData( data );
     
     // 浜у搧鐗╂枡-6
-    info( "Product::DoSync" )
-    //todo: 鏁版嵁鏈夐噸澶嶏紝鍏堢暐杩�
-    macroPlan.Broker_OTD_Product().Execute();
-    info( "Start data mapping of product" );
-    macroPlan.MappingProductData( businessTypes, false );
+    //info( "Get CurrencyRates From Api Finished, Start Product Data Broker" )
+    //macroPlan.Broker_OTD_Product().Execute();
+    info( "Product Data Broker Finished, Start Product Mapping" );
+    //testproduct := construct( Strings );
+    macroPlan.MappingProductData( businessTypes, globalOTDTable,isKeyProduct );
+    
     //鍗曚綅杞崲-7
-    info( "BaseConversionFactor::DoSync" )
-    BaseConversionFactor::DoSync( macroPlan );
-    // Unit-9 
-    // 涓嶰peration涓�鍚屽鐞�
-    info( "Unit::DoSync" )
-    info( "Start data broker of operation" );
-    macroPlan.Broker_OTD_Operation().Execute();
-    macroPlan.MappingUnitData( businessTypes );
+    BaseConversionFactor::DoSync( macroPlan ,globalOTDTable);
+    
     // 宸ヨ壓璺嚎 + BOM-9
-    info( "Operation&BOM::DoSync" )
-    info( "Start data mapping of operation" );
-    macroPlan.MappingOperationData( businessTypes );  
-    macroPlan.Broker_OTD_BOM().Execute();
-    macroPlan.MappingOperationBOMData( businessTypes, isKeyProduct, createPurchaseSupplyMaterial );
+    info( "Unit Finished, Start Operation Mapping" );
+    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, organcodelist );
+    
     //杞﹂亾淇℃伅-10
-    info( "Lanes::DoSync" )
+    info( "BOM Finished, Start Get Lanes From Api" );
     bodynumber := "3";
     postrequestbody := macroPlan.ApiBuildPostRequestBody( bodynumber );
     address := "api-uat-sgc.tianma.cn";
@@ -88,8 +112,9 @@
     port := 443;
     data := macroPlan.ApiResponesCheck( address, url, port, postrequestbody );
     macroPlan.ApiLanesData( data );
+    
     //杞﹂亾杩愯緭娈�-11
-    info( "LaneLegs::DoSync" )
+    info( "Get Lanes From Api Finished, Start Get LaneLegs From Api" );
     bodynumber := "4";
     postrequestbody := macroPlan.ApiBuildPostRequestBody( bodynumber );
     address := "api-uat-sgc.tianma.cn";
@@ -97,36 +122,44 @@
     port := 443;
     data := macroPlan.ApiResponesCheck( address, url, port, postrequestbody );
     macroPlan.ApiLaneLegsData( data );
+    
     // 渚涘簲缃戠粶锛堣溅閬擄級-12
-    info( "ProductInLane::DoSync" )
-    macroPlan.Broker_OTD_ProductInLane().Execute();
-    macroPlan.MappingProductInLaneData();
+    //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(globalOTDTable);
+    
     // 鍦ㄥ簱搴撳瓨鏁版嵁-13
-    info( "ActualPISPIP::DoSync" )
-    macroPlan.Broker_OTD_ActualPISPIP().Execute();
-    //macroPlan.MappingActualPISPIPData( businessTypes, true );
-    macroPlan.MappingActualPISPIPData( businessTypes, false );
+    //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, organcodelist );
+    
     // 鍦ㄩ�斿簱瀛�-14
-    info( "ExternalSupply::DoSync" )
-    info( "Start data broker of External supply" );
-    macroPlan.Broker_OTD_ExternalSupply().Execute();
-    //macroPlan.MappingExternalSupplyData( businessTypes, true );
-    info( "Start data mapping of External supply" );
-    macroPlan.MappingExternalSupplyData( businessTypes, false );
+    //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, organcodelist );
+    
     // 搴撳瓨鎴愭湰-15
-    info( "InventoryCost::DoSync" );
-    InventoryValueAndCost::DoSync( macroPlan );
-    //// todo 鍒堕�犳垚鏈�-16
-    //info( "OperationCost::DoSync" );
-    //macroPlan.MappingOperationCostData( businessTypes );
+    InventoryValueAndCost::DoSync( macroPlan,globalOTDTable );
+    
+    // todo 鍒堕�犳垚鏈�-16
+    info( "InventoryCost Finished, Start OperationCost Mapping" );
+    macroPlan.MappingOperationCostData( globalOTDTable, businessTypes, organcodelist );
+    
     // 璁㈠崟棰勬祴-17
-    info( "Forecast::DoSync" );
-    Forecast::DoSync( macroPlan, businessTypes );
+    Forecast::DoSync( macroPlan, businessTypes, globalOTDTable, organcodelist );
+    
     // 璁㈠崟闇�姹�-18
-    info( "CustomerOrder::DoSync" );
-    CustomerOrder::DoSync( macroPlan, businessTypes );
+    CustomerOrder::DoSync( macroPlan, businessTypes, globalOTDTable, organcodelist );
+    
+    //鍒犻櫎澶氫綑鎶ラ敊鏁版嵁-19
+    macroPlan.DeleteSnaityCheck();
+    
     //// todo 渚涘簲鍟嗚兘鍔�
     //info( "ProviderCapacity::DoSync" )
+    
     //// todo 渚涘簲鍟嗗洖澶�
     //info( "ProviderReply::DoSync" )
   *]

--
Gitblit v1.9.3