hongji.li
2023-11-05 2713c338a98325cad21ebec2085802a5e49a98ef
_Main/BL/Type_GlobalOTDSOP/Method_CapacityAndSaleBudgeChart.qbl
@@ -22,259 +22,5 @@
    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( "==↑==" );
    ////}
  *]
}