| | |
| | | products := construct( Product_MPs ); |
| | | //初始化列 |
| | | table.GenerateColumn( owner, 'All', search.StartDate(), search.EndDate() ); |
| | | endperiod := maxobject( owner, Period_MP, period, not period.IsHistorical() and period.TimeUnit() = Translations::MP_GlobalParameters_Day(), period.StartDate() ); |
| | | |
| | | //生成生产和库存数据 |
| | | traverse( owner, Product_MP.ProductInStockingPoint_MP, pisp, pisp.IsLeaf() and not pisp.IsSystem() ){ |
| | | unit := pisp.StockingPoint_MP().UnitID(); |
| | | // info( unit, pisp.ProductID() ); |
| | | //初始化行 |
| | | row := table.GetRow( pisp.ProductID() ); |
| | | traverse( owner, StockingPoint_MP, stockingpoint ){ |
| | | unit := stockingpoint.Unit(); |
| | | parentunits := unit.GetAllParent(); |
| | | //是否属于长春工厂 |
| | | iscc := unit.ID() = ccunit or exists( parentunits, Elements, punit, punit.ID() = ccunit ); |
| | | //是否属于大连工厂 |
| | | isdl := unit.ID() = dlunit or exists( parentunits, Elements, punit, punit.ID() = dlunit ); |
| | | |
| | | traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() |
| | | and ( pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day() |
| | | or pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Week() ) ){ |
| | | periodtime := pispip.Period_MP().StartDate(); |
| | | periodname := periodtime.Format( "M2/D2/Y" ); |
| | | // info( '---------------------------------', periodtime, table.Column( relsize ), pispip.Period_MP().TimeUnit() ); |
| | | column := selectobject( table, Column, column, column.Name() = periodname and column.Period() = periodtime and column.TimeUnit() = pispip.Period_MP().TimeUnit() ); |
| | | // info( '---------------------------------', isnull( column ), isnull( row ) ); |
| | | // info( '---------------------------------', column.Name(), row.Name() ); |
| | | if( unit = ccunit or unit = dlunit ){ |
| | | row.SetCellProductionValue( column, unit, pispip.NewSupplyProductionQuantity() ); |
| | | traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() and not pisp.IsSystem() ){ |
| | | weekstart := owner.StartOfPlanning().Date(); |
| | | pispips := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() |
| | | and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day(), pispip.Start() ); |
| | | row := table.GetRow( pisp.ProductID() ); |
| | | traverse( pispips, Elements, pispip ){ |
| | | //天 |
| | | daycolumn := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), pispip.Start().Date() ); |
| | | //周 |
| | | weekcolumn := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), weekstart ); |
| | | supplyquantity := [Real]ceil( pispip.NewSupplyQuantity() );//向上取整 |
| | | inventoryquantity := [Real]ceil( pispip.PlannedInventoryLevelEnd() );//向上取整 |
| | | //产量是加总 |
| | | if( iscc or isdl ){ |
| | | row.SetCellProductionValue( daycolumn, iscc, supplyquantity ); |
| | | row.SetCellProductionValue( weekcolumn, iscc, supplyquantity ); |
| | | } |
| | | //库存需要取最后一天 |
| | | row.SetCellInventoryValue( daycolumn, pispip.PlannedInventoryLevelEnd() ); |
| | | |
| | | if( pispip.Start() = weekstart + Duration::Days( 6 ) or pispip.Period_MP() = endperiod ){ |
| | | weekstart := ( weekstart + Duration::Days( 7 ) ).Date(); |
| | | |
| | | row.SetCellInventoryValue( weekcolumn, inventoryquantity ); |
| | | } |
| | | } |
| | | row.SetCellInventoryValue( column, pispip.PlannedInventoryLevelEnd() ); |
| | | } |
| | | } |
| | | |
| | | //生成需求数据 |
| | | traverse( owner, SalesDemand.astype( Forecast ), forecast, ( forecast.EndDate() - forecast.StartDate() ) < 8){ |
| | | row := table.GetRow( forecast.ProductID() ); |
| | | weekdate := ( forecast.StartDate() - Duration::Days( 7 ) ).Date(); |
| | | periodtime := forecast.StartDate(); |
| | | periodname := periodtime.Format( "M2/D2/Y" ); |
| | | |
| | | column := selectobject( table, Column, column, column.Name() = periodname and column.Period() = periodtime and column.TimeUnit() = Translations::MP_GlobalParameters_Day() ); |
| | | weekcolumn := minobject( table, Column, wcolumn, wcolumn.Period() <= weekdate and wcolumn.TimeUnit() = Translations::MP_GlobalParameters_Week(), wcolumn.Period() ); |
| | | |
| | | if( not isnull( column ) ){ |
| | | row.SetCellDemandValue( column, forecast.SalesSegmentName(), forecast.Quantity() ); |
| | | } |
| | | |
| | | if( not isnull( weekcolumn ) ){ |
| | | row.SetCellDemandValue( weekcolumn, forecast.SalesSegmentName(), forecast.Quantity() ); |
| | | traverse( owner, SalesDemand.astype( Forecast ), forecast ){ |
| | | row := table.GetRow( forecast.ProductID() ); |
| | | weekstart := owner.StartOfPlanning().Date(); |
| | | traverse( forecast, PlanningSalesDemandInPeriod, psdip ){ |
| | | //天 |
| | | daycolumn := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), psdip.StartDate() ); |
| | | //周 |
| | | weekcolumn := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), weekstart ); |
| | | |
| | | if( not isnull( daycolumn ) ){ |
| | | row.SetCellDemandValue( daycolumn, forecast.SalesSegmentName(), forecast.Quantity() ); |
| | | } |
| | | if( not isnull( weekcolumn ) ){ |
| | | row.SetCellDemandValue( weekcolumn, forecast.SalesSegmentName(), forecast.Quantity() ); |
| | | } |
| | | } |
| | | } |
| | | |
| | | rows := selectsortedset( table, Row, row, row.Name() ); |
| | | i := 0; |
| | | traverse( rows, Elements, e ){ |