osworkflow example之请假

来源:互联网 发布:网络应用软件 编辑:程序博客网 时间:2024/04/30 05:04
业务用例描述 
核心工作流: 
1、员工填写请假申请单,包括“请假原因”和“请假天数”,填写后进行提交; 
2、部门主管对员工请假申请进行审批,同意员工请假; 
3、人力资源主管对员工请假申请进行审批,同意员工请假; 
4、系统发送邮件通知员工请假申请已获得批准; 

5、用例结束;

工作流定义文件说明 
依据本业务需求的工作流定义文件如下 
定义中包括6个step 

step1是员工请假申请的步骤,本步骤的action在执行时将回调业务方法类ApplyFunction,将申请单数据插入到数据库中,同时处理结果将根据请假申请天数dayCount进行判断,如果请假申请天数大于3天,将跳到step2让部门主管审批,如果不大于3天,将直接跳到step3让人力资源主管审批; 

step2 是部门主管审批,如果审批同意(opinion!=2)将跳到step3再由人力资源主管审批,如果审批不同意(opinion==2)将跳到step5自动发“申请未批准”邮件通知步骤; 

step3 是人力资源主管审批,如果审批同意(opinion!=2)将跳到step4自动发“申请批准”邮件通知步骤,如果审批不同意(opinion==2)将跳到step5自动发“申请未批准”邮件通知步骤; 

step4和step5都是自动发送邮件通知步骤,执行完之后跳到空步骤step6结束该工作流实例。 

工作流定义文件 

Java代码  收藏代码
  1. <?xml version="1.0" encoding="GBK"?>  
  2. <!DOCTYPE workflow PUBLIC "-//OpenSymphony Group//DTD OSWorkflow 2.6//EN" "http://www.opensymphony.com/osworkflow/workflow_2_8.dtd">  
  3. <workflow>  
  4.     <initial-actions>  
  5.         <action id="100" name="启动请假申请工作流">  
  6.             <results>  
  7.                 <unconditional-result old-status="Finished" status="Underway" step="1"/>  
  8.             </results>  
  9.         </action>  
  10.     </initial-actions>  
  11.     <steps>  
  12.         <step id="1" name="请假申请">  
  13.             <actions>  
  14.                 <action id="1" name="提交需求申请">  
  15.                     <restrict-to>  
  16.                         <conditions type="AND">  
  17.                             <condition type="class">  
  18.                                 <arg name="class.name">com.opensymphony.workflow.util.OSUserGroupCondition</arg>  
  19.                                 <arg name="group">employee</arg>  
  20.                             </condition>  
  21.                         </conditions>  
  22.                     </restrict-to>  
  23.                     <pre-functions>  
  24.                         <function type="class">  
  25.                             <arg name="class.name">com.qiny.leave.ApplyFunction</arg>  
  26.                         </function>  
  27.                     </pre-functions>  
  28.                     <results>  
  29.                         <result old-status="Finished" status="Underway" step="2" owner="manager1">  
  30.                             <conditions type="AND">  
  31.                                 <condition type="beanshell">  
  32.                                     <arg name="script">  
  33.                                     propertySet.getInt("dayCount")>3  
  34.                                     </arg>  
  35.                                 </condition>  
  36.                             </conditions>  
  37.                             <post-functions>  
  38.                                 <function type="beanshell">  
  39.                                     <arg name="script">  
  40.                                         System.out.println("步骤 1 提交需求申请 满足条件结果 需部门经理审批...");  
  41.                                     </arg>  
  42.                                 </function>  
  43.                             </post-functions>  
  44.                         </result>  
  45.                         <unconditional-result old-status="Finished" status="Underway" step="3" owner="hr1"/>  
  46.                     </results>  
  47.                 </action>  
  48.             </actions>  
  49.         </step>  
  50.         <step id="2" name="请假申请审核">  
  51.             <actions>  
  52.                 <action id="2" name="部门主管审批请假申请">  
  53.                     <restrict-to>  
  54.                         <conditions type="AND">  
  55.                             <condition type="beanshell">  
  56.                                 <arg name="script">true</arg>  
  57.                             </condition>  
  58.                             <condition type="class">  
  59.                                 <arg name="class.name">com.opensymphony.workflow.util.StatusCondition</arg>  
  60.                                 <arg name="status">Underway</arg>  
  61.                             </condition>  
  62.                             <condition type="class">  
  63.                                 <arg name="class.name">com.opensymphony.workflow.util.OSUserGroupCondition</arg>  
  64.                                 <arg name="group">manager</arg>  
  65.                             </condition>  
  66.                         </conditions>  
  67.                     </restrict-to>  
  68.                     <pre-functions>  
  69.                         <function type="class">  
  70.                             <arg name="class.name">com.qiny.leave.ApproveFunction</arg>  
  71.                         </function>  
  72.                     </pre-functions>  
  73.                     <results>  
  74.                         <result old-status="Finished" status="Underway" step="5">  
  75.                             <conditions type="AND">  
  76.                                 <condition type="beanshell">  
  77.                                     <arg name="script">  
  78.                                     propertySet.getInt("opinion")==2  
  79.                                     </arg>  
  80.                                 </condition>  
  81.                             </conditions>  
  82.                             <post-functions>  
  83.                                 <function type="beanshell">  
  84.                                     <arg name="script">  
  85.                                         System.out.println("步骤 2 请假申请审核 部门经理审批没有通过 ...");  
  86.                                     </arg>  
  87.                                 </function>  
  88.                             </post-functions>  
  89.                         </result>  
  90.                         <unconditional-result old-status="Finished" status="Underway" step="3" owner="hr1"/>  
  91.                     </results>  
  92.                 </action>  
  93.             </actions>  
  94.         </step>  
  95.         <step id="3" name="请假申请审核">  
  96.             <actions>  
  97.                 <action id="3" name="人力资源主管审批请假申请">  
  98.                     <pre-functions>  
  99.                         <function type="class">  
  100.                             <arg name="class.name">com.qiny.leave.ApproveFunction</arg>  
  101.                         </function>  
  102.                     </pre-functions>  
  103.                     <results>  
  104.                         <result old-status="Finished" status="Underway" step="5">  
  105.                             <conditions type="AND">  
  106.                                 <condition type="beanshell">  
  107.                                     <arg name="script">  
  108.                                     propertySet.getInt("opinion")==2  
  109.                                     </arg>  
  110.                                 </condition>  
  111.                             </conditions>  
  112.                         </result>  
  113.                         <unconditional-result old-status="Finished" status="Underway" step="5"/>  
  114.                     </results>  
  115.                 </action>  
  116.             </actions>  
  117.         </step>  
  118.         <step id="4" name="请假申请结果通知">  
  119.             <actions>  
  120.                 <action id="4" auto="true" name="请假申请获准邮件通知">  
  121.                     <pre-functions>  
  122.                         <function type="beanshell">  
  123.                             <arg name="script">  
  124.                                 System.out.println("步骤 4 自动动作 请假申请获准邮件通知 Send mail 祝贺你$$$$$$$");  
  125.                             </arg>  
  126.                         </function>  
  127.                     </pre-functions>  
  128.                     <results>  
  129.                         <unconditional-result old-status="Finished" status="Finished" step="6"/>  
  130.                     </results>  
  131.                 </action>  
  132.             </actions>  
  133.         </step>  
  134.         <step id="5" name="请假申请结果通知">  
  135.             <actions>  
  136.                 <action id="5" auto="true" name="请假申请没能获准邮件通知">  
  137.                     <pre-functions>  
  138.                         <function type="beanshell">  
  139.                             <arg name="script">  
  140.                                 System.out.println("步骤 5 自动动作 请假申请没能获准邮件通知 Send mail 很抱歉$$$$$$$");  
  141.                             </arg>  
  142.                         </function>  
  143.                     </pre-functions>  
  144.                     <results>  
  145.                         <unconditional-result old-status="Finished" status="Finished" step="6"/>  
  146.                     </results>  
  147.                 </action>  
  148.             </actions>  
  149.         </step>  
  150.         <step id="6" name="flow over">  
  151.         </step>  
  152.     </steps>  
  153. </workflow>  


转:http://www.iteye.com/topic/100499

原创粉丝点击