lihongji
2024-08-14 d0d4a34072977d5194fb981a23fce67ba1b7eae2
_Main/BL/Type_EnginePipelineSource/StaticMethod_Initialize.qbl
@@ -10,10 +10,11 @@
    owner.EnginePipelineSource( relflush );
    //ccunit                    := EnginePipelineReport::GetDefaultCCUnit();
    //dlunit                    := EnginePipelineReport::GetDefaultDLUnit();
    ccalineunit               := FinancialProductionReport::GetDefaultCCALineUnit();
    dlalienunit               := FinancialProductionReport::GetDefaultDLALineUnit()
    ccmplineunit              := FinancialProductionReport::GetDefaultCCMPLineUnit()
    dlmplineunit              := FinancialProductionReport::GetDefaultDLMPLineUnit();
    productparent             := EnginePipelineReport::GetDefaultProductParent();
    ccalineunit               := EnginePipelineReport::GetDefaultCCALineUnit();
    dlalienunit               := EnginePipelineReport::GetDefaultDLALineUnit()
    ccmplineunit              := EnginePipelineReport::GetDefaultCCMPLineUnit()
    dlmplineunit              := EnginePipelineReport::GetDefaultDLMPLineUnit();
    //allunit                   := EnginePipelineReport::GetDefaultAllUnit();
    source                    := owner.EnginePipelineSource( relnew, Name := EnginePipelineReport::GetDefaultName() );
    table                     := source.Report( relnew, ID := source.Name(), Name := source.Name() );
@@ -35,18 +36,20 @@
      //是否属于大连工厂
      isdl         := unit.ID() = dlalienunit or unit.ID() = dlmplineunit  or exists( parentunits, Elements, punit, punit.ID() = dlalienunit or punit.ID() = dlmplineunit );
      
      traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() and not pisp.IsSystem() ){
        weekstart             := owner.StartOfPlanning().Date();
        pispips               := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical()
                                                  and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day(), pispip.Start() );
      traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() and not pisp.IsSystem()
                and exists( pisp.Product_MP().GetAllParent(), Elements, e, e.ID() = productparent )
                and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day() and ( pispip.NewSupplyQuantity() <> 0 or pispip.PlannedInventoryLevelEnd() <> 0 ) ) ){
        weekstart           := owner.StartOfPlanning().Date();
        pispips             := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical()
                                                    and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day(), pispip.Start() );
        row := table.GetRow( pisp.ProductID() );
        traverse( pispips, Elements, pispip ){
          //天
          daycolumn           := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), pispip.Start().Date() );
          daycolumn         := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), pispip.Start().Date() );
          //周
          weekcolumn          := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), weekstart );
          supplyquantity      := [Number]pispip.NewSupplyQuantity();//四舍五入
          inventoryquantity   := [Number]pispip.PlannedInventoryLevelEnd();//四舍五入
          weekcolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), weekstart );
          supplyquantity    := [Number]pispip.NewSupplyQuantity();//四舍五入
          inventoryquantity := [Number]pispip.PlannedInventoryLevelEnd();//四舍五入
          //产量是加总
          if( iscc or isdl ){
            row.SetCellProductionValue( daycolumn, iscc, [Real]supplyquantity );
@@ -54,10 +57,10 @@
          }
          //库存需要取最后一天
          row.SetCellInventoryValue( daycolumn, [Real]inventoryquantity );
          if( pispip.Start() = weekstart + Duration::Days( 6 ) or pispip.Period_MP() = endperiod ){
            weekstart         := ( weekstart + Duration::Days( 7 ) ).Date();
            weekstart       := ( weekstart + Duration::Days( 7 ) ).Date();
            row.SetCellInventoryValue( weekcolumn, [Real]inventoryquantity );
          } 
        }
@@ -65,21 +68,26 @@
    }
    
    //生成需求数据
    traverse( owner, SalesDemand.astype( Forecast ), forecast ){
      row                   := table.GetRow( forecast.ProductID() );
      weekstart             := owner.StartOfPlanning().Date();
      traverse( forecast, PlanningSalesDemandInPeriod, psdip ){
    traverse( owner, SalesDemand.astype( Forecast ), forecast, forecast.StartDate() < endperiod.StartDate() and forecast.Quantity() <> 0
              and exists( forecast.Product_MP().GetAllParent(), Elements, e, e.ID() = productparent )
              and exists( forecast, PlanningSalesDemandInPeriod, psdip, psdip.Quantity() <> 0 ) ){
      row                 := table.GetRow( forecast.ProductID() );
      weekstart           := owner.StartOfPlanning().Date();
      traverse( forecast, PlanningSalesDemandInPeriod, psdip, psdip.Quantity() <> 0 ){
        //天
        daycolumn           := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), psdip.StartDate() );
        daycolumn         := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), psdip.StartDate() );
        //周
        weekcolumn          := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), weekstart );
        weekcolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), weekstart );
        if( not isnull( daycolumn ) ){
          row.SetCellDemandValue( daycolumn, forecast.SalesSegmentName(), forecast.Quantity() );
        }
        if( not isnull( weekcolumn ) ){
          row.SetCellDemandValue( weekcolumn, forecast.SalesSegmentName(), forecast.Quantity() );
        }
        if( psdip.StartDate() = ( weekstart + Duration::Days( 6 ) ).Date() or psdip.PeriodStart() = endperiod.StartDate() ){
          weekstart       := ( weekstart + Duration::Days( 7 ) ).Date();
        }
      }
    }