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 () {}
/ ** * the establishment of a new workflow template * @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.getscription (), template.getDescription (), template.getdescription (), Template.getDescription () .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}; // Insert person information IF (Flownode.getmans ()! = Null ) {List mans = flownode.getmans ();
for (int i = 0; i / ** * Generate a new workflow instance call requires itself to set this information 1) itself 2) Non-point information * 3) Non-point information * Status: -1, to start, -2: Mandatory termination, -3 : Returning to the original state (need to be modified), 0: Run, 1: Has been completed. * Flow_id: Current run node ID. -9999: There is no current node. * * @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.getStatus (), Workflow.GetStatDate, Workflow.getStartDate (), Workflow.getStartDate (), Workflow.Getenddate (), Workflow.getComment ()}, new int [] {Types.varchar, Types.varchar, Types.Iteger, Types.Varchar, Types.Date, Types.date, Types.varchar} ; // Insert the node information, inserted by the node to insert the person information Li St Nodes = Workflow.getWorkflowNodes (); if (Nodes! = null) {for (int i = 0; i / ** * Through a certain process node * 1) In addition to updating the state of this process, you need to see if it is the last node * If it is the last node, this process is completed. * Otherwise, the update process is the next node, the next node starts * @param updateWorkFlowNode WorkflowNode * @param man_id String * / public void approveWorkFlowNode (WorkflowNode updateWorkFlowNode, String man_id) {// workflow needs to update the node WorkflowNode wfNode = updateWorkFlowNode; String wf_node_id = wfNode.getId (); // update node updateWorkflowNode (wf_node_id, wfNode); // get the next node should run WorkflowNode shouldRunNode = getAfterShouldRunningWorkflowNode (wfNode getWorkId (), wfNode.getSequence ().); // if ( ShouldRunnode == NULL) {// No next node, workflow should complete Workflow Wf = this.getWorkflowbyId (WFNode.GetWorkid ()); // wf.setcomment ("Normal Completion"); WF.SetStatus (Workflow .Workflow_status_finished; java.sql.timestamp enddate = new timestamp (system.currenttimemillis; wf.sesetddate (enddate); // / / Update the workflow to complete the status UpdateWorkflow (WF.GetId (), WF);} else {// There is also a next node, the workflow should be transferred to the next node Workflow Wf = this.getWorkflowbyid (wfnote.getWorkid) ()); // set the current node workflow wf.setFlowId (shouldRunNode.getId ()); // update the current node running state shouldRunNode.setStatus (WorkflowNode.WORKFLOW_NODE_STATUS_RUNNING); java.sql.Timestamp startDate = new Timestamp (System currentTimeMillis ().); shouldRunNode.setStartDate (startDate); // update node updateWorkflowNode (shouldRunNode.getId (), shouldRunNode); // update workflow updateWorkflow (wf.getId (), wf);}} / ** * rejected by a certain node * @param updateWorkFlowNode WorkflowNode * @param man_id String * / public void declineWorkFlowNode (WorkflowNode updateWorkFlowNode, String man_id) {WorkflowNode wfNode = updateWorkFlowNode; // update; String wf_node_id = wfNode.getId () node updateWorkflowNode (wf_node_id, wfNode); // WorkflowNode shouldRunNode = getBeforeShouldRunningWorkflowNode (wfNode getWorkId (), wfNode.getSequence ().); if (shouldRunNode == null) {// return to the edit mode has been Workflow wf = this.getWorkflowById (WFnotE.getWorkid ()); // wf.setcomment ("Re-edited"); // Identify the workflow to return Edit Status Wf.setstatus (Workflow.Workflow_Status_Backed); UpdateWorkflow (wf.getid (), wf);} Else {// Returned to the previous node Workflow wf = this.getWorkflowbyId (wfNode.getWorkid ()); wf.setflowid ()); // - 2 means this node is because the next node is not Pass // return review '[Batch node 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);}} / ** * Delete nodes associated with the specified point of all personnel records * @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};} / ** * Delete workflow mode, will delete nodes and nodes of person information record * @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) {delete nodes need to be adjusted number WorkflowTemplateNode templateNode = this.getTemplateNodeById (id); String template_id = templateNode.getWorkId (); int maxseq = getTemplateNodeMaxSequence (template_id); int currentId = templateNode.getSequence (); if (currentId } public void deleteTemplateNodesOfTemplate (String template_id) {WorkflowTemplateNode [] nodes = this.getTemplateNodesOfTemplate (template_id); if (! nodes = null) {for (int i = 0; i THIS.GETJDBCTEMPLATE (). Update ("delete from workflow_template_flow where template_id =?", new object [] {template_id}, new int {types.varchar}; / ** * Remove Workflow Instance * @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 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 ");} Return NULL; Public WorkflowNode [] getCurrentWorkflowNode () {Return Null;} Public WorkflowTemplate [] getTemplates (INT FLAG) {IF ((Flag! = -1) && (Flag! = 0) && (Flag! = 1)) {Return NULL;} List list = null; IF (Flag! = -1) {list = this.getjdbcTemplate (). Query ("SELECT * WORKFLOW_TEMPLATE WHERE STATUS =? Order By CreateDate", new object [] {new integer (flag)}, new int inteer ( 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.Setcreated (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;}}}});} f ((list! = null) && (list.size ()> 0)) {Return (WorkflowTemplate []) list.toarray (new WorkflowTemplate ";} Return NULL; / ** * get the specified workflow current node * @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");}});}});} 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 resultsetextdractor () {public object {r p et = = (rs.next ()) {int maxNum = rs.get ("maxsequence"); "MAXSEQUENCE"); Return New Integer (MAXNUM); Return new integer (0);}}); Return (Integer) .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 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.setString ("doc_id")); wf.setstatus (Rs.Getint ("status")); wf.setcomment (rs.getstring ("comment" ))); Wf.setStartDate (RS.GetTimeStamp ("start_date")); wf.sesetddate (rs.gettimestamp ("end_date") ); Wf.setString ("flow_id"); return wf;} return null;}}; if (obj! = Null) {return (Workflow) Obj;} return null;} public workflow getWorkflowbyName String id) {return null;} / ** * Get a workflow according to the status * @Param status int * @return Workflow [] * / public workflow [] getWorkflowByStatus (int stat 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 .senddate (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 setsequence (sequenceService sequence "{this.sequence) {this.sequence; = 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}; / * ** Update workflow * @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.get JdbcTemplate (). 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}; // Insert personnel information IF (FlowNode.getmans ()! = Null) {list mans = flownode.getmans (); For (int i = 0; i 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); wfnote.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.setstartdat e (RS.GetTimeStamp ("start_date")); wfNode.seenddate (RS.GetTimeStamp ("end_date")); wfNode.setauditman (Rs.getstring ("Audit_man"); return wfnot;}}; 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); wfnote.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.sesetDate (RS.GetTimeStamp (" end_date ")); wfNode.setauditman (Rs.getstring (" audit_man "); return wfnode;} Return null;}}); if (obj! = null) {return (WorkflowNode) Obj;} return null;} / ** * get all persons designated nodes included * @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");} return null;} Public WorkflowNode [] getWorkflowNodeByStatus (int stats) {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 design, new object [] {new integer (status)}}}}}}}}}}}}}}}}}}}}}}}}}}}}} Throws sqlexception { WorkflowNode WfNode = new workflowNode (); wfnote.setid (rs.getstring ("flow_id")); wfNode.SetworkId (rs.getstring); 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 ("start_date"); wfNode.sesetDate (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); wf.setstatus (Rs.Getint ("status")); wf.setcomment (rs.getstring ("comment"); wf.setstartdate (RS .getTimeStamp ("start_date")); wf.sesetddate (Rs.getTimeStamp ("end_date")); wf.setflowid (rs.getstr ING ("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 = ?, st_date =? NEW ITEGER (WFnotE.getSEquence (), wfNode.getStartDate (), wfnode.getStartDate (), wfnote.getStartDate (), wfnote.Getenddate (), wfnote.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}); } / ** * get the next node should run * * @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 (); wfnote.setId (rs.g ETSTRING ("ID")); wfNode.SetWorkid (rs.getstring ("Work_ID")); wfnote.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.seenddate (Rs.getTimeStamp ("end_date")); wfnode.setauditman (rs.getstring ("audit_man"); Return wfNode;}}); if (obj! = null) {return (WorkflowNode) Obj;} return null;} / ** * In the case of a rejected node, a node must obtain a return * * @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 (); WFN Ode.setid (rs.getstring ("Id")); wfNode.SetWorkid (rs.getstring); wfnote.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.sesetddate (Rs.getTimeStamp ("end_date")); wfnode.setauditman (rs.getstring " Audit_man "); return wfnode;}}}; 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 (); wfnote.setid (rs.getstring ("flow_id")); wfNode.SetworkId (rs.getstring); 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 ("start_date"); wfNode.sesetDate (RS.GetTimeStamp ("end_date")); wfNode.setauditman (Rs.getstring ("Audit_man"); return wfnode }}); If (list! = Null && list.size ()> 0) {Return (WorkflowNode []) list.toarray (new WorkflowNode ";} Return NULL;} public WorkflowNode [] getAllBackedWorkflowNode () {WorkflowNode [] wfNodes = getWorkflowNodeByStatus (Workflow WORKFLOW_STATUS_RUNNING, WorkflowNode.WORKFLOW_NODE_STATUS_BACKED.); return wfNodes;}