From 7d76b6db9a56ab18c131f538902b96e14e516875 Mon Sep 17 00:00:00 2001 From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com> Date: 星期五, 01 十一月 2024 17:26:36 +0800 Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/VWED into dev --- _Main/BL/Type_CustomerDemandIDS/StaticMethod_GenerateData.qbl | 50 ++++++++++++++++++++++++++++++-------------------- 1 files changed, 30 insertions(+), 20 deletions(-) diff --git a/_Main/BL/Type_CustomerDemandIDS/StaticMethod_GenerateData.qbl b/_Main/BL/Type_CustomerDemandIDS/StaticMethod_GenerateData.qbl index 0cbe54d..db43831 100644 --- a/_Main/BL/Type_CustomerDemandIDS/StaticMethod_GenerateData.qbl +++ b/_Main/BL/Type_CustomerDemandIDS/StaticMethod_GenerateData.qbl @@ -2,6 +2,7 @@ #parent: #root StaticMethod GenerateData ( InterfaceDataset interface, + const MacroPlan macroplan, RecycleBin recycle, const Archive archive ) @@ -11,10 +12,16 @@ [* // 鐢勫叞楦� Aug-20-2024 (created) interface.CustomerDemandIDS( relflush ); - interface.CustomerDemandIDSSearch( relflush ); + //interface.CustomerDemandIDSSearch( relflush ); + info( '-------------------------Start---------------------'); allunit := CustomerDemandIDS::GetDefaultAllUnit(); - interface.CustomerDemandIDSSearch( relnew, Generation := allunit, MqbMlb := allunit, Power := allunit, TimeUnit := Translations::MP_GlobalParameters_Day(), Unit := allunit ); - idstable := interface.CustomerDemandIDS( relnew, ID := '瀹㈡埛闇�姹�', Name := '瀹㈡埛闇�姹�' ); + if( isnull( interface.CustomerDemandIDSSearch() ) ){ + interface.CustomerDemandIDSSearch( relnew, Generation := allunit, MqbMlb := allunit, Power := allunit, TimeUnit := Translations::MP_GlobalParameters_Day(), Unit := allunit ); + } + idstable := selectobject( interface, CustomerDemandIDS, idstable, idstable.ID() = '瀹㈡埛闇�姹�' ); + if( isnull( idstable ) ){ + idstable := interface.CustomerDemandIDS( relnew, ID := '瀹㈡埛闇�姹�', Name := '瀹㈡埛闇�姹�' ); + } binaryValue := TemplateManager::GetIDSFullTable( archive, Date::ActualDate().Year() ); source := GeneralExcelImportAndExportDataSource::Upload( recycle, binaryValue, OS::TempPath() + "template.xlsx" ); source.ReadStructure(); @@ -23,14 +30,12 @@ cnv2.SetCustomConversion(); cnv2.CustomFormatString( "yyyy/MM/dd" ); idsdates := selectuniquevalues( source, GeneralExcelImportAndExportDataTable.GeneralExcelImportAndExportDataColumn, column, column.ColumnIndex() > 2, cnv2.Convert( column.Name() ) ); - ppadates := selectuniquevalues( interface, InterfaceForecast, forecast, forecast.Origin() = 'PPA', forecast.Date() ); - //ppadates := construct( Dates ); - //traverse( macroplan, SalesDemand.astype( Forecast ), forecast, forecast.Origin() = 'PPA' ){ - // ppadates := ppadates.Union( selectuniquevalues( forecast, PlanningSalesDemandInPeriod, salesdemand, salesdemand.StartDate() ) ); - //} + ppadates := selectuniquevalues( macroplan, SalesDemand.astype( Forecast ), forecast, forecast.Origin() = 'PPA', forecast.StartDate() ); periods := idsdates.Union( ppadates ); - periods := selectuniquevalues( periods, Elements, e, e ); - idstable.GenerateColumn( periods.Sort() ); + periods := selectuniquevalues( periods, Elements, e, not exists( idstable, Column, column, column.StartDate() = e ), e ); + if( periods.Size() > 0 ){ + idstable.GenerateColumn( periods.Sort() ); + } traverse( recycle, GeneralExcelImportAndExportDataSource.GeneralExcelImportAndExportDataTable, table ){ traverse( table, GeneralExcelImportAndExportDataRow, row ){ productcell := selectobject( row, GeneralExcelImportAndExportDataCell, cell, cell.GeneralExcelImportAndExportDataColumn().ColumnIndex() = 2 ); @@ -41,22 +46,27 @@ daycolumn := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Day(), period ); weekcolumn := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Week(), period ); monthcolumn := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Month(), period ); + idsrow.SetCellValue( daycolumn, [Number]cell.Value() ); - idsrow.SetCellValue( weekcolumn, [Number]cell.Value() ); - idsrow.SetCellValue( monthcolumn, [Number]cell.Value() ); + idsrow.SetCellValue( weekcolumn, [Number]cell.Value() ); + idsrow.SetCellValue( monthcolumn, [Number]cell.Value() ); } } } - traverse( interface, InterfaceForecast, forecast, forecast.Origin() = 'PPA' ){ - idsrow := idstable.GetRowByUnit( forecast.PartNumber(), forecast.Factory() ); - daycolumn := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Day(), forecast.Date() ); - weekcolumn := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Week(), forecast.Date() ); - monthcolumn := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Month(), forecast.Date() ); - idsrow.SetCellValue( daycolumn, [Number]forecast.Quantity() ); - idsrow.SetCellValue( weekcolumn, [Number]forecast.Quantity() ); - idsrow.SetCellValue( monthcolumn, [Number]forecast.Quantity() ); + traverse ( macroplan, SalesDemand.astype( Forecast ), forecast, not isnull( forecast.Product_MP() ) and forecast.Origin() = 'PPA' ){ + traverse( forecast, PlanningSalesDemandInPeriod, sdip ){ + idsrow := idstable.GetRowByUnit( forecast.ProductID(), forecast.SalesSegmentName() ); + daycolumn := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Day(), sdip.StartDate() ); + weekcolumn := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Week(), sdip.StartDate() ); + monthcolumn := idstable.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Month(), sdip.StartDate() ); + info( '-----------------', isnull( idsrow ), isnull( daycolumn ), isnull( weekcolumn ), isnull( monthcolumn ), sdip.StartDate() ); + idsrow.SetCellValue( daycolumn, [Number]sdip.Quantity() ); + idsrow.SetCellValue( weekcolumn, [Number]sdip.Quantity() ); + idsrow.SetCellValue( monthcolumn, [Number]sdip.Quantity() ); + } } source.Delete(); + info( '-------------------------End---------------------'); *] } -- Gitblit v1.9.3