Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method Generate ( 
 | 
  EnginePipelineSearch search, 
 | 
  Product_MPs products 
 | 
) 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    // 甄兰鸽 Jun-25-2024 (created) 
 | 
    table                   := selectobject( this, Source.Report, report, not report.IsShow() ); 
 | 
     
 | 
    //清空之前存储的显示数据 
 | 
    this.Clear( search.TimeUnit(), search.StartDate(), search.EndDate() ); 
 | 
    Transaction::Transaction().Propagate( attribute( EnginePipelineColumn, Index ) ); 
 | 
    Transaction::Transaction().Propagate( attribute( EnginePipelineCell, ProductionQuantity ) ); 
 | 
    Transaction::Transaction().Propagate( attribute( EnginePipelineCell, DemandQuantity ) ); 
 | 
    //过滤后的产品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 ); 
 | 
    rowno                   := sumrowproduction.RowNr() + 4; 
 | 
    traverse( models, Elements, model ){ 
 | 
      EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, 'SUM', model, rowno, false );  
 | 
      rowno                 := rowno + 1; 
 | 
    } 
 | 
    sumrowinventory         := EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, 'SUM', '库存', rowno, false ); 
 | 
     
 | 
    //行计数 
 | 
    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 ); 
 | 
      rownr               := rownr + 4; 
 | 
      traverse( models, Elements, model ){ 
 | 
        EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, row.Name(), model, rownr, false );  
 | 
        rownr             := rownr + 1; 
 | 
      } 
 | 
      showrowinventory    :=  EnginePipelineRow::CraeteCellValueForRow( this, productcolumn, attricolumn, row.Name(), '库存', rownr, false ); 
 | 
     
 | 
      traverse( row, Cell, cell, cell.Column().TimeUnit() = search.TimeUnit() ){ 
 | 
     
 | 
        column            := selectobject( this, Column, column, column.Name() = cell.Column().Name() and column.TimeUnit() = search.TimeUnit() ); 
 | 
         
 | 
        if( not isnull( column ) ){ 
 | 
           
 | 
          //生产 
 | 
          production              := column.CellValue( relnew, Value := [String]cell.ProductionQuantity() ); 
 | 
          showrowproduction.CellValue( relinsert, production ); 
 | 
          sumproduction           := selectobject( column, CellValue, c, c.Row() = sumrowproduction ); 
 | 
          if( isnull( sumproduction ) ){ 
 | 
            sumproduction         := column.CellValue( relnew, Value := [String]0 ); 
 | 
            sumrowproduction.CellValue( relinsert, sumproduction ); 
 | 
          } 
 | 
          sumproduction.Value( [String]( [Real]sumproduction.Value() + cell.ProductionQuantity() ) ); 
 | 
     
 | 
          //大连产量 
 | 
          dlproductionquantity     := guard( cell.Production().DLProduction(), 0 ); 
 | 
          dlproduction             := column.CellValue( relnew, Value := [String]dlproductionquantity ); 
 | 
          showrowdlproduction.CellValue( relinsert, dlproduction ); 
 | 
          sumdlproduction          := selectobject( column, CellValue, c, c.Row() = sumrowdlproduction ); 
 | 
          if( isnull( sumdlproduction ) ){ 
 | 
            sumdlproduction        := column.CellValue( relnew, Value := [String]0 ); 
 | 
            sumrowdlproduction.CellValue( relinsert, sumdlproduction ); 
 | 
          } 
 | 
          sumdlproduction.Value( [String]( [Real]sumdlproduction.Value() + dlproductionquantity ) ); 
 | 
           
 | 
          //长春产量 
 | 
          ccproductionquantity     := guard( cell.Production().CCProduction(), 0 ); 
 | 
          ccproduction             := column.CellValue( relnew, Value := [String]ccproductionquantity ); 
 | 
          showrowccproduction.CellValue( relinsert, ccproduction ); 
 | 
          sumccproduction          := selectobject( column, CellValue, c, c.Row() = sumrowccproduction ); 
 | 
          if( isnull( sumccproduction ) ){ 
 | 
            sumccproduction        := column.CellValue( relnew, Value := [String]0 ); 
 | 
            sumrowccproduction.CellValue( relinsert, sumccproduction ); 
 | 
          } 
 | 
          sumccproduction.Value( [String]( [Real]sumccproduction.Value() + ccproductionquantity ) ); 
 | 
           
 | 
          //需求 
 | 
          totaldemand              := column.CellValue( relnew, Value := [String]cell.DemandQuantity() ); 
 | 
          showrowdemand.CellValue( relinsert, totaldemand ); 
 | 
          sumdemand                := selectobject( column, CellValue, c, c.Row() = sumrowdemand ); 
 | 
          if( isnull( sumdemand ) ){ 
 | 
            sumdemand              := column.CellValue( relnew, Value := [String]0 ); 
 | 
            sumrowdemand.CellValue( relinsert, sumdemand ); 
 | 
          } 
 | 
          sumdemand.Value( [String]( [Real]sumdemand.Value() + cell.DemandQuantity() ) ); 
 | 
           
 | 
          traverse( cell, Demand, demand ){ 
 | 
            demandrow              := selectobject( this, Row, r, r.Name() = row.Name() and exists( r, CellValue, cv, cv.Value() = demand.Model() ) ); 
 | 
            sumdemandrow           := selectobject( this, Row, r, r.Name() = 'SUM' and exists( r, CellValue, cv, cv.Value() = demand.Model() ) ); 
 | 
     
 | 
            if( not isnull( demandrow ) ){ 
 | 
              demandcell             := column.CellValue( relnew, Value := [String]demand.Quantity() ); 
 | 
              demandrow.CellValue( relinsert, demandcell ); 
 | 
            } 
 | 
             
 | 
            sumdemandcell          := selectobject( column, CellValue, c, c.Row() = sumdemandrow ); 
 | 
            if( isnull( sumdemandcell ) ){ 
 | 
              sumdemandcell        := column.CellValue( relnew, Value := [String]0 ); 
 | 
              sumdemandrow.CellValue( relinsert, sumdemandcell ); 
 | 
            } 
 | 
            sumdemandcell.Value( [String]( [Real]sumdemandcell.Value() + demand.Quantity() ) ); 
 | 
          } 
 | 
     
 | 
          for( demandr := showrowdemand.RowNr() + 1; demandr < showrowinventory.RowNr(); demandr := demandr + 1 ){ 
 | 
            demandrow              := selectobject( this, Row, r, r.RowNr() = demandr ); 
 | 
            if( not isnull( demandrow ) and not exists( demandrow, CellValue, cv, cv.Column() = column ) ){ 
 | 
              demandcell           := column.CellValue( relnew, Value := '' ); 
 | 
              demandrow.CellValue( relinsert, demandcell ); 
 | 
            } 
 | 
          } 
 | 
     
 | 
           
 | 
          //库存 
 | 
          inventory                := column.CellValue( relnew, Value := [String]cell.InventoryQuantity() ); 
 | 
          showrowinventory.CellValue( relinsert, inventory ); 
 | 
          suminventory             := selectobject( column, CellValue, c, c.Row() = sumrowinventory ); 
 | 
          if( isnull( suminventory ) ){ 
 | 
            suminventory           := column.CellValue( relnew, Value := [String]0 ); 
 | 
            sumrowinventory.CellValue( relinsert, suminventory ); 
 | 
          } 
 | 
          suminventory.Value( [String]( [Real]suminventory.Value() + cell.InventoryQuantity() ) ); 
 | 
     
 | 
        } 
 | 
      } 
 | 
    } 
 | 
    traverse( this, Column, column ){ 
 | 
      for( demandr := sumrowdemand.RowNr() + 1; demandr < sumrowinventory.RowNr(); demandr := demandr + 1 ){ 
 | 
        demandrow              := selectobject( this, Row, r, r.RowNr() = demandr ); 
 | 
        if( not isnull( demandrow ) and not exists( demandrow, CellValue, cv, cv.Column() = column ) ){ 
 | 
          demandcell           := column.CellValue( relnew, Value := '' ); 
 | 
          demandrow.CellValue( relinsert, demandcell ); 
 | 
        } 
 | 
      } 
 | 
    } 
 | 
  *] 
 | 
} 
 |