|
@@ -2995,4 +2995,59 @@ public class ExportController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "老师列表导出")
|
|
|
+ @RequestMapping("export/teacherList")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('export/teacherList')")
|
|
|
+ public void exportTeacherList(TeacherQueryInfo queryInfo,HttpServletResponse response) throws IOException {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ throw new BizException("用户信息获取失败");
|
|
|
+ }
|
|
|
+ Employee employee = employeeDao.get(sysUser.getId());
|
|
|
+ if (StringUtils.isEmpty(queryInfo.getOrganId())) {
|
|
|
+ queryInfo.setOrganId(employee.getOrganIdList());
|
|
|
+ }else if(StringUtils.isEmpty(employee.getOrganIdList())){
|
|
|
+ throw new BizException("用户所在分部异常");
|
|
|
+ }else {
|
|
|
+ List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
|
|
|
+ if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
|
|
|
+ throw new BizException("非法请求");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ queryInfo.setPage(1);
|
|
|
+ queryInfo.setRows(49999);
|
|
|
+ List<Teacher> rows = teacherService.queryPageDetail(queryInfo).getRows();
|
|
|
+ if (CollectionUtils.isEmpty(rows)) {
|
|
|
+ response.setStatus(200);
|
|
|
+ response.setContentType("Content-Type: application/json;charset=UTF-8");
|
|
|
+ response.getOutputStream().write("{\"data\": null, \"code\": 500, \"status\": false, \"msg\": \"没有可导出的记录\"}".getBytes());
|
|
|
+ response.flushBuffer();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ OutputStream outputStream = response.getOutputStream();
|
|
|
+ try {
|
|
|
+ String[] header = {"老师编号", "老师名称", "所属分部", "老师状态", "专业技能", "联系电话", "工作类型",
|
|
|
+ "员工状态", "已开小课", "试听课安排", "开放网管课","转正日期","离职日期"};
|
|
|
+ String[] body = {"id", "realName", "organName", "lockFlag == 0?'正常':lockFlag == 1?'冻结':'锁定'", "splitSubjectName", "phone", "jobNature.msg",
|
|
|
+ "isProbationPeriod.msg", "vipNum", "demoNum", "isSupportExtraPracticeLesson?'是':'否'","formalStaffDate","demissionDate"};
|
|
|
+ HSSFWorkbook workbook = POIUtil.exportExcel(header, body, rows);
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=teacherPage-" + 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|