lazhen
2024-07-12 e7d178297c6065691f5a8ad20fb5e1c54c55031a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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() );
    //过滤后的产品id
    productids := selectuniquevalues( products, Elements, product, true, product.ID() );
    sumrow     := this.Row( relnew, Name := 'SUM', RowNr := table.Row( relsize ) );
    traverse( table, Row, row, productids.Find( row.Name() ) >= 0 ){
      showrow := this.Row( relnew, Name := row.Name(), RowNr := row.RowNr() );
      
      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 ) ){
          sumcell  := selectobject( column, Cell, c, c.Row() = sumrow );
          if( isnull( sumcell ) ){
            sumcell := column.Cell( relnew, InventoryQuantity := 0 );
            sumrow.Cell( relinsert, sumcell );
          }
          
          showcell := cell.Copy( column );
          showrow.Cell( relinsert, showcell );
      
          sumcell.InventoryQuantity( cell.InventoryQuantity() + sumcell.InventoryQuantity() );
          
          traverse( cell, Demand, demand ){
            sumcell.Demand( relnew, EngineType := demand.EngineType(), Model := demand.Model(), Period := demand.Period(), Quantity := demand.Quantity() );
          }
          
          traverse( cell, Production, production ){
            sumcell.Production( relnew, EngineType := production.EngineType(), Period := production.Period(), DLProduction := production.DLProduction(), CCProduction := production.CCProduction() );
          }
        }
      }
    }
  *]
}