rislai
2024-07-12 6c6bbb2ae3ee0e8c539bb3b97d90590cff957a54
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
Quintiq file version 2.0
#parent: #root
StaticMethod Download (
  MacroPlan macroPlan
) as BinaryValue
{
  Description: '下载发动机管线数据'
  TextBody:
  [*
    
    table := selectobject( macroPlan, EnginePipelineSource.Report, table, 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 );
    //Product
    productcolumnelement := xmlDOM.CreateElement( "column" );
    productnameelement   := xmlDOM.CreateElement( "name" );
    producttypeelement   := xmlDOM.CreateElement( "type" );
    productnameelement.TextContent( 'Product' );
    producttypeelement.TextContent( "String" );
    productcolumnelement.AppendChild( productnameelement );
    productcolumnelement.AppendChild( producttypeelement );
    //Attribute
    attricolumnelement := xmlDOM.CreateElement( "column" );
    attrinameelement   := xmlDOM.CreateElement( "name" );
    attritypeelement   := xmlDOM.CreateElement( "type" );
    attrinameelement.TextContent( 'Attribute' );
    attritypeelement.TextContent( "String" );
    attricolumnelement.AppendChild( attrinameelement );
    attricolumnelement.AppendChild( attritypeelement );
    
    tableElement.AppendChild( productcolumnelement ); 
    tableElement.AppendChild( attricolumnelement );
    traverse ( table, Column, column ) {
      columnelement := xmlDOM.CreateElement( "column" );
      nameelement   := xmlDOM.CreateElement( "name" );
      typeelement   := xmlDOM.CreateElement( "type" );
      nameelement.TextContent( column.Name() );
      typeelement.TextContent( "String" );
      columnelement.AppendChild( nameelement );
      columnelement.AppendChild( typeelement );
      
      cells := selectsortedset( column, Cell, cell, cell.Row().RowNr() );
    
      traverse ( cells, Elements, c ) {
        if( column.Index() = 0 ){
          row := c.Row();
          //Product
          productcellElement1 := xmlDOM.CreateElement( "cell" );
          productcellElement1.SetAttribute( "value", row.Name() );
          productcolumnelement.AppendChild( productcellElement1 );
          productcellElement2 := xmlDOM.CreateElement( "cell" );
          productcellElement2.SetAttribute( "value", row.Name() );
          productcolumnelement.AppendChild( productcellElement2 );
          productcellElement3 := xmlDOM.CreateElement( "cell" );
          productcellElement3.SetAttribute( "value", row.Name() );
          productcolumnelement.AppendChild( productcellElement3 );
          //Attribute
          //生产
          endcellElement := xmlDOM.CreateElement( "cell" );
          endcellElement.SetAttribute( "value", 'ProductionQuantity' );
          attricolumnelement.AppendChild( endcellElement );
          //需求
          mincellElement := xmlDOM.CreateElement( "cell" );
          mincellElement.SetAttribute( "value", 'DemandQuantity' );
          attricolumnelement.AppendChild( mincellElement );
          //库存
          maxcellElement := xmlDOM.CreateElement( "cell" );
          maxcellElement.SetAttribute( "value", 'InventoryQUantity' );
          attricolumnelement.AppendChild( maxcellElement );
        }
        //生产
        endcellElement := xmlDOM.CreateElement( "cell" );
        endcellElement.SetAttribute( "value", [String]c.ProductionQuantity() );
        columnelement.AppendChild( endcellElement );
        //需求
        mincellElement := xmlDOM.CreateElement( "cell" );
        mincellElement.SetAttribute( "value", [String]c.DemandQuantity() );
        columnelement.AppendChild( mincellElement );
        //库存
        maxcellElement := xmlDOM.CreateElement( "cell" );
        maxcellElement.SetAttribute( "value", [String]c.InventoryQuantity() );
        columnelement.AppendChild( maxcellElement );
      }
      tableElement.AppendChild( columnelement );  
    }
    
    xmlString := xmlDOMI.CreateSerializer().WriteToString( xmlDOM );
    
    //info( xmlString );
    
    tableGroupHandle := TableGroupHandle::Create( EnginePipelineReport::GetDefaultName() );
    tableHandle      := TableHandle::ImportXML( BinaryValue::Construct( xmlString ) );
    tableGroupHandle.Add( tableHandle );
    
    binaryData := XLS::SaveTableGroupToBinaryData( tableGroupHandle, true );
    
    return binaryData.AsBinaryValue();
  *]
}