%dw 2.0
output application/json
---
{
data: payload groupBy $.EMP_ID pluck ((value, key) -> {
empID: value[0].EMP_ID,
jobData: value groupBy ($.EMP_ID ++ '|' ++ $.DEPT_ID ++ '|' ++ $.OPRT_UNIT_CODE ++ '|' ++ $.PROD_CODE) pluck ((subValue, subKey) -> {
DEPT_ID: subValue[0].DEPT_ID,
OPRT_UNIT_CODE: subValue[0].OPRT_UNIT_CODE,
PROD_CODE: subValue[0].PROD_CODE,
orgData: subValue map ((item, index) -> {
OrgCode: item.NODE_CODE,
AllocPct: item.ALLOC_PCT
})
})
})
}