论坛首页 Ruby版 ruby

写了一个简单的工作流引擎

浏览 8737 次
该帖已经被评为良好帖
作者 正文
时间:2008-06-23
Godlikeme 写道

写的太粗糙,?Action定义怎么配置的?

 

一开始粗糙是难免的,Action定义在workflow——>steps——>actions中。在这里是用YAML描述的。

Action前后可以接受一段RUBY脚本,在before-action和after-action中定义。

 

下面再给出一个国土的案件查处流程:

 

workflow:
  init-actions:
    1:
      name: 开始
      results:
        -
          step: 1
          status: 受理
          owner: @wf_params['caller']+':案件受理人'
  steps:
    1:
      name: 受理
      actions:
        1:
          name: 修改
          condition: curr_instance_step(1).status=='受理'
          params:
            action-name: edit
          results:
            -
              step: 1
              status: 受理
              owner: @wf_params['caller']+':案件受理人'
        2:
          name: 删除
          condition: curr_instance_step(1).status=='受理'
          params:
            action-name: destroy
          results:
            -
              step: 1
              status: 受理
              owner: @wf_params['caller']+':案件受理人'
        3:
          name: 移交立案
          condition: curr_instance_step(1).status=='受理'
          params:
            action-name: comm_work
            doc-template: doc06
          results:
            -
              step: 2
              status: 立案
              owner: @wf_params['caller']+':案件立案人'
        4:
          name: 当场处罚
          condition: curr_instance_step(1).status=='受理'
          params:
            action-name: comm_work
            doc-template: doc05
          results:
            -
              step: 60
              status: 当场
              owner: @wf_params['caller']+':案件办理人'
    2:
      name: 立案
      actions:
        1:
          name: 立案窗口
          condition: curr_instance_step(2).status=='立案'
          params:
            action-name: edit_document
          results:
            -
              step: 2
              status: 立案
              owner: @wf_params['caller']+':案件立案人'
        2:
          name: 移交调查
          condition: curr_instance_step(2).status=='立案'
          params:
            action-name: comm_work
            doc-template: doc07 doc08 doc10 doc11 doc09 doc12
          results:
            -
              step: 3
              status: 调查
              owner: @wf_params['caller']+':案件调查人'
    3:
      name: 调查
      actions:
        1:
          name: 调查窗口
          condition: curr_instance_step(3).status=='调查'
          params:
            action-name: edit_document
          results:
            -
              step: 3
              status: 调查
              owner: @wf_params['caller']+':案件调查人'
        2:
          name: 移交审理
          condition: curr_instance_step(3).status=='调查'
          params:
            action-name: comm_work
            doc-template: doc13 doc14 doc15
          results:
            -
              step: 4
              status: 审理
              owner: @wf_params['caller']+':案件办理人'
    4:
      name: 审理
      actions:
        1:
          name: 审理窗口
          condition: curr_instance_step(4).status=='审理'
          params:
            action-name: edit_document
          results:
            -
              step: 4
              status: 审理
              owner: @wf_params['caller']+':案件办理人'
        2:
          name: 不予行政处罚
          condition: curr_instance_step(4).status=='审理'
          params:
            action-name: comm_work
            doc-template: doc16 doc27
          results:
            -
              step: 33
              status: 结案
              owner: @wf_params['caller']+':案件办理人'
        3:
          name: 处罚告知
          condition: curr_instance_step(4).status=='审理'
          params:
            action-name: comm_work
            doc-template: doc19
          results:
            -
              step: 30
              status: 告知
              owner: @wf_params['caller']+':案件办理人'
        4:
          name: 撤案
          condition: curr_instance_step(4).status=='审理'
          params:
            action-name: comm_work
            doc-template: doc17
          results:
            -
              step: 40
              status: 撤案
              owner: @wf_params['caller']+':案件办理人'
    30:
      name: 告知
      actions:
        1:
          name: 告知窗口
          condition: curr_instance_step(30).status=='告知'
          params:
            action-name: edit_document
          results:
            -
              step: 30
              status: 告知
              owner: @wf_params['caller']+':案件办理人'
        2:
          name: 移交处罚决定
          condition: curr_instance_step(30).status=='告知'
          params:
            action-name: comm_work
            doc-template: doc23 doc24
          results:
            -
              step: 31
              status: 处罚
              owner: @wf_params['caller']+':案件办理人'
    31:
      name: 处罚
      actions:
        1:
          name: 处罚决定窗口
          condition: curr_instance_step(31).status=='处罚'
          params:
            action-name: edit_document
          results:
            -
              step: 31
              status: 处罚
              owner: @wf_params['caller']+':案件办理人'
        2:
          name: 移交执行
          condition: curr_instance_step(31).status=='处罚'
          params:
            action-name: comm_work
            doc-template: doc25 doc26
          results:
            -
              step: 32
              status: 执行
              owner: @wf_params['caller']+':案件办理人'
    32:
      name: 执行
      actions:
        1:
          name: 执行窗口
          condition: curr_instance_step(32).status=='执行'
          params:
            action-name: edit_document
          results:
            -
              step: 32
              status: 执行
              owner: @wf_params['caller']+':案件办理人'
        2:
          name: 移交结案
          condition: curr_instance_step(32).status=='执行'
          params:
            action-name: comm_work
            doc-template: doc27
          results:
            -
              step: 33
              status: 结案
              owner: @wf_params['caller']+':案件办理人'
    33:
      name: 结案
      actions:
        1:
          name: 结案窗口
          condition: curr_instance_step(33).status=='结案'
          params:
            action-name: edit_document
          results:
            -
              step: 33
              status: 结案
              owner: @wf_params['caller']+':案件办理人'
        2:
          name: 完成
          condition: curr_instance_step(33).status=='结案'
          params:
            action-name: comm_work
            doc-template: 
          results:
            -
              step: 90
              status: 结案
              owner: @wf_params['caller']+':案件办理人'
    40:
      name: 撤案
      actions:
        1:
          name: 撤案窗口
          condition: curr_instance_step(40).status=='撤案'
          params:
            action-name: edit_document
          results:
            -
              step: 40
              status: 撤案
              owner: @wf_params['caller']+':案件办理人'
        2:
          name: 完成
          condition: curr_instance_step(40).status=='撤案'
          params:
            action-name: comm_work
            doc-template: 
          results:
            -
              step: 90
              status: 撤案
              owner: @wf_params['caller']+':案件办理人'
    60:
      name: 当场
      actions:
        1:
          name: 当场处罚窗口
          condition: curr_instance_step(60).status=='当场'
          params:
            action-name: edit_document
          results:
            -
              step: 60
              status: 当场
              owner: @wf_params['caller']+':案件办理人'
        2:
          name: 移交执行
          condition: curr_instance_step(60).status=='当场'
          params:
            action-name: comm_work
            doc-template: doc25 doc26
          results:
            -
              step: 32
              status: 执行
              owner: @wf_params['caller']+':案件办理人'
    90:
      name: 完成
      actions:
        1:
          name: 完成处理
          auto: true
          after-action: |
            law_case = LawCase.find_by_wf_instance_id @wf_instance.id
            if law_case
              law_case.wf_instance_id = nil
              law_case.status = '完成'
              law_case.save!
            end
            @wf_instance.destroy
          results:
            -
              step: 90
              status: 完成
 
   
0 请登录后投票
时间:2008-06-23
fuwang 写道
ltian 写道

Form设计,也就是说工作单的开发吧,谁会用一个专用Form设计工具去开发工作单呢?更多的程序员还是用eclipse,vs等通用的开发工具开工作单。

现在有些工作流产品带表单设计的,自定义表单+自定义流程,这是一大卖点。

说实话,这样的卖点卖给最终用户开发简单的工作单和工作流程似乎还可以,对于软件开发公司来说,这个功能等于画蛇添足。自定义流程核自定义工作单是一个天大的谎言。客户增加工作环节只要稍微改变一点业务逻辑,就需要用代码来完成,不知道自定义的工具是否支持编写业务逻辑,如果能够支持,是用特定的语言还是用通用的语言?选择前者,等于给开发者强加了一门新的,用户极少的语言,如果是后者,则肯定没有通用开发工具支持的功能强。所以自定义工作单和自定义工作流程的实际意义不大。
   
0 请登录后投票
时间:2008-06-26
ltian 写道
fuwang 写道
ltian 写道

Form设计,也就是说工作单的开发吧,谁会用一个专用Form设计工具去开发工作单呢?更多的程序员还是用eclipse,vs等通用的开发工具开工作单。

现在有些工作流产品带表单设计的,自定义表单+自定义流程,这是一大卖点。

说实话,这样的卖点卖给最终用户开发简单的工作单和工作流程似乎还可以,对于软件开发公司来说,这个功能等于画蛇添足。自定义流程核自定义工作单是一个天大的谎言。客户增加工作环节只要稍微改变一点业务逻辑,就需要用代码来完成,不知道自定义的工具是否支持编写业务逻辑,如果能够支持,是用特定的语言还是用通用的语言?选择前者,等于给开发者强加了一门新的,用户极少的语言,如果是后者,则肯定没有通用开发工具支持的功能强。所以自定义工作单和自定义工作流程的实际意义不大。
   
0 请登录后投票
时间:2008-07-22
自定义表单和自定义流程到也没什么问题,就是如何带业务数据跑才是重点,如果所谓的流程应用只能是搞个请假、报销之类的简单信息流转的话,好像很难满足客户需求啊。领导审批请假往往希望看到申请人到底最近一周请了几次假、最近一月请了几次假,申请人的最近有哪些工作在做,这些业务数据往往是流转的核心,要定义出来就不易啦,当然不是不可能的。
国内众多软件厂商的工作流系统好像都难支持,要支持还是离不开工程师开发,用户自己做?难啊。
   
0 请登录后投票
时间:2008-07-25
以前在JAVA下的工作流引擎玩的很多,没有想到居然用RUBY写了工作流,强烈支持
   
0 请登录后投票
论坛首页 Ruby版 ruby

跳转论坛:
JavaEye推荐