From e9a34cee95221d9964b2fd0c364f49a9486f855f Mon Sep 17 00:00:00 2001 From: zhai_lw Date: Wed, 16 Jan 2019 16:15:04 +0800 Subject: [PATCH] Merge remote-tracking branch 'remotes/origin/wmj' # Conflicts: # src/core/process/C_CollegeFillScoreOpinion.java # src/core/process/C_MentorFillOpeningReportOpinion.java # src/core/process/C_MentorFillReview.java # src/core/process/C_ReviewerFillReview.java # src/core/process/C_SchoolFillScoreOpinion.java # src/core/process/C_SecretaryFillOpeningReportRecord.java # src/core/process/C_SecretaryFillReplyRecord.java # src/core/process/C_TeacherTeamFillOpeningReportOpinion.java # src/core/process/C_TeacherTeamFillScoreOpinion.java --- .../C_StudentUploadFinishedProduct.java | 17 +++++++------- .../process/C_StudentUploadOpeningReport.java | 14 ++++++------ .../S_StudentUploadFinishedProduct.java | 13 ++++++++++- src/servlet/S_StudentUploadOpeningReport.java | 22 +++++++++++++++---- 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/src/core/process/C_StudentUploadFinishedProduct.java b/src/core/process/C_StudentUploadFinishedProduct.java index 5d3172b..5199be6 100644 --- a/src/core/process/C_StudentUploadFinishedProduct.java +++ b/src/core/process/C_StudentUploadFinishedProduct.java @@ -4,13 +4,12 @@ import core.operation.UploadFile; import error.GExcptInit; import error.GExcptSQL; -import java.io.File; import java.util.HashMap; import java.util.Map; public class C_StudentUploadFinishedProduct extends C_UploadFile { - File finishedProduct; + String finishedProductURL; String graduationDesignId; private static String buttonName ="提交定稿"; private static String iconURL="../cssFile/images/upload.png"; @@ -21,11 +20,11 @@ public class C_StudentUploadFinishedProduct extends C_UploadFile { private static String field ="finished_product_status"; static String file_type = "finished_product"; - public void uploadOpeningReport() throws Exception{ + public void uploadFinishedProduct() throws Exception{ if(!check()) throw new GExcptInit("Upload FinishedProduct Attrs init error!"); UploadFile uploadFile=new UploadFile(); uploadFile.setOptions(new HashMap<>()); - uploadFile.addOptions("file",this.getFinishedProduct()); + uploadFile.addOptions("file_url",this.getFinishedProductURL()); uploadFile.addOptions("file_type",file_type); Maplimits = new HashMap<>(); limits.put("id",this.getGraduationDesignId()); @@ -35,16 +34,16 @@ public class C_StudentUploadFinishedProduct extends C_UploadFile { } protected boolean check() { - if(this.getFinishedProduct()==null||this.getGraduationDesignId()==null) + if(this.getFinishedProductURL()==null||this.getGraduationDesignId()==null) return false; return true; } - public File getFinishedProduct() { - return finishedProduct; + public String getFinishedProductURL() { + return finishedProductURL; } - public void setFinishedProduct(File finishedProduct) { - this.finishedProduct = finishedProduct; + public void setFinishedProductURL(String finishedProductURL) { + this.finishedProductURL = finishedProductURL; } public String getGraduationDesignId() { return graduationDesignId; diff --git a/src/core/process/C_StudentUploadOpeningReport.java b/src/core/process/C_StudentUploadOpeningReport.java index 489c669..395a956 100644 --- a/src/core/process/C_StudentUploadOpeningReport.java +++ b/src/core/process/C_StudentUploadOpeningReport.java @@ -9,7 +9,7 @@ import java.util.HashMap; import java.util.Map; public class C_StudentUploadOpeningReport extends C_UploadFile{ - File openingReport; + String openingReportURL; String graduationDesignId; private static String buttonName ="提交开题报告"; private static String file_type = "opening_report"; @@ -24,7 +24,7 @@ public class C_StudentUploadOpeningReport extends C_UploadFile{ if(!check()) throw new GExcptInit("Upload OpeningReport Attrs init error!"); UploadFile uploadFileOperation=new UploadFile(); uploadFileOperation.setOptions(new HashMap<>()); - uploadFileOperation.addOptions("file",this.getOpeningReport()); + uploadFileOperation.addOptions("file_url",this.getOpeningReportURL()); uploadFileOperation.addOptions("file_type",file_type); Maplimits = new HashMap<>(); limits.put("id",this.getGraduationDesignId()); @@ -34,17 +34,17 @@ public class C_StudentUploadOpeningReport extends C_UploadFile{ } protected boolean check() { - if(this.getGraduationDesignId()==null||this.getOpeningReport()==null) + if(this.getGraduationDesignId()==null||this.getOpeningReportURL()==null) return false; return true; } - public File getOpeningReport() { - return openingReport; + public String getOpeningReportURL() { + return openingReportURL; } - public void setOpeningReport(File openingReport) { - this.openingReport = openingReport; + public void setOpeningReportURL(String openingReportURL) { + this.openingReportURL = openingReportURL; } public String getGraduationDesignId() { diff --git a/src/servlet/S_StudentUploadFinishedProduct.java b/src/servlet/S_StudentUploadFinishedProduct.java index 393a567..32f0353 100644 --- a/src/servlet/S_StudentUploadFinishedProduct.java +++ b/src/servlet/S_StudentUploadFinishedProduct.java @@ -1,5 +1,7 @@ package servlet; +import core.process.C_StudentUploadFinishedProduct; + import javax.servlet.ServletException; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -14,7 +16,7 @@ public class S_StudentUploadFinishedProduct extends HttpServlet { static String fileType = "graduation_design_finished_product"; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String id = request.getParameter("id"); - String fileURL; + String fileURL = null; try { fileURL = servlet.Utils.saveFile(request, fileType); }catch (Exception e) @@ -22,5 +24,14 @@ public class S_StudentUploadFinishedProduct extends HttpServlet { System.out.print(e); response.sendRedirect("/op_fail.jsp"); } + C_StudentUploadFinishedProduct p =new C_StudentUploadFinishedProduct(); + p.setFinishedProductURL(fileURL); + p.setGraduationDesignId(id); + try { + p.uploadFinishedProduct(); + } catch (Exception e) { + e.printStackTrace(); + response.sendRedirect("/op_fail.jsp"); + } } } diff --git a/src/servlet/S_StudentUploadOpeningReport.java b/src/servlet/S_StudentUploadOpeningReport.java index 9e04357..1d40bac 100644 --- a/src/servlet/S_StudentUploadOpeningReport.java +++ b/src/servlet/S_StudentUploadOpeningReport.java @@ -1,6 +1,6 @@ package servlet; -import core.user.User; +import core.process.C_StudentUploadOpeningReport; import javax.servlet.ServletException; import javax.servlet.annotation.MultipartConfig; @@ -8,9 +8,7 @@ import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.Part; import java.io.IOException; -import java.util.UUID; @WebServlet("/home/student-upload-opening-report") @MultipartConfig @@ -18,6 +16,22 @@ public class S_StudentUploadOpeningReport extends HttpServlet { static String fileType = "graduation_design_opening_report"; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String id = request.getParameter("id"); - //String fileURL = servlet.Utils.saveFile(request, fileType); + String fileURL = null; + try { + fileURL = servlet.Utils.saveFile(request, fileType); + }catch (Exception e) + { + System.out.print(e); + response.sendRedirect("/op_fail.jsp"); + } + C_StudentUploadOpeningReport p =new C_StudentUploadOpeningReport(); + p.setOpeningReportURL(fileURL); + p.setGraduationDesignId(id); + try { + p.uploadOpeningReport(); + } catch (Exception e) { + e.printStackTrace(); + response.sendRedirect("/op_fail.jsp"); + } } }