| Quintiq file version 2.0 | 
| #parent: #root | 
| Method CapacityAndSaleBudgeChart ( | 
|   MacroPlans macroPlans, | 
|   String saleOrCapacity, | 
|   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( saleOrCapacity ); | 
|     // 月;季度;半年;年 | 
|     info( groupBy ); | 
|     // 面板基地;事业部 | 
|     info( byBusinessTypeOrByOrgCode ); | 
|     info( businessTypeChosen ); | 
|     info( placeOfProductionOfArrayChosen ); | 
|     info( year ); | 
|      | 
|     // ====清理旧数据==== | 
|     this.CapacityAndSaleBudgeChartRow( relflush ); | 
|     this.CapacityAndSaleBudgeChartElement( relflush ); | 
|      | 
|     // ====按面板基地和事业部对产品进行筛选分组==== | 
|     historyData := selectset( mpSync, MappingCapacityAndSaleBudge, item, true ); | 
|     if( placeOfProductionOfArrayChosen <> "" ) { | 
|       historyData := selectset( historyData, Elements, item, item.PlaceOfProductionOfArray() = placeOfProductionOfArrayChosen ); | 
|     } | 
|     if( businessTypeChosen <> "" ) { | 
|       historyData := selectset( historyData, Elements, item, item.BusinessType() = businessTypeChosen ); | 
|     } | 
|     //info( "historyData : " + [String]historyData.Size() ); | 
|     traverse( historyData, Elements, item ) { | 
|       row := CapacityAndSaleBudgeChartRow::CreateIfNotExist( this, item.BusinessType(), item.PlaceOfProductionOfArray() ); | 
|       // 记录每行包含哪些product | 
|       CapacityAndSaleBudgeChartRowProduct::CreateIfNotExist( row, item.ProductCode() ); | 
|     } | 
|     rows := selectset( this, CapacityAndSaleBudgeChartRow, item, true ); | 
|     //info( "rows : " + [String]rows.Size() ); | 
|     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 + "年-目标", | 
|                                                BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray,  | 
|                                                Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                    MappingAnnualBudget::GetSheetByYear( productCodeList, mpSync, [Number]year ), | 
|                                                                    MappingCapacityAndSaleBudge::GetSheetByYear( productCodeList, mpSync, [Number]year ) ) | 
|                                                );   | 
|         // S&OP | 
|         traverse( macroPlans, Elements, macroPlan ) { | 
|           this.CapacityAndSaleBudgeChartElement( relnew,  | 
|                                                  TimeStringAndScenarioName := [String]year + "年-" + macroPlan.ScenarioName(), | 
|                                                  BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray,  | 
|                                                  Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                      0.0, | 
|                                                                      Product_MP::GetNewSupplyByYear( productCodeList, macroPlan, [Number]year ) ) | 
|                                                  );  | 
|         }                     | 
|       } | 
|     }  | 
|     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, "上", "下" ) + "半年-目标", | 
|                                                  BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray,  | 
|                                                  Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                      MappingAnnualBudget::GetSheetByHalfYear( productCodeList, mpSync, [Number]year, halfNo ), | 
|                                                                      MappingCapacityAndSaleBudge::GetSheetByHalfYear( productCodeList, mpSync, [Number]year, halfNo ) ) | 
|                                                  );   | 
|           // S&OP | 
|           traverse( macroPlans, Elements, macroPlan ) { | 
|             this.CapacityAndSaleBudgeChartElement( relnew,  | 
|                                                    TimeStringAndScenarioName := [String]year + "年-" + ifexpr( halfNo = 1, "上", "下" ) + "半年-" + macroPlan.ScenarioName(), | 
|                                                    BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray,  | 
|                                                    Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                        0.0, | 
|                                                                        Product_MP::GetNewSupplyByHalfYear( productCodeList, macroPlan, [Number]year, halfNo ) ) | 
|                                                    );  | 
|           }                     | 
|         } | 
|       } | 
|     } | 
|     if ( byBusinessTypeOrByOrgCode = "面板基地" and groupBy = "季度" ) { | 
|       for( seasonNo := 1; seasonNo <= 4; seasonNo := seasonNo + 1 ) { | 
|         traverse( placeOfProductionOfArrayList, Elements, placeOfProductionOfArray ) { | 
|           productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByPlaceOfProductionOfArray( rows, placeOfProductionOfArray ); | 
|     //      info( "productCodeList : " + [String]productCodeList.Size() ); | 
|     //      info( "MappingCapacityAndSaleBudge::GetSheetBySeason : " + [String]MappingCapacityAndSaleBudge::GetSheetBySeason( productCodeList, mpSync, [Number]year, seasonNo ) ); | 
|     //      info( "seasonNo : " + [String]seasonNo ); | 
|           this.CapacityAndSaleBudgeChartElement( relnew,  | 
|                                                  TimeStringAndScenarioName := [String]year + "年-第" + [String]seasonNo + "季度-目标", | 
|                                                  BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray,  | 
|                                                  Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                      MappingAnnualBudget::GetSheetBySeason( productCodeList, mpSync, [Number]year, seasonNo ), | 
|                                                                      MappingCapacityAndSaleBudge::GetSheetBySeason( productCodeList, mpSync, [Number]year, seasonNo ) ) | 
|                                                  );   | 
|     //      info( "productCodeList : " + [String]productCodeList.Size() ); | 
|           // S&OP | 
|           traverse( macroPlans, Elements, macroPlan ) { | 
|             this.CapacityAndSaleBudgeChartElement( relnew,  | 
|                                                    TimeStringAndScenarioName := [String]year + "年-第" + [String]seasonNo + "季度-" + macroPlan.ScenarioName(), | 
|                                                    BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray,  | 
|                                                    Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                        0.0, | 
|                                                                        Product_MP::GetNewSupplyBySeason( productCodeList, macroPlan, [Number]year, seasonNo ) ) | 
|                                                    );  | 
|           }                     | 
|         } | 
|       } | 
|     } | 
|     if ( byBusinessTypeOrByOrgCode = "面板基地" and groupBy = "月" ) { | 
|       for( monthNo := 1; monthNo <= 12; monthNo := monthNo + 1 ) { | 
|         monthNoString := ifexpr( monthNo <= 9, "0" + [String]monthNo, [String]monthNo ); | 
|         traverse( placeOfProductionOfArrayList, Elements, placeOfProductionOfArray ) { | 
|           productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByPlaceOfProductionOfArray( rows, placeOfProductionOfArray ); | 
|           this.CapacityAndSaleBudgeChartElement( relnew,  | 
|                                                  TimeStringAndScenarioName := [String]year + "年-第" + monthNoString + "月-目标", | 
|                                                  BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray,  | 
|                                                  Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                      MappingAnnualBudget::GetSheetByMonth( productCodeList, mpSync, [Number]year, monthNo ), | 
|                                                                      MappingCapacityAndSaleBudge::GetSheetByMonth( productCodeList, mpSync, [Number]year, monthNo ) ) | 
|                                                  );   | 
|           // S&OP | 
|           traverse( macroPlans, Elements, macroPlan ) { | 
|             this.CapacityAndSaleBudgeChartElement( relnew,  | 
|                                                    TimeStringAndScenarioName := [String]year + "年-第" + monthNoString + "月-" + macroPlan.ScenarioName(), | 
|                                                    BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray,  | 
|                                                    Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                        0.0, | 
|                                                                        Product_MP::GetNewSupplyByMonth( productCodeList, macroPlan, [Number]year, monthNo ) ) | 
|                                                    );  | 
|           }                     | 
|         } | 
|       } | 
|     } | 
|     if( byBusinessTypeOrByOrgCode = "事业部" and groupBy = "年" ) { | 
|       // 目标 | 
|       traverse( businessTypeList, Elements, businessType ) { | 
|         productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByBusinessType( rows, businessType ); | 
|         this.CapacityAndSaleBudgeChartElement( relnew,  | 
|                                                TimeStringAndScenarioName := [String]year + "年-目标", | 
|                                                BusinessTypeOrPlaceOfProductionOfArray := businessType,  | 
|                                                Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                    MappingAnnualBudget::GetSheetByYear( productCodeList, mpSync, [Number]year ), | 
|                                                                    MappingCapacityAndSaleBudge::GetSheetByYear( productCodeList, mpSync, [Number]year ) ) | 
|                                                );   | 
|         // S&OP | 
|         traverse( macroPlans, Elements, macroPlan ) { | 
|           this.CapacityAndSaleBudgeChartElement( relnew,  | 
|                                                  TimeStringAndScenarioName := [String]year + "年-" + macroPlan.ScenarioName(), | 
|                                                  BusinessTypeOrPlaceOfProductionOfArray := businessType,  | 
|                                                  Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                      0.0, | 
|                                                                      Product_MP::GetNewSupplyByYear( productCodeList, macroPlan, [Number]year ) ) | 
|                                                  );  | 
|         }                     | 
|       } | 
|     }  | 
|     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, "上", "下" ) + "半年-目标", | 
|                                                  BusinessTypeOrPlaceOfProductionOfArray := businessType,  | 
|                                                  Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                      MappingAnnualBudget::GetSheetByHalfYear( productCodeList, mpSync, [Number]year, halfNo ), | 
|                                                                      MappingCapacityAndSaleBudge::GetSheetByHalfYear( productCodeList, mpSync, [Number]year, halfNo ) ) | 
|                                                  );   | 
|           // S&OP | 
|           traverse( macroPlans, Elements, macroPlan ) { | 
|             this.CapacityAndSaleBudgeChartElement( relnew,  | 
|                                                    TimeStringAndScenarioName := [String]year + "年-" + ifexpr( halfNo = 1, "上", "下" ) + "半年-" + macroPlan.ScenarioName(), | 
|                                                    BusinessTypeOrPlaceOfProductionOfArray := businessType,  | 
|                                                    Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                        0.0, | 
|                                                                        Product_MP::GetNewSupplyByHalfYear( productCodeList, macroPlan, [Number]year, halfNo ) ) | 
|                                                    );  | 
|           }                     | 
|         } | 
|       } | 
|     } | 
|     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 + "季度-目标", | 
|                                                  BusinessTypeOrPlaceOfProductionOfArray := businessType,  | 
|                                                  Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                      MappingAnnualBudget::GetSheetBySeason( productCodeList, mpSync, [Number]year, seasonNo ), | 
|                                                                      MappingCapacityAndSaleBudge::GetSheetBySeason( productCodeList, mpSync, [Number]year, seasonNo ) ) | 
|                                                  );   | 
|           // S&OP | 
|           traverse( macroPlans, Elements, macroPlan ) { | 
|             this.CapacityAndSaleBudgeChartElement( relnew,  | 
|                                                    TimeStringAndScenarioName := [String]year + "年-第" + [String]seasonNo + "季度-" + macroPlan.ScenarioName(), | 
|                                                    BusinessTypeOrPlaceOfProductionOfArray := businessType,  | 
|                                                    Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                        0.0, | 
|                                                                        Product_MP::GetNewSupplyBySeason( productCodeList, macroPlan, [Number]year, seasonNo ) ) | 
|                                                    );  | 
|           }                     | 
|         } | 
|       } | 
|     } | 
|     if ( byBusinessTypeOrByOrgCode = "事业部" and groupBy = "月" ) { | 
|       for( monthNo := 1; monthNo <= 12; monthNo := monthNo + 1 ) { | 
|         monthNoString := ifexpr( monthNo <= 9, "0" + [String]monthNo, [String]monthNo ); | 
|         traverse( businessTypeList, Elements, businessType ) { | 
|           productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByBusinessType( rows, businessType ); | 
|           this.CapacityAndSaleBudgeChartElement( relnew,  | 
|                                                  TimeStringAndScenarioName := [String]year + "年-第" + monthNoString + "月-目标", | 
|                                                  BusinessTypeOrPlaceOfProductionOfArray := businessType,  | 
|                                                  Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                      MappingAnnualBudget::GetSheetByMonth( productCodeList, mpSync, [Number]year, monthNo ), | 
|                                                                      MappingCapacityAndSaleBudge::GetSheetByMonth( productCodeList, mpSync, [Number]year, monthNo ) ) | 
|                                                  );   | 
|           // S&OP | 
|           traverse( macroPlans, Elements, macroPlan ) { | 
|             this.CapacityAndSaleBudgeChartElement( relnew,  | 
|                                                    TimeStringAndScenarioName := [String]year + "年-第" + monthNoString + "月-" + macroPlan.ScenarioName(), | 
|                                                    BusinessTypeOrPlaceOfProductionOfArray := businessType,  | 
|                                                    Quantity := ifexpr( saleOrCapacity = "销售额", | 
|                                                                        0.0, | 
|                                                                        Product_MP::GetNewSupplyByMonth( productCodeList, macroPlan, [Number]year, 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( "==↑==" ); | 
|     //} | 
|   *] | 
| } |