rislai
2024-08-16 bcd7eb876bff759f6aef96f1014b0bca7a3322ff
_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl
@@ -32,7 +32,8 @@
    table.GenerateColumn( owner );
    
    //首先在forecast界面查找sales segment为长春的所有需求,识别出MLB的所有产品,每个产品按月汇总需求数量
    traverse( owner, SalesDemand.astype( Forecast ), forecast, forecast.StartDate() < startofnextyear ){
    traverse( owner, SalesDemand.astype( Forecast ), forecast, not isnull( forecast.SalesSegment_MP() ) and forecast.StartDate() < startofnextyear and forecast.Quantity() <> 0
              and exists( forecast, PlanningSalesDemandInPeriod, psdip, psdip.Quantity() <> 0 ) ){
      salessegment            := forecast.SalesSegment_MP();
      parentsalessegments     := salessegment.GetAllParent();
      //是否属于长春
@@ -46,20 +47,18 @@
      if( ( iscc and forecast.Product_MP().MQBMLB() = 'MLB' ) or isdl ){
        product              := forecast.Product_MP();
        //获取合计行
        allrow               := table.GetRow( allunit, product.ID() );
        allrow               := table.GetRow( allunit, product );
        //获取工厂行
        factoryrow           := table.GetRow( ifexpr( iscc and forecast.Product_MP().MQBMLB() = 'MLB', ccunit, dlunit ), product.ID() );
        factoryrow           := table.GetRow( ifexpr( iscc and forecast.Product_MP().MQBMLB() = 'MLB', ccunit, dlunit ), product );
      
        if( products.Find( product ) < 0 ){
          products.Add( product );
        }
        traverse( forecast, PlanningSalesDemandInPeriod, psdip ){
        products.Add( product );
        traverse( forecast, PlanningSalesDemandInPeriod, psdip, psdip.Quantity() <> 0 ){
          periodtime         := psdip.StartDate().StartOfMonth();
          periodname         := periodtime.Format( "M2/D2/Y" );
    //      info( '-------------------------', periodname, periodtime );
          column             := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime );
    //      info( '-------------------------', column.Name() );
          quantity   := ceil( psdip.Quantity() );//向上取整
          quantity   := [Number]psdip.Quantity();//四舍五入
          
          factoryrow.Initialize( column, quantity );
          allrow.Initialize( column, quantity );
@@ -73,14 +72,17 @@
      //是否属于长春装配线
    //  iscc                  := unit.ID() = ccspline or exists( parentunits, Elements, punit, punit.ID() = ccspline );
      if( table.IsInUnit( stockingpoint, ccspline ) ){
        traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() and pisp.Product_MP().MQBMLB() = 'MQB' ){//产品为MQB
          allrow            := table.GetRow( allunit, pisp.ProductID() );
          ccrow             := table.GetRow( ccunit, pisp.ProductID() );
          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear ){
        traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() and pisp.Product_MP().MQBMLB() = 'MQB'
                  and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.DependentDemandAndSalesDemandQuantity() <> 0 ) ){//产品为MQB
          product           := pisp.Product_MP();
          allrow            := table.GetRow( allunit, product );
          ccrow             := table.GetRow( ccunit, product );
          products.Add( product );
          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.DependentDemandAndSalesDemandQuantity() <> 0 ){
            periodtime      := pispip.Start().StartOfMonth().Date();
            periodname      := periodtime.Format( "M2/D2/Y" );
            column          := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime );
            quantity        := ceil( pispip.DependentDemandAndSalesDemandQuantity() );//向上取整
            quantity        := [Number]pispip.DependentDemandAndSalesDemandQuantity();//四舍五入
            
            ccrow.Initialize( column, quantity );//取Total Demand字段按月汇总需求数量
            allrow.Initialize( column, quantity );
@@ -98,18 +100,23 @@
      destisp               := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.DestinationStockingPointID() );
      isccrent              := table.IsInUnit( destisp, ccrent );
      if( isdlspline and isccrent ){
        traverse( laneleg, Trip, trip, trip.Arrival() < startofnextyearlead ){
          periodtime        := ( trip.Arrival() - FinancialSalesReport::GetDefaultTripLeadingTime() ).StartOfMonth().Date();
        traverse( laneleg, Trip, trip, trip.Arrival() < startofnextyearlead and exists( trip, ProductInTrip, pit, pit.Quantity() <> 0 ) ){
    //      periodtime        := ( trip.Arrival() - FinancialSalesReport::GetDefaultTripLeadingTime() ).StartOfMonth().Date();
          periodtime        := trip.Departure().StartOfMonth().Date();
          periodname        := periodtime.Format( "M2/D2/Y" );
          
          column            := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime );
          traverse( trip, ProductInTrip, pit ){
            quantity        := ceil( pit.Quantity() );//向上取整
            dlrow           := table.GetRow( dlunit, pit.ProductID() );
            dlrow.Initialize( column, quantity );//汇总数量
            allrow          := table.GetRow( allunit, pit.ProductID() );
            allrow.Initialize( column, quantity );
          if( not isnull( column ) ){
            traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 ){
              product       := pit.Product_MP();
              products.Add( product );
              quantity      := [Number]pit.Quantity();//四舍五入
              dlrow         := table.GetRow( dlunit, pit.Product_MP() );
              dlrow.Initialize( column, quantity );//汇总数量
              allrow        := table.GetRow( allunit, pit.Product_MP() );
              allrow.Initialize( column, quantity );
            }
          }
        }
      }