소스 검색

导入导出bugfix

wangliang 4 년 전
부모
커밋
1e4513c26a

+ 4 - 4
themis-business/src/main/java/com/qmth/themis/business/templete/TaskExportCommon.java

@@ -188,17 +188,17 @@ public class TaskExportCommon {
      * 异常处理
      *
      * @param min
-     * @param y
      * @param e
      * @param txtList
      * @return
      */
-    public List<String> exception(int min, int y, Exception e, List<String> txtList) {
+    public List<String> exception(int min, Exception e, List<String> txtList) {
         this.exception = true;
-        String exceptionStr = "数据导出到第" + (y == 0 ? y + 1 : y) + "条时发生异常,请联系系统管理员处理!";
-        txtList.add(DateUtil.format(new Date(), this.timeFormat) + "->" + exceptionStr);
+        String exceptionStr = "数据导出到第" + (min == 0 ? min + 1 : min) + "条时发生异常,请查看报告或联系系统管理员处理!";
+        txtList.add(DateUtil.format(new Date(), this.timeFormat) + "->" + exceptionStr + "错误信息:[" + e.getMessage() + "]");
         this.tbTaskHistory.setSummary(exceptionStr);
         this.tbTaskHistory.setStatus(TaskStatusEnum.FINISH);
+        tbTaskHistoryService.updateById(this.tbTaskHistory);
         return txtList;
     }
 

+ 3 - 2
themis-business/src/main/java/com/qmth/themis/business/templete/TaskImportCommon.java

@@ -165,10 +165,11 @@ public class TaskImportCommon {
      */
     public List<String> exception(int min, Exception e, List<String> txtList) {
         this.exception = true;
-        String exceptionStr = "数据处理到第" + (min == 0 ? min + 1 : min) + "条时发生异常,请联系系统管理员处理!";
-        txtList.add(DateUtil.format(new Date(), this.timeFormat) + "->" + exceptionStr);
+        String exceptionStr = "数据处理到第" + (min == 0 ? min + 1 : min) + "条时发生异常,请查看报告或联系系统管理员处理!";
+        txtList.add(DateUtil.format(new Date(), this.timeFormat) + "->" + exceptionStr + "错误信息:[" + e.getMessage() + "]");
         this.tbTaskHistory.setSummary(exceptionStr);
         this.tbTaskHistory.setStatus(TaskStatusEnum.FINISH);
+        tbTaskHistoryService.updateById(this.tbTaskHistory);
         return txtList;
     }
 

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

@@ -72,7 +72,7 @@ public class TaskMarkResultSimpleExportTemplete implements TaskExportTemplete {
         String excelFilePath = null;
         InputStream inputStream = null;
         ByteArrayOutputStream out = null;
-        int y = 0, min = 0;
+        int min = 0;
         try {
             taskExportCommon.getTxtList().add(DateUtil.format(new Date(), timeFormat) + "->开始准备处理导出的成绩简版数据");
             Long examId = (Long) map.get("examId");
@@ -133,7 +133,7 @@ public class TaskMarkResultSimpleExportTemplete implements TaskExportTemplete {
             while (max <= size) {
                 List subList = markResultSimpleExportDtoList.subList(min, max);
                 //绘制数据
-                for (; y < subList.size(); y++) {
+                for (int y = 0; y < subList.size(); y++) {
                     MarkResultSimpleExportDto markResultSimpleExportDto = (MarkResultSimpleExportDto) subList.get(y);
                     int firstRow = y + 1;
                     cellIndex = 0;
@@ -170,7 +170,7 @@ public class TaskMarkResultSimpleExportTemplete implements TaskExportTemplete {
             log.info("导出成绩简版数据结束,============耗时============:{}秒", (end - start) / 1000);
         } catch (Exception e) {
             log.error("导出报错", e);
-            taskExportCommon.exception(min, y, e, taskExportCommon.getTxtList());
+            taskExportCommon.exception(min, e, taskExportCommon.getTxtList());
         } finally {
             //这里写入txt文件
             taskExportCommon.writeExportResultTxt(stringJoiner.toString(), taskExportCommon.getTxtList().toString(), excelFilePath);

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

@@ -84,7 +84,7 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
         String excelFilePath = null;
         InputStream inputStream = null;
         ByteArrayOutputStream out = null;
-        int y = 0, min = 0;
+        int min = 0;
         try {
             taskExportCommon.getTxtList().add(DateUtil.format(new Date(), timeFormat) + "->开始准备处理导出的成绩标准版数据");
             Long examId = (Long) map.get("examId");
@@ -231,7 +231,7 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
             while (max <= size) {
                 List subList = markResultStandardExportDtoList.subList(min, max);
                 //绘制数据
-                for (; y < subList.size(); y++) {
+                for (int y = 0; y < subList.size(); y++) {
                     MarkResultStandardExportDto markResultStandardExportDto = (MarkResultStandardExportDto) subList.get(y);
                     int firstRow = y + 1;
                     cellIndex = 0;
@@ -281,7 +281,7 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
             log.info("导出成绩标准版数据结束,============耗时============:{}秒", (end - start) / 1000);
         } catch (Exception e) {
             log.error("导出报错", e);
-            taskExportCommon.exception(min, y, e, taskExportCommon.getTxtList());
+            taskExportCommon.exception(min, e, taskExportCommon.getTxtList());
         } finally {
             //这里写入txt文件
             taskExportCommon.writeExportResultTxt(stringJoiner.toString(), taskExportCommon.getTxtList().toString(), excelFilePath);

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

@@ -58,7 +58,7 @@ public class TaskRoomCodeExportTemplete implements TaskExportTemplete {
         String excelFilePath = null;
         InputStream inputStream = null;
         ByteArrayOutputStream out = null;
-        int y = 0, min = 0;
+        int min = 0;
         try {
             taskExportCommon.getTxtList().add(DateUtil.format(new Date(), timeFormat) + "->开始准备处理导出的考场数据");
             Long examId = (Long) map.get("examId");
@@ -99,7 +99,7 @@ public class TaskRoomCodeExportTemplete implements TaskExportTemplete {
             while (max <= size) {
                 List subList = roomCodeExportDtoList.subList(min, max);
                 //绘制数据
-                for (; y < subList.size(); y++) {
+                for (int y = 0; y < subList.size(); y++) {
                     RoomCodeExportDto roomCodeExportDto = (RoomCodeExportDto) subList.get(y);
                     int firstRow = y + 1;
                     cellIndex = 0;
@@ -133,7 +133,7 @@ public class TaskRoomCodeExportTemplete implements TaskExportTemplete {
             log.info("导出考场数据结束,============耗时============:{}秒", (end - start) / 1000);
         } catch (Exception e) {
             log.error("导出报错", e);
-            taskExportCommon.exception(min, y, e, taskExportCommon.getTxtList());
+            taskExportCommon.exception(min, e, taskExportCommon.getTxtList());
         } finally {
             //这里写入txt文件
             taskExportCommon.writeExportResultTxt(stringJoiner.toString(), taskExportCommon.getTxtList().toString(), excelFilePath);

+ 5 - 2
themis-business/src/main/java/com/qmth/themis/business/templete/service/impl/TempleteLogicServiceImpl.java

@@ -53,6 +53,9 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
     @Resource
     TEExamCourseService teExamCourseService;
 
+    @Resource
+    TBTaskHistoryService tbTaskHistoryService;
+
     /**
      * 考生导入逻辑
      *
@@ -61,7 +64,6 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
      * @return
      */
     @Override
-    @Transactional
     public Map<String, Object> execImportExamStudentLogic(List<LinkedMultiValueMap<Integer, Object>> finalList, Map<String, Object> map) {
         Long orgId = Long.parseLong(String.valueOf(map.get("orgId")));
         Long examId = Long.parseLong(String.valueOf(map.get("examId")));
@@ -224,7 +226,6 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
      * @return
      */
     @Override
-    @Transactional
     public Map<String, Object> execImportRoomCodeLogic(List<LinkedMultiValueMap<Integer, Object>> finalList, Map<String, Object> map) {
         Long orgId = null;
         if (Objects.nonNull(map.get("orgId"))) {
@@ -380,6 +381,7 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
             txtList.add(DateUtil.format(new Date(), timeFormat) + "->数据处理中," + tbTaskHistory.getSummary());
         }
         tbTaskHistory.setProgress(progress.doubleValue());
+        tbTaskHistoryService.updateById(tbTaskHistory);
         return txtList;
     }
 
@@ -418,6 +420,7 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
             txtList.add(DateUtil.format(new Date(), timeFormat) + "->数据导出中," + tbTaskHistory.getSummary());
         }
         tbTaskHistory.setProgress(progress.doubleValue());
+        tbTaskHistoryService.updateById(tbTaskHistory);
         return txtList;
     }