| | |
| | | table.GenerateColumn( owner, 'All', startofyear, startofnextyear ); |
| | | //info( '-----------------------------------', table.InventorySummaryColumn( relsize ) ); |
| | | //库存数量为Actual inventories里面的点Planned inventories字段库存量加总 |
| | | traverse( owner, Product_MP.ProductInStockingPoint_MP, pisp, pisp.IsLeaf() and not pisp.IsSystem() and not isnull( pisp.StockingPoint_MP() ) and ( pisp.StockingPoint_MP().UnitID() = ccunit or pisp.StockingPoint_MP().UnitID() = dlunit ) ){ |
| | | unit := pisp.StockingPoint_MP().UnitID(); |
| | | product := pisp.Product_MP(); |
| | | // info( '-----------------------------------', unit, product.ID() ); |
| | | weekpispips := construct( ProductInStockingPointInPeriods ); |
| | | monthpispips := construct( ProductInStockingPointInPeriods ); |
| | | nextweek := startofplanning.StartOfNextWeek(); |
| | | nextmonth := startofplanning.StartOfNextMonth(); |
| | | |
| | | unitrow := table.GetRow( unit, product.ID() ); |
| | | allrow := table.GetRow( allunit, product.ID() ); |
| | | pispips := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, pispip.Start() >= startofplanning and pispip.Start() < startofnextyear and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day(), pispip.Start() ); |
| | | // info( '-----------------------------------', isnull( allrow ), pispips.Size() ); |
| | | traverse( pispips, Elements, pispip, pispip.Start() = startofplanning ){ |
| | | // info( '-----------------------------------', pispip.Start() ); |
| | | period := pispip.Period_MP(); |
| | | periodtime := period.Start().Date(); |
| | | periodname := periodtime.Format( "M2/D2/Y" ); |
| | | //天,选择日颗粒度时,期末库存,最小库存,最大库存和平均库存的数值保持一致 |
| | | daycolumn := selectobject( table, InventorySummaryColumn, column, column.Name() = periodname, column.Period() = periodtime, column.TimeUnit() = Translations::MP_GlobalParameters_Day() ); |
| | | info( daycolumn.Name(), daycolumn.Period(), daycolumn.TimeUnit() ); |
| | | unitrow.SetCellValue( daycolumn, pispip.PlannedInventoryLevelEnd() ); |
| | | allrow.SetCellValue( daycolumn, pispip.PlannedInventoryLevelEnd() ); |
| | | |
| | | //周,选择周时,期末库存为每一周最后一天的汇总库存信息,最小库存为这一周库存量最小的一天的数值,最大库存为这一周库存量最大的一天的数值,平均库存为该周的平均值 |
| | | if( period.Start() < nextweek ){ |
| | | weekpispips.Add( pispip ); |
| | | 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 ); |
| | | if( iscc or isdl ){ |
| | | traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() ){ |
| | | //获取工厂行 |
| | | factoryrow := table.GetRow( ifexpr( iscc, ccunit, dlunit ), pisp.ProductID() ); |
| | | //获取合计行 |
| | | allrow := table.GetRow( allunit, pisp.ProductID() ); |
| | | //周度的数据 |
| | | weekpispips := construct( ProductInStockingPointInPeriods ); |
| | | //月度的数据 |
| | | monthpispips := construct( ProductInStockingPointInPeriods ); |
| | | nextweek := startofplanning.StartOfNextWeek(); |
| | | nextmonth := startofplanning.StartOfNextMonth(); |
| | | |
| | | weekend := nextweek - Duration::Days( 1 ); |
| | | if( period.Start() = weekend ){ |
| | | weekcolumn := selectobject( table, InventorySummaryColumn, column, column.Name() = periodname, column.Period() = periodtime, column.TimeUnit() = Translations::MP_GlobalParameters_Week() ); |
| | | pispips := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() |
| | | and pispip.Start() < startofnextyear |
| | | and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day(), pispip.Start() ); |
| | | |
| | | traverse( pispips, Elements, pispip ){ |
| | | period := pispip.Period_MP(); |
| | | periodtime := period.Start().Date(); |
| | | periodname := periodtime.Format( "M2/D2/Y" ); |
| | | |
| | | maxinventory := max( weekpispips, Elements, e, e.PlannedInventoryLevelEnd() ); |
| | | mininventory := min( weekpispips, Elements, e, e.PlannedInventoryLevelEnd() ); |
| | | aveinventory := average( weekpispips, Elements, e, e.PlannedInventoryLevelEnd() ); |
| | | unitrow.SetCellValue( weekcolumn, pispip.PlannedInventoryLevelEnd(), mininventory, maxinventory, aveinventory ); |
| | | allrow.SetCellValue( weekcolumn, pispip.PlannedInventoryLevelEnd(), mininventory, maxinventory, aveinventory ); |
| | | } |
| | | }else{ |
| | | weekpispips.Flush(); |
| | | weekpispips.Add( pispip ); |
| | | nextweek := nextweek.StartOfNextWeek(); |
| | | } |
| | | |
| | | //月,选择月时,期末库存为每一月最后一天的汇总库存信息,最小库存为这一个月库存量最小的一天的数值,最大库存为这一个月库存量最大的一天的数值,平均库存为该月的平均值 |
| | | if( period.Start() < nextmonth ){ |
| | | monthpispips.Add( pispip ); |
| | | |
| | | monthend := nextmonth - Duration::Days( 1 ); |
| | | if( period.Start() = monthend ){ |
| | | monthcolumn := selectobject( table, InventorySummaryColumn, column, column.Name() = periodname, column.Period() = periodtime, column.TimeUnit() = Translations::MP_GlobalParameters_Month() ); |
| | | //天,选择日颗粒度时,期末库存,最小库存,最大库存和平均库存的数值保持一致 |
| | | daycolumn := selectobject( table, InventorySummaryColumn, column, column.Name() = periodname, column.Period() = periodtime, column.TimeUnit() = Translations::MP_GlobalParameters_Day() ); |
| | | info( daycolumn.Name(), daycolumn.Period(), daycolumn.TimeUnit() ); |
| | | factoryrow.SetCellValue( daycolumn, [Number]pispip.PlannedInventoryLevelEnd() ); |
| | | allrow.SetCellValue( daycolumn, [Number]pispip.PlannedInventoryLevelEnd() ); |
| | | |
| | | maxinventory := max( monthpispips, Elements, e, e.PlannedInventoryLevelEnd() ); |
| | | mininventory := min( monthpispips, Elements, e, e.PlannedInventoryLevelEnd() ); |
| | | aveinventory := average( monthpispips, Elements, e, e.PlannedInventoryLevelEnd() ); |
| | | unitrow.SetCellValue( monthcolumn, pispip.PlannedInventoryLevelEnd(), mininventory, maxinventory, aveinventory ); |
| | | allrow.SetCellValue( monthcolumn, pispip.PlannedInventoryLevelEnd(), mininventory, maxinventory, aveinventory ); |
| | | //周,选择周时,期末库存为每一周最后一天的汇总库存信息,最小库存为这一周库存量最小的一天的数值,最大库存为这一周库存量最大的一天的数值,平均库存为该周的平均值 |
| | | if( period.Start() < nextweek ){ |
| | | weekpispips.Add( pispip ); |
| | | |
| | | weekend := nextweek - Duration::Days( 1 ); |
| | | if( period.Start() = weekend ){ |
| | | weekcolumn := selectobject( table, InventorySummaryColumn, column, column.Name() = periodname, column.Period() = periodtime, column.TimeUnit() = Translations::MP_GlobalParameters_Week() ); |
| | | |
| | | maxinventory := max( weekpispips, Elements, e, [Number]e.PlannedInventoryLevelEnd() ); |
| | | mininventory := min( weekpispips, Elements, e, [Number]e.PlannedInventoryLevelEnd() ); |
| | | aveinventory := average( weekpispips, Elements, e, [Number]e.PlannedInventoryLevelEnd() ); |
| | | factoryrow.SetCellValue( weekcolumn, [Number]pispip.PlannedInventoryLevelEnd(), mininventory, maxinventory, [Number]aveinventory ); |
| | | allrow.SetCellValue( weekcolumn, [Number]pispip.PlannedInventoryLevelEnd(), mininventory, maxinventory, [Number]aveinventory ); |
| | | } |
| | | }else{ |
| | | weekpispips.Flush(); |
| | | weekpispips.Add( pispip ); |
| | | nextweek := nextweek.StartOfNextWeek(); |
| | | } |
| | | |
| | | //月,选择月时,期末库存为每一月最后一天的汇总库存信息,最小库存为这一个月库存量最小的一天的数值,最大库存为这一个月库存量最大的一天的数值,平均库存为该月的平均值 |
| | | if( period.Start() < nextmonth ){ |
| | | monthpispips.Add( pispip ); |
| | | |
| | | monthend := nextmonth - Duration::Days( 1 ); |
| | | if( period.Start() = monthend ){ |
| | | monthcolumn := selectobject( table, InventorySummaryColumn, column, column.Name() = periodname, column.Period() = periodtime, column.TimeUnit() = Translations::MP_GlobalParameters_Month() ); |
| | | |
| | | maxinventory := max( monthpispips, Elements, e, [Number]e.PlannedInventoryLevelEnd() ); |
| | | mininventory := min( monthpispips, Elements, e, [Number]e.PlannedInventoryLevelEnd() ); |
| | | aveinventory := average( monthpispips, Elements, e, [Number]e.PlannedInventoryLevelEnd() ); |
| | | factoryrow.SetCellValue( monthcolumn, [Number]pispip.PlannedInventoryLevelEnd(), mininventory, maxinventory, [Number]aveinventory ); |
| | | allrow.SetCellValue( monthcolumn, [Number]pispip.PlannedInventoryLevelEnd(), mininventory, maxinventory, [Number]aveinventory ); |
| | | } |
| | | }else{ |
| | | monthpispips.Flush(); |
| | | monthpispips.Add( pispip ); |
| | | nextmonth := nextmonth.StartOfNextMonth(); |
| | | } |
| | | } |
| | | }else{ |
| | | monthpispips.Flush(); |
| | | monthpispips.Add( pispip ); |
| | | nextmonth := nextmonth.StartOfNextMonth(); |
| | | } |
| | | } |
| | | } |