yy
2023-09-25 ab6a21c73e6507923beb22611af772641321c256
_Main/BL/Type_MacroPlan/Method_MappingCustomerOrderData.qbl
@@ -1,7 +1,8 @@
Quintiq file version 2.0
#parent: #root
Method MappingCustomerOrderData (
  Strings businessTypes
  Strings businessTypes,
  GlobalOTDTable globalOTDTable
)
{
  Description: 'ETL订单预测'
@@ -9,15 +10,15 @@
  [*
    // yypsybs Aug-15-2023 (created)
    // 待处理数据
    listToDeal := construct( structured[MappingCustomerOrder] );
    listToDeal := construct( Global_MappingCustomOrders );
    if( isnull( businessTypes ) or businessTypes.Size() = 0 ) {
        listToDeal := selectset( this, MappingCustomerOrder, item, true );
        listToDeal := selectset( globalOTDTable, Global_MappingCustomOrder, item, true );
    } else {
        listToDeal := selectset( this, MappingCustomerOrder, item, businessTypes.Find( item.BusinessType() ) <> -1 );
        listToDeal := selectset( globalOTDTable, Global_MappingCustomOrder, item, businessTypes.Find( item.BusinessType() ) <> -1 );
    }
    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( listToDeal, Elements, item, item.OrderDate() >= queryStartDate /*and item.OrderDate() <= queryEndDate*/, not isnull( Product_MP::FindById( this, item.ProductID() ) ) and not isnull( StockingPoint_MP::FindById( this, item.StockPointID() ) ) and not isnull( SalesSegment_MP::FindByName( this, item.SalesSegmentName() ) ) );
    listToDeal := selectset( listToDeal, Elements, item, item.OrderDate() >= queryStartDate /*and item.OrderDate() <= queryEndDate*/, not isnull( Product_MP::FindById( this, item.ProductID() ) ) and not isnull( StockingPoint_MP::FindById( this, item.StockingPointID() ) ) and not isnull( SalesSegment_MP::FindByName( this, item.SalesSegmentName() ) ) );
    
    totalcount := listToDeal.Size();
    info( "CustomerOrder has " + totalcount.AsQUILL() + " rows in total" );
@@ -35,7 +36,7 @@
      CustomerOrder::CreateOrUpdate( this, item.CurrencyID(), item.Customer(), item.CustomerID(), item.ID(), 
                                     item.OrderDate(), item.OrderID(), item.OrderLineID(), item.Price(), 
                                     priorityName, item.ProductID(), 
                                     item.StockPointID(),
                                     item.StockingPointID(),
                                     item.SalesSegmentName(), 
                                     item.Quantity(), item.UnitOfMeasureName(), item.OrderType(), item.IsAvailable());
    //  }else{