📄 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 + -