Jump to content

Create and add in "BatchID" with specific format as property inside each batch


Recommended Posts

  • Seeq Team

Interesting question from a Seeqer who would like to create a BatchID for each batch with the format YYYYMMDDS# where YYYY is the year, MM is month, DD is day, S is the shift and # is the order of the batch in that shift. 
 

This is one of the possible method.

STEP 1: Create the signal for YYYYMMDD

//STEP1: Trend the "Start" date of each capsule

$StartDate =  $batch
              .move(7h) //based on time zone use in workbench.
              .toSignal('Start')
              .toString()
              .move(-7h) //move back the signal to the original position
              
//STEP2: Replace the format to YYYYMMDD

$YYYYMMDD = $StartDate
             .replace('/^(..........).*/' , '$1') //example of the output is 2022-09-02
             .replace('-','') //20220902
             .validValues()
             .toStep(1d)
$YYYYMMDD

STEP 2: Create the signal for S which represent the shift number

combinewith(
shifts (6, 12, "Asia/Kuala_Lumpur").setProperty('Shift','1'),
shifts(18, 12, "Asia/Kuala_Lumpur").setProperty('Shift','2'))

Followed by another formula,

$s.toSignal('Shift')

STEP 3 : Create the # which represent batch sequence in the respective shift
 

$count = $batch.aggregate(count(),$batch, startkey(),0s)

$count
.runningCount($shift)
.toStep(1d)
.toString()

STEP 4 : Create the BatchID and set as property
 

$BatchID = $YYYYMMDD + $S + $x

$batch.setProperty('BatchID', $BatchID, StartValue())

image.png

Edited by Sharlinda Salim
  • Like 1
Link to comment
Share on other sites

  • Sharlinda Salim changed the title to Create and add in "BatchID" with specific format as property inside each batch

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...