<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:flowable="http://flowable.org/bpmn"
             targetNamespace="http://flowable.org/process">

    <process id="earlyWarningProcess" name="预警处置流程" isExecutable="true">

        <!-- 开始事件 -->
        <startEvent id="start" name="开始">
            <outgoing>flow1</outgoing>
        </startEvent>

        <!-- 发布预警任务 -->
        <userTask id="publishWarning" name="发布预警" flowable:assignee="${publisher}">
            <incoming>flow1</incoming>
            <outgoing>flow2</outgoing>
        </userTask>

        <!-- 处理预警任务 -->
        <userTask id="handleWarning" name="处理预警" flowable:assignee="${handler}">
            <incoming>flow2</incoming>
            <outgoing>flow3</outgoing>
        </userTask>

        <!-- 决策网关 -->
        <exclusiveGateway id="decision" name="是否解除">
            <incoming>flow3</incoming>
            <outgoing>flow4</outgoing>
            <outgoing>flow5</outgoing>
        </exclusiveGateway>

        <!-- 解除预警任务 -->
        <userTask id="resolveWarning" name="解除预警" flowable:assignee="${handler}">
            <incoming>flow4</incoming>
            <outgoing>flow6</outgoing>
        </userTask>

        <!-- 退回重办任务 -->
        <userTask id="returnWarning" name="退回重办" flowable:assignee="${publisher}">
            <incoming>flow5</incoming>
            <outgoing>flow7</outgoing>
        </userTask>

        <!-- 结束事件 -->
        <endEvent id="end" name="结束">
            <incoming>flow6</incoming>
        </endEvent>

        <!-- 流程连接线 -->
        <sequenceFlow id="flow1" sourceRef="start" targetRef="publishWarning"/>
        <sequenceFlow id="flow2" sourceRef="publishWarning" targetRef="handleWarning"/>
        <sequenceFlow id="flow3" sourceRef="handleWarning" targetRef="decision"/>
        <sequenceFlow id="flow4" sourceRef="decision" targetRef="resolveWarning" name="是">
            <conditionExpression xsi:type="tFormalExpression">${approved == true}</conditionExpression>
        </sequenceFlow>
        <sequenceFlow id="flow5" sourceRef="decision" targetRef="returnWarning" name="否">
            <conditionExpression xsi:type="tFormalExpression">${approved == false}</conditionExpression>
        </sequenceFlow>
        <sequenceFlow id="flow6" sourceRef="resolveWarning" targetRef="end"/>
        <sequenceFlow id="flow7" sourceRef="returnWarning" targetRef="handleWarning"/>

    </process>

</definitions>
