/** * 判断流程是否可撤回 * 历史流程节点中最后一个审批人是userId */ @Override public Result canWithdraw(HistoricProcessInstance processInstance, String userId) { List<HistoricTaskInstance> taskInstances = historyService.createHistoricTaskInstanceQuery().processUnfinished() .processInstanceId(processInstance.getId()).orderByTaskCreateTime().desc().orderByTaskId().desc() .list(); //Task activeTask=taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); if (taskInstances.isEmpty() || taskInstances.size() < 2) return new Result(false, null, "已办理,不可撤回"); else { HistoricTaskInstance taskInstance = taskInstances.get(1); HistoricTaskInstance taskCurrent = taskInstances.get(0); //流程审批人未未指定(未签收+未办理) if (StrUtil.isEmpty(taskCurrent.getAssignee())) { if (taskInstance.getAssignee() != null && taskInstance.getAssignee().equals(userId)) { return new Result(true, taskInstance, "可以撤回"); } } //流程定义时指定了办理人,也可以撤回 else if (getTaskState(taskCurrent.getId())) { if (taskInstance.getAssignee() != null && taskInstance.getAssignee().equals(userId)) { return new Result(true, taskInstance, "可以撤回"); } } } return new Result(false, null, "任务被签收或办理,不可撤回"); }
public Result deleteCurrentTaskInstance(String taskId, HistoricTaskInstance taskInstance) { //删除正在执行的任务 //删除HistoricTaskInstance String sql_task = "delete from " + managementService.getTableName(HistoricTaskInstance.class) + " where " + "ID_='" + taskId + "' or ID_='" + taskInstance.getId() + "'"; this.executeSql(sql_task); //删除HistoricActivityInstance String sql_activity = "delete from " + managementService.getTableName(HistoricActivityInstance.class) + " where " + "TASK_ID_='" + taskId + "' or TASK_ID_='" + taskInstance.getId() + "'"; this.executeSql(sql_activity); //获取当前的任务,保存签收人 Task task = taskService.createTaskQuery().executionId(taskInstance.getExecutionId()).singleResult(); task.setAssignee(taskInstance.getAssignee()); task.setOwner(taskInstance.getOwner()); taskService.saveTask(task); //解决HistoricActivityInstance的Assignee为空的现象 if (!StrUtil.isEmpty(taskInstance.getAssignee())) { String sql_update = "update " + managementService.getTableName(HistoricActivityInstance.class) + " set " + "ASSIGNEE_='" + taskInstance.getAssignee() + "' where TASK_ID_='" + task.getId() + "'"; this.executeSql(sql_update); } String sql_update_execution = "update " + managementService.getTableName(Execution.class) + " set " + "ACT_ID_='" + taskInstance.getTaskDefinitionKey() + "' where ID_='" + taskInstance.getExecutionId() + "'"; this.executeSql(sql_update_execution); return new Result(true); }
private String getOwner() { if(task != null) { return task.getAssignee(); } else { return historicTask.getAssignee(); } } }
private String getOwner() { if(task != null) { return task.getAssignee(); } else { return historicTask.getAssignee(); } } }
protected void initAssignee() { String assigneeRole = historicTask.getAssignee() != null ? Messages.TASK_ASSIGNEE : Messages.TASK_NO_ASSIGNEE; UserDetailsComponent assignee = new UserDetailsComponent(historicTask.getAssignee(), i18nManager.getMessage(assigneeRole)); peopleGrid.addComponent(assignee); }
properties.put(ContentModel.PROP_OWNER, historicTask.getAssignee());
properties.put(ContentModel.PROP_OWNER, historicTask.getAssignee());
if (historicTaskInstance.getAssignee() != null) { historySameKeyTask = historicTaskInstance; break; if (historySameKeyTask != null && historySameKeyTask.getAssignee() != null) { String lastAssignee = historySameKeyTask.getAssignee(); taskService.claim(task.getId(), lastAssignee); logger.info("task [id={}] automatic assignee to : {}", taskId, lastAssignee);
public HistoricTaskWrapper(HistoricTaskInstance historicTaskInstance) { this.id = historicTaskInstance.getId(); setName(historicTaskInstance.getName()); setDescription(historicTaskInstance.getDescription()); setDueDate(historicTaskInstance.getDueDate()); setPriority(historicTaskInstance.getPriority()); setOwner(historicTaskInstance.getOwner()); setAssignee(historicTaskInstance.getAssignee()); setTenantId(historicTaskInstance.getTenantId()); setFormKey(historicTaskInstance.getFormKey()); }
protected void addTaskItem(HistoricTaskInstance task, Table taskTable) { Item item = taskTable.addItem(task.getId()); if(task.getEndTime() != null) { item.getItemProperty("finished").setValue(new Embedded(null, Images.TASK_FINISHED_22)); } else { item.getItemProperty("finished").setValue(new Embedded(null, Images.TASK_22)); } item.getItemProperty("name").setValue(task.getName()); item.getItemProperty("priority").setValue(task.getPriority()); item.getItemProperty("startDate").setValue(new PrettyTimeLabel(task.getStartTime(), true)); item.getItemProperty("endDate").setValue(new PrettyTimeLabel(task.getEndTime(), true)); if(task.getDueDate() != null) { Label dueDateLabel = new PrettyTimeLabel(task.getEndTime(), i18nManager.getMessage(Messages.TASK_NOT_FINISHED_YET), true); item.getItemProperty("dueDate").setValue(dueDateLabel); } if(task.getAssignee() != null) { Component taskAssigneeComponent = getTaskAssigneeComponent(task.getAssignee()); if(taskAssigneeComponent != null) { item.getItemProperty("assignee").setValue(taskAssigneeComponent); } } }
protected void addTaskItem(HistoricTaskInstance task, Table taskTable) { Item item = taskTable.addItem(task.getId()); if(task.getEndTime() != null) { item.getItemProperty("finished").setValue(new Embedded(null, Images.TASK_FINISHED_22)); } else { item.getItemProperty("finished").setValue(new Embedded(null, Images.TASK_22)); } item.getItemProperty("name").setValue(task.getName()); item.getItemProperty("priority").setValue(task.getPriority()); item.getItemProperty("startDate").setValue(new PrettyTimeLabel(task.getStartTime(), true)); item.getItemProperty("endDate").setValue(new PrettyTimeLabel(task.getEndTime(), true)); if(task.getDueDate() != null) { Label dueDateLabel = new PrettyTimeLabel(task.getEndTime(), i18nManager.getMessage(Messages.TASK_NOT_FINISHED_YET), true); item.getItemProperty("dueDate").setValue(dueDateLabel); } if(task.getAssignee() != null) { Component taskAssigneeComponent = getTaskAssigneeComponent(task.getAssignee()); if(taskAssigneeComponent != null) { item.getItemProperty("assignee").setValue(taskAssigneeComponent); } } }
protected void addTaskItem(HistoricTaskInstance task, Table taskTable) { Item item = taskTable.addItem(task.getId()); if(task.getEndTime() != null) { item.getItemProperty("finished").setValue(new Embedded(null, Images.TASK_FINISHED_22)); } else { item.getItemProperty("finished").setValue(new Embedded(null, Images.TASK_22)); } item.getItemProperty("name").setValue(task.getName()); item.getItemProperty("priority").setValue(task.getPriority()); item.getItemProperty("startDate").setValue(new PrettyTimeLabel(task.getStartTime(), true)); item.getItemProperty("endDate").setValue(new PrettyTimeLabel(task.getEndTime(), true)); if(task.getDueDate() != null) { Label dueDateLabel = new PrettyTimeLabel(task.getEndTime(), i18nManager.getMessage(Messages.TASK_NOT_FINISHED_YET), true); item.getItemProperty("dueDate").setValue(dueDateLabel); } if(task.getAssignee() != null) { Component taskAssigneeComponent = getTaskAssigneeComponent(task.getAssignee()); if(taskAssigneeComponent != null) { item.getItemProperty("assignee").setValue(taskAssigneeComponent); } } }
private TaskInfoBean transToTaskInfoBean(HistoricTaskInstance task) { TaskInfoBean taskInfoBean = new TaskInfoBean(); taskInfoBean.setTaskDefinitionKey(task.getTaskDefinitionKey()); taskInfoBean.setFormKey(task.getFormKey()); taskInfoBean.setProcessDefinitionId(task.getProcessDefinitionId()); taskInfoBean.setProcessInstanceId(task.getProcessInstanceId()); taskInfoBean.setTaskName(task.getName()); taskInfoBean.setTaskId(task.getId()); taskInfoBean.setAssigneeId(task.getAssignee()); taskInfoBean.setTaskCreateTime(task.getCreateTime()); taskInfoBean.setTaskEndTime(task.getEndTime()); taskInfoBean.setTaskOwner(task.getOwner()); HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).includeProcessVariables().singleResult(); taskInfoBean.setItemsName(historicInstance.getProcessDefinitionName()); taskInfoBean.setVariables(historicInstance.getProcessVariables()); return taskInfoBean; }
public HistoricTaskInstanceResponse createHistoricTaskInstanceResponse(HistoricTaskInstance taskInstance, RestUrlBuilder urlBuilder) { HistoricTaskInstanceResponse result = new HistoricTaskInstanceResponse(); result.setAssignee(taskInstance.getAssignee()); result.setClaimTime(taskInstance.getClaimTime()); result.setDeleteReason(taskInstance.getDeleteReason());
assertEquals("admin", hti.getAssignee());