Explorar el Código

Merge branch 'master' of https://e.coding.net/chuanghaikeji/smartCampus/backend_code

夏文涛 hace 2 años
padre
commit
63e2ffef84

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

@@ -269,5 +269,9 @@ public interface SmartUserControllerAPI {
     @ApiOperation(value = "管理端——在校统计", notes = "管理端——在校统计", httpMethod = "GET")
     CommonResult statisticsCampusManage(@RequestParam Integer gradeId,@RequestParam Integer classId,@RequestParam String dateTime,@RequestParam Integer type,String keyWord);
 
+    @GetMapping(value = "/statisticsCampusManagExport")
+    @ApiOperation(value = "管理端——在校统计导出", notes = "管理端——在校统计导出", httpMethod = "GET")
+    void statisticsCampusManageExport(HttpServletResponse response,@RequestParam Integer gradeId,@RequestParam Integer classId,@RequestParam String dateTime,@RequestParam Integer type,String keyWord);
+
 
 }

+ 109 - 0
src/main/java/com/template/controller/SmartUserController.java

@@ -5062,6 +5062,115 @@ public class SmartUserController implements SmartUserControllerAPI {
         }
 
     }
+
+    @Override
+    @PassToken
+    public void statisticsCampusManageExport(HttpServletResponse response, Integer gradeId, Integer classId, String dateTime, Integer type, String keyWord) {
+        //导出
+        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("类型");
+        headerRow.createCell(6).setCellValue("时间");
+
+
+        DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        LocalDateTime startTime = LocalDateTime.parse(dateTime, dateTimeFormatter1);
+        LocalDateTime endTime = startTime.plusDays(1);
+
+        //        正常
+        Set<StatisticsCampusManageVo> vos = new HashSet<>();
+
+            //        查找请假记录
+        List<StatisticsCampusManageVo>    ackVos= smartUserService.getAckStatisticsCampusManage(gradeId,classId,startTime,endTime,keyWord);
+        if (ObjectUtils.isNotEmpty(ackVos)&&ackVos.size()>0) {
+            for (StatisticsCampusManageVo ackVo : ackVos) {
+                vos.add(ackVo);
+            }
+        }
+
+//        查找门禁记录
+        List<StatisticsCampusManageVo> accessVos=smartUserService.getAccessStatisticsCampusManage(gradeId,classId,startTime,endTime,keyWord);
+        for (StatisticsCampusManageVo accessVo : accessVos) {
+            vos.add(accessVo);
+        }
+//        查找打卡记录
+        List<StatisticsCampusManageVo> attendanceVos=smartUserService.getAttendanceStatisticsCampusManage(gradeId,classId,startTime,endTime,keyWord);
+        for (StatisticsCampusManageVo attendanceVo : attendanceVos) {
+            vos.add(attendanceVo);
+        }
+//        查找人脸记录
+        List<StatisticsCampusManageVo> faceDiscernVos=smartUserService.getFaceDiscernStatisticsCampusManage(gradeId,classId,startTime,endTime,keyWord);
+        for (StatisticsCampusManageVo faceDiscernVo : faceDiscernVos) {
+            vos.add(faceDiscernVo);
+        }
+
+//            异常
+            //        查找该班级下的所有人
+        List<StatisticsCampusManageVo> campusVos= smartUserService.getClassStudentManage(gradeId,classId,keyWord);
+
+//        不在正常记录里面的就是异常记录
+        ArrayList<StatisticsCampusManageVo> abnormalVos = new ArrayList<>();
+        for (StatisticsCampusManageVo campusVo : campusVos) {
+            if (!vos.contains(campusVo)) {
+                abnormalVos.add(campusVo);
+            }
+        }
+        String[] s = dateTime.split(" ");
+        String s1=s[0];
+
+        int count=0;
+
+        for (int i = 0; i < abnormalVos.size(); i++) {
+            StatisticsCampusManageVo vo = abnormalVos.get(i);
+            count=count+1;
+            Row dataRow = sheet.createRow(count);
+            dataRow.createCell(0).setCellValue(count);
+            dataRow.createCell(1).setCellValue(vo.getGradeName());
+            dataRow.createCell(2).setCellValue(vo.getClassName());
+            dataRow.createCell(3).setCellValue(vo.getName());
+            dataRow.createCell(4).setCellValue(vo.getCardNo());
+            dataRow.createCell(5).setCellValue("异常");
+            dataRow.createCell(6).setCellValue(s1);
+        }
+
+        for (int i = 0; i < ackVos.size(); i++) {
+            StatisticsCampusManageVo vo = ackVos.get(i);
+            count=count+1;
+            Row dataRow = sheet.createRow(count);
+            dataRow.createCell(0).setCellValue(count);
+            dataRow.createCell(1).setCellValue(vo.getGradeName());
+            dataRow.createCell(2).setCellValue(vo.getClassName());
+            dataRow.createCell(3).setCellValue(vo.getName());
+            dataRow.createCell(4).setCellValue(vo.getCardNo());
+            dataRow.createCell(5).setCellValue("请假");
+            dataRow.createCell(6).setCellValue(s1);
+        }
+
+
+        for (StatisticsCampusManageVo vo : vos) {
+            count=count+1;
+            Row dataRow = sheet.createRow(count);
+            dataRow.createCell(0).setCellValue(count);
+            dataRow.createCell(1).setCellValue(vo.getGradeName());
+            dataRow.createCell(2).setCellValue(vo.getClassName());
+            dataRow.createCell(3).setCellValue(vo.getName());
+            dataRow.createCell(4).setCellValue(vo.getCardNo());
+            dataRow.createCell(5).setCellValue("正常");
+            dataRow.createCell(6).setCellValue(s1);
+        }
+
+// 将工作簿写入文件
+        ExcelUtils.excelDownload(workbook, s1+":在校统计.xlsx", response);
+
+    }
+
+
     //endregion
 
     //region 用户导出