xiatian 7 mesiacov pred
rodič
commit
1ad2cd6c28

+ 40 - 0
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/export_course_questions_count/BatchQuestionsMaxCountDto.java

@@ -0,0 +1,40 @@
+package cn.com.qmth.dp.examcloud.oe.modules.export_course_questions_count;
+
+import cn.com.qmth.dp.examcloud.oe.excel.ExcelProperty;
+
+public class BatchQuestionsMaxCountDto {
+
+    @ExcelProperty(name = "课程名称", width = 25, index = 1)
+    private String courseName;
+
+    @ExcelProperty(name = "课程代码", width = 25, index = 2)
+    private String courseCode;
+
+    @ExcelProperty(name = "试题数", width = 15, index = 3)
+    private int count;
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public int getCount() {
+        return count;
+    }
+
+    public void setCount(int count) {
+        this.count = count;
+    }
+
+}

+ 32 - 28
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/export_course_questions_count/FomatExcelFileUtil.java

@@ -24,17 +24,17 @@ public class FomatExcelFileUtil {
     private static String dir = "d:/examcloud-data-export/ret/";
 
     public static void main(String[] args) {
-        Map<String, BatchQuestionsCountDto> map = new HashMap<>();
+        Map<String, BatchQuestionsMaxCountDto> map = new HashMap<>();
         File dirFile = new File(dir);
         for (File f : dirFile.listFiles()) {
             fillData(f, map);
         }
-        List<BatchQuestionsCountDto> ret = new ArrayList<>();
+        List<BatchQuestionsMaxCountDto> ret = new ArrayList<>();
         ret.addAll(map.values());
-        Collections.sort(ret, new Comparator<BatchQuestionsCountDto>() {
+        Collections.sort(ret, new Comparator<BatchQuestionsMaxCountDto>() {
 
             @Override
-            public int compare(BatchQuestionsCountDto o1, BatchQuestionsCountDto o2) {
+            public int compare(BatchQuestionsMaxCountDto o1, BatchQuestionsMaxCountDto o2) {
                 String c1 = o1.getCourseCode();
                 String c2 = o2.getCourseCode();
                 return c1.compareTo(c2);
@@ -49,7 +49,7 @@ public class FomatExcelFileUtil {
             }
             file.createNewFile();
             fos = new FileOutputStream(file);
-            ExportUtils.makeExcel(BatchQuestionsCountDto.class, ret, fos);
+            ExportUtils.makeExcel(BatchQuestionsMaxCountDto.class, ret, fos);
         } catch (Exception e) {
             e.printStackTrace();
         } finally {
@@ -63,9 +63,9 @@ public class FomatExcelFileUtil {
         }
     }
 
-    private static void fillData(File file, Map<String, BatchQuestionsCountDto> map) {
-        String fileName = file.getName();
-        String fn = fileName.substring(0, fileName.lastIndexOf("."));
+    private static void fillData(File file, Map<String, BatchQuestionsMaxCountDto> map) {
+        // String fileName = file.getName();
+        // String fn = fileName.substring(0, fileName.lastIndexOf("."));
         XSSFWorkbook wb = null;
         try {
             wb = new XSSFWorkbook(file);
@@ -80,33 +80,37 @@ public class FomatExcelFileUtil {
                     String val = row.getCell(c).getStringCellValue().trim();
                     total = total + Integer.valueOf(val);
                 }
-                BatchQuestionsCountDto dto = map.get(subjectCode);
+                BatchQuestionsMaxCountDto dto = map.get(subjectCode);
                 if (dto == null) {
-                    dto = new BatchQuestionsCountDto();
+                    dto = new BatchQuestionsMaxCountDto();
                     dto.setCourseCode(subjectCode);
                     dto.setCourseName(subjectName);
                     map.put(subjectCode, dto);
                 }
-                if ("230517".equals(fn)) {
-                    dto.setC1(total);
-                } else if ("230821".equals(fn)) {
-                    dto.setC2(total);
-                } else if ("230914".equals(fn)) {
-                    dto.setC3(total);
-                } else if ("231205".equals(fn)) {
-                    dto.setC4(total);
-                } else if ("231219".equals(fn)) {
-                    dto.setC5(total);
-                } else if ("240313".equals(fn)) {
-                    dto.setC6(total);
-                } else if ("240320".equals(fn)) {
-                    dto.setC7(total);
-                } else if ("240612".equals(fn)) {
-                    dto.setC8(total);
-                } else if ("240618".equals(fn)) {
-                    dto.setC9(total);
+                if (dto.getCount() < total) {
+                    dto.setCount(total);
                 }
 
+                // if ("230517".equals(fn)) {
+                // dto.setC1(total);
+                // } else if ("230821".equals(fn)) {
+                // dto.setC2(total);
+                // } else if ("230914".equals(fn)) {
+                // dto.setC3(total);
+                // } else if ("231205".equals(fn)) {
+                // dto.setC4(total);
+                // } else if ("231219".equals(fn)) {
+                // dto.setC5(total);
+                // } else if ("240313".equals(fn)) {
+                // dto.setC6(total);
+                // } else if ("240320".equals(fn)) {
+                // dto.setC7(total);
+                // } else if ("240612".equals(fn)) {
+                // dto.setC8(total);
+                // } else if ("240618".equals(fn)) {
+                // dto.setC9(total);
+                // }
+
             }
         } catch (Exception e) {
             throw new RuntimeException(e);