123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- <?xml version="1.0" encoding="UTF-8"?>
- <bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.22.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
- <bpmn2:process id="ProcessPlanApprove" name="计划创建审批流程" isExecutable="true" camunda:versionTag="1.0">
- <bpmn2:startEvent id="event_start">
- <bpmn2:extensionElements>
- <camunda:properties>
- <camunda:property name="test" value="test111" />
- </camunda:properties>
- </bpmn2:extensionElements>
- <bpmn2:outgoing>Flow_15zn1tu</bpmn2:outgoing>
- </bpmn2:startEvent>
- <bpmn2:userTask id="task_request_plan" name="申请创建计划" camunda:assignee="owner">
- <bpmn2:extensionElements>
- <camunda:inputOutput>
- <camunda:inputParameter name="show_in_my_works">${false}</camunda:inputParameter>
- <camunda:inputParameter name="process_type">${1}</camunda:inputParameter>
- <camunda:inputParameter name="target_type">project-plan</camunda:inputParameter>
- <camunda:inputParameter name="draft">${false}</camunda:inputParameter>
- </camunda:inputOutput>
- <camunda:executionListener event="end">
- <camunda:script scriptFormat="JavaScript">
- (async function () {
- try {
- let owner = await this.environment.services.owner(); // 获取任务责任人
- if (!owner) {
- await this.environment.services.gen_warn_task('admin', '提交计划审核时未找到负责人',
- `提交计划审核时未找到负责人,流程出错。case id: ${this.environment.variables.id}`);
- }
- // 获取审核人列表
- let checkers = await this.environment.services.get_handlers('project_checker');
- if (!checkers || checkers.length === 0) return;
- let checkers_str = "";
- for (var i = 0; i < checkers.length; i++) {
- if (i > 0) checkers_str += '、';
- checkers_str += `${checkers[i].name}`;
- }
- await this.environment.services.gen_remind_task(owner.id, '项目计划已提交', `<b>${owner.name}</b>已于 <b>` +
- this.environment.services.get_datetime() + `</b> 提交了项目计划,将由: <br> <b>${checkers_str}</b> 进行审核。`);
- await this.environment.services.logger(owner.id, owner.name, `提交了项目计划,将由: <br> <b>${checkers_str}</b> <br>进行审核。`);
-
- } catch (e) {
- this.environment.Logger('work').error(e);
- }
- })();
- </camunda:script>
- </camunda:executionListener>
- <camunda:executionListener event="start">
- <camunda:script scriptFormat="JavaScript">(async function () {
- try {
- let handlers = await this.environment.services.get_handlers('project_checker');
- let result = handlers.length > 0 ? true: false;
- if (!result) {
- return {
- result: false,
- message: '计划申请前,请先配置审核组成员,否则无法执行计划审核任务。'
- }
- } else {
- return {
- result: true,
- message: 'OK'
- }
- }
-
-
- } catch (e) {
- this.environment.Logger('work').error(e);
- return {
- result: false,
- message: 'fail'
- }
- }
- })();</camunda:script>
- </camunda:executionListener>
- </bpmn2:extensionElements>
- <bpmn2:incoming>Flow_1t45qnv</bpmn2:incoming>
- <bpmn2:incoming>Flow_0gyvyyo</bpmn2:incoming>
- <bpmn2:outgoing>Flow_1rg4oob</bpmn2:outgoing>
- <bpmn2:outgoing>Flow_0bhibn0</bpmn2:outgoing>
- </bpmn2:userTask>
- <bpmn2:sequenceFlow id="Flow_15zn1tu" sourceRef="event_start" targetRef="task_create_plan" />
- <bpmn2:sequenceFlow id="Flow_1rg4oob" sourceRef="task_request_plan" targetRef="task_approve_plan">
- <bpmn2:extensionElements>
- <camunda:properties>
- <camunda:property name="prj_phase" value="overview_plan" />
- <camunda:property name="prj_phase_name" value="计划审核中" />
- </camunda:properties>
- </bpmn2:extensionElements>
- </bpmn2:sequenceFlow>
- <bpmn2:userTask id="task_approve_plan" name="审核计划" camunda:formKey="plan_create_approve" camunda:assignee="project_checker">
- <bpmn2:extensionElements>
- <camunda:inputOutput>
- <camunda:inputParameter name="show_in_my_works">${true}</camunda:inputParameter>
- <camunda:inputParameter name="process_type">${1}</camunda:inputParameter>
- <camunda:inputParameter name="target_type"> project-plan</camunda:inputParameter>
- <camunda:inputParameter name="prj_id">${environment.variables.prj_id}</camunda:inputParameter>
- <camunda:inputParameter name="draft">${false}</camunda:inputParameter>
- </camunda:inputOutput>
- <camunda:executionListener event="end">
- <camunda:script scriptFormat="JavaScript">
- (async function () {
- try {
- let owner = await this.environment.services.owner(); // 获取任务责任人
- if (!owner) {
- await this.environment.services.gen_warn_task('admin', '计划申请时未找到负责人',
- `计划申请时未找到负责人,流程出错。case id: ${this.environment.variables.id}`);
- }
- this.environment.Logger('work').debug(this.content);
- let checker = this.content.handlers[this.content.index]; // 获取当前审核人,这个是循环任务,有多个审核人依次审核
- let result = this.content.output[this.content.index]; // 来自于审核人表单结果
- if (result.pass) { // 如果审核通过
- await this.environment.services.gen_remind_task(owner.id, `${checker.name}已批准项目计划`,
- '<b>' + checker.name + '</b>已于 <b>' + this.environment.services.get_datetime() + '</b> 批准项目计划。审核意见如下:<br>' + result.opinion);
- await this.environment.services.logger(checker.id, checker.name, '批准项目计划,审核意见:' + result.opinion);
- } else {
- await this.environment.services.gen_remind_task(owner.id, `${checker.name}已驳回项目计划`,
- '<b>' + checker.name + '</b>已于 <b>' + this.environment.services.get_datetime() + '</b> 驳回项目计划。审核意见如下:<br>' + result.opinion);
- await this.environment.services.logger(checker.id, checker.name, '驳回项目计划,审核意见:<span style="color: red;">' + result.opinion + '</span>');
- }
- } catch (e) {
- this.environment.Logger('work').error(e);
- }
- })();
- </camunda:script>
- </camunda:executionListener>
- </bpmn2:extensionElements>
- <bpmn2:incoming>Flow_1rg4oob</bpmn2:incoming>
- <bpmn2:outgoing>Flow_193tusd</bpmn2:outgoing>
- <bpmn2:multiInstanceLoopCharacteristics isSequential="true" camunda:collection="${content.handlers}" camunda:elementVariable="handler">
- <bpmn2:loopCardinality xsi:type="bpmn2:tFormalExpression">${content.handlers.length}</bpmn2:loopCardinality>
- <bpmn2:completionCondition xsi:type="bpmn2:tFormalExpression">${!content.output.pass}</bpmn2:completionCondition>
- </bpmn2:multiInstanceLoopCharacteristics>
- </bpmn2:userTask>
- <bpmn2:exclusiveGateway id="gateway_approved" default="Flow_0nwaga3">
- <bpmn2:incoming>Flow_193tusd</bpmn2:incoming>
- <bpmn2:outgoing>Flow_0zubkyw</bpmn2:outgoing>
- <bpmn2:outgoing>Flow_0nwaga3</bpmn2:outgoing>
- </bpmn2:exclusiveGateway>
- <bpmn2:sequenceFlow id="Flow_193tusd" sourceRef="task_approve_plan" targetRef="gateway_approved" />
- <bpmn2:sequenceFlow id="Flow_0zubkyw" name="通过" sourceRef="gateway_approved" targetRef="event_throw_approved">
- <bpmn2:extensionElements>
- <camunda:properties>
- <camunda:property name="prj_phase" value="doing" />
- <camunda:property name="prj_phase_name" value="执行中" />
- </camunda:properties>
- </bpmn2:extensionElements>
- <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression" language="JavaScript">next(null, this.environment.variables.pass===true);</bpmn2:conditionExpression>
- </bpmn2:sequenceFlow>
- <bpmn2:sequenceFlow id="Flow_0nwaga3" name="驳回" sourceRef="gateway_approved" targetRef="event_throw_approved_back">
- <bpmn2:extensionElements>
- <camunda:properties>
- <camunda:property name="prj_phase" value="reject_plan" />
- <camunda:property name="prj_phase_name" value="计划被驳回" />
- </camunda:properties>
- </bpmn2:extensionElements>
- </bpmn2:sequenceFlow>
- <bpmn2:sequenceFlow id="Flow_0bhibn0" sourceRef="task_request_plan" targetRef="task_with_draw" />
- <bpmn2:userTask id="task_with_draw" name="撤回计划审核" camunda:assignee="owner">
- <bpmn2:extensionElements>
- <camunda:inputOutput>
- <camunda:inputParameter name="process_type">${1}</camunda:inputParameter>
- </camunda:inputOutput>
- <camunda:executionListener event="end">
- <camunda:script scriptFormat="JavaScript">
- (async function() {
- try{
- let owner = await this.environment.services.owner(); // 获取任务责任人
- if (!owner) {
- await this.environment.services.gen_warn_task('admin', '项目计划申请被撤回时未找到负责人',
- `项目计划申请被撤回时未找到负责人,流程出错。case id: ${this.environment.variables.id}`);
- }
- await this.environment.services.gen_remind_task(owner.id, '项目计划已被撤回',
- owner.name+'已于 ' + this.environment.services.get_datetime() + ' 撤回项目计划。');
- await this.environment.services.logger(owner.id, owner.name, `撤回了项目计划申请。`);
- } catch(e){
- this.environment.Logger('work').error(e);
- }
- })();
- </camunda:script>
- </camunda:executionListener>
- </bpmn2:extensionElements>
- <bpmn2:incoming>Flow_0bhibn0</bpmn2:incoming>
- <bpmn2:outgoing>Flow_0tj9nd6</bpmn2:outgoing>
- </bpmn2:userTask>
- <bpmn2:sequenceFlow id="Flow_0tj9nd6" sourceRef="task_with_draw" targetRef="Event_throw_withdraw">
- <bpmn2:extensionElements>
- <camunda:properties>
- <camunda:property name="prj_phase" value="created" />
- <camunda:property name="prj_phase_name" value="计划申请已撤回" />
- </camunda:properties>
- </bpmn2:extensionElements>
- </bpmn2:sequenceFlow>
- <bpmn2:boundaryEvent id="Event_catch_withdraw" name="撤回" attachedToRef="task_approve_plan">
- <bpmn2:outgoing>Flow_0nzbvpg</bpmn2:outgoing>
- <bpmn2:signalEventDefinition id="SignalEventDefinition_111s194" signalRef="Signal_0hhmd7l" />
- </bpmn2:boundaryEvent>
- <bpmn2:intermediateThrowEvent id="Event_throw_withdraw" name="撤回事件">
- <bpmn2:incoming>Flow_0tj9nd6</bpmn2:incoming>
- <bpmn2:signalEventDefinition id="SignalEventDefinition_1tt7p06" signalRef="Signal_0hhmd7l" />
- </bpmn2:intermediateThrowEvent>
- <bpmn2:sequenceFlow id="Flow_02taytj" sourceRef="event_throw_approved" targetRef="Event_end">
- <bpmn2:extensionElements />
- </bpmn2:sequenceFlow>
- <bpmn2:intermediateThrowEvent id="event_throw_approved" name="已审核事件">
- <bpmn2:incoming>Flow_0zubkyw</bpmn2:incoming>
- <bpmn2:outgoing>Flow_02taytj</bpmn2:outgoing>
- <bpmn2:signalEventDefinition id="SignalEventDefinition_07jfo4t" signalRef="Signal_0828f9d" />
- </bpmn2:intermediateThrowEvent>
- <bpmn2:sequenceFlow id="Flow_1ucg773" sourceRef="event_catch_approved" targetRef="Event_end" />
- <bpmn2:boundaryEvent id="event_catch_approved" name="已审核" attachedToRef="task_with_draw">
- <bpmn2:outgoing>Flow_1ucg773</bpmn2:outgoing>
- <bpmn2:signalEventDefinition id="SignalEventDefinition_02ri5rf" signalRef="Signal_0828f9d" />
- </bpmn2:boundaryEvent>
- <bpmn2:intermediateThrowEvent id="event_throw_approved_back" name="已审核事件">
- <bpmn2:incoming>Flow_0nwaga3</bpmn2:incoming>
- <bpmn2:outgoing>Flow_06cxzjx</bpmn2:outgoing>
- <bpmn2:signalEventDefinition id="SignalEventDefinition_0y27jk5" signalRef="Signal_0828f9d" />
- </bpmn2:intermediateThrowEvent>
- <bpmn2:sequenceFlow id="Flow_1t45qnv" sourceRef="task_modify" targetRef="task_request_plan" />
- <bpmn2:sequenceFlow id="Flow_0nzbvpg" sourceRef="Event_catch_withdraw" targetRef="task_modify">
- <bpmn2:extensionElements />
- </bpmn2:sequenceFlow>
- <bpmn2:sequenceFlow id="Flow_06cxzjx" sourceRef="event_throw_approved_back" targetRef="task_modify" />
- <bpmn2:manualTask id="task_create_plan" name="创建计划">
- <bpmn2:incoming>Flow_15zn1tu</bpmn2:incoming>
- <bpmn2:outgoing>Flow_0gyvyyo</bpmn2:outgoing>
- </bpmn2:manualTask>
- <bpmn2:sequenceFlow id="Flow_0gyvyyo" sourceRef="task_create_plan" targetRef="task_request_plan">
- <bpmn2:extensionElements />
- </bpmn2:sequenceFlow>
- <bpmn2:manualTask id="task_modify" name="修改计划信息">
- <bpmn2:incoming>Flow_0nzbvpg</bpmn2:incoming>
- <bpmn2:incoming>Flow_06cxzjx</bpmn2:incoming>
- <bpmn2:outgoing>Flow_1t45qnv</bpmn2:outgoing>
- </bpmn2:manualTask>
- <bpmn2:endEvent id="Event_end">
- <bpmn2:incoming>Flow_1ucg773</bpmn2:incoming>
- <bpmn2:incoming>Flow_02taytj</bpmn2:incoming>
- </bpmn2:endEvent>
- </bpmn2:process>
- <bpmn2:signal id="Signal_0hhmd7l" name="cancel_sign" />
- <bpmn2:message id="Message_0fh9t3e" name="msg_cancel" />
- <bpmn2:message id="Message_1qtzp8g" name="Message_0q7qbc4" />
- <bpmn2:signal id="Signal_0828f9d" name="Signal_2sf6vik" />
- <bpmndi:BPMNDiagram id="BPMNDiagram_1">
- <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ProcessPlanApprove">
- <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="event_start">
- <dc:Bounds x="152" y="132" width="36" height="36" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Activity_09wmdbt_di" bpmnElement="task_request_plan">
- <dc:Bounds x="380" y="110" width="100" height="80" />
- <bpmndi:BPMNLabel />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Activity_0ds6ym0_di" bpmnElement="task_approve_plan">
- <dc:Bounds x="540" y="110" width="100" height="80" />
- <bpmndi:BPMNLabel />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Gateway_06baw71_di" bpmnElement="gateway_approved" isMarkerVisible="true">
- <dc:Bounds x="845" y="125" width="50" height="50" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Activity_0fonc56_di" bpmnElement="task_with_draw">
- <dc:Bounds x="450" y="410" width="100" height="80" />
- <bpmndi:BPMNLabel />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Event_0mceau4_di" bpmnElement="Event_throw_withdraw">
- <dc:Bounds x="662" y="432" width="36" height="36" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="658" y="475" width="44" height="14" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Event_0tntlum_di" bpmnElement="event_throw_approved">
- <dc:Bounds x="972" y="132" width="36" height="36" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="963" y="175" width="55" height="14" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Event_1gjhb1n_di" bpmnElement="event_throw_approved_back">
- <dc:Bounds x="852" y="222" width="36" height="36" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="892" y="233" width="55" height="14" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Activity_0isolrc_di" bpmnElement="task_create_plan">
- <dc:Bounds x="250" y="110" width="100" height="80" />
- <bpmndi:BPMNLabel />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Activity_1k7kq2t_di" bpmnElement="task_modify">
- <dc:Bounds x="460" y="240" width="100" height="80" />
- <bpmndi:BPMNLabel />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Event_1jljt88_di" bpmnElement="Event_end">
- <dc:Bounds x="1072" y="132" width="36" height="36" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Event_06bs6js_di" bpmnElement="event_catch_approved">
- <dc:Bounds x="482" y="392" width="36" height="36" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="513" y="386" width="33" height="14" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Event_0s1xb2l_di" bpmnElement="Event_catch_withdraw">
- <dc:Bounds x="602" y="172" width="36" height="36" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="629" y="208" width="22" height="14" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="Flow_15zn1tu_di" bpmnElement="Flow_15zn1tu">
- <di:waypoint x="188" y="150" />
- <di:waypoint x="250" y="150" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="Flow_1rg4oob_di" bpmnElement="Flow_1rg4oob">
- <di:waypoint x="480" y="150" />
- <di:waypoint x="540" y="150" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="Flow_193tusd_di" bpmnElement="Flow_193tusd">
- <di:waypoint x="640" y="150" />
- <di:waypoint x="845" y="150" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="Flow_0zubkyw_di" bpmnElement="Flow_0zubkyw">
- <di:waypoint x="895" y="150" />
- <di:waypoint x="972" y="150" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="923" y="132" width="22" height="14" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="Flow_0nwaga3_di" bpmnElement="Flow_0nwaga3">
- <di:waypoint x="870" y="175" />
- <di:waypoint x="870" y="222" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="874" y="183" width="22" height="14" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="Flow_0bhibn0_di" bpmnElement="Flow_0bhibn0">
- <di:waypoint x="430" y="190" />
- <di:waypoint x="430" y="450" />
- <di:waypoint x="450" y="450" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="Flow_0tj9nd6_di" bpmnElement="Flow_0tj9nd6">
- <di:waypoint x="550" y="450" />
- <di:waypoint x="662" y="450" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="Flow_02taytj_di" bpmnElement="Flow_02taytj">
- <di:waypoint x="1008" y="150" />
- <di:waypoint x="1072" y="150" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="Flow_1ucg773_di" bpmnElement="Flow_1ucg773">
- <di:waypoint x="500" y="392" />
- <di:waypoint x="500" y="340" />
- <di:waypoint x="1090" y="340" />
- <di:waypoint x="1090" y="168" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="Flow_1t45qnv_di" bpmnElement="Flow_1t45qnv">
- <di:waypoint x="510" y="240" />
- <di:waypoint x="510" y="215" />
- <di:waypoint x="450" y="215" />
- <di:waypoint x="450" y="190" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="Flow_0nzbvpg_di" bpmnElement="Flow_0nzbvpg">
- <di:waypoint x="620" y="208" />
- <di:waypoint x="620" y="280" />
- <di:waypoint x="560" y="280" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="Flow_06cxzjx_di" bpmnElement="Flow_06cxzjx">
- <di:waypoint x="870" y="258" />
- <di:waypoint x="870" y="280" />
- <di:waypoint x="560" y="280" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="Flow_0gyvyyo_di" bpmnElement="Flow_0gyvyyo">
- <di:waypoint x="350" y="150" />
- <di:waypoint x="380" y="150" />
- </bpmndi:BPMNEdge>
- </bpmndi:BPMNPlane>
- </bpmndi:BPMNDiagram>
- </bpmn2:definitions>
|