|
@@ -29,7 +29,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
@@ -80,6 +79,8 @@ public class ExportController extends BaseController {
|
|
|
private CourseScheduleDao courseScheduleDao;
|
|
|
@Autowired
|
|
|
private ExtracurricularExercisesReplyService extracurricularExercisesReplyService;
|
|
|
+ @Autowired
|
|
|
+ private StudentExtracurricularExercisesSituationService studentExtracurricularExercisesSituationService;
|
|
|
|
|
|
@ApiOperation(value = "网管课购买列表")
|
|
|
@PostMapping("export/studentBuyPractice")
|
|
@@ -1098,4 +1099,57 @@ public class ExportController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "课外训练-教学导出")
|
|
|
+ @GetMapping("export/exercisesSituations")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('export/exercisesSituations')")
|
|
|
+ public void exercisesSituations(StudentExercisesSituationQueryInfo queryInfo, HttpServletResponse response) throws IOException {
|
|
|
+ queryInfo.setRows(999999999);
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ throw new BizException("用户信息获取失败");
|
|
|
+ }
|
|
|
+ if (!sysUser.getIsSuperAdmin()) {
|
|
|
+ Employee employee = employeeDao.get(sysUser.getId());
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isEmpty(queryInfo.getOrganIdList())) {
|
|
|
+ queryInfo.setOrganIdList(employee.getOrganIdList());
|
|
|
+ } else if (org.apache.commons.lang3.StringUtils.isEmpty(employee.getOrganIdList())) {
|
|
|
+ throw new BizException("用户所在分部异常");
|
|
|
+ } else {
|
|
|
+ List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
|
|
|
+ if (!list.containsAll(Arrays.asList(queryInfo.getOrganIdList().split(",")))) {
|
|
|
+ throw new BizException("非法请求");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<StudentExercisesSituationDto> rows = studentExtracurricularExercisesSituationService.findStudentExtracurricularExercisesSituations(queryInfo).getRows();
|
|
|
+ if (CollectionUtils.isEmpty(rows)) {
|
|
|
+ response.setStatus(500);
|
|
|
+ response.setContentType("Content-Type: application/json;charset=UTF-8");
|
|
|
+ response.getOutputStream().write("{\"data\": null, \"code\": 500, \"status\": false, \"msg\": \"没有可导出的记录\"}".getBytes());
|
|
|
+ response.flushBuffer();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ OutputStream ouputStream = null;
|
|
|
+ try {
|
|
|
+ HSSFWorkbook workbook = POIUtil.exportExcel(
|
|
|
+ new String[]{"学员编号", "学员姓名", "所属分部", "指导老师", "预期安排", "实际安排", "提交次数", "评价次数", "及时评价次数"},
|
|
|
+ new String[]{"studentId", "studentName", "organName", "teacherName", "expectExercisesNum", "user.actualExercisesNum", "exercisesReplyNum", "exercisesMessageNum", "exercisesMessageTimelyNum"}, rows);
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");
|
|
|
+ ouputStream = response.getOutputStream();
|
|
|
+ workbook.write(ouputStream);
|
|
|
+ ouputStream.flush();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (ouputStream != null) {
|
|
|
+ try {
|
|
|
+ ouputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|