Net Production

Net production is based on the Production tab configuration in the Unit Properties – Production Metrics.



If ‘Production is Accumulated From Event Dimensions’ is selected then ‘Net Production’ is the summary of the production events’ ‘Initial Dimension X’ field (for example, Event_Details.Initial_Dimension_X) where the production event time stamp (for example, Event.TimeStamp) falls within the report range and the status of the production status is defined as ‘Count for Production’.

The production quantity is pro-rated over the report time frame. The quantity of any event that crosses the report start and/or end time will be multiplied by the ratio of the event duration and the portion of the event that is within the report period. It is assumed that the rate at which material was added to the production event was constant over the duration of the event.



The following is an example of a query that is used to calculate ‘Net Production’. The query uses a standard View of the Events table available in 4.3+.


SELECT Net_Production =
       SUM(	ed.Initial_Dimension_X
                * datediff(s,CASE WHEN e.Actual_Start_Time < @ReportStartTime THEN @ReportStartTime 
                                  ELSE e.Actual_Start_Time
                                  END,
                            CASE  WHEN e.TimeStamp > @ReportEndTime THEN @ReportEndTime 
                                  ELSE e.TimeStamp
                                  END)
              / datediff(s, e.Actual_Start_Time, e.TimeStamp)) 
FROM dbo.Events_With_StartTime e
       JOIN dbo.Event_Details ed ON ed.Event_Id = e.Event_Id
       JOIN dbo.Production_Status ps ON e.Event_Status = ps.ProdStatus_Id 
WHERE	        e.PU_Id = @ReportUnit
                AND	e.TimeStamp > @ReportStartTime 
                AND e.Actual_Start_Time < @ReportEndTime 
                AND ps.Count_For_Production = 1

If ‘Production is Accumulated From a Variable’ is selected then ‘Net Production’ is the summary of the variable value where the variable time stamp (for example, Tests.Result_On) falls within the report range.



SELECT Net_Production = SUM(convert(real, t.Result_On)) 
FROM dbo.Tests t
WHERE	t.Var_Id = @ProductionVariableId
        AND t.Result_On > @ReportStartTime 
        AND t.Result_On <= @ReportEndTime