期刊论文在线投稿审稿系统④(审稿人功能页)
一、功能
二、效果如下
三、代码如下
Reviewer.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 identity = (String) session.getAttribute("identity"); 25 out.print(identity); 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="ReviewerServlet?method=gaojianpingshen" target="frame">稿件评审</a></li> 45 <li class="layui-nav-item"><a 46 href="Contribute_alterpassword.jsp" target="frame">密码修改</a></li> 47 </ul> 48 </div> 49 </div> 50 <div class="layui-body"> 51 <!-- 内容主体区域 --> 52 <iframe name="frame" width="100%" height="100%" 53 style="border: 1px solid #CCC;"></iframe> 54 </div> 55 <div> 56 <div> 57 <input type="text" id="date" /> 58 </div> 59 </div> 60 </div> 61 62 </body> 63 </html>
Reviewer_gaojianpingshen.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 </tr> 23 </thead> 24 <tbody> 25 <c:forEach items="${list}" var="story" varStatus="status"> 26 <tr> 27 <td>${ status.index + 1}</td> 28 <td>${story.ctitle}</td> 29 <td>${story.etitle}</td> 30 <td>${story.name}</td> 31 <td><button class="layui-btn layui-btn-normal" 32 onclick="window.location.href='ReviewerServlet?method=gaojianpingshen_check&ctitle=${story.ctitle}'">评审</button></td> 33 </tr> 34 </c:forEach> 35 </tbody> 36 </table> 37 </body> 38 </html>
Reviewer_gaojianpingshen_check.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" 15 action="ReviewerServlet?method=gaojianpingshen_checkResult" method="post"> 16 <c:forEach items="${list}" var="story"> 17 <div class="layui-form-item"> 18 <label class="layui-form-label">中文标题</label> 19 <div class="layui-input-block"> 20 <input type="text" name="ctitle" required lay-verify="required" 21 placeholder="请输入中文标题" autocomplete="off" class="layui-input" 22 value="${story.ctitle}"> <input type="text" 23 name="judgectitle" required lay-verify="required" 24 placeholder="请输入中文标题" autocomplete="off" class="layui-input" 25 value="${story.ctitle}"> 26 </div> 27 <div class="layui-form-mid layui-word-aux">(限100字以内)</div> 28 </div> 29 <div class="layui-form-item layui-form-text"> 30 <label class="layui-form-label">英文标题</label> 31 <div class="layui-input-block"> 32 <input type="text" name="etitle" required lay-verify="required" 33 placeholder="请输入英文标题" autocomplete="off" class="layui-input" 34 value="${story.etitle}"> 35 </div> 36 <div class="layui-form-mid layui-word-aux">(限400个字符以内)</div> 37 </div> 38 <div class="layui-form-item"> 39 <label class="layui-form-label">中文摘要</label> 40 <div class="layui-inline"> 41 <input type="text" name="cabstract" required lay-verify="required" 42 placeholder="请输入中文摘要" autocomplete="off" class="layui-input" 43 value="${story.cabstract}"> 44 </div> 45 <div class="layui-form-mid layui-word-aux">(限300字以内)</div> 46 </div> 47 <div class="layui-form-item"> 48 <label class="layui-form-label">英文摘要</label> 49 <div class="layui-inline"> 50 <input type="text" name="eabstract" required lay-verify="required" 51 placeholder="请输入英文摘要" autocomplete="off" class="layui-input" 52 value="${story.eabstract}"> 53 </div> 54 <div class="layui-form-mid layui-word-aux">(限3000字符以内)</div> 55 </div> 56 <div class="layui-form-item"> 57 <label class="layui-form-label">中文关键字</label> 58 <div class="layui-inline"> 59 <input type="text" name="ckey" required lay-verify="required" 60 placeholder="请输入中文关键字" autocomplete="off" class="layui-input" 61 value="${story.ckey}"> 62 </div> 63 <div class="layui-form-mid layui-word-aux">(限100字以内)</div> 64 </div> 65 <div class="layui-form-item"> 66 <label class="layui-form-label">英文关键字</label> 67 <div class="layui-inline"> 68 <input type="text" name="ekey" required lay-verify="required" 69 placeholder="请输入英文关键字" autocomplete="off" class="layui-input" 70 value="${story.ekey}"> 71 </div> 72 <div class="layui-form-mid layui-word-aux">(限200个字符以内)</div> 73 </div> 74 <div class="layui-form-item layui-form-text"> 75 <label class="layui-form-label">稿件正文</label> 76 <div class="layui-input-block"> 77 <textarea name="content" placeholder="请输入稿件正文" 78 class="layui-textarea">${story.content}</textarea> 79 </div> 80 </div> 81 <div class="layui-form-item"> 82 <label class="layui-form-label">投稿人</label> 83 <div class="layui-input-block"> 84 <input type="text" name="name" required lay-verify="required" 85 placeholder="请输入您的账号" autocomplete="off" class="layui-input" 86 value="${story.name}"> 87 </div> 88 </div> 89 <div class="layui-form-item"> 90 <label class="layui-form-label">是否同意</label> 91 <div class="layui-input-block"> 92 <input type="radio" name="nameAgree" value="同意" title="同意" 93 checked> <input type="radio" name="nameAgree" 94 value="不同意" title="不同意"> 95 </div> 96 </div> 97 <div class="layui-form-item layui-form-text"> 98 <label class="layui-form-label">意见</label> 99 <div class="layui-input-block"> 100 <textarea name="nameOpinion" placeholder="请输入您的意见" 101 class="layui-textarea"></textarea> 102 </div> 103 </div> 104 <div class="layui-form-item"> 105 <div class="layui-input-block"> 106 <button class="layui-btn" lay-submit>提交</button> 107 <button type="reset" class="layui-btn layui-btn-primary">重置</button> 108 </div> 109 </div> 110 </c:forEach> 111 </form> 112 </body> 113 </html>
ReviewerServlet.java(在servlet文件下建立此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 import javax.servlet.http.HttpSession; 12 13 import dao.ReviewerDao; 14 import util.Story; 15 16 /** 17 * Servlet implementation class ReviewerServlet 18 */ 19 @WebServlet("/ReviewerServlet") 20 public class ReviewerServlet extends HttpServlet { 21 private static final long serialVersionUID = 1L; 22 23 /** 24 * @see HttpServlet#HttpServlet() 25 */ 26 public ReviewerServlet() { 27 super(); 28 // TODO Auto-generated constructor stub 29 } 30 31 ReviewerDao dao = new ReviewerDao(); 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 request.setCharacterEncoding("utf-8"); 53 response.setCharacterEncoding("utf-8"); 54 55 System.out.println("进入ContributeServlet"); 56 String method = request.getParameter("method"); 57 System.out.println(method); 58 if ("gaojianpingshen".equals(method)) { 59 gaojianpingshen(request, response);// 稿件评审 60 } else if ("gaojianpingshen_check".equals(method)) { 61 gaojianpingshen_check(request, response); 62 } else if ("gaojianpingshen_checkResult".equals(method)) { 63 gaojianpingshen_checkResult(request, response); 64 } 65 } 66 67 public void gaojianpingshen(HttpServletRequest request, HttpServletResponse response) 68 throws ServletException, IOException { 69 response.setCharacterEncoding("UTF-8"); 70 request.setCharacterEncoding("UTF-8"); 71 72 // 使用request对象的getSession()获取session,如果session不存在则创建一个 73 HttpSession session = request.getSession(); 74 // 将数据取出 75 String name = (String) session.getAttribute("username"); 76 77 System.out.println("进入gaojianpingshen"); 78 List<Story> list = dao.gaojianpingshen(name); 79 request.setAttribute("list", list); 80 request.getRequestDispatcher("Reviewer_gaojianpingshen.jsp").forward(request, response); 81 82 } 83 84 public void gaojianpingshen_check(HttpServletRequest request, HttpServletResponse response) 85 throws ServletException, IOException { 86 response.setCharacterEncoding("UTF-8"); 87 request.setCharacterEncoding("UTF-8"); 88 89 String ctitle = request.getParameter("ctitle"); 90 List<Story> list = dao.gaojianpingshen_check(ctitle); 91 request.setAttribute("list", list); 92 request.getRequestDispatcher("Reviewer_gaojianpingshen_check.jsp").forward(request, response); 93 94 } 95 96 public void gaojianpingshen_checkResult(HttpServletRequest request, HttpServletResponse response) 97 throws ServletException, IOException { 98 response.setCharacterEncoding("UTF-8"); 99 request.setCharacterEncoding("UTF-8"); 100 101 // 使用request对象的getSession()获取session,如果session不存在则创建一个 102 HttpSession session = request.getSession(); 103 // 将数据取出 104 String name = (String) session.getAttribute("username"); 105 106 String ctitle = request.getParameter("judgectitle"); 107 String nameAgree = request.getParameter("nameAgree"); 108 String nameOpinion = request.getParameter("nameOpinion"); 109 110 if (dao.gaojianpingshen_checkResult(name,ctitle, nameAgree, nameOpinion)) { 111 request.getRequestDispatcher("ReviewerServlet?method=gaojianpingshen").forward(request, response); 112 } else { 113 request.getRequestDispatcher("TestFail.jsp").forward(request, response); 114 } 115 116 } 117 }
ReviewerDao.java(在dao文件下建立此java文件)
1 package dao; 2 3 import java.sql.Connection; 4 import java.sql.PreparedStatement; 5 import java.sql.ResultSet; 6 import java.text.SimpleDateFormat; 7 import java.util.ArrayList; 8 import java.util.Date; 9 import java.util.List; 10 11 import databse.Database; 12 import util.Story; 13 14 public class ReviewerDao { 15 /** 16 * 稿件评审 17 * 18 * @return 19 */ 20 public List<Story> gaojianpingshen(String name) { 21 List<Story> list = new ArrayList<>(); 22 Connection conn = null; 23 ResultSet rs = null; 24 PreparedStatement pstm = null; 25 Story story = null; 26 try { 27 conn = Database.getConnection(); 28 // 判断姓名为审稿人几,从而防止已审过稿的稿件出现,暂时没有做出就是当审核完成后,审核表中依旧有那个稿件的信息,只有等三人都审核完毕后,才会不列出稿件信息 29 // 通过姓名来查询相关需要审核的稿件 30 String sql = "select story.* from story join storysituation on (story.ctitle = storysituation.ctitle) where story.receiver=? AND (storysituation.name_one=? OR storysituation.name_two=? OR storysituation.name_three=?)"; 31 pstm = conn.prepareStatement(sql); 32 pstm.setString(1, "审稿流程已过"); 33 pstm.setString(2, name); 34 pstm.setString(3, name); 35 pstm.setString(4, name); 36 rs = pstm.executeQuery(); 37 while (rs.next()) { 38 String ctitle = rs.getString("ctitle"); 39 String etitle = rs.getString("etitle"); 40 String cabstract = rs.getString("cabstract"); 41 String eabstract = rs.getString("eabstract"); 42 String ckey = rs.getString("ckey"); 43 String ekey = rs.getString("ekey"); 44 String content = rs.getString("content"); 45 String receiver = rs.getString("receiver"); 46 String status = rs.getString("status"); 47 String namee = rs.getString("name"); 48 story = new Story(ctitle, etitle, cabstract, eabstract, ckey, ekey, content, receiver, status, namee); 49 list.add(story); 50 } 51 } catch (Exception e) { 52 e.printStackTrace(); 53 } finally { 54 Database.close(conn, pstm, rs); 55 } 56 return list; 57 } 58 59 public List<Story> gaojianpingshen_check(String ctitle) { 60 List<Story> list = new ArrayList<>(); 61 Connection conn = null; 62 ResultSet rs = null; 63 PreparedStatement pstm = null; 64 Story story = null; 65 try { 66 conn = Database.getConnection(); 67 String sql = "select * from story where ctitle=?"; 68 pstm = conn.prepareStatement(sql); 69 pstm.setString(1, ctitle); 70 rs = pstm.executeQuery(); 71 while (rs.next()) { 72 String ctitlee = rs.getString("ctitle"); 73 String etitle = rs.getString("etitle"); 74 String cabstract = rs.getString("cabstract"); 75 String eabstract = rs.getString("eabstract"); 76 String ckey = rs.getString("ckey"); 77 String ekey = rs.getString("ekey"); 78 String content = rs.getString("content"); 79 String receiver = rs.getString("receiver"); 80 String status = rs.getString("status"); 81 String name = rs.getString("name"); 82 story = new Story(ctitlee, etitle, cabstract, eabstract, ckey, ekey, content, receiver, status, name); 83 list.add(story); 84 } 85 } catch (Exception e) { 86 e.printStackTrace(); 87 } finally { 88 Database.close(conn, pstm, rs); 89 } 90 return list; 91 } 92 93 public boolean gaojianpingshen_checkResult(String name, String ctitle, String nameAgree, String nameOpinion) { 94 Connection conn = null; 95 PreparedStatement pstm = null; 96 PreparedStatement pstm1 = null; 97 PreparedStatement pstm2 = null; 98 PreparedStatement pstm3 = null; 99 ResultSet rs1 = null; 100 ResultSet rs2 = null; 101 ResultSet rs3 = null; 102 boolean judge = false; 103 String id1 = "0"; 104 String id2 = "0"; 105 String id3 = "0"; 106 try { 107 conn = Database.getConnection(); 108 109 /** 110 * 通过中文标题和用户名来查询该审稿人是审稿人几(审稿人1、审稿人2、审稿人3) 111 */ 112 String sql1 = "SELECT id FROM storysituation WHERE ctitle=? AND name_one=?"; 113 String sql2 = "SELECT id FROM storysituation WHERE ctitle=? AND name_two=?"; 114 String sql3 = "SELECT id FROM storysituation WHERE ctitle=? AND name_three=?"; 115 116 pstm1 = conn.prepareStatement(sql1); 117 pstm2 = conn.prepareStatement(sql2); 118 pstm3 = conn.prepareStatement(sql3); 119 120 pstm1.setString(1, ctitle); 121 pstm1.setString(2, name); 122 pstm2.setString(1, ctitle); 123 pstm2.setString(2, name); 124 pstm3.setString(1, ctitle); 125 pstm3.setString(2, name); 126 127 rs1 = pstm1.executeQuery(); 128 rs2 = pstm2.executeQuery(); 129 rs3 = pstm3.executeQuery(); 130 131 while (rs1.next()) { 132 id1 = rs1.getString("id"); 133 } 134 while (rs2.next()) { 135 id2 = rs2.getString("id"); 136 } 137 while (rs3.next()) { 138 id3 = rs3.getString("id"); 139 } 140 141 System.out.println(id1 + "," + id2 + "," + id3); 142 System.out.println(id1 != "0"); 143 144 // 通过查询id来增加审稿人的意见 145 if (id1 != "0" && id2.equals("0") && id3.equals("0")) { 146 System.out.println(id1); 147 System.out.println(name + "是审稿人name_one"); 148 String sql = "update storysituation set name_one_agree=?,name_one_opinion=? where id=?"; 149 pstm = conn.prepareStatement(sql); 150 pstm.setString(1, nameAgree); 151 pstm.setString(2, nameOpinion); 152 pstm.setString(3, id1); 153 // 执行插入操作 154 int num = pstm.executeUpdate(); 155 if (num > 0) { 156 System.out.println("审签成功"); 157 if (monitor(ctitle)) { 158 System.out.println("开始判断是否此稿子是否完全通过审稿"); 159 } else { 160 System.out.println("稿子还未完全审核完成"); 161 } 162 judge = true; 163 } else { 164 System.out.println("审签失败"); 165 judge = false; 166 } 167 } else if (id1.equals("0") && id2 != "0" && id3.equals("0")) { 168 System.out.println(id2); 169 System.out.println(name + "是审稿人name_two"); 170 String sql = "update storysituation set name_two_agree=?,name_two_opinion=? where id=?"; 171 pstm = conn.prepareStatement(sql); 172 pstm.setString(1, nameAgree); 173 pstm.setString(2, nameOpinion); 174 pstm.setString(3, id2); 175 // 执行插入操作 176 int num = pstm.executeUpdate(); 177 if (num > 0) { 178 System.out.println("审签成功"); 179 if (monitor(ctitle)) { 180 System.out.println("开始判断是否此稿子是否完全通过审稿"); 181 } else { 182 System.out.println("稿子还未完全审核完成"); 183 } 184 judge = true; 185 } else { 186 System.out.println("审签失败"); 187 judge = false; 188 } 189 } else if (id1.equals("0") && id2.equals("0") && id3 != "0") { 190 System.out.println(id3); 191 System.out.println(name + "是审稿人name_three"); 192 String sql = "update storysituation set name_three_agree=?,name_three_opinion=? where id=?"; 193 pstm = conn.prepareStatement(sql); 194 pstm.setString(1, nameAgree); 195 pstm.setString(2, nameOpinion); 196 pstm.setString(3, id3); 197 // 执行插入操作 198 int num = pstm.executeUpdate(); 199 if (num > 0) { 200 System.out.println("审签成功"); 201 if (monitor(ctitle)) { 202 System.out.println("开始判断是否此稿子是否完全通过审稿"); 203 } else { 204 System.out.println("稿子还未完全审核完成"); 205 } 206 judge = true; 207 } else { 208 System.out.println("审签失败"); 209 judge = false; 210 } 211 } else { 212 System.out.println("系统出错!请重试!"); 213 } 214 215 } catch (Exception e) { 216 e.printStackTrace(); 217 } finally { 218 // SQL执行完成后释放相关资源 219 Database.close(conn, pstm); 220 } 221 return judge; 222 } 223 224 /** 225 * 用于监测是否已经完全审稿成功 226 * 227 * @param id 228 * @param ctitle 229 * @return 230 */ 231 public boolean monitor(String ctitle) { 232 Connection conn = null; 233 PreparedStatement pstm = null; 234 PreparedStatement pstm1 = null; 235 PreparedStatement pstm2 = null; 236 ResultSet rs = null; 237 boolean judge = false; 238 String name_one_agree = "null"; 239 String name_two_agree = "null"; 240 String name_three_agree = "null"; 241 String receiver = "稿件评审已通过"; 242 try { 243 conn = Database.getConnection(); 244 String sql = "SELECT name_one_agree,name_two_agree,name_three_agree FROM storysituation WHERE ctitle=?"; 245 pstm = conn.prepareStatement(sql); 246 pstm.setString(1, ctitle); 247 rs = pstm.executeQuery(); 248 while (rs.next()) { 249 name_one_agree = rs.getString("name_one_agree"); 250 name_two_agree = rs.getString("name_two_agree"); 251 name_three_agree = rs.getString("name_three_agree"); 252 } 253 System.out.println("name_one_agree:" + name_one_agree + ",name_two_agree:" + name_two_agree 254 + ",name_three_agree:" + name_three_agree); 255 256 if (name_one_agree != "null" && name_two_agree != "null" && name_three_agree != "null") { 257 if (name_one_agree.equals("同意") && name_two_agree.equals("同意") && name_three_agree.equals("同意")) { 258 System.out.println("已签发"); 259 receiver = "已签发"; 260 } else if (name_one_agree.equals("同意") && name_two_agree.equals("同意") 261 && name_three_agree.equals("不同意")) { 262 System.out.println("稿件评审已通过"); 263 } else if (name_one_agree.equals("同意") && name_two_agree.equals("不同意") 264 && name_three_agree.equals("同意")) { 265 System.out.println("稿件评审已通过"); 266 } else if (name_one_agree.equals("不同意") && name_two_agree.equals("同意") 267 && name_three_agree.equals("同意")) { 268 System.out.println("稿件评审已通过"); 269 } else { 270 System.out.println("稿件评审未通过"); 271 receiver = "退回稿件"; 272 } 273 274 //稿件签发后,自动获取签发日期 275 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 276 System.out.println(df.format(new Date()));// new Date()为获取当前系统时间 277 278 String sql1 = "update story set receiver=?,time=? where ctitle=?"; 279 pstm1 = conn.prepareStatement(sql1); 280 pstm1.setString(1, receiver); 281 pstm1.setString(2, df.format(new Date())); 282 pstm1.setString(3, ctitle); 283 String sql2 = "update storysituation set receiver=? where ctitle=?"; 284 pstm2 = conn.prepareStatement(sql2); 285 pstm2.setString(1, receiver); 286 pstm2.setString(2, ctitle); 287 288 // 执行插入操作 289 int num = pstm1.executeUpdate(); 290 int num1 = pstm2.executeUpdate(); 291 if (num > 0 && num1 > 0) { 292 System.out.println("审稿成功"); 293 judge = true; 294 } else { 295 System.out.println("审稿失败"); 296 judge = false; 297 } 298 } 299 } catch (Exception e) { 300 e.printStackTrace(); 301 } finally { 302 // SQL执行完成后释放相关资源 303 Database.close(conn, pstm); 304 } 305 return judge; 306 } 307 }