工作流java代码_一个用数据库实现的工作流-JSP教程,Java技巧及代码

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;    }}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
2.1 工作流 3 2.1.1 什么叫工作流 3 2.1.2 工作流发展 3 2.1.3 工作流的优点 3 2.2 MVC工作模式 4 2.2.1 MVC设计思想 4 2.2.2 MVC的具体实现 5 2.2.3 MVC的不足 6 2.3 JSP技术介绍 6 2.3.1 JSP的运行原理 7 2.3.2 JSP的生命周期 8 2.3.3 Servlet和JavaBean技术介绍 8 2.3.4 Java 虚拟机 9 2.3.5 JSP访问SQL Server 2000数据库 9 2.4 数据库后台环境配置 10 2.5 系统开发工具简介 10 2.5.1 Dreamweaver 10 2.5.2 MyEclipse 10 2.5.3 Tomcat 11 2.5.4 SQL Server2000 11 2.5.5 chs_sql2ksp3 12 3 系统需求分析 13 3.1 系统功能分析 13 3.2 系统性能分析 13 3.3 系统方案的确定和评价 13 4 系统总体设计 15 4.1 系统层次模块图 15 4.1.1 营业厅模块 15 4.1.2 收费管理模块 16 4.2 系统数据流程图 16 4.3 数据表设计 18 5 详细设计及编码 21 5.1 编写JAVABEAN 21 5.2 营业厅实现函数 21 5.3 收费厅主要的实现函数 22 5.4 JAVABEAN主要实现模块 22 5.4.1 中文字符格式的转换模块(Stringto.java) 22 5.4.2 自动生成验证码(Ran.java) 22 5.4.3 数据库的连接(ConnectionFactory.java) 23 5.4.4 数据库连接的关闭(DatabaseUtils.java)--只提供接口 23 5.4.5 密码修改模块(Common_fuction.java) 24 5.4.6 时间格式转换(timeBean.java) 24 5.4.7 数据统计(counthander.java) 25 5.4.8 营业厅的接口(luruaction.java) 27 5.4.9 营业厅的主要函数实现(luruhander.java) 28 5.4.10 收费厅的主要函数接口 32 5.5 管理员登陆模块 33 5.5.1 管理员登录 33 5.6 营业厅管理模块 36 5.6.1 Left.jsp页面 36 5.6.2 Work.jsp 40 5.6.3 customerlistinfo.jsp 41 5.6.4 allinfo.jsp 41 5.7 收费厅管理模块 42 5.7.1 Left.jsp 42 5.7.2 Work.jsp 43 5.7.3 Customerlistinfo.jsp 43 5.7.4 gongdan.jsp 43 6 系统测试与维护 45 6.1 测试目的 45 6.2 测试环境 45 6.3 系统测试 45 6.4 系统维护 45 7 开发难点与技术 46 7.1 主要程序实现代码描述 46 7.1.1 验证码的自动生成 46 7.1.2 生成WORD工单 46 7.1.3 以一定的时间刷新页面 47 7.1.4 JSP中文问题的解决 47 7.2 在程序编码过程遇到的主要问题: 48 7.3 代码编写风格 49 7.4 我的不足: 49

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值