?? workflow_stepmain.java
字號:
package treedoc;
// 對已經提交進數據庫中的流程圖的數據進行修改,查詢的類
// 該類中的方法為其它類所調用..///////////////
// 該類中包含了絕大部分對庫的操作方法///////////
/**
* 名稱 : WORKFLOW_StepMain
* 描述 : WWW.FANGFA.NET 工作流管理系統--數據庫SQL操作方法集合類
* 版權信息 : Copyright (c) 2004 COMSCI
* @作者 : COMSCI Sichuan Fangfa Digital
* @版本 : 0.9 builder 2004091910
* @日期 : 2004/09/19
*/
public class workflow_StepMain {
workflow_DB_connection db_conn;
String graph_id;
public workflow_StepMain(String graphid) {
db_conn = new workflow_DB_connection(); //構造方法...初始連接庫////
}
// 通過LOGINNAME 獲得USER ID
public int get_userid(String loginname) {
int uid = 0;
try {
db_conn.rs = db_conn.stmt.executeQuery
("select id from user where loginname = '" + loginname + "' ");
if (db_conn.rs.next()) {
uid = db_conn.rs.getInt("id");
}
// db_conn.stmt.close();
// db_conn.rs.close();
}
catch (Exception e) {
System.out.println("獲得UID異常" + e);
}
return uid;
}
// 通過UID獲得LOGINNAME
public String get_username(int uid) {
String uuid = "";
try {
db_conn.rs = db_conn.stmt.executeQuery
("select loginname from user where id = " + uid + " ");
if (db_conn.rs.next()) {
uuid = db_conn.rs.getString("loginname");
}
// db_conn.stmt.close();
db_conn.rs.close();
}
catch (Exception e) {
System.out.println("獲得loginname異常");
}
return uuid;
}
////////////////通過UNAME 獲得DEPARTMENT_ID/////////////////////////
public int get_department(String uname) {
int uuid = 0;
try {
db_conn.rs = db_conn.stmt.executeQuery
("select department_id from user where loginname = '" + uname + "' ");
if (db_conn.rs.next()) {
uuid = db_conn.rs.getInt("department_id");
}
// db_conn.stmt.close();
db_conn.rs.close();
}
catch (Exception e) {
System.out.println("獲得department_id異常");
}
return uuid;
}
/////////////////////////////////////////////////////////////////////////////
///////////////////根據選擇條件,將step_main中的allow_toback 設置為1,容許回退//////////////////////////////////////////////
public boolean allow_toback(String sid, String graph_id) {
boolean at = false;
try {
db_conn.stmt.executeUpdate
("update step_main set allow_toback = 1 where graph_id = '" +
graph_id +
"' and step_name = '" + sid + "' ");
at = true;
// db_conn.stmt.close();
}
catch (Exception e) {
System.out.println("設置allow_toback" + e);
}
return at;
}
//////////////////////////////////////////////////////////////////////////
//////根據選擇條件,將step_main中的is_route設置為1,表示有特殊跳轉點///////////
public boolean is_route(String sid, String graph_id) {
boolean aat = false;
try {
db_conn.stmt.executeUpdate
("update step_main set is_routed = 1 where graph_id = '" +
graph_id +
"' and step_name = '" + sid + "' ");
aat = true;
// db_conn.stmt.close();
}
catch (Exception e) {
System.out.println("設置is_routed" + e);
}
return aat;
}
//////////////////////////////////////////////////////////////////////////////
// 獲得該流程圖中的所有節點列表
public java.util.Vector get_allsteps(String graph_id) {
java.util.Vector als = new java.util.Vector();
try {
db_conn.rs = db_conn.stmt.executeQuery
("select distinct(step_name) from step_main where graph_id = '" +
graph_id + "' order by step_name ");
while (db_conn.rs.next()) {
als.add( (String) db_conn.rs.getString("step_name"));
}
// db_conn.stmt.close();
// db_conn.rs.close();
}
catch (Exception e) {
System.out.println("返回上N個節點錯");
}
return als;
}
// 插入一條新的FLOW記錄到FLOW_MASTER表中
public void new_flow(String graphid, String create_time, int department_id) {
try {
db_conn.stmt.execute(
"insert into flow_manager values('','" + graphid + "','" + graphid +
"','','無文件','','','','" + create_time + "'," + department_id + ")");
}
catch (Exception e) {
System.out.println(e);
}
}
///////////////讀取STEP_DETAIL中的用戶ID方法//////////////////////////
public java.util.ArrayList return_active_user(String stepid, String graphid) {
String uid = "";
java.util.ArrayList jua = new java.util.ArrayList();
try {
db_conn.rs2 = db_conn.stmt2.executeQuery
(
"select * from step_detail where step_id = '" + stepid +
"' and flow_id = '" +
graphid + "' ");
if (db_conn.rs2.next()) {
jua.add(db_conn.rs2.getString("action_type"));
jua.add(db_conn.rs2.getString("action_result"));
jua.add(db_conn.rs2.getString("action_record"));
jua.add(db_conn.rs2.getString("action_status"));
jua.add(db_conn.rs2.getString("route_node"));
uid = this.get_username(db_conn.rs2.getInt("user_id"));
jua.add(uid);
}
// db_conn.stmt2.close();
db_conn.rs2.close();
}
catch (Exception e) {
System.out.println("獲得活動用戶異常");
}
return jua;
}
///////////////讀取STEP_DETAIL中的活動狀態方法//////////////////////////
public String return_action_status(String stepid, String graphid) {
String jv = "";
try {
db_conn.rs2 = db_conn.stmt2.executeQuery
(
"select action_status from step_detail where step_id = '" + stepid +
"' and flow_id = '" +
graphid + "' ");
if (db_conn.rs2.next()) {
jv = db_conn.rs2.getString("action_status");
}
// db_conn.stmt2.close();
db_conn.rs2.close();
}
catch (Exception e) {
System.out.println("獲得活動狀態異常");
}
return jv;
}
////////////////////////通過部門ID獲得該部門下全部用戶///////////////
public java.util.Vector get_user_department(String did) {
java.util.Vector user = new java.util.Vector();
try {
db_conn.rs = db_conn.stmt.executeQuery
(
"select loginname from user where department_id = '" + did + "' ");
while (db_conn.rs.next()) {
user.add(db_conn.rs.getString("loginname"));
}
}
catch (Exception e) {
System.out.println("獲取該部門用戶錯");
}
return user;
}
////////////////////////獲得所有可以關聯的工作流//////////////////////////
public java.util.Vector get_workflow() {
java.util.Vector flow = new java.util.Vector();
try {
db_conn.rs = db_conn.stmt.executeQuery
(
"select flow_name from flow_manager where flow_status = 0 ");
while (db_conn.rs.next()) {
flow.add(db_conn.rs.getString("flow_name"));
}
}
catch (Exception e) {
System.out.println("獲取flow_manager錯");
}
return flow;
}
///////////////////////////取系統根部門/////////////////////////////
public java.util.Vector get_department_id() {
java.util.Vector gd = new java.util.Vector();
try {
db_conn.rs = db_conn.stmt.executeQuery
(
"select id from department where parent_id = 0 ");
while (db_conn.rs.next()) {
gd.add(db_conn.rs.getString("id"));
}
}
catch (Exception e) {
System.out.println("獲取部門錯");
}
return gd;
}
///////////////////通過ID獲得部門名稱/////////////////////////
public String get_department_name(String did) {
String gdd = "";
try {
db_conn.rs = db_conn.stmt.executeQuery
(
"select name from department where id = '" + did + "' ");
while (db_conn.rs.next()) {
gdd = db_conn.rs.getString("name");
}
}
catch (Exception e) {
System.out.println("獲取部門名稱錯");
}
return gdd;
}
///////////////////////////////////////////////////////
public String get_department_name1(int did) {
String gdd = "";
try {
db_conn.rs = db_conn.stmt.executeQuery
(
"select name from department where id = " + did + " ");
while (db_conn.rs.next()) {
gdd = db_conn.rs.getString("name");
}
}
catch (Exception e) {
System.out.println("獲取部門名稱錯");
}
return gdd;
}
///////////////通過名稱獲得ID///////////////////////////
public String get_Did(String dname) {
String gdi = "";
try {
db_conn.rs = db_conn.stmt.executeQuery
(
"select id from department where name = '" + dname + "' ");
if (db_conn.rs.next()) {
gdi = db_conn.rs.getString("id");
}
}
catch (Exception e) {
System.out.println("獲取部門ID錯");
}
return gdi;
}
///////////////////////////////////////////////////////
public java.util.Vector get_child_department(String parent_id) {
java.util.Vector gddi = new java.util.Vector();
int pid = 95949; //隨機
if (!parent_id.equals("")) {
pid = Integer.parseInt(parent_id);
}
try {
db_conn.rs = db_conn.stmt.executeQuery
(
"select name from department where parent_id = " + pid + " ");
while (db_conn.rs.next()) {
gddi.add(db_conn.rs.getString("name"));
}
}
catch (Exception e) {
System.out.println("獲取子部門錯");
}
return gddi;
}
////////////////將STEPID的明細活動添加到step_detaiL表中
public boolean insert_stepactive(String stepid, String graphid, int uid,
String action_type, String action_record,
String route_node) {
boolean insert = false;
try {
db_conn.stmt2.execute(
"insert into step_detail(flow_id,step_id,user_id,action_type,action_record,route_node) values('" +
graphid +
"','" + stepid +
"'," + uid + ",'" + action_type + "','" + action_record + "','" +
route_node + "')");
insert = true;
// System.out.println("adfd");
}
catch (Exception e) {
System.out.println("添加活動異常");
}
return insert;
}
///////////////////////對流程FLOW表進行操作的方法///////////////////////
// 修改FLOW記錄的狀態
public boolean start_flow(String graphid, String flow_startup_time) {
boolean sf = false;
String sid = "";
try {
db_conn.stmt.executeUpdate
("update flow_manager set flow_status =1,flow_startup_time = '" +
flow_startup_time + "' where graph_id = '" +
graphid +
"' ");
}
catch (Exception e) {
System.out.println(e);
}
sid = this.return_nextStep(this.return_FristStep(graphid), graphid);
try {
db_conn.stmt.executeUpdate
("update step_main set is_active = 1 where graph_id = '" +
graphid +
"' and step_id = '" + sid + "' ");
sf = true;
}
catch (Exception e) {
System.out.println(e);
}
return sf;
}
public void end_flow(String graphid) {}
public boolean suspend_flow(String graphid) {
boolean status = false;
try {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -