陈清红
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
Quintiq file version 2.0
#parent: #root
StaticMethod Download (
  MacroPlan macroPlan
) as BinaryValue
{
  Description: '下载财务报表数据'
  TextBody:
  [*
    
    table                         := selectobject( macroPlan, FinancialSalesSource.FinancialSalesReport, table, not table.IsImport() and table.IsShow() );
    
    xmlDOMI                       := XMLDOMImplementation::Create();
    xmlDOM                        := xmlDOMI.CreateDocumentFromString( '<?xml version="1.0" encoding="UTF-16"?><table><name>' + table.Name() + '</name></table>' );
    
    tableElement                  := xmlDOM.GetElementByTagName( "table", 0 );
    //Factory
    searchunitcolumn              := InventorySummarySource::CreateColumnElement( tableElement, xmlDOM, 'Unit' );
    //Generation
    generationcolumn              := InventorySummarySource::CreateColumnElement( tableElement, xmlDOM, 'Generation' );
    //Power
    powercolumn                   := InventorySummarySource::CreateColumnElement( tableElement, xmlDOM, 'Power' );
    //MLBMQBS
    mlbmqbcolumn                  := InventorySummarySource::CreateColumnElement( tableElement, xmlDOM, 'MLBMQB' );
    //Product
    productcolumnelement          := InventorySummarySource::CreateColumnElement( tableElement, xmlDOM, 'Product' );
    //Unit
    unitcolumnelement             := InventorySummarySource::CreateColumnElement( tableElement, xmlDOM, 'Unit' );
    
    minindex                      := min( table, FinancialSalesColumn, column, column.Index() );
    traverse ( table, FinancialSalesColumn, column ) {
      columnelement               := InventorySummarySource::CreateColumnElement( tableElement, xmlDOM, column.Name() );
      
      cells := selectsortedset( column, FinancialSalesCell, cell, cell.FinancialSalesRow().RowNr() );
    
      traverse ( cells, Elements, c ) {
        if( column.Index() = minindex ){
          row                     := c.FinancialSalesRow();
          //Factory
          InventorySummarySource::CreateCellElement( xmlDOM, searchunitcolumn, row.Factory() );
          if( not isnull( row.Product_MP() ) ){
            //Generation
            InventorySummarySource::CreateCellElement( xmlDOM, generationcolumn, row.Product_MP().Generation() );
            //Power
            InventorySummarySource::CreateCellElement( xmlDOM, powercolumn, row.Product_MP().Power() );
            //MLBMQBS
            InventorySummarySource::CreateCellElement( xmlDOM, mlbmqbcolumn, row.Product_MP().MQBMLB() );
          }else{
            //Generation
            InventorySummarySource::CreateCellElement( xmlDOM, generationcolumn, '' );
            //Power
            InventorySummarySource::CreateCellElement( xmlDOM, powercolumn, '' );
            //MLBMQBS
            InventorySummarySource::CreateCellElement( xmlDOM, mlbmqbcolumn, '' );
          }
          //Product
          InventorySummarySource::CreateCellElement( xmlDOM, productcolumnelement, row.Name() );
          //Unit
          InventorySummarySource::CreateCellElement( xmlDOM, unitcolumnelement, row.Unit() );
        }
        InventorySummarySource::CreateCellElement( xmlDOM, columnelement, c.Value() );
      }
      tableElement.AppendChild( columnelement );  
    }
    
    xmlString                     := xmlDOMI.CreateSerializer().WriteToString( xmlDOM );
    
    tableGroupHandle              := TableGroupHandle::Create( FinancialSalesReport::GetDefaultName() );
    tableHandle                   := TableHandle::ImportXML( BinaryValue::Construct( xmlString ) );
    tableGroupHandle.Add( tableHandle );
    
    binaryData                    := XLS::SaveTableGroupToBinaryData( tableGroupHandle, true );
    
    return binaryData.AsBinaryValue();
  *]
}