From f7a60f1d44240119bbcafe6107438688be7f0f70 Mon Sep 17 00:00:00 2001 From: pengyouwei <3215821196@qq.com> Date: Tue, 15 Nov 2022 19:35:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BA=86=E5=87=BA?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoPaper3Controller.java | 13 +++++++++- .../GeneratePaperController.java | 1 + .../GeneratePaperSecondController.java | 24 +++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/hnust/controller/paper/autoPaperController/AutoPaper3Controller.java b/src/main/java/com/hnust/controller/paper/autoPaperController/AutoPaper3Controller.java index 98c0473..7043a69 100644 --- a/src/main/java/com/hnust/controller/paper/autoPaperController/AutoPaper3Controller.java +++ b/src/main/java/com/hnust/controller/paper/autoPaperController/AutoPaper3Controller.java @@ -264,8 +264,19 @@ public class AutoPaper3Controller implements Initializable { //为对应的ListView设置内容 public void showData(ListViewview,ObservableList list,List addList,CheckBox cb){ + //—-------------------------------------------------------------------------- 去重操作 addList.forEach(subjectDataRecord -> subjectDataRecord.setChecked(false)); - list.addAll(addList); + ArrayList list_id = new ArrayList(); + list.forEach(value -> { + list_id.add(value.getSubjectData().getId()); + }); + addList.forEach(subjectDataRecord -> { + + if(!list_id.contains(subjectDataRecord.getSubjectData().getId())){ + list.addAll(subjectDataRecord); + } + }); + //—-------------------------------------------------------------------------- view.setItems(list); setListViewHeight(view,list); view.setCellFactory(new Callback, ListCell>() { diff --git a/src/main/java/com/hnust/controller/paper/generateController/GeneratePaperController.java b/src/main/java/com/hnust/controller/paper/generateController/GeneratePaperController.java index 4ff0761..4e7a407 100644 --- a/src/main/java/com/hnust/controller/paper/generateController/GeneratePaperController.java +++ b/src/main/java/com/hnust/controller/paper/generateController/GeneratePaperController.java @@ -144,6 +144,7 @@ public class GeneratePaperController implements Initializable { String grade = gradeMajor.substring(0,4); String major = gradeMajor.substring(4); boolean m = classApi.getClassMsgByMajor_Grade(grade,major); + System.out.println(m); //存入年级 if(m==true){ // System.out.println("找到了并返回给前端"); diff --git a/src/main/java/com/hnust/controller/paper/generateController/GeneratePaperSecondController.java b/src/main/java/com/hnust/controller/paper/generateController/GeneratePaperSecondController.java index 00d457a..ba6ca72 100644 --- a/src/main/java/com/hnust/controller/paper/generateController/GeneratePaperSecondController.java +++ b/src/main/java/com/hnust/controller/paper/generateController/GeneratePaperSecondController.java @@ -32,6 +32,7 @@ import retrofit2.Response; import java.io.IOException; import java.net.URL; +import java.sql.SQLOutput; import java.util.*; import java.util.stream.Collectors; @@ -126,6 +127,8 @@ public class GeneratePaperSecondController implements Initializable { private Map midLabelMap=new HashMap<>(); private Map diffLabelMap=new HashMap<>(); private Map itemMap=new HashMap<>(); + + @Override public void initialize(URL location, ResourceBundle resources) { scp_paper.setFitToWidth(true); @@ -211,9 +214,21 @@ public class GeneratePaperSecondController implements Initializable { } //为对应的ListView设置内容 - public void showData(ListViewview,ObservableList list,List addList,CheckBox cb){ + public void + showData(ListViewview,ObservableList list,List addList,CheckBox cb){ addList.forEach(subjectDataRecord -> subjectDataRecord.setChecked(false)); - list.addAll(addList); +//—-------------------------------------------------------------------------- 去重操作 + ArrayList list_id = new ArrayList(); + list.forEach(value -> { + list_id.add(value.getSubjectData().getId()); + }); + addList.forEach(subjectDataRecord -> { + + if(!list_id.contains(subjectDataRecord.getSubjectData().getId())){ + list.addAll(subjectDataRecord); + } + }); +//—-------------------------------------------------------------------------- view.setItems(list); setListViewHeight(view,list); view.setCellFactory(new Callback, ListCell>() { @@ -223,6 +238,7 @@ public class GeneratePaperSecondController implements Initializable { @Override protected void updateItem(SubjectDataRecord item, boolean empty) { super.updateItem(item, empty); + if(empty==false){ AnchorPane anchorPane=new AnchorPane(); CheckBox checkBox=new CheckBox(); @@ -241,6 +257,8 @@ public class GeneratePaperSecondController implements Initializable { }); AnchorPane.setTopAnchor(checkBox, 7.0); AnchorPane.setLeftAnchor(checkBox, 10.0); + + //在这里显示题目 WebView webView=new WebView(); WebEngine webEngine=webView.getEngine(); webEngine.loadContent(item.getSubjectData().getContent()); @@ -250,6 +268,7 @@ public class GeneratePaperSecondController implements Initializable { AnchorPane.setTopAnchor(vBox, 7.0); AnchorPane.setLeftAnchor(vBox, 35.0); AnchorPane.setRightAnchor(vBox, 70.0); + Label label3=new Label("分值:"); Label label4=new Label(String.valueOf(item.getScore())); label3.setStyle("-fx-text-fill: #000"); @@ -301,6 +320,7 @@ public class GeneratePaperSecondController implements Initializable { } } }; + //在这里对题目进行去重 return cell; } }); -- Gitee From c5cce6cb7326d6ef34a29cdcae2b85f13c90a56b Mon Sep 17 00:00:00 2001 From: pengyouwei <3215821196@qq.com> Date: Mon, 13 Feb 2023 18:33:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E4=B8=8A=E4=BC=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 + .../paperManagement/PaperListController.java | 95 +++++++++++++++---- .../PaperReviewController.java | 12 ++- src/main/java/com/hnust/domain/Oss.java | 20 ++++ src/main/java/com/hnust/util/FileUpload.java | 6 +- src/main/resources/application.yml | 9 +- .../fxml/paper/paperManagement/paperList.fxml | 1 + 7 files changed, 128 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/hnust/domain/Oss.java diff --git a/pom.xml b/pom.xml index 91d74c5..3c72b28 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,11 @@ ikonli-fontawesome5-pack 2.4.0 + + com.aliyun.oss + aliyun-sdk-oss + 3.15.0 + diff --git a/src/main/java/com/hnust/controller/paper/paperManagement/PaperListController.java b/src/main/java/com/hnust/controller/paper/paperManagement/PaperListController.java index 7fa7b7a..7422157 100644 --- a/src/main/java/com/hnust/controller/paper/paperManagement/PaperListController.java +++ b/src/main/java/com/hnust/controller/paper/paperManagement/PaperListController.java @@ -176,22 +176,7 @@ public class PaperListController implements Initializable { } } - Iterator unStarted = unStartedList.iterator(); - while (unStarted.hasNext()) { - Test lh =unStarted.next(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - try { - long current_time = new Date().getTime(); - String cur_time = sdf.format(current_time); - String exam_start_time = (String) lh.getBeginTime(); - String exam_end_time = (String) lh.getEndTime(); - if (cur_time.compareTo(exam_start_time) <= 0) { //当前时间<=考试开始时间----待开始 - mydata_unstart.add(lh); - } - } catch (Exception e) { - e.printStackTrace(); - } - } + //另外定义函数启动页面显示 getUnstarting2(); } @@ -582,6 +567,84 @@ public class PaperListController implements Initializable { } return box; } + /* + Author:彭有为 + */ + //根据待开始,待批阅,已完成不同的页面来数据最新的数据 + public void refreshData(){ + if (cbox111.isSelected()){ + //清空上一次设置样卷/取消样卷/删除 功能中保留的选中数据,同时将所有的checkbox选中状态取消 + user_select_data.removeAll(user_select_data); + cbox111.setSelected(false); + } + // 获取待批阅处理的所有试卷列表 + List paperLists = testPaperService.getNeedCorrectExams(TeaNum.teaNum).getData(); + List unStartedList = testPaperService.getUnstartedExams(TeaNum.teaNum).getData(); + dealData(paperLists , unStartedList); + // 获取待开始的试卷列表 + + //待开始tab栏被选中 +// if(tab0.isSelected()) { +// tabPane = new JFXTabPane(); +// mydata_unstart = new ArrayList<>(); +// List unStartedList = testPaperService.getUnstartedExams(TeaNum.teaNum).getData(); +// Iterator unStarted = unStartedList.iterator(); +// while (unStarted.hasNext()) { +// Test lh = unStarted.next(); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// try { +// long current_time = new Date().getTime(); +// String cur_time = sdf.format(current_time); +// String exam_start_time = (String) lh.getBeginTime(); +// String exam_end_time = (String) lh.getEndTime(); +// if (cur_time.compareTo(exam_start_time) <= 0) { //当前时间<=考试开始时间----待开始 +// mydata_unstart.add(lh); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// System.out.println("待开始tab栏被选中"); +// } +// +// ArrayList mydata_finished_temp = new ArrayList<>(); +// ArrayList mydata_need_correct_temp = new ArrayList<>(); +// Iterator it = paperLists.iterator(); +// +// while (it.hasNext()) { +// Test lh = it.next(); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// try { +// long current_time = new Date().getTime(); +// String cur_time = sdf.format(current_time); +// String exam_start_time = (String) lh.getBeginTime(); +// String exam_end_time = (String) lh.getEndTime(); +// if (cur_time.compareTo(exam_start_time) > 0) { //当前时间>考试结束时间----判断待批阅和已完成 +// if ("1".equals(lh.getStatus())) { +// mydata_finished_temp.add(lh); +// } else { +// mydata_need_correct_temp.add(lh); +// } +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// //待批阅tab栏被选中 +// if(tab1.isSelected()){ +// tabPane = new JFXTabPane(); +// mydata_finished = mydata_finished_temp; +// System.out.println(mydata_finished_temp); +// System.out.println("待批阅tab栏被选中"); +// } +// //已完成tab栏被选中 +// if(tab2.isSelected()){ +// tabPane = new JFXTabPane(); +// mydata_need_correct = mydata_need_correct_temp; +// System.out.println("已完成tab栏被选中"); +// } + } public void change_selectall(){ //当选项卡切换时,取消选中当前选项卡的checkbox选中状态 if (cbox111.isSelected()){ diff --git a/src/main/java/com/hnust/controller/paper/paperManagement/PaperReviewController.java b/src/main/java/com/hnust/controller/paper/paperManagement/PaperReviewController.java index b05a020..ff3c183 100644 --- a/src/main/java/com/hnust/controller/paper/paperManagement/PaperReviewController.java +++ b/src/main/java/com/hnust/controller/paper/paperManagement/PaperReviewController.java @@ -1,4 +1,7 @@ package com.hnust.controller.paper.paperManagement; +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; +import com.aliyun.oss.model.GetObjectRequest; import com.hnust.controller.MainController; import com.hnust.domain.*; import com.hnust.fx.FXMLController; @@ -6,6 +9,7 @@ import com.hnust.service.*; import com.hnust.store.DataStore; import com.hnust.store.PaperListDataStore; import com.hnust.domain.JudgeAnswerPartDto; +import com.hnust.util.FileUpload; import com.hnust.util.PaperDataModel; import javafx.application.Platform; import javafx.beans.value.ChangeListener; @@ -26,6 +30,8 @@ import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; + +import java.io.File; import java.net.URL; import java.util.*; @@ -1014,7 +1020,11 @@ public class PaperReviewController implements Initializable { ImageView imageView = new ImageView(); HBox hBox5 = new HBox(); hBox5.setStyle("-fx-pref-width: 5;"); - Image image = new Image(questionAnswer.getStuAnswer().get(j)); +// Image image = new Image("http://hnustpyw.oss-cn-hangzhou.aliyuncs.com/upload/2006040306/image2"); //现在就是需要改这里 引入oss就行 +// Oss object = new Oss(); +// OSS ossClient = new OSSClientBuilder().build(object.getEndpoint() , object.getAccessKeyId() , object.getAccessKeySecret()); +// ossClient.getObject(new GetObjectRequest(object.getBucket() , object.) questionAnswer.getStuAnswer().get(j)); + Image image = new Image(questionAnswer.getStuAnswer().get(j)); //现在就是需要改这里 引入oss就行 double w = image.getWidth(); double h = image.getHeight(); double max = Math.max(w, h); diff --git a/src/main/java/com/hnust/domain/Oss.java b/src/main/java/com/hnust/domain/Oss.java new file mode 100644 index 0000000..a6d6fde --- /dev/null +++ b/src/main/java/com/hnust/domain/Oss.java @@ -0,0 +1,20 @@ +package com.hnust.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.beans.factory.annotation.Value; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Oss { + @Value("${aliyun.oss.file.endpoint}") + private String endpoint ; + @Value("${aliyun.oss.file.bucket}") + private String bucket ; + @Value("${aliyun.oss.file.accessKeyId}") + private String accessKeyId ; + @Value("${aliyun.oss.file.accessKeySecret}") + private String accessKeySecret ; +} diff --git a/src/main/java/com/hnust/util/FileUpload.java b/src/main/java/com/hnust/util/FileUpload.java index e9d95c1..6fe6a01 100644 --- a/src/main/java/com/hnust/util/FileUpload.java +++ b/src/main/java/com/hnust/util/FileUpload.java @@ -1,10 +1,12 @@ package com.hnust.util; -import org.apache.commons.fileupload.FileItem; -import org.apache.commons.fileupload.FileItemFactory; +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; +import com.aliyun.oss.model.OSSObject; import org.apache.commons.fileupload.disk.DiskFileItem; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.io.IOUtils; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.MediaType; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.commons.CommonsMultipartFile; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8728382..bf94f4c 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -15,7 +15,14 @@ feign: # readTimeout: 10000 websocket时使用的 loggerLevel: basic - +#配置阿里云oss服务信息 +aliyun: + oss: + file: + endpoint: "oss-cn-hangzhou.aliyuncs.com" + bucket: "hnustpyw" + accessKeyId: "LTAI5tGedGYp9sC9G26dsJJY" + accessKeySecret: "R3W751BpLNbiNUVtEnlVhansbvpFn0" #关闭banner spring: main: diff --git a/src/main/resources/fxml/paper/paperManagement/paperList.fxml b/src/main/resources/fxml/paper/paperManagement/paperList.fxml index 4ae573c..d02f227 100644 --- a/src/main/resources/fxml/paper/paperManagement/paperList.fxml +++ b/src/main/resources/fxml/paper/paperManagement/paperList.fxml @@ -50,6 +50,7 @@ + -- Gitee