|
@@ -1,23 +1,24 @@
|
|
|
package com.ym.mec.web.controller;
|
|
package com.ym.mec.web.controller;
|
|
|
|
|
|
|
|
-import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
|
|
|
|
|
|
|
+import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
|
|
+import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dto.StudentStatisticsDto;
|
|
import com.ym.mec.biz.dal.dto.StudentStatisticsDto;
|
|
|
import com.ym.mec.biz.dal.dto.StudentStatisticsSumDto;
|
|
import com.ym.mec.biz.dal.dto.StudentStatisticsSumDto;
|
|
|
import com.ym.mec.biz.dal.dto.StudentStatisticsSumForDateDto;
|
|
import com.ym.mec.biz.dal.dto.StudentStatisticsSumForDateDto;
|
|
|
|
|
+import com.ym.mec.biz.dal.entity.ManagerDownload;
|
|
|
|
|
+import com.ym.mec.biz.dal.enums.ExportTypeEnum;
|
|
|
import com.ym.mec.biz.dal.page.StudentStatisticsQueryInfo;
|
|
import com.ym.mec.biz.dal.page.StudentStatisticsQueryInfo;
|
|
|
|
|
+import com.ym.mec.biz.service.ExportService;
|
|
|
import com.ym.mec.biz.service.OrganizationService;
|
|
import com.ym.mec.biz.service.OrganizationService;
|
|
|
import com.ym.mec.biz.service.StudentStatisticsService;
|
|
import com.ym.mec.biz.service.StudentStatisticsService;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
-import com.ym.mec.util.date.DateUtil;
|
|
|
|
|
-import com.ym.mec.util.excel.POIUtil;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -25,12 +26,12 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
-import java.io.OutputStream;
|
|
|
|
|
-import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
|
|
@RequestMapping("studentStatistics")
|
|
@RequestMapping("studentStatistics")
|
|
|
@Api(tags = "学员小课统计")
|
|
@Api(tags = "学员小课统计")
|
|
@@ -41,6 +42,10 @@ public class StudentStatisticsController extends BaseController {
|
|
|
private StudentStatisticsService studentStatisticsService;
|
|
private StudentStatisticsService studentStatisticsService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private OrganizationService organizationService;
|
|
private OrganizationService organizationService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ExportService exportService;
|
|
|
|
|
|
|
|
@ApiOperation(value = "分页查询收费类型列表")
|
|
@ApiOperation(value = "分页查询收费类型列表")
|
|
|
@PostMapping("/queryPage")
|
|
@PostMapping("/queryPage")
|
|
@@ -88,45 +93,26 @@ public class StudentStatisticsController extends BaseController {
|
|
|
@ApiOperation(value = "导出小课学员管理")
|
|
@ApiOperation(value = "导出小课学员管理")
|
|
|
@PostMapping("/exportStudentSmallClassStatisticsSum")
|
|
@PostMapping("/exportStudentSmallClassStatisticsSum")
|
|
|
@PreAuthorize("@pcs.hasPermissions('studentStatistics/exportStudentSmallClassStatisticsSum')")
|
|
@PreAuthorize("@pcs.hasPermissions('studentStatistics/exportStudentSmallClassStatisticsSum')")
|
|
|
- public void exportStudentSmallClassStatisticsSum(StudentStatisticsQueryInfo queryInfo, HttpServletResponse response) throws IOException {
|
|
|
|
|
- queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
|
|
|
|
|
- queryInfo.setRows(65535);
|
|
|
|
|
|
|
+ public HttpResponseResult exportStudentSmallClassStatisticsSum(StudentStatisticsQueryInfo queryInfo) throws IOException {
|
|
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
|
|
+ queryInfo.setOrganId(organizationService.getEmployeeOrgan(sysUser.getId(),queryInfo.getOrganId(),sysUser.getIsSuperAdmin()));
|
|
|
PageInfo<StudentStatisticsDto> pageList = studentStatisticsService.queryStatisticsPage(queryInfo);
|
|
PageInfo<StudentStatisticsDto> pageList = studentStatisticsService.queryStatisticsPage(queryInfo);
|
|
|
-
|
|
|
|
|
if (pageList.getTotal() <= 0) {
|
|
if (pageList.getTotal() <= 0) {
|
|
|
throw new BizException("没有可导出的记录");
|
|
throw new BizException("没有可导出的记录");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- OutputStream outputStream = response.getOutputStream();
|
|
|
|
|
- HSSFWorkbook workbook = null;
|
|
|
|
|
- try {
|
|
|
|
|
- String[] header = {"分部", "学生姓名", "学员编号","联系电话", "声部", "学校", "年级", "学员状态", "未排课时", "总课时", "已完成课时",
|
|
|
|
|
- "剩余课时","预收金额","第一次课时间","最近上课时间","指导老师编号","指导老师","乐团主管编号","乐团主管","声部课老师编号","声部课老师","近30天课耗","回访次数",
|
|
|
|
|
- "回访状态","原因","回访日期"};
|
|
|
|
|
- String[] body = {"studentBasicInfo.organName", "studentBasicInfo.userName", "studentBasicInfo.userId",
|
|
|
|
|
- "studentBasicInfo.phone","studentBasicInfo.subjectName", "studentBasicInfo.cooperationOrganName", "studentBasicInfo.grade",
|
|
|
|
|
- "overCourseNum > 0 && subCourseNum > 0 && latelyYearCourseConsumer < 1 ? '沉睡' : (noScheduleNum > 0 || subCourseNum > 0) && (latelyYearCourseConsumer > 0 || overCourseNum <= 0) ? '在读':''",
|
|
|
|
|
- "noScheduleNum","totalCourseNum", "overCourseNum", "subCourseNum","preCourseFee","firstCourseTime","lastCourseTime","teacherId","teacherName","musicDirectorId","musicDirectorName",
|
|
|
|
|
- "studentBasicInfo.subjectTeacherId","studentBasicInfo.subjectTeacherName","latelyCourseConsumer","visitNum","lastVisitStatus","visitReason","lastVisitTime"};
|
|
|
|
|
- workbook = POIUtil.exportExcel(header, body, pageList.getRows());
|
|
|
|
|
- response.setContentType("application/octet-stream");
|
|
|
|
|
- response.setHeader("Content-Disposition", "attachment;filename=replacement-" + DateUtil.getDate(new Date()) + ".xls");
|
|
|
|
|
- response.flushBuffer();
|
|
|
|
|
- outputStream = response.getOutputStream();
|
|
|
|
|
- workbook.write(outputStream);
|
|
|
|
|
- outputStream.flush();
|
|
|
|
|
- workbook.close();
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- } finally {
|
|
|
|
|
- if (outputStream != null) {
|
|
|
|
|
- try {
|
|
|
|
|
- workbook.close();
|
|
|
|
|
- outputStream.close();
|
|
|
|
|
- } catch (IOException e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ManagerDownload managerDownload = exportService.saveManagerDownload(ExportTypeEnum.STUDENT_SMALL_CLASS_STATISTICS,sysUser.getId());
|
|
|
|
|
+ ExecutorService executor = Executors.newCachedThreadPool();
|
|
|
|
|
+ CompletableFuture.runAsync(()->{
|
|
|
|
|
+ try {
|
|
|
|
|
+ queryInfo.setPage(1);
|
|
|
|
|
+ queryInfo.setRows(65535);
|
|
|
|
|
+ exportService.exportStudentSmallClassStatisticsSum(queryInfo, managerDownload);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ },executor);
|
|
|
|
|
+ HttpResponseResult<Object> succeed = succeed();
|
|
|
|
|
+ succeed.setMsg(managerDownload.getName() + "导出申请已提交,请到【报表中心-下载列表查看】");
|
|
|
|
|
+ return succeed;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|