【问题标题】:Complete Task Alfreso Rest API完成任务 Alfresco Rest API
【发布时间】:2018-04-27 23:18:37
【问题描述】:

我正在开发一个 Web 应用程序来使用 Rest api 管理露天工作流,在我的过程中,我有一个专用网关,其条件是 flow22,如下图所示: (如果决策变量等于“批准”,则流程转到任务 3)

对于第一个和第二个任务,一切正常,除了我在使用 Rest 完成 task2 时遇到此错误,因为我知道我已经将变量设置为 approve 。 这是我的 bpm

<?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:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="pres" name="prestation" isExecutable="true">
    <startEvent id="startevent1" name="Start" activiti:initiator="${initiator.properties.userName}" activiti:formKey="pfewf:submitHelloWorldTask"></startEvent>
    <userTask id="usertask1" name="Remplir formulaire demande" activiti:assignee="${initiator.properties.userName}" activiti:formKey="pfewf:demandepres">
      <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('pfewf_nomprenomDemA',task.getVariableLocal('pfewf_nomprenomDem'));
execution.setVariable('pfewf_ipDemA',task.getVariableLocal('pfewf_ipDem'));
execution.setVariable('pfewf_organismeDemA',task.getVariableLocal('pfewf_organismeDem'));
execution.setVariable('pfewf_refDemA',task.getVariableLocal('pfewf_refDem'));
execution.setVariable('pfewf_appDemA',task.getVariableLocal('pfewf_appDem'));
execution.setVariable('pfewf_dateDemA',task.getVariable('pfewf_dateDem'));
execution.setVariable('pfewf_typeDemA',task.getVariableLocal('pfewf_typeDem'));
execution.setVariable('pfewf_userDetailsA',task.getVariableLocal('pfewf_userDetails'));
execution.setVariable('pfewf_respTech',task.getVariableLocal('pfewf_respTech'));
execution.setVariable('pfewf_respTechR',task.getVariableLocal('pfewf_respTech'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[var date = new Date();
var timeInMillisecs = date.getTime(); 
var ISODate = utils.toISO8601(timeInMillisecs);
var origDate = utils.fromISO8601(ISODate);
execution.setVariable('pfewf_dateDem',origDate);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('pfewf_userDetails',task.getVariable('pfewf_userDetails'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <userTask id="usertask2" name="Responsable technique" activiti:assignee="${pfewf_respTech.properties.userName}" activiti:formKey="pfewf:avisTech">
      <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('pfewf_nomprenomDemR',task.getVariable('pfewf_nomprenomDemA'));
execution.setVariable('pfewf_ipDemR',task.getVariable('pfewf_ipDemA'));
execution.setVariable('pfewf_organismeDemR',task.getVariable('pfewf_organismeDemA'));
execution.setVariable('pfewf_refDemR',task.getVariable('pfewf_refDemA'));
execution.setVariable('pfewf_appDemR',task.getVariable('pfewf_appDemA'));
execution.setVariable('pfewf_dateDemR',task.getVariable('pfewf_dateDemA'));
execution.setVariable('pfewf_typeDemR',task.getVariable('pfewf_typeDemA'));
execution.setVariable('pfewf_userDetailsR',task.getVariable('pfewf_userDetails'));
execution.setVariable('pfewf_userDetailsA',task.getVariable('pfewf_userDetails'));
execution.setVariable('pfewf_testR',task.getVariable('pfewf_testA'));
execution.setVariable('pfewf_avisRespTech',task.getVariableLocal('pfewf_avisRespTech'));
execution.setVariable('pfewf_respTechR',task.getVariable('pfewf_respTech'));
execution.setVariable('pfewf_remarquesR',task.getVariableLocal('pfewf_remarquesA'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow3" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
    <userTask id="usertask3" name="Revision demande" activiti:assignee="${initiator.properties.userName}" activiti:formKey="pfewf:revisionDem"></userTask>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow8" sourceRef="usertask2" targetRef="exclusivegateway1"></sequenceFlow>
    <sequenceFlow id="flow9" name="a reviser" sourceRef="exclusivegateway1" targetRef="usertask3">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_avisRespTech
                   == 'A Rectifier'}]]></conditionExpression>
    </sequenceFlow>
    <exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow10" sourceRef="usertask3" targetRef="exclusivegateway2"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow11" name="annuler" sourceRef="exclusivegateway2" targetRef="endevent1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_decisionR
                   == 'Annuler'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow12" name="renvoyer" sourceRef="exclusivegateway2" targetRef="usertask2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_decisionR
                   == 'Renvoyer'}]]></conditionExpression>
    </sequenceFlow>
    <endEvent id="endevent2" name="End"></endEvent>
    <sequenceFlow id="flow13" name="refuser" sourceRef="exclusivegateway1" targetRef="endevent2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_avisRespTech
                   == 'Refuser'}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="usertask4" name="Avis DHE" activiti:candidateGroups="GROUP_DHE" activiti:formKey="pfewf:dhe">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('pfewf_nomprenomDemD',task.getVariable('pfewf_nomprenomDemA'));
execution.setVariable('pfewf_ipDemD',task.getVariable('pfewf_ipDemA'));
execution.setVariable('pfewf_organismeDemD',task.getVariable('pfewf_organismeDemA'));
execution.setVariable('pfewf_refDemD',task.getVariable('pfewf_refDemA'));
execution.setVariable('pfewf_appDemD',task.getVariable('pfewf_appDemA'));
execution.setVariable('pfewf_dateDemD',task.getVariable('pfewf_dateDemA'));
execution.setVariable('pfewf_typeDemD',task.getVariable('pfewf_typeDemA'));
execution.setVariable('pfewf_userDetailsD',task.getVariable('pfewf_userDetails'));
execution.setVariable('pfewf_testD',task.getVariable('pfewf_testA'));


execution.setVariable('pfewf_nomprenomDemDr',task.getVariable('pfewf_nomprenomDemA'));
execution.setVariable('pfewf_ipDemDr',task.getVariable('pfewf_ipDemA'));
execution.setVariable('pfewf_organismeDemDr',task.getVariable('pfewf_organismeDemA'));
execution.setVariable('pfewf_refDemDr',task.getVariable('pfewf_refDemA'));
execution.setVariable('pfewf_appDemDr',task.getVariable('pfewf_appDemA'));
execution.setVariable('pfewf_dateDemDr',task.getVariable('pfewf_dateDemA'));
execution.setVariable('pfewf_typeDemDr',task.getVariable('pfewf_typeDemA'));
execution.setVariable('pfewf_userDetailsDr',task.getVariable('pfewf_userDetails'));
execution.setVariable('pfewf_testDr',task.getVariable('pfewf_testA'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow14" name="valider" sourceRef="exclusivegateway1" targetRef="usertask4">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_avisRespTech
                   == 'Valider'}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="usertask5" name="Avis DRSM" activiti:candidateGroups="GROUP_DRSM" activiti:formKey="pfewf:drsm"></userTask>
    <sequenceFlow id="flow15" sourceRef="usertask4" targetRef="usertask5"></sequenceFlow>
    <endEvent id="endevent3" name="End"></endEvent>
    <sequenceFlow id="flow16" sourceRef="usertask5" targetRef="endevent3"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_pres">
    <bpmndi:BPMNPlane bpmnElement="pres" id="BPMNPlane_pres">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="310.0" y="323.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="71.0" width="112.0" x="400.0" y="305.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
        <omgdc:Bounds height="65.0" width="105.0" x="558.0" y="308.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
        <omgdc:Bounds height="55.0" width="105.0" x="688.0" y="461.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="720.0" y="321.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway2" id="BPMNShape_exclusivegateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="590.0" y="468.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="480.0" y="471.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="723.0" y="220.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask4" id="BPMNShape_usertask4">
        <omgdc:Bounds height="55.0" width="105.0" x="805.0" y="314.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask5" id="BPMNShape_usertask5">
        <omgdc:Bounds height="55.0" width="105.0" x="955.0" y="314.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent3" id="BPMNShape_endevent3">
        <omgdc:Bounds height="35.0" width="35.0" x="1105.0" y="324.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="345.0" y="340.0"></omgdi:waypoint>
        <omgdi:waypoint x="400.0" y="340.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="512.0" y="340.0"></omgdi:waypoint>
        <omgdi:waypoint x="558.0" y="340.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="663.0" y="340.0"></omgdi:waypoint>
        <omgdi:waypoint x="720.0" y="341.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="740.0" y="361.0"></omgdi:waypoint>
        <omgdi:waypoint x="740.0" y="461.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="16.0" width="48.0" x="752.0" y="390.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
        <omgdi:waypoint x="688.0" y="488.0"></omgdi:waypoint>
        <omgdi:waypoint x="630.0" y="488.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
        <omgdi:waypoint x="590.0" y="488.0"></omgdi:waypoint>
        <omgdi:waypoint x="515.0" y="488.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="16.0" width="42.0" x="532.0" y="500.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
        <omgdi:waypoint x="610.0" y="468.0"></omgdi:waypoint>
        <omgdi:waypoint x="610.0" y="373.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="16.0" width="48.0" x="615.0" y="431.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
        <omgdi:waypoint x="740.0" y="321.0"></omgdi:waypoint>
        <omgdi:waypoint x="740.0" y="255.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="16.0" width="39.0" x="752.0" y="296.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow14" id="BPMNEdge_flow14">
        <omgdi:waypoint x="760.0" y="341.0"></omgdi:waypoint>
        <omgdi:waypoint x="805.0" y="341.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="16.0" width="100.0" x="760.0" y="341.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
        <omgdi:waypoint x="910.0" y="341.0"></omgdi:waypoint>
        <omgdi:waypoint x="955.0" y="341.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16">
        <omgdi:waypoint x="1060.0" y="341.0"></omgdi:waypoint>
        <omgdi:waypoint x="1105.0" y="341.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

如何通过 Rest api 处理独占网关? 提前谢谢你。

【问题讨论】:

    标签: rest api alfresco


    【解决方案1】:

    我强烈怀疑 decision 变量是否已经设置,完成 task2 后您可以通过调用此端点来检查变量的值:

    GET /tasks/{taskId}/variables
    

    要在完成任务之前设置变量,您必须这样做

    网址:

    PUT /tasks/{taskId}?select=state,variables
    

    请求正文:

    {
      "state": "completed",
      "variables": [
          {
              "name": "decision",
              "type": "d_text",
              "value": "approve",
              "scope": "global"
          }
      ]
    }
    

    【讨论】:

    • 您能发布您的 BPMN 定义吗?
    • 这可能会更好,如果您编辑原始帖子以添加 BPMN,无论如何在您发布的 BPMN 中有一个名为决策的变量,请仔细检查变量的名称。
    • 哦抱歉这是原来的bpm,决策变量是pfewf_avisRespTech,我认为问题是任务脚本没有执行,当我完成一个任务时,下一个任务的变量总是空的。跨度>
    【解决方案2】:

    有很多解决方案:

    1. 您可以在流程中使用此条件14 "${pfewf_avisRespTech != 'Refuser' && pfewf_avisRespTech != 'A Rectifier'}"。
    2. 例如,在您的模型中,将 pfewf_avisRespTech 的默认值设置为“Valider”
    3. 在要求工作流引擎完成您的任务之前,请他更新您的 pfewf_avisRespTech 的值
    4. 在 task2 的完整侦听器中检查“pfewf_avisRespTech”的值,如果它等于“”,或者 null 给它一些值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多