返回顶部

一缕半夏微光

温柔半两,从容一生

导航

公文流转系统③|办公室功能页

一、效果如下:

二、SQL语句

delete_document表:

 1 -- ----------------------------
 2 -- Table structure for `delete_document`
 3 -- ----------------------------
 4 DROP TABLE IF EXISTS `delete_document`;
 5 CREATE TABLE `delete_document` (
 6   `id` int(11) NOT NULL AUTO_INCREMENT,
 7   `title` varchar(255) DEFAULT NULL,
 8   `content` varchar(255) DEFAULT NULL,
 9   `time` varchar(255) DEFAULT NULL,
10   `createPeople` varchar(255) DEFAULT NULL,
11   `viceFactoryAgree` varchar(255) DEFAULT NULL,
12   `viceFactoryOpinion` varchar(255) DEFAULT NULL,
13   `factoryAgree` varchar(255) DEFAULT NULL,
14   `factoryOpinion` varchar(255) DEFAULT NULL,
15   `receiver` varchar(255) DEFAULT NULL,
16   PRIMARY KEY (`id`)
17 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
18 
19 -- ----------------------------
20 -- Records of delete_document
21 -- ----------------------------
22 INSERT INTO `delete_document` VALUES ('1', '销售部公文1修改1', '销售部公文内容鸭已修改一遍', '2021-09-20', 'xs', '不同意', '1', null, null, '副厂长审核完毕');

三、代码如下:

(1)Office.jsp

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <!DOCTYPE html>
 4 <html>
 5 <head>
 6 <meta charset="UTF-8">
 7 <title>办公室功能页</title>
 8 <link rel="stylesheet" href=".//layui/css/layui.css" media="all">
 9 <script src=".//layui/layui.all.js"></script>
10 <script src=".//layui/layui.js"></script>
11 <script type="text/javascript">
12     //JavaScript代码区域
13     layui.use('element', function() {
14         var element = layui.element;
15     });
16 </script>
17 </head>
18 <body class="layui-layout-body">
19 
20     <div class="layui-layout layui-layout-admin">
21         <div class="layui-header">
22             <div class="layui-logo">
23                 <%
24                 String department = (String) session.getAttribute("department");
25                 out.print(department);
26                 %>
27                 功能页欢迎
28                 <%
29                 String username = (String) session.getAttribute("username");
30                 out.print(username);
31                 %>
32             </div>
33             <!-- 水平导航 -->
34              <ul class="layui-nav layui-layout-right">
35                  <li class="layui-nav-item "><a href="index.jsp">退出</a></li>
36              </ul>
37         </div>
38 
39         <div class="layui-side layui-bg-black">
40             <div class="layui-side-scroll">
41                 <!-- 左侧导航 -->
42                 <ul class="layui-nav layui-nav-tree">
43                     <li class="layui-nav-item"><a
44                         href="OfficeServlet?method=Office_alter_document" target="frame">修改公文</a></li>
45                     <li class="layui-nav-item"><a
46                         href="OfficeServlet?method=Office_flow_document" target="frame">公文流转</a></li>
47                         <li class="layui-nav-item"><a
48                         href="OfficeServlet?method=Office_delete_document" target="frame">删除公文</a></li>
49                 </ul>
50             </div>
51         </div>
52         <div class="layui-body">
53             <!-- 内容主体区域 -->
54             <iframe name="frame" width="100%" height="100%"
55                 style="border: 1px solid #CCC;"></iframe>
56         </div>
57         <div>
58             <div>
59                 <input type="text" id="date" />
60             </div>
61         </div>
62     </div>
63 
64 </body>
65 </html>

(2)Office_document_flow.jsp

 1 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 2 <%@ page language="java" contentType="text/html; charset=UTF-8"
 3     pageEncoding="UTF-8"%>
 4 <!DOCTYPE html>
 5 <html>
 6 <head>
 7 <meta charset="UTF-8">
 8 <title>公文流转</title>
 9 <link rel="stylesheet" href=".//layui/css/layui.css" media="all">
10 <script src=".//layui/layui.all.js"></script>
11 <script src=".//layui/layui.js"></script>
12 </head>
13 <body>
14         <table class="layui-table">
15         <thead>
16             <tr>
17                 <th>id</th>
18                 <th>公文标题</th>
19                 <th>创建人</th>
20                 <th>副厂长是否同意</th>
21                 <th>厂长是否同意</th>
22                 <th>接收情况</th>
23                 <th>流转按钮</th>
24             </tr>
25         </thead>
26         <tbody>
27             <c:forEach items="${list}" var="document" varStatus="status">
28                 <tr>
29                     <td>${ status.index + 1}</td>
30                     <td>${document.title}</td>
31                     <td>${document.createPeople}</td>
32                     <td>${document.viceFactoryAgree}</td>
33                     <td>${document.factoryAgree}</td>
34                     <td>${document.receiver}</td>
35                     <td>
36                     <button class="layui-btn layui-btn-normal"
37                             onclick="window.location.href='OfficeServlet?method=flow_viceFactory&createPeople=${document.createPeople}&title=${document.title}'">副厂长</button>
38                     <button class="layui-btn layui-btn-warm"
39                             onclick="window.location.href='OfficeServlet?method=flow_factory&createPeople=${document.createPeople}&title=${document.title}&viceFactoryAgree=${document.viceFactoryAgree}'">厂长</button>
40                     <button class="layui-btn"
41                             onclick="window.location.href='OfficeServlet?method=flow_department&createPeople=${document.createPeople}&title=${document.title}&viceFactoryAgree=${document.viceFactoryAgree}&factoryAgree=${document.factoryAgree}'">部门</button>
42                     </td>
43                 </tr>
44             </c:forEach>
45         </tbody>
46     </table>
47 </body>
48 </html>

(3)Office_delete_document.jsp

 1 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 2 <%@ page language="java" contentType="text/html; charset=UTF-8"
 3     pageEncoding="UTF-8"%>
 4 <!DOCTYPE html>
 5 <html>
 6 <head>
 7 <meta charset="UTF-8">
 8 <title>删除公文</title>
 9 <link rel="stylesheet" href=".//layui/css/layui.css" media="all">
10 <script src=".//layui/layui.all.js"></script>
11 <script src=".//layui/layui.js"></script>
12 </head>
13 <body>
14         <table class="layui-table">
15         <thead>
16             <tr>
17                 <th>id</th>
18                 <th>公文标题</th>
19                 <th>创建人</th>
20                 <th>副厂长是否同意</th>
21                 <th>厂长是否同意</th>
22                 <th>操作</th>
23             </tr>
24         </thead>
25         <tbody>
26             <c:forEach items="${list}" var="document" varStatus="status">
27                 <tr>
28                     <td>${ status.index + 1}</td>
29                     <td>${document.title}</td>
30                     <td>${document.createPeople}</td>
31                     <td>${document.viceFactoryAgree}</td>
32                     <td>${document.factoryAgree}</td>
33                     <td>
34                     <button class="layui-btn layui-btn-normal"
35                             onclick="window.location.href='OfficeServlet?method=delete_document&title=${document.title}'">删除</button>
36                     </td>
37                 </tr>
38             </c:forEach>
39         </tbody>
40     </table>
41 </body>
42 </html>

(4)Office_alter_show_document.jsp

 1 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 2 <%@ page language="java" contentType="text/html; charset=UTF-8"
 3     pageEncoding="UTF-8"%>
 4 <!DOCTYPE html>
 5 <html>
 6 <head>
 7 <meta charset="UTF-8">
 8 <title>修改公文</title>
 9 <link rel="stylesheet" href=".//layui/css/layui.css" media="all">
10 <script src=".//layui/layui.all.js"></script>
11 <script src=".//layui/layui.js"></script>
12 </head>
13 <body>
14     <form class="layui-form" action="OfficeServlet?method=Office_update_document" method="post">
15         <c:forEach items="${list}" var="document">
16             <div class="layui-form-item">
17                 <label class="layui-form-label">公文标题</label>
18                 <div class="layui-input-block">
19                     <input type="text" name="title" required lay-verify="required"
20                         placeholder="请输入公文标题" autocomplete="off" class="layui-input"
21                         value="${document.title}"> <input type="hidden"
22                         name="judgetitle" required lay-verify="required"
23                         placeholder="请输入公文标题" autocomplete="off" class="layui-input"
24                         value="${document.title}">
25                 </div>
26             </div>
27             <div class="layui-form-item layui-form-text">
28                 <label class="layui-form-label">公文内容</label>
29                 <div class="layui-input-block">
30                     <textarea name="content" placeholder="请输入公文内容"
31                         class="layui-textarea">${document.content}</textarea>
32                 </div>
33             </div>
34             <div class="layui-form-item">
35                 <label class="layui-form-label">时间</label>
36                 <div class="layui-inline">
37                     <!-- 注意:这一层元素并不是必须的 -->
38                     <input type="text" class="layui-input" id="time" name="time"
39                         value="${document.time}">
40                 </div>
41             </div>
42             <div class="layui-form-item">
43                 <label class="layui-form-label">创建人</label>
44                 <div class="layui-input-block">
45                     <input type="text" name="createPeople" required
46                         lay-verify="required" placeholder="请输入您的账号" autocomplete="off"
47                         class="layui-input" value="${document.createPeople}">
48                 </div>
49             </div>
50             <div class="layui-form-item">
51                 <div class="layui-input-block">
52                     <button class="layui-btn" lay-submit>修改</button>
53                     <button type="reset" class="layui-btn layui-btn-primary">重置</button>
54                 </div>
55             </div>
56         </c:forEach>
57     </form>
58     <script>
59         layui.use('laydate', function() {
60             var laydate = layui.laydate;
61             //执行一个laydate实例
62             laydate.render({
63                 elem : '#time' //指定元素
64             });
65         });
66     </script>
67 </body>
68 </html>

(5)Office_alter_document.jsp

 1 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 2 <%@ page language="java" contentType="text/html; charset=UTF-8"
 3     pageEncoding="UTF-8"%>
 4 <!DOCTYPE html>
 5 <html>
 6 <head>
 7 <meta charset="UTF-8">
 8 <title>修改公文</title>
 9 <link rel="stylesheet" href=".//layui/css/layui.css" media="all">
10 <script src=".//layui/layui.all.js"></script>
11 <script src=".//layui/layui.js"></script>
12 </head>
13 <body>
14     <table class="layui-table">
15         <colgroup>
16             <col width="150">
17             <col width="200">
18             <col>
19         </colgroup>
20         <thead>
21             <tr>
22                 <th>id</th>
23                 <th>公文标题</th>
24                 <th>公文内容</th>
25                 <th>时间</th>
26                 <th>创建人</th>
27                 <th>操作</th>
28             </tr>
29         </thead>
30         <tbody>
31             <c:forEach items="${list}" var="document" varStatus="status">
32                 <tr>
33                     <td>${ status.index + 1}</td>
34                     <td>${document.title}</td>
35                     <td>${document.content}</td>
36                     <td>${document.time}</td>
37                     <td>${document.createPeople}</td>
38                     <td><button class="layui-btn layui-btn-normal"
39                             onclick="window.location.href='OfficeServlet?method=Office_alter_show_document&title=${document.title}'">修改</button></td>
40                 </tr>
41             </c:forEach>
42         </tbody>
43     </table>
44 </body>
45 </html>

(6)OfficeServlet.java

  1 package servlet;
  2 
  3 import java.io.IOException;
  4 import java.util.List;
  5 
  6 import javax.servlet.ServletException;
  7 import javax.servlet.annotation.WebServlet;
  8 import javax.servlet.http.HttpServlet;
  9 import javax.servlet.http.HttpServletRequest;
 10 import javax.servlet.http.HttpServletResponse;
 11 
 12 import dao.OfficeDao;
 13 import util.Document;
 14 import util.User;
 15 
 16 /**
 17  * Servlet implementation class OfficeServlet
 18  */
 19 @WebServlet("/OfficeServlet")
 20 public class OfficeServlet extends HttpServlet {
 21     private static final long serialVersionUID = 1L;
 22 
 23     /**
 24      * @see HttpServlet#HttpServlet()
 25      */
 26     public OfficeServlet() {
 27         super();
 28         // TODO Auto-generated constructor stub
 29     }
 30 
 31     OfficeDao dao = new OfficeDao();
 32 
 33     /**
 34      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
 35      *      response)
 36      */
 37     protected void doGet(HttpServletRequest request, HttpServletResponse response)
 38             throws ServletException, IOException {
 39         // TODO Auto-generated method stub
 40         // response.getWriter().append("Served at: ").append(request.getContextPath());
 41         doPost(request, response);
 42     }
 43 
 44     /**
 45      * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
 46      *      response)
 47      */
 48     protected void doPost(HttpServletRequest request, HttpServletResponse response)
 49             throws ServletException, IOException {
 50         // TODO Auto-generated method stub
 51         // doGet(request, response);
 52 
 53         request.setCharacterEncoding("utf-8");
 54         response.setCharacterEncoding("utf-8");
 55 
 56         System.out.println("进入OfficeServlet");
 57         String method = request.getParameter("method");
 58         System.out.println(method);
 59         if ("Office_alter_document".equals(method)) {
 60             Office_alter_document(request, response);
 61         } else if ("Office_alter_show_document".equals(method)) {
 62             Office_alter_show_document(request, response);
 63         } else if ("Office_update_document".equals(method)) {
 64             Office_update_document(request, response);
 65         } else if ("Office_flow_document".equals(method)) {
 66             Office_flow_document(request, response);
 67         } else if ("flow_viceFactory".equals(method)) {
 68             flow_viceFactory(request, response);
 69         } else if ("flow_factory".equals(method)) {
 70             flow_factory(request, response);
 71         } else if ("Office_delete_document".equals(method)) {
 72             Office_delete_document(request, response);
 73         } else if ("delete_document".equals(method)) {
 74             delete_document(request, response);
 75         } else if ("flow_department".equals(method)) {
 76             flow_department(request, response);
 77         }
 78     }
 79 
 80     public void Office_alter_document(HttpServletRequest request, HttpServletResponse response)
 81             throws ServletException, IOException {
 82         response.setCharacterEncoding("UTF-8");
 83         request.setCharacterEncoding("UTF-8");
 84 
 85         List<Document> list = dao.Office_alter_document();
 86         request.setAttribute("list", list);
 87         request.getRequestDispatcher("Office_alter_document.jsp").forward(request, response);
 88 
 89     }
 90 
 91     public void Office_alter_show_document(HttpServletRequest request, HttpServletResponse response)
 92             throws ServletException, IOException {
 93         response.setCharacterEncoding("UTF-8");
 94         request.setCharacterEncoding("UTF-8");
 95 
 96         String title = request.getParameter("title");
 97         List<Document> list = dao.Office_alter_show_document(title);
 98         request.setAttribute("list", list);
 99         request.getRequestDispatcher("Office_alter_show_document.jsp").forward(request, response);
100 
101     }
102 
103     public void Office_update_document(HttpServletRequest request, HttpServletResponse response)
104             throws ServletException, IOException {
105         response.setCharacterEncoding("UTF-8");
106         request.setCharacterEncoding("UTF-8");
107 
108         String title = request.getParameter("title");
109         String judgetitle = request.getParameter("judgetitle");
110         String content = request.getParameter("content");
111         String time = request.getParameter("time");
112         String createPeople = request.getParameter("createPeople");
113 
114         Document document = new Document(title, content, time, createPeople);
115 
116         if (dao.Office_update_document(document, judgetitle)) {
117             request.getRequestDispatcher("OfficeServlet?method=Office_alter_document").forward(request, response);
118         } else {
119             request.getRequestDispatcher("TestFail.jsp").forward(request, response);
120         }
121 
122     }
123 
124     public void Office_flow_document(HttpServletRequest request, HttpServletResponse response)
125             throws ServletException, IOException {
126         response.setCharacterEncoding("UTF-8");
127         request.setCharacterEncoding("UTF-8");
128 
129         List<Document> list = dao.Office_flow_document();
130         request.setAttribute("list", list);
131         request.getRequestDispatcher("Office_document_flow.jsp").forward(request, response);
132 
133     }
134 
135     public void flow_viceFactory(HttpServletRequest request, HttpServletResponse response)
136             throws ServletException, IOException {
137         response.setCharacterEncoding("UTF-8");
138         request.setCharacterEncoding("UTF-8");
139 
140         String createPeople = request.getParameter("createPeople");
141         String title = request.getParameter("title");
142         System.out.println(createPeople);
143         System.out.println(title);
144         if (dao.flow_viceFactory(createPeople, title)) {
145             request.getRequestDispatcher("OfficeServlet?method=Office_flow_document").forward(request, response);
146         } else {
147             request.getRequestDispatcher("TestFail.jsp").forward(request, response);
148         }
149 
150     }
151 
152     public void flow_factory(HttpServletRequest request, HttpServletResponse response)
153             throws ServletException, IOException {
154         response.setCharacterEncoding("UTF-8");
155         request.setCharacterEncoding("UTF-8");
156 
157         String createPeople = request.getParameter("createPeople");
158         String title = request.getParameter("title");
159         String viceFactoryAgree = request.getParameter("viceFactoryAgree");
160         System.out.println(createPeople);
161         System.out.println(title);
162         System.out.println(viceFactoryAgree);
163         if (viceFactoryAgree.equals("同意")) {
164             if (dao.flow_factory(title)) {
165                 request.getRequestDispatcher("OfficeServlet?method=Office_flow_document").forward(request, response);
166             } else {
167                 request.getRequestDispatcher("TestFail.jsp").forward(request, response);
168             }
169         } else {
170             System.out.println("清先让副厂长同意!");
171             request.getRequestDispatcher("OfficeServlet?method=Office_flow_document").forward(request, response);
172         }
173 
174     }
175 
176     public void Office_delete_document(HttpServletRequest request, HttpServletResponse response)
177             throws ServletException, IOException {
178         response.setCharacterEncoding("UTF-8");
179         request.setCharacterEncoding("UTF-8");
180 
181         List<Document> list = dao.Office_delete_document();
182         request.setAttribute("list", list);
183         request.getRequestDispatcher("Office_delete_document.jsp").forward(request, response);
184 
185     }
186 
187     public void delete_document(HttpServletRequest request, HttpServletResponse response)
188             throws ServletException, IOException {
189         response.setCharacterEncoding("UTF-8");
190         request.setCharacterEncoding("UTF-8");
191 
192         String title = request.getParameter("title");
193         if (dao.delete_document(title)) {
194             request.getRequestDispatcher("OfficeServlet?method=Office_delete_document").forward(request, response);
195         } else {
196             request.getRequestDispatcher("TestFail.jsp").forward(request, response);
197         }
198 
199     }
200 
201     public void flow_department(HttpServletRequest request, HttpServletResponse response)
202             throws ServletException, IOException {
203         response.setCharacterEncoding("UTF-8");
204         request.setCharacterEncoding("UTF-8");
205 
206         String createPeople = request.getParameter("createPeople");
207         String title = request.getParameter("title");
208         String viceFactoryAgree = request.getParameter("viceFactoryAgree");
209         String factoryAgree = request.getParameter("factoryAgree");
210         System.out.println(createPeople);
211         System.out.println(title);
212         System.out.println(viceFactoryAgree);
213         System.out.println(factoryAgree);
214         if (viceFactoryAgree.equals("同意")) {
215             if (factoryAgree.equals("同意")) {
216                 if (dao.flow_department(title)) {
217                     request.getRequestDispatcher("OfficeServlet?method=Office_flow_document").forward(request,
218                             response);
219                 } else {
220                     request.getRequestDispatcher("TestFail.jsp").forward(request, response);
221                 }
222             } else {
223                 System.out.println("清先让厂长同意!");
224                 request.getRequestDispatcher("OfficeServlet?method=Office_flow_document").forward(request, response);
225             }
226         } else {
227             System.out.println("清先让副厂长同意!");
228             request.getRequestDispatcher("OfficeServlet?method=Office_flow_document").forward(request, response);
229         }
230 
231     }
232 }

(7)OfficeDao.java

  1 package dao;
  2 
  3 import java.sql.Connection;
  4 import java.sql.PreparedStatement;
  5 import java.sql.ResultSet;
  6 import java.util.ArrayList;
  7 import java.util.List;
  8 
  9 import database.Database;
 10 import util.Document;
 11 
 12 public class OfficeDao {
 13     /**
 14      * 修改功能
 15      * @return
 16      */
 17     public List<Document> Office_alter_document(){
 18         List<Document> list=new ArrayList<>();
 19         Connection conn=null;
 20         ResultSet rs=null;
 21         PreparedStatement pstm=null;
 22         Document document=null;
 23         try {
 24             conn=Database.getConnection();
 25             String sql="select * from document";
 26             pstm=conn.prepareStatement(sql);
 27             rs=pstm.executeQuery();
 28             while(rs.next()) {
 29                 String title=rs.getString("title");
 30                 String content=rs.getString("content");
 31                 String time=rs.getString("time");
 32                 String createPeople=rs.getString("createPeople");
 33                 document=new Document(title,content,time,createPeople);
 34                 list.add(document);
 35             }
 36         }catch(Exception e) {
 37             e.printStackTrace();
 38         }finally {
 39             Database.close(conn, pstm, rs);
 40         }
 41         return list;
 42     }
 43     /**
 44      * 修改界面show
 45      * @param title
 46      * @return
 47      */
 48     public List<Document> Office_alter_show_document(String title){
 49         List<Document> list=new ArrayList<>();
 50         Connection conn=null;
 51         ResultSet rs=null;
 52         PreparedStatement pstm=null;
 53         Document document=null;
 54         try {
 55             conn=Database.getConnection();
 56             String sql="select * from document where title=?";
 57             pstm=conn.prepareStatement(sql);
 58             pstm.setString(1,title);
 59             rs=pstm.executeQuery();
 60             while(rs.next()) {
 61                 String titlee=rs.getString("title");
 62                 String content=rs.getString("content");
 63                 String time=rs.getString("time");
 64                 String createPeople=rs.getString("createPeople");
 65                 document=new Document(titlee,content,time,createPeople);
 66                 System.out.println(content);
 67                 list.add(document);
 68             }
 69         }catch(Exception e) {
 70             e.printStackTrace();
 71         }finally {
 72             Database.close(conn, pstm, rs);
 73         }
 74         return list;
 75     }
 76     /**
 77      * 修改更新
 78      * @param document
 79      * @param judgetitle
 80      * @return
 81      */
 82     public boolean Office_update_document(Document document,String judgetitle) {
 83         Connection conn=null;
 84         PreparedStatement pstm=null;
 85         boolean judge=false;
 86         try {
 87             conn=Database.getConnection();
 88             String sql="update document set title=?,content=?,time=?,createPeople=? where title=?";
 89             pstm=conn.prepareStatement(sql);
 90             pstm.setString(1, document.getTitle());
 91             pstm.setString(2, document.getContent());
 92             pstm.setString(3, document.getTime());
 93             pstm.setString(4, document.getCreatePeople());
 94             pstm.setString(5, judgetitle);
 95             //执行插入操作
 96             int num=pstm.executeUpdate();
 97             if(num>0) {
 98                 System.out.println("修改成功");
 99                 judge=true;
100             }else {
101                 System.out.println("修改失败");
102                 judge=false;
103             }
104         }catch(Exception e) {
105             e.printStackTrace();
106         }finally {
107             //SQL执行完成后释放相关资源
108             Database.close(conn,pstm);
109         }
110         return judge;
111     }
112     /**
113      * 公文流转
114      * @return
115      */
116     public List<Document> Office_flow_document(){
117         List<Document> list=new ArrayList<>();
118         Connection conn=null;
119         ResultSet rs=null;
120         PreparedStatement pstm=null;
121         Document document=null;
122         try {
123             conn=Database.getConnection();
124             String sql="select * from document";
125             pstm=conn.prepareStatement(sql);
126             rs=pstm.executeQuery();
127             while(rs.next()) {
128                 String title=rs.getString("title");
129                 String content=rs.getString("content");
130                 String time=rs.getString("time");
131                 String createPeople=rs.getString("createPeople");
132                 String viceFactoryAgree=rs.getString("viceFactoryAgree");
133                 String factoryAgree=rs.getString("factoryAgree");
134                 String receiver=rs.getString("receiver");
135                 document=new Document(title,content,time,createPeople,viceFactoryAgree,factoryAgree,receiver);
136                 list.add(document);
137             }
138         }catch(Exception e) {
139             e.printStackTrace();
140         }finally {
141             Database.close(conn, pstm, rs);
142         }
143         return list;
144     }
145     /**
146      * 副厂长
147      * @param createPeople
148      * @param title
149      * @return
150      */
151     public boolean flow_viceFactory(String createPeople,String title) {
152         Connection conn=null;
153         PreparedStatement pstm=null;
154         PreparedStatement pstm1=null;
155         ResultSet rs=null;
156         boolean judge=false;
157         String department="null";
158         String receiver;
159         try {
160             conn=Database.getConnection();
161             String sql="select department from user where name=?";
162             pstm=conn.prepareStatement(sql);
163             pstm.setString(1, createPeople);
164             rs=pstm.executeQuery();
165             while(rs.next()) {
166                 department=rs.getString("department");
167             }
168             System.out.println(department);
169             
170             if(department.equals("销售部")) {
171                 receiver="副厂长-销售部待同意";
172             }else if(department.equals("财务部")) {
173                 receiver="副厂长-财务部待同意";
174             }else if(department.equals("生产部主厂区")||department.equals("生产部一分厂")||department.equals("生产部二分厂")||department.equals("生产部三分厂")) {
175                 receiver="副厂长-生产部待同意";
176             }else {
177                 receiver="error";
178             }
179             
180             try {
181                 if(receiver.equals("error!")) {
182                     System.out.println("error!");
183                     judge=false;
184                 }else {
185                     String sql1="update document set receiver=? where createPeople=? and title=?";
186                     pstm1=conn.prepareStatement(sql1);
187                     pstm1.setString(1, receiver);
188                     pstm1.setString(2, createPeople);
189                     pstm1.setString(3, title);
190                     //执行插入操作
191                     int num=pstm1.executeUpdate();
192                     if(num>0) {
193                         System.out.println("流转副厂长成功");
194                         judge=true;
195                     }else {
196                         System.out.println("流转副厂长失败");
197                         judge=false;
198                     }
199                 }
200             }catch(Exception e) {
201                 e.printStackTrace();
202             }
203             
204         }catch(Exception e) {
205             e.printStackTrace();
206         }finally {
207             //SQL执行完成后释放相关资源
208             Database.close(conn,pstm);
209         }
210         return judge;
211     }
212     /**
213      * 厂长
214      * @param createPeople
215      * @param title
216      * @return
217      */
218     public boolean flow_factory(String title) {
219         Connection conn=null;
220         PreparedStatement pstm=null;
221         boolean judge=false;
222         String receiver="厂长待同意";
223         try {
224             conn=Database.getConnection();
225             String sql="update document set receiver=? where title=?";
226             pstm=conn.prepareStatement(sql);
227             pstm.setString(1, receiver);
228             pstm.setString(2, title);
229             //执行插入操作
230             int num=pstm.executeUpdate();
231             if(num>0) {
232                 System.out.println("流转厂长成功");
233                 judge=true;
234             }else {
235                 System.out.println("流转厂长失败");
236                 judge=false;
237             }    
238         }catch(Exception e) {
239             e.printStackTrace();
240         }finally {
241             //SQL执行完成后释放相关资源
242             Database.close(conn,pstm);
243         }
244         return judge;
245     }
246     /**
247      * 删除公文
248      * @return
249      */
250     public List<Document> Office_delete_document(){
251         List<Document> list=new ArrayList<>();
252         Connection conn=null;
253         ResultSet rs=null;
254         PreparedStatement pstm=null;
255         Document document=null;
256         try {
257             conn=Database.getConnection();
258             String sql="select * from document where viceFactoryAgree=? or factoryAgree=?";
259             pstm=conn.prepareStatement(sql);
260             pstm.setString(1, "不同意");
261             pstm.setString(2, "不同意");
262             rs=pstm.executeQuery();
263             while(rs.next()) {
264                 String title=rs.getString("title");
265                 String content=rs.getString("content");
266                 String time=rs.getString("time");
267                 String createPeople=rs.getString("createPeople");
268                 String viceFactoryAgree=rs.getString("viceFactoryAgree");
269                 String factoryAgree=rs.getString("factoryAgree");
270                 String receiver=rs.getString("receiver");
271                 document=new Document(title,content,time,createPeople,viceFactoryAgree,factoryAgree,receiver);
272                 list.add(document);
273             }
274         }catch(Exception e) {
275             e.printStackTrace();
276         }finally {
277             Database.close(conn, pstm, rs);
278         }
279         return list;
280     }
281     /**
282      * 通过标题,查询公文的所有内容,并插入到删除表中,方便删除
283      * @param title
284      * @return
285      */
286     public List<Document> Office_flow_document(String title){
287         List<Document> list=new ArrayList<>();
288         Connection conn=null;
289         ResultSet rs=null;
290         PreparedStatement pstm=null;
291         PreparedStatement pstm1=null;
292         Document document=null;
293         try {
294             conn=Database.getConnection();
295             String sql="select * from document where title=?";
296             pstm=conn.prepareStatement(sql);
297             pstm.setString(1, title);
298             rs=pstm.executeQuery();
299             while(rs.next()) {
300                 String titlee=rs.getString("title");
301                 String content=rs.getString("content");
302                 String time=rs.getString("time");
303                 String createPeople=rs.getString("createPeople");
304                 String viceFactoryAgree=rs.getString("viceFactoryAgree");
305                 String viceFactoryOpinion=rs.getString("viceFactoryOpinion");
306                 String factoryAgree=rs.getString("factoryAgree");
307                 String factoryOpinion=rs.getString("factoryOpinion");
308                 String receiver=rs.getString("receiver");
309                 document=new Document(titlee,content,time,createPeople,viceFactoryAgree,viceFactoryOpinion,factoryAgree,factoryOpinion,receiver);
310                 list.add(document);
311             }
312             try {
313                 String sql1="insert into delete_document(title,content,time,createPeople,viceFactoryAgree,viceFactoryOpinion,factoryAgree,factoryOpinion,receiver) values(?,?,?,?,?,?,?,?,?)";
314                 System.out.println(sql1);
315                 pstm1=conn.prepareStatement(sql1);
316                 pstm1.setString(1, document.getTitle());
317                 pstm1.setString(2, document.getContent());
318                 pstm1.setString(3, document.getTime());
319                 pstm1.setString(4, document.getCreatePeople());
320                 pstm1.setString(5, document.getViceFactoryAgree());
321                 pstm1.setString(6, document.getViceFactoryOpinion());
322                 pstm1.setString(7, document.getFactoryAgree());
323                 pstm1.setString(8, document.getFactoryOpinion());
324                 pstm1.setString(9, document.getReceiver());
325                 //执行插入操作
326                 int num1=pstm1.executeUpdate();
327                 if(num1>0) {
328                     System.out.println("放入删除表中成功");
329                 }else {
330                     System.out.println("放入删除表中失败");
331                 }
332             }catch(Exception e) {
333                 e.printStackTrace();
334             }
335         }catch(Exception e) {
336             e.printStackTrace();
337         }finally {
338             Database.close(conn, pstm, rs);
339         }
340         return list;
341     }
342     /**
343      * 删除公文
344      * @param document
345      * @param judgetitle
346      * @return
347      */
348     public boolean delete_document(String title) {
349         Connection conn=null;
350         PreparedStatement pstm=null;
351         ResultSet rs=null;
352         boolean judge=false;
353         try {
354             Office_flow_document(title);
355             conn=Database.getConnection();
356             String sql="delete from document where title=?";
357             pstm=conn.prepareStatement(sql);
358             pstm.setString(1, title);
359             int num=pstm.executeUpdate();
360             if(num>0) {
361                 System.out.println("删除成功");
362                 judge=true;
363             }else {
364                 System.out.println("删除失败");
365                 judge=false;
366             }
367         }catch(Exception e) {
368             e.printStackTrace();
369         }finally {
370             //SQL执行完成后释放相关资源
371             Database.close(conn,pstm,rs);
372         }
373         return judge;
374     }
375     /**
376      * 流转部门
377      * @param title
378      * @return
379      */
380     public boolean flow_department(String title) {
381         Connection conn=null;
382         PreparedStatement pstm=null;
383         boolean judge=false;
384         String receiver="部门待签收";
385         try {
386             conn=Database.getConnection();
387             String sql="update document set receiver=? where title=?";
388             pstm=conn.prepareStatement(sql);
389             pstm.setString(1, receiver);
390             pstm.setString(2, title);
391             //执行插入操作
392             int num=pstm.executeUpdate();
393             if(num>0) {
394                 System.out.println("流转部门成功");
395                 judge=true;
396             }else {
397                 System.out.println("流转部门失败");
398                 judge=false;
399             }    
400         }catch(Exception e) {
401             e.printStackTrace();
402         }finally {
403             //SQL执行完成后释放相关资源
404             Database.close(conn,pstm);
405         }
406         return judge;
407     }
408     
409 }

(8)Delete.java

 1 package util;
 2 
 3 public class Delete {
 4     private String title;
 5     private String content;
 6     private String time;
 7     private String createPeople;
 8     private String viceFactoryAgree;
 9     private String viceFactoryOpinion;
10     private String factoryAgree;
11     private String factoryOpinion;
12     private String receiver;
13     public Delete() {
14         super();
15     }
16     public Delete(String title, String content, String time, String createPeople, String viceFactoryAgree,
17             String factoryAgree, String receiver) {
18         // TODO Auto-generated constructor stub
19         super();
20         this.title=title;
21         this.content=content;
22         this.time=time;
23         this.createPeople=createPeople;
24         this.receiver=receiver;
25         this.viceFactoryAgree=viceFactoryAgree;
26         this.factoryAgree=factoryAgree;
27         this.receiver=receiver;
28     }
29     public String getTitle() {
30         return title;
31     }
32     public void setTitle(String title) {
33         this.title = title;
34     }
35     public String getContent() {
36         return content;
37     }
38     public void setContent(String content) {
39         this.content = content;
40     }
41     public String getTime() {
42         return time;
43     }
44     public void setTime(String time) {
45         this.time = time;
46     }
47     public String getCreatePeople() {
48         return createPeople;
49     }
50     public void setCreatePeople(String createPeople) {
51         this.createPeople = createPeople;
52     }
53     public String getViceFactoryAgree() {
54         return viceFactoryAgree;
55     }
56     public void setViceFactoryAgree(String viceFactoryAgree) {
57         this.viceFactoryAgree = viceFactoryAgree;
58     }
59     public String getViceFactoryOpinion() {
60         return viceFactoryOpinion;
61     }
62     public void setViceFactoryOpinion(String viceFactoryOpinion) {
63         this.viceFactoryOpinion = viceFactoryOpinion;
64     }
65     public String getFactoryAgree() {
66         return factoryAgree;
67     }
68     public void setFactoryAgree(String factoryAgree) {
69         this.factoryAgree = factoryAgree;
70     }
71     public String getFactoryOpinion() {
72         return factoryOpinion;
73     }
74     public void setFactoryOpinion(String factoryOpinion) {
75         this.factoryOpinion = factoryOpinion;
76     }
77     public String getReceiver() {
78         return receiver;
79     }
80     public void setReceiver(String receiver) {
81         this.receiver = receiver;
82     }
83 }

 

posted on 2021-09-22 17:00  一缕半夏微光  阅读(74)  评论(0编辑  收藏  举报