| | |
| | | allunit := InventorySummaryReport::GetDefaultAllUnit(); |
| | | ccunit := InventorySummaryReport::GetDefaultCCUnit(); |
| | | dlunit := InventorySummaryReport::GetDefaultDLUnit(); |
| | | //ccalineunit := FinancialProductionReport::GetDefaultCCALineUnit(); |
| | | //dlalienunit := FinancialProductionReport::GetDefaultDLALineUnit() |
| | | //ccmplineunit := FinancialProductionReport::GetDefaultCCMPLineUnit() |
| | | //dlmplineunit := FinancialProductionReport::GetDefaultDLMPLineUnit(); |
| | | |
| | | source := owner.InventorySummarySource( relnew, ID := InventorySummaryReport::GetDefaultName(), Name := InventorySummaryReport::GetDefaultName() ); |
| | | table := source.InventorySummaryReport( relnew, ID := source.Name(), Name := source.Name() ); |
| | | showtable := source.InventorySummaryReport( relnew, ID := source.Name() + 'Show', Name := source.Name(), IsShow := true ); |
| | | startofplanning := owner.StartOfPlanning(); |
| | | startofyear := startofplanning.StartOfYear() - Duration::Days( 1 ); |
| | | startofnextyear := startofplanning.StartOfNextYear() - Duration::Days( 1 ); |
| | | startofnextyear := startofplanning.StartOfNextYear(); |
| | | |
| | | search := owner.InventorySummarySearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit, Category := Translations::MP_GlobalParameters_Day(), StartDate := Date::MinDate(), EndDate := Date::MaxDate() ); |
| | | |
| | | table.GenerateColumn( owner, 'All', startofyear, startofnextyear ); |
| | | //info( '-----------------------------------', table.InventorySummaryColumn( relsize ) ); |
| | | //库存数量为Actual inventories里面的点Planned inventories字段库存量加总 |
| | | traverse( owner, StockingPoint_MP, stockingpoint ){ |
| | | //traverse( owner, StockingPoint_MP, stockingpoint, stockingpoint.ID().EndsWith( '厂内库' ) ){ |
| | | unit := stockingpoint.Unit(); |
| | | parentunits := unit.GetAllParent(); |
| | | //是否属于长春工厂 |
| | | // iscc := stockingpoint.ID().StartsWith( 'CC' ) or stockingpoint.ID() = '长春' ;//unit.ID() = ccalineunit or unit.ID() = ccmplineunit or exists( parentunits, Elements, punit, punit.ID() = ccalineunit or punit.ID() = ccmplineunit ); |
| | | iscc := exists( parentunits, Elements, punit, punit.ID().StartsWith( 'VWED CC' ) ); |
| | | //是否属于大连工厂 |
| | | // isdl := stockingpoint.ID().StartsWith( '大连' );//unit.ID() = dlalienunit or unit.ID() = dlmplineunit or exists( parentunits, Elements, punit, punit.ID() = dlalienunit or punit.ID() = dlmplineunit ); |
| | | isdl := exists( parentunits, Elements, punit, punit.ID().StartsWith( 'VWED DL' ) ); |
| | | 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(); |
| | | |
| | | pispips := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, pispip.Start() < startofnextyear |
| | | and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day(), pispip.Start() ); |
| | |
| | | quantity := ifexpr( pispip.Period_MP().IsHistorical(), [Number]pispip.ActualInventoryLevelEnd(), [Number]pispip.PlannedInventoryLevelEnd() ); |
| | | factoryrow.SetCellValue( daycolumn, quantity ); |
| | | allrow.SetCellValue( daycolumn, quantity ); |
| | | |
| | | //周,选择周时,期末库存为每一周最后一天的汇总库存信息,最小库存为这一周库存量最小的一天的数值,最大库存为这一周库存量最大的一天的数值,平均库存为该周的平均值 |
| | | 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, ifexpr( pispip.Period_MP().IsHistorical(), [Number]e.ActualInventoryLevelEnd(), [Number]e.PlannedInventoryLevelEnd() ) ); |
| | | mininventory := min( weekpispips, Elements, e, ifexpr( pispip.Period_MP().IsHistorical(), [Number]e.ActualInventoryLevelEnd(), [Number]e.PlannedInventoryLevelEnd() ) ); |
| | | aveinventory := average( weekpispips, Elements, e, ifexpr( pispip.Period_MP().IsHistorical(), [Number]e.ActualInventoryLevelEnd(), [Number]e.PlannedInventoryLevelEnd() ) ); |
| | | factoryrow.SetCellValue( weekcolumn, quantity, mininventory, maxinventory, [Number]aveinventory ); |
| | | allrow.SetCellValue( weekcolumn, quantity, 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, ifexpr( pispip.Period_MP().IsHistorical(), [Number]e.ActualInventoryLevelEnd(), [Number]e.PlannedInventoryLevelEnd() ) ); |
| | | mininventory := min( monthpispips, Elements, e, ifexpr( pispip.Period_MP().IsHistorical(), [Number]e.ActualInventoryLevelEnd(), [Number]e.PlannedInventoryLevelEnd() ) ); |
| | | aveinventory := average( monthpispips, Elements, e, ifexpr( pispip.Period_MP().IsHistorical(), [Number]e.ActualInventoryLevelEnd(), [Number]e.PlannedInventoryLevelEnd() ) ); |
| | | factoryrow.SetCellValue( monthcolumn, quantity, mininventory, maxinventory, [Number]aveinventory ); |
| | | allrow.SetCellValue( monthcolumn, quantity, mininventory, maxinventory, [Number]aveinventory ); |
| | | } |
| | | }else{ |
| | | monthpispips.Flush(); |
| | | monthpispips.Add( pispip ); |
| | | nextmonth := nextmonth.StartOfNextMonth(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //首先在Entities里识别父级Unit为长春/大连的所有库存点 |
| | | //长春库存点 |
| | | ccsps := construct( Strings ); |
| | | ccsps := construct( Strings ); |
| | | //大连库存点 |
| | | dlsps := construct( Strings ); |
| | | allsps := construct( Strings ); |
| | | dlsps := construct( Strings ); |
| | | allsps := construct( Strings ); |
| | | traverse( owner, Unit, unit, unit.ID() = ccunit or unit.ID() = dlunit ){ |
| | | if( unit.ID() = ccunit ){ |
| | | ccsps := selectuniquevalues( unit, StockingPoint_MP, sp, sp.ID() ); |
| | | ccsps := selectuniquevalues( unit, StockingPoint_MP, sp, sp.ID() ); |
| | | } |
| | | if( unit.ID() = dlunit ){ |
| | | dlsps := selectuniquevalues( unit, StockingPoint_MP, sp, sp.ID() ); |
| | | dlsps := selectuniquevalues( unit, StockingPoint_MP, sp, sp.ID() ); |
| | | } |
| | | allsps := allsps.Union( selectuniquevalues( unit, StockingPoint_MP, sp, sp.ID() ) ); |
| | | allsps := allsps.Union( selectuniquevalues( unit, StockingPoint_MP, sp, sp.ID() ) ); |
| | | } |
| | | //再在库存更新的子界面库存点选择中找到这些库存点所关联的已勾选库位 |
| | | selections := selectset( interface, InventoryPointSelection, selection, allsps.Find( selection.StockpoingPoint() ) >= 0 and selection.IsIncluded() ); |
| | | productids := selectuniquevalues( selections, Elements, selection, selection.ProductID() ); |
| | | selections := selectset( interface, InventoryPointSelection, selection, allsps.Find( selection.StockpoingPoint() ) >= 0 and selection.IsIncluded() ); |
| | | productids := selectuniquevalues( selections, Elements, selection, selection.ProductID() ); |
| | | //最后将这些库位中零件号的数量进行加总 |
| | | traverse( table, InventorySummaryColumn, column, column.Period() < startofplanning.Date() ){ |
| | | traverse( table, InventorySummaryColumn, column, column.TimeUnit() = Translations::MP_GlobalParameters_Day() and column.Period() < startofplanning.Date() ){ |
| | | traverse( productids, Elements, productid ){ |
| | | if( column.TimeUnit() = Translations::MP_GlobalParameters_Day() ){//天 |
| | | column.GenerateCell( selections, ccsps, dlsps, table, column.Period(), column.Period(), productid, allunit, ccunit, dlunit ); |
| | | }else if( column.TimeUnit() = Translations::MP_GlobalParameters_Week() ){//周 |
| | | column.GenerateCell( selections, ccsps, dlsps, table, column.Period().StartOfWeek(), column.Period(), productid, allunit, ccunit, dlunit ); |
| | | }else if( column.TimeUnit() = Translations::MP_GlobalParameters_Month() ){//月 |
| | | column.GenerateCell( selections, ccsps, dlsps, table, column.Period().StartOfMonth(), column.Period(), productid, allunit, ccunit, dlunit ); |
| | | } |
| | | column.GenerateCell( selections, ccsps, dlsps, table, column.Period(), column.Period(), productid, allunit, ccunit, dlunit ); |
| | | } |
| | | } |
| | | |
| | | |
| | | rows := selectsortedset( table, InventroySummaryRow, row, row.Name() ); |
| | | i := 0; |
| | | rows := selectsortedset( table, InventroySummaryRow, row, row.Name() ); |
| | | i := 0; |
| | | traverse( rows, Elements, e ){ |
| | | if( exists( e, InventorySummaryCell, cell, cell.AverageInventory() <> 0 or cell.EndingInventory() <> 0 or cell.MaximumInventory() <> 0 or cell.MinimumInventory() <> 0 ) ){ |
| | | e.RowNr( i ); |
| | | i := i + 1; |
| | | i := i + 1; |
| | | }else{ |
| | | e.Delete(); |
| | | } |