rislai
2024-08-16 bcd7eb876bff759f6aef96f1014b0bca7a3322ff
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
Quintiq file version 2.0
#parent: #root
StaticMethod Download (
  MacroPlan macroPlan
) as BinaryValue
{
  Description: '下载发动机管线数据'
  TextBody:
  [*
    
    table := selectobject( macroPlan, MachiningPipelineSource.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 );
          productcellElement4 := xmlDOM.CreateElement( "cell" );
          productcellElement4.SetAttribute( "value", row.Name() );
          productcolumnelement.AppendChild( productcellElement4 );
          productcellElement5 := xmlDOM.CreateElement( "cell" );
          productcellElement5.SetAttribute( "value", row.Name() );
          productcolumnelement.AppendChild( productcellElement5 );
          productcellElement6 := xmlDOM.CreateElement( "cell" );
          productcellElement6.SetAttribute( "value", row.Name() );
          productcolumnelement.AppendChild( productcellElement6 );
          productcellElement7 := xmlDOM.CreateElement( "cell" );
          productcellElement7.SetAttribute( "value", row.Name() );
          productcolumnelement.AppendChild( productcellElement7 );
          productcellElement8 := xmlDOM.CreateElement( "cell" );
          productcellElement8.SetAttribute( "value", row.Name() );
          productcolumnelement.AppendChild( productcellElement8 );
          productcellElement9 := xmlDOM.CreateElement( "cell" );
          productcellElement9.SetAttribute( "value", row.Name() );
          productcolumnelement.AppendChild( productcellElement9 );
          //Attribute
          //长春装配计划
          ccaqcellElement := xmlDOM.CreateElement( "cell" );
          ccaqcellElement.SetAttribute( "value", 'CCAssemblyPlanQty' );
          attricolumnelement.AppendChild( ccaqcellElement );
          //长春生产计划
          ccpqcellElement := xmlDOM.CreateElement( "cell" );
          ccpqcellElement.SetAttribute( "value", 'CCProductionQty' );
          attricolumnelement.AppendChild( ccpqcellElement );
          //长春调拨计划
          cctqcellElement := xmlDOM.CreateElement( "cell" );
          cctqcellElement.SetAttribute( "value", 'CCTransferQty' );
          attricolumnelement.AppendChild( cctqcellElement );
          //长春库存
          cciqcellElement := xmlDOM.CreateElement( "cell" );
          cciqcellElement.SetAttribute( "value", 'CCInventoryQty' );
          attricolumnelement.AppendChild( cciqcellElement );
          //大连装配计划
          dlaqcellElement := xmlDOM.CreateElement( "cell" );
          dlaqcellElement.SetAttribute( "value", 'DLAssemblyPlanQty' );
          attricolumnelement.AppendChild( dlaqcellElement );
          //大连生产计划
          dlpqcellElement := xmlDOM.CreateElement( "cell" );
          dlpqcellElement.SetAttribute( "value", 'DLProductionQty' );
          attricolumnelement.AppendChild( dlpqcellElement );
          //大连调拨计划
          dltqcellElement := xmlDOM.CreateElement( "cell" );
          dltqcellElement.SetAttribute( "value", 'DLTransferQty' );
          attricolumnelement.AppendChild( dltqcellElement );
          //大连库存
          dliqcellElement := xmlDOM.CreateElement( "cell" );
          dliqcellElement.SetAttribute( "value", 'DLInventoryQty' );
          attricolumnelement.AppendChild( dliqcellElement );
          //长春 + 大连 库存
          tiqcellElement := xmlDOM.CreateElement( "cell" );
          tiqcellElement.SetAttribute( "value", 'TotalInventoryQty' );
          attricolumnelement.AppendChild( tiqcellElement );
        }
        //长春装配计划
        ccaqcellElement := xmlDOM.CreateElement( "cell" );
        ccaqcellElement.SetAttribute( "value", [String]c.CCAssemblyPlanQty() );
        columnelement.AppendChild( ccaqcellElement );
        //长春生产计划
        ccpqcellElement := xmlDOM.CreateElement( "cell" );
        ccpqcellElement.SetAttribute( "value", [String]c.CCProductionQty() );
        columnelement.AppendChild( ccpqcellElement );
        //长春调拨计划
        cctqcellElement := xmlDOM.CreateElement( "cell" );
        cctqcellElement.SetAttribute( "value", [String]c.CCTransferQty() );
        columnelement.AppendChild( cctqcellElement );
        //长春库存
        cciqcellElement := xmlDOM.CreateElement( "cell" );
        cciqcellElement.SetAttribute( "value", [String]c.CCInventoryQty() );
        columnelement.AppendChild( cciqcellElement );
        //大连装配计划
        dlaqcellElement := xmlDOM.CreateElement( "cell" );
        dlaqcellElement.SetAttribute( "value", [String]c.DLAssemblyPlanQty() );
        columnelement.AppendChild( dlaqcellElement );
        //大连生产计划
        dlpqcellElement := xmlDOM.CreateElement( "cell" );
        dlpqcellElement.SetAttribute( "value", [String]c.DLProductionQty() );
        columnelement.AppendChild( dlpqcellElement );
        //大连调拨计划
        dltqcellElement := xmlDOM.CreateElement( "cell" );
        dltqcellElement.SetAttribute( "value", [String]c.DLTransferQty() );
        columnelement.AppendChild( dltqcellElement );
        //大连库存
        dliqcellElement := xmlDOM.CreateElement( "cell" );
        dliqcellElement.SetAttribute( "value", [String]c.DLInventoryQty() );
        columnelement.AppendChild( dliqcellElement );
        //长春 + 大连 库存
        tiqcellElement := xmlDOM.CreateElement( "cell" );
        tiqcellElement.SetAttribute( "value", [String]c.TotalInventoryQty() );
        columnelement.AppendChild( tiqcellElement );
      }
      tableElement.AppendChild( columnelement );  
    }
    
    xmlString := xmlDOMI.CreateSerializer().WriteToString( xmlDOM );
    
    //info( xmlString );
    
    tableGroupHandle := TableGroupHandle::Create( MachiningPipelineReport::GetDefaultName() );
    tableHandle      := TableHandle::ImportXML( BinaryValue::Construct( xmlString ) );
    tableGroupHandle.Add( tableHandle );
    
    binaryData := XLS::SaveTableGroupToBinaryData( tableGroupHandle, true );
    
    return binaryData.AsBinaryValue();
  *]
}