| Quintiq file version 2.0 | 
| #parent: #root | 
| Method MappingExternalSupplyData ( | 
|   Strings businessTypes, | 
|   Boolean nuclear, | 
|   GlobalOTDTable globalOTDTable | 
| ) | 
| { | 
|   TextBody: | 
|   [* | 
|     // 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 externalSupply.Date() <= queryEndDate*/); | 
|     totalcount := listtodeal.Size(); | 
|     description := "在途在制"; | 
|     info( "ExternalSupply has " + totalcount.AsQUILL() + " rows in total" ); | 
|      | 
|     count := 0; | 
|     traverse( listtodeal,Elements,externalSupply){ | 
|       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( globalOTDTable,Global_MappingProduct_MP,product,product.ID() = externalSupply.ProductID(),true); | 
|        | 
|        | 
|       if( not isnull( product)){ | 
|         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()){ | 
|               InventorySupply::CreateOrUpdate( externalSupply.ID(), | 
|                                                productMP, | 
|                                                stockingpoint, | 
|                                                externalSupply.Date(), | 
|                                                externalSupply.ManufacturedDate(), | 
|                                                externalSupply.UserQuantity(),description); | 
|             } | 
|           } | 
|            | 
|         }else{ | 
|            | 
|             InventorySupply::CreateOrUpdate( externalSupply.ID(), | 
|                                            productMP, | 
|                                            stockingpoint, | 
|                                            externalSupply.Date(), | 
|                                            externalSupply.ManufacturedDate(), | 
|                                            externalSupply.UserQuantity(),description); | 
|           } | 
|        | 
|         } | 
|          | 
|       } | 
|     } | 
|   *] | 
| } |