请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

候选人任务启动实例,未做拾取操作,任务的执行人就直接变成了“bajie,wukong”,求解决?

第一步:bpmn

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" 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" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1608990367912" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
  <process id="HouXuanRen_claim" isClosed="false" isExecutable="true" name="houxuanrenliuchengrenwu" processType="None">
    <startEvent id="_2" name="StartEvent"/>
    <userTask activiti:assignee="bajie,wukong" activiti:candidateUsers="bajie,wukong" activiti:exclusive="true" id="_3" name="houxuanrenrenwu"/>
    <endEvent id="_4" name="EndEvent"/>
    <sequenceFlow id="_5" sourceRef="_2" targetRef="_3"/>
    <sequenceFlow id="_6" sourceRef="_3" targetRef="_4"/>
  </process>
  <bpmndi:BPMNDiagram documentation="background=#FFFFFF;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
    <bpmndi:BPMNPlane bpmnElement="HouXuanRen_claim">
      <bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
        <omgdc:Bounds height="32.0" width="32.0" x="375.0" y="125.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3">
        <omgdc:Bounds height="55.0" width="85.0" x="350.0" y="245.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_4" id="Shape-_4">
        <omgdc:Bounds height="32.0" width="32.0" x="375.0" y="380.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="_5" id="BPMNEdge__5" sourceElement="_2" targetElement="_3">
        <omgdi:waypoint x="391.0" y="157.0"/>
        <omgdi:waypoint x="391.0" y="245.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_6" id="BPMNEdge__6" sourceElement="_3" targetElement="_4">
        <omgdi:waypoint x="391.0" y="300.0"/>
        <omgdi:waypoint x="391.0" y="380.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

第二步:部署流程

    /**
     * 通过bpmn部署流程
     */
    @Test
    void initDeploymentBPMN() {
        String filename = "BPMN/Part4_Task_claim.bpmn";
//        String pngname = "BPMN/Part4_Task.bpmn";
        Deployment deployment = repositoryService.createDeployment()
                .addClasspathResource(filename)
//                .addClasspathResource(pngname)
                .name("候选人流程部署001")
                .deploy();

        System.out.println(deployment.getName());
    }

第三步:启动流程实例

    /**
     * 初始化流程
     */
    @Test
    public void initProcessInstance(){
        // 1、获取表单填报的内容:请假时间、请假事由,String fromData
        // 2、写入业务表,返回业务表主键 ID
        // 3、把业务数据与Activiti7流程数据关联
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("HouXuanRen_claim", "businessKey004");
        System.out.println("流程实例ID:" + processInstance.getProcessDefinitionId());
    }

第四步:查询任务

    // 任务查询
    @Test
    public void getTasks(){
        List<Task> list = taskService.createTaskQuery()
                .list();
        list.forEach(task -> {
            System.out.println("Id:" + task.getId());
            System.out.println("Name:" + task.getName());
            System.out.println("Assignee:" + task.getAssignee());
        });
    }
    
    // 任务查询结果
	Id:8c1490ec-4d81-11eb-861c-c23049e74a6b
	Name:houxuanrenrenwu
	Assignee:bajie,wukong

第五步:执行拾取任务

    // 拾取任务
    @Test
    public void claimTask(){
        Task task = taskService.createTaskQuery()
                .taskId("8c1490ec-4d81-11eb-861c-c23049e74a6b")
                .singleResult();
        taskService.claim("8c1490ec-4d81-11eb-861c-c23049e74a6b", "wukong");
    }
    
    // 任务拾取报错
    org.activiti.engine.ActivitiTaskAlreadyClaimedException: Task '8c1490ec-4d81-11eb-861c-c23049e74a6b' is already claimed by someone else.

正在回答 回答被采纳积分+3

插入代码

2回答

汪汪对 2021-01-04 10:51:50

提示说,任务已经有人拾取了

原因是代理人assignee字段被赋值了,删掉代理人,只保留候选用户,就正常了。

0 回复 有任何疑惑可以回复我~
  • 提问者 贰零一贰 #1
    实例启动后,没有做拾取任务的操作,任务就自动被 bajie,wukong 给拾取了
    回复 有任何疑惑可以回复我~ 2021-01-04 11:33:03
  • 汪汪对 回复 提问者 贰零一贰 #2
    assignee="bajie,wukong" 去掉
    回复 有任何疑惑可以回复我~ 2021-01-06 14:00:34
汪汪对 2021-01-03 22:51:04

问题描述的很详细,我明早测试下,给你结果。

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号