Эх сурвалжийг харах

wps操作题新增输出答案附件

wangliang 1 жил өмнө
parent
commit
3f665edfa9

+ 17 - 6
server/src/main/java/com/qmth/jkserver/controller/api/WpsController.java

@@ -383,7 +383,7 @@ public class WpsController extends BaseSystemController {
             JSONObject obj = sections.getJSONObject(i);
             JSONArray array = obj.getJSONArray("blocks");
             if (array.size() > 0) {
-                JSONArray delArray = new JSONArray();
+//                JSONArray delArray = new JSONArray();
                 List<WpsAttachmentVo> wpsOperationFile = new ArrayList<>();
                 for (int j = 0; j < array.size(); j++) {
                     JSONObject arrayJSONObject = array.getJSONObject(j);
@@ -391,24 +391,35 @@ public class WpsController extends BaseSystemController {
                     String value = arrayJSONObject.getString("value");
                     if (Objects.nonNull(type) && Objects.equals(type.trim(), "file")) {
                         wpsParamVo = JSONObject.parseObject(value, WpsParamVo.class);
-                        List<WpsAttachmentVo> attachmentVoList = wpsParamVo.getWpsOperationFile();
+                        List<WpsAttachmentVo> attachmentVoList = wpsParamVo.getWpsSourceFile();
                         for (WpsAttachmentVo w : attachmentVoList) {
                             File sourceFile = new File(new File(workRoot), path + File.separator + w.getValue());
                             File destFile = new File(dirName, w.getValue());
                             IOUtils.copy(new FileInputStream(sourceFile), new FileOutputStream(destFile));
                             wpsOperationFile.add(w);
                         }
-                        delArray.add(arrayJSONObject);
+//                        delArray.add(arrayJSONObject);
                     }
                 }
-                array.removeAll(delArray);
+//                array.removeAll(delArray);
                 if (Objects.nonNull(wpsParamVo)) {
-                    wpsParamVo.getWpsOperationFile().clear();
-                    wpsParamVo.setWpsOperationFile(wpsOperationFile);
+                    wpsParamVo.getWpsSourceFile().clear();
+                    wpsParamVo.setWpsSourceFile(wpsOperationFile);
                 }
             }
         }
         wpsQuestionVo.setBody(object);
+
+        JSONArray answers = json.getJSONArray("answers");
+        if (Objects.nonNull(answers) && answers.size() > 0) {
+            List<WpsAttachmentVo> attachmentVoList = new ArrayList<>(answers.size());
+            for (int j = 0; j < answers.size(); j++) {
+                JSONObject arrayJSONObject = answers.getJSONObject(j);
+                String fileName = arrayJSONObject.getString("fileName");
+                attachmentVoList.add(new WpsAttachmentVo(fileName));
+            }
+            wpsParamVo.setWpsOutputFile(attachmentVoList);
+        }
         wpsQuestionVo.setParam(wpsParamVo);
         wpsDetailVo.setQuestions(wpsQuestionVoList);
         JSONObject newJson = JSONObject.parseObject(JacksonUtil.parseJson(wpsDetailVo));

+ 7 - 0
server/src/main/java/com/qmth/jkserver/dto/wps/WpsAttachmentVo.java

@@ -1,5 +1,7 @@
 package com.qmth.jkserver.dto.wps;
 
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
@@ -11,6 +13,7 @@ import java.io.Serializable;
  * @Author: wangliang
  * @Date: 2024/5/8
  */
+@JsonInclude(value = Include.NON_NULL)
 public class WpsAttachmentVo implements Serializable {
 
     @ApiModelProperty(value = "wps题库文件名")
@@ -23,6 +26,10 @@ public class WpsAttachmentVo implements Serializable {
 
     }
 
+    public WpsAttachmentVo(String name) {
+        this.name = name;
+    }
+
     public WpsAttachmentVo(String name, String value) {
         this.name = name;
         this.value = value;

+ 18 - 7
server/src/main/java/com/qmth/jkserver/dto/wps/WpsParamVo.java

@@ -22,16 +22,19 @@ public class WpsParamVo implements Serializable {
     BigDecimal wpsQuestionScore;
 
     @ApiModelProperty(value = "wps题库原始文件")
-    List<WpsAttachmentVo> wpsOperationFile;
+    List<WpsAttachmentVo> wpsSourceFile;
+
+    @ApiModelProperty(value = "WPS题库作答文件")
+    List<WpsAttachmentVo> wpsOutputFile;
 
     public WpsParamVo() {
 
     }
 
-    public WpsParamVo(String wpsQuestionId, BigDecimal wpsQuestionScore, List<WpsAttachmentVo> wpsOperationFile) {
+    public WpsParamVo(String wpsQuestionId, BigDecimal wpsQuestionScore, List<WpsAttachmentVo> wpsSourceFile) {
         this.wpsQuestionId = wpsQuestionId;
         this.wpsQuestionScore = wpsQuestionScore;
-        this.wpsOperationFile = wpsOperationFile;
+        this.wpsSourceFile = wpsSourceFile;
     }
 
     public String getWpsQuestionId() {
@@ -50,11 +53,19 @@ public class WpsParamVo implements Serializable {
         this.wpsQuestionScore = wpsQuestionScore;
     }
 
-    public List<WpsAttachmentVo> getWpsOperationFile() {
-        return wpsOperationFile;
+    public List<WpsAttachmentVo> getWpsSourceFile() {
+        return wpsSourceFile;
+    }
+
+    public void setWpsSourceFile(List<WpsAttachmentVo> wpsSourceFile) {
+        this.wpsSourceFile = wpsSourceFile;
+    }
+
+    public List<WpsAttachmentVo> getWpsOutputFile() {
+        return wpsOutputFile;
     }
 
-    public void setWpsOperationFile(List<WpsAttachmentVo> wpsOperationFile) {
-        this.wpsOperationFile = wpsOperationFile;
+    public void setWpsOutputFile(List<WpsAttachmentVo> wpsOutputFile) {
+        this.wpsOutputFile = wpsOutputFile;
     }
 }