您的位置:首页 > 其它

后台事务自动跳转工作流节点

2012-06-16 23:37 429 查看
在facade增加方法jumpWF4PaymentOrder,然后在后台事务定义增加.

示例:流程名称为 付款单HTH 有个时间等待节点,该节点执行日期为9999年12月12日(意思是让流程永远停留在时间等待节点),当发现外部环境变化,需要跳转到时间等待节点的下一个节点时,采用如下代码-----

/**

* 跳转

*/

protected void _jumpWF4PaymentOrder(Context ctx) throws BOSException,EASBizException {

IEnactmentService iService = EnactmentServiceFactory.createEnactService(ctx);

String procSql = "select  FPROCDEFHASH,FPROCINSTID  from T_WFR_ProcInst " +

"where fpprocdefname_l2 ='付款单HTH' and fstate='open.running' ";

IRowSet procRs = DbUtil.executeQuery(ctx, procSql);

try{

while(procRs.next()){

String procDefHash = procRs.getString("FPROCDEFHASH");

String procInstId = procRs.getString("FPROCINSTID");

String actSql = "SELECT  FACTDEFNAME_l2 actDefName,FACTDEFID,FACTINSTID FROM  T_WFR_ActInst WHERE FPROCINSTID='"+procInstId+"' and fstate='open.running'";

IRowSet actRs = DbUtil.executeQuery(ctx, actSql);

if(actRs.next()){

String actDefName = actRs.getString("actDefName");

if(actDefName!=null && !actDefName.equals("等待"))

continue;

ProcessDef processDef = iService.getProcessDefByDefineHashValue(procDefHash);

ActivityDef activityDef = processDef.getActivityDef(actRs.getString("FACTDEFID"));

ActivityCollection actCol = activityDef.getPostActivities();

if (actCol.size() == 1){

ActivityDef scriptActDef = actCol.get(0);

if (scriptActDef instanceof ScriptActivityDef){

try{

MyThread t = new MyThread();

t.procInstId = procInstId;

t.scriptActDef = scriptActDef;

t.ctx = ctx;

if(procInstId==null)continue;

if(scriptActDef==null)continue;

t.start();

for(int ll = 0;ll <10;ll++)

{

if (t.state == true)

{

break;

}

Thread.sleep(1000);

}

if (t.state ==false)

{

//证明超时了,需要终止

t.interrupt();

}

} catch (InterruptedException e) {

e.printStackTrace();

}

}

}

}

}

}catch (SQLException e) {

e.printStackTrace();

}

super._jumpWF4PaymentOrder(ctx);

}

class MyThread extends Thread

{

public boolean state = false;

public Object procInstId = null;

public ActivityDef scriptActDef = null;

public Context ctx=null;

public MyThread()

{

}

public void run()

{

try

{

IEnactmentService iService = EnactmentServiceFactory.createEnactService(ctx);

iService.jump(procInstId.toString(), scriptActDef);

}

catch(Exception ex)

{

ex.printStackTrace();

}

state= true;

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐