浏览代码

导入导出bugfix

wangliang 4 年之前
父节点
当前提交
5ab51b4acf

+ 5 - 0
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskExamPaperImportTemplete.java

@@ -95,6 +95,11 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
             log.error("处理出错 ", e);
             log.error("处理出错 ", e);
             addResult(result, "处理出错 " + e.getMessage());
             addResult(result, "处理出错 " + e.getMessage());
             taskImportCommon.getTbTaskHistory().setSummary("处理出错");
             taskImportCommon.getTbTaskHistory().setSummary("处理出错");
+            if (e instanceof BusinessException) {
+                throw new BusinessException(e.getMessage());
+            } else {
+                throw new RuntimeException(e);
+            }
         } finally {
         } finally {
             if (file != null) {
             if (file != null) {
                 file.delete();
                 file.delete();

+ 6 - 1
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskExamStudentExportTemplete.java

@@ -15,6 +15,7 @@ import java.util.StringJoiner;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 
 
+import com.qmth.themis.common.exception.BusinessException;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -89,8 +90,12 @@ public class TaskExamStudentExportTemplete implements TaskExportTemplete {
             log.error("导出报错", e);
             log.error("导出报错", e);
             taskExportCommon.setException(true);
             taskExportCommon.setException(true);
             taskExportCommon.getTbTaskHistory().setSummary("处理出错");
             taskExportCommon.getTbTaskHistory().setSummary("处理出错");
+            if (e instanceof BusinessException) {
+                throw new BusinessException(e.getMessage());
+            } else {
+                throw new RuntimeException(e);
+            }
         } finally {
         } finally {
-        	
             taskExportCommon.getTbTaskHistory().setFinishTime(System.currentTimeMillis());
             taskExportCommon.getTbTaskHistory().setFinishTime(System.currentTimeMillis());
             taskExportCommon.getTbTaskHistory().setStatus(TaskStatusEnum.FINISH);
             taskExportCommon.getTbTaskHistory().setStatus(TaskStatusEnum.FINISH);
             taskExportCommon.getTbTaskHistory().setProgress(100.0d);
             taskExportCommon.getTbTaskHistory().setProgress(100.0d);

+ 5 - 0
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskExamStudentImportTemplete.java

@@ -117,6 +117,11 @@ public class TaskExamStudentImportTemplete implements TaskImportTemplete {
             log.error("导入报错", e);
             log.error("导入报错", e);
             int min = Objects.isNull(map.get("min")) ? 0 : Integer.parseInt(String.valueOf(map.get("min")));
             int min = Objects.isNull(map.get("min")) ? 0 : Integer.parseInt(String.valueOf(map.get("min")));
             taskImportCommon.exception(min, e, taskImportCommon.getTxtList());
             taskImportCommon.exception(min, e, taskImportCommon.getTxtList());
+            if (e instanceof BusinessException) {
+                throw new BusinessException(e.getMessage());
+            } else {
+                throw new RuntimeException(e);
+            }
         } finally {
         } finally {
             //这里写入txt文件
             //这里写入txt文件
             taskImportCommon.writeImportResultTxt(taskImportCommon.getTxtList().toString(), file);
             taskImportCommon.writeImportResultTxt(taskImportCommon.getTxtList().toString(), file);

+ 6 - 0
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultSimpleExportTemplete.java

@@ -15,6 +15,7 @@ import com.qmth.themis.business.service.TOeExamRecordService;
 import com.qmth.themis.business.templete.TaskExportCommon;
 import com.qmth.themis.business.templete.TaskExportCommon;
 import com.qmth.themis.business.templete.TaskExportTemplete;
 import com.qmth.themis.business.templete.TaskExportTemplete;
 import com.qmth.themis.business.templete.service.TempleteLogicService;
 import com.qmth.themis.business.templete.service.TempleteLogicService;
+import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import com.qmth.themis.common.util.ResultUtil;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
@@ -171,6 +172,11 @@ public class TaskMarkResultSimpleExportTemplete implements TaskExportTemplete {
         } catch (Exception e) {
         } catch (Exception e) {
             log.error("导出报错", e);
             log.error("导出报错", e);
             taskExportCommon.exception(min, e, taskExportCommon.getTxtList());
             taskExportCommon.exception(min, e, taskExportCommon.getTxtList());
+            if (e instanceof BusinessException) {
+                throw new BusinessException(e.getMessage());
+            } else {
+                throw new RuntimeException(e);
+            }
         } finally {
         } finally {
             //这里写入txt文件
             //这里写入txt文件
             taskExportCommon.writeExportResultTxt(stringJoiner.toString(), taskExportCommon.getTxtList().toString(), excelFilePath);
             taskExportCommon.writeExportResultTxt(stringJoiner.toString(), taskExportCommon.getTxtList().toString(), excelFilePath);

+ 6 - 0
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultStandardExportTemplete.java

@@ -21,6 +21,7 @@ import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.templete.TaskExportCommon;
 import com.qmth.themis.business.templete.TaskExportCommon;
 import com.qmth.themis.business.templete.TaskExportTemplete;
 import com.qmth.themis.business.templete.TaskExportTemplete;
 import com.qmth.themis.business.templete.service.TempleteLogicService;
 import com.qmth.themis.business.templete.service.TempleteLogicService;
+import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import com.qmth.themis.common.util.ResultUtil;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
@@ -282,6 +283,11 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
         } catch (Exception e) {
         } catch (Exception e) {
             log.error("导出报错", e);
             log.error("导出报错", e);
             taskExportCommon.exception(min, e, taskExportCommon.getTxtList());
             taskExportCommon.exception(min, e, taskExportCommon.getTxtList());
+            if (e instanceof BusinessException) {
+                throw new BusinessException(e.getMessage());
+            } else {
+                throw new RuntimeException(e);
+            }
         } finally {
         } finally {
             //这里写入txt文件
             //这里写入txt文件
             taskExportCommon.writeExportResultTxt(stringJoiner.toString(), taskExportCommon.getTxtList().toString(), excelFilePath);
             taskExportCommon.writeExportResultTxt(stringJoiner.toString(), taskExportCommon.getTxtList().toString(), excelFilePath);

+ 6 - 0
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskRoomCodeExportTemplete.java

@@ -8,6 +8,7 @@ import com.qmth.themis.business.service.TBExamInvigilateUserService;
 import com.qmth.themis.business.templete.TaskExportCommon;
 import com.qmth.themis.business.templete.TaskExportCommon;
 import com.qmth.themis.business.templete.TaskExportTemplete;
 import com.qmth.themis.business.templete.TaskExportTemplete;
 import com.qmth.themis.business.templete.service.TempleteLogicService;
 import com.qmth.themis.business.templete.service.TempleteLogicService;
+import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import com.qmth.themis.common.util.ResultUtil;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
@@ -134,6 +135,11 @@ public class TaskRoomCodeExportTemplete implements TaskExportTemplete {
         } catch (Exception e) {
         } catch (Exception e) {
             log.error("导出报错", e);
             log.error("导出报错", e);
             taskExportCommon.exception(min, e, taskExportCommon.getTxtList());
             taskExportCommon.exception(min, e, taskExportCommon.getTxtList());
+            if (e instanceof BusinessException) {
+                throw new BusinessException(e.getMessage());
+            } else {
+                throw new RuntimeException(e);
+            }
         } finally {
         } finally {
             //这里写入txt文件
             //这里写入txt文件
             taskExportCommon.writeExportResultTxt(stringJoiner.toString(), taskExportCommon.getTxtList().toString(), excelFilePath);
             taskExportCommon.writeExportResultTxt(stringJoiner.toString(), taskExportCommon.getTxtList().toString(), excelFilePath);

+ 5 - 0
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskRoomCodeImportTemplete.java

@@ -97,6 +97,11 @@ public class TaskRoomCodeImportTemplete implements TaskImportTemplete {
             log.error("导入报错", e);
             log.error("导入报错", e);
             int min = Objects.isNull(map.get("min")) ? 0 : Integer.parseInt(String.valueOf(map.get("min")));
             int min = Objects.isNull(map.get("min")) ? 0 : Integer.parseInt(String.valueOf(map.get("min")));
             taskImportCommon.exception(min, e, taskImportCommon.getTxtList());
             taskImportCommon.exception(min, e, taskImportCommon.getTxtList());
+            if (e instanceof BusinessException) {
+                throw new BusinessException(e.getMessage());
+            } else {
+                throw new RuntimeException(e);
+            }
         } finally {
         } finally {
             //这里写入txt文件
             //这里写入txt文件
             taskImportCommon.writeImportResultTxt(taskImportCommon.getTxtList().toString(), file);
             taskImportCommon.writeImportResultTxt(taskImportCommon.getTxtList().toString(), file);