此文接期刊论文在线投稿审稿系统④(校稿人功能页-'内容查重'功能的实现)
一、'审稿流程'功能
二、效果如下
三、代码如下
Proofread_shengaoliucheng.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 </tr> 28 </thead> 29 <tbody> 30 <c:forEach items="${list}" var="story" varStatus="status"> 31 <tr> 32 <td>${ status.index + 1}</td> 33 <td>${story.ctitle}</td> 34 <td>${story.etitle}</td> 35 <td>${story.name}</td> 36 <td><button class="layui-btn layui-btn-normal" 37 onclick="window.location.href='ProofreadServlet?method=shengao_check&ctitle=${story.ctitle}'">选择对应的审稿人</button></td> 38 </tr> 39 </c:forEach> 40 </tbody> 41 </table> 42 </body> 43 </html>
Proofread_shengaoliucheng_choose.jsp
1 <%@page import="util.User"%> 2 <%@ page language="java" contentType="text/html; charset=UTF-8" 3 pageEncoding="UTF-8" import="java.util.*"%> 4 <!DOCTYPE html> 5 <html> 6 <head> 7 <meta charset="UTF-8"> 8 <title>审稿流程</title> 9 <script src=".//layui/layui.js"></script> 10 <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> 11 <meta name="renderer" content="webkit"> 12 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 13 <meta name="viewport" 14 content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"> 15 <link rel="stylesheet" href=".//layui/css/layui.css" media="all"> 16 <link rel="stylesheet" href=".//style/admin.css" media="all"> 17 <link rel="stylesheet" href=".//style/login.css" media="all"> 18 </head> 19 <body> 20 <form action="ProofreadServlet?method=shengao_choose" method="post"> 21 <div class="layadmin-user-login layadmin-user-display-show" 22 id="LAY-user-login" style="display: none;"> 23 <div class="layadmin-user-login-main"> 24 <div class="layadmin-user-login-box layadmin-user-login-header"> 25 <h2>请选择审稿人</h2> 26 </div> 27 <div 28 class="layadmin-user-login-box layadmin-user-login-body layui-form"> 29 <div class="layui-form-item"> 30 <label class="layui-form-label">审稿人1</label> 31 <div class="layui-input-inline"> 32 <select name="name1"> 33 <option value="">请选择</option> 34 <% 35 List<User> user = (List) session.getAttribute("List"); 36 for (User u : user) { 37 %> 38 <option value="<%=u.getName()%>"><%=u.getName()%></option> 39 <% 40 } 41 %> 42 </select> 43 </div> 44 </div> 45 <div class="layui-form-item"> 46 <label class="layui-form-label">审稿人2</label> 47 <div class="layui-input-inline"> 48 <select name="name2"> 49 <option value="">请选择</option> 50 <% 51 List<User> user1 = (List) session.getAttribute("List"); 52 for (User u : user1) { 53 %> 54 <option value="<%=u.getName()%>"><%=u.getName()%></option> 55 <% 56 } 57 %> 58 </select> 59 </div> 60 </div> 61 <div class="layui-form-item"> 62 <label class="layui-form-label">审稿人3</label> 63 <div class="layui-input-inline"> 64 <select name="name3"> 65 <option value="">请选择</option> 66 <% 67 List<User> user2 = (List) session.getAttribute("List"); 68 for (User u : user) { 69 %> 70 <option value="<%=u.getName()%>"><%=u.getName()%></option> 71 <% 72 } 73 %> 74 </select> 75 </div> 76 </div> 77 <div class="layui-form-item"> 78 <div class="layui-input-block"> 79 <button class="layui-btn" lay-submit>确认提交</button> 80 <button type="reset" class="layui-btn layui-btn-primary">重置</button> 81 </div> 82 </div> 83 </div> 84 </div> 85 </div> 86 </form> 87 </body> 88 </html>
在ProofreadServlet.java文件内添加上以下语句
1 protected void doPost(HttpServletRequest request, HttpServletResponse response) 2 throws ServletException, IOException { 3 // TODO Auto-generated method stub 4 // doGet(request, response); 5 request.setCharacterEncoding("utf-8"); 6 response.setCharacterEncoding("utf-8"); 7 8 System.out.println("进入ContributeServlet"); 9 String method = request.getParameter("method"); 10 System.out.println(method); 11 if ("geshishencha".equals(method)) { 12 geshishencha(request, response);// 格式审查 13 } else if ("check".equals(method)) { 14 check(request, response);// 审查 15 } else if ("checkResult".equals(method)) { 16 checkResult(request, response); 17 } else if ("neirongchachong".equals(method)) { 18 neirongchachong(request, response);// 内容查重 19 } else if ("neirong_check".equals(method)) { 20 neirong_check(request, response); 21 } else if ("neirong_checkResult".equals(method)) { 22 neirong_checkResult(request, response); 23 } else if ("shengaoliucheng".equals(method)) { 24 shengaoliucheng(request, response); 25 } else if ("shengao_check".equals(method)) { 26 shengao_check(request, response); 27 } else if ("shengao_choose".equals(method)) { 28 shengao_choose(request, response); 29 } 30 } 31 32 public void shengaoliucheng(HttpServletRequest request, HttpServletResponse response) 33 throws ServletException, IOException { 34 response.setCharacterEncoding("UTF-8"); 35 request.setCharacterEncoding("UTF-8"); 36 37 List<Story> list = dao.shengaoliucheng(); 38 request.setAttribute("list", list); 39 request.getRequestDispatcher("Proofread_shengaoliucheng.jsp").forward(request, response); 40 41 } 42 43 public void shengao_check(HttpServletRequest request, HttpServletResponse response) 44 throws ServletException, IOException { 45 response.setCharacterEncoding("UTF-8"); 46 request.setCharacterEncoding("UTF-8"); 47 48 String ctitle = request.getParameter("ctitle"); 49 50 // 使用request对象的getSession()获取session,如果session不存在则创建一个 51 HttpSession session = request.getSession(); 52 // 将数据存储到session中 53 session.setAttribute("ctitle", ctitle); 54 55 List<User> list = dao.shengaoliucheng_check("审稿人"); 56 session.setAttribute("List", list); 57 58 request.getRequestDispatcher("Proofread_shengaoliucheng_choose.jsp").forward(request, response); 59 60 } 61 62 public void shengao_choose(HttpServletRequest request, HttpServletResponse response) 63 throws ServletException, IOException { 64 response.setCharacterEncoding("UTF-8"); 65 request.setCharacterEncoding("UTF-8"); 66 67 String name1 = request.getParameter("name1"); 68 String name2 = request.getParameter("name2"); 69 String name3 = request.getParameter("name3"); 70 71 System.out.println(name1 + "," + name2 + "," + name3); 72 73 if (name1.equals(name2) || name1.equals(name3) || name2.equals(name3)) { 74 JOptionPane.showMessageDialog(null, "不能选择相同的审稿人,请重新进行选择!!", "ERROR", JOptionPane.PLAIN_MESSAGE); 75 request.getRequestDispatcher("ProofreadServlet?method=shengaoliucheng").forward(request, response); 76 } else { 77 HttpSession session = request.getSession(); 78 String ctitle = (String) session.getAttribute("ctitle"); 79 if (dao.shengao_choose(ctitle, name1, name2, name3)) { 80 JOptionPane.showMessageDialog(null, "选择审稿人成功!", "SUCCESS", JOptionPane.PLAIN_MESSAGE); 81 request.getRequestDispatcher("ProofreadServlet?method=shengaoliucheng").forward(request, response); 82 } else { 83 request.getRequestDispatcher("TestFail.jsp").forward(request, response); 84 } 85 } 86 87 }
在ProofreadDao.java文件内添加上以下语句
1 /** 2 * 审稿流程 3 * @return 4 */ 5 public List<Story> shengaoliucheng() { 6 List<Story> list = new ArrayList<>(); 7 Connection conn = null; 8 ResultSet rs = null; 9 PreparedStatement pstm = null; 10 Story story = null; 11 try { 12 conn = Database.getConnection(); 13 String sql = "select * from story where receiver=?"; 14 pstm = conn.prepareStatement(sql); 15 pstm.setString(1, "内容查重合格"); 16 rs = pstm.executeQuery(); 17 while (rs.next()) { 18 String ctitle = rs.getString("ctitle"); 19 String etitle = rs.getString("etitle"); 20 String cabstract = rs.getString("cabstract"); 21 String eabstract = rs.getString("eabstract"); 22 String ckey = rs.getString("ckey"); 23 String ekey = rs.getString("ekey"); 24 String content = rs.getString("content"); 25 String receiver = rs.getString("receiver"); 26 String status = rs.getString("status"); 27 String name = rs.getString("name"); 28 story = new Story(ctitle, etitle, cabstract, eabstract, ckey, ekey, content, receiver, status, name); 29 list.add(story); 30 } 31 } catch (Exception e) { 32 e.printStackTrace(); 33 } finally { 34 Database.close(conn, pstm, rs); 35 } 36 return list; 37 } 38 39 public List<User> shengaoliucheng_check(String identity) { 40 List<User> list = new ArrayList<>(); 41 Connection conn = null; 42 ResultSet rs = null; 43 PreparedStatement pstm = null; 44 User user = null; 45 try { 46 conn = Database.getConnection(); 47 String sql = "select name from user where identity=?"; 48 pstm = conn.prepareStatement(sql); 49 pstm.setString(1, identity); 50 rs = pstm.executeQuery(); 51 while (rs.next()) { 52 String name = rs.getString("name"); 53 user = new User(name); 54 list.add(user); 55 } 56 } catch (Exception e) { 57 e.printStackTrace(); 58 } finally { 59 Database.close(conn, pstm, rs); 60 } 61 return list; 62 } 63 public boolean shengao_choose(String ctitle, String name1,String name2,String name3) { 64 Connection conn = null; 65 PreparedStatement pstm = null; 66 PreparedStatement pstm1 = null; 67 boolean judge = false; 68 String receiver="审稿流程已过"; 69 try { 70 conn = Database.getConnection(); 71 String sql = "update story set receiver=? where ctitle=?"; 72 String sql1 = "update storysituation set name_one=?,name_two=?,name_three=?,receiver=? where ctitle=?"; 73 pstm = conn.prepareStatement(sql); 74 pstm.setString(1, receiver); 75 pstm.setString(2, ctitle); 76 pstm1 = conn.prepareStatement(sql1); 77 pstm1.setString(1, name1); 78 pstm1.setString(2, name2); 79 pstm1.setString(3, name3); 80 pstm1.setString(4, receiver); 81 pstm1.setString(5, ctitle); 82 // 执行插入操作 83 int num = pstm.executeUpdate(); 84 int num1 = pstm1.executeUpdate(); 85 if (num > 0 & num1 > 0) { 86 System.out.println("提交成功"); 87 judge = true; 88 } else { 89 System.out.println("提交失败"); 90 judge = false; 91 } 92 } catch (Exception e) { 93 e.printStackTrace(); 94 } finally { 95 // SQL执行完成后释放相关资源 96 Database.close(conn, pstm); 97 } 98 return judge; 99 }