فهرست منبع

添加统计报表导出接口

liu 1 سال پیش
والد
کامیت
cd29768ef1

+ 4 - 0
src/main/java/com/template/api/SmartUserControllerAPI.java

@@ -278,5 +278,9 @@ public interface SmartUserControllerAPI {
     @ApiOperation(value = "管理端——统计报表", notes = "管理端——在校统计", httpMethod = "GET")
     CommonResult statisticsStatementManag(@RequestParam String dateTime);
 
+    @GetMapping(value = "/statisticsStatementManagExport")
+    @ApiOperation(value = "管理端——统计报表导出", notes = "管理端——在校统计导出", httpMethod = "GET")
+    void statisticsStatementManagExport(HttpServletResponse response,@RequestParam String dateTime);
+
 
 }

+ 118 - 30
src/main/java/com/template/controller/SmartUserController.java

@@ -5040,20 +5040,20 @@ public class SmartUserController implements SmartUserControllerAPI {
         }
 
         JSONObject jsonObject = new JSONObject();
-        jsonObject.put("abnormal",abnormalVos.size());//未监听
-        jsonObject.put("normal",vos.size());//监听
-        jsonObject.put("ack",ackVos.size());//请假
+        jsonObject.put("abnormal", abnormalVos.size());//未监听
+        jsonObject.put("normal", vos.size());//监听
+        jsonObject.put("ack", ackVos.size());//请假
 
-        if (1==type) {
-            jsonObject.put("data",abnormalVos);
+        if (1 == type) {
+            jsonObject.put("data", abnormalVos);
             return CommonResult.ok(jsonObject);
-        }else if (2==type){
-            jsonObject.put("data",vos);
+        } else if (2 == type) {
+            jsonObject.put("data", vos);
             return CommonResult.ok(jsonObject);
-        }else if (3==type){
-            jsonObject.put("data",ackVos);
+        } else if (3 == type) {
+            jsonObject.put("data", ackVos);
             return CommonResult.ok(jsonObject);
-        }else {
+        } else {
             return CommonResult.fail("状态异常");
         }
 
@@ -5174,22 +5174,22 @@ public class SmartUserController implements SmartUserControllerAPI {
         LocalDateTime startTime = LocalDateTime.parse(dateTime, dateTimeFormatter1);
         LocalDateTime endTime = startTime.plusDays(1);
 
-        Integer totalAbnormal=0;
-        Integer totalNormal=0;
-        Integer totalAck=0;
+        Integer totalAbnormal = 0;
+        Integer totalNormal = 0;
+        Integer totalAck = 0;
 
 //        获取年级
         List<SmartGrade> smartGrades = smartGradeService.list(new LambdaQueryWrapper<>());
 
 
 //        获取每个班的请假人数
-        List<StatisticsStatement> ackList= smartUserService.getUserAckTotal(startTime,endTime);
+        List<StatisticsStatement> ackList = smartUserService.getUserAckTotal(startTime, endTime);
 
 //        获取每个班级的人数
-        List<StatisticsStatement> totalList= smartUserService.getUserClassTotal();
+        List<StatisticsStatement> totalList = smartUserService.getUserClassTotal();
 
 //        获取每个班级的正常人数
-        List<StatisticsStatement> normalList= smartUserService.getUserNormalTotal(startTime,endTime);
+        List<StatisticsStatement> normalList = smartUserService.getUserNormalTotal(startTime, endTime);
 
 
         ArrayList<StatisticsStatementVo> vos = new ArrayList<>();
@@ -5204,14 +5204,14 @@ public class SmartUserController implements SmartUserControllerAPI {
 
 //            总数
             Integer total = statisticsStatement.getCount();
-            Integer normal=0;
-            Integer ack=0;
+            Integer normal = 0;
+            Integer ack = 0;
 
             for (StatisticsStatement statement : normalList) {
                 Integer classId1 = statement.getClassId();
                 Integer gradeId1 = statement.getGradeId();
-                if (classId.equals(classId1)&&gradeId.equals(gradeId1)) {
-                    normal=statement.getCount();
+                if (classId.equals(classId1) && gradeId.equals(gradeId1)) {
+                    normal = statement.getCount();
                     break;
                 }
             }
@@ -5219,20 +5219,20 @@ public class SmartUserController implements SmartUserControllerAPI {
             for (StatisticsStatement statement : ackList) {
                 Integer classId1 = statement.getClassId();
                 Integer gradeId1 = statement.getGradeId();
-                if (classId.equals(classId1)&&gradeId.equals(gradeId1)) {
+                if (classId.equals(classId1) && gradeId.equals(gradeId1)) {
 //                  请假数量
-                    ack=statement.getCount();
+                    ack = statement.getCount();
                     break;
                 }
             }
-            Integer abnormal=total-normal;
+            Integer abnormal = total - normal;
             vo.setAck(ack);
             vo.setNormal(normal);
             vo.setAbnormal(abnormal);
 
-            totalAbnormal=totalAbnormal+abnormal;
-            totalNormal=totalNormal+normal;
-            totalAck=totalAck+ack;
+            totalAbnormal = totalAbnormal + abnormal;
+            totalNormal = totalNormal + normal;
+            totalAck = totalAck + ack;
 
             vos.add(vo);
 
@@ -5250,14 +5250,102 @@ public class SmartUserController implements SmartUserControllerAPI {
         }
 
         JSONObject jsonObject = new JSONObject();
-        jsonObject.put("list",ssmVos);
-        jsonObject.put("totalAbnormal",totalAbnormal);
-        jsonObject.put("totalNormal",totalNormal);
-        jsonObject.put("totalAck",totalAck);
+        jsonObject.put("list", ssmVos);
+        jsonObject.put("totalAbnormal", totalAbnormal);
+        jsonObject.put("totalNormal", totalNormal);
+        jsonObject.put("totalAck", totalAck);
 
         return CommonResult.ok(jsonObject);
     }
 
+    @Override
+    public void statisticsStatementManagExport(HttpServletResponse response, String dateTime) {
+
+        //导出
+        Workbook workbook = new XSSFWorkbook();
+        Sheet sheet = workbook.createSheet("统计报表");
+        Row headerRow = sheet.createRow(0);
+        headerRow.createCell(0).setCellValue("序号");
+        headerRow.createCell(1).setCellValue("年级");
+        headerRow.createCell(2).setCellValue("班级");
+        headerRow.createCell(3).setCellValue("监听");
+        headerRow.createCell(4).setCellValue("未监听");
+        headerRow.createCell(5).setCellValue("请假");
+
+
+        DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        LocalDateTime startTime = LocalDateTime.parse(dateTime, dateTimeFormatter1);
+        LocalDateTime endTime = startTime.plusDays(1);
+
+//        获取每个班的请假人数
+        List<StatisticsStatement> ackList = smartUserService.getUserAckTotal(startTime, endTime);
+
+//        获取每个班级的人数
+        List<StatisticsStatement> totalList = smartUserService.getUserClassTotal();
+
+//        获取每个班级的正常人数
+        List<StatisticsStatement> normalList = smartUserService.getUserNormalTotal(startTime, endTime);
+
+
+        ArrayList<StatisticsStatementVo> vos = new ArrayList<>();
+        for (StatisticsStatement statisticsStatement : totalList) {
+            StatisticsStatementVo vo = new StatisticsStatementVo();
+            Integer classId = statisticsStatement.getClassId();
+            Integer gradeId = statisticsStatement.getGradeId();
+            vo.setGradeId(gradeId);
+            vo.setClassId(classId);
+            vo.setGradeName(statisticsStatement.getGradeName());
+            vo.setClassName(statisticsStatement.getClassName());
+
+//            总数
+            Integer total = statisticsStatement.getCount();
+            Integer normal = 0;
+            Integer ack = 0;
+
+            for (StatisticsStatement statement : normalList) {
+                Integer classId1 = statement.getClassId();
+                Integer gradeId1 = statement.getGradeId();
+                if (classId.equals(classId1) && gradeId.equals(gradeId1)) {
+                    normal = statement.getCount();
+                    break;
+                }
+            }
+
+            for (StatisticsStatement statement : ackList) {
+                Integer classId1 = statement.getClassId();
+                Integer gradeId1 = statement.getGradeId();
+                if (classId.equals(classId1) && gradeId.equals(gradeId1)) {
+//                  请假数量
+                    ack = statement.getCount();
+                    break;
+                }
+            }
+            Integer abnormal = total - normal;
+            vo.setAck(ack);
+            vo.setNormal(normal);
+            vo.setAbnormal(abnormal);
+
+            vos.add(vo);
+
+        }
+
+        String[] s = dateTime.split(" ");
+        String s1 = s[0];
+
+        for (int i = 0; i < vos.size(); i++) {
+            StatisticsStatementVo vo = vos.get(i);
+            Row dataRow = sheet.createRow(i+1);
+            dataRow.createCell(0).setCellValue(i+1);
+            dataRow.createCell(1).setCellValue(vo.getGradeName());
+            dataRow.createCell(2).setCellValue(vo.getClassName());
+            dataRow.createCell(3).setCellValue(vo.getNormal());
+            dataRow.createCell(4).setCellValue(vo.getAbnormal());
+            dataRow.createCell(5).setCellValue(vo.getAck());
+        }
+
+        ExcelUtils.excelDownload(workbook, s1 + ":统计报表.xlsx", response);
+    }
+
 
     //endregion