| | |
| | | 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) |
| | |
| | | this.CapacityAndSaleBudgeCompareItemRow( relflush ); |
| | | this.CapacityAndSaleBudgeCompareItemColumn( relflush ); |
| | | // ====汇总所有出现的产品==== |
| | | productCodeList := construct( Strings ); |
| | | historyData := selectset( mpSync, MappingCapacityAndSaleBudge, item, true ); |
| | | info( "historyData : " + [String]historyData.Size() ) |
| | | traverse( historyData, Elements, one ) { |
| | | productCodeList.Add( one.ProductCode() ); |
| | | } |
| | | traverse( macroPlans, Elements, macroPlan ) { |
| | | traverse( macroPlan, Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod, pispip ) { |
| | | productCodeList.Add( pispip.ProductInStockingPoint_MP().Product_MP().ID() ); |
| | | } |
| | | } |
| | | productCodeList := selectuniquevalues( productCodeList, Elements, item, item ); |
| | | info( "product count : " + [String]productCodeList.Size() ) |
| | | // ====根据产品查事业部和组织编码,然后按事业部和组织编码汇总==== |
| | | traverse( productCodeList, Elements, productCode ) { |
| | | bom := MappingBOM::CreateTestData( mappingParent, [String](productCode.Length() mod 3), [String](productCode.Length() mod 4) ); |
| | | // bom := select( mappingParent, MappingBOM, bom, bom.ProductCode() = productCode ); |
| | | if( not isnull( bom ) ) { |
| | | productCode := one.ProductCode(); |
| | | MappingBOM::CreateTestData( mappingParent, "事业部" + [String](productCode.Length() mod 3), [String](productCode.Length() mod 4), productCode ); |
| | | boms := selectset( mappingParent, MappingBOM, bom, bom.ProductCode() = productCode ); |
| | | if( boms.Size() > 0 ) { |
| | | bom := boms.First(); |
| | | businessType := bom.BusinessType(); |
| | | orgCode := bom.OrganCode(); |
| | | row := CapacityAndSaleBudgeCompareItemRow::CreateIfNotExist( this, businessType, orgCode ); |
| | | placeOfProductionOfArray := one.PlaceOfProductionOfArray(); |
| | | // 相同面板基地和事业部的放一行 |
| | | row := CapacityAndSaleBudgeCompareItemRow::CreateIfNotExist( this, businessType, placeOfProductionOfArray ); |
| | | // 记录每行包含哪些product |
| | | CapacityAndSaleBudgeCompareItemRowProduct::CreateIfNotExist( row, productCode ); |
| | | } else { |
| | | // info( "111111" ); |
| | | } |
| | | } |
| | | info( "CapacityAndSaleBudgeCompareItemRow : " + [String]selectset( this, CapacityAndSaleBudgeCompareItemRow, item, true ).Size() ); |
| | | // ====从左向右生成列头与内容==== |
| | | // 事业部,组织 |
| | | info( "dealing businessType and orgCode" ) |
| | | info( "dealing businessType and placeOfProductionOfArray" ) |
| | | columnBusinessType := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "事业部" ); |
| | | columnOrgCode := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "组织编码" ); |
| | | columnPlaceOfProductionOfArray := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "面板基地" ); |
| | | traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) { |
| | | cell := columnBusinessType.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := row.BusinessType() ); |
| | | cell.CapacityAndSaleBudgeCompareItemRow( relset, row ); |
| | | cell := columnOrgCode.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := row.OrgCode() ); |
| | | cell := columnPlaceOfProductionOfArray.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := row.PlaceOfProductionOfArray() ); |
| | | cell.CapacityAndSaleBudgeCompareItemRow( relset, row ); |
| | | } |
| | | // 面板分配量 - 年度预算 |
| | | // 面板分配量 - 年度预算 (sheets) |
| | | // 格式: 面板分配量 - 年 - 月(1-12 & total) - 年度预算/scenarioName |
| | | info( "dealing 面板分配量" ) |
| | | 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 := MappingCapacityAndSaleBudge::GetSheetByMonth( row.GetProductCodes(), mpSync, 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 := MappingCapacityAndSaleBudge::GetSheetByYear( row.GetProductCodes(), mpSync, DateTime::Now().Year() ); |
| | | // cellReal := Real::Random( 1.0, 999.0 ); |
| | | cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal ); |
| | | cell.CapacityAndSaleBudgeCompareItemRow( relset, row ); |
| | | } |
| | | // S&OP数据 |
| | |
| | | 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 ); |
| | | } |
| | | } |
| | |
| | | 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 := MappingCapacityAndSaleBudge::GetSaleByMonth( row.GetProductCodes(), mpSync, 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 := MappingCapacityAndSaleBudge::GetSaleByYear( row.GetProductCodes(), mpSync, 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::GetBalanceByMonth( 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::GetBalanceByYear( row.GetProductCodes(), mappingParent, year.YearNo() ); |
| | | cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal ); |
| | | cell.CapacityAndSaleBudgeCompareItemRow( relset, row ); |
| | | } |
| | | } |
| | |
| | | // 历史数据 |
| | | columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "大张盈利额-年度预算" ); |
| | | traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) { |
| | | cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) ); |
| | | // todo |
| | | 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 ); |
| | | } |
| | | } |
| | |
| | | // 历史数据 |
| | | columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "产品盈利额-年度预算" ); |
| | | traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) { |
| | | cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 100 ) ); |
| | | // todo |
| | | 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 ) ); |
| | | // todo |
| | | 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.PlaceOfProductionOfArray() + "_" + item.BusinessType() ); |
| | | traverse( rowSorted, Elements, item ) { |
| | | item.RowNo( rowNo ); |
| | | rowNo := rowNo + 1; |
| | | } |
| | | columnNo := 1; |
| | | traverse( this, CapacityAndSaleBudgeCompareItemColumn, item ) { |
| | | item.ColumnNo( columnNo ); |
| | | columnNo := columnNo + 1; |
| | | } |
| | | info( "done" ); |
| | | *] |
| | | } |