deason 5 vuotta sitten
vanhempi
commit
ab19c2a9e6

+ 10 - 10
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperServiceImpl.java

@@ -1193,20 +1193,12 @@ public class PaperServiceImpl implements PaperService {
         final String mp3FileName = questionId + "_" + randomNumber + "_" + file.getOriginalFilename();
         File mp3File = new File(mp3DirectoryPath + File.separator + mp3FileName);
 
-        FileOutputStream outputStream = null;
+        FileOutputStream outputStream;
         try {
             outputStream = new FileOutputStream(mp3File);
         } catch (FileNotFoundException e) {
             log.error(e.getMessage(), e);
             throw new StatusException("500", "音频文件处理失败!");
-        } finally {
-            try {
-                if (outputStream != null) {
-                    outputStream.close();
-                }
-            } catch (IOException e) {
-                //ignore
-            }
         }
 
         try (InputStream is = file.getInputStream();
@@ -1228,6 +1220,14 @@ public class PaperServiceImpl implements PaperService {
         } catch (Exception e) {
             log.error(e.getMessage(), e);
             throw new StatusException("500", "音频文件保存失败!");
+        } finally {
+            try {
+                if (outputStream != null) {
+                    outputStream.close();
+                }
+            } catch (IOException e) {
+                //ignore
+            }
         }
     }
 
@@ -1266,7 +1266,7 @@ public class PaperServiceImpl implements PaperService {
             //处理选项
             for (QuesOption quesOption : question.getQuesOptions()) {
                 Integer optNumber = CommonUtils.characterToNumber(numbers[2]);
-                if (!quesOption.getNumber().equals(optNumber)) {
+                if (!quesOption.getNumber().equals(optNumber.toString())) {
                     continue;
                 }