Browse Source

学员小课数据统计

zouxuan 3 years ago
parent
commit
d065644ac0

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/ExportTypeEnum.java

@@ -9,7 +9,8 @@ public enum ExportTypeEnum implements BaseEnum<Integer, ExportTypeEnum> {
 	STUDENT_VIP_PRACTICE(3, "VIP网管课耗导出"),
 	STUDENT_VIP_PRACTICE(3, "VIP网管课耗导出"),
 	STUDENT_MUSIC_THEORY_COURSE_INFO(4, "网管课学员课程信息导出"),
 	STUDENT_MUSIC_THEORY_COURSE_INFO(4, "网管课学员课程信息导出"),
 	STUDENT_VIP_COURSE_INFO(5, "VIP课学员课程信息导出"),
 	STUDENT_VIP_COURSE_INFO(5, "VIP课学员课程信息导出"),
-	VIP_STUDENT_COURSE_MANAGE(6, "vip学员课程管理");
+	VIP_STUDENT_COURSE_MANAGE(6, "vip学员课程管理"),
+	STUDENT_SMALL_CLASS_STATISTICS(7, "学员小课数据统计");
 
 
 	private Integer code;
 	private Integer code;
 
 

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ExportService.java

@@ -5,6 +5,7 @@ import com.ym.mec.biz.dal.entity.ManagerDownload;
 import com.ym.mec.biz.dal.enums.ExportEnum;
 import com.ym.mec.biz.dal.enums.ExportEnum;
 import com.ym.mec.biz.dal.enums.ExportTypeEnum;
 import com.ym.mec.biz.dal.enums.ExportTypeEnum;
 import com.ym.mec.biz.dal.page.EndCourseScheduleQueryInfo;
 import com.ym.mec.biz.dal.page.EndCourseScheduleQueryInfo;
+import com.ym.mec.biz.dal.page.StudentStatisticsQueryInfo;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.HttpResponseResult;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Async;
 
 
@@ -284,4 +285,6 @@ public interface ExportService {
     void queryStudentCourseInfo(String organId, Integer tenantId, String vip, ManagerDownload managerDownload, List<String> headColumns,ExportEnum exportEnum) throws FileNotFoundException;
     void queryStudentCourseInfo(String organId, Integer tenantId, String vip, ManagerDownload managerDownload, List<String> headColumns,ExportEnum exportEnum) throws FileNotFoundException;
 
 
     void queryVipStudentCourseManage(String organId, Integer tenantId, ManagerDownload managerDownload, List<String> headColumns, ExportEnum exportEnum) throws FileNotFoundException;
     void queryVipStudentCourseManage(String organId, Integer tenantId, ManagerDownload managerDownload, List<String> headColumns, ExportEnum exportEnum) throws FileNotFoundException;
+
+    void exportStudentSmallClassStatisticsSum(StudentStatisticsQueryInfo queryInfo, ManagerDownload managerDownload) throws FileNotFoundException;
 }
 }

+ 28 - 42
mec-web/src/main/java/com/ym/mec/web/controller/StudentStatisticsController.java

@@ -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;
     }
     }
 }
 }