xiaoding721
2024-10-12 489022017f8b581ab413455b41ec841879a75e03
_Main/BL/Type_EnginePipelineReport/Method_Generate.qbl
@@ -17,31 +17,30 @@
    //过滤后的产品id
    productids              := selectuniquevalues( products, Elements, product, true, product.ID() );
    rows                    := selectsortedset( table, Row, row, row.RowNr() );
    //显示列
    productcolumn           := selectobject( this, Column, column, column.Index() = 0 );
    attricolumn             := selectobject( this, Column, column, column.Index() = 1 );
    models                  := selectuniquevalues( table, Column.Cell.Demand, demand, demand.Model() );
    cellnr                  := 5 + models.Size();
    //合计行
    sumrowproduction        := EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, 'SUM', '总产量', rows.Size() * cellnr, true );
    sumrowdlproduction      := EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, 'SUM', '大连产量', sumrowproduction.RowNr() + 1, false );
    sumrowccproduction      := EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, 'SUM', '长春产量', sumrowproduction.RowNr() + 2, false );
    sumrowdemand            := EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, 'SUM', '总需求', sumrowproduction.RowNr() + 3, false );
    sumname                 := 'SUM';
    sumstr                  := sumname.Format( 'S(Len(10))' );
    sumrowproduction        := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '总产量' ), sumname, '', rows.Size() * cellnr );
    sumrowdlproduction      := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '大连产量' ), sumname, '', sumrowproduction.RowNr() + 1 );
    sumrowccproduction      := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '长春产量' ), sumname, '', sumrowproduction.RowNr() + 2  );
    sumrowdemand            := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '总需求' ), sumname, '', sumrowproduction.RowNr() + 3 );
    rowno                   := sumrowproduction.RowNr() + 4;
    traverse( models, Elements, model ){
      EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, 'SUM', model.Concat( '需求' ), rowno, false );
      EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( model.Concat( '需求' ) ), sumname, model, rowno );
      rowno                 := rowno + 1;
    }
    sumrowinventory         := EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, 'SUM', '库存', rowno, false );
    sumrowinventory         := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '库存' ), sumname, '', rowno );
    
    //行计数
    rownr                   := 0;
    traverse( rows, Elements, row, productids.Find( row.Name() ) >= 0 ){
      showrowproduction   := EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, row.Name(), '总生产', rownr, true );;
      showrowdlproduction := EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, row.Name(), '大连产量', rownr + 1, false );
      showrowccproduction := EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, row.Name(), '长春产量', rownr + 2, false );
      showrowdemand       := EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, row.Name(), '总需求', rownr + 3, false );
      rowname             := row.Name().Format( 'S(Len(10))' );
      showrowproduction   := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '总产量' ), row.Name(), '', rownr );
      showrowdlproduction := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '大连产量' ), row.Name(), '', rownr + 1 );
      showrowccproduction := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '长春产量' ), row.Name(), '', rownr + 2 );
      showrowdemand       := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '总需求' ), row.Name(), '', rownr + 3 );
      rownr               := rownr + 4;
      modelsnr            := rownr + 3;
      models              := construct( Strings );
@@ -50,7 +49,7 @@
      traverse( uniquemodels, Elements, e ){
    
        if( rownr < modelsnr ){
          EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, row.Name(), e.Concat( '需求' ), rownr, false );
          EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( e.Concat( '需求' ) ), row.Name(), e, rownr );
          models.Add( e );
          rownr             := rownr + 1;
        }
@@ -58,9 +57,9 @@
    
      for( rownr := rownr; rownr < modelsnr; rownr ++ ){
    
        EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, row.Name(), '', rownr, false );
        EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '' ), row.Name(), '', rownr );
      }
      showrowinventory    :=  EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, row.Name(), '库存', rownr, false );
      showrowinventory    :=  EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '库存' ), row.Name(), '', rownr );
    
      traverse( row, Cell, cell, cell.Column().TimeUnit() = search.TimeUnit() ){
    
@@ -114,8 +113,8 @@
          sumdemand.Value( [String]( [Real]sumdemand.Value() + cell.DemandQuantity() ) );
          
          traverse( cell, Demand, demand, exists( models, Elements, model, model = demand.Model() ) ){
            demandrow              := selectobject( this, Row, r, r.Name() = row.Name() and exists( r, CellValue, cv, cv.Column() = attricolumn and cv.Value() = demand.Model().Concat( '需求' ) ) );
            sumdemandrow           := selectobject( this, Row, r, r.Name() = 'SUM' and exists( r, CellValue, cv, cv.Column() = attricolumn and cv.Value() = demand.Model().Concat( '需求' ) ) );
            demandrow              := selectobject( this, Row, r, r.Product() = row.Name() and r.Demand() = demand.Model() );
            sumdemandrow           := selectobject( this, Row, r, r.Name() = sumname and r.Demand() = demand.Model() );
    
            if( not isnull( demandrow ) ){
              demandcell             := column.CellValue( relnew, Value := [String]demand.Quantity() );
@@ -155,7 +154,7 @@
    }
    traverse( this, Column, column ){
      for( demandr := sumrowdemand.RowNr() + 1; demandr < sumrowinventory.RowNr(); demandr := demandr + 1 ){
        demandrow              := selectobject( this, Row, r, r.RowNr() = demandr and r.Name() = 'SUM' );
        demandrow              := selectobject( this, Row, r, r.RowNr() = demandr and r.Name() = sumname );
    //    info( '------------------14----------------' );
        if( not isnull( demandrow ) and not exists( demandrow, CellValue, cv, cv.Column() = column ) ){
          demandcell           := column.CellValue( relnew, Value := '' );