package com.highcom.workflow.dao.jdbc;
import org.springframework.dao.*;
import org.springframework.jdbc.core.*;import org.springframework.jdbc.core.support.*;
import java.sql.*;
import java.util.*;import com.highcom.workflow.domain.*;import com.highcom.workflow.dao.*;import com.highcom.seqgen.*;
public class workflowdaojdbcimpl extends jdbcdaosupport implements workflowdao { private sequenceservice sequenceservice = null; private string workflow_template_seq = "com.highcom.workflow.template"; private string workflow_template_node_seq = "com.highcom.workflow.template.node"; private string workflow_template_node_man_seq = "com.highcom.workflow.template.node.man"; // private string workflow_seq = "com.highcom.workflow"; private string workflow_node_seq = "com.highcom.workflow.node"; private string workflow_node_man_seq = "com.highcom.workflow.node.man"; // public workflowdaojdbcimpl() { }
/** * 新建立一个工作流模板 * @param template workflowtemplate */ public void addnewtemplate(workflowtemplate template) { string id = sequenceservice.getvalue(workflow_template_seq); this.getjdbctemplate().update("insert into workflow_template(id,name,description,createdate,createman,status,defaultworkflow) values(?,?,?,?,?,?,?)", new object[] { id, template.getname(), template.getdescription(), template.getcreatedate(), template.getcreateman(), new integer(template.getstatus()), new integer(template.getdefaultworkflow()) }, new int[] { types.varchar, types.varchar, types.varchar, types.date, types.varchar, types.integer, types.integer }); }
public void addnewtemplatenode(workflowtemplatenode flownode) { string id = this.sequenceservice.getvalue(this. workflow_template_node_seq); int maxseq = gettemplatenodemaxsequence(flownode.getworkid()); maxseq += 1; this.getjdbctemplate().update("insert into workflow_template_flow(id,template_id,sequence,name,description) values(?,?,?,?,?)", new object[] { id, flownode.getworkid(), new integer(maxseq), flownode.getname(), flownode.getdescription() }, new int[] { types.varchar, types.varchar, types.integer, types.varchar, types.varchar });
//插入人员信息 if (flownode.getmans() != null) { list mans = flownode.getmans();
for (int i = 0; i < mans.size(); i++) { string man_id = this.sequenceservice.getvalue(this. workflow_template_node_man_seq); string account_id = (string) mans.get(i); this.getjdbctemplate().update("insert into workflow_template_man(id,template_flow_id,account_id) values(?,?,?)", new object[] {man_id, id, account_id}, new int[] {types.varchar, types.varchar, types.varchar}); } } }
/** * 生成新的工作流实例 调用程序需要本身设置这些信息 1)本身信息 2)结点信息 * 3)结点人员信息 * status:-1,待启动,-2:强制终止,-3:退回到原始状态(需要修改),0:正在运行,1:已经完成. * flow_id:当前运行结点id.-9999:已经没有当前结点. * * @param workflow workflow * @return string */ public string addnewworkflow(workflow workflow) { // string id = sequenceservice.getvalue(workflow_seq); this.getjdbctemplate().update( "insert into workflow_work(id,doc_id,status," + "flow_id,start_date,end_date,v_comment) values(?,?,?,?,?,?,?)", new object[] { id, workflow.getdocid(), new integer(workflow.getstatus()), workflow.getflowid(), workflow.getstartdate(), workflow.getenddate(), workflow.getcomment()}, new int[] { types.varchar, types.varchar, types.integer, types.varchar, types.date, types.date, types.varchar}); //插入结点信息,由结点插入来插入人员信息 list nodes = workflow.getworkflownodes(); if (nodes != null) { for (int i = 0; i < nodes.size(); i++) { workflownode node = (workflownode) nodes.get(i); addnewworkflownode(node); }
} return id; }
/** * 通过某一个流程结点 * 1)除了更新此流程的状态以外,还需要查看是否是最后一个结点 * 如果是最后一个结点,则完成此流程. * 否则,更新流程状态为下一个结点,启动下一个结点 * @param updateworkflownode workflownode * @param man_id string */ public void approveworkflownode(workflownode updateworkflownode, string man_id) { //需要更新的工作流结点 workflownode wfnode = updateworkflownode; string wf_node_id = wfnode.getid();
//更新结点 updateworkflownode(wf_node_id, wfnode); //得到应该运行的下一个结点 workflownode shouldrunnode = getaftershouldrunningworkflownode(wfnode. getworkid(), wfnode.getsequence()); // if (shouldrunnode == null) { //已经没有下一个结点,工作流应该完成 workflow wf = this.getworkflowbyid(wfnode.getworkid()); // wf.setcomment("正常完成"); wf.setstatus(workflow.workflow_status_finished); java.sql.timestamp enddate = new timestamp(system.currenttimemillis()); wf.setenddate(enddate); //
//更新工作流为完成状态 updateworkflow(wf.getid(), wf); } else { //还存在下一个结点,工作流应该转移到下一个结点 workflow wf = this.getworkflowbyid(wfnode.getworkid()); //设置工作流当前结点 wf.setflowid(shouldrunnode.getid()); //更新当前结点为运行状态 shouldrunnode.setstatus(workflownode.workflow_node_status_running); java.sql.timestamp startdate = new timestamp(system. currenttimemillis()); shouldrunnode.setstartdate(startdate); //更新结点 updateworkflownode(shouldrunnode.getid(), shouldrunnode); //更新工作流 updateworkflow(wf.getid(), wf); } }
/** * 拒绝通过某一个结点 * @param updateworkflownode workflownode * @param man_id string */ public void declineworkflownode(workflownode updateworkflownode, string man_id) { workflownode wfnode = updateworkflownode; string wf_node_id = wfnode.getid(); //更新结点 updateworkflownode(wf_node_id, wfnode); // workflownode shouldrunnode = getbeforeshouldrunningworkflownode(wfnode. getworkid(), wfnode.getsequence()); if (shouldrunnode == null) { //已经退回到编辑状态 workflow wf = this.getworkflowbyid(wfnode.getworkid()); // wf.setcomment("重新编辑"); //标识工作流为退回编辑状态 wf.setstatus(workflow.workflow_status_backed); updateworkflow(wf.getid(), wf); } else { //退回到前一个结点 workflow wf = this.getworkflowbyid(wfnode.getworkid()); wf.setflowid(shouldrunnode.getid()); //-2表示这个结点是因为下一个结点没有通过而返回的 //重审[批结点 shouldrunnode.setstatus(workflownode.workflow_node_status_backed); // java.sql.timestamp startdate = new timestamp(system. currenttimemillis()); shouldrunnode.setstartdate(startdate); updateworkflownode(shouldrunnode.getid(), shouldrunnode); // updateworkflow(wf.getid(), wf); }
}
/** * 删除与指定结点关联的所有人员记录 * @param nodeid string */ public void deletemansofnode(string nodeid) { this.getjdbctemplate().update( "delete from workflow_template_man where template_flow_id=?", new object[] {nodeid}, new int[] {types.varchar}); }
/** * 删除工作流模版,将一同删除结点与结点的人员信息记录 * @param id string */ public void deletetemplate(string id) { this.getjdbctemplate().update( "delete from workflow_template where id=?", new object[] {id}, new int[] {types.varchar}); deletetemplatenodesoftemplate(id); }
public void deletetemplatenode(string id) { 删除结点需要调整序号 workflowtemplatenode templatenode = this.gettemplatenodebyid(id); string template_id = templatenode.getworkid(); int maxseq = gettemplatenodemaxsequence(template_id); int currentid = templatenode.getsequence(); if (currentid < maxseq) { this.getjdbctemplate().update("update workflow_template_flow set sequence=sequence-1 where template_id=? and sequence>?", new object[] {template_id, new integer(currentid)}, new int[] {types.varchar, types.integer}); } // this.deletemansofnode(id); this.getjdbctemplate().update( "delete from workflow_template_flow where id=?", new object[] {id}, new int[] {types.varchar});
}
public void deletetemplatenodesoftemplate(string template_id) { workflowtemplatenode[] nodes = this.gettemplatenodesoftemplate( template_id);
if (nodes != null) { for (int i = 0; i < nodes.length; i++) { workflowtemplatenode node = nodes[i]; deletemansofnode(node.getid()); } }
this.getjdbctemplate().update( "delete from workflow_template_flow where template_id=?", new object[] {template_id}, new int[] {types.varchar}); }
/** * 删除工作流实例 * @param id string */ public void deleteworkflow(string id) { this.getjdbctemplate().update("delete from workflow_work where id=?", new object[] {id}, new int[] {types.varchar}); // workflownode[] wfnodes = this.getworkflownodesofwork(id); if (wfnodes != null) { for (int i = 0; i < wfnodes.length; i++) { this.deleteworkflownode(wfnodes[i].getid()); } } }
public void finishworkflow(string id) { }
public string[] getaccountidsoftempaltenode(string template_node_id) { list mans = this.gettemplatenodemans(template_node_id);
if (mans != null) { return (string[]) mans.toarray(new string[mans.size()]); }
return null; }
public workflownode[] getallcurrentworkflownode() { return null; }
public workflowtemplate[] getalltemplates(int flag) { if ((flag != -1) && (flag != 0) && (flag != 1)) { return null; }
list list = null;
if (flag != -1) { list = this.getjdbctemplate().query( "select * from workflow_template where status=? order by createdate", new object[] {new integer(flag)}, new int[] {types.integer}, new rowmapper() { public object maprow(resultset rs, int _int) throws sqlexception { workflowtemplate temp = new workflowtemplate(); temp.setid(rs.getstring("id")); temp.setname(rs.getstring("name")); temp.setdescription(rs.getstring("description")); temp.setcreateman(rs.getstring("createman")); temp.setcreatedate(rs.gettimestamp("createdate")); temp.setstatus(rs.getint("status")); return temp; } }); } else { list = this.getjdbctemplate().query( "select * from workflow_template order by createdate", new rowmapper() { public object maprow(resultset rs, int _int) throws sqlexception { workflowtemplate temp = new workflowtemplate(); temp.setid(rs.getstring("id")); temp.setname(rs.getstring("name")); temp.setdescription(rs.getstring("description")); temp.setcreateman(rs.getstring("createman")); temp.setcreatedate(rs.gettimestamp("createdate")); temp.setstatus(rs.getint("status"));
return temp; } }); }
if ((list != null) && (list.size() > 0)) { return (workflowtemplate[]) list.toarray(new workflowtemplate[list. size()]); }
return null; }
/** * 得到指定工作流的当前结点 * @param work_id string * @return workflownode */ public workflownode getcurrentnode(string work_id) { object obj = this.getjdbctemplate().query( "select flow_id from workflow_work where id=?", new object[] {work_id}, new int[] {types.varchar}, new resultsetextractor() { public object extractdata(resultset rs) throws sqlexception, dataaccessexception { if (rs.next()) { return rs.getstring("flow_id"); } return null; } }); if (obj != null) { string flow_id = (string) obj; // return this.getworkflownodebyid(flow_id); } return null; }
public workflownode getcurrentnode(workflow workflow) { return null; }
public workflownode[] getcurrentworkflownodebyman(string mam_id) { return null; }
public workflowtemplate gettemplatebyid(string id) { object obj = this.getjdbctemplate().query( "select * from workflow_template where id=?", new object[] {id}, new int[] {types.varchar}, new resultsetextractor() { public object extractdata(resultset rs) throws sqlexception, dataaccessexception { if (rs.next()) { workflowtemplate temp = new workflowtemplate(); temp.setid(rs.getstring("id")); temp.setname(rs.getstring("name")); temp.setdescription(rs.getstring("description")); temp.setcreateman(rs.getstring("createman")); temp.setcreatedate(rs.gettimestamp("createdate")); temp.setstatus(rs.getint("status"));
return temp; }
return null; } });
if (obj != null) { return (workflowtemplate) obj; }
return null; }
public workflowtemplate gettemplatebyname(string name) { return null; }
public workflowtemplatenode gettemplatenodebyid(string id) { object obj = this.getjdbctemplate().query( "select * from workflow_template_flow where id=?", new object[] {id}, new int[] {types.varchar}, new resultsetextractor() { public object extractdata(resultset rs) throws sqlexception, dataaccessexception { if (rs.next()) { workflowtemplatenode wfnode = new workflowtemplatenode(); wfnode.setid(rs.getstring("id")); wfnode.setname(rs.getstring("name")); wfnode.setdescription(rs.getstring("description")); wfnode.setworkid(rs.getstring("template_id")); wfnode.setsequence(rs.getint("sequence"));
return wfnode; }
return null; } });
if (obj != null) { return (workflowtemplatenode) obj; }
return null; }
public workflowtemplatenode gettemplatenodebyname(string name) { return null; }
public list gettemplatenodemans(string template_flow_id) { list list = this.getjdbctemplate().query( "select account_id from workflow_template_man where template_flow_id=? ", new object[] {template_flow_id}, new int[] {types.varchar}, new rowmapper() { public object maprow(resultset rs, int _int) throws sqlexception { return rs.getstring("account_id"); } });
return list; }
public list getworkflownodemans(string work_flow_id) { list list = this.getjdbctemplate().query( "select account_id from workflow_man where flow_id=? ", new object[] {work_flow_id}, new int[] {types.varchar}, new rowmapper() { public object maprow(resultset rs, int _int) throws sqlexception { return rs.getstring("account_id"); } });
return list; }
public int gettemplatenodemaxsequence(string template_id) { object obj = this.getjdbctemplate().query("select max(sequence) as maxsequence from workflow_template_flow where template_id=?", new object[] {template_id}, new int[] {types.varchar}, new resultsetextractor() { public object extractdata(resultset rs) throws sqlexception, dataaccessexception { if (rs.next()) { int maxnum = rs.getint("maxsequence");
return new integer(maxnum); }
return new integer(0); } });
return ((integer) obj).intvalue(); }
public workflowtemplatenode[] gettemplatenodesoftemplate(string template_id) { list list = this.getjdbctemplate().query( "select * from workflow_template_flow where template_id=? order by sequence", new object[] {template_id}, new int[] {types.varchar}, new rowmapper() { public object maprow(resultset rs, int _int) throws sqlexception { workflowtemplatenode tnode = new workflowtemplatenode(); tnode.setid(rs.getstring("id")); tnode.setdescription(rs.getstring("description")); tnode.setname(rs.getstring("name")); tnode.setsequence(rs.getint("sequence")); tnode.setworkid(rs.getstring("template_id"));
return tnode; } });
if (list != null) { for (int i = 0; i < list.size(); i++) { workflowtemplatenode tnode = (workflowtemplatenode) list.get(i); list mans = this.gettemplatenodemans(tnode.getid()); tnode.setmans(mans); }
return (workflowtemplatenode[]) list.toarray(new workflowtemplatenode[ list.size()]); }
return null; }
public workflow getworkflowbyid(string id) { object obj = this.getjdbctemplate().query("select id,doc_id,status," + "flow_id,start_date,end_date,comment from workflow_work where id=?", new object[] {id}, new int[] {types.varchar}, new resultsetextractor() { public object extractdata(resultset rs) throws sqlexception, dataaccessexception { if (rs.next()) { workflow wf = new workflow(); wf.setid(rs.getstring("id")); wf.setdocid(rs.getstring("doc_id")); wf.setstatus(rs.getint("status")); wf.setcomment(rs.getstring("comment")); wf.setstartdate(rs.gettimestamp("start_date")); wf.setenddate(rs.gettimestamp("end_date")); wf.setflowid(rs.getstring("flow_id")); return wf; } return null; } }); if (obj != null) { return (workflow) obj; } return null; }
public workflow getworkflowbyname(string id) { return null; }
/** * 根据状态得到工作流 * @param status int * @return workflow[] */ public workflow[] getworkflowbystatus(int status) { list list = this.getjdbctemplate().query("select id,doc_id,status," + "flow_id,start_date,end_date,comment from workflow_work where status=? order by start_date desc", new object[] {new integer( status)}, new int[] {types.integer}, new rowmapper() { public object maprow(resultset rs, int _int) throws sqlexception { workflow wf = new workflow(); wf.setid(rs.getstring("id")); wf.setdocid(rs.getstring("doc_id")); wf.setstatus(rs.getint("status")); wf.setcomment(rs.getstring("comment")); wf.setstartdate(rs.gettimestamp("start_date")); wf.setenddate(rs.gettimestamp("end_date")); wf.setflowid(rs.getstring("flow_id")); return wf;
} }); if (list != null && list.size() > 0) { return (workflow[]) list.toarray(new workflow[list.size()]); } return null; }
public void setsequenceservice(sequenceservice sequenceservice) { this.sequenceservice = sequenceservice; }
public void terminateworkflow(workflow workflow) { }
public void updatetemplate(string id, workflowtemplate template) { this.getjdbctemplate().update( "update workflow_template set name=?,description=?,status=? where id=?", new object[] { template.getname(), template.getdescription(), new integer(template.getstatus()), id }, new int[] { types.varchar, types.varchar, types.integer, types.varchar}); }
public void updatetemplatenode(string id, workflowtemplatenode flownode) { this.getjdbctemplate().update( "update workflow_template_flow set name=?,description=?,sequence=? where id=?", new object[] { flownode.getname(), flownode.getdescription(), new integer(flownode.getsequence()), id }, new int[] { types.varchar, types.varchar, types.integer, types.varchar}); }
/** * 更新工作流 * @param id string * @param workflow workflow */ public void updateworkflow(string id, workflow workflow) { this.getjdbctemplate().update( "update workflow_work set doc_id=?,status=?," + "flow_id=?,start_date=?,end_date=?,comment=? from workflow_work where id=?", new object[] {workflow.getdocid(), new integer(workflow.getstatus()), workflow.getflowid(), workflow.getstartdate(), workflow.getenddate(), workflow.getcomment(), id}, new int[] {types.varchar, types.integer, types.varchar, types.timestamp, types.timestamp, types.varchar, types.varchar}); }
public void addnewtemplatenodeman(string template_node_id, string account_id) { string id = this.sequenceservice.getvalue(this. workflow_template_node_man_seq); this.getjdbctemplate().update("insert into workflow_template_man(id,template_flow_id,account_id) values(?,?,?)", new object[] {id, template_node_id, account_id}, new int[] {types.varchar, types.varchar, types.varchar}); }
public void deletetemplatenodeman(string template_node_id, string account_id) { this.getjdbctemplate().update( "delete from workflow_template_man where template_flow_id=? and account_id=?", new object[] {template_node_id, account_id}, new int[] {types.varchar, types.varchar});
}
/** * * @param flownode workflownode * @return string */ public string addnewworkflownode(workflownode flownode) { string id = this.sequenceservice.getvalue(this.workflow_node_seq); // this.getjdbctemplate().update( "insert into workflow_flow(id,work_id,status," + "sequence,name,description,comment,start_date,end_date,audit_man) values(?,?,?,?,?,?,?,?,?,?)", new object[] { id, flownode.getworkid(), new integer(flownode.getstatus()), new integer(flownode.getsequence()), flownode.getname(), flownode.getdescription(), flownode.getcomment(), flownode.getstartdate(), flownode.getenddate(), flownode.getauditman()}, new int[] { types.varchar, types.varchar, types.integer, types.integer, types.varchar, types.varchar, types.varchar, types.date, types.date, types.varchar});
//插入人员信息 if (flownode.getmans() != null) { list mans = flownode.getmans();
for (int i = 0; i < mans.size(); i++) { string man_id = this.sequenceservice.getvalue(this. workflow_node_man_seq); string account_id = (string) mans.get(i); this.getjdbctemplate().update( "insert into workflow_man(id,flow_id,account_id) values(?,?,?)", new object[] {man_id, id, account_id}, new int[] {types.varchar, types.varchar, types.varchar}); } } return id; }
public workflownode[] getworkflownodesofwork(string work_id) {
list list = this.getjdbctemplate().query("select id,work_id,comment,status,sequence,name,description,start_date,end_date,audit_man from workflow_flow where " + "work_id=?", new object[] {work_id}, new int[] {types.varchar}, new rowmapper() { public object maprow(resultset rs, int _int) throws sqlexception { workflownode wfnode = new workflownode(); wfnode.setid(rs.getstring("id")); wfnode.setworkid(rs.getstring("work_id")); wfnode.setcomment(rs.getstring("comment")); wfnode.setstatus(rs.getint("status")); wfnode.setsequence(rs.getint("sequence")); wfnode.setname(rs.getstring("name")); wfnode.setdescription(rs.getstring("description")); wfnode.setstartdate(rs.gettimestamp("start_date")); wfnode.setenddate(rs.gettimestamp("end_date")); wfnode.setauditman(rs.getstring("audit_man")); return wfnode;
} }); if (list != null && list.size() > 0) { return (workflownode[]) list.toarray(new workflownode[list.size()]); } return null; }
public void deleteworkflownode(string flow_id) { this.getjdbctemplate().update("delete from workflow_flow where id=?", new object[] {flow_id}, new int[] {types.varchar}); this.getjdbctemplate().update( "delete from workflow_man where flow_id=?", new object[] {flow_id}, new int[] {types.varchar}); }
/** * * @return workflow */ public workflow[] getallrunningworkflow() { return this.getworkflowbystatus(workflow.workflow_status_running); }
public workflownode getworkflownodebyid(string node_id) { object obj = this.getjdbctemplate().query( "select id,work_id,comment,status," + "sequence,name,description,start_date,end_date,audit_man from workflow_flow where id=?", new object[] {node_id}, new int[] {types.varchar}, new resultsetextractor() { public object extractdata(resultset rs) throws sqlexception, dataaccessexception { if (rs.next()) { workflownode wfnode = new workflownode(); wfnode.setid(rs.getstring("id")); wfnode.setworkid(rs.getstring("work_id")); wfnode.setcomment(rs.getstring("comment")); wfnode.setstatus(rs.getint("status")); wfnode.setsequence(rs.getint("sequence")); wfnode.setname(rs.getstring("name")); wfnode.setdescription(rs.getstring("description")); wfnode.setstartdate(rs.gettimestamp("start_date")); wfnode.setenddate(rs.gettimestamp("end_date")); wfnode.setauditman(rs.getstring("audit_man")); return wfnode;
} return null; } }); if (obj != null) { return (workflownode) obj; } return null; }
/** * 得到指定结点所包含的所有人员 * @param node_id string * @return string[] */ public string[] getmansofworkflownode(string node_id) { list list = this.getjdbctemplate().query( "select account_id from workflow_man where flow_id=?", new object[] {node_id}, new int[] {types.varchar}, new rowmapper() { public object maprow(resultset rs, int _int) throws sqlexception { return rs.getstring("account_id"); } }); if (list != null && list.size() > 0) { return (string[]) list.toarray(new string[list.size()]); } return null; }
public workflownode[] getworkflownodebystatus(int status) { list list = this.getjdbctemplate().query( "select b.flow_id,a.work_id,a.comment,a.status," + "a.sequence,a.name,a.description,a.start_date,a.end_date,a.audit_man from workflow_flow a" + ",workflow_work b where a.id=b.flow_id and b.status=? order by a.start_date desc", new object[] {new integer(status)}, new int[] {types.integer}, new rowmapper() { public object maprow(resultset rs, int _int) throws sqlexception {
workflownode wfnode = new workflownode(); wfnode.setid(rs.getstring("flow_id")); wfnode.setworkid(rs.getstring("work_id")); wfnode.setcomment(rs.getstring("comment")); wfnode.setstatus(rs.getint("status")); wfnode.setsequence(rs.getint("sequence")); wfnode.setname(rs.getstring("name")); wfnode.setdescription(rs.getstring("description")); wfnode.setstartdate(rs.gettimestamp("start_date")); wfnode.setenddate(rs.gettimestamp("end_date")); wfnode.setauditman(rs.getstring("audit_man")); return wfnode; } }); if (list != null && list.size() > 0) { return (workflownode[]) list.toarray(new workflownode[list.size()]); } return null; }
public workflownode[] getallrunningworkflownode() { return this.getworkflownodebystatus(workflow.workflow_status_running, workflownode. workflow_node_status_running); }
public workflow getworkflowbydocid(string doc_id) {
object obj = this.getjdbctemplate().query("select id,doc_id,status," + "flow_id,start_date,end_date,comment from workflow_work where doc_id=?", new object[] {doc_id}, new int[] {types.varchar}, new resultsetextractor() { public object extractdata(resultset rs) throws sqlexception, dataaccessexception { if (rs.next()) { workflow wf = new workflow(); wf.setid(rs.getstring("id")); wf.setdocid(rs.getstring("doc_id")); wf.setstatus(rs.getint("status")); wf.setcomment(rs.getstring("comment")); wf.setstartdate(rs.gettimestamp("start_date")); wf.setenddate(rs.gettimestamp("end_date")); wf.setflowid(rs.getstring("flow_id")); return wf; } return null; } }); if (obj != null) { return (workflow) obj; } return null;
}
/** * * @param flow_id string * @param wfnode workflownode */ public void updateworkflownode(string flow_id, workflownode wfnode) { this.getjdbctemplate().update( "update workflow_flow set work_id=?,comment=?,status=?," + "sequence=?,name=?,description=?,start_date=?,end_date=?,audit_man=? where id=?", new object[] {wfnode.getworkid(), wfnode.getcomment(), new integer(wfnode.getstatus()), new integer(wfnode.getsequence()), wfnode.getname(), wfnode.getdescription(), wfnode.getstartdate(), wfnode.getenddate(), wfnode.getauditman(), flow_id}, new int[] {types.varchar, types.varchar, types.integer, types.integer, types.varchar, types.varchar, types.timestamp, types.timestamp, types.varchar, types.varchar}); }
/** * 得到应该运行的下一个结点 * * @param workflow_id string * @param currentseq int * @return workflownode */ public workflownode getaftershouldrunningworkflownode(string workflow_id, int currentseq) { object obj = this.getjdbctemplate().query( "select id,work_id,comment,status," + "sequence,name,description,start_date,end_date,audit_man from workflow_flow where " + "work_id=? and sequence=(select min(sequence) from workflow_flow where work_id=? and sequence>?)", new object[] {workflow_id, workflow_id, new integer(currentseq)}, new int[] {types.varchar, types.varchar, types.integer}, new resultsetextractor() { public object extractdata(resultset rs) throws sqlexception, dataaccessexception { if (rs.next()) { workflownode wfnode = new workflownode(); wfnode.setid(rs.getstring("id")); wfnode.setworkid(rs.getstring("work_id")); wfnode.setcomment(rs.getstring("comment")); wfnode.setstatus(rs.getint("status")); wfnode.setsequence(rs.getint("sequence")); wfnode.setname(rs.getstring("name")); wfnode.setdescription(rs.getstring("description")); wfnode.setstartdate(rs.gettimestamp("start_date")); wfnode.setenddate(rs.gettimestamp("end_date")); wfnode.setauditman(rs.getstring("audit_man")); return wfnode;
} return null; } }); if (obj != null) { return (workflownode) obj; } return null; }
/** * 在一个结点被拒绝的情况下,得到应该返回的上一个结点 * * @param workflow_id string * @param currentseq int * @return workflownode */ public workflownode getbeforeshouldrunningworkflownode(string workflow_id, int currentseq) { object obj = this.getjdbctemplate().query( "select id,work_id,comment,status," + "sequence,name,description,start_date,end_date,audit_man from workflow_flow where " + "work_id=? and sequence=(select max(sequence) from workflow_flow where work_id=? and sequence)", new object[] {workflow_id, workflow_id, new integer(currentseq)}, new int[] {types.varchar, types.varchar, types.integer}, new resultsetextractor() { public object extractdata(resultset rs) throws sqlexception, dataaccessexception { if (rs.next()) { workflownode wfnode = new workflownode(); wfnode.setid(rs.getstring("id")); wfnode.setworkid(rs.getstring("work_id")); wfnode.setcomment(rs.getstring("comment")); wfnode.setstatus(rs.getint("status")); wfnode.setsequence(rs.getint("sequence")); wfnode.setname(rs.getstring("name")); wfnode.setdescription(rs.getstring("description")); wfnode.setstartdate(rs.gettimestamp("start_date")); wfnode.setenddate(rs.gettimestamp("end_date")); wfnode.setauditman(rs.getstring("audit_man")); return wfnode;
} return null; } }); if (obj != null) { return (workflownode) obj; } return null; }
public workflownode[] getworkflownodebystatus(int work_status, int node_status) { list list = this.getjdbctemplate().query( "select b.flow_id,a.work_id,a.comment,a.status," + "a.sequence,a.name,a.description,a.start_date,a.end_date,a.audit_man from workflow_flow a" + ",workflow_work b where a.id=b.flow_id and b.status=? and a.status=? order by a.start_date desc", new object[] {new integer(work_status), new integer(node_status)}, new int[] {types.integer, types.integer}, new rowmapper() { public object maprow(resultset rs, int _int) throws sqlexception {
workflownode wfnode = new workflownode(); wfnode.setid(rs.getstring("flow_id")); wfnode.setworkid(rs.getstring("work_id")); wfnode.setcomment(rs.getstring("comment")); wfnode.setstatus(rs.getint("status")); wfnode.setsequence(rs.getint("sequence")); wfnode.setname(rs.getstring("name")); wfnode.setdescription(rs.getstring("description")); wfnode.setstartdate(rs.gettimestamp("start_date")); wfnode.setenddate(rs.gettimestamp("end_date")); wfnode.setauditman(rs.getstring("audit_man")); return wfnode; } }); if (list != null && list.size() > 0) { return (workflownode[]) list.toarray(new workflownode[list.size()]); } return null;
}
public workflownode[] getallbackedworkflownode() { workflownode[] wfnodes = getworkflownodebystatus(workflow. workflow_status_running, workflownode.workflow_node_status_backed); return wfnodes; }
public workflownode[] getallreeditworkflownode() { workflownode[] wfnodes = getworkflownodebystatus(workflow. workflow_status_backed, workflownode.workflow_node_status_declined); return wfnodes; } /** * 取得默认的工作流模板 * @return workflowtemplate */ public workflowtemplate getdefaultworkflow() { object obj = this.getjdbctemplate().query( "select * from workflow_template where defaultworkflow=?", new object[] {new integer(0)}, new int[] {types.integer}, new resultsetextractor() { public object extractdata(resultset rs) throws sqlexception, dataaccessexception { if (rs.next()) { workflowtemplate temp = new workflowtemplate(); temp.setid(rs.getstring("id")); temp.setname(rs.getstring("name")); temp.setdescription(rs.getstring("description")); temp.setcreateman(rs.getstring("createman")); temp.setcreatedate(rs.gettimestamp("createdate")); temp.setstatus(rs.getint("status")); temp.setdefaultworkflow(rs.getint("defaultworkflow")); return temp; } return null; } }); if (obj != null) { return (workflowtemplate) obj; } return null; }}