Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method CapacityAndSaleBudgeChart ( 
 | 
  MacroPlans macroPlans, 
 | 
  String saleOrCapacity, 
 | 
  String groupBy, 
 | 
  String byBusinessTypeOrByOrgCode, 
 | 
  CapacityAndSaleBudgeFilterBusinessTypes businessTypes, 
 | 
  CapacityAndSaleBudgeFilterPlaceOfProductionOfArrays placeOfProductionOfArrays, 
 | 
  CapacityAndSaleBudgeFilterYears years, 
 | 
  CapacityAndSaleBudgeFilterMonths months, 
 | 
  MPSync mpSync, 
 | 
  GlobalOTDTable otdTable, 
 | 
  MacroPlan mappingParent 
 | 
) 
 | 
{ 
 | 
  Description: '按入参处理数据,产生需要的CapacityAndSaleBudgeChartElement' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // yypsybs Sep-19-2023 (created) 
 | 
    // true, false 
 | 
    info( saleOrCapacity ); 
 | 
    // 月;季度;半年;年 
 | 
    info( groupBy ); 
 | 
    // 面板基地;事业部 
 | 
    info( byBusinessTypeOrByOrgCode ); 
 | 
    traverse( businessTypes, Elements, businessType ) { 
 | 
      info( "businessType : " + businessType.BusinessType() ); 
 | 
    } 
 | 
    traverse( placeOfProductionOfArrays, Elements, placeOfProductionOfArray ) { 
 | 
      info( "placeOfProductionOfArray : " + placeOfProductionOfArray.PlaceOfProductionOfArray() ); 
 | 
    } 
 | 
    traverse( macroPlans, Elements, macroPlan ) { 
 | 
      info( "macroPlan : " + macroPlan.ScenarioName() );   
 | 
    } 
 | 
    // 年份不选时全选 
 | 
    if( years.Size() = 0 ) { 
 | 
      years := selectsortedset( this, CapacityAndSaleBudgeFilterYear, item, true, item.YearNo() ); 
 | 
    } 
 | 
    traverse( years, Elements, year ) { 
 | 
      info( "yearNo : " + [String]year.YearNo() ); 
 | 
    } 
 | 
    // 月份不选时全选 
 | 
    if( months.Size() = 0 ) { 
 | 
      months := selectsortedset( this, CapacityAndSaleBudgeFilterMonth, item, true, item.MonthNo() ); 
 | 
    } 
 | 
    traverse( months, Elements, month ) { 
 | 
      info( "monthNo : " + [String]month.MonthNo() ); 
 | 
    } 
 | 
     
 | 
    // ====清理旧数据==== 
 | 
    this.CapacityAndSaleBudgeChartRow( relflush ); 
 | 
    this.CapacityAndSaleBudgeChartElement( relflush ); 
 | 
     
 | 
    // ====按面板基地和事业部对产品进行筛选分组==== 
 | 
    historyData := selectset( mpSync, MappingCapacityAndSaleBudge, item, true ); 
 | 
    if( businessTypes.Size() > 0 ) { 
 | 
      businessTypeStrings := selectuniquevalues( businessTypes, Elements, item, true, item.BusinessType() ); 
 | 
      historyData := selectset( historyData, Elements, item, businessTypeStrings.Find( item.BusinessType() ) > -1 ); 
 | 
    } 
 | 
    if( placeOfProductionOfArrays.Size() > 0 ) { 
 | 
      placeOfProductionOfArrayStrings := selectuniquevalues( placeOfProductionOfArrays, Elements, item, true, item.PlaceOfProductionOfArray() ); 
 | 
      historyData := selectset( historyData, Elements, item, placeOfProductionOfArrayStrings.Find( item.PlaceOfProductionOfArray() ) > -1 ); 
 | 
    } 
 | 
    //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() ); 
 | 
    // 生成图表元素 
 | 
    traverse( years, Elements, year ) { 
 | 
      info( "process year start : " + [String]year.YearNo() ); 
 | 
      if( byBusinessTypeOrByOrgCode = "面板基地" and groupBy = "年" ) { 
 | 
        // 目标 
 | 
        traverse( placeOfProductionOfArrayList, Elements, placeOfProductionOfArray ) { 
 | 
          productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByPlaceOfProductionOfArray( rows, placeOfProductionOfArray ); 
 | 
          this.CapacityAndSaleBudgeChartElement( relnew,  
 | 
                                                 TimeStringAndScenarioName := [String]year.YearNo() + "年-目标", 
 | 
                                                 BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray,  
 | 
                                                 Quantity := ifexpr( saleOrCapacity = "销售额", 
 | 
                                                                     MappingAnnualBudget::GetSheetByYear( productCodeList, mpSync, year.YearNo() ), 
 | 
                                                                     MappingCapacityAndSaleBudge::GetSheetByYear( productCodeList, mpSync, year.YearNo() ) ) 
 | 
                                                 );   
 | 
          // S&OP 
 | 
          traverse( macroPlans, Elements, macroPlan ) { 
 | 
            this.CapacityAndSaleBudgeChartElement( relnew,  
 | 
                                                   TimeStringAndScenarioName := [String]year.YearNo() + "年-" + macroPlan.ScenarioName(), 
 | 
                                                   BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray,  
 | 
                                                   Quantity := ifexpr( saleOrCapacity = "销售额", 
 | 
                                                                       MappingCustomerOrder::GetNewSupplyByYear( productCodeList, macroPlan, year.YearNo() ), 
 | 
                                                                       Product_MP::GetNewSupplyByYear( productCodeList, macroPlan, year.YearNo() )  
 | 
                                                                       ) 
 | 
                                                   );  
 | 
          }                     
 | 
        } 
 | 
      }  
 | 
      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.YearNo() + "年-" + ifexpr( halfNo = 1, "上", "下" ) + "半年-目标", 
 | 
                                                   BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray,  
 | 
                                                   Quantity := ifexpr( saleOrCapacity = "销售额", 
 | 
                                                                       MappingAnnualBudget::GetSheetByHalfYear( productCodeList, mpSync, year.YearNo(), halfNo ), 
 | 
                                                                       MappingCapacityAndSaleBudge::GetSheetByHalfYear( productCodeList, mpSync, 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 = "销售额", 
 | 
                                                                         MappingCustomerOrder::GetNewSupplyByHalfYear( productCodeList, macroPlan, year.YearNo(), halfNo ), 
 | 
                                                                         Product_MP::GetNewSupplyByHalfYear( productCodeList, macroPlan, year.YearNo(), 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.YearNo() + "年-第" + [String]seasonNo + "季度-目标", 
 | 
                                                   BusinessTypeOrPlaceOfProductionOfArray := placeOfProductionOfArray,  
 | 
                                                   Quantity := ifexpr( saleOrCapacity = "销售额", 
 | 
                                                                       MappingAnnualBudget::GetSheetBySeason( productCodeList, mpSync, year.YearNo(), seasonNo ), 
 | 
                                                                       MappingCapacityAndSaleBudge::GetSheetBySeason( productCodeList, mpSync, 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 = "销售额", 
 | 
                                                                         MappingCustomerOrder::GetNewSupplyBySeason( productCodeList, macroPlan, year.YearNo(), seasonNo ) , 
 | 
                                                                         Product_MP::GetNewSupplyBySeason( productCodeList, macroPlan, year.YearNo(), seasonNo ) 
 | 
                                                                         ) 
 | 
                                                     );  
 | 
            }                     
 | 
          } 
 | 
        } 
 | 
      } 
 | 
      if ( byBusinessTypeOrByOrgCode = "面板基地" 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 = "销售额", 
 | 
                                                                       MappingAnnualBudget::GetSheetByMonth( productCodeList, mpSync, year.YearNo(), month.MonthNo() ), 
 | 
                                                                       MappingCapacityAndSaleBudge::GetSheetByMonth( productCodeList, mpSync, 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 = "销售额", 
 | 
                                                                         MappingCustomerOrder::GetNewSupplyByMonth( productCodeList, macroPlan, year.YearNo(), month.MonthNo() ), 
 | 
                                                                         Product_MP::GetNewSupplyByMonth( productCodeList, macroPlan, year.YearNo(), month.MonthNo() )  
 | 
                                                                         ) 
 | 
                                                     );  
 | 
            } 
 | 
          } 
 | 
          info( "process month end : " + [String]month.MonthNo() ); 
 | 
        } 
 | 
      } 
 | 
      if( byBusinessTypeOrByOrgCode = "事业部" and groupBy = "年" ) { 
 | 
        // 目标 
 | 
        traverse( businessTypeList, Elements, businessType ) { 
 | 
          productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByBusinessType( rows, businessType ); 
 | 
          this.CapacityAndSaleBudgeChartElement( relnew,  
 | 
                                                 TimeStringAndScenarioName := [String]year.YearNo() + "年-目标", 
 | 
                                                 BusinessTypeOrPlaceOfProductionOfArray := businessType,  
 | 
                                                 Quantity := ifexpr( saleOrCapacity = "销售额", 
 | 
                                                                     MappingAnnualBudget::GetSheetByYear( productCodeList, mpSync, year.YearNo() ), 
 | 
                                                                     MappingCapacityAndSaleBudge::GetSheetByYear( productCodeList, mpSync, year.YearNo() ) ) 
 | 
                                                 );   
 | 
          // S&OP 
 | 
          traverse( macroPlans, Elements, macroPlan ) { 
 | 
            this.CapacityAndSaleBudgeChartElement( relnew,  
 | 
                                                   TimeStringAndScenarioName := [String]year.YearNo() + "年-" + macroPlan.ScenarioName(), 
 | 
                                                   BusinessTypeOrPlaceOfProductionOfArray := businessType,  
 | 
                                                   Quantity := ifexpr( saleOrCapacity = "销售额", 
 | 
                                                                       MappingCustomerOrder::GetNewSupplyByYear( productCodeList, macroPlan, year.YearNo() ) , 
 | 
                                                                       Product_MP::GetNewSupplyByYear( productCodeList, macroPlan, year.YearNo() ) 
 | 
                                                                       ) 
 | 
                                                   );  
 | 
          }                     
 | 
        } 
 | 
      }  
 | 
      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.YearNo() + "年-" + ifexpr( halfNo = 1, "上", "下" ) + "半年-目标", 
 | 
                                                   BusinessTypeOrPlaceOfProductionOfArray := businessType,  
 | 
                                                   Quantity := ifexpr( saleOrCapacity = "销售额", 
 | 
                                                                       MappingAnnualBudget::GetSheetByHalfYear( productCodeList, mpSync, year.YearNo(), halfNo ), 
 | 
                                                                       MappingCapacityAndSaleBudge::GetSheetByHalfYear( productCodeList, mpSync, 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 = "销售额", 
 | 
                                                                         MappingCustomerOrder::GetNewSupplyByHalfYear( productCodeList, macroPlan, year.YearNo(), halfNo ) , 
 | 
                                                                         Product_MP::GetNewSupplyByHalfYear( productCodeList, macroPlan, year.YearNo(), halfNo ) 
 | 
                                                                         ) 
 | 
                                                     );  
 | 
            }                     
 | 
          } 
 | 
        } 
 | 
      } 
 | 
      if ( byBusinessTypeOrByOrgCode = "事业部" and groupBy = "季度" ) { 
 | 
        for( seasonNo := 1; seasonNo <= 4; seasonNo := seasonNo + 1 ) { 
 | 
          info( "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 = "销售额", 
 | 
                                                                       MappingAnnualBudget::GetSheetBySeason( productCodeList, mpSync, year.YearNo(), seasonNo ), 
 | 
                                                                       MappingCapacityAndSaleBudge::GetSheetBySeason( productCodeList, mpSync, 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 = "销售额", 
 | 
                                                                         MappingCustomerOrder::GetNewSupplyBySeason( productCodeList, macroPlan, year.YearNo(), seasonNo ), 
 | 
                                                                         Product_MP::GetNewSupplyBySeason( productCodeList, macroPlan, year.YearNo(), seasonNo )  
 | 
                                                                         ) 
 | 
                                                     );  
 | 
            }                     
 | 
          } 
 | 
          info( "process season end : " + [String]seasonNo ); 
 | 
        } 
 | 
      } 
 | 
      if ( byBusinessTypeOrByOrgCode = "事业部" 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( businessTypeList, Elements, businessType ) { 
 | 
            productCodeList := CapacityAndSaleBudgeChartRow::GetProductCodesByBusinessType( rows, businessType ); 
 | 
            this.CapacityAndSaleBudgeChartElement( relnew,  
 | 
                                                   TimeStringAndScenarioName := [String]year.YearNo() + "年-第" + monthNoString + "月-目标", 
 | 
                                                   BusinessTypeOrPlaceOfProductionOfArray := businessType,  
 | 
                                                   Quantity := ifexpr( saleOrCapacity = "销售额", 
 | 
                                                                       MappingCapacityAndSaleBudge::GetSheetByMonth( productCodeList, mpSync, year.YearNo(), month.MonthNo() ), 
 | 
                                                                       MappingAnnualBudget::GetSheetByMonth( productCodeList, mpSync, 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 = "销售额", 
 | 
                                                                         MappingCustomerOrder::GetNewSupplyByMonth( productCodeList, macroPlan, year.YearNo(), month.MonthNo() ) , 
 | 
                                                                         Product_MP::GetNewSupplyByMonth( productCodeList, macroPlan, year.YearNo(), month.MonthNo() ) 
 | 
                                                                         ) 
 | 
                                                     );  
 | 
            }             
 | 
          } 
 | 
          info( "process month end : " + [String]month.MonthNo() ); 
 | 
        } 
 | 
      } 
 | 
      info( "process year end : " + [String]year.YearNo() ) 
 | 
    } 
 | 
    //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( "==↑==" ); 
 | 
    //} 
 | 
  *] 
 | 
} 
 |