Jelajahi Sumber

课表列表导出新增乐团主管

zouxuan 4 tahun lalu
induk
melakukan
be6a4bd931

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

@@ -4,6 +4,7 @@ import com.ym.mec.common.enums.BaseEnum;
 
 public enum ExportTypeEnum implements BaseEnum<Integer, ExportTypeEnum> {
 	ORDER(1, "订单列表"),
+	COURSE_SCHEDULE(3, "课表列表"),
 	ROUTE_ORDER(2, "财务管理");
 
 	private Integer code;

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleService.java

@@ -656,4 +656,6 @@ public interface CourseScheduleService extends BaseService<Long, CourseSchedule>
 	 * @return void
 	 */
 	void mergeCourseSplit(Long mainCourseId, Integer operatorId);
+
+	int endCountCourseSchedules(Map<String, Object> params);
 }

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

@@ -2,6 +2,7 @@ package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.entity.ManagerDownload;
 
+import java.io.FileNotFoundException;
 import java.util.Map;
 
 
@@ -22,4 +23,11 @@ public interface ExportService {
      * @throws Exception
      */
     void routeOrderList(Map<String, Object> params, ManagerDownload managerDownload) throws Exception;
+
+    /**
+     * 课表列表导出
+     * @param params
+     * @param managerDownload
+     */
+    void superFindCourseSchedules(Map<String, Object> params, ManagerDownload managerDownload) throws FileNotFoundException;
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -5804,4 +5804,9 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			courseScheduleModifyLogDao.batchInsert(insertCourseScheduleModifyLogList);
 		}
     }
+
+	@Override
+	public int endCountCourseSchedules(Map<String, Object> params) {
+		return courseScheduleDao.endCountCourseSchedules(params);
+	}
 }

+ 43 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -1,10 +1,7 @@
 package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.FeeFlagNumDto;
-import com.ym.mec.biz.dal.dto.PracticeCourseDto;
-import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
-import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
@@ -27,10 +24,7 @@ import org.springframework.boot.system.ApplicationHome;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
+import java.io.*;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -60,6 +54,8 @@ public class ExportServiceImpl implements ExportService {
     private CooperationOrganDao cooperationOrganDao;
     @Autowired
     private ReplacementInstrumentActivityDao replacementInstrumentActivityDao;
+    @Autowired
+    private CourseScheduleDao courseScheduleDao;
 
     @Override
     @Async
@@ -699,4 +695,43 @@ public class ExportServiceImpl implements ExportService {
             }
         }
     }
+
+    @Override
+    public void superFindCourseSchedules(Map<String, Object> params, ManagerDownload managerDownload) throws FileNotFoundException {
+        List<CourseScheduleEndDto> rows = courseScheduleDao.endFindCourseSchedules(params);
+        for (CourseScheduleEndDto row : rows) {
+            row.setIsComplaints(StringUtils.equals(row.getIsComplaints(), "1") ? "有" : "无");
+        }
+        String basePath = new ApplicationHome(this.getClass()).getSource().getParentFile().getPath();
+        File file = new File(basePath + "/" + managerDownload.getName());
+        FileOutputStream fileOutputStream = new FileOutputStream(file);
+        OutputStream ouputStream = null;
+        try {
+            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部名称","乐团主管", "课程编号", "开始时间", "结束时间",
+                    "班级名称", "班级声部", "课程名称", "课程类型", "教学模式",
+                    "教学点", "课程状态", "指导老师", "学员编号", "是否点名", "是否有考勤申诉", "预计上课人数"}, new String[]{
+                    "organName","educationTeacherName", "id", "startClassTime", "endClassTime", "classGroupName", "subjectName", "name",
+                    "groupType.desc", "teachMode.msg", "schoolName", "status.msg", "teacherName", "studentId", "isCallNames.msg", "isComplaints", "studentNum"}, rows);
+            workbook.write(fileOutputStream);
+            fileOutputStream.getFD().sync();
+            fileOutputStream.close();
+
+            String folder = "download/" + UploadUtil.getFileFloder();
+            String url = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, folder, file);
+            //把记录插入下载表
+            managerDownload.setFileUrl(url);
+            managerDownload.setStatus(1);
+            managerDownloadDao.update(managerDownload);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (ouputStream != null) {
+                try {
+                    ouputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
 }

+ 22 - 37
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -10,10 +10,8 @@ import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.service.IdGeneratorService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-
 import java.io.IOException;
 import java.io.OutputStream;
-import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -24,9 +22,7 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
-
 import javax.servlet.http.HttpServletResponse;
-
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -36,7 +32,6 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.common.controller.BaseController;
@@ -66,10 +61,6 @@ public class ExportController extends BaseController {
     @Autowired
     private EmployeeDao employeeDao;
     @Autowired
-    private StudentPaymentOrderService studentPaymentOrderService;
-    @Autowired
-    private StudentRegistrationDao studentRegistrationDao;
-    @Autowired
     private VipGroupDao vipGroupDao;
     @Autowired
     private MusicGroupDao musicGroupDao;
@@ -124,8 +115,6 @@ public class ExportController extends BaseController {
     @Autowired
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
     @Autowired
-    private SellOrderDao sellOrderDao;
-    @Autowired
     private VipGroupActivityService vipGroupActivityService;
     @Autowired
     private GoodsService goodsService;
@@ -863,7 +852,7 @@ public class ExportController extends BaseController {
     @ApiOperation(value = "终课表列表导出")
     @GetMapping("export/superFindCourseSchedules")
     @PreAuthorize("@pcs.hasPermissions('export/superFindCourseSchedules')")
-    public void superFindCourseSchedules(EndCourseScheduleQueryInfo queryInfo, HttpServletResponse response) throws IOException {
+    public Object superFindCourseSchedules(EndCourseScheduleQueryInfo queryInfo) throws IOException {
         queryInfo.setPage(1);
         queryInfo.setRows(49999);
         queryInfo.setIsExport(true);
@@ -882,33 +871,29 @@ public class ExportController extends BaseController {
                 throw new BizException("非法请求");
             }
         }
-        List<CourseScheduleEndDto> rows = scheduleService.endFindCourseSchedules(queryInfo).getRows();
-        for (CourseScheduleEndDto row : rows) {
-            row.setIsComplaints(StringUtils.equals(row.getIsComplaints(), "1") ? "有" : "无");
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, queryInfo);
+        int count = scheduleService.endCountCourseSchedules(params);
+        if (count <= 0) {
+            return failed("没有可导出的数据");
         }
-        OutputStream ouputStream = null;
-        try {
-            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部名称","乐团主管", "课程编号", "开始时间", "结束时间",
-                    "班级名称", "班级声部", "课程名称", "课程类型", "教学模式",
-                    "教学点", "课程状态", "指导老师", "学员编号", "是否点名", "是否有考勤申诉", "预计上课人数"}, new String[]{
-                    "organName","educationTeacherName", "id", "startClassTime", "endClassTime", "classGroupName", "subjectName", "name",
-                    "groupType.desc", "teachMode.msg", "schoolName", "status.msg", "teacherName", "studentId", "isCallNames.msg", "isComplaints", "studentNum"}, 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();
-                }
-            }
+
+        if (count > 50000) {
+            return failed("数据集太大,不能导出.最大数据集不能超过50000");
         }
+        Date nowDate = new Date();
+        String no = idGeneratorService.generatorId("download") + "";
+        String fileName = "课表列表-" + no + "-" + DateUtil.getDate(nowDate) + ".xls";
+        ManagerDownload managerDownload = new ManagerDownload();
+        managerDownload.setType(ExportTypeEnum.COURSE_SCHEDULE);
+        managerDownload.setUserId(sysUser.getId());
+        managerDownload.setName(fileName);
+        managerDownload.setFileUrl("");
+        managerDownload.setCreateTime(nowDate);
+        managerDownload.setUpdateTime(nowDate);
+        managerDownloadDao.insert(managerDownload);
+        exportService.superFindCourseSchedules(params, managerDownload);
+        return succeed(fileName+"导出申请已提交,请到【报表中心-下载列表查看】");
     }