yypsybs
2023-09-19 bc27afe76dc7bfbb63c8d078d546b97746ebddde
_Main/BL/Type_ScenarioManager/Method_CapacityAndSaleBudgeCompare.qbl
@@ -6,10 +6,11 @@
  CapacityAndSaleBudgeFilterYears years,
  CapacityAndSaleBudgeFilterMonths months,
  MPSync mpSync,
  GlobalOTDTable otdTable,
  MacroPlan mappingParent
)
{
  Description: 'todo : mappingParent改为mpSync'
  Description: 'todo : mappingParent改为mpSync, random删了'
  TextBody:
  [*
    // yypsybs Sep-18-2023 (created)
@@ -77,15 +78,19 @@
    if( CapacityAndSaleBudgeFilterItem::Contains( items, "面板分配量" ) ) {
      // 历史数据
      traverse( months, Elements, month ) {
        columnMonth := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "面板分配量-" + "-" + [String]month.MonthNo() + "-年度预算" );
        columnMonth := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "面板分配量-" + "-" + [String]month.MonthNo() + "月-年度预算" );
        traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
          cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) );
          cellReal := CapacityAndSaleBudge::GetSheetByMonth( row.GetProductCodes(), otdTable, DateTime::Now().Year(), month.MonthNo() );
          cellReal := Real::Random( 1.0, 999.0 );
          cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
          cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
        }
      }
      columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "面板分配量-" + "-total-年度预算" );
      columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "面板分配量-total-年度预算" );
      traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
        cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) );
        cellReal := CapacityAndSaleBudge::GetSheetByYear( row.GetProductCodes(), otdTable, DateTime::Now().Year() );
        cellReal := Real::Random( 1.0, 999.0 );
        cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
        cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
      }
      // S&OP数据
@@ -93,16 +98,20 @@
        traverse( macroPlans, Elements, macroPlan ) {
          traverse( months, Elements, month ) {
            columnMonth := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, 
                                                                                    "面板分配量-" + [String]year.YearNo() + "-" + [String]month.MonthNo() + "-" + macroPlan.ScenarioName() );
                                                                                    "面板分配量-" + [String]year.YearNo() + "年-" + [String]month.MonthNo() + "月-" + macroPlan.ScenarioName() );
            traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
              cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) );
              cellReal := Product_MP::GetNewSupplyByMonth( row.GetProductCodes(), macroPlan, year.YearNo(), month.MonthNo() );
              cellReal := Real::Random( 1.0, 999.0 );
              cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
              cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
            }
          }
          columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, 
                                                                                 "面板分配量-" + [String]year.YearNo() + "-total-" + macroPlan.ScenarioName() );
                                                                                 "面板分配量-" + [String]year.YearNo() + "年-total-" + macroPlan.ScenarioName() );
          traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
            cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) );
            cellReal := Product_MP::GetNewSupplyByYear( row.GetProductCodes(), macroPlan, year.YearNo() );
            cellReal := Real::Random( 1.0, 999.0 );
            cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
            cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
          }
        }
@@ -113,30 +122,36 @@
    if( CapacityAndSaleBudgeFilterItem::Contains( items, "销售额" ) ) {
      // 历史数据
      traverse( months, Elements, month ) {
        columnMonth := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "对外销售额-" + "-" + [String]month.MonthNo() + "-年度预算" );
        columnMonth := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "对外销售额-" + "-" + [String]month.MonthNo() + "月-年度预算" );
        traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
          cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) );
          cellReal := CapacityAndSaleBudge::GetSaleByMonth( row.GetProductCodes(), otdTable, DateTime::Now().Year(), month.MonthNo() );
          cellReal := Real::Random( 1.0, 999.0 );
          cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
          cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
        }
      }
      columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "对外销售额-" + "-total-年度预算" );
      columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "对外销售额-total-年度预算" );
      traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
        cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) );
        cellReal := CapacityAndSaleBudge::GetSaleByYear( row.GetProductCodes(), otdTable, DateTime::Now().Year() );
        cellReal := Real::Random( 1.0, 999.0 );
        cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
        cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
      }
      // S&OP数据
      traverse( years, Elements, year ) {
        traverse( macroPlans, Elements, macroPlan ) {
          traverse( months, Elements, month ) {
            columnMonth := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "对外销售额-" + [String]year.YearNo() + "-" + [String]month.MonthNo() + "-" + macroPlan.ScenarioName() );
            columnMonth := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "对外销售额-" + [String]year.YearNo() + "年-" + [String]month.MonthNo() + "月-" + macroPlan.ScenarioName() );
            traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
              cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) );
              cellReal := MappingForecast::GetByMonth( row.GetProductCodes(), mappingParent, year.YearNo(), month.MonthNo() );
              cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
              cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
            }
          }
          columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "对外销售额-" + [String]year.YearNo() + "-total-" + macroPlan.ScenarioName() );
          columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "对外销售额-" + [String]year.YearNo() + "年-total-" + macroPlan.ScenarioName() );
          traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
            cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) );
            cellReal := MappingForecast::GetByYear( row.GetProductCodes(), mappingParent, year.YearNo() );
            cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
            cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
          }
        }
@@ -148,14 +163,14 @@
      // 历史数据
      columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "大张盈利额-年度预算" );
      traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
        cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) );
        cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 0 ) );
        cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
      }
      // S&OP数据
      traverse( macroPlans, Elements, macroPlan ) {
        columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "大张盈利额-" + [String]year.YearNo() );
        columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "大张盈利额-" + [String]year.YearNo() + "年" );
        traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
          cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) );
          cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 0 ) );
          cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
        }
      }
@@ -166,20 +181,32 @@
      // 历史数据
      columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "产品盈利额-年度预算" );
      traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
        cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) );
        cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 0 ) );
        cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
      }
      // S&OP数据
      traverse( macroPlans, Elements, macroPlan ) {
        columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "产品盈利额-" + [String]year.YearNo() );
        columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "产品盈利额-" + [String]year.YearNo() + "年" );
        traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
          cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) );
          cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 0 ) );
          cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
        }
      }
    }
    
    // 设置rowNo和columnNo
    info( "set rowNo and columnNo" );
    rowNo := 1;
    rowSorted := selectsortedset( this, CapacityAndSaleBudgeCompareItemRow, item, item.BusinessType() + "_" + item.OrgCode() );
    traverse( rowSorted, Elements, item ) {
      item.RowNo( rowNo );
      rowNo := rowNo + 1;
    }
    columnNo := 1;
    traverse( this, CapacityAndSaleBudgeCompareItemColumn, item ) {
      item.ColumnNo( columnNo );
      columnNo := columnNo + 1;
    }
    info( "done" );
  *]
}