system.mes.oee.calculateOeeByShift
Description
Returns one OeeShiftResultsDTO per shift instance in the date range for the given location. Each
result pairs a ShiftRecordDTO (shift metadata and timing) with an OeeResultsDTO (all OEE
metrics for that shift window). Results are sorted by shift start date ascending.
Uses the SHIFT pre-computed record cache where available. On a cache miss, falls back to the hierarchical record cache (MONTH → WEEK → DAY → HOUR records), then to raw calculation.
Permissions
This method requires the OEE.READ.GET permission.
Syntax
system.mes.oee.calculateOeeByShift(locationIdOrPath, startDate, endDate=None, shiftNameOrId=None, unitOfMeasureName=None)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
locationIdOrPath | String | False | Location ID (ULID) or path. |
startDate | Date | False | Start of the query range (inclusive). |
endDate | Date | True | End of the query range (inclusive). Defaults to now if None. |
shiftNameOrId | String | True | Shift name or ID (ULID). When provided, only instances of this shift are returned. Omit for all shifts. |
unitOfMeasureName | String | True | Unit of measure name for production counts. Uses the location OEE configuration default if None. |
Returns
A JSON list of OeeShiftResultsDTO objects sorted by shift start date ascending. Each entry
contains the following top-level fields:
| Name | Type | Description |
|---|---|---|
shiftRecord | Object | Shift instance metadata (ShiftRecordDTO). |
oeeResults | Object | OEE metrics for the shift window (OeeResultsDTO). |
shiftRecord fields (ShiftRecordDTO)
| Name | Type | Nullable | Description |
|---|---|---|---|
id | String | True | The ID of the shift record (ULID). |
shiftId | String | False | ID of the shift definition that generated this record. |
shiftName | String | True | Name of the shift (display only). |
startDate | Instant | True | Start of the shift instance. |
endDate | Instant | True | End of the shift instance. |
status | String | False | Shift status: "IDLE", "ACTIVE", "CLOSED", or "VERIFIED". |
locationId | String | False | ID of the location where the shift ran. |
locationPath | String | True | Path of the location (display only). |
duration | Double | False | Duration of the shift instance in seconds. |
oeeResults fields (OeeResultsDTO)
| Name | Type | Nullable | Description | Default Value |
|---|---|---|---|---|
locationId | String | False | Identifier of the associated location. | null |
locationPath | String | True | Path of the associated location. | null |
startDate | Instant | False | Start of the shift window. | Instant.now() |
endDate | Instant | True | End of the shift window. | null |
totalDurationSec | Double | False | Total duration of the shift window in seconds. | 0.0 |
scheduledDurationSec | Double | False | Duration scheduled for production in seconds. | 0.0 |
scheduledProductionModeEventCount | Integer | False | Total number of scheduled production mode events. | 0 |
scheduledDowntimeDurationSec | Double | False | Duration in scheduled downtime mode in seconds. | 0.0 |
scheduledDowntimeModeEventCount | Integer | False | Total number of scheduled downtime mode events. | 0 |
unscheduledDowntimeDurationSec | Double | False | Duration in unscheduled downtime mode in seconds. | 0.0 |
unscheduledDowntimeEventCount | Integer | False | Total number of unscheduled downtime mode events. | 0 |
runningDurationSec | Double | False | Duration the machine was actively running in seconds. | 0.0 |
runningStateEventCount | Integer | False | Total number of running state events. | 0 |
blockedDurationSec | Double | False | Duration in BLOCKED state in seconds. | 0.0 |
blockedStateEventCount | Integer | False | Total number of blocked state events. | 0 |
starvedDurationSec | Double | False | Duration in STARVED state in seconds. | 0.0 |
starvedStateEventCount | Integer | False | Total number of starved state events. | 0 |
idleDurationSec | Double | False | Duration in IDLE state in seconds. | 0.0 |
idleStateEventCount | Integer | False | Total number of idle state events. | 0 |
downtimeDurationSec | Double | False | Duration in DOWNTIME state in seconds. | 0.0 |
downtimeStateEventCount | Integer | False | Total number of downtime state events. | 0 |
productionCount | Double | False | Total units produced during the shift. | 0.0 |
expectedProductionCount | Double | False | Expected units to be produced during the shift. | 0.0 |
averageStandardRate | Double | False | Average standard rate for the shift (units per minute). | 0.0 |
maximumStandardRate | Double | False | Maximum standard rate for the shift (units per minute). | 0.0 |
wasteCount | Double | False | Total waste units recorded during the shift. | 0.0 |
goodCount | Double | False | Total good units recorded during the shift. | 0.0 |
productionCountUnitOfMeasureId | String | True | Identifier of the unit of measure for production count. | null |
productionCountUnitOfMeasureName | String | True | Name of the unit of measure for production count. | null |
productionCountUnitOfMeasureSymbol | String | True | Symbol of the unit of measure for production count. | null |
availability | Double | True | Availability metric (0.0 to 1.0). | 1.0 |
performance | Double | True | Performance metric (0.0 to 1.0). | 1.0 |
quality | Double | True | Quality metric (0.0 to 1.0). | 1.0 |
oee | Double | True | Overall Equipment Effectiveness (OEE) metric (0.0 to 1.0). | 1.0 |
teep | Double | True | Total Effective Equipment Performance (TEEP) metric (0.0 to 1.0). | 1.0 |
Code Examples
from java.util import Date
import system.date
# Get OEE for all shifts over the past 7 days
location = "Enterprise/Site/Line1"
endDate = Date()
startDate = system.date.addDays(endDate, -7)
shiftResults = system.mes.oee.calculateOeeByShift(location, startDate, endDate)
for result in shiftResults:
shift = result['shiftRecord']
oee = result['oeeResults']
print shift['shiftName'], shift['startDate'], "OEE:", oee['oee']
# Get OEE for a specific shift only
dayShiftResults = system.mes.oee.calculateOeeByShift(
location,
startDate,
endDate,
shiftNameOrId="Day Shift"
)
for result in dayShiftResults:
print result['shiftRecord']['startDate'], "->", result['oeeResults']['oee']