QMS AP Workflow

id: QMS_AP_REQUEST
name: QMS_AP_REQUEST Workflow
version: '1.0'
dataInputSchema:
  schema: >-
    {"$schema":"http://json-schema.org/draft-04/schema#","type":"object","properties":{"customer":{"type":"object","properties":{"name":{"type":"string"},"age":{"type":"integer"}},"required":["name","age"]},"results":{"type":"array","items":{}}},"required":["customer","results"]}
  failOnValidationErrors: true
metadata:
  startFormKey: 'LCD#65d6aad45a18672fd954d93d'
timeouts:
  workflowExecTimeout:
    duration: P1D
  actionExecTimeout: PT1M
retries:
  - name: WorkflowRetries
    delay: PT3S
    maxAttempts: 10
start:
  stateName: New
states:
  - name: New
    type: operation
    actions:
      - name: Create QmsAPRequest
        functionRef:
          refName: CreateQmsAPRequest
          arguments:
            code: '${ .customer.phone }'
            aggId: '${ uuid4 }'
            workflowId: '${ $procInst.workflowId }'
      - name: Test JS Code
        functionRef:
          refName: TestJsCode
          arguments:
            custName: '${ .customer.name }'
        actionDataFilter:
          useResults: false
    transition: 1. Tiếp nhận hồ sơ
  - name: Kê khai hồ sơ
    taskKey: taskRework
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: '${ $procInst.startUserId }'
    taskOutcomes:
      - code: Complete
        name: Gửi lại
        outcomeDecision: COMPLETED
        transition: 1. Tiếp nhận hồ sơ
      - code: Cancel
        name: Hủy hồ sơ
        outcomeDecision: CANCEL
        transition:
          end: true
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: 1. Tiếp nhận hồ sơ
  - name: 1. Tiếp nhận hồ sơ
    taskKey: taskBPMCApprove
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    candidateUsers: [email protected]
    taskOutcomes:
      - code: Approve
        name: Đồng ý
        outcomeDecision: APPROVED
        transition: 2.1 Phân công xử lý
      - code: Reject
        name: Từ chối
        outcomeDecision: REJECTED
        transition: Kê khai hồ sơ
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: 2.1 Phân công xử lý
  - name: 2.1 Phân công xử lý
    taskKey: taskLDVHCHQPhanCong
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: [email protected]
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: 2.2 Xử lý hồ sơ
  - name: 2.2 Xử lý hồ sơ
    taskKey: taskCVXuLy
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: [email protected]
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: 2.3 Xem xét & quyết định
  - name: 2.3 Xem xét & quyết định
    taskKey: taskLDVHCHQApprove
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: [email protected]
    taskOutcomes:
      - code: Approve
        name: Đồng ý
        outcomeDecision: APPROVED
        transition: 3. Kiểm tra thể thức
      - code: Reject
        name: Từ chối
        outcomeDecision: REJECTED
        transition: 2.2 Xử lý hồ sơ
      - code: Return
        name: Bổ sung hồ sơ
        outcomeDecision: RETURN
        transition: Kê khai hồ sơ
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: 3. Kiểm tra thể thức
  - name: 3. Kiểm tra thể thức
    taskKey: taskVPTCApprove
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: [email protected]
    taskOutcomes:
      - code: Approve
        name: Đồng ý
        outcomeDecision: APPROVED
        transition: 4. Xem xét phê duyệt
      - code: Reject
        name: Từ chối
        outcomeDecision: REJECTED
        transition: 2.2 Xử lý hồ sơ
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: 4. Xem xét phê duyệt
  - name: 4. Xem xét phê duyệt
    taskKey: taskLDTCApprove
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: [email protected]
    taskOutcomes:
      - code: Approve
        name: Đồng ý
        outcomeDecision: APPROVED
        transition: Export & Sign Form
      - code: Reject
        name: Từ chối
        outcomeDecision: REJECTED
        transition: 2.2 Xử lý hồ sơ
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: Export & Sign Form
  - name: Export & Sign Form
    type: operation
    actions:
      - name: Invoke Export & Sign Form Function
        functionRef:
          refName: ExportAndSignForm
          arguments:
            custName: '${ .customer.name }'
    transition: 5. Cấp số & đóng dấu
  - name: 5. Cấp số & đóng dấu
    taskKey: taskVPTCStamp
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: [email protected]
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: A
    transition: Đóng dấu
  - name: Đóng dấu
    type: operation
    actions:
      - name: Invoke StampForm Function
        functionRef:
          refName: StampForm
          arguments:
            custName: '${ .customer.name }'
        actionDataFilter:
          fromStateData: '${ .customer }'
    end: true
functions:
  - name: CreateQmsAPRequest
    type: custom
    operation: ExecuteQueryAction
    metadata:
      libraryQueryName: cmd.create.qms_ap_request
      libraryQueryRecordId: latest
      params: '["code", "aggId", "workflowId"]'
  - name: UpdateQmsAPRequestStatus
    type: custom
    operation: ExecuteQueryAction
    metadata:
      libraryQueryName: cmd.update.qms_ap_request_status
      libraryQueryRecordId: latest
      params: '["authStat", "workflowId"]'
  - name: NotifyWhenUserTaskCreated
    type: custom
    operation: ExecuteQueryAction
    metadata:
      libraryQueryName: cmd.mail.send_task_created
      libraryQueryRecordId: latest
      params: '["custName"]'
  - name: ExportAndSignForm
    type: custom
    operation: ExecuteQueryAction
    metadata:
      libraryQueryName: cmd.notif.log
      libraryQueryRecordId: latest
      params: '["custName"]'
  - name: StampForm
    type: custom
    operation: ExecuteQueryAction
    metadata:
      libraryQueryName: cmd.notif.log
      libraryQueryRecordId: latest
      params: '["custName"]'
  - name: TestJsCode
    type: custom
    operation: RunJs
    metadata:
      jsCode: return 'Hello' + custName1;
      params: '["custName"]'
events:
  - name: NewApplicationEvent
    type: com.a4b.xflow.engine.StateData
    source: xflowengine
  - name: UserTaskCreated
    type: com.a4b.xptask.event.post.user_task.UserTaskCreatedEvent
  - name: UserTaskCompleted
    type: com.a4b.xptask.event.post.user_task.UserTaskCompletedEvent
errors:
  - name: Not allowed to transfer money
    code: (.+) not allowed to transfer money
    description: User was not allowed to transfer money
  - name: Underage denied
    code: Transferring money is denied for underage
    description: Transferring money is denied for underage individuals.

Last updated