lazhen
2024-10-14 4be2a228025a44c7cc4a1fec31d5ade0f84a988b
_Main/BL/Type_FinancialSalesSource/StaticMethod_InitializeNew.qbl
@@ -10,23 +10,20 @@
    // 甄兰鸽 Jun-24-2024 (created)
    owner.FinancialSalesSource( relflush );
    owner.FSImportData( relflush );
    products                  := construct( Product_MPs );
    productids                := construct( Strings );
    allunit                   := FinancialSalesReport::GetDefaultAllUnit();
    ccunit                    := FinancialSalesReport::GetDefaultCCUnit();
    dlunit                    := FinancialSalesReport::GetDefaultDLUnit();
    ccsalessegment            := FinancialSalesReport::GetSalesSegmentCC();
    tjsalessegment            := FinancialSalesReport::GetSalesSegmentTJ();
    fssalessegment            := FinancialSalesReport::GetSalesSegmentFS();
    //ccspline                  := FinancialSalesReport::GetStockingPointCCLine();
    //dlspline                  := FinancialSalesReport::GetStockingPointDLLine();
    //ccrent                    := FinancialSalesReport::GetStockingPointCCRent();
    
    source                    := owner.FinancialSalesSource( relnew, IsImport := false, Name := FinancialSalesReport::GetDefaultName() );
    table                     := source.FinancialSalesReport( relnew, ID := source.Name(), Name := source.Name(), IsImport := false );
    showtable                 := source.FinancialSalesReport( relnew, ID := source.Name() + 'Show', Name := source.Name(), IsImport := false, IsShow := true );
    startofplanning           := owner.StartOfPlanning().Date();
    startofyear               := ( startofplanning.StartOfYear() - Duration::Days( 1 ) ).Date();
    startofnextyear           := ( startofplanning.StartOfNextYear() - Duration::Days( 1 ) ).Date();
    //startofyear               := startofplanning.StartOfYear();
    startofnextyear           := startofplanning.StartOfNextYear();
    
    search                    := owner.FinancialSalesSearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit );
    
@@ -54,7 +51,7 @@
        //获取工厂行
        factoryrow           := table.GetRow( ifexpr( isdl, dlunit, ccunit ), product );
      
        products.Add( product );
        productids.Add( forecast.ProductID() );
        traverse( forecast, PlanningSalesDemandInPeriod, psdip, psdip.Quantity() <> 0 ){
          dayperiodtime      := psdip.StartDate();
          dayperiodname      := dayperiodtime.Format( "M2/D2/Y" );
@@ -75,13 +72,13 @@
    //从Product planning查找库存点为大连发动机的长春外租库,取New supply字段按月汇总需求数量
    traverse( owner, StockingPoint_MP, stockingpoint, stockingpoint.ID() = '大连发动机的长春外租库' ){
        traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf()
                  and exists( pisp, ProductInStockingPointInPeriod, pispip, pispip.Period_MP().StartDate() >= startofyear and pispip.Period_MP().StartDate() < startofnextyear
                  and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear
                              and ( pispip.DependentDemandAndSalesDemandQuantity() <> 0 or pispip.NewSupplyQuantity() <> 0 ) ) ){//产品为MQB
          product           := pisp.Product_MP();
          allrow            := table.GetRow( allunit, product );
          factoryrow        := table.GetRow( dlunit, product );
          products.Add( product );
          traverse( pisp, ProductInStockingPointInPeriod, pispip, pispip.Period_MP().StartDate() >= startofyear
          productids.Add( pisp.ProductID() );
          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical()
                    and pispip.Period_MP().StartDate() < startofnextyear 
                    and ( pispip.DependentDemandAndSalesDemandQuantity() <> 0 or pispip.NewSupplyQuantity() <> 0 ) ){
            dayperiodtime   := ( pispip.Start() + Duration::Days( 1 ) ).Date();
@@ -134,13 +131,7 @@
    //    }
    //  }
    //}
    rows := selectsortedset( table, FinancialSalesRow, row, row.Name() );
    i    := 0;
    traverse( rows, Elements, e ){
      e.RowNr( i );
      i := i + 1;
    }
    showtable.Generate( search, products );
    factorys                  := selectset( owner, Factory, factory, factory.ID() = FinancialProductionReport::GetDefaultAllUnit() );
    showtable.Generate( search, factorys, productids );
  *]
}