From 89c96171bb971dcaed7cf289b58ef44ca689523c Mon Sep 17 00:00:00 2001
From: limj <limj@taizhitech.com>
Date: 星期四, 21 九月 2023 09:11:20 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/TIANMA_JITUAN into dev_lmj

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

diff --git a/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
index ea2ad61..ead549d 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
@@ -8,9 +8,11 @@
   TextBody:
   [*
     // renhao Aug-14-2023 (created)
-    
-    listtodeal := selectset( this,MappingExternalSupply,externalSupply, true );
+    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*/);
     totalcount := listtodeal.Size();
+    description := "鍦ㄩ�斿湪鍒�";
     info( "ExternalSupply has " + totalcount.AsQUILL() + " rows in total" );
     
     count := 0;
@@ -18,12 +20,14 @@
       count := count + 1;
       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);
+       }
+      product := select( this,MappingProduct,product,product.ID() = externalSupply.ProductID(),true);
+      
       
       if( not isnull( product)){
-        productMP :=  select( this,Product_MP,productMP,productMP.ID() = externalSupply.ProductID() ,true);
+        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++ ){
@@ -34,25 +38,23 @@
                                                stockingpoint,
                                                externalSupply.Date(),
                                                externalSupply.ManufacturedDate(),
-                                               externalSupply.UserQuantity(),"鍦ㄩ�斿湪鍒�");
+                                               externalSupply.UserQuantity(),description);
             }
           }
           
         }else{
-        if( not isnull( stockingpoint) and not isnull( productMP)){
-          InventorySupply::CreateOrUpdate( externalSupply.ID(),
+          
+            InventorySupply::CreateOrUpdate( externalSupply.ID(),
                                            productMP,
                                            stockingpoint,
                                            externalSupply.Date(),
                                            externalSupply.ManufacturedDate(),
-                                           externalSupply.UserQuantity(),"鍦ㄩ�斿湪鍒�");
-        }
+                                           externalSupply.UserQuantity(),description);
+          }
       
         }
         
-      }else{
-        info( "Invaild product" );
-        }
+      }
     }
   *]
 }

--
Gitblit v1.9.3