// 禀议撤销 @Transactional public void delete(String taskId) { Task task = taskService.getTask(taskId); Execution execution = executionService.findExecutionById(task.getExecutionId()); if (execution.getProcessInstance().isActive("填写经费报销")) { String wCode = (String) taskService.getVariable(taskId, "wCode"); this.delete(wipeDao.getWipe(wCode)); taskService.completeTask(taskId, "cancel"); } }
// 审核待办任务 @Transactional public Wipe confirm(String taskId, String topJudge, Wipe wipe) { task = taskService.getTask(taskId); execution = executionService.findExecutionById(task.getExecutionId()); if (execution.getProcessInstance().isActive("部门主管审批")) { // 部门主管审批 taskService.completeTask(taskId, "To"); // To二级决裁 } else if (execution.getProcessInstance().isActive("项目经理审批")) { // 项目经理审批 String variable = (String) taskService.getVariable(taskId, "sanJiUser"); if (variable == null || "".equals(variable)) { taskService.completeTask(taskId, "To项目经理不批准"); wipe.setState((short) 1); } else { taskService.completeTask(taskId, "To三级合议"); } } else if (execution.getProcessInstance().isActive("三级合议")) { // 总经理审批的过程 taskService.completeTask(taskId, "To四级合议"); } else if (execution.getProcessInstance().isActive("四级合议")) { // 四级议论 if (topJudge != null) { // if (topJudge.equals("1")) // { Map<String, Object> variables = new HashMap<String, Object>(); variables.put("topUser", topJudge); taskService.setVariables(taskId, variables); taskService.completeTask(taskId, "To最终决裁"); // 这里还要根据经理是否需要老板决裁。 wipe.setTopJudge(topJudge); wipe.setState((short) 1); // } // else if (topJudge.equals("0")) // { // wipe.setState((short) 1); // taskService.completeTask(taskId, "To四级不批准"); // } } else taskService.completeTask(taskId, "To最终决裁"); } else if (execution.getProcessInstance().isActive("最终决裁")) { wipe.setState((short) 1); // 五级审批 taskService.completeTask(taskId, "To流程结束"); } else { taskService.completeTask(taskId); } this.save(wipe); return wipe; }
// 不批准 public void dissent(String taskId) { task = taskService.getTask(taskId); execution = executionService.findExecutionById(task.getExecutionId()); if (execution.getProcessInstance().isActive("部门主管审批")) { // 部门主管不批准 taskService.completeTask(taskId, "To主管不批准"); } else if (execution.getProcessInstance().isActive("项目经理审批")) { // 项目经理不批准 taskService.completeTask(taskId, "To项目经理不批准"); } else if (execution.getProcessInstance().isActive("三级合议")) { // 总经理审批的过程 taskService.completeTask(taskId, "To三级不批准"); } else if (execution.getProcessInstance().isActive("四级合议")) { // 四级议论 taskService.completeTask(taskId, "To四级不批准"); } else if (execution.getProcessInstance().isActive("最终决裁")) { // 五级审批 taskService.completeTask(taskId, "To最终驳回"); } else { taskService.completeTask(taskId); } }
// 驳回 public void reject(String taskId) { task = taskService.getTask(taskId); Set<String> set = taskService.getVariableNames(taskId); map = taskService.getVariables(taskId, set); map.put("reject", task.getAssignee()); // 驳回人 taskService.setVariables(task.getId(), map); execution = executionService.findExecutionById(task.getExecutionId()); if (execution.getProcessInstance().isActive("部门主管审批")) { // 部门主管不批准 taskService.completeTask(taskId, "To主管驳回"); } else if (execution.getProcessInstance().isActive("项目经理审批")) { // 项目经理不批准 taskService.completeTask(taskId, "To项目经理驳回"); } else if (execution.getProcessInstance().isActive("三级合议")) { // 总经理不批准的过程 taskService.completeTask(taskId, "To三级驳回"); } else if (execution.getProcessInstance().isActive("四级合议")) { // 四级议论 taskService.completeTask(taskId, "To四级驳回"); } else if (execution.getProcessInstance().isActive("最终决裁")) { // 五级审批 taskService.completeTask(taskId, "To最终驳回"); } else { taskService.completeTask(taskId); } }
public String getBusinessIdByTaskId(String taskId) { Task task = processEngine.getTaskService().getTask(taskId); Execution execution = processEngine.getExecutionService().findExecutionById(task.getExecutionId()); return execution.getKey(); }
// 添加wipe的方法 @Transactional public Wipe saveWipe(Wipe wipe, List<WipeItem> itemList, List<WipeItemDetail> detailList) { Map<String, Object> variables = new HashMap<String, Object>(); Integer type = wipe.getWType(); // 0部内,1部外。 String yiji = String.valueOf(wipe.getJudgeSet().get(0).getUser().getId()); String erji = String.valueOf(wipe.getJudgeSet().get(1).getUser().getId()); String sanji = null, siji = null, wuji = null; if (type == 1) { if (wipe.getJudgeSet().get(2).getUser() == null) { sanji = null; } else { sanji = String.valueOf(wipe.getJudgeSet().get(2).getUser().getId()); } if (wipe.getJudgeSet().get(3).getUser() == null) { siji = null; } else { siji = String.valueOf(wipe.getJudgeSet().get(3).getUser().getId()); } if (wipe.getJudgeSet().get(4).getUser() == null) { wuji = null; } else { wuji = String.valueOf(wipe.getJudgeSet().get(4).getUser().getId()); } } variables.put("wCode", wipe.getwCode()); // 把禀议编号存储在变量中。 variables.put("deptUser", yiji); variables.put("projUser", erji); variables.put("sanJiUser", sanji); variables.put("manager", siji); variables.put("topUser", wuji); variables.put("fillUser", String.valueOf(ActionUtil.getCurLoginInfo().getId())); executionService.startProcessInstanceByKey("jingfeibaoxiao", variables); taskList = taskService.findPersonalTasks(String.valueOf(ActionUtil.getCurLoginInfo().getId())); task = taskList.get(taskList.size() - 1); taskService.completeTask(task.getId()); execution = executionService.findExecutionById(task.getExecutionId()); wipe.getJudgeSet().get(0).setWipe(wipe); wipe.getJudgeSet().get(1).setWipe(wipe); // 全公司 if (type == 1) { if (wipe.getJudgeSet().get(2) == null) { wipe.getJudgeSet().set(2, null); } else { wipe.getJudgeSet().get(2).setWipe(wipe); } if (wipe.getJudgeSet().get(3) == null) { wipe.getJudgeSet().set(3, null); } else { wipe.getJudgeSet().get(3).setWipe(wipe); } if (wipe.getJudgeSet().get(4) == null) { wipe.getJudgeSet().set(4, null); } else { wipe.getJudgeSet().get(4).setWipe(wipe); } } wipe.setPId(execution.getProcessInstance().getId()); // 获得流程实例ID; this.save(wipe); if (itemList != null && itemList.size() != 0) { for (WipeItem wipeItem : itemList) { wipeItem.setWipe(wipe); if (detailList != null && detailList.size() != 0) { for (WipeItemDetail wipeItemDetail : detailList) { if (wipeItem.getiItem().equals(wipeItemDetail.getWipeItem().getiItem())) { wipeItemDetail.setWipeItem(wipeItem); wipeItemDetailService.save(wipeItemDetail); } } } wipeItemService.save(wipeItem); } } return wipe; }