Преглед на файлове

课时统计,详情导出

dzx преди 1 година
родител
ревизия
cd04cf8ada

+ 2 - 2
src/main/java/com/xjrsoft/module/classtime/controller/ClassTimeStatisticsController.java

@@ -191,10 +191,10 @@ public class ClassTimeStatisticsController {
         return RT.ok(recordList);
     }
 
-    @GetMapping(value = "/record-export-query")
+    @PostMapping(value = "/record-export-query")
     @ApiOperation(value="课时统计详情导出")
     @SaCheckPermission("classtimestatistics:detail")
-    public ResponseEntity<byte[]> recordExport(@Valid RefreshStatisticsDto dto) throws IOException {
+    public ResponseEntity<byte[]> recordExport(@Valid @RequestBody  RefreshStatisticsDto dto) throws IOException {
         byte[] bytes = classTimeStatisticsService.recordExport(dto.getId());
         String fileName = "recordExport" + ExcelTypeEnum.XLSX.getValue();
         return RT.fileStream(bytes, fileName);

+ 18 - 8
src/main/java/com/xjrsoft/module/classtime/service/impl/ClassTimeStatisticsServiceImpl.java

@@ -156,7 +156,7 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
     @Transactional(rollbackFor = Exception.class)
     public Boolean refreshRecord(ClassTimeStatistics statistics) {
         try {
-            // 1、查询教师
+// 1、查询教师
             List<TeacherListVo> teacherList = this.baseMapper.getTeacherList();
             // 2、查询补课课时
             List<WfTeacherCourseTime> courseTimeList = this.baseMapper.getWfTeacherCourseTimeList(statistics);
@@ -258,11 +258,11 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
                         continue;
                     }
                     if("早自习".equals(courseListVo.getShortName())){
-                        classTime7 += weightSetMap.get(courseListVo.getShortName());
+                        classTime7 += weightSetMap.get(courseListVo.getShortName()) == null ? 0d : weightSetMap.get(courseListVo.getShortName());
                     }else if(zkList.contains(courseListVo.getShortName())){
-                        classTime8 += weightSetMap.get(courseListVo.getShortName());
+                        classTime8 += weightSetMap.get(courseListVo.getShortName()) == null ? 0d : weightSetMap.get(courseListVo.getShortName());
                     }else if(wzxList.contains(courseListVo.getShortName())){
-                        classTime9 += weightSetMap.get(courseListVo.getShortName());
+                        classTime9 += weightSetMap.get(courseListVo.getShortName()) == null ? 0d : weightSetMap.get(courseListVo.getShortName());
                     }
 
                     if(courseListVo.getAdjustType() != null && !courseListVo.getAdjustType().isEmpty()){
@@ -302,11 +302,11 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
                         }
 
                         if("早自习".equals(courseListVo.getShortName())){
-                            zkTimes += weightSetMap.get(courseListVo.getShortName());
+                            zkTimes += weightSetMap.get(courseListVo.getShortName()) == null ? 0d : weightSetMap.get(courseListVo.getShortName());
                         }else if(zkList.contains(courseListVo.getShortName())){
-                            zkTimes += weightSetMap.get(courseListVo.getShortName());
+                            zkTimes += weightSetMap.get(courseListVo.getShortName()) == null ? 0d : weightSetMap.get(courseListVo.getShortName());
                         }else if(wzxList.contains(courseListVo.getShortName())){
-                            wzxTimes += weightSetMap.get(courseListVo.getShortName());
+                            wzxTimes += weightSetMap.get(courseListVo.getShortName()) == null ? 0d : weightSetMap.get(courseListVo.getShortName());
                         }
 
                         if(courseListVo.getAdjustType() != null && !courseListVo.getAdjustType().isEmpty()){
@@ -487,6 +487,7 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
      */
     @Override
     public byte[] recordExport(Long id) throws IOException {
+        try {
             //1、查询数据
             List<ClassTimeStatisticsRecordVo> recordList = this.baseMapper.getRecordList(id);
             //计算出一共有多少周
@@ -584,7 +585,12 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
             createFourthTitle(workbook, sheet, weekTimeRangeVos, 13);
             int dataRowNumber = 4;
             //设置样式
-            font.setFontHeightInPoints((short)24);
+            font = workbook.createFont();
+            font.setBold(false);// 设置为粗体
+            font.setFontName("宋体");
+            //font.setColor(IndexedColors.RED.getIndex()); // 设置字体颜色为红色
+            font.setFontHeightInPoints((short)12);
+
 
             // 创建一个单元格样式对象
             cellStyle = workbook.createCellStyle();
@@ -605,6 +611,10 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
             ByteArrayOutputStream bot = new ByteArrayOutputStream();
             workbook.write(bot);
             return bot.toByteArray();
+        }catch (Exception e){
+            log.error(e.getMessage());
+            throw new MyException("导出出错,请联系管理员");
+        }
     }
 
     /**

+ 1 - 1
src/main/resources/mapper/classtime/ClassTimeStatisticsMapper.xml

@@ -55,7 +55,7 @@
 
 
     <select id="getRecordList" resultType="com.xjrsoft.module.classtime.vo.ClassTimeStatisticsRecordVo">
-        SELECT t1.id,t2.user_name,t2.name,t3.name AS employ_type_cn,
+        SELECT t1.id,t2.user_name,t2.name,t3.name AS employ_type_cn,t1.week_data,
         t1.class_time1,t1.class_time2,t1.class_time3,t1.class_time4,t1.class_time5,
         t1.class_time6,t1.class_time7,t1.class_time8,t1.class_time9,t1.class_time10,t1.class_time11,
         t1.all_class_time,t1.total_amount,t1.class_time_amount,t1.beyond_class_time_amount FROM class_time_statistics_record t1