|
@@ -0,0 +1,55 @@
|
|
|
+package com.keao.edu.user.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.keao.edu.common.controller.BaseController;
|
|
|
+import com.keao.edu.common.page.QueryInfo;
|
|
|
+import com.keao.edu.util.date.DateUtil;
|
|
|
+import com.keao.edu.util.excel.POIUtil;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+@RequestMapping
|
|
|
+@Api(tags = "数据导出服务")
|
|
|
+@RestController
|
|
|
+public class ExportController extends BaseController {
|
|
|
+
|
|
|
+ @ApiOperation(value = "导出")
|
|
|
+ @PostMapping("export/queryTeacherAttendances")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('export/queryTeacherAttendances')")
|
|
|
+ public void exportTeacherAttendances(HttpServletResponse response, QueryInfo queryInfo) throws IOException {
|
|
|
+ OutputStream outputStream = response.getOutputStream();
|
|
|
+ try {
|
|
|
+ HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "老师编号", "老师姓名", "课程编号", "课程名称", "上课日期",
|
|
|
+ "课程开始时间", "课程结束时间", "课程类型", "签到时间", "签到状态", "签退时间", "签退状态", "备注"}, new String[]{
|
|
|
+ "organName", "teacherId", "teacherName", "courseScheduleId", "courseScheduleName", "classDate",
|
|
|
+ "startClassTime", "endClassTime", "courseScheduleType.msg", "signInTime", "signInStatus.msg", "signOutTime", "signOutStatus.msg",
|
|
|
+ "remark"}, null);
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");
|
|
|
+ response.flushBuffer();
|
|
|
+ outputStream = response.getOutputStream();
|
|
|
+ workbook.write(outputStream);
|
|
|
+ outputStream.flush();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (outputStream != null) {
|
|
|
+ try {
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|