公文流转 java_Java web 公文流转系统 完成结果

packagedao;importjava.sql.Connection;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.util.ArrayList;importbean.InfoBean;importbean.authority;importbean.user;importutil.DBUtil;public classdao {public static ArrayListgetInfos(String str) {

Connection conn= null;

PreparedStatement pst= null;

ResultSet rs= null;

conn=DBUtil.getConnection();

String sql;if (str.equals("receive"))

sql= "select * from infobean where status=0 or status=2 or status=3 or status=4 or status=5 or status=6 or status=7 or status=-1 and deletestatus=0";if (str.equals("send"))

sql= "select * from infobean where status=1 or status=4 or status=5 or status=8 or status=9 or status=10 and deletestatus=0";if (str.equals("delete"))

sql= "select * from infobean where deletestatus=1";elsesql= "select * from infobean";try{

PreparedStatement prepareStatement=conn.prepareStatement(sql);

rs=prepareStatement.executeQuery();

ArrayList list = new ArrayList<>();while(rs.next()) {

InfoBean ib= newInfoBean();

ib.setId(rs.getInt("id"));

ib.setTitle(rs.getString("title"));

ib.setOwner(rs.getString("owner"));

ib.setTime(rs.getString("time"));

ib.setReceiver(rs.getString("receive"));

ib.setStatus(rs.getInt("status"));

ib.setResult(rs.getInt("reslut"));

ib.setPlace(rs.getString("place"));

ib.setDeletestatus(rs.getInt("deletestatus"));

list.add(ib);

}returnlist;

}catch(SQLException e) {//TODO Auto-generated catch block

e.printStackTrace();

}finally{

DBUtil.close(rs, pst, conn);

}return null;

}public static booleanuserExits(user user) {

Connection con= null;

PreparedStatement pstmt= null;

ResultSet rs= null;

con=DBUtil.getConnection();

String sql= "select * from user where username ='" + user.getUsername() + "'and password='"

+ user.getPassword() + "'and status !=0";try{

pstmt=con.prepareStatement(sql);

rs=pstmt.executeQuery();if (rs.next() == false)return false;else

return true;

}catch(SQLException e) {//TODO Auto-generated catch block

e.printStackTrace();

}finally{

DBUtil.close(rs, pstmt, con);

}return false;

}public static booleanaddInfo(InfoBean ib) {

Connection con= null;

PreparedStatement pstmt= null;

ResultSet rs= null;try{

con=DBUtil.getConnection();

String sql= "insert into infobean(title,owner,receiver,time,status,result,place,deletestatus,callback) values(?,?,?,?,?,?,?,?,?)";

pstmt=con.prepareStatement(sql);

pstmt.setString(1, ib.getTitle());

pstmt.setString(2, ib.getOwner());

pstmt.setString(3, ib.getReceiver());

pstmt.setString(4, ib.getTime());

pstmt.setInt(5, ib.getStatus());

pstmt.setInt(6, ib.getResult());

pstmt.setString(7, ib.getPlace());

pstmt.setInt(8, 0);

pstmt.setInt(9, 0);

pstmt.executeUpdate();return true;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(rs, pstmt, con);

}return false;

}public static booleandelete_user(user u) {

Connection con= null;

PreparedStatement pstmt= null;try{

con=DBUtil.getConnection();

String sql= "delete from user where id=" +u.getId();

System.out.println(sql);

pstmt=con.prepareStatement(sql);

pstmt.executeUpdate();return true;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(pstmt, con);

}return false;

}public static booleanupdate_user_status(user user) {

Connection con= null;

PreparedStatement pstmt= null;try{

con=DBUtil.getConnection();

String sql= "update user set status = ? where id = ?";

pstmt=con.prepareStatement(sql);

pstmt.setInt(1, user.getStatus());

pstmt.setInt(2, user.getId());

pstmt.executeUpdate();return true;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(pstmt, con);

}return false;

}public static booleanupdate_user(user user) {

Connection con= null;

PreparedStatement pstmt= null;try{

con=DBUtil.getConnection();

String sql= "update user set username=?,password=?,job=? where id = " +user.getId();

pstmt=con.prepareStatement(sql);

pstmt.setString(1, user.getUsername());

pstmt.setString(2, user.getPassword());

pstmt.setString(3, user.getJob());

pstmt.executeUpdate();return true;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(pstmt, con);

}return false;

}

@SuppressWarnings("resource")public static boolean sendDoc(intid) {

Connection con= null;

PreparedStatement pstmt= null;

ResultSet rs= null;int status = -1;int newstatus = -1;

String receiver= "";try{

con=DBUtil.getConnection();

String sql= "select * from infobean where id=" +id;

pstmt=con.prepareStatement(sql);

rs=pstmt.executeQuery();if(rs.next()) {

status= rs.getInt("status");

}switch(status) {case 0:

newstatus= 1;

receiver= "副厂长";break;case 2:

newstatus= 5;

receiver= "厂长";break;case 3:

newstatus= 4;

receiver= "部门";break;case 6:

newstatus= 8;

receiver= "部门和副厂长";break;case 7:

newstatus= 9;

receiver= "部门和副厂长";break;case 8:

newstatus= 10;

receiver= "部门";break;default:

System.out.println("公文状态有误!");break;

}

String sql_update= "update infobean set status = ? where id = ?";

pstmt=con.prepareStatement(sql_update);

pstmt.setInt(1, newstatus);

pstmt.setInt(2, id);

pstmt.executeUpdate();return true;

}catch(SQLException e) {

System.out.println("数据库信息更新失败");

e.printStackTrace();

}finally{

DBUtil.close(pstmt, con);

}return false;

}public static ArrayListgetInfoBychoose(String type, String value) {

Connection connection= null;

PreparedStatement preparedStatement= null;

ResultSet rs= null;try{

connection=DBUtil.getConnection();

String sql= "";

System.out.println(type);if (type.equals("title")) {

sql= "select * from infobean where title='" + value + "'";

}else if (type.equals("owner")) {

sql= "select * from infobean where owner='" + value + "'";

}else if (type.equals("receiver")) {

sql= "select * from infobean where receiver='" + value + "'";

}else if (type.equals("result")) {

sql= "select * from infobean where result='" + value + "'";

}

preparedStatement=connection.prepareStatement(sql);

rs=preparedStatement.executeQuery();

ArrayList list = new ArrayList<>();while(rs.next()) {

InfoBean ib= newInfoBean();

ib.setId(rs.getInt("id"));

ib.setTitle(rs.getString("title"));

ib.setOwner(rs.getString("owner"));

ib.setTime(rs.getString("time"));

ib.setReceiver(rs.getString("receiver"));

ib.setStatus(rs.getInt("status"));

ib.setResult(rs.getInt("result"));

ib.setPlace(rs.getString("place"));

list.add(ib);

}returnlist;

}catch(SQLException e) {//TODO: handle exception

e.printStackTrace();

}finally{

DBUtil.close(rs, preparedStatement, connection);

}return null;

}public static ArrayListgetCheckedOrNotInfo(String type) {

Connection connection= null;

PreparedStatement preparedStatement= null;

ResultSet rs= null;try{

connection=DBUtil.getConnection();

String sql= "";if (type.equals("checked")) {

sql= "select * from infobean where status=6 or status=7";

}else{

sql= "select * from infobean where status=5";

}

preparedStatement=connection.prepareStatement(sql);

rs=preparedStatement.executeQuery();

ArrayList list = new ArrayList<>();while(rs.next()) {

InfoBean ib= newInfoBean();

ib.setId(rs.getInt("id"));

ib.setTitle(rs.getString("title"));

ib.setOwner(rs.getString("owner"));

ib.setTime(rs.getString("time"));

ib.setReceiver(rs.getString("receiver"));

ib.setStatus(rs.getInt("status"));

ib.setResult(rs.getInt("result"));

ib.setPlace(rs.getString("place"));

list.add(ib);

}returnlist;

}catch(SQLException e) {//TODO: handle exception

e.printStackTrace();

}finally{

DBUtil.close(rs, preparedStatement, connection);

}return null;

}public static ArrayListgetCheckedorNot(String str) {

Connection connection= null;

PreparedStatement preparedStatement= null;

ResultSet rs= null;try{

connection=DBUtil.getConnection();

String sql= "";

System.out.println(str);if (str.equals("notchecked")) {

sql= "select * from infobean where status=1";

}else{

sql= "select * from infobean where status!=1 and status!=0 and status!=-1";

}

preparedStatement=connection.prepareStatement(sql);

rs=preparedStatement.executeQuery();

ArrayList list = new ArrayList<>();while(rs.next()) {

InfoBean ib= newInfoBean();

ib.setId(rs.getInt("id"));

ib.setTitle(rs.getString("title"));

ib.setOwner(rs.getString("owner"));

ib.setTime(rs.getString("time"));

ib.setReceiver(rs.getString("receiver"));

ib.setStatus(rs.getInt("status"));

ib.setResult(rs.getInt("result"));

ib.setPlace(rs.getString("place"));

list.add(ib);

}returnlist;

}catch(SQLException e) {//TODO: handle exception

e.printStackTrace();

}finally{

DBUtil.close(rs, preparedStatement, connection);

}return null;

}public static ArrayListgetReceivedInfoByUser(String type, user user) {

Connection connection= null;

PreparedStatement preparedStatement= null;

ResultSet rs= null;try{

connection=DBUtil.getConnection();

String sql= "";if (type.equals("received")) {

sql= "select * from infobean where owner=? and status=10";

}else{

sql= "select * from infobean where owner=? and status!=10";

}

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setString(1, user.getUsername());

rs=preparedStatement.executeQuery();

ArrayList list = new ArrayList<>();while(rs.next()) {

InfoBean doc= newInfoBean();

doc.setId(rs.getInt("id"));

doc.setTitle(rs.getString("title"));

doc.setTime(rs.getString("time"));

doc.setStatus(rs.getInt("status"));

doc.setResult(rs.getInt("result"));

list.add(doc);

}returnlist;

}catch(SQLException e) {//TODO: handle exception

e.printStackTrace();

}finally{

DBUtil.close(rs, preparedStatement, connection);

}return null;

}public staticInfoBean getInfoById(InfoBean ib) {

Connection connection= null;

PreparedStatement preparedStatement= null;

ResultSet rs= null;try{

connection=DBUtil.getConnection();

String sql= "select * from infobean where id=" +ib.getId();

preparedStatement=connection.prepareStatement(sql);

rs=preparedStatement.executeQuery();if(rs.next()) {

ib.setTitle(rs.getString("title"));

ib.setOwner(rs.getString("owner"));

ib.setTime(rs.getString("time"));

ib.setReceiver(rs.getString("receiver"));

ib.setStatus(rs.getInt("status"));

ib.setResult(rs.getInt("result"));

ib.setPlace(rs.getString("place"));

ib.setViceplace(rs.getString("viceplace"));

ib.setPrimaryplace(rs.getString("primaryplace"));returnib;

}

}catch(SQLException e) {//TODO: handle exception

e.printStackTrace();

}finally{

DBUtil.close(rs, preparedStatement, connection);

}return null;

}public static booleanchecked_change(InfoBean ib) {

Connection connection= null;

PreparedStatement preparedStatement= null;

String sql= "update infobean set status = ?,result = ?,receiver = ?,viceplace = ? where id = ?";try{

connection=DBUtil.getConnection();

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setInt(1, ib.getStatus());

preparedStatement.setInt(2, ib.getResult());

preparedStatement.setString(3, ib.getReceiver());

preparedStatement.setString(4, ib.getViceplace());

preparedStatement.setInt(5, ib.getId());

preparedStatement.executeUpdate();return true;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(preparedStatement, connection);

}return false;

}public static booleanunchecked_change(InfoBean ib) {

Connection connection= null;

PreparedStatement preparedStatement= null;

String sql= "update infobean set status = ?,result = ?,receiver = ?,viceplace = ? where id = ?";try{

connection=DBUtil.getConnection();

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setInt(1, ib.getStatus());

preparedStatement.setInt(2, ib.getResult());

preparedStatement.setString(3, ib.getReceiver());

preparedStatement.setString(4, ib.getViceplace());

preparedStatement.setInt(5, ib.getId());

preparedStatement.executeUpdate();return true;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(preparedStatement, connection);

}return false;

}public static booleanformatDoc(InfoBean ib) {

Connection connection= null;

PreparedStatement preparedStatement= null;

String sql_update= "update infobean set status = ? where id = ?";try{

connection=DBUtil.getConnection();

preparedStatement=connection.prepareStatement(sql_update);

preparedStatement.setInt(1, ib.getStatus());

preparedStatement.setInt(2, ib.getId());

preparedStatement.executeUpdate();return true;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(preparedStatement, connection);

}return false;

}public static booleanReceiveInfo(InfoBean ib) {

Connection connection= null;

PreparedStatement preparedStatement= null;

String sql= "update infobean set status = ?,callback = 1 where id = ?";try{

connection=DBUtil.getConnection();

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setInt(1, 10);

preparedStatement.setInt(2, ib.getId());

preparedStatement.executeUpdate();return true;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(preparedStatement, connection);

}return false;

}public static ArrayListgetInfoByTime(InfoBean ib1, InfoBean ib2) {

Connection connection= null;

PreparedStatement preparedStatement= null;

ResultSet rs= null;

String sql= "select * from infobean where time between ? and ?";try{

connection=DBUtil.getConnection();

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setString(1, ib1.getTime());

preparedStatement.setString(2, ib2.getTime());

rs=preparedStatement.executeQuery();

ArrayList list = new ArrayList<>();while(rs.next()) {

InfoBean doc= newInfoBean();

doc.setId(rs.getInt("id"));

doc.setTitle(rs.getString("title"));

doc.setTime(rs.getString("time"));

doc.setOwner(rs.getString("owner"));

list.add(doc);

}returnlist;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(rs, preparedStatement, connection);

}return null;

}public static ArrayListgetAllInfos() {

Connection connection= null;

PreparedStatement preparedStatement= null;

ResultSet rs= null;

String sql= "select * from infobean";try{

connection=DBUtil.getConnection();

preparedStatement=connection.prepareStatement(sql);

rs=preparedStatement.executeQuery();

ArrayList list = new ArrayList<>();while(rs.next()) {

InfoBean ib= newInfoBean();

ib.setId(rs.getInt("id"));

ib.setTitle(rs.getString("title"));

ib.setTime(rs.getString("time"));

ib.setOwner(rs.getString("owner"));

list.add(ib);

}returnlist;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(rs, preparedStatement, connection);

}return null;

}public static ArrayListgetAllUser() {

Connection connection= null;

PreparedStatement preparedStatement= null;

ResultSet rs= null;

String sql= "select * from user";try{

connection=DBUtil.getConnection();

preparedStatement=connection.prepareStatement(sql);

rs=preparedStatement.executeQuery();

ArrayList list = new ArrayList<>();while(rs.next()) {

user user= newuser();

user.setId(rs.getInt("id"));

user.setUsername(rs.getString("username"));

user.setPassword(rs.getString("password"));

user.setPermissionId(rs.getInt("permissionId"));

user.setJob(rs.getString("job"));

user.setStatus(rs.getInt("status"));

list.add(user);

}returnlist;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(rs, preparedStatement, connection);

}return null;

}public staticuser getUserById(user user) {

Connection connection= null;

PreparedStatement preparedStatement= null;

ResultSet rs= null;

String sql= "select * from user where id=" +user.getId();try{

connection=DBUtil.getConnection();

preparedStatement=connection.prepareStatement(sql);

rs=preparedStatement.executeQuery();

user user1= newuser();if(rs.next()) {

user1.setId(rs.getInt("id"));

user1.setUsername(rs.getString("username"));

user1.setPassword(rs.getString("password"));

user1.setPermissionId(rs.getInt("permissionId"));

user1.setStatus(rs.getInt("status"));

user1.setJob(rs.getString("job"));

}returnuser1;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(preparedStatement, connection);

}return null;

}public static ArrayListgetAuthority(authority at) {

Connection connection= null;

PreparedStatement preparedStatement= null;

ResultSet rs= null;

String sql= "select * from permission where id=" +at.getId();try{

connection=DBUtil.getConnection();

preparedStatement=connection.prepareStatement(sql);

rs=preparedStatement.executeQuery();

ArrayList list = new ArrayList<>();while(rs.next()) {

authority at1= newauthority();

at1.setId(rs.getInt("id"));

at1.setAuthority(rs.getInt("authority"));

list.add(at1);

}returnlist;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(rs, preparedStatement, connection);

}return null;

}public static booleandeleteAuthority(authority at) {

Connection con= null;

PreparedStatement pstmt= null;try{

con=DBUtil.getConnection();

String sql= "delete from permission where id=" +at.getId();

pstmt=con.prepareStatement(sql);

pstmt.executeUpdate();return true;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(pstmt, con);

}return false;

}public static booleanupdateAuthority(authority at1, authority at2) {

Connection con= null;

PreparedStatement pstmt= null;try{

con=DBUtil.getConnection();

String sql= "update permission set permission = ? where id = ? and permission = ?";

pstmt=con.prepareStatement(sql);

pstmt.setInt(1, at2.getAuthority());

pstmt.setInt(2, at1.getId());

pstmt.setInt(3, at1.getAuthority());

pstmt.executeUpdate();return true;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(pstmt, con);

}return false;

}publicdao() {//TODO Auto-generated constructor stub

}public static booleanupdatePwd(user user) {

Connection con= null;

PreparedStatement pstmt= null;try{

con=DBUtil.getConnection();

String sql= "update users set password = ? where username = ?";

pstmt=con.prepareStatement(sql);

pstmt.setString(1, user.getPassword());

pstmt.setString(2, user.getUsername());

pstmt.executeUpdate();return true;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(pstmt, con);

}return false;

}public staticuser getUserByUsername(user user) {

Connection connection= null;

PreparedStatement preparedStatement= null;

ResultSet rs= null;

String sql= "select * from user where username='" + user.getUsername() + "'";try{

connection=DBUtil.getConnection();

preparedStatement=connection.prepareStatement(sql);

rs=preparedStatement.executeQuery();

user user1= newuser();if(rs.next()) {

user1.setId(rs.getInt("id"));

user1.setPermissionId(rs.getInt("permissionId"));

System.out.println(user1.getPermissionId());

}returnuser1;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(rs, preparedStatement, connection);

}return null;

}public static booleandeleteInfo(InfoBean ib) {

Connection con= null;

PreparedStatement pstmt= null;try{

con=DBUtil.getConnection();

String sql= "update infobean set deletestatus = ? where id = ?";

pstmt=con.prepareStatement(sql);

pstmt.setInt(1, ib.getDeletestatus());

pstmt.setInt(2, ib.getId());

pstmt.executeUpdate();return true;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(pstmt, con);

}return false;

}public static ArrayListgetCall() {

Connection connection= null;

PreparedStatement preparedStatement= null;

ResultSet rs= null;try{

connection=DBUtil.getConnection();

String sql= "select * from infobean where callback=1";

preparedStatement=connection.prepareStatement(sql);

rs=preparedStatement.executeQuery();

ArrayList list = new ArrayList<>();while(rs.next()) {

InfoBean ib= newInfoBean();

ib.setId(rs.getInt("id"));

ib.setTitle(rs.getString("title"));

ib.setOwner(rs.getString("owner"));

ib.setTime(rs.getString("time"));

ib.setReceiver(rs.getString("receiver"));

ib.setStatus(rs.getInt("status"));

ib.setResult(rs.getInt("result"));

ib.setPlace(rs.getString("place"));

ib.setDeletestatus(rs.getInt("deletestatus"));

ib.setCallback(rs.getInt("callback"));

list.add(ib);

}returnlist;

}catch(SQLException e) {//TODO: handle exception

e.printStackTrace();

}finally{

DBUtil.close(rs, preparedStatement, connection);

}return null;

}public static booleansetCallOver(InfoBean ib) {

Connection con= null;

PreparedStatement pstmt= null;try{

con=DBUtil.getConnection();

String sql= "update infobean set callback = ? where id = ?";

pstmt=con.prepareStatement(sql);

pstmt.setInt(1, 0);

pstmt.setInt(2, ib.getId());

pstmt.executeUpdate();return true;

}catch(SQLException e) {

e.printStackTrace();

}finally{

DBUtil.close(pstmt, con);

}return false;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值