zoukankan      html  css  js  c++  java
  • Liferay7 BPM门户开发之47: 集成Activiti待办已办任务清单和流程启动

    首先增加两个Portlet,分别用于待办处理、流程启动。待办是别人发起的流程,流到自己这里的流程;流程启动用于发起新的流程。

    程序文件放置于

    在ACtivit中待办概念分两种,1是指派给你的,专门的指派流程节点;2是在候选组中,符合抢签权限的人。在代码中进行了合并:

    package com.lifiti.portlet;
    
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.zip.ZipInputStream;
    import javax.portlet.ActionRequest;
    import javax.portlet.ActionResponse;
    import javax.portlet.Portlet;
    import javax.portlet.PortletException;
    import javax.portlet.RenderRequest;
    import javax.portlet.RenderResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.activiti.engine.repository.DeploymentBuilder;
    import org.activiti.engine.repository.ProcessDefinition;
    import org.activiti.engine.repository.ProcessDefinitionQuery;
    import org.activiti.engine.task.Task;
    import org.osgi.service.component.annotations.Component;
    import com.liferay.portal.kernel.exception.PortalException;
    import com.liferay.portal.kernel.servlet.ServletResponseUtil;
    import com.liferay.portal.kernel.theme.ThemeDisplay;
    import com.liferay.portal.kernel.upload.UploadPortletRequest;
    import com.liferay.portal.kernel.util.ParamUtil;
    import com.liferay.portal.kernel.util.PortalUtil;
    import com.liferay.portal.kernel.util.WebKeys;
    import com.lifiti.model.ToDo;
    import com.lifiti.util.ActivitiUtils;
    import com.lifiti.util.FilenameUtils;
    import com.lifiti.util.IdentifyHelper;
    import com.lifiti.util.ProcessHelper;
    
    @Component(immediate = true, property = { "com.liferay.portlet.display-category=category.sample",
            "com.liferay.portlet.instanceable=true", "javax.portlet.display-name=Process ToDo",
            "javax.portlet.init-param.template-path=/", "javax.portlet.init-param.view-template=/process/processToDo.jsp",
            "javax.portlet.resource-bundle=content.Language",
            "javax.portlet.security-role-ref=power-user,user" }, service = Portlet.class)
    
    public class ProcessToDoPortlet extends BpmBasePortlet {
        @Override
        public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException {
    
            ThemeDisplay td =(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
            String candidateUser= td.getUser().getEmailAddress(); //IdentifyHelper.getUserFromSession(session).getId();
            System.out.println("candidateUser:"+candidateUser);
            try {
                System.out.println("getLogin:"+td.getUser().getLogin());
            } catch (PortalException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println("getUserId:"+td.getUser().getUserId());
            System.out.println("getUserUuid:"+td.getUser().getUserUuid());
            System.out.println("getScreenName:"+td.getUser().getScreenName());
            // 执行查询
            List<Task> tasksCandidate = taskService.createTaskQuery()
                    .taskCandidateUser(candidateUser)
                    .orderByTaskCreateTime().desc().list();
            List<Task> tasksAssignee = taskService.createTaskQuery()
                    .taskAssignee(candidateUser)
                    .orderByTaskCreateTime().desc().list();
            
            List<ToDo> todoList = new ArrayList<ToDo>();
    
            //指定签收人
            for (Task task : tasksAssignee){
                ProcessDefinition pd = ProcessHelper.findProcessDefinitionByPid(task.getProcessInstanceId());
                todoList.add(new ToDo(task.getId(),task.getName(),task.getCreateTime().toString(),task.getExecutionId(),
                        task.getProcessInstanceId(),task.getTaskDefinitionKey(),task.getProcessDefinitionId(),pd.getName(),
                        pd.getKey()));
            }
            //符合候选人名单的抢签权限的人
            for (Task task : tasksCandidate){
                ProcessDefinition pd = ProcessHelper.findProcessDefinitionByPid(task.getProcessInstanceId());
                todoList.add(new ToDo(task.getId(),task.getName(),task.getCreateTime().toString(),task.getExecutionId(),
                        task.getProcessInstanceId(),task.getTaskDefinitionKey(),task.getProcessDefinitionId(),pd.getName(),
                        pd.getKey()));
            }
            request.setAttribute("tasks", todoList);
    
        }
    
    }

    jsp页面

    <%@ include file="/init.jsp" %>
    
    <h2><liferay-ui:message key="Todo"/></h2>
    
    <table width="100%" class="table table-bordered table-hover table-condensed">
            <thead>
                <tr>
                    <th><liferay-ui:message key="ProcessInstanceId"/></th>
                    <th><liferay-ui:message key="ProcessName"/></th>
                    <th><liferay-ui:message key="NodeNow"/></th>
                    <th><liferay-ui:message key="CreateTime"/></th>
                    <th width="80"><liferay-ui:message key="Operation"/></th>
                </tr>
            </thead>
            <tbody>
                <c:forEach items="${tasks }" var="ta">
                    <tr>
                        <td>${ta.processInstanceId }</td>
                        <td>${ta.processName }</td>
                        <td>${ta.name }</td>
                        <td>${ta.createTime }</td>
                        <td><a target="_blank" href='${ctx }/process/taskTodo?key=${ta.processKey }&procInstId=${ta.processInstanceId }&taskId=${ta.id }&activityId=${ta.taskDefinitionKey }'></a><liferay-ui:message key="Sign"/></td>
                        
                    </tr>
                </c:forEach>
            </tbody>
        </table>
        

    这部分的任务完成了一半,还要处理2个逻辑

    1、签收待办任务的“签收”处理;

    2、发起流程的“启动”处理;

    接下来解决。

  • 相关阅读:
    一、CentOS 7安装部署GitLab服务器

    四、指定Nginx启动用户
    三、Nginx支持php
    二、Nginx多站点配置(参考宝塔的)分析
    一、Nginx多站点配置
    一、PHP和Apache实现多用户自助建站
    Flask+uwsgi+Nginx+Ubuntu部署
    flask 上传头像
    flask 分页
  • 原文地址:https://www.cnblogs.com/starcrm/p/6201283.html
Copyright © 2011-2022 走看看