From 1a5a8be205641f5f79dd809f6c7e59fc84d76243 Mon Sep 17 00:00:00 2001
From: yunchai <yunying.chai@capgemini.com>
Date: 星期日, 08 十月 2023 09:11:26 +0800
Subject: [PATCH] Merge remote-tracking branch 'refs/remotes/origin/dev'

---
 _Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
index ead549d..39675d3 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
@@ -2,7 +2,8 @@
 #parent: #root
 Method MappingExternalSupplyData (
   Strings businessTypes,
-  Boolean nuclear
+  Boolean nuclear,
+  GlobalOTDTable globalOTDTable
 )
 {
   TextBody:
@@ -10,7 +11,13 @@
     // 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( this,MappingExternalSupply,externalSupply, externalSupply.UserQuantity()>0 and externalSupply.Date() >= queryStartDate /*and externalSupply.Date() <= queryEndDate*/);
+    organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, businessTypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() );
+    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" );
@@ -21,7 +28,7 @@
       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(),true);
+      product := select( globalOTDTable,Global_MappingProduct_MP,product,product.ID() = externalSupply.ProductID(),true);
       
       
       if( not isnull( product)){
@@ -31,7 +38,7 @@
         if( not isnull(businessTypes)){
         
           for( i :=0 ;i < businessTypes.Size();i++ ){
-            businessType := businessTypes.Element( i);
+            businessType := businessTypes.Element( i );
             if( product.BusinessType() = businessType and not product.IsCommon()){
               InventorySupply::CreateOrUpdate( externalSupply.ID(),
                                                productMP,

--
Gitblit v1.9.3