陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Quintiq file version 2.0
#parent: #root
Method Generate (
  CCEngineLogisticsCostSearch search,
  Product_MPs products
)
{
  TextBody:
  [*
    // 甄兰鸽 Jun-25-2024 (created)
    table            := selectobject( this, MacroPlan.CCEngineLogisticsCostReport, report, not report.IsShow() );
    allunit          := '<All>';
    //清空之前存储的显示数据
    this.Clear();
    //年汇总 
    yearcolumn := this.Column( relnew, Name := '汇总', StartDate := search.MacroPlan().StartOfPlanning().StartOfNextYear().Date() );
    //过滤后的产品id
    productids       := selectuniquevalues( products, Elements, product, ( search.Generation() = allunit or product.Generation() = search.Generation() )
                                      and ( search.MqbMlb() = allunit or product.MQBMLB() = search.MqbMlb() )
                                      and ( search.Power() = allunit or product.Power() = search.Power() ), product.ID() );
    sumrow           := this.Row( relnew, Name := 'SUM', RowNr := table.Row( relsize ) );
    sumyearcell      := sumrow.Initialize( yearcolumn );
    traverse( table, Row, row ){
      productid      := construct( Strings );
      productid.Add( row.Name() );
      
      if( productids.ContainsAll( productid ) ){
        showrow      := this.Row( relnew, Name := row.Name(), RowNr := row.RowNr() );
        yearcell     := showrow.Initialize( yearcolumn );
        
        traverse( row, Cell, cell ){
          column     := selectobject( this, Column, column, column.Name() = cell.Column().Name() );
          
          sumcell    := selectobject( column, Cell, c, c.Row() = sumrow );
          if( isnull( sumcell ) ){
            sumcell  := sumrow.Initialize( column );
          }
          //显示月单元格
          showcell   := showrow.Cell( relnew, RentInCost := cell.RentInCost(), RentOutOfCost := cell.RentOutOfCost(), WerkToRentTransCost := cell.WerkToRentTransCost(), RentStorCost := cell.RentStorCost(), CoefficientValue := cell.CoefficientValue(), AllCost := cell.EstimateTotalCost() * [Real]cell.CoefficientValue() );
          column.Cell( relinsert, showcell );
          showcell.EstimateTotalCost( showcell.CalcEstimateTotalCost() );
          showcell.AllCost( showcell.EstimateTotalCost() * [Real]showcell.CoefficientValue() );
          //显示年单元格
          yearcell.RentInCost( cell.RentInCost() + yearcell.RentInCost() );
          yearcell.RentOutOfCost( cell.RentOutOfCost() + yearcell.RentOutOfCost() );
          yearcell.WerkToRentTransCost( cell.WerkToRentTransCost() + yearcell.WerkToRentTransCost() );
          yearcell.RentStorCost( cell.RentStorCost() + yearcell.RentStorCost() );
          //显示合计年单元格
          sumyearcell.RentInCost( cell.RentInCost() + sumyearcell.RentInCost() );
          sumyearcell.RentOutOfCost( cell.RentOutOfCost() + sumyearcell.RentOutOfCost() );
          sumyearcell.WerkToRentTransCost( cell.WerkToRentTransCost() + sumyearcell.WerkToRentTransCost() );
          sumyearcell.RentStorCost( cell.RentStorCost() + sumyearcell.RentStorCost() );
          //显示合计月单元格
          sumcell.RentInCost( cell.RentInCost() + sumcell.RentInCost() );
          sumcell.RentOutOfCost( cell.RentOutOfCost() + sumcell.RentOutOfCost() );
          sumcell.WerkToRentTransCost( cell.WerkToRentTransCost() + sumcell.WerkToRentTransCost() );
          sumcell.RentStorCost( cell.RentStorCost() + sumcell.RentStorCost() );
        }
        yearcell.EstimateTotalCost( yearcell.CalcEstimateTotalCost() );
        yearcell.AllCost( yearcell.EstimateTotalCost() * [Real]yearcell.CoefficientValue() );
      }
    }
    
    traverse( yearcolumn, Cell, cell ){
      cell.EstimateTotalCost( cell.CalcEstimateTotalCost() );
      cell.AllCost( cell.EstimateTotalCost() * [Real]cell.CoefficientValue() );
    }
    traverse( sumrow, Cell, cell ){
      cell.EstimateTotalCost( cell.CalcEstimateTotalCost() );
      cell.AllCost( cell.EstimateTotalCost() * [Real]cell.CoefficientValue() );
      cell.IsAllCostUpdate( exists( cell.Column(), Cell, acell, acell.IsAllCostUpdate() ) );
      cell.IsCoefficientUpdate( exists( cell.Column(), Cell, acell, acell.IsCoefficientUpdate() ) );
      cell.IsEstimateTotalCostUpdate( exists( cell.Column(), Cell, acell, acell.IsEstimateTotalCostUpdate() ) );
      cell.IsRentInCostUpdate( exists( cell.Column(), Cell, acell, acell.IsRentInCostUpdate() ) );
      cell.IsRentOutOfCostUpdate( exists( cell.Column(), Cell, acell, acell.IsRentOutOfCostUpdate() ) );
      cell.IsRentStorCostUpdate( exists( cell.Column(), Cell, acell, acell.IsRentStorCostUpdate() ) );
      cell.IsWerkToRentTransCostUpdate( exists( cell.Column(), Cell, acell, acell.IsWerkToRentTransCostUpdate() ) );
    }
    rows := selectsortedset( this, Row, row, row.Name() );
    i    := 0;
    traverse( rows, Elements, e ){
      e.RowNr( i );
      i := i + 1;
    }
  *]
}