renhao
2023-09-21 d30a8bbf3f46528e1773bce1a2065b2462b84a18
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
Quintiq file version 2.0
#parent: #root
Method CapacityAndSaleBudgeChart (
  MacroPlans macroPlans,
  Boolean isCapacity,
  String groupBy,
  String byBusinessTypeOrByOrgCode,
  String businessTypeChosen,
  String placeOfProductionOfArrayChosen,
  String year,
  MPSync mpSync,
  GlobalOTDTable otdTable,
  MacroPlan mappingParent
)
{
  Description: '按入参处理数据,产生需要的CapacityAndSaleBudgeChartElement'
  TextBody:
  [*
    // yypsybs Sep-19-2023 (created)
    // true, false
    info( isCapacity );
    // 月;季度;半年;年
    info( groupBy );
    // 面板基地;事业部
    info( byBusinessTypeOrByOrgCode );
    info( businessTypeChosen );
    info( placeOfProductionOfArrayChosen );
    info( year );
    
    // ====清理旧数据====
    this.CapacityAndSaleBudgeChartRow( relflush );
    this.CapacityAndSaleBudgeChartElement( relflush );
    
    // ====按面板基地和事业部对产品进行筛选分组====
    historyData := selectset( otdTable, CapacityAndSaleBudge, item, true );
    if( placeOfProductionOfArrayChosen <> "" ) {
      historyData := selectset( historyData, Elements, item, item.PlaceOfProductionOfArray() = placeOfProductionOfArrayChosen );
    }
    if( businessTypeChosen <> "" ) {
      historyData := selectset( historyData, Elements, item, item.BusinessType() = businessTypeChosen );
    }
    traverse( historyData, Elements, item ) {
      row := CapacityAndSaleBudgeChartRow::CreateIfNotExist( this, item.BusinessType(), item.PlaceOfProductionOfArray() );
      // 记录每行包含哪些product
      CapacityAndSaleBudgeChartRowProduct::CreateIfNotExist( row, item.ProductCode() );
    }
    rows := selectset( this, CapacityAndSaleBudgeChartRow, item, true );
    placeOfProductionOfArrayList := selectuniquevalues( historyData, Elements, item, item.PlaceOfProductionOfArray() );
    businessTypeList := selectuniquevalues( historyData, Elements, item, item.BusinessType() );
    // 生成图表元素
    if( byBusinessTypeOrByOrgCode = "面板基地" and groupBy = "年" ) {
      // 目标
      traverse( placeOfProductionOfArrayList, Elements, placeOfProductionOfArray ) {
        productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByPlaceOfProductionOfArray( rows, placeOfProductionOfArray );
        this.CapacityAndSaleBudgeChartElement( relnew, 
                                               TimeStringAndScenarioName := [String]year + "年-目标",
                                               BusinessTypeOrOrgCode := placeOfProductionOfArray, 
                                               Quantity := ifexpr( isCapacity,
                                                                   CapacityAndSaleBudge::GetSheetByYear( productCodeList, otdTable, [Number]year ),
                                                                   MappingForecast::GetQuantityByYear( productCodeList, mappingParent, [Number]year ) )
                                               );  
          // S&OP
        traverse( macroPlans, Elements, macroPlan ) {
          this.CapacityAndSaleBudgeChartElement( relnew, 
                                                 TimeStringAndScenarioName := [String]year + "年-" + macroPlan.ScenarioName(),
                                                 BusinessTypeOrOrgCode := placeOfProductionOfArray, 
                                                 Quantity := ifexpr( isCapacity,
                                                                     Product_MP::GetNewSupplyByYear( productCodeList, macroPlan, [Number]year ),
                                                                     0.0 )
                                                 ); 
        }                    
      }
    } 
    if ( byBusinessTypeOrByOrgCode = "面板基地" and groupBy = "半年" ) {
      for( halfNo := 1; halfNo <= 2; halfNo := halfNo + 1 ) {
        traverse( placeOfProductionOfArrayList, Elements, placeOfProductionOfArray ) {
          productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByPlaceOfProductionOfArray( rows, placeOfProductionOfArray );
          this.CapacityAndSaleBudgeChartElement( relnew, 
                                                 TimeStringAndScenarioName := [String]year + "年-" + ifexpr( halfNo = 1, "上", "下" ) + "半年-目标",
                                                 BusinessTypeOrOrgCode := placeOfProductionOfArray, 
                                                 Quantity := ifexpr( isCapacity,
                                                                     CapacityAndSaleBudge::GetSheetByHalfYear( productCodeList, otdTable, [Number]year, halfNo ),
                                                                     MappingForecast::GetQuantityByHalfYear( productCodeList, mappingParent, [Number]year, halfNo ) )
                                                 );  
            // S&OP
          traverse( macroPlans, Elements, macroPlan ) {
            this.CapacityAndSaleBudgeChartElement( relnew, 
                                                   TimeStringAndScenarioName := [String]year + "年-" + ifexpr( halfNo = 1, "上", "下" ) + "半年-" + macroPlan.ScenarioName(),
                                                   BusinessTypeOrOrgCode := placeOfProductionOfArray, 
                                                   Quantity := ifexpr( isCapacity,
                                                                       Product_MP::GetNewSupplyByHalfYear( productCodeList, macroPlan, [Number]year, halfNo ),
                                                                       0.0 )
                                                   ); 
          }                    
        }
      }
    }
    if ( byBusinessTypeOrByOrgCode = "面板基地" and groupBy = "季度" ) {
      for( seasonNo := 1; seasonNo <= 4; seasonNo := seasonNo + 1 ) {
        traverse( placeOfProductionOfArrayList, Elements, placeOfProductionOfArray ) {
          productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByPlaceOfProductionOfArray( rows, placeOfProductionOfArray );
          this.CapacityAndSaleBudgeChartElement( relnew, 
                                                 TimeStringAndScenarioName := [String]year + "年-第" + [String]seasonNo + "季度-目标",
                                                 BusinessTypeOrOrgCode := placeOfProductionOfArray, 
                                                 Quantity := ifexpr( isCapacity,
                                                                     CapacityAndSaleBudge::GetSheetBySeason( productCodeList, otdTable, [Number]year, seasonNo ),
                                                                     MappingForecast::GetQuantityBySeason( productCodeList, mappingParent, [Number]year, seasonNo ) )
                                                 );  
            // S&OP
          traverse( macroPlans, Elements, macroPlan ) {
            this.CapacityAndSaleBudgeChartElement( relnew, 
                                                   TimeStringAndScenarioName := [String]year + "年-第" + [String]seasonNo + "季度-" + macroPlan.ScenarioName(),
                                                   BusinessTypeOrOrgCode := placeOfProductionOfArray, 
                                                   Quantity := ifexpr( isCapacity,
                                                                       Product_MP::GetNewSupplyBySeason( productCodeList, macroPlan, [Number]year, seasonNo ),
                                                                       0.0 )
                                                   ); 
          }                    
        }
      }
    }
    if ( byBusinessTypeOrByOrgCode = "面板基地" and groupBy = "月" ) {
      for( monthNo := 1; monthNo <= 12; monthNo := monthNo + 1 ) {
        traverse( placeOfProductionOfArrayList, Elements, placeOfProductionOfArray ) {
          productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByPlaceOfProductionOfArray( rows, placeOfProductionOfArray );
          this.CapacityAndSaleBudgeChartElement( relnew, 
                                                 TimeStringAndScenarioName := [String]year + "年-第" + [String]monthNo + "月-目标",
                                                 BusinessTypeOrOrgCode := placeOfProductionOfArray, 
                                                 Quantity := ifexpr( isCapacity,
                                                                     CapacityAndSaleBudge::GetSheetByMonth( productCodeList, otdTable, [Number]year, monthNo ),
                                                                     MappingForecast::GetQuantityByMonth( productCodeList, mappingParent, [Number]year, monthNo ) )
                                                 );  
            // S&OP
          traverse( macroPlans, Elements, macroPlan ) {
            this.CapacityAndSaleBudgeChartElement( relnew, 
                                                   TimeStringAndScenarioName := [String]year + "年-第" + [String]monthNo + "月-" + macroPlan.ScenarioName(),
                                                   BusinessTypeOrOrgCode := placeOfProductionOfArray, 
                                                   Quantity := ifexpr( isCapacity,
                                                                       Product_MP::GetNewSupplyByMonth( productCodeList, macroPlan, [Number]year, monthNo ),
                                                                       0.0 )
                                                   ); 
          }                    
        }
      }
    }
    if( byBusinessTypeOrByOrgCode = "事业部" and groupBy = "年" ) {
      // 目标
      traverse( businessTypeList, Elements, businessType ) {
        productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByBusinessType( rows, businessType );
        this.CapacityAndSaleBudgeChartElement( relnew, 
                                               TimeStringAndScenarioName := [String]year + "年-目标",
                                               BusinessTypeOrOrgCode := businessType, 
                                               Quantity := ifexpr( isCapacity,
                                                                   CapacityAndSaleBudge::GetSheetByYear( productCodeList, otdTable, [Number]year ),
                                                                   MappingForecast::GetQuantityByYear( productCodeList, mappingParent, [Number]year ) )
                                               );  
          // S&OP
        traverse( macroPlans, Elements, macroPlan ) {
          this.CapacityAndSaleBudgeChartElement( relnew, 
                                                 TimeStringAndScenarioName := [String]year + "年-" + macroPlan.ScenarioName(),
                                                 BusinessTypeOrOrgCode := businessType, 
                                                 Quantity := ifexpr( isCapacity,
                                                                     Product_MP::GetNewSupplyByYear( productCodeList, macroPlan, [Number]year ),
                                                                     0.0 )
                                                 ); 
        }                    
      }
    } 
    if ( byBusinessTypeOrByOrgCode = "事业部" and groupBy = "半年" ) {
      for( halfNo := 1; halfNo <= 2; halfNo := halfNo + 1 ) {
        traverse( businessTypeList, Elements, businessType ) {
          productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByBusinessType( rows, businessType );
          this.CapacityAndSaleBudgeChartElement( relnew, 
                                                 TimeStringAndScenarioName := [String]year + "年-" + ifexpr( halfNo = 1, "上", "下" ) + "半年-目标",
                                                 BusinessTypeOrOrgCode := businessType, 
                                                 Quantity := ifexpr( isCapacity,
                                                                     CapacityAndSaleBudge::GetSheetByHalfYear( productCodeList, otdTable, [Number]year, halfNo ),
                                                                     MappingForecast::GetQuantityByHalfYear( productCodeList, mappingParent, [Number]year, halfNo ) )
                                                 );  
            // S&OP
          traverse( macroPlans, Elements, macroPlan ) {
            this.CapacityAndSaleBudgeChartElement( relnew, 
                                                   TimeStringAndScenarioName := [String]year + "年-" + ifexpr( halfNo = 1, "上", "下" ) + "半年-" + macroPlan.ScenarioName(),
                                                   BusinessTypeOrOrgCode := businessType, 
                                                   Quantity := ifexpr( isCapacity,
                                                                       Product_MP::GetNewSupplyByHalfYear( productCodeList, macroPlan, [Number]year, halfNo ),
                                                                       0.0 )
                                                   ); 
          }                    
        }
      }
    }
    if ( byBusinessTypeOrByOrgCode = "事业部" and groupBy = "季度" ) {
      for( seasonNo := 1; seasonNo <= 4; seasonNo := seasonNo + 1 ) {
        traverse( businessTypeList, Elements, businessType ) {
          productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByBusinessType( rows, businessType );
          this.CapacityAndSaleBudgeChartElement( relnew, 
                                                 TimeStringAndScenarioName := [String]year + "年-第" + [String]seasonNo + "季度-目标",
                                                 BusinessTypeOrOrgCode := businessType, 
                                                 Quantity := ifexpr( isCapacity,
                                                                     CapacityAndSaleBudge::GetSheetBySeason( productCodeList, otdTable, [Number]year, seasonNo ),
                                                                     MappingForecast::GetQuantityBySeason( productCodeList, mappingParent, [Number]year, seasonNo ) )
                                                 );  
            // S&OP
          traverse( macroPlans, Elements, macroPlan ) {
            this.CapacityAndSaleBudgeChartElement( relnew, 
                                                   TimeStringAndScenarioName := [String]year + "年-第" + [String]seasonNo + "季度-" + macroPlan.ScenarioName(),
                                                   BusinessTypeOrOrgCode := businessType, 
                                                   Quantity := ifexpr( isCapacity,
                                                                       Product_MP::GetNewSupplyBySeason( productCodeList, macroPlan, [Number]year, seasonNo ),
                                                                       0.0 )
                                                   ); 
          }                    
        }
      }
    }
    if ( byBusinessTypeOrByOrgCode = "事业部" and groupBy = "月" ) {
      for( monthNo := 1; monthNo <= 12; monthNo := monthNo + 1 ) {
        traverse( businessTypeList, Elements, businessType ) {
          productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByBusinessType( rows, businessType );
          this.CapacityAndSaleBudgeChartElement( relnew, 
                                                 TimeStringAndScenarioName := [String]year + "年-第" + [String]monthNo + "月-目标",
                                                 BusinessTypeOrOrgCode := businessType, 
                                                 Quantity := ifexpr( isCapacity,
                                                                     CapacityAndSaleBudge::GetSheetByMonth( productCodeList, otdTable, [Number]year, monthNo ),
                                                                     MappingForecast::GetQuantityByMonth( productCodeList, mappingParent, [Number]year, monthNo ) )
                                                 );  
            // S&OP
          traverse( macroPlans, Elements, macroPlan ) {
            this.CapacityAndSaleBudgeChartElement( relnew, 
                                                   TimeStringAndScenarioName := [String]year + "年-第" + [String]monthNo + "月-" + macroPlan.ScenarioName(),
                                                   BusinessTypeOrOrgCode := businessType, 
                                                   Quantity := ifexpr( isCapacity,
                                                                       Product_MP::GetNewSupplyByMonth( productCodeList, macroPlan, [Number]year, monthNo ),
                                                                       0.0 )
                                                   ); 
          }                    
        }
      }
    }
  *]
}