久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

jbpm 4.4 簡單流程示例

 懷舊妞妞 2010-11-04
1、流程定義內(nèi)容為:
<?xml version="1.0" encoding="UTF-8"?>
<process name="leave" xmlns="http:///4.3/jpdl">
   <start g="196,25,48,48" name="start1">
      <transition to="申請"/>
   </start>
   <task form="qhrequest.jsp" g="172,118,92,52" name="申請" candidate-groups="#{dev}">
//*****candidate-groups="#{dev}" 采用JBPM用戶組進行處理任務
//*****assignee="manager" 采用指定manager用戶進行處理任務
      <transition to="經(jīng)理審批"/>
   </task>
   <task assignee="manager" form="qhmanager.jsp" g="175,217,92,52" name="經(jīng)理審批">
      <transition g="-32,-8" name="批準" to="exclusive1"/>
      <transition g="128,221;124,165:-42,-18" name="駁回" to="申請"/>
   </task>
   <decision expr="#{day > 3 ? '老板審批' : '結(jié)束'}" g="200,308,48,48" name="exclusive1">
      <transition g="-39,-10" name="結(jié)束" to="end1"/>
      <transition g="339,342:-71,-17" name="老板審批" to="老板審批"/>
   </decision>
   <task assignee="boss" form="qhboss.jsp" g="294,375,92,52" name="老板審批">
      <transition g="339,457:" to="end1"/>
   </task>
   <end g="199,445,48,48" name="end1"/>
</process>
2、qhlogin.jsp:
HttpSession session = request.getSession();
session.setAttribute("username", request.getParameter("username"));
response.sendRedirect("qhindex.jsp");
登錄頁面,,驗證用戶登錄,,登錄成功返回qhindex.jsp
3、qhindex.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@page import="java.util.*,org.jbpm.api.*,org.jbpm.api.task.*" %>
<%
ProcessEngine processEngine = Configuration.getProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
ExecutionService executionService = processEngine.getExecutionService();
TaskService taskService = processEngine.getTaskService();
String username = (String) session.getAttribute("username");
List<ProcessDefinition> pdList = repositoryService.createProcessDefinitionQuery().list();
List<ProcessInstance> piList = executionService.createProcessInstanceQuery().list();
//***指對指定用戶處理任務列表
List<Task> taskList = taskService.findPersonalTasks(username);
//***指對指定用戶組處理任務列表
List<Task> groupTaskList = taskService.findGroupTasks(username);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www./TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>index</title>
  </head>
  <body>
    <a href="qhdeploy.jsp">發(fā)布新流程</a> [username: <%=username %>]<a href="qhlogin.jsp">登陸</a>

    <table border="1" width="100%">
      <caption>流程定義</caption>
      <thead>
        <tr>
          <td>id</td>
          <td>name</td>
          <td>version</td>
          <td> </td>
        </tr>
      </thead>
      <tbody>
<%
 for (ProcessDefinition pd : pdList) {
%>
     <tr>
       <td><%=pd.getId() %></td>
       <td><%=pd.getName() %></td>
       <td><%=pd.getVersion() %></td>
       <td>
         <a href="qhremove.jsp?id=<%=pd.getDeploymentId() %>">remove</a>
          | 
         <a href="qhstart.jsp?id=<%=pd.getId() %>">start</a>
       </td>
     </tr>
<%
 }
%>
   </tbody>
 </table>

    <table border="1" width="100%">
      <caption>流程實例</caption>
      <thead>
        <tr>
          <td>id</td>
          <td>activity</td>
          <td>state</td>
          <td> </td>
        </tr>
      </thead>
      <tbody>
<%
 for (ProcessInstance pi : piList) {
%>
     <tr>
       <td><%=pi.getId() %></td>
       <td><%=pi.findActiveActivityNames() %></td>
       <td><%=pi.getState() %></td>
       <td><a href="qhview.jsp?id=<%=pi.getId() %>">view</a></td>
     </tr>
<%
 }
%>
   </tbody>
 </table>

    <table border="1" width="100%">
      <caption>待辦任務</caption>
      <thead>
        <tr>
          <td>id</td>
          <td>name</td>
          <td> </td>
        </tr>
      </thead>
      <tbody>
<%
 for (Task task : taskList) {
%>
     <tr>
       <td><%=task.getId() %></td>
       <td><%=task.getName() %></td>
       <td><a href="<%=task.getFormResourceName() %>?id=<%=task.getId() %>">view</a></td>
     </tr>
<%
 }
%>
   </tbody>
 </table>
  </body>
</html>
3-1,、qhdeploy.jsp:發(fā)布新流程
<%@page import="java.util.*,org.jbpm.api.*,java.util.zip.*"%>
<%
 ProcessEngine processEngine = Configuration.getProcessEngine();
 RepositoryService repositoryService = processEngine
   .getRepositoryService();

 //repositoryService.createDeployment().addResourceFromClasspath("leave.jpdl.xml").deploy();
 ZipInputStream zis = new ZipInputStream(this.getClass()
   .getResourceAsStream("/leave.zip"));
 repositoryService.createDeployment()
   .addResourcesFromZipInputStream(zis).deploy();
 response.sendRedirect("qhindex.jsp");
%>
3-2,、qhstart.jsp:開始啟動流程
<%@page import="java.util.*,org.jbpm.api.*,java.util.*"%>
<%
 ProcessEngine processEngine = Configuration.getProcessEngine();
 ExecutionService executionService = processEngine
   .getExecutionService();
//***********對指定用戶進行啟動流程
 Map map = new HashMap();
 map.put("owner", session.getAttribute("username"));

//***********用JPBM用戶組啟動流程
 Map map = new HashMap();
 IdentityService identityService = processEngine.getIdentityService();
 identityService.createGroup("dev");
 identityService.createUser("user1", "user1", "user1");
 identityService.createUser("user2", "user2", "user2");
 identityService.createMembership("user1", "dev");
 identityService.createMembership("user2", "dev");
 map.put("dev",identityService.findGroupById("dev").getId());
 executionService.startProcessInstanceById(request
   .getParameter("id"), map);
 response.sendRedirect("qhindex.jsp");
%>
3-3、qhview.jsp查看流程視圖執(zhí)行節(jié)點:
3-3-1qhview.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="org.jbpm.api.*,java.util.*,org.jbpm.api.model.*" %>
<%
 String id = request.getParameter("id");
 ProcessEngine processEngine = Configuration.getProcessEngine();
 RepositoryService repositoryService = processEngine.getRepositoryService();
 ExecutionService executionService = processEngine.getExecutionService();
 ProcessInstance processInstance = executionService.findProcessInstanceById(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./TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<img src="qhpic.jsp?id=<%=id %>" style="position:absolute;left:0px;top:0px;">
<div style="position:absolute;border:1px solid red;left:<%=ac.getX()%>px;top:<%=ac.getY()%>px;width:<%=ac.getWidth()%>px;height:<%=ac.getHeight()%>px;"></div>
</body>
</html>
3-3-2,、qhpic.jsp 畫出流程圖
<%@page import="org.jbpm.api.*,java.io.*"%>
<%
 ProcessEngine processEngine = Configuration.getProcessEngine();
 RepositoryService repositoryService = processEngine
   .getRepositoryService();
 ExecutionService executionService = processEngine
   .getExecutionService();
 String id = request.getParameter("id");
 ProcessInstance processInstance = executionService
   .findProcessInstanceById(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;
 while ((len = inputStream.read(b, 0, 1024)) != -1) {
  response.getOutputStream().write(b, 0, len);
 }
%>
3-4,、進入表單處理任務<a href="<%=task.getFormResourceName() %>?id=<%=task.getId() %>">view</a>
表單定義:
leave.jpdl.xml
   <task form="qhrequest.jsp" g="172,118,92,52" name="申請" candidate-groups="#{dev}"http://指定用戶組辦理任務 ||assignee="manager" //指定用戶辦理任務>
    <transition to="經(jīng)理審批"/>
   </task>
------------------------------------------------
qhrequest.jsp:
  <fieldset>
    <legend>申請</legend>
    <form action="qhsubmit.jsp" method="post">
      <input type="hidden" name="taskId" value="${param.id}">
       申請人:<input type="text" name="owner" value="${sessionScope['username']}"/><br/>
   請假時間:<input type="text" name="day" value=""/><br/>
     請假原因:<textarea name="reason"></textarea><br/>
    <input type="submit"/>
    </form>
  </fieldset>

3-5、qhsubmit.jsp處理表單任務:
<%@page import="java.util.*,org.jbpm.api.*"%>
<%
 ProcessEngine processEngine = Configuration.getProcessEngine();
 TaskService taskService = processEngine.getTaskService();

 String taskId = request.getParameter("taskId");
 String owner = request.getParameter("owner");
 int day = Integer.parseInt(request.getParameter("day"));
 String reason = request.getParameter("reason");
 Map map = new HashMap();
 map.put("day", day);
 map.put("reason", reason);
 taskService.completeTask(taskId, map);
 response.sendRedirect("qhindex.jsp");
%>

 4,、經(jīng)理對請假進行審批:
index.jsp---進入表單處理任務<a href="<%=task.getFormResourceName() %>?id=<%=task.getId() %>">view</a>
---------------------------------------
manager.jsp
<%
 ProcessEngine processEngine = Configuration.getProcessEngine();
 TaskService taskService = processEngine.getTaskService();
 String taskId = request.getParameter("id");
 Task task = taskService.getTask(taskId);
%>
<body>
  <fieldset>
    <legend>經(jīng)理審核</legend>
    <form action="qhsubmit_manager.jsp" method="post">
      <input type="hidden" name="taskId" value="${param.id}">
      申請人:<%=taskService.getVariable(taskId, "owner") %><br/>
  請假時間:<%=taskService.getVariable(taskId, "day") %><br/>
    請假原因:<%=taskService.getVariable(taskId, "reason") %><br/>
    <input name="result" type="submit" value="批準"/><input name="result" type="submit" value="駁回"/>
    </form>
  </fieldset>
----------------------------------------------
qhsubmit_manager.jsp  處理經(jīng)理審批結(jié)果
<%@page contentType="text/html;charset=UTF-8" %>
<%@page import="java.util.*,org.jbpm.api.*"%>
<%
 ProcessEngine processEngine = Configuration.getProcessEngine();
 TaskService taskService = processEngine.getTaskService();
 String taskId = request.getParameter("taskId");
 String result = request.getParameter("result");
 result = new String(result.getBytes("ISO-8859-1"), "UTF-8");
 taskService.completeTask(taskId, result);
 response.sendRedirect("qhindex.jsp");
%>
5,、老板對請假天數(shù)大于三天的流程進行審批:
index.jsp---進入表單處理任務<a href="<%=task.getFormResourceName() %>?id=<%=task.getId() %>">view</a>
--------------------------------------------------
<%@page import="org.jbpm.api.*,org.jbpm.api.task.*" %>   
<%
 ProcessEngine processEngine = Configuration.getProcessEngine();
 TaskService taskService = processEngine.getTaskService();
 String taskId = request.getParameter("id");
 Task task = taskService.getTask(taskId);
%>
<fieldset>
    <legend>老板審核</legend>
    <form action="qhsubmit_boss.jsp" method="post">
      <input type="hidden" name="taskId" value="${param.id}">
      申請人:<%=taskService.getVariable(taskId, "owner") %><br/>
  請假時間:<%=taskService.getVariable(taskId, "day") %><br/>
    請假原因:<%=taskService.getVariable(taskId, "reason") %><br/>
    <input type="submit" value="批準"/>
    </form>
  </fieldset>
----------------------------------------------
<%@page import="java.util.*,org.jbpm.api.*"%>
<%
 ProcessEngine processEngine = Configuration.getProcessEngine();
 TaskService taskService = processEngine.getTaskService();
 String taskId = request.getParameter("taskId");
 taskService.completeTask(taskId);
 response.sendRedirect("qhindex.jsp");
%>
 
 
 
 
 
 
 
 
 
 
 
 

 

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點,。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,,謹防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報,。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多