|
@@ -1041,7 +1041,7 @@ public class PaperServiceImpl implements PaperService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public Map<String, String> checkRadioFile(String paperId, List<String> filesName) {
|
|
public Map<String, String> checkRadioFile(String paperId, List<String> filesName) {
|
|
- Map<String, String> messageMap = new HashMap<String, String>();
|
|
|
|
|
|
+ Map<String, String> messageMap = new HashMap<>();
|
|
//判断文件名中格式是否正确
|
|
//判断文件名中格式是否正确
|
|
for (String fileName : filesName) {
|
|
for (String fileName : filesName) {
|
|
String[] fileNames = fileName.split("\\.");
|
|
String[] fileNames = fileName.split("\\.");
|
|
@@ -1050,30 +1050,36 @@ public class PaperServiceImpl implements PaperService {
|
|
messageMap.put("errorMsg", fileName + ",文件格式不正确,当前支持格式:" + upYunProperty.getRadioType());
|
|
messageMap.put("errorMsg", fileName + ",文件格式不正确,当前支持格式:" + upYunProperty.getRadioType());
|
|
return messageMap;
|
|
return messageMap;
|
|
}
|
|
}
|
|
|
|
+
|
|
String pattern_01 = "\\d+_1_\\d{1,2}"; //题干正则
|
|
String pattern_01 = "\\d+_1_\\d{1,2}"; //题干正则
|
|
String pattern_02 = "\\d+_2_[A-Z|a-z]_\\d{1,2}"; //选项正则
|
|
String pattern_02 = "\\d+_2_[A-Z|a-z]_\\d{1,2}"; //选项正则
|
|
- if (!(Pattern.matches(pattern_01, fileNames[0]) ||
|
|
|
|
- Pattern.matches(pattern_02, fileNames[0]))) {
|
|
|
|
|
|
+ if (!(Pattern.matches(pattern_01, fileNames[0]) || Pattern.matches(pattern_02, fileNames[0]))) {
|
|
messageMap.put("errorMsg", fileName + "文件名格式不正确,请检查");
|
|
messageMap.put("errorMsg", fileName + "文件名格式不正确,请检查");
|
|
return messageMap;
|
|
return messageMap;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
//根据试卷id,查询该试卷
|
|
//根据试卷id,查询该试卷
|
|
Paper paper = Model.of(paperRepo.findById(paperId));
|
|
Paper paper = Model.of(paperRepo.findById(paperId));
|
|
|
|
+
|
|
//根据试卷查询所有的小题
|
|
//根据试卷查询所有的小题
|
|
List<PaperDetailUnit> paperDetailUnits = paperDetailUnitRepo.findByPaperOrderByNumber(paper);
|
|
List<PaperDetailUnit> paperDetailUnits = paperDetailUnitRepo.findByPaperOrderByNumber(paper);
|
|
|
|
+
|
|
String names = "";
|
|
String names = "";
|
|
for (PaperDetailUnit paperDetailUnit : paperDetailUnits) {
|
|
for (PaperDetailUnit paperDetailUnit : paperDetailUnits) {
|
|
names = names + paperDetailUnit.getNumber().toString() + ",";
|
|
names = names + paperDetailUnit.getNumber().toString() + ",";
|
|
}
|
|
}
|
|
|
|
+
|
|
for (String fileName : filesName) {
|
|
for (String fileName : filesName) {
|
|
String fileNames[] = fileName.split("_");
|
|
String fileNames[] = fileName.split("_");
|
|
|
|
+
|
|
//先判断小题号是否正确
|
|
//先判断小题号是否正确
|
|
String fileNameFirst = fileNames[0];
|
|
String fileNameFirst = fileNames[0];
|
|
if (!names.contains(fileNameFirst)) {
|
|
if (!names.contains(fileNameFirst)) {
|
|
messageMap.put("errorMsg", fileName + "文件,试卷中没有对应的小题");
|
|
messageMap.put("errorMsg", fileName + "文件,试卷中没有对应的小题");
|
|
return messageMap;
|
|
return messageMap;
|
|
}
|
|
}
|
|
|
|
+
|
|
//再判断题干中是否存在ABCD
|
|
//再判断题干中是否存在ABCD
|
|
String fileNameSecond = fileNames[1];
|
|
String fileNameSecond = fileNames[1];
|
|
if (fileNameSecond.equals("1")) {
|
|
if (fileNameSecond.equals("1")) {
|
|
@@ -1085,6 +1091,7 @@ public class PaperServiceImpl implements PaperService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
//判断选项
|
|
//判断选项
|
|
else if (fileNameSecond.equals("2")) {
|
|
else if (fileNameSecond.equals("2")) {
|
|
messageMap = checkOptions(paperDetailUnits, fileNames, fileName);
|
|
messageMap = checkOptions(paperDetailUnits, fileNames, fileName);
|
|
@@ -1097,6 +1104,7 @@ public class PaperServiceImpl implements PaperService {
|
|
return messageMap;
|
|
return messageMap;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
messageMap.put("errorMsg", "OK");
|
|
messageMap.put("errorMsg", "OK");
|
|
return messageMap;
|
|
return messageMap;
|
|
}
|
|
}
|
|
@@ -1140,7 +1148,7 @@ public class PaperServiceImpl implements PaperService {
|
|
* @param paperId
|
|
* @param paperId
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
- public void uploadRadio(List<MultipartFile> files, String paperId, User user) throws IOException {
|
|
|
|
|
|
+ public void uploadRadio(List<MultipartFile> files, String paperId, User user) {
|
|
//根据试卷id,查询该试卷
|
|
//根据试卷id,查询该试卷
|
|
Paper paper = Model.of(paperRepo.findById(paperId));
|
|
Paper paper = Model.of(paperRepo.findById(paperId));
|
|
|
|
|
|
@@ -1173,8 +1181,12 @@ public class PaperServiceImpl implements PaperService {
|
|
|
|
|
|
//删除服务器文件夹
|
|
//删除服务器文件夹
|
|
String mp3DirectoryPath = TEMP_FILE_EXP + File.separator + paperId;
|
|
String mp3DirectoryPath = TEMP_FILE_EXP + File.separator + paperId;
|
|
- File mp3Directory = new File(mp3DirectoryPath);
|
|
|
|
- FileUtils.deleteDirectory(mp3Directory);
|
|
|
|
|
|
+ try {
|
|
|
|
+ File mp3Directory = new File(mp3DirectoryPath);
|
|
|
|
+ FileUtils.deleteDirectory(mp3Directory);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|