activiti 多人会签
// 3个人审批,第二个人不同意,则直接返回修改
1 @Override 2 public void comTask(String taskId, String desc, Map<String, Object> variables, String isGo) throws Exception { 3 //完成节点 4 Task task = taskService// 与正在执行的任务管理相关的service 5 .createTaskQuery()// 创建任务查询对象 6 .taskId(taskId) 7 .singleResult() //返回唯一的结果集 8 ; 9 task.setDescription(desc); 10 taskService.saveTask(task); 11 claimTask(task,variables); 12 createAttachment(task,variables); 13 if(isGo!=null&&isGo.equals("no")){ 14 List<Task> listA = taskService.createTaskQuery() 15 .processInstanceId(task.getProcessInstanceId()) 16 .list(); 17 if(listA!=null&&listA.size()>0){ 18 for(Task a:listA){ 19 if(!a.getId().equals(task.getId())){ 20 taskService.complete(a.getId()); 21 String sql = "delete from ActHiTaskinst t where t.id = '"+a.getId()+"'"; 22 dao.executeHql(sql); 23 } 24 } 25 } 26 } 27 taskService.complete(task.getId(),variables); 28 }
@Override public void completeTask(String taskId, String instanceId, String passflag, Map<String, Object> vars) { // TODO: 一旦有人不通过,则delete剩下的所有在执行中的task ActRuTask actRuTask = (ActRuTask) basicService.getObjectById(ActRuTask.class, taskId); if(actRuTask == null) { return; } ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); List<Task> tasks = processEngine.getTaskService().createTaskQuery().taskName(actRuTask.getName()) .processInstanceId(instanceId).list(); int count = 0; int totalCount = 0; for (Task task : tasks) { if (task.getId().equals(taskId)) { // 获取通过记录数,这里不能使用nrOfCompletedInstances,因为与我们业务无关 String tmpCount = processEngine.getTaskService().getVariable(task.getId(), "passCount") + ""; // 获取记录总数 String tmpTotal = processEngine.getTaskService().getVariable(task.getId(), "totalCount") + ""; if (!tmpCount.equals("null") && !tmpCount.trim().equals("")) { count = Integer.parseInt(tmpCount); } if (!tmpTotal.equals("null") && !tmpTotal.trim().equals("")) { totalCount = Integer.parseInt(tmpTotal); } System.out.println(task.getId() + "var = " + passflag); if (passflag.equals("yes")) {// 选择通过则+1 count++; } totalCount++; } } // 变量回写记录 vars.put("passCount", count); vars.put("totalCount", totalCount); processEngine.getTaskService().complete(taskId, vars); }