hongji.li
2023-11-03 d6bd7a69bc31efa79b21c7be12ba9547a921c251
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
Quintiq file version 2.0
#parent: #root
Method CapacityAndSaleBudgeChart (
  MacroPlans macroPlans,
  String saleOrCapacity,
  String groupBy,
  String popoa,
  owning CapacityAndSaleBudgeFilterItems items,
  owning CapacityAndSaleBudgeFilterPlaceOfProductionOfArrays placeOfProductionOfArrays,
  owning CapacityAndSaleBudgeFilterBusinessTypes businessTypes,
  owning CapacityAndSaleBudgeFilterYears years,
  owning CapacityAndSaleBudgeFilterMonths months,
  GlobalOTDTable otdTable
)
{
  Description: '按入参处理数据,产生需要的CapacityAndSaleBudgeChartElement'
  TextBody:
  [*
    this.CapacityAndSaleBudgeChartRow( relflush );
    this.CapacityAndSaleBudgeChartElement( relflush );
    
    casbcirs := CapacityAndSaleBudgeChartElement::SelectGenerateChartRows( this, &items, &placeOfProductionOfArrays, &businessTypes, &years, &months );
    
    CapacityAndSaleBudgeChartElement::CreateData( this, macroPlans, casbcirs, popoa, groupBy, saleOrCapacity, years, months );
    
    //// 年份不选时全选
    //if ( years.Size() = 0 ) {
    //  years := selectset( this, CapacityAndSaleBudgeFilterYear, tempCASBFY, tempCASBFY.YearNo() = Date::ActualDate().Year() );
    //}
    //// 月份不选时全选
    //if ( months.Size() = 0 ) {
    //  months := selectsortedset( this, CapacityAndSaleBudgeFilterMonth, item, true, item.MonthNo() );
    //}
    //
    //// ====清理旧数据====
    //
    //// ====按面板基地和事业部对产品进行筛选分组====
    //targeGlobal_MappingAnnualBudgetDatas := selectset( otdTable, Global_MappingAnnualBudgetData, tempGMABD, true );
    //if ( businessTypes.Size() > 0 ) {
    //  businessTypeStrings := selectuniquevalues( businessTypes, Elements, item, true, item.BusinessType() );
    //  targeGlobal_MappingAnnualBudgetDatas := selectset( targeGlobal_MappingAnnualBudgetDatas, Elements, item, businessTypeStrings.Find( item.BusinessType() ) > -1 );
    //}
    //if ( placeOfProductionOfArrays.Size() > 0 ) {
    //  placeOfProductionOfArrayStrings := selectuniquevalues( placeOfProductionOfArrays, Elements, item, true, item.PlaceOfProductionOfArray() );
    //  targeGlobal_MappingAnnualBudgetDatas := selectset( targeGlobal_MappingAnnualBudgetDatas, Elements, item, placeOfProductionOfArrayStrings.Find( item.OrganCode() ) > -1 );
    //}
    ////info( "选中的个数:", targeGlobal_MappingAnnualBudgetDatas.Size() );
    //
    //traverse ( targeGlobal_MappingAnnualBudgetDatas, Elements, gmabd ) {
    //  row := CapacityAndSaleBudgeChartRow::CreateIfNotExist( this, gmabd.BusinessType(), gmabd.OrganCode() );
    //  // 记录每行包含哪些product
    //  CapacityAndSaleBudgeChartRowProduct::CreateIfNotExist( row, gmabd.ProductID() );
    //}
    //
    //rows := selectset( this, CapacityAndSaleBudgeChartRow, item, true );
    //placeOfProductionOfArrayList := selectuniquevalues( targeGlobal_MappingAnnualBudgetDatas, Elements, tempGMABD, tempGMABD.OrganCode() );
    //businessTypeList := selectuniquevalues( targeGlobal_MappingAnnualBudgetDatas, Elements, tempGMABD, tempGMABD.BusinessType() );
    //
    //// 生成图表元素
    //traverse ( years, Elements, year ) {
    //  if ( popoa = "面板基地" and groupBy = "年" ) {
    //    // 目标
    //    traverse ( placeOfProductionOfArrayList, Elements, placeOfProductionOfArray ) {
    //      productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByPlaceOfProductionOfArray( rows, placeOfProductionOfArray );
    //      this.CapacityAndSaleBudgeChartElement( relnew, 
    //                                             TimeStringAndScenarioName := [String]year.YearNo() + "年-目标",
    //                                             BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray, 
    //                                             Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                 Global_MappingAnnualBudgetData::GetSaleByYear( productCodeList, otdTable, year.YearNo() ),
    //                                                                 Global_MappingForecast::GetQuantityByYear( productCodeList, otdTable, year.YearNo() ) )
    //                                            );
    //      // S&OP
    //      traverse ( macroPlans, Elements, macroPlan ) {
    //        this.CapacityAndSaleBudgeChartElement( relnew, 
    //                                               TimeStringAndScenarioName := [String]year.YearNo() + "年-" + macroPlan.ScenarioName(),
    //                                               BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray, 
    //                                               Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                   Forecast::GetFulfilledBalanceByYear( productCodeList, macroPlan, year.YearNo() ),
    //                                                                   Product_MP::GetNewSupplyByYear( productCodeList, macroPlan, year.YearNo() ) 
    //                                                                   )
    //                                               ); 
    //      }                    
    //    }
    //  } 
    //  if ( popoa = "面板基地" 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.YearNo() + "年-" + ifexpr( halfNo = 1, "上", "下" ) + "半年-目标",
    //                                               BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray, 
    //                                               Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                   Global_MappingAnnualBudgetData::GetSaleByHalfYear( productCodeList, otdTable, year.YearNo(), halfNo ),
    //                                                                   Global_MappingForecast::GetQuantityByHalfYear( productCodeList, otdTable, year.YearNo(), halfNo ) )
    //                                               );  
    //        // S&OP
    //        traverse( macroPlans, Elements, macroPlan ) {
    //          this.CapacityAndSaleBudgeChartElement( relnew, 
    //                                                 TimeStringAndScenarioName := [String]year.YearNo() + "年-" + ifexpr( halfNo = 1, "上", "下" ) + "半年-" + macroPlan.ScenarioName(),
    //                                                 BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray, 
    //                                                 Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                     Forecast::GetFulfilledBalanceByHalfYear( productCodeList, macroPlan, year.YearNo(), halfNo ),
    //                                                                     Product_MP::GetNewSupplyByHalfYear( productCodeList, macroPlan, year.YearNo(), halfNo )
    //                                                                     )
    //                                                 ); 
    //        }                    
    //      }
    //    }
    //  }
    //  if ( popoa = "面板基地" 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.YearNo() + "年-第" + [String]seasonNo + "季度-目标",
    //                                               BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray, 
    //                                               Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                   Global_MappingAnnualBudgetData::GetSaleBySeason( productCodeList, otdTable, year.YearNo(), seasonNo ),
    //                                                                   Global_MappingForecast::GetQuantityBySeason( productCodeList, otdTable, year.YearNo(), seasonNo ) )
    //                                               );  
    //  //      info( "productCodeList : " + [String]productCodeList.Size() );
    //        // S&OP
    //        traverse( macroPlans, Elements, macroPlan ) {
    //          this.CapacityAndSaleBudgeChartElement( relnew, 
    //                                                 TimeStringAndScenarioName := [String]year.YearNo() + "年-第" + [String]seasonNo + "季度-" + macroPlan.ScenarioName(),
    //                                                 BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray, 
    //                                                 Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                     Forecast::GetFulfilledBalanceBySeason( productCodeList, macroPlan, year.YearNo(), seasonNo ) ,
    //                                                                     Product_MP::GetNewSupplyBySeason( productCodeList, macroPlan, year.YearNo(), seasonNo )
    //                                                                     )
    //                                                 ); 
    //        }                    
    //      }
    //    }
    //  }
    //  if ( popoa = "面板基地" and groupBy = "月" ) {
    //    traverse( months, Elements, month ) {
    ////      info( "process month start : " + [String]month.MonthNo() );
    //      monthNoString := ifexpr( month.MonthNo() <= 9, "0" + [String]month.MonthNo(), [String]month.MonthNo() );
    //      traverse( placeOfProductionOfArrayList, Elements, placeOfProductionOfArray ) {
    //        productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByPlaceOfProductionOfArray( rows, placeOfProductionOfArray );
    //        this.CapacityAndSaleBudgeChartElement( relnew, 
    //                                               TimeStringAndScenarioName := [String]year.YearNo() + "年-第" + monthNoString + "月-目标",
    //                                               BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray, 
    //                                               Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                   Global_MappingAnnualBudgetData::GetSaleByMonth( productCodeList, otdTable, year.YearNo(), month.MonthNo() ),
    //                                                                   Global_MappingForecast::GetQuantityByMonth( productCodeList, otdTable, year.YearNo(), month.MonthNo() ) )
    //                                               );  
    //        // S&OP
    //        traverse( macroPlans, Elements, macroPlan ) {
    //          this.CapacityAndSaleBudgeChartElement( relnew, 
    //                                                 TimeStringAndScenarioName := [String]year.YearNo() + "年-第" + monthNoString + "月-" + macroPlan.ScenarioName(),
    //                                                 BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray, 
    //                                                 Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                     Forecast::GetFulfilledBalanceByMonth( productCodeList, macroPlan, year.YearNo(), month.MonthNo() ),
    //                                                                     Product_MP::GetNewSupplyByMonth( productCodeList, macroPlan, year.YearNo(), month.MonthNo() ) 
    //                                                                     )
    //                                                 ); 
    //        }
    //      }
    ////      info( "process month end : " + [String]month.MonthNo() );
    //    }
    //  }
    //  if( popoa = "事业部" and groupBy = "年" ) {
    //    // 目标
    //    traverse( businessTypeList, Elements, businessType ) {
    //      productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByBusinessType( rows, businessType );
    //      this.CapacityAndSaleBudgeChartElement( relnew, 
    //                                             TimeStringAndScenarioName := [String]year.YearNo() + "年-目标",
    //                                             BusinessTypeOrPlaceOfProductionOfArray := businessType, 
    //                                             Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                 Global_MappingAnnualBudgetData::GetSaleByYear( productCodeList, otdTable, year.YearNo() ),
    //                                                                 Global_MappingForecast::GetQuantityByYear( productCodeList, otdTable, year.YearNo() ) )
    //                                             );  
    //      // S&OP
    //      traverse( macroPlans, Elements, macroPlan ) {
    //        this.CapacityAndSaleBudgeChartElement( relnew, 
    //                                               TimeStringAndScenarioName := [String]year.YearNo() + "年-" + macroPlan.ScenarioName(),
    //                                               BusinessTypeOrPlaceOfProductionOfArray := businessType, 
    //                                               Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                   Forecast::GetFulfilledBalanceByYear( productCodeList, macroPlan, year.YearNo() ) ,
    //                                                                   Product_MP::GetNewSupplyByYear( productCodeList, macroPlan, year.YearNo() )
    //                                                                   )
    //                                               ); 
    //      }                    
    //    }
    //  } 
    //  if ( popoa = "事业部" 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.YearNo() + "年-" + ifexpr( halfNo = 1, "上", "下" ) + "半年-目标",
    //                                               BusinessTypeOrPlaceOfProductionOfArray := businessType, 
    //                                               Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                   Global_MappingAnnualBudgetData::GetSaleByHalfYear( productCodeList, otdTable, year.YearNo(), halfNo ),
    //                                                                   Global_MappingForecast::GetQuantityByHalfYear( productCodeList, otdTable, year.YearNo(), halfNo ) )
    //                                               );  
    //        // S&OP
    //        traverse( macroPlans, Elements, macroPlan ) {
    //          this.CapacityAndSaleBudgeChartElement( relnew, 
    //                                                 TimeStringAndScenarioName := [String]year.YearNo() + "年-" + ifexpr( halfNo = 1, "上", "下" ) + "半年-" + macroPlan.ScenarioName(),
    //                                                 BusinessTypeOrPlaceOfProductionOfArray := businessType, 
    //                                                 Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                     Forecast::GetFulfilledBalanceByHalfYear( productCodeList, macroPlan, year.YearNo(), halfNo ) ,
    //                                                                     Product_MP::GetNewSupplyByHalfYear( productCodeList, macroPlan, year.YearNo(), halfNo )
    //                                                                     )
    //                                                 ); 
    //        }                    
    //      }
    //    }
    //  }
    //  if ( popoa = "事业部" and groupBy = "季度" ) {
    //    for( seasonNo := 1; seasonNo <= 4; seasonNo := seasonNo + 1 ) {
    ////      debuginfo( "process season start : " + [String]seasonNo );
    //      traverse( businessTypeList, Elements, businessType ) {
    //        productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByBusinessType( rows, businessType );
    //        this.CapacityAndSaleBudgeChartElement( relnew, 
    //                                               TimeStringAndScenarioName := [String]year.YearNo() + "年-第" + [String]seasonNo + "季度-目标",
    //                                               BusinessTypeOrPlaceOfProductionOfArray := businessType, 
    //                                               Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                   Global_MappingAnnualBudgetData::GetSaleBySeason( productCodeList, otdTable, year.YearNo(), seasonNo ),
    //                                                                   Global_MappingForecast::GetQuantityBySeason( productCodeList, otdTable, year.YearNo(), seasonNo ) )
    //                                               );  
    //        // S&OP
    //        traverse( macroPlans, Elements, macroPlan ) {
    //          this.CapacityAndSaleBudgeChartElement( relnew, 
    //                                                 TimeStringAndScenarioName := [String]year.YearNo() + "年-第" + [String]seasonNo + "季度-" + macroPlan.ScenarioName(),
    //                                                 BusinessTypeOrPlaceOfProductionOfArray := businessType, 
    //                                                 Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                     Forecast::GetFulfilledBalanceBySeason( productCodeList, macroPlan, year.YearNo(), seasonNo ),
    //                                                                     Product_MP::GetNewSupplyBySeason( productCodeList, macroPlan, year.YearNo(), seasonNo ) 
    //                                                                     )
    //                                                 ); 
    //        }                    
    //      }
    ////      info( "process season end : " + [String]seasonNo );
    //    }
    //  }
    //  if ( popoa = "事业部" and groupBy = "月" ) {
    //    traverse( months, Elements, month ) {
    ////      debuginfo( "process month start : " + [String]month.MonthNo() );
    //      monthNoString := ifexpr( month.MonthNo() <= 9, "0" + [String]month.MonthNo(), [String]month.MonthNo() );
    //      traverse( businessTypeList, Elements, businessType ) {
    //        productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByBusinessType( rows, businessType );
    //        this.CapacityAndSaleBudgeChartElement( relnew, 
    //                                               TimeStringAndScenarioName := [String]year.YearNo() + "年-第" + monthNoString + "月-目标",
    //                                               BusinessTypeOrPlaceOfProductionOfArray := businessType, 
    //                                               Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                   Global_MappingAnnualBudgetData::GetSaleByMonth( productCodeList, otdTable, year.YearNo(), month.MonthNo() ),
    //                                                                   Global_MappingForecast::GetQuantityByMonth( productCodeList, otdTable, year.YearNo(), month.MonthNo() ) )
    //                                               );  
    //        // S&OP
    //        traverse( macroPlans, Elements, macroPlan ) {
    //          this.CapacityAndSaleBudgeChartElement( relnew, 
    //                                                 TimeStringAndScenarioName := [String]year.YearNo() + "年-第" + monthNoString + "月-" + macroPlan.ScenarioName(),
    //                                                 BusinessTypeOrPlaceOfProductionOfArray := businessType, 
    //                                                 Quantity := ifexpr( saleOrCapacity = "销售额",
    //                                                                     Forecast::GetFulfilledBalanceByMonth( productCodeList, macroPlan, year.YearNo(), month.MonthNo() ) ,
    //                                                                     Product_MP::GetNewSupplyByMonth( productCodeList, macroPlan, year.YearNo(), month.MonthNo() )
    //                                                                     )
    //                                                 ); 
    //        }            
    //      }
    ////      debuginfo( "process month end : " + [String]month.MonthNo() );
    //    }
    //  }
    //}
    ////info( "CapacityAndSaleBudgeChartElement : " + [String]selectset( this, CapacityAndSaleBudgeChartElement, item, true ).Size() );
    ////traverse( this, CapacityAndSaleBudgeChartRow, row ) {
    ////  info( "==↓==" );
    ////  info( row.BusinessType() );
    ////  info( row.PlaceOfProductionOfArray() );
    ////  elements := selectset( row, CapacityAndSaleBudgeChartRowProduct, cell, true );
    ////  info( elements.Size() );
    ////  info( row.GetProductCodes().Concatenate( " | " ) );
    ////  info( "==↑==" );
    ////}
  *]
}