<?xml version="1.0" encoding="UTF-8"?> <process name="leave" xmlns="http://jbpm.org/4.3/jpdl"> <start g="199,100,48,48" name="start1"> <transition to="申请"/> </start> <task assignee="#{owner}" form="request.jsp" g="178,190,92,52" name="申请"> <transition to="经理审批"/> </task> <task assignee="manager" form="manager.jsp" g="182,322,92,52" name="经理审批"> <transition g="-37,-11" name="批准" to="exclusive1"/> <transition name="驳回" to="申请" g="108,350;106,216:-30,-7"/> </task> <task assignee="boss" form="boss.jsp" g="358,471,92,52" name="老板审批"> <transition g="406,571:-47,-17" name="to end1" to="end1"/> </task> <decision expr="#{day > 3 ? 'to 老板审批' : 'to end1'}" g="208,425,48,48" name="exclusive1"> <transition g="-47,-17" name="to end1" to="end1"/> <transition g="405,448:-71,-17" name="to 老板审批" to="老板审批"/> </decision> <end g="211,549,48,48" name="end1"/> </process>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>登录</title> </head> <body> </body> <form name="loginForm" action="doLogin.jsp" method="post"> <div> 请输入用户名:<input type="text" name="userName" /> <input type="submit" value="登录" /> </div> </form> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.util.*,org.jbpm.api.*,org.jbpm.api.task.*" %> <%@ include file="checkLogin.jsp" %> <% String userName = (String)session.getAttribute("userName"); ProcessEngine processEngine = Configuration.getProcessEngine(); // 创建一个流程引擎 RepositoryService repositoryService = processEngine.getRepositoryService(); // 创建一个流程服务 ExecutionService executionService = processEngine.getExecutionService(); // 实例服务 TaskService taskService = processEngine.getTaskService(); // 任务 List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().list(); // 获取流程列表 List<ProcessInstance> piList = executionService.createProcessInstanceQuery().list(); // 获取实例列表 List<Task> taskList = taskService.findPersonalTasks(userName); %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <link rel="Stylesheet" type="text/css" href="style.css" /> </head> <body> <div> 当前登录用户[<%=userName %>]| <a href="deploy.jsp">发布新流程</a>|<a href="login.jsp">登录</a> </div> <div> <h2>流程列表</h2> <table> <tr> <td>ID</td> <td>Name</td> <td>Version</td> <td>操作</td> </tr> <% for(ProcessDefinition pd : list) { %> <tr> <td><%=pd.getId() %></td> <td><%=pd.getName() %></td> <td><%=pd.getVersion() %></td> <td> <a href="remove.jsp?deploymentId=<%=pd.getDeploymentId() %>">删除</a>| <a href="start.jsp?id=<%=pd.getId() %>">开始</a> </td> </tr> <% } %> </table> <h2>实例列表</h2> <table> <tr> <td>ID</td> <td>活动</td> <td>状态</td> <td>操作</td> </tr> <% for(ProcessInstance pi : piList) { %> <tr> <td><%=pi.getId() %></td> <td><%=pi.findActiveActivityNames() %></td> <td><%=pi.getState() %></td> <td><a href="view.jsp?id=<%=pi.getId() %>">查看</a></td> </tr> <% } %> </table> <h2>任务列表</h2> <table> <tr> <td>ID</td> <td>名称</td> <td>操作</td> </tr> <% for(Task task : taskList) { %> <tr> <td><%=task.getId() %></td> <td><%=task.getName() %></td> <td><a href="<%=task.getFormResourceName() %>?taskId=<%=task.getId() %>">查看</a><br /></td> </tr> <% } %> </table> </div> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.util.*,org.jbpm.api.*"%> <% ProcessEngine processEngine = Configuration.getProcessEngine(); // 创建一个流程引擎 RepositoryService repositoryService = processEngine .getRepositoryService(); // 创建一个流程服务 repositoryService.createDeployment() .addResourceFromClasspath("leave.jpdl.xml").deploy(); // 发布一个流程 response.sendRedirect("index.jsp"); %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.util.*,org.jbpm.api.*,org.jbpm.api.task.*" %> <% String id = request.getParameter("id"); String userName = (String)session.getAttribute("userName"); ProcessEngine processEngine = Configuration.getProcessEngine(); // 创建流程引擎 ExecutionService executionService = processEngine.getExecutionService(); // Map<String, Object> map = new HashMap<String, Object>(); map.put("owner", userName); executionService.startProcessInstanceById(id, map); response.sendRedirect("index.jsp"); %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Request</title> <link rel="Stylesheet" type="text/css" href="style.css" /> </head> <body> <h2>申请</h2> <form action="submit.jsp" method="post"> <input type="hidden" name="taskId" value="${param.taskId }" /> <table> <tr> <td>申请人</td> <td><input type="text" name="owner" value="${sessionScope['userName'] }"/></td> </tr> <tr> <td>请假时间(天)</td> <td><input type="text" name="day" value="" /></td> </tr> <tr> <td>请假原因</td> <td><input type="text" name="reason" value="" /></td> </tr> </table> <input type="submit" value="提交" /> </form> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.util.*,org.jbpm.api.*,org.jbpm.api.task.*" %> <% request.setCharacterEncoding("UTF-8"); ProcessEngine processEngine = Configuration.getProcessEngine(); TaskService taskService = processEngine.getTaskService(); // 接收任务ID String taskId = request.getParameter("taskId"); // 接收用户名 String owner = request.getParameter("owner"); // 接收请假天数 int day = Integer.parseInt(request.getParameter("day")); // 接收请假原因 String reason = request.getParameter("reason"); Map<String, Object> map = new HashMap<String, Object>(); map.put("day", day); map.put("reason", reason); // 执行任务 taskService.completeTask(taskId, map); // 跳转到首页 response.sendRedirect("index.jsp"); %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.util.*,org.jbpm.api.*,org.jbpm.api.task.*" %> <% ProcessEngine processEngine = Configuration.getProcessEngine(); TaskService taskService = processEngine.getTaskService(); String taskId = request.getParameter("taskId"); Task task = taskService.getTask(taskId); // 获取任务 %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Manager</title> <link rel="Stylesheet" type="text/css" href="style.css" /> </head> <body> <h2>经理审核</h2> <form action="submit_manager.jsp" method="post"> <input type="hidden" name="taskId" value="${param.taskId }" /> <table> <tr> <td>申请人</td> <td><%=taskService.getVariable(taskId, "owner") %></td> </tr> <tr> <td>请假时间(天)</td> <td><%=taskService.getVariable(taskId, "day") %></td> </tr> <tr> <td>请假原因</td> <td><%=taskService.getVariable(taskId, "reason") %></td> </tr> </table> <input type="submit" name="result" value="批准" /> <input type="submit" name="result" value="驳回" /> </form> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.util.*,org.jbpm.api.*,org.jbpm.api.task.*" %> <% request.setCharacterEncoding("UTF-8"); ProcessEngine processEngine = Configuration.getProcessEngine(); TaskService taskService = processEngine.getTaskService(); // 接收任务ID String taskId = request.getParameter("taskId"); // 接受命令 String result = request.getParameter("result"); // 执行任务 /* * jbpm会根据传过去的result来判断流程转向哪个task */ taskService.completeTask(taskId, result); // 跳转到首页 response.sendRedirect("index.jsp"); %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.util.*,org.jbpm.api.*,org.jbpm.api.model.*"%> <% String id = request.getParameter("id"); // 获取流程实例ID ProcessEngine processEngine = Configuration.getProcessEngine(); RepositoryService repositoryService = processEngine .getRepositoryService(); ExecutionService executionService = processEngine .getExecutionService(); ProcessInstance processInstance = executionService .findProcessInstanceById(id); // 根据ID获取流程实例 Set<String> activityNames = processInstance .findActiveActivityNames(); // 获取实例执行到的当前节点的名称 ActivityCoordinates ac = repositoryService.getActivityCoordinates( processInstance.getProcessDefinitionId(), activityNames .iterator().next()); %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>View</title> <link rel="Stylesheet" type="text/css" href="style.css" /> </head> <body> <h2>流程图显示</h2> <img src="pic.jsp?id=<%=id%>" style="position: absolute; left: 0px; top: 0px" /> <div style="position:absolute;border:2px solid red;left:<%=ac.getX()%>px;top:<%=ac.getY()%>px;width:<%=ac.getWidth()%>px;height:<%=ac.getHeight()%>px;"></div> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.util.*,org.jbpm.api.*,java.io.*"%> <% String id = request.getParameter("id"); // 获取流程实例ID ProcessEngine processEngine = Configuration.getProcessEngine(); RepositoryService repositoryService = processEngine .getRepositoryService(); ExecutionService executionService = processEngine .getExecutionService(); ProcessInstance processInstance = executionService .findProcessInstanceById(id); // 根据ID获取流程实例 String processDefinitionId = processInstance .getProcessDefinitionId(); ProcessDefinition processDefinition = repositoryService .createProcessDefinitionQuery() .processDefinitionId(processDefinitionId).uniqueResult(); InputStream inputStream = repositoryService.getResourceAsStream( processDefinition.getDeploymentId(), "leave.png"); byte[] b = new byte[1024]; int len = -1; OutputStream ops = response.getOutputStream(); while ((len = inputStream.read(b, 0, 1024)) != -1) { ops.write(b, 0, len); } %>