|
@@ -49,7 +49,6 @@ import java.security.NoSuchAlgorithmException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: 机考wps对接接口
|
|
* @Description: 机考wps对接接口
|
|
@@ -267,14 +266,9 @@ public class WpsController extends BaseSystemController {
|
|
byte[] bytes = IOUtils.toByteArray(new FileInputStream(f));
|
|
byte[] bytes = IOUtils.toByteArray(new FileInputStream(f));
|
|
JSONObject jsonObject = JSONObject.parseObject(new String(bytes, SystemConstant.CHARSET_NAME));
|
|
JSONObject jsonObject = JSONObject.parseObject(new String(bytes, SystemConstant.CHARSET_NAME));
|
|
JSONArray jsonArray = jsonObject.getJSONArray("details");//明细
|
|
JSONArray jsonArray = jsonObject.getJSONArray("details");//明细
|
|
-
|
|
|
|
JSONObject json = (JSONObject) jsonMap.get(id);
|
|
JSONObject json = (JSONObject) jsonMap.get(id);
|
|
- JSONArray object = json.getJSONArray("answer");
|
|
|
|
- for (int i = 0; i < object.size(); i++) {
|
|
|
|
- JSONObject jsonObject1 = object.getJSONObject(i);
|
|
|
|
- List<WpsBlocksVo> wpsBlocksVoList = JSONArray.parseArray(JacksonUtil.parseJson(jsonObject1.getJSONArray("blocks")), WpsBlocksVo.class);
|
|
|
|
- WpsSectionsVo wpsSectionsVo = new WpsSectionsVo(wpsBlocksVoList);
|
|
|
|
- WpsAnswerSectionsVo wpsAnswerSectionsVo = new WpsAnswerSectionsVo(Arrays.asList(wpsSectionsVo));
|
|
|
|
|
|
+ List<WpsAnswerSectionsVo> wpsAnswerSectionsVoList = JSONArray.parseArray(JacksonUtil.parseJson(json.getJSONArray("answer")), WpsAnswerSectionsVo.class);
|
|
|
|
+ for (WpsAnswerSectionsVo wpsAnswerSectionsVo : wpsAnswerSectionsVoList) {
|
|
List<WpsAnswerQuestionVo> wpsAnswerQuestionVoList = new ArrayList<>();
|
|
List<WpsAnswerQuestionVo> wpsAnswerQuestionVoList = new ArrayList<>();
|
|
wpsAnswerQuestionVoList.add(new WpsAnswerQuestionVo(1, Arrays.asList(wpsAnswerSectionsVo)));
|
|
wpsAnswerQuestionVoList.add(new WpsAnswerQuestionVo(1, Arrays.asList(wpsAnswerSectionsVo)));
|
|
WpsAnswerVo wpsAnswerVo = new WpsAnswerVo(id, 1, wpsAnswerQuestionVoList);
|
|
WpsAnswerVo wpsAnswerVo = new WpsAnswerVo(id, 1, wpsAnswerQuestionVoList);
|
|
@@ -379,11 +373,11 @@ public class WpsController extends BaseSystemController {
|
|
JSONObject object = json.getJSONObject("body");
|
|
JSONObject object = json.getJSONObject("body");
|
|
JSONArray sections = object.getJSONArray("sections");
|
|
JSONArray sections = object.getJSONArray("sections");
|
|
WpsParamVo wpsParamVo = null;
|
|
WpsParamVo wpsParamVo = null;
|
|
|
|
+ JSONArray delArray = new JSONArray();
|
|
for (int i = 0; i < sections.size(); i++) {
|
|
for (int i = 0; i < sections.size(); i++) {
|
|
JSONObject obj = sections.getJSONObject(i);
|
|
JSONObject obj = sections.getJSONObject(i);
|
|
JSONArray array = obj.getJSONArray("blocks");
|
|
JSONArray array = obj.getJSONArray("blocks");
|
|
if (array.size() > 0) {
|
|
if (array.size() > 0) {
|
|
-// JSONArray delArray = new JSONArray();
|
|
|
|
List<WpsAttachmentVo> wpsOperationFile = new ArrayList<>();
|
|
List<WpsAttachmentVo> wpsOperationFile = new ArrayList<>();
|
|
for (int j = 0; j < array.size(); j++) {
|
|
for (int j = 0; j < array.size(); j++) {
|
|
JSONObject arrayJSONObject = array.getJSONObject(j);
|
|
JSONObject arrayJSONObject = array.getJSONObject(j);
|
|
@@ -398,16 +392,20 @@ public class WpsController extends BaseSystemController {
|
|
IOUtils.copy(new FileInputStream(sourceFile), new FileOutputStream(destFile));
|
|
IOUtils.copy(new FileInputStream(sourceFile), new FileOutputStream(destFile));
|
|
wpsOperationFile.add(w);
|
|
wpsOperationFile.add(w);
|
|
}
|
|
}
|
|
-// delArray.add(arrayJSONObject);
|
|
|
|
|
|
+ delArray.add(obj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-// array.removeAll(delArray);
|
|
|
|
if (Objects.nonNull(wpsParamVo)) {
|
|
if (Objects.nonNull(wpsParamVo)) {
|
|
wpsParamVo.getWpsSourceFile().clear();
|
|
wpsParamVo.getWpsSourceFile().clear();
|
|
wpsParamVo.setWpsSourceFile(wpsOperationFile);
|
|
wpsParamVo.setWpsSourceFile(wpsOperationFile);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (delArray.size() > 0) {
|
|
|
|
+ for (int i = 0; i < delArray.size(); i++) {
|
|
|
|
+ sections.remove(delArray.get(i));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
wpsQuestionVo.setBody(object);
|
|
wpsQuestionVo.setBody(object);
|
|
|
|
|
|
JSONArray answers = json.getJSONArray("answers");
|
|
JSONArray answers = json.getJSONArray("answers");
|
|
@@ -490,11 +488,10 @@ public class WpsController extends BaseSystemController {
|
|
//解析body
|
|
//解析body
|
|
JSONObject object = jsonObject.getJSONObject("body");
|
|
JSONObject object = jsonObject.getJSONObject("body");
|
|
JSONArray jsonArray = object.getJSONArray("sections");
|
|
JSONArray jsonArray = object.getJSONArray("sections");
|
|
|
|
+ List<WpsSectionsVo> wpsSectionsVoList = new ArrayList<>();
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
JSONObject obj = jsonArray.getJSONObject(i);
|
|
JSONObject obj = jsonArray.getJSONObject(i);
|
|
JSONArray array = obj.getJSONArray("blocks");
|
|
JSONArray array = obj.getJSONArray("blocks");
|
|
- List<WpsSectionsVo> wpsSectionsVoList = new ArrayList<>();
|
|
|
|
- List<WpsBlocksVo> wpsBlocksVoList = new ArrayList<>();
|
|
|
|
for (int j = 0; j < array.size(); j++) {
|
|
for (int j = 0; j < array.size(); j++) {
|
|
JSONObject arrayJSONObject = array.getJSONObject(j);
|
|
JSONObject arrayJSONObject = array.getJSONObject(j);
|
|
String type = arrayJSONObject.getString("type");
|
|
String type = arrayJSONObject.getString("type");
|
|
@@ -508,9 +505,15 @@ public class WpsController extends BaseSystemController {
|
|
set = this.replaceHtmlTag(value, "span");
|
|
set = this.replaceHtmlTag(value, "span");
|
|
}
|
|
}
|
|
if (!CollectionUtils.isEmpty(set)) {
|
|
if (!CollectionUtils.isEmpty(set)) {
|
|
- set.stream().peek(s -> wpsBlocksVoList.add(new WpsBlocksVo("text", s))).collect(Collectors.toSet());
|
|
|
|
|
|
+ for (String s : set) {
|
|
|
|
+ List<WpsBlocksVo> wpsBlocksVoList = new ArrayList<>();
|
|
|
|
+ wpsBlocksVoList.add(new WpsBlocksVo("text", s));
|
|
|
|
+ wpsSectionsVoList.add(new WpsSectionsVo(wpsBlocksVoList));
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
|
|
+ List<WpsBlocksVo> wpsBlocksVoList = new ArrayList<>();
|
|
wpsBlocksVoList.add(new WpsBlocksVo("text", value));
|
|
wpsBlocksVoList.add(new WpsBlocksVo("text", value));
|
|
|
|
+ wpsSectionsVoList.add(new WpsSectionsVo(wpsBlocksVoList));
|
|
}
|
|
}
|
|
} else if (Objects.nonNull(type) && Objects.equals(type.trim(), "file")) {
|
|
} else if (Objects.nonNull(type) && Objects.equals(type.trim(), "file")) {
|
|
File rootFile = this.createWpsRootPath(DateUtil.format(new Date(), SystemConstant.WPS_DEFAULT_DATE_PATTERN));
|
|
File rootFile = this.createWpsRootPath(DateUtil.format(new Date(), SystemConstant.WPS_DEFAULT_DATE_PATTERN));
|
|
@@ -523,12 +526,13 @@ public class WpsController extends BaseSystemController {
|
|
WpsParamVo wpsParamVo = new WpsParamVo(id, score, wpsOperationFile);
|
|
WpsParamVo wpsParamVo = new WpsParamVo(id, score, wpsOperationFile);
|
|
arrayJSONObject.put("wpsValue", value);
|
|
arrayJSONObject.put("wpsValue", value);
|
|
arrayJSONObject.put("value", wpsParamVo);
|
|
arrayJSONObject.put("value", wpsParamVo);
|
|
|
|
+ List<WpsBlocksVo> wpsBlocksVoList = new ArrayList<>();
|
|
wpsBlocksVoList.add(new WpsBlocksVo("file", JacksonUtil.parseJson(wpsParamVo)));
|
|
wpsBlocksVoList.add(new WpsBlocksVo("file", JacksonUtil.parseJson(wpsParamVo)));
|
|
|
|
+ wpsSectionsVoList.add(new WpsSectionsVo(wpsBlocksVoList));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- wpsSectionsVoList.add(new WpsSectionsVo(wpsBlocksVoList));
|
|
|
|
- object.put("sections", JSONArray.parseArray(JacksonUtil.parseJson(wpsSectionsVoList)));
|
|
|
|
}
|
|
}
|
|
|
|
+ object.put("sections", JSONArray.parseArray(JacksonUtil.parseJson(wpsSectionsVoList)));
|
|
//解析operationDesc
|
|
//解析operationDesc
|
|
String operationDesc = jsonObject.getString("operationDesc");
|
|
String operationDesc = jsonObject.getString("operationDesc");
|
|
Set<String> set = this.replaceHtmlTag(operationDesc, "p");
|
|
Set<String> set = this.replaceHtmlTag(operationDesc, "p");
|
|
@@ -538,15 +542,22 @@ public class WpsController extends BaseSystemController {
|
|
if (CollectionUtils.isEmpty(set)) {
|
|
if (CollectionUtils.isEmpty(set)) {
|
|
set = this.replaceHtmlTag(operationDesc, "span");
|
|
set = this.replaceHtmlTag(operationDesc, "span");
|
|
}
|
|
}
|
|
- List<WpsBlocksVo> wpsBlocksVoList = new ArrayList<>();
|
|
|
|
- List<WpsSectionsVo> wpsSectionsVoList = new ArrayList<>();
|
|
|
|
- wpsSectionsVoList.add(new WpsSectionsVo(wpsBlocksVoList));
|
|
|
|
|
|
+
|
|
|
|
+ List<WpsAnswerSectionsVo> wpsAnswerSectionsVoList = new ArrayList<>();
|
|
|
|
+ wpsSectionsVoList = new ArrayList<>();
|
|
if (!CollectionUtils.isEmpty(set)) {
|
|
if (!CollectionUtils.isEmpty(set)) {
|
|
- set.stream().peek(s -> wpsBlocksVoList.add(new WpsBlocksVo("text", s))).collect(Collectors.toSet());
|
|
|
|
|
|
+ for (String s : set) {
|
|
|
|
+ List<WpsBlocksVo> wpsBlocksVoList = new ArrayList<>();
|
|
|
|
+ wpsBlocksVoList.add(new WpsBlocksVo("text", s));
|
|
|
|
+ wpsSectionsVoList.add(new WpsSectionsVo(wpsBlocksVoList));
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
|
|
+ List<WpsBlocksVo> wpsBlocksVoList = new ArrayList<>();
|
|
wpsBlocksVoList.add(new WpsBlocksVo("text", operationDesc));
|
|
wpsBlocksVoList.add(new WpsBlocksVo("text", operationDesc));
|
|
|
|
+ wpsSectionsVoList.add(new WpsSectionsVo(wpsBlocksVoList));
|
|
}
|
|
}
|
|
- json.put("answer", JSONArray.parseArray(JacksonUtil.parseJson(wpsSectionsVoList)));
|
|
|
|
|
|
+ wpsAnswerSectionsVoList.add(new WpsAnswerSectionsVo(wpsSectionsVoList));
|
|
|
|
+ json.put("answer", JSONArray.parseArray(JacksonUtil.parseJson(wpsAnswerSectionsVoList)));
|
|
json.put("body", object);
|
|
json.put("body", object);
|
|
json.put("answers", jsonObject.get("answers"));
|
|
json.put("answers", jsonObject.get("answers"));
|
|
json.put("rightAnswers", jsonObject.get("rightAnswers"));
|
|
json.put("rightAnswers", jsonObject.get("rightAnswers"));
|