• Activiti7开发(四)-我的待办


    1. 查询登录用户的待办任务

    private List<Task> queryMyTasks(){
    	String username = SecurityUtils.getUsername();
    	String roles = String.join(",", tokenService.getLoginUser().getRoles());
    	//待办
    	List<String> assignedTaskIds = taskService.createTaskQuery()
    			.taskAssignee(username)
    		  //  .taskCandidateOrAssigned(username)
    			.list().stream().map(TaskInfo::getId).collect(Collectors.toList());
    	//待签收
    	List<String> waitClaimTaskIdsByCandidateUser =  actRuIdentityLinkMapper.queryTaskIdsByCandidateUser(username);
    	List<String> waitClaimTaskIdsByCandidateGroup =  actRuIdentityLinkMapper.queryTaskIdsByCandidateGroup(roles);
    	//待签收任务合并去重
    	waitClaimTaskIdsByCandidateUser.removeAll(waitClaimTaskIdsByCandidateGroup);
    	waitClaimTaskIdsByCandidateUser.addAll(waitClaimTaskIdsByCandidateGroup);
    
    
    	//待办、待签收合并去重
    	assignedTaskIds.removeAll(waitClaimTaskIdsByCandidateUser);
    	assignedTaskIds.addAll(waitClaimTaskIdsByCandidateUser);
    
    	return assignedTaskIds.stream().map(taskId -> taskService.createTaskQuery().taskId(taskId).singleResult()).collect(Collectors.toList());
    }
    

    2.审批

    注:查询待办任务时并没有使当前用户进行任务拾取,而是等他办理审批时确定拾取人是当前用户

    如果是申请用户调整申请,则允许修改实体类+审批(对于申请用户并没有审批的功能,只是判断他是否继续申请还是取消申请)。如果是继续申请,则点击同意并修改实体类;取消申请则没必要对实体类进行修改了

    public AjaxResult formDataSave(@PathVariable("taskID") String taskID,
                                       @RequestBody   List<ActWorkflowFormDataDTO> formData ) throws ParseException {
    	return toAjax(actTaskService.formDataSave(taskID, formData));
    }
    
    public int formDataSave(String taskID, List<ActWorkflowFormDataDTO> awfs) throws ParseException {
    //        Task task = taskRuntime.task(taskID);
    	Task task = taskService.createTaskQuery().taskId(taskID).singleResult();
    	ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
    
    	Boolean hasVariables = false;//没有任何参数
    	HashMap<String, Object> variables = new HashMap<String, Object>();
    	//前端传来的字符串,拆分成每个控件
    	List<ActWorkflowFormData> acwfds = new ArrayList<>();
    	for (ActWorkflowFormDataDTO awf : awfs) {
    		ActWorkflowFormData actWorkflowFormData = new ActWorkflowFormData(processInstance.getBusinessKey(),awf, task);
    		acwfds.add(actWorkflowFormData);
    		//构建参数集合
    		if(!"f".equals(awf.getControlIsParam())) {
    				variables.put(awf.getControlId(), awf.getControlValue());
    				hasVariables = true;
    		}
    	}
    	if (task.getAssignee() == null) {
    //            taskService.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());
    		//拾取任务
    		taskService.claim(task.getId(),SecurityUtils.getUsername());
    	}
    	if (hasVariables) {
    		//带参数完成任务
      /*      taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskID)
    				.withVariables(variables)
    				.build());*/
    		taskService.complete(taskID,variables);
    	} else {
    	   /* taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskID)
    				.build());*/
    		taskService.complete(taskID);
    	}
    	//
    
    	//写入数据库 这张表是自己设计的,在查看历史任务是会用到
    	return actWorkflowFormDataService.insertActWorkflowFormDatas(acwfds);
    }
    
  • 相关阅读:
    [置顶] 某大型银行深化系统技术方案之一:实现技术定义
    android代码实现关机
    一个IP每天只弹一次广告窗口
    bootstrap框架开发电子商城案例
    HDU 1203 I NEED A OFFER!(dp)
    STL algorithmi算法s_sorted和is_sorted_until(28)
    计数排序(C语言版本)
    4.事务提交过程,交易的基本概念,Oracle交易周期,保存点savepoint,数据库的隔离级别
    《python源代码分析》笔记 pythonVM一般表达式
    ASP.NET——两个下拉框来实现动态联动
  • 原文地址:https://www.cnblogs.com/lhxBlogs/p/15091877.html
Copyright © 2020-2023  润新知