Skip to main content

system.mes.oee.pruneOeeRecords

Description

Prunes OEE records from the database that are older than a specified date. This is a destructive operation and cannot be undone.

Permissions

This method requires the OEE.WRITE.DELETE permission.

Syntax

# Run method with prune date as Date object
system.mes.oee.pruneOeeRecords(locationIdsOrPaths, pruneBeforeDate)

# Run method with prune date in milliseconds as Long object
system.mes.oee.pruneOeeRecords(locationIdsOrPaths, pruneBeforeDateMillis)

Parameters

ParameterTypeNullableDescription
locationIdsOrPathsSet<String>TrueA set of location IDs or paths to prune. If empty, all locations are considered.
pruneBeforeDateDateFalseAll records created before this date will be deleted.
pruneBeforeDateMillisLongFalseAll records created before the date defined by Instant.ofEpochMilli will be deleted.

Returns

This method does not return a value.

Code Examples

from java.util import Date
from java.util.concurrent import TimeUnit

# Define the cutoff date for pruning (e.g., 90 days ago)
cutoffMillis = Date().getTime() - TimeUnit.DAYS.toMillis(90)
cutoffDate = Date(cutoffMillis)

# Specify a set of locations to prune
locationsToPrune = {"Enterprise/Site/Area/Line1", "Enterprise/Site/Area/Line2"}

# Prune the records
try:
system.mes.oee.pruneOeeRecords(locationsToPrune, cutoffDate)
print "Successfully pruned records older than", cutoffDate
except Exception as e:
print "Error during pruning:", str(e)

# Prune records for all locations
# system.mes.oee.pruneOeeRecords(set(), cutoffDate)