deason 8 mēneši atpakaļ
vecāks
revīzija
4afda3b241

+ 10 - 9
src/main/java/com/qmth/exam/reserve/service/impl/MaterialGenerateServiceImpl.java

@@ -52,30 +52,31 @@ public class MaterialGenerateServiceImpl implements MaterialGenerateService {
             doc.add(subHead(title, totalSize, FONT_SIZE));
             doc.add(overviewTable(FONT_SIZE, 100, 80, 20));//todo
 
+            int rowCount = FIRST_PAGE_STUDENT_ROW_COUNT;
             List<StudentApplyVO> tempList = new ArrayList<>();
             for (int index = 0; index < totalSize; index++) {
                 tempList.add(studentList.get(index));
 
-                int rowCount = 0;
-                if (index < FIRST_PAGE_STUDENT_ROW_COUNT * STUDENT_GROUP_COUNT) {
-                    // 首页
-                    rowCount = FIRST_PAGE_STUDENT_ROW_COUNT;
-                } else {
+                if (index >= FIRST_PAGE_STUDENT_ROW_COUNT * STUDENT_GROUP_COUNT) {
                     // 非首页
                     rowCount = NOT_FIRST_PAGE_STUDENT_ROW_COUNT;
                 }
 
-                if (tempList.size() == rowCount * STUDENT_GROUP_COUNT || index == totalSize - 1) {
+                if (tempList.size() == rowCount * STUDENT_GROUP_COUNT) {
                     createSignInTable(tempList, doc, rowCount);
-
-                    if (tempList.size() == rowCount * STUDENT_GROUP_COUNT) {
+                    if (index != totalSize - 1) {
+                        // 非末页
                         doc.add(new AreaBreak());
                     }
-
                     tempList.clear();
                 }
             }
 
+            if (!tempList.isEmpty()) {
+                createSignInTable(tempList, doc, rowCount);
+                tempList.clear();
+            }
+
             return file;
         } catch (Exception e) {
             log.error(e.getMessage(), e);