From ae5ea57221f6bab29d84e8c58042a07130befcc8 Mon Sep 17 00:00:00 2001
From: hongji.li <hongji.a.li@capgemini.com>
Date: 星期二, 24 十月 2023 15:33:18 +0800
Subject: [PATCH] 异步分发优化

---
 _Main/BL/Type_MacroPlan/Method_DoASyncMappingExternalSupplyData.qbl |   33 +++++++++++++++++++++++----------
 1 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/_Main/BL/Type_MacroPlan/Method_DoASyncMappingExternalSupplyData.qbl b/_Main/BL/Type_MacroPlan/Method_DoASyncMappingExternalSupplyData.qbl
index e8950bc..6596139 100644
--- a/_Main/BL/Type_MacroPlan/Method_DoASyncMappingExternalSupplyData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_DoASyncMappingExternalSupplyData.qbl
@@ -12,12 +12,25 @@
     // 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() );
-    listtodeal := selectset( globalOTDTable,
-                             Global_MappingInventorySupply,
-                             externalSupply, 
-                             ( externalSupply.UserQuantity()>0 ) and 
-                             ( externalSupply.Date() >= queryStartDate ) and 
-                             ( organcodelist.Find( externalSupply.StockingPointID().SubString( 0, 3 ) ) >= 0 )/*and externalSupply.Date() <= queryEndDate*/);
+    
+    listtodeal := construct( Global_MappingInventorySupplys, constcontent );
+    if ( businessTypes.Size() > 0 ) {
+      businessTypeName := businessTypes.Element( 0 );
+      targetGlobal_ProductCategory := select( globalOTDTable, Global_ProductCategory, tempGPC, tempGPC.BusinessTypeName() = businessTypeName );
+      listtodeal := selectset( targetGlobal_ProductCategory, Global_MappingProduct_MP.Global_InventorySupplyCategory.Global_MappingInventorySupply, 
+                               tempGMIS, 
+                               ( tempGMIS.UserQuantity()>0 ) and 
+                               ( tempGMIS.Date() >= queryStartDate ) and 
+                               ( organcodelist.Find( tempGMIS.StockingPointID().SubString( 0, 3 ) ) >= 0 ) );
+    } else {
+      listtodeal := selectset( globalOTDTable,
+                               Global_MappingInventorySupply,
+                               externalSupply, 
+                               ( externalSupply.UserQuantity()>0 ) and 
+                               ( externalSupply.Date() >= queryStartDate ) and 
+                               ( organcodelist.Find( externalSupply.StockingPointID().SubString( 0, 3 ) ) >= 0 )/*and externalSupply.Date() <= queryEndDate*/);
+    }
+    
     totalcount := listtodeal.Size();
     description := "鍦ㄩ�斿湪鍒�";
     info( "ExternalSupply has " + totalcount.AsQUILL() + " rows in total" );
@@ -28,18 +41,18 @@
       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( globalOTDTable,Global_MappingProduct_MP,product,product.ID() = externalSupply.ProductID(),true);
+      //product := select( globalOTDTable,Global_MappingProduct_MP,product,product.ID() = externalSupply.ProductID(),true);
       
       
-      if( not isnull( product)){
+      if( /*not isnull( product)*/ not isnull( externalSupply.Global_InventorySupplyCategory() ) ){
         productMP :=  Product_MP :: FindProductTypeIndex( externalSupply.ProductID());
         stockingpoint := select( this,StockingPoint_MP,st,st.ID() = externalSupply.StockingPointID(),true);
         if( not isnull( stockingpoint) and not isnull( productMP)){
         if( not isnull(businessTypes)){
         
           for( i :=0 ;i < businessTypes.Size();i++ ){
-            businessType := businessTypes.Element( i );
-            if( product.BusinessType() = businessType and not product.IsCommon()){
+            //businessType := businessTypes.Element( i );
+            if( /*product.BusinessType() = businessType and not product.IsCommon()*/ not externalSupply.Global_InventorySupplyCategory().IsCommon() ){
               InventorySupply::CreateOrUpdate( externalSupply.ID(),
                                                productMP,
                                                stockingpoint,

--
Gitblit v1.9.3