package com.ym.mec.web.controller;

import com.ym.mec.auth.api.client.SysUserFeignService;
import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.biz.dal.dao.*;
import com.ym.mec.biz.dal.dto.*;
import com.ym.mec.biz.dal.entity.*;
import com.ym.mec.biz.dal.enums.*;
import com.ym.mec.biz.dal.page.*;
import com.ym.mec.biz.dal.vo.ImLiveBroadcastRoomMemberVo;
import com.ym.mec.biz.service.*;
import com.ym.mec.common.constant.CommonConstants;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.entity.HttpResponseResult;
import com.ym.mec.common.exception.BizException;
import com.ym.mec.common.page.PageInfo;
import com.ym.mec.common.tenant.TenantContextHolder;
import com.ym.mec.util.collection.MapUtil;
import com.ym.mec.util.date.DateUtil;
import com.ym.mec.util.excel.POIUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

@RequestMapping
@Api(tags = "数据导出服务")
@RestController
public class ExportController extends BaseController {

    @Autowired
    private StudentRegistrationService studentRegistrationService;
    @Autowired
    private StudentManageService studentManageService;
    @Autowired
    private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
    @Autowired
    private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
    @Autowired
    private SysUserFeignService sysUserFeignService;
    @Autowired
    private OrganizationService organizationService;
    @Autowired
    private VipGroupDao vipGroupDao;
    @Autowired
    private MusicGroupDao musicGroupDao;
    @Autowired
    private VipGroupService vipGroupService;
    @Autowired
    private PracticeGroupService practiceGroupService;
    @Autowired
    private CourseScheduleService scheduleService;
    @Autowired
    private SporadicChargeInfoService sporadicChargeInfoService;
    @Autowired
    private PracticeGroupDao practiceGroupDao;
    @Autowired
    private CourseReviewService courseReviewService;
    @Autowired
    private TenantPaymentOrderService tenantPaymentOrderService;
    @Autowired
    private CourseScheduleDao courseScheduleDao;
    @Autowired
    private ExtracurricularExercisesReplyService extracurricularExercisesReplyService;
    @Autowired
    private StudentExtracurricularExercisesSituationService studentExtracurricularExercisesSituationService;
    @Autowired
    private TeacherSalaryComplaintsService teacherSalaryComplaintsService;
    @Autowired
    private TeacherAttendanceService teacherAttendanceService;
    @Autowired
    private StudentAttendanceService studentAttendanceService;
    @Autowired
    private TeacherCourseRewardService teacherCourseRewardService;
    @Autowired
    private DegreeRegistrationService degreeRegistrationService;
    @Autowired
    private CooperationOrganService cooperationOrganService;
    @Autowired
    private StudentPaymentOrderDao studentPaymentOrderDao;
    @Autowired
    private StudentDao studentDao;
    @Autowired
    private MusicGroupPaymentCalenderDetailService musicGroupPaymentCalenderDetailService;
    @Autowired
    private TeacherService teacherService;
    @Autowired
    private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
    @Autowired
    private SellOrderService sellOrderService;
    @Autowired
    private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
    @Autowired
    private VipGroupActivityService vipGroupActivityService;
    @Autowired
    private GoodsService goodsService;
    @Autowired
    private ClassGroupService classGroupService;
    @Autowired
    private ExportService exportService;
    @Autowired
    private MusicGroupQuitService musicGroupQuitService;
    @Autowired
    private IndexBaseMonthDataService indexService;
    @Autowired
    private TeacherCourseStatisticsService teacherCourseStatisticsService;
    @Autowired
    private SysUserCashAccountDetailDao sysUserCashAccountDetailDao;
    @Autowired
    private SysUserCoursesAccountDetailDao sysUserCoursesAccountDetailDao;
    @Autowired
    private ChildrenDayReserveService childrenDayReserveService;
    @Autowired
    private IndexErrDataRecordService indexErrDataRecordService;
    @Autowired
    private EmployeeInfoService employeeInfoService;
    @Autowired
    private StudentService studentService;
    @Autowired
    private MusicEnlightenmentQuestionnaireService musicEnlightenmentQuestionnaireService;
    @Autowired
    private MusicGroupService musicGroupService;
    @Autowired
    private SysTenantConfigService sysTenantConfigService;
    
    @Autowired
    private ImLiveBroadcastRoomMemberService imLiveBroadcastRoomMemberService;

    @ApiOperation(value = "获取可导出字段")
    @RequestMapping("export/getFields")
    @PreAuthorize("@pcs.hasPermissions('export/getFields')")
    public HttpResponseResult export(ExportEnum exportEnum) throws IOException {
        return succeed(exportService.getExportFields(exportEnum));
    }

    @ApiOperation(value = "导出")
    @RequestMapping("export/now")
    @PreAuthorize("@pcs.hasPermissions('export/now')")
    public void export(HttpServletResponse response, @RequestBody ExportDto exportDto) throws Exception {
        if (exportDto.getExportEnum() == ExportEnum.MUSIC_GROUP_REGISTER) {
            exportService.musicGroupRegister(response, exportDto);
        } else if (exportDto.getExportEnum() == ExportEnum.MUSIC_GROUP_NORMAL_STUDENT_NUM) {
            exportService.musicGroupNormalStudentNum(response, exportDto);
        } else {
            Map<String, Object> queryInfo = exportDto.getQueryInfo();
            if (queryInfo == null) {
                queryInfo = new HashMap<>(10);
            }
            queryInfo.put("page", 1);
            queryInfo.put("rows", 49999);
            queryInfo.put("isExport", true);
            exportService.export(response, exportService.getExportFuncMap().get(exportDto.getExportEnum()).apply(queryInfo), exportDto);
        }
    }

    @ApiOperation(value = "导出到报表中心")
    @PostMapping("export/managerDownload")
    @PreAuthorize("@pcs.hasPermissions('export/managerDownload')")
    public HttpResponseResult managerDownload(@RequestBody ExportDto exportDto) {
        Map<String, Object> queryInfo = exportDto.getQueryInfo();
        if (queryInfo == null) {
            queryInfo = new HashMap<>(10);
        }
        queryInfo.put("page", 1);
        queryInfo.put("rows", 49999);
        queryInfo.put("isExport", true);
        return exportService.getExportManageFuncMap().get(exportDto.getExportEnum()).apply(queryInfo);
    }


    @ApiOperation(value = "导出乐团课列表详情")
    @PostMapping("export/exportMusicGroupCourseList")
    @PreAuthorize("@pcs.hasPermissions('export/exportMusicGroupCourseList')")
    public HttpResponseResult exportMusicGroupCourseList(ExportUserAccountQueryInfo queryInfo) {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(sysUser.getId(), queryInfo.getOrganId(), sysUser.getIsSuperAdmin()));
        Integer i = musicGroupDao.countMusicGroupCourseList(queryInfo);
        if (Objects.isNull(i) || i <= 0) {
            throw new BizException("没有可导出的记录");
        }
        ManagerDownload managerDownload = exportService.saveManagerDownload(ExportTypeEnum.MUSIC_GROUP_DATA_EXPORT, sysUser.getId());
        return exportService.asyncExport(() -> exportService.exportMusicGroupCourseList(managerDownload, queryInfo), managerDownload.getName());
    }

    @ApiOperation(value = "乐团详情--课表详情列表（课表详情）导出")
    @GetMapping("export/exportMusicGroupCourseScheduleDetail")
    @PreAuthorize("@pcs.hasPermissions('export/exportMusicGroupCourseScheduleDetail')")
    public HttpResponseResult exportMusicGroupCourseScheduleDetail(queryMusicGroupCourseScheduleQueryInfo queryInfo) {
        PageInfo<MusicGroupCourseScheduleDto> pageList = classGroupService.queryMusicGroupCourseScheduleDetail(queryInfo);
        if (pageList.getTotal() <= 0) {
            throw new BizException("没有可导出的记录");
        }
        queryInfo.setPage(1);
        queryInfo.setRows(65535);
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        ManagerDownload managerDownload = exportService.saveManagerDownload(ExportTypeEnum.MUSIC_GROUP_COURSE_LIST, sysUser.getId());
        return exportService.asyncExport(() -> exportService.exportMusicGroupCourseScheduleDetail(queryInfo, managerDownload), managerDownload.getName());
    }

    @ApiOperation(value = "乐团列表导出")
    @PostMapping("export/musicGroup")
    @PreAuthorize("@pcs.hasPermissions('export/musicGroup')")
    public void exportMusicGroup(HttpServletResponse response, MusicGroupQueryInfo queryInfo) throws IOException {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<MusicGroup> rows = musicGroupService.queryMusicGroupPage(queryInfo).getRows();
        if (rows.size() < 1) {
            throw new BizException("没有可导出数据");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "乐团编号", "乐团名称", "合作单位", "乐团状态",
                    "收费模式", "收费类型", "乐团主管", "成团人数", "在读人数", "申请时间", "成团时间", "清单状态", "收费标准"}, new String[]{
                    "organName", "id", "name", "cooperationOrganName", "status.msg", "courseViewType.msg", "chargeTypeName",
                    "educationalTeacherName", "groupMemberNum", "payNum"
                    , "createTime", "updateTime", "hasVerifyMusicalList?'已确认':'未确认'", "chargeStandard"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attac:wq" +
                    "hment;filename=classGroup-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "21年暑期考级活动统计页面详情导出")
    @PostMapping("export/statisticsDetail")
    @PreAuthorize("@pcs.hasPermissions('export/statisticsDetail')")
    public void statisticsDetail(HttpServletResponse response, ChildrenReserveQueryInfo queryInfo) throws IOException {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<ChildrenStatisticsDetailDto> rows = childrenDayReserveService.exportStatisticsDetail(queryInfo);
        if (rows.size() < 1) {
            throw new BizException("没有可导出数据");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "合作单位", "乐团", "学员编号", "学员姓名", "手机号", "声部", "所在班级", "指导老师", "是否预约", "器乐等级", "乐理等级", "是否购买VIP", "是否购买乐理课"}, new String[]{
                    "organName", "cooperationOrganName", "musicGroupName", "userId", "username", "phone", "subjectName",
                    "currentClass", "realName", "isReserve == true ?'是':'否'", "gradeLeave"
                    , "theoryLevel", "buyVipFlag == true ?'是':'否'", "buyTheoryCourseFlag == true ?'是':'否'"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attac:wq" +
                    "hment;filename=classGroup-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "2021双十一学员购买详情")
    @RequestMapping("export/doubleEleven2021OrderDetail")
    @PreAuthorize("@pcs.hasPermissions('export/doubleEleven2021OrderDetail')")
    public void doubleEleven2021OrderDetail(HttpServletResponse response, DoubleEleven2021QueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<DoubleEleven2021OrderDetailDto> rows = vipGroupActivityService.doubleEleven2021OrderDetail(queryInfo).getRows();
        if (rows.size() < 1) {
            throw new BizException("没有可导出数据");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"学员编号", "学员姓名", "订单号", "交易金额",
                    "交易时间", "订单创建时间", "购买课程", "赠送会员"}, new String[]{
                    "userId", "username", "orderNo", "amount", "payTime", "createTime", "type",
                    "giveMember==0?'否':'是'"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attac:wq" +
                    "hment;filename=classGroup-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "分部2021双11活动统计导出")
    @RequestMapping("export/organDoubleEleven2021Statis")
    @PreAuthorize("@pcs.hasPermissions('export/organDoubleEleven2021Statis')")
    public void organDoubleEleven2021Statis(HttpServletResponse response, OrganDoubleEleven2021StatisDto statisDto) throws IOException {
        List<DoubleEleven2021Dto> rows = vipGroupActivityService.organDoubleEleven2021Statis(statisDto);
        if (rows.size() < 1) {
            throw new BizException("没有可导出数据");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "总成交金额", "总购买人数", "人均购买金额",
                    "20节1v1成交金额", "20节1v1成交人数", "40节1v1成交金额", "40节1v1成交人数", "20节1v2成交金额", "20节1v2成交人数",
                    "40节1v2成交金额", "40节1v2成交人数", "乐理课成交金额", "乐理课成交人数", "赠送会员人数"}, new String[]{
                    "organName", "totalBuyAmount", "totalBuyNum", "avgBuyAmount", "vip1V120Amount", "vip1V120Num", "vip1V140Amount",
                    "vip1V140Num", "vip1V220Amount", "vip1V220Num", "vip1V240Amount"
                    , "vip1V240Num", "musicTheoryAmount", "musicTheoryNum", "giveMemberNum"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attac:wq" +
                    "hment;filename=classGroup-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "学生个人账户余额导出")
    @PostMapping("export/userCashAccountDetail")
    @PreAuthorize("@pcs.hasPermissions('export/userCashAccountDetail')")
    public void userCashAccountDetail(HttpServletResponse response, ExportUserAccountQueryInfo queryInfo) throws IOException {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        List<SysUserCashAccountDetail> cashAccountDetails = sysUserCashAccountDetailDao.exportDetail(queryInfo);
        if (cashAccountDetails.size() < 1) {
            throw new BizException("没有可导出数据");
        }
        if (cashAccountDetails.size() > 49999) {
            throw new BizException("数据超长，请联系管理员");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "学员编号", "姓名", "电话", "声部",
                    "交易类型", "交易金额", "交易时间", "备注", "可用余额"}, new String[]{
                    "organName", "userId", "username", "phone", "subjectName",
                    "type.msg", "amount", "createTime", "comment", "balance"}, cashAccountDetails);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attac:wq" +
                    "hment;filename=classGroup-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "学生个人课程余额导出")
    @PostMapping("export/userCoursesAccount")
    @PreAuthorize("@pcs.hasPermissions('export/userCoursesAccount')")
    public void userCoursesAccount(HttpServletResponse response, ExportUserAccountQueryInfo queryInfo) throws IOException {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        List<SysUserCoursesAccountDetail> coursesAccountDetails = sysUserCoursesAccountDetailDao.exportDetail(queryInfo);
        if (coursesAccountDetails.size() < 1) {
            throw new BizException("没有可导出数据");
        }
        if (coursesAccountDetails.size() > 49999) {
            throw new BizException("数据超长，请联系管理员");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "学员编号", "姓名", "电话", "声部",
                    "交易类型", "交易金额", "交易时间", "备注", "可用余额"}, new String[]{
                    "organName", "userId", "username", "phone", "subjectName",
                    "type.msg", "amount", "createTime", "comment", "balance"}, coursesAccountDetails);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attac:wq" +
                    "hment;filename=classGroup-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "班级列表导出")
    @PostMapping("export/classGroup")
    @PreAuthorize("@pcs.hasPermissions('export/classGroup')")
    public void exportClassGroup(HttpServletResponse response, ClassGroupQueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setOrganIds(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        List<ClassGroupTeachersDto> rows = classGroupService.queryClassGroupPage(queryInfo).getRows();
        for (ClassGroupTeachersDto row : rows) {
            List<ClassGroupTeacherMapper> classGroupTeacherMapperList = row.getClassGroupTeacherMapperList();
            if (classGroupTeacherMapperList.size() > 0) {
                List<ClassGroupTeacherMapper> teachingTeachers = classGroupTeacherMapperList.stream().filter(e -> e.getTeacherRole() == TeachTypeEnum.TEACHING).collect(Collectors.toList());
                if (teachingTeachers.size() > 0) {
                    row.setTeachingTeacherName(StringUtils.join(teachingTeachers.stream().map(e -> e.getUserName()).collect(Collectors.toList()), ","));
                }
                List<ClassGroupTeacherMapper> bishopTeachers = classGroupTeacherMapperList.stream().filter(e -> e.getTeacherRole() == TeachTypeEnum.BISHOP).collect(Collectors.toList());
                if (bishopTeachers.size() > 0) {
                    row.setBishopTeacherName(StringUtils.join(bishopTeachers.stream().map(e -> e.getUserName()).collect(Collectors.toList()), ","));
                }
            }
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"课程组编号", "课程组名称", "分部名称", "班级名称",
                    "班级类型", "班级人数", "主教老师", "助教老师", "已上课时", "总课数"}, new String[]{
                    "musicGroupId", "musicGroupName", "organName", "name",
                    "type.msg", "studentNum == NUll?0:studentNum", "bishopTeacherName", "teachingTeacherName", "currentClassTimes",
                    "totalClassTimes"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attac:wq" +
                    "hment;filename=classGroup-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "商品列表导出")
    @PostMapping("export/goods")
    @PreAuthorize("@pcs.hasPermissions('export/goods')")
    public void exportGoods(HttpServletResponse response, GoodsQueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<Goods> rows = goodsService.queryPage(queryInfo).getRows();
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"商品编号", "货号", "品牌", "商品名称",
                    "是否组合商品", "商品类型", "商品分类", "具体型号", "内部库存", "税务库存", "库存类型", "市场价(元)",
                    "零售价(元)", "商品团购价(元)", "商品描述", "商品详情", "是否上下架"}, new String[]{
                    "id", "sn", "brand", "name",
                    "complementGoodsIdList == null || complementGoodsIdList == '' ? '否':'是'",
                    "type.desc", "goodsCategoryName", "specification", "stockCount", "taxStockCount", "stockType.msg", "marketPrice",
                    "discountPrice", "groupPurchasePrice", "brief", "desc", "status.msg"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attac:wq" +
                    "hment;filename=goods-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "VIP活动导出")
    @PostMapping("export/vipGroupActivity")
    @PreAuthorize("@pcs.hasPermissions('export/vipGroupActivity')")
    public void exportVipGroupActivity(HttpServletResponse response, VipGroupActivityQueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        List<ExportVipGroupActivityDto> rows = vipGroupActivityService.exportVipGroupActivity(queryInfo);
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部名称", "活动编号", "活动名称", "活动内容", "适用课程类型",
                    "启用状态", "活动持续时间", "课程安排时间", "活动类型", "活动折扣", "线上课结算类型", "线上课结算公式",
                    "线下课结算类型", "线下课结算公式"}, new String[]{
                    "organName", "id", "name", "description", "vipGroupCategoryIdList",
                    "openFlag.msg", "time", "courseTime", "type", "disCount", "onlineSalaryType", "onlineSalarySettlement", "offlineSalaryType", "offlineSalarySettlement"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attac:wq" +
                    "hment;filename=vipGroupActivity-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "学员考勤记录导出")
    @PostMapping("export/exportStudentAttendances")
    @PreAuthorize("@pcs.hasPermissions('export/exportStudentAttendances')")
    public void exportStudentAttendances(HttpServletResponse response, ExportStudentAttendanceQueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        List<ExportStudentAttendanceDto> rows = studentAttendanceService.exportStudentAttendancesQueryPage(queryInfo).getRows();
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部编号", "分部名称", "课程组类型", "课程组编号", "课程组名称", "学员姓名",
                    "学员编号", "课程编号", "课程名称", "上课日期", "上课开始时间", "上课结束时间",
                    "指导老师名称", "指导老师编号", "教务老师名称", "教务老师编号", "授课老师名称", "授课老师编号", "学员考勤状态"}, new String[]{
                    "organId", "organName", "groupType.desc", "groupId", "groupName", "username",
                    "userId", "courseScheduleId", "courseScheduleName", "classDate", "startClassTime", "endClassTime", "guideTeacherName", "guideTeacherId"
                    , "educationalTeacherName", "educationalTeacherId", "actualTeacherName", "actualTeacherId", "studentAttendanceStatus.msg"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=studentAttendance-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "乐团管理--修改--缴费设置--缴费记录导出")
    @PostMapping("export/musicGroupPaymentCalenderDetail")
    @PreAuthorize("@pcs.hasPermissions('export/musicGroupPaymentCalenderDetail')")
    public void exportMusicGroupPaymentCalenderDetail(HttpServletResponse response, MusicCalenderDetailQueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<MusicGroupPaymentCalenderDetailDto> rows = musicGroupPaymentCalenderDetailService.queryDetailPage(queryInfo).getRows();
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"学员编号", "学员姓名", "学员声部", "学员状态", "手机号",
                    "缴费开始日期", "缴费截止日期", "是否开启缴费", "缴费状态", "支付时间", "会员金额", "乐器金额", "课程金额", "辅件金额", "乐保金额", "活动金额"}, new String[]{
                    "userId", "sysUser.username", "studentRegistration.subjectName", "studentRegistration.musicGroupStatus.msg", "sysUser.phone",
                    "startPaymentDateMgpc", "deadlinePaymentDateMgpc", "openFlag.msg", "paymentStatus.desc", "payTime",
                    "cloudAmount", "musicalAmount", "courseAmount", "accessoriesAmount", "maintenanceAmount", "activityAmount"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "业务管理--审核列表导出")
    @PostMapping("export/exportPaymentCalenderAuditList")
    @PreAuthorize("@pcs.hasPermissions('export/exportPaymentCalenderAuditList')")
    public void exportPaymentCalenderAuditList(HttpServletResponse response, MusicGroupPaymentCalenderQueryInfo queryInfo) throws IOException {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<MusicGroupPaymentCalenderAuditDto> rows = musicGroupPaymentCalenderService.auditList(queryInfo).getRows();
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部名称", "分部编号", "乐团编号", "乐团名称", "申请类型", "订单类型", "加课总时长（分钟）", "原现价（元）",
                    "申请价格（元）", "备注", "申请人", "状态", "申请时间"}, new String[]{
                    "organName", "organId", "musicGroupId", "musicGroupName", "paymentType.desc", "payUserType.desc",
                    "addCourseTotalTime", "courseCurrentPrice", "courseOriginalPrice", "memo", "operatorName", "auditStatus.desc", "createTime"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "导出教师考勤列表")
    @PostMapping("export/queryTeacherAttendances")
    @PreAuthorize("@pcs.hasPermissions('export/queryTeacherAttendances')")
    public void exportTeacherAttendances(HttpServletResponse response, TeacherCloseQueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        List rows = teacherAttendanceService.queryTeacherAttendances(queryInfo).getRows();
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "老师编号", "老师姓名", "工作性质", "课程编号", "课程名称", "上课日期",
                    "课程开始时间", "课程结束时间", "课程类型", "签到时间", "签到状态", "签退时间", "签退状态", "备注"}, new String[]{
                    "organName", "teacherId", "teacherName", "jobNature.msg", "courseScheduleId", "courseScheduleName", "classDate",
                    "startClassTime", "endClassTime", "courseScheduleType.msg", "signInTime", "signInStatus.msg", "signOutTime", "signOutStatus.msg",
                    "remark"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "导出申述处理列表")
    @PostMapping("export/teacherSalaryComplaints")
    @PreAuthorize("@pcs.hasPermissions('export/teacherSalaryComplaints')")
    public void exportTeacherSalaryComplaints(HttpServletResponse response, TeacherSalaryModifyQueryInfo queryInfo) throws IOException {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<TeacherSalaryComplaints> rows = teacherSalaryComplaintsService.queryPage(queryInfo).getRows();
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "老师ID", "老师姓名", "课酬归属时间", "申诉提交时间", "状态",
                    "申述处理者"}, new String[]{
                    "organName", "teacherId", "realName", "salarySettlementMonth", "createTime", "statusEnum.msg",
                    "operatorRealName"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "网管课购买列表")
    @PostMapping("export/studentBuyPractice")
    @PreAuthorize("@pcs.hasPermissions('export/studentBuyPractice')")
    public void studentBuyPractice(HttpServletResponse response, StudentBuyPracticeQueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        List<StudentBuyPracticeDto> rows = practiceGroupService.studentBuys(queryInfo).getRows();
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"学员编号", "学员名称", "所属分部", "课程老师", "课程组老师", "购买网管课",
                    "免费课结束日期", "首次购买日期", "时间差"}, new String[]{
                    "studentId", "studentName", "organName", "teacherName", "courseGroupTeacherName", "buyPractice.msg",
                    "lastClassDate", "firstBuyTime", "intervalDay"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "导出对外订单列表")
    @PostMapping("export/tenantPaymentOrder")
    @PreAuthorize("@pcs.hasPermissions('export/tenantPaymentOrder')")
    public void tenantPaymentOrder(HttpServletResponse response, TenantPaymentOrderQueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            throw new BizException("用户信息获取失败");
        }
        List<TenantPaymentOrder> paymentOrders = tenantPaymentOrderService.queryPage(queryInfo).getRows();
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"交易流水号", "订单号", "订单日期", "交易类型", "应付金额", "实付金额", "用户姓名", "手机号码", "交易方式", "收款账户", "交易状态",
                    "备注", "交易方式"}, new String[]{"transNo", "orderNo", "createTime", "type.desc", "expectAmount", "actualAmount", "user.username",
                    "user.phone", "paymentChannel", "merNos", "status.msg", "memo", "paymentChannel.desc"}, paymentOrders);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "导出老师课酬")
    @PostMapping("export/teacherSalary")
    @PreAuthorize("@pcs.hasPermissions('export/teacherSalary')")
    public void teacherSalary(HttpServletResponse response, ExportTeacherSalaryQueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            throw new BizException("用户信息获取失败");
        }
        queryInfo.setIsExport(true);
        List<ExportTeacherSalaryDto> rows = courseScheduleTeacherSalaryService.exportTeacherSalary(queryInfo);
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"课时编号", "老师编号", "老师姓名", "老师分部", "工作类别",
                    "课程分部", "课程组编号", "课程班名称", "乐团模式", "vip活动名称", "Vip课程类型", "阶梯奖励名称", "线上课/线下课", "线上课单价", "线下课单价",
                    "课程类别", "课时时长", "实际上课时长", "上课日期",
                    "上课时间", "教师签到状态", "教师签退状态", "教师签到时间", "教师签退时间", "考勤申诉处理状态", "处理意见",
                    "主辅", "上课地点", "应到学员", "学员签到时间", "学员签退时间", "课时课酬", "阶梯奖励", "扣款原因", "收入"}, new String[]{
                    "courseScheduleId", "teacherId", "teacherName", "teacherOrganName", "jobType",
                    "courseScheduleOrganName", "groupId", "groupName", "changeType", "vipActiveName", "vipCategoryName", "activeName", "teachMode", "onlineClassesUnitPrice", "offlineClassesUnitPrice",
                    "courseScheduleType", "signCourseScheduleTime", "currentTime", "classDate", "courseScheduleStartTime", "signInStatus",
                    "signOutStatus", "signInTime", "signOutTime", "complaintsStatus", "disposeContent", "teacherRole", "address", "studentNum",
                    "studentSignInTime", "studentSignOutTime", "price", "rewards", "deductionReason", "courseIncome"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "导出老师结转奖励")
    @PostMapping("export/teacherCourseReward")
    @PreAuthorize("@pcs.hasPermissions('export/teacherCourseReward')")
    public void teacherCourseReward(HttpServletResponse response, TeacherCourseRewardQueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        Date endTime = queryInfo.getEndTime();
        if (endTime != null) {
            queryInfo.setEndTime(DateUtil.addDays(endTime, 1));
        }
        List<TeacherCourseReward> rows = teacherCourseRewardService.queryPage(queryInfo).getRows();
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"课程组编号", "课程组名称", "分部", "指导老师", "是否结转", "结转金额", "结转日期", "备注"}, new String[]{
                    "musicGroupId", "courseGroupName", "organName", "teacherName", "settlementStatus.msg",
                    "expectRewardAmount", "settlementDate", "memo"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }


    @ApiOperation(value = "导出学员列表")
    @PostMapping("export/studentHasCourse")
    @PreAuthorize("@pcs.hasPermissions('export/studentHasCourse')")
    public void studentHasCourse(HttpServletResponse response, StudentManageQueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        queryInfo.setIsExport(true);
        List<StudentManageListDto> rows = studentManageService.findStudentsByOrganId(queryInfo).getRows();
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "学员编号", "学员姓名", "性别", "家长姓名",
                    "家长联系电话", "是否激活", "是否有课", "是否有网管课", "网管课剩余课时", "VIP课剩余课时", "课程余额(元)", "账户余额(元)",
                    "所在乐团", "乐团所属声部", "所在乐团状态", "所在vip课", "所在VIP状态", "服务标签", "运营标签", "指导老师", "是否签订协议", "是否使用云教练", "会员截止日期", "会员剩余天数", "会员试用结束日期", "会员试用剩余天数"}, new String[]{
                    "organName", "userId", "username", "gender.description", "parentsName", "parentsPhone",
                    "isActive.msg", "hasCourse.msg", "hasPracticeCourse.msg", "noStartPracticeCourseNum", "noStartVipCourseNum", "courseBalance", "balance", "musicGroupName",
                    "subjectName", "musicGroupStatus", "vipGroupName", "vipGroupStatus", "serviceTag.msg", "operatingTag.msg", "teacherName", "isSignedContract ? '是' : '否'", "recordUserId == null ? '否' : '是'",
                    "membershipEndTime", "membershipEndTime == null ? hasNoStartCloudTeacher ? \"未生效\" : \"未购买\" : membershipDay >= 0 ? membershipDay : hasNoStartCloudTeacher ? \"未生效\" : \"会员已过期\"",
                    "experienceMembershipEndTime", "membershipEndTime == null ? \"未试用\" : membershipDay >= 0 ? membershipDay : \"已失效\""}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }


    @ApiOperation(value = "导出陪练课列表")
    @GetMapping("export/practiceGroupList")
    @PreAuthorize("@pcs.hasPermissions('export/practiceGroupList')")
    public void queryAll(HttpServletResponse response, PracticeGroupQueryInfo queryInfo) throws IOException {
        queryInfo.setIsExport(true);
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        List<PracticeGroupDto> rows = practiceGroupService.findPracticeGroups(queryInfo).getRows();
        OutputStream outputStream = response.getOutputStream();
        if (rows != null && rows.size() > 0) {
            rows.forEach(e -> {
                e.setSubClassTimes(e.getTotalClassTimes() == null ? 0 : e.getTotalClassTimes() - (e.getCurrentClassTimes() == null ? 0 : e.getCurrentClassTimes()));
                if (e.getBuyMonths() == null || e.getBuyMonths() == 0) {
                    e.setPayStatus("免费");
                } else {
                    if (e.getBeRenewGroupId() == null || e.getBeRenewGroupId() == 0l) {
                        e.setPayStatus("首充");
                    } else {
                        e.setPayStatus("续费");
                    }
                }
            });
        }
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"课程组编号", "课程组名称", "课程组类型", "分部", "教务老师", "指导老师", "班级人数",
                    "当前课次", "总课次", "剩余课次", "开课时间", "结束时间", "课程组状态", "是否续费", "备注"}, new String[]{
                    "id", "name", "type.msg", "organName", "educationalTeacherName", "teacherName", "studentNum", "currentClassTimes",
                    "totalClassTimes", "subClassTimes", "coursesStartDate", "coursesExpireDate",
                    "groupStatus.desc", "payStatus", "memo"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "导出VIP课管理")
    @GetMapping("export/vipGroupList")
    @PreAuthorize("@pcs.hasPermissions('export/vipGroupList')")
    public void queryAll(HttpServletResponse response, VipGroupQueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setIsExport(true);
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        List<VipGroup> rows = vipGroupService.findVipGroups(queryInfo).getRows();
        OutputStream outputStream = response.getOutputStream();
//        if (rows != null && rows.size() > 0) {
//            for (VipGroup e : rows) {
//                e.setSubClassTimes(e.getTotalClassTimes() == null ? 0 : e.getTotalClassTimes() - (e.getCurrentClassTimes() == null ? 0 : e.getCurrentClassTimes()));
//            }
//        }
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"VIP编号", "课程名称", "课程状态", "指导老师", "教务老师", "班级人数", "课程单价",
                    "活动方案", "当前课次", "总课次", "剩余课次", "月消耗", "上次课时间", "开课时间", "结束时间", "申请时间", "学生姓名", "课程形式", "备注"}, new String[]{
                    "id", "name", "status.msg", "userName", "educationalTeacherName", "studentNum", "courseUnitPrice",
                    "vipGroupActivityName", "currentClassTimes", "totalClassTimes", "totalClassTimes == null ? 0 : totalClassTimes - (currentClassTimes == null ? 0 : currentClassTimes)", "monthConsumeRate", "lastOverTime",
                    "courseStartDate", "coursesExpireDate", "registrationStartTime", "userInfo", "vipGroupCategoryName", "stopReason"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }


    @ApiOperation(value = "导出零星收费列表")
    @GetMapping("export/sporadicChargeInfo")
    @PreAuthorize("@pcs.hasPermissions('export/sporadicChargeInfo')")
    public void queryPage(SporadicChargeInfoQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setIsExport(true);
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        List<SporadicChargeInfo> rows = sporadicChargeInfoService.queryDetailPage(queryInfo).getRows();
//        for (SporadicChargeInfo row : rows) {
//            row.setOpenFlagStr(row.getOpenFlag().equals(0) ? "开启" : "关闭");
//            row.setOrderType(row.getUserId() == null ? "公用" : "个人");
//        }
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "收费类型", "标题", "收费状态", "金额", "时间", "学生姓名", "订单类型", "创建人"}, new String[]{
                    "organName", "chargeType.msg", "title", "openFlag == 0?'开启':'关闭'", "amount", "createTime", "userName", "userId == null?'公用':'个人'", "operatorName"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }


    @ApiOperation(value = "导出乐器采购清单")
    @PostMapping("order/musicalListExport")
    @PreAuthorize("@pcs.hasPermissions('order/musicalListExport')")
    public void musicalListExport(HttpServletResponse response, String musicGroupId) throws IOException {
        List<Goods> musicalList = studentPaymentOrderDetailService.getMusicalList(musicGroupId);
        if (musicalList == null) {
            throw new BizException("数据集为空");
        }
        if (musicalList.size() > 50000) {
            throw new BizException("数据集太大，不能导出.最大数据集不能超过50000");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "乐团", "商品类型", "商品名称", "型号", "数量"}, new String[]{
                    "brief", "memo", "type.desc", "name", "specification", "sellCount"}, musicalList);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "导出学员采购清单明细")
    @PostMapping("order/musicalListDetailExport")
    @PreAuthorize("@pcs.hasPermissions('order/musicalListDetailExport')")
    public void musicalListDetailExport(HttpServletResponse response, String musicGroupId) throws IOException {
        List<MusicalListDetailDto> musicalList = studentPaymentOrderDetailService.getMusicalListDetail(musicGroupId, null);
        if (musicalList.size() > 50000) {
            throw new BizException("数据集太大，不能导出.最大数据集不能超过50000");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "乐团", "学员编号", "学员姓名", "声部", "购买乐器", "乐器采购方式", "乐器金额", "购买教辅", "教辅金额", "课程金额", "云教练金额", "乐保金额", "订单总价"}, new String[]{
                    "organName", "musicGroupName", "userId", "username", "subjectName", "musicalName", "kitGroupPurchaseTypeEnum.msg",
                    "musicalAmount", "accessoriesName", "accessoriesAmount", "courseAmount", "cloudTeacherAmount", "maintenanceAmount", "orderAmount"}, musicalList);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "乐团【报名中、缴费中】 学生详情列表导出")
    @PostMapping(value = "studentRegistration/queryStudentApplyDetailExport")
    @PreAuthorize("@pcs.hasPermissions('studentRegistration/queryStudentApplyDetailExport')")
    public void queryStudentApplyDetailExport(StudentRegistrationQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setIsExport(true);
        List<StudentApplyDetailDto> studentApplyDetail = studentRegistrationService.queryStudentDetailPage(queryInfo).getRows();
        if (studentApplyDetail.size() <= 0) {
            throw new BizException("没有可导出的记录");
        }
        List<MusicalListDetailDto> musicalListDetails = studentPaymentOrderDetailService.getMusicalListDetail(queryInfo.getMusicGroupId(), null);
        //获取分部年级列表
        MusicGroup musicGroup = musicGroupDao.get(queryInfo.getMusicGroupId());
        Map<Integer, String> gradeList = organizationService.getGradeList(musicGroup.getOrganId());
        for (StudentApplyDetailDto studentApplyDetailDto : studentApplyDetail) {
            if (StringUtils.isNotEmpty(studentApplyDetailDto.getCurrentGrade())) {
                String grade = gradeList.get(Integer.parseInt(studentApplyDetailDto.getCurrentGrade()));
                if (StringUtils.isNotEmpty(grade)) {
                    studentApplyDetailDto.setCurrentGrade(grade);
                }
            }

            for (MusicalListDetailDto musicalListDetail : musicalListDetails) {
                if (!musicalListDetail.getUserId().equals(studentApplyDetailDto.getStudentId())) continue;
                studentApplyDetailDto.setKitGroupPurchaseTypeEnum(musicalListDetail.getKitGroupPurchaseTypeEnum());
            }
            if (PaymentStatusEnum.YES.equals(studentApplyDetailDto.getPaymentStatus()) && studentApplyDetailDto.getKitGroupPurchaseTypeEnum() == null) {
                studentApplyDetailDto.setKitGroupPurchaseTypeEnum(KitGroupPurchaseTypeEnum.OWNED);
            }
            if (studentApplyDetailDto.getPayingStatus().equals(1)) {
                studentApplyDetailDto.setPayingStatusStr("缴费中");
            } else if (studentApplyDetailDto.getPayingStatus().equals(2)) {
                studentApplyDetailDto.setPayingStatusStr("审核中");
            }
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"学生姓名", "家长姓名", "年级", "班级", "性别", "服从调剂", "报名专业",
                    "实际专业", "联系电话", "学员缴费状态", "乐器购买方式", "缴费中/审核中", "是否购买云教练"}, new String[]{
                    "studentName", "parentsName", "currentGrade", "currentClass", "gender.description",
                    "isAllowAdjust.msg", "subjectName", "actualSubjectName", "parentsPhone", "paymentStatus.desc",
                    "kitGroupPurchaseTypeEnum.msg", "payingStatusStr", "hasCloudTeacher==1？'有':'没有'"}, studentApplyDetail);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "分页导出教师薪酬列表")
    @RequestMapping("courseScheduleTeacherSalary/export")
    @PreAuthorize("@pcs.hasPermissions('courseScheduleTeacherSalary/export')")
    public void export(CourseScheduleTeacherSalaryQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setIsExport(true);
        List<TeacherSalaryDto> teacherSalaries = courseScheduleTeacherSalaryService.querySalaries(queryInfo).getRows();
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"用户编号", "用户名", "手机号", "课程类型", "实际薪水", "补助", "结算时间", "教师角色"}, new String[]{
                    "userId", "username", "phone", "type.msg", "name", "actualSalary", "subsidy", "settlementTime", "teacherRole.msg"}, teacherSalaries);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }


    @ApiOperation(value = "乐团管理--乐团详情-导出学员列表")
    @RequestMapping("export/musicGroupStudent")
    @PreAuthorize("@pcs.hasPermissions('export/musicGroupStudent')")
    public void queryMusicGroupStudent(MusicGroupStudentQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setIsExport(true);
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        PageInfo<MusicGroupStudentsDto> musicGroupStudentsDtoPageInfo = studentManageService.queryMusicGroupStudent(queryInfo);
        OutputStream outputStream = response.getOutputStream();
        try {
            //获取分部年级列表
            MusicGroup musicGroup = musicGroupDao.get(queryInfo.getMusicGroupId());
            Map<Integer, String> gradeList = organizationService.getGradeList(musicGroup.getOrganId());
            for (MusicGroupStudentsDto row : musicGroupStudentsDtoPageInfo.getRows()) {
                if (StringUtils.isNotEmpty(row.getCurrentGrade())) {
                    String grade = gradeList.get(Integer.parseInt(row.getCurrentGrade()));
                    if (StringUtils.isNotEmpty(grade)) {
                        row.setCurrentGrade(grade);
                    }
                }

                if (row.getGender() != null) {
                    if (row.getGender().equals("1")) {
                        row.setGender("男");
                    } else {
                        row.setGender("女");
                    }
                }
                if (row.getStudentStatus().equals("NORMAL")) {
                    row.setStudentStatus("在读");
                } else if (row.getStudentStatus().equals("QUIT")) {
                    row.setStudentStatus("退团");
                } else if (row.getStudentStatus().equals("APPLY")) {
                    row.setStudentStatus("报名");
                } else {
                    row.setStudentStatus("" + row.getStudentStatus());
                }
                if (row.getIsActive()) {
                    row.setActiveName("是");
                } else {
                    row.setActiveName("否");
                }
                if (row.getMusicMembershipDay() != null && row.getMusicMembershipDay() < 0) {
                    row.setMusicMembershipDay1(Math.abs(row.getMusicMembershipDay()));
                }
                if (row.getNextPaymentDate() != null) {
                    row.setNextPaymentDateStr(DateUtil.format(row.getNextPaymentDate(), DateUtil.DEFAULT_PATTERN));
                }
            }
            String[] header = {"学员编号", "学员姓名", "性别", "联系电话", "入团时间", "年级", "班级", "入团专业", "学员状态", "报名缴费", "缴费金额", "是否激活",
                    "VIP/网管是否有课", "关心包", "加油包", "欠费金额（元）", "退团原因", "会员截止时间", "会员剩余天数"};
            String[] body = {"userId", "realName", "gender", "phone", "registerTime", "currentGrade", "currentClass", "subjectName", "studentStatus", "paymentStatus.desc"
                    , "courseFee", "activeName", "hasCourse ? '是' : '否'"
                    , "carePackage == null || carePackage == 0 ? '不可用' : carePackage == 1 ? '可用' : '已使用'"
                    , "comeOnPackage == null || comeOnPackage == 0 ? '不可用'' : comeOnPackage == 1 ? '可用' : '已使用'"
                    , "noPaymentAmount == null ? 0 : noPaymentAmount", "quitReason",
                    "membershipEndTime", "membershipEndTime == null ? hasNoStartCloudTeacher ? '未生效' : '未购买' : membershipDay >= 0 ? membershipDay : hasNoStartCloudTeacher ? '未生效' : '会员已过期'"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, musicGroupStudentsDtoPageInfo.getRows());
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "评论列表导出")
    @RequestMapping("export/courseReviews")
    @PreAuthorize("@pcs.hasPermissions('export/courseReviews')")
    public void courseReviews(CourseReviewQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        queryInfo.setIsExport(1);
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        PageInfo<CourseReviewDto> practiceGroupReviews = courseReviewService.getVipCourseReviews(queryInfo);
        if (practiceGroupReviews.getTotal() <= 0) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            for (CourseReviewDto row : practiceGroupReviews.getRows()) {
                row.setClassDateStr(DateUtil.dateToString(row.getClassDate(), "yyyy-MM-dd"));
                if (row.getHandHomework() != null && row.getHandHomework() > 0) {
                    row.setHandHomeworkStr("是");
                } else {
                    row.setHandHomeworkStr("否");
                }
                if (row.getHasLiaison() != null && row.getHasLiaison().equals("1")) {
                    row.setHasLiaison("是");
                } else {
                    row.setHasLiaison("否");
                }
                if (row.getCreateTime() != null) {
                    row.setCreateTimeStr(DateUtil.dateToString(row.getCreateTime(), "yyyy-MM-dd"));
                }
                if (row.getPronunciation() != null) {
                    row.setPronunciationStr(row.getPronunciation() + "星");
                }
                if (row.getTempo() != null) {
                    row.setTempoStr(row.getTempo() + "星");
                }
                if (row.getMusicTheory() != null) {
                    row.setMusicTheoryStr(row.getMusicTheory() + "星");
                }
                if (row.getHomeWorkReplied() != null && row.getHomeWorkReplied().equals("1")) {
                    row.setHomeWorkReplied("已回复");
                } else if (row.getHandHomework() != null && row.getHandHomework() > 0) {
                    row.setHomeWorkReplied("未回复");
                } else {
                    row.setHomeWorkReplied(null);
                }
                if (row.getAttendanceId() != null) {
                    row.setAttendanceStr("是");
                } else {
                    row.setAttendanceStr("否");
                }
                if (new Integer(1).equals(row.getAssignHomework())) {
                    row.setAssignHomeworkStr("是");
                } else {
                    row.setAssignHomeworkStr("否");
                }
            }

            String[] header = {"分部", "上课日期", "学生编号", "课程编号", "学员是否到课", "课程班名称", "老师", "教材内容", "发音", "节奏",
                    "乐理", "曲目", "评价备注", "回访日期（布置训练）", "完成app双向沟通", "学员评分", "是否布置训练", "是否提交训练", "是否回复训练", "教务老师", "教务评价"};
            String[] body = {"organName", "classDateStr", "studentId", "id", "attendanceStr", "courseName",
                    "teacherName", "teachingMaterial", "pronunciationStr", "tempoStr", "musicTheoryStr", "song",
                    "memo", "createTimeStr", "hasLiaison", "studentReview", "assignHomeworkStr", "handHomeworkStr", "homeWorkReplied", "eduTeacherName", "courseReview"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, practiceGroupReviews.getRows());
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }


    @ApiOperation(value = "网管课管理导出")
    @RequestMapping("export/practiceGroup")
    @PreAuthorize("@pcs.hasPermissions('export/practiceGroup')")
    public void practiceGroup(HttpServletResponse response) throws IOException {
        String organIds = organizationService.getEmployeeOrgan("");

        List<CourseGroupExportDto> practiceGroupExports = practiceGroupDao.getPracticeGroupExport(organIds, TenantContextHolder.getTenantId());
        if (practiceGroupExports == null || practiceGroupExports.size() == 0) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();
        Set<Integer> studentIds = practiceGroupExports.stream().map(CourseGroupExportDto::getStudentId).collect(Collectors.toSet());
        List<CourseGroupExportDto> studentCourseInfos = courseScheduleDao.getStudentCourseInfo(studentIds, GroupType.PRACTICE);

        List<CourseGroupExportDto> totalClassTimes = courseScheduleDao.getStudentCourseScheduleNum(studentIds, GroupType.PRACTICE, null);
        List<CourseGroupExportDto> noStartClassTimes = courseScheduleDao.getStudentCourseScheduleNum(studentIds, GroupType.PRACTICE, CourseStatusEnum.NOT_START);
        for (CourseGroupExportDto practiceGroupExport : practiceGroupExports) {
            for (CourseGroupExportDto studentCourseInfo : studentCourseInfos) {
                if (studentCourseInfo.getStudentId().equals(practiceGroupExport.getStudentId())) {
                    practiceGroupExport.setTeacherIds(studentCourseInfo.getTeacherIds());
                    practiceGroupExport.setTeacherName(studentCourseInfo.getTeacherName());
                    practiceGroupExport.setClassEndDate(studentCourseInfo.getClassEndDate());
                    break;
                }
            }

            for (CourseGroupExportDto studentTotalClassTimes : totalClassTimes) {
                if (studentTotalClassTimes.getStudentId().equals(practiceGroupExport.getStudentId())) {
                    practiceGroupExport.setTotalClassTimes(studentTotalClassTimes.getTotalClassTimes());
                    break;
                }
            }
            for (CourseGroupExportDto noStartStudentClassTimes : noStartClassTimes) {
                if (noStartStudentClassTimes.getStudentId().equals(practiceGroupExport.getStudentId())) {
                    practiceGroupExport.setNoStartClassTimes(noStartStudentClassTimes.getTotalClassTimes());
                    break;
                }
            }
        }

        try {
            String[] header = {"分部", "学生编号", "学生姓名", "网管课老师id", "网管课老师", "教务老师id", "教务老师",
                    "有效期截止时间", "课程截止时间", "总课时", "剩余课时", "是否购买"};
            String[] body = {"organName", "studentId", "studentName", "teacherIds", "teacherName", "eduTeacherIds",
                    "eduTeacherName", "expireDate", "classEndDate", "totalClassTimes", "noStartClassTimes", "buyPractice.msg"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, practiceGroupExports);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "vip管理导出")
    @RequestMapping("export/vipGroup")
    @PreAuthorize("@pcs.hasPermissions('export/vipGroup')")
    public void vipGroup(HttpServletResponse response) throws IOException {
        List<CourseGroupExportDto> vipGroupExports = courseScheduleDao.getVipGroupExport(organizationService.getEmployeeOrgan(""));
        if (vipGroupExports == null || vipGroupExports.size() == 0) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();
        Set<Integer> studentIds = vipGroupExports.stream().map(CourseGroupExportDto::getStudentId).collect(Collectors.toSet());
        List<Map<Integer, Date>> studentLastCourseSchedule = courseScheduleStudentPaymentDao.findStudentLastCourseSchedule(new ArrayList<>(studentIds));
        Map<Integer, String> studentLastCourseMap = new HashMap<>();
        if (!CollectionUtils.isEmpty(studentLastCourseSchedule)) {
            studentLastCourseMap = MapUtil.convertMybatisMap(studentLastCourseSchedule);
        }
        List<CourseGroupExportDto> studentCourseInfos = courseScheduleDao.getStudentVipCourseInfo(studentIds);
        List<CourseGroupExportDto> totalClassTimes = courseScheduleDao.getStudentCourseScheduleNum(studentIds, GroupType.VIP, null);
        List<CourseGroupExportDto> noStartClassTimes = courseScheduleDao.getStudentCourseScheduleNum(studentIds, GroupType.VIP, CourseStatusEnum.NOT_START);
        for (CourseGroupExportDto vipGroupExport : vipGroupExports) {

            String lastClassDateStr = studentLastCourseMap.get(vipGroupExport.getStudentId());
            if (StringUtils.isNotBlank(lastClassDateStr)) {
                vipGroupExport.setLastClassDate(DateUtil.stringToDate(lastClassDateStr));
            }

            for (CourseGroupExportDto studentCourseInfo : studentCourseInfos) {
                if (studentCourseInfo.getStudentId().equals(vipGroupExport.getStudentId())) {
                    vipGroupExport.setTeacherIds(studentCourseInfo.getTeacherIds());
                    vipGroupExport.setTeacherName(studentCourseInfo.getTeacherName());
                    vipGroupExport.setClassStartDate(studentCourseInfo.getClassStartDate());
                    vipGroupExport.setClassEndDate(studentCourseInfo.getClassEndDate());
                    break;
                }
            }
            for (CourseGroupExportDto studentTotalClassTimes : totalClassTimes) {
                if (studentTotalClassTimes.getStudentId().equals(vipGroupExport.getStudentId())) {
                    vipGroupExport.setTotalClassTimes(studentTotalClassTimes.getTotalClassTimes());
                    break;
                }
            }
            for (CourseGroupExportDto noStartStudentClassTimes : noStartClassTimes) {
                if (noStartStudentClassTimes.getStudentId().equals(vipGroupExport.getStudentId())) {
                    vipGroupExport.setNoStartClassTimes(noStartStudentClassTimes.getTotalClassTimes());
                    break;
                }
            }
        }

        try {
            String[] header = {"分部", "学生编号", "学生姓名", "指导老师id", "指导老师", "教务老师id", "教务老师", "课程开始时间", "课程截止时间", "上次课时间", "总课时", "剩余课时"};
            String[] body = {"organName", "studentId", "studentName", "teacherIds", "teacherName", "eduTeacherIds", "eduTeacherName", "classStartDate", "classEndDate", "lastClassDate", "totalClassTimes", "noStartClassTimes"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, vipGroupExports);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "学生课外训练记录导出")
    @GetMapping("export/extraExercisesReplys")
    @PreAuthorize("@pcs.hasPermissions('export/extraExercisesReplys')")
    public void extraExercisesReplys(ExtraExercilseReplyQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setOrganIdList(organizationService.getEmployeeOrgan(queryInfo.getOrganIdList()));
        List<ExtraExerciseStudentsDto> rows = extracurricularExercisesReplyService.findExtraExercises(queryInfo).getRows();
        if (CollectionUtils.isEmpty(rows)) {
            throw new BizException("没有可导出的记录");
        }
        for (ExtraExerciseStudentsDto row : rows) {
            row.setStatusStr(Objects.isNull(row.getStatus()) || row.getStatus() == 0 ? "否" : "是");
            row.setIsViewStr(Objects.isNull(row.getIsView()) || row.getIsView() == 0 ? "否" : "是");
            row.setIsRepliedStr(Objects.isNull(row.getIsReplied()) || row.getIsReplied() == 0 ? "否" : "是");
            row.setIsRepliedTimelyStr(Objects.isNull(row.getIsRepliedTimely()) || row.getIsRepliedTimely() == 0 ? "否" : "是");
            row.setExistVipCourseStr(Objects.isNull(row.getExistVipCourse()) || row.getExistVipCourse() == 0 ? "否" : "是");
            row.setMusicScoreId(StringUtils.isEmpty(row.getMusicScoreId()) ? "否" : "是");
        }
        OutputStream ouputStream = null;
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(
                    new String[]{"布置时间", "截至时间", "训练标题", "老师名字", "分部", "学生姓名", "学生编号", "提交训练", "提交训练时间", "是否评价", "是否有vip", "及时评价", "是否云教练布置"},
                    new String[]{"createTime", "expireDate", "title", "teacherName", "organName",
                            "user.username", "userId", "statusStr", "submitTime", "isRepliedStr", "existVipCourseStr", "isRepliedTimelyStr", "musicScoreId"}, 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();
                }
            }
        }
    }

    @ApiOperation(value = "课外训练-教学导出")
    @GetMapping("export/exercisesSituations")
    @PreAuthorize("@pcs.hasPermissions('export/exercisesSituations')")
    public void exercisesSituations(StudentExercisesSituationQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        List<StudentExercisesSituationDto> rows = studentExtracurricularExercisesSituationService.findStudentExtracurricularExercisesSituations(queryInfo).getRows();
        if (CollectionUtils.isEmpty(rows)) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream ouputStream = null;
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(
                    new String[]{"学员编号", "学员姓名", "所属分部", "乐团名称", "指导老师", "教务老师", "服务课程",
                            "预期安排", "实际安排", "提交次数", "评价次数", "及时评价次数", "付费网管课", "VIP课", "训练提交时间"},
                    new String[]{"studentId", "studentName", "organName", "groupNames", "teacherName",
                            "educationalTeacherName", "serveType == 'EXERCISE' ? '课外训练':courseIds",
                            "expectExercisesNum", "actualExercisesNum", "exercisesReplyNum",
                            "exercisesMessageNum", "exercisesMessageTimelyNum", "existPracticeCourse", "existVipCourse", "lastSubmitTime"}, 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();
                }
            }
        }
    }

    @ApiOperation(value = "教师课酬导出")
    @GetMapping("export/isSettlementCourseSalarys")
    @PreAuthorize("@pcs.hasPermissions('export/isSettlementCourseSalarys')")
    public void isSettlementCourseSalarys(CourseSalaryQueryInfo4Web queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setOrganIdList(organizationService.getEmployeeOrgan(queryInfo.getOrganIdList()));
        List<TeacherCourseSalaryDetail4WebDto> rows = courseScheduleTeacherSalaryService.findIsSettlementCourseSalarys(queryInfo).getRows();
        if (CollectionUtils.isEmpty(rows)) {
            throw new BizException("没有可导出的记录");
        }
        for (TeacherCourseSalaryDetail4WebDto row : rows) {
            if (Objects.isNull(row.getSignInTime())) {
                row.setSignInStatusStr("未签到");
            } else {
                String signInTimeStr = DateUtil.dateToString(row.getSignInTime(), "yyyy-MM-dd HH:mm");
                if (YesOrNoEnum.YES.equals(row.getSignInStatus())) {
                    row.setSignInStatusStr(signInTimeStr + "(正常签到)");
                } else {
                    row.setSignInStatusStr(signInTimeStr + "(异常签到)");
                }
            }
            if (Objects.isNull(row.getSignOutTime())) {
                row.setSignOutStatusStr("未签退");
            } else {
                String signOutTimeStr = DateUtil.dateToString(row.getSignOutTime(), "yyyy-MM-dd HH:mm");
                if (YesOrNoEnum.YES.equals(row.getSignOutStatus())) {
                    row.setSignOutStatusStr(signOutTimeStr + "(正常签退)");
                } else {
                    row.setSignOutStatusStr(signOutTimeStr + "(异常签退)");
                }
            }
            if (row.getBelongDaya() == 1) {
                row.setSalaryType("基本课酬");
            } else {
                row.setSalaryType("其它课酬");
            }
        }
        OutputStream ouputStream = null;
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(
                    new String[]{"分部", "课程组类型", "课程编号", "时间", "课程名称", "老师编号", "老师姓名", "签到时间", "签退时间",
                            "学员缴费", "课酬类型", "应发课酬", "课酬扣款", "结算课酬", "状态", "备注", "扣款原因"},
                    new String[]{"organName", "groupType.desc", "courseScheduleId", "startClassTime", "courseName", "teacherId", "teacherName",
                            "signInStatusStr", "signOutStatusStr", "actualReceipts", "salaryType", "actualSalary", "reduceSalary", "finalSalary",
                            "confirmStatus.desc", "memo", "deductionReason"}, 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();
                }
            }
        }
    }


    @ApiOperation(value = "运营指标管理导出")
    @GetMapping("export/operatingStudents")
    @PreAuthorize("@pcs.hasPermissions('export/operatingStudents')")
    public void operatingStudents(StudentOperatingQueryInfo queryInfo, HttpServletResponse response) {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        PageInfo<Student4operating> PageOperatingStudents = studentManageService.getOperatingStudents(queryInfo);

        if (PageOperatingStudents.getTotal() <= 0) {
            throw new BizException("导出记录不存在");
        }
        List<Student4operating> rows = PageOperatingStudents.getRows();
        for (Student4operating row : rows) {
            if (row.getOperatingTag() != null && row.getOperatingTag() == 1) {
                row.setOperatingTagStr("是");
            } else {
                row.setOperatingTagStr("否");
            }
            if (row.getVipTimes() != null && row.getVipTimes() > 0) {
                row.setVipTimesStr("是");
            } else {
                row.setVipTimesStr("否");
            }
            if (row.getMusicNetWorkTimes() != null && row.getMusicNetWorkTimes() > 0) {
                row.setMusicNetWorkTimesStr("是");
            } else {
                row.setMusicNetWorkTimesStr("否");
            }
            if (row.getFreePracticeTimes() != null && row.getFreePracticeTimes() > 0) {
                row.setFreePracticeTimesStr("是");
            } else {
                row.setFreePracticeTimesStr("否");
            }
            if (row.getBuyPracticeTimes() != null && row.getBuyPracticeTimes() > 0) {
                row.setBuyPracticeTimesStr("是");
            } else {
                row.setBuyPracticeTimesStr("否");
            }
        }
        OutputStream ouputStream = null;
        try {

            HSSFWorkbook workbook = POIUtil.exportExcel(
                    new String[]{"分部", "乐团名称", "学生", "学生编号", "指导老师", "指导老师id", "参与运营指标", "有线上VIP课", "参与免费网管课", "有付费网管课", "有乐团网管课"},
                    new String[]{"organName", "groupNames", "studentName", "studentId", "teacherName", "teacherId",
                            "operatingTagStr", "vipTimesStr", "freePracticeTimesStr", "buyPracticeTimesStr", "musicNetWorkTimesStr"}, 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();
                }
            }
        }
    }

    @ApiOperation(value = "vip评论列表导出")
    @RequestMapping("export/vipCourseReviews")
    @PreAuthorize("@pcs.hasPermissions('export/vipCourseReviews')")
    public void vipCourseReviews(CourseReviewQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        queryInfo.setIsExport(1);
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        PageInfo<CourseReviewDto> practiceGroupReviews = courseReviewService.getVipCourseReviews(queryInfo);
        if (practiceGroupReviews.getTotal() <= 0) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            for (CourseReviewDto row : practiceGroupReviews.getRows()) {
                row.setClassDateStr(DateUtil.dateToString(row.getClassDate(), "yyyy-MM-dd"));
                if (row.getHandHomework() != null && row.getHandHomework() > 0) {
                    row.setHandHomeworkStr("是");
                } else {
                    row.setHandHomeworkStr("否");
                }
                if (row.getHasLiaison() != null && row.getHasLiaison().equals("1")) {
                    row.setHasLiaison("是");
                } else {
                    row.setHasLiaison("否");
                }
                if (row.getCreateTime() != null) {
                    row.setCreateTimeStr(DateUtil.dateToString(row.getCreateTime(), "yyyy-MM-dd"));
                }
                if (row.getPronunciation() != null) {
                    row.setPronunciationStr(row.getPronunciation() + "星");
                }
                if (row.getTempo() != null) {
                    row.setTempoStr(row.getTempo() + "星");
                }
                if (row.getMusicTheory() != null) {
                    row.setMusicTheoryStr(row.getMusicTheory() + "星");
                }
                if (row.getHomeWorkReplied() != null && row.getHomeWorkReplied().equals("1")) {
                    row.setHomeWorkReplied("已回复");
                } else if (row.getHandHomework() != null && row.getHandHomework() > 0) {
                    row.setHomeWorkReplied("未回复");
                } else {
                    row.setHomeWorkReplied(null);
                }
                if (row.getAttendanceId() != null) {
                    row.setAttendanceStr("是");
                } else {
                    row.setAttendanceStr("否");
                }
                if (new Integer(1).equals(row.getAssignHomework())) {
                    row.setAssignHomeworkStr("是");
                } else {
                    row.setAssignHomeworkStr("否");
                }
            }

            String[] header = {"分部", "上课日期", "课程编号", "课程班名称", "老师", "教材内容", "发音", "节奏", "乐理",
                    "曲目", "评价备注", "回访日期（布置训练）", "是否布置训练", "是否提交训练", "教务老师", "教务评价"};
            String[] body = {"organName", "classDateStr", "id", "courseName", "teacherName", "teachingMaterial",
                    "pronunciationStr", "tempoStr", "musicTheoryStr", "song", "memo", "createTimeStr", "assignHomeworkStr",
                    "handHomeworkStr", "eduTeacherName", "courseReview"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, practiceGroupReviews.getRows());
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }


    @ApiOperation(value = "考级报名导出")
    @RequestMapping("export/degreeRegistration")
    @PreAuthorize("@pcs.hasPermissions('export/degreeRegistration')")
    public void degreeRegistration(DegreeQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setSort("create_time_");
        queryInfo.setOrder("ASC");
        queryInfo.setRows(65000);
        PageInfoDegree<DegreeRegistration> pageList = degreeRegistrationService.getPageList(queryInfo);
        if (pageList.getTotal() <= 0) {
            throw new BizException("没有可导出的记录");
        }
        Map<String, String> map = new HashMap<>(10);
        map.put("一级", "1");
        map.put("二级", "2");
        map.put("三级", "3");
        map.put("四级", "4");
        map.put("五级", "5");
        map.put("六级", "6");
        map.put("七级", "7");
        map.put("八级", "8");
        map.put("九级", "9");
        map.put("十级", "10");
        for (DegreeRegistration row : pageList.getRows()) {
            row.setActivityTag(map.get(row.getLevel()));
            if (row.getType() == 2) {
                row.setSubject("乐理");
            }
            row.setGender("1".equals(row.getGender()) ? "男" : "女");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {"姓名", "性别", "编号", "证件号码", "城市", "学校", "报考乐器", "报考级别", "级别", "乐理级别证书", "家长联系电话", "考级费用", "备注", "缴费状态", "订单编号", "商户订单号", "报名时间"};
            String[] body = {"name", "gender", "id", "idcard", "city", "school", "subject", "level", "activityTag",
                    "theoryCert", "mobile", "money", "memo", "status == 2?'已缴费':status == 3?'已退费':'未缴费'", "orderNo", "transNo", "createTime"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, pageList.getRows());
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }


    @ApiOperation(value = "合作单位导出")
    @RequestMapping("export/cooperationOrgan")
    @PreAuthorize("@pcs.hasPermissions('export/cooperationOrgan')")
    public void cooperationOrgan(CooperationOrganQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        queryInfo.setRows(65000);
        PageInfo<CooperationOrgan> pageList = cooperationOrganService.queryPage(queryInfo);
        if (pageList.getTotal() <= 0) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();
        try {

            String[] header = {"分部", "单位编号", "单位名称", "是否启用", "乐团主管", "状态栏"};
            String[] body = {"organization.name", "id", "name", "isEnable == true ? '是':'否'", "realName", "isEnable == true ? '开启' : '未开启'"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, pageList.getRows());
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=cooperationOrgan-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "终课表列表导出")
    @GetMapping("export/superFindCourseSchedules")
    @PreAuthorize("@pcs.hasPermissions('export/superFindCourseSchedules')")
    public HttpResponseResult superFindCourseSchedules(EndCourseScheduleQueryInfo queryInfo) throws IOException {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            throw new BizException("用户信息获取失败");
        }
        queryInfo.setOrganIdList(organizationService.getEmployeeOrgan(sysUser.getId(), queryInfo.getOrganIdList(), sysUser.getIsSuperAdmin()));
        Map<String, Object> params = new HashMap<>();
        MapUtil.populateMap(params, queryInfo);
        Integer tenantId = TenantContextHolder.getTenantId();
        if (Objects.equals("COURSE_TIME_ERROR", queryInfo.getSearchType())) {
            String courseStartTimeError = sysTenantConfigService.getTenantConfigValue(SysConfigService.COURSE_START_TIME_ERROR, tenantId);
            String courseEndTimeError = sysTenantConfigService.getTenantConfigValue(SysConfigService.COURSE_END_TIME_ERROR, tenantId);
            if (StringUtils.isEmpty(courseStartTimeError) || StringUtils.isEmpty(courseEndTimeError)) {
                return failed("没有可导出的数据");
            }
            params.put("courseStartTimeError", courseStartTimeError);
            params.put("courseEndTimeError", courseEndTimeError);
        }
        int count = scheduleService.endCountCourseSchedules(params);
        if (count <= 0) {
            return failed("没有可导出的数据");
        }
        if (count > 50000) {
            return failed("数据集太大，不能导出.最大数据集不能超过50000");
        }
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        queryInfo.setIsExport(true);
        ManagerDownload managerDownload = exportService.saveManagerDownload(ExportTypeEnum.COURSE_SCHEDULE, sysUser.getId());
        TenantContextHolder.setTenantId(tenantId);
        HttpResponseResult succeed = exportService.asyncExport(() -> exportService.superFindCourseSchedules(queryInfo, managerDownload), managerDownload.getName());
        TenantContextHolder.clearTenantId();
        return succeed;
    }

    @ApiOperation(value = "老师默认课酬导出")
    @RequestMapping("export/teacherDefaultSalary")
    @PreAuthorize("@pcs.hasPermissions('export/teacherDefaultSalary')")
    public void exportTeacherDefaultSalary(String organIdList, HttpServletResponse response) throws IOException {
        List<TeacherDefaultSalaryDto> pageList = teacherService.queryTeacherDefaultSalary(organIdList);
        if (pageList.size() <= 0) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {"老师编号", "姓名", "分部", "工作类型", "在职状态", "老师状态", "1v1", "1v2", "1v3", "1v4", "1v5", "1v6", "1v7",
                    "网管课", "单技课2.0(主教)", "合奏课2.0(主教)", "综合课2.0(主教)", "集训单技课2.0(主教)", "集训合奏课2.0(主教)",
                    "基础技能课2.0(主教)", "课堂课(主教)", "单技课3.0(主教)", "合奏课3.0(主教)", "综合课3.0(主教)", "集训单技课3.0(主教)", "集训合奏课3.0(主教)",
                    "基础技能课3.0(主教)"
                    , "单技课2.0(助教)", "合奏课2.0(助教)", "综合课2.0(助教)", "集训单技课2.0(助教)", "集训合奏课2.0(助教)",
                    "基础技能课2.0(助教)", "课堂课(助教)", "单技课3.0(助教)", "合奏课3.0(助教)", "综合课3.0(助教)", "集训单技课3.0(助教)", "集训合奏课3.0(助教)",
                    "基础技能课3.0(助教)", "网络基础训练课1v3", "网络基础训练课1v4", "网络基础训练课1v5", "乐团网管课1v1"};
            String[] body = {"userId", "realName", "organName", "jobNature", "demissionStatus", "status", "vip1", "vip2", "vip3", "vip4", "vip5", "vip6", "vip7",
                    "practiceSalary", "mainSingleSalary2", "mainMixSalary2", "mainComprehensiveSalary2", "mainTraningSigleSalary2", "mainTraningMixSalary2",
                    "mainHighSalary2", "mainClassroomSalary2", "mainSingleSalary", "mainMixSalary", "mainComprehensiveSalary", "mainTraningSigleSalary", "mainTraningMixSalary",
                    "mainHighSalary",
                    "assistantSingleSalary2", "assistantMixSalary2", "assistantComprehensiveSalary2", "assistantTraningSigleSalary2", "assistantTraningMixSalary2",
                    "assistantHighSalary2", "assistantClassroomSalary2", "assistantSingleSalary", "assistantMixSalary", "assistantComprehensiveSalary", "assistantTraningSigleSalary", "assistantTraningMixSalary",
                    "assistantHighSalary", "highOnline3Salary", "highOnline4Salary", "highOnline5Salary", "musicNetwork1Salary"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, pageList);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=teacherDefaultSalary-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "回款统计")
    @RequestMapping("export/studentOrder")
    @PreAuthorize("@pcs.hasPermissions('export/studentOrder')")
    public void studentOrder(String organIds, Date date, HttpServletResponse response) throws IOException {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        organIds = organizationService.getEmployeeOrgan(sysUser.getId(), organIds, sysUser.getIsSuperAdmin());
        Date startTime = DateUtil.getFirstDayOfMonth(date);
        Date EndTime = DateUtil.getLastSecondWithDay(DateUtil.getLastDayOfMonth(date));

        List<OrderTypeEnum> orderTypeList = new ArrayList<>();
        orderTypeList.add(OrderTypeEnum.SPORADIC);
        orderTypeList.add(OrderTypeEnum.PRACTICE_GROUP_BUY);
        orderTypeList.add(OrderTypeEnum.PRACTICE_GROUP_RENEW);
        orderTypeList.add(OrderTypeEnum.SMALL_CLASS_TO_BUY);
        List<OrderByTypeExportDto> orders = studentPaymentOrderDao.getOrderByMonthAndType(organIds, orderTypeList, startTime, EndTime);

        if (orders.size() <= 0) {
            throw new BizException("没有可导出的记录");
        }
        List<Long> vipGroupIds = orders.stream().filter(e -> e.getGroupType().equals(GroupType.VIP)).map(OrderByTypeExportDto::getMusicGroupId).collect(Collectors.toList());
        List<Long> practiceGroupIds = orders.stream().filter(e -> e.getGroupType().equals(GroupType.PRACTICE)).map(OrderByTypeExportDto::getMusicGroupId).collect(Collectors.toList());
        List<Integer> studentIds = orders.stream().filter(e -> e.getGroupType().equals(GroupType.SPORADIC)).map(OrderByTypeExportDto::getStudentId).collect(Collectors.toList());

        List<VipBuyResultDto> vipGroupTeachers = new ArrayList<>();
        List<PracticeCourseDto> practiceGroupsTeacher = new ArrayList<>();
        List<Student> studentTeachers = new ArrayList<>();
        if (vipGroupIds.size() > 0) {
            vipGroupTeachers = vipGroupDao.getGroupTeachers(vipGroupIds, TenantContextHolder.getTenantId());
        }

        if (practiceGroupIds.size() > 0) {
            practiceGroupsTeacher = practiceGroupDao.getPracticeGroupByIds(practiceGroupIds);
        }
        if (studentIds.size() > 0) {
            studentTeachers = studentDao.getStudentTeacher(studentIds);
        }

        for (OrderByTypeExportDto order : orders) {
            for (VipBuyResultDto vipGroupTeacher : vipGroupTeachers) {
                if (order.getGroupType().equals(GroupType.VIP) && order.getMusicGroupId().equals(vipGroupTeacher.getVipGroupId().longValue())) {
                    order.setTeacherName(vipGroupTeacher.getTeacherName());
                    order.setEduTeacherName(vipGroupTeacher.getEduTeacherName());
                    break;
                }
            }
            for (PracticeCourseDto practiceCourseDto : practiceGroupsTeacher) {
                if (order.getGroupType().equals(GroupType.PRACTICE) && order.getMusicGroupId().equals(practiceCourseDto.getId())) {
                    order.setTeacherName(practiceCourseDto.getTeacherName());
                    order.setEduTeacherName(practiceCourseDto.getEduTeacherName());
                    break;
                }
            }
            for (Student studentTeacher : studentTeachers) {
                if (order.getGroupType().equals(GroupType.SPORADIC) && studentTeacher.getUserId().equals(order.getStudentId())) {
                    order.setTeacherName(studentTeacher.getTeacherName());
                    break;
                }
            }

        }

        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {"学员编号", "学员姓名", "指导老师", "教务老师", "订单日期", "交易类型", "实际金额"};
            String[] body = {"studentId", "studentName", "teacherName", "eduTeacherName", "createTime", "orderType.msg", "actualAmount"};

            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, orders);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "销售列表导出")
    @RequestMapping("export/exportSellOrders")
    @PreAuthorize("@pcs.hasPermissions('export/exportSellOrders')")
    public void exportSellOrders(HttpServletResponse response, SellOrderQueryInfo queryInfo) throws IOException {
        queryInfo.setOrganIdList(organizationService.getEmployeeOrgan(queryInfo.getOrganIdList()));
        if (queryInfo.getEndTime() != null) {
            queryInfo.setEndTime(DateUtil.getLastTimeWithDay(queryInfo.getEndTime()));
        }
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<SellOrder> rows = sellOrderService.queryPage(queryInfo).getRows();
        for (SellOrder row : rows) {
            if (StringUtils.isNoneBlank(row.getPaymentChannel())) {
                row.setPaymentChannelStr(PaymentChannelEnum.valueOf(row.getPaymentChannel()).getDesc());
            }
            row.setAccountTypeStr(AccountType.INTERNAL.equals(row.getAccountType()) ? "对内" : "对外");
            switch (row.getReceiveStatus()) {
                case "NO_RECEIVE":
                    row.setReceiveStatusStr("未确认");
                    break;
                case "MANUAL_RECEIVE":
                    row.setReceiveStatusStr("手动确认");
                    break;
                case "AUTO_RECEIVE":
                    row.setReceiveStatusStr("自动确认");
                    break;
            }
            row.setOrderAmount(row.getExpectAmount().add(row.getCouponRemitAmount()));
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{
                    "交易流水号", "订单号", "销售日期", "销售类型", "商品名称", "数量", "订单金额(元)", "应付金额(元)", "余额支付(元)",
                    "现金支付(元)", "优惠金额(元)", "销售成本(元)", "学员姓名", "交易方式", "收款账户", "账户类型", "扣减库存", "所属分部",
                    "所属学校", "教务老师", "确认收货", "状态"}, new String[]{
                    "transNo", "orderNo", "sellTime", "type.desc", "goodsName", "num", "orderAmount", "expectAmount", "balanceAmount",
                    "actualAmount", "couponRemitAmount", "sellCost", "userName", "paymentChannelStr", "merNo", "accountTypeStr", "stockType.msg", "organName",
                    "schoolName", "eduTeacher", "receiveStatusStr", "status.msg"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "欠费学员列表导出")
    @RequestMapping("export/arrearageStudents")
    @PreAuthorize("@pcs.hasPermissions('export/arrearageStudents')")
    public void arrearageStudents(ArrearageStudentsQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            throw new BizException("用户信息获取失败");
        }
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(sysUser.getId(), queryInfo.getOrganId(), sysUser.getIsSuperAdmin()));
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        PageInfo<MusicArrearageStudentDto> result = musicGroupPaymentCalenderDetailService.queryArrearageStudents(queryInfo);
        if (CollectionUtils.isEmpty(result.getRows())) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {"学员编号", "学员姓名", "所属分部", "合作单位", "所在乐团", "乐团主管", "声部", "性别", "家长姓名", "家长联系电话", "欠费金额"};
            String[] body = {"userId", "studentName", "organName", "cooperationName", "musicGroupName", "eduTeacherName",
                    "subjectName", "gender==0?'女':'男'", "parentName", "phone", "noPaymentAmount"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, result.getRows());
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=teacherDefaultSalary-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "退团申请列表导出")
    @RequestMapping("export/musicGroupQuit")
    @PreAuthorize("@pcs.hasPermissions('export/musicGroupQuit')")
    public void musicGroupQuit(MusicGroupQuitQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        PageInfo<MusicGroupQuit> result = musicGroupQuitService.queryPage(queryInfo);
        if (CollectionUtils.isEmpty(result.getRows())) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {"学员编号", "学员姓名", "所属乐团", "申请时间", "退团原因", "状态"};
            String[] body = {"userId", "user.username", "musicGroup.name", "createTime", "userComment", "status.getMsg()"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, result.getRows());
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=teacherDefaultSalary-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "服务指标明细导出")
    @RequestMapping("export/teacherServeInfo")
    @PreAuthorize("@pcs.hasPermissions('export/teacherServeInfo')")
    public void teacherServeInfo(TeacherServeQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            throw new BizException("用户信息获取失败");
        }
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        PageInfo<TeacherServeDto> result = studentExtracurricularExercisesSituationService.queryTeacherServeInfo(queryInfo);
        if (CollectionUtils.isEmpty(result.getRows())) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();

        BigDecimal oneHundred = new BigDecimal(100);
        BigDecimal zero = new BigDecimal("0.00");

        for (TeacherServeDto row : result.getRows()) {
            row.setDateRange(com.ym.mec.util.date.DateUtil.dateToString(row.getMonday(), "yyyy-MM-dd") + '~' + com.ym.mec.util.date.DateUtil.dateToString(row.getSunday(), "yyyy-MM-dd"));
            if (row.getActualExercisesNum() <= 0) {
                row.setSubmitRate(zero.toString() + "%");
            } else {
                BigDecimal submitRate = new BigDecimal(row.getExercisesReplyNum()).divide(new BigDecimal(row.getActualExercisesNum()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(oneHundred);
                row.setSubmitRate(submitRate + "%");
            }
            if (row.getExercisesReplyNum() <= 0) {
                row.setExercisesMessageRate(zero.toString() + "%");
            } else {
                BigDecimal exercisesMessageRate = new BigDecimal(row.getExercisesMessageNum()).divide(new BigDecimal(row.getExercisesReplyNum()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(oneHundred);
                row.setExercisesMessageRate(exercisesMessageRate + "%");
            }
            if (row.getExercisesReplyNum() <= 0) {
                row.setExercisesMessageTimelyRate(zero.toString() + "%");
            } else {
                BigDecimal exercisesMessageTimelyRate = new BigDecimal(row.getExercisesMessageTimelyNum()).divide(new BigDecimal(row.getExercisesReplyNum()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(oneHundred);
                row.setExercisesMessageTimelyRate(exercisesMessageTimelyRate + "%");
            }
        }

        try {
            String[] header = {"分部", "老师编号", "老师姓名", "服务周期", "课后训练(节)", "课后训练(人)", "课外训练(人)", "预计训练布置(人次)", "实际训练布置(人次)", "提交次数", "评价次数", "及时评价次数", "及时评价率", "作业点评率",
                    "训练布置", "训练点评", "训练提交率",
                    "提醒时间", "操作人"};
            String[] body = {"organName", "teacherId", "teacherName", "dateRange", "homeworkNum", "homeworkStuNum", "exerciseNum", "expectExercisesNum", "actualExercisesNum", "exercisesReplyNum", "exercisesMessageNum", "exercisesMessageTimelyNum", "exercisesMessageTimelyRate", "exercisesMessageRate",
                    "expectExercisesNum>actualExercisesNum?'异常':'正常'", "exercisesReplyNum>exercisesMessageNum?'异常':'正常'", "submitRate",
                    "remindDate", "operatorName"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, result.getRows());
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=teacherDefaultSalary-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "首页异常统计导出")
    @RequestMapping("export/exportIndexErrData")
    @PreAuthorize("@pcs.hasPermissions('export/exportIndexErrData')")
    public void exportIndexErrData(String organId, IndexErrorType errorType, HttpServletResponse response) throws IOException {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            throw new BizException("用户信息获取失败");
        }
        organId = organizationService.getEmployeeOrgan(sysUser.getId(), organId, sysUser.getIsSuperAdmin());
        List<IndexErrorDataExportDto> result = indexService.exportIndexErrData(organId, errorType);
        if (CollectionUtils.isEmpty(result)) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();

        try {
            String[] header = {"分部", "基础技能班学员数量异常", "乐团巡查事项异常", "未在班级学员数", "欠费学员数",
                    "申请退团学员数", "预计课酬较低", "课程时间安排异常", "乐团巡查未计划", "乐团巡查任务未提交",
                    "回访任务未完成", "课程考勤异常", "课程异常", "服务指标异常", "异常请假", "会员过期学员数", "总计"};
            String[] body = {"organName", "highClassStudentLessThanThreeNum", "musicPatrolItem", "noClassMusicGroupStudentInfo", "studentNotPayment",
                    "studentApplyForQuitMusicGroup", "teacherExpectSalaryBeLow", "courseTimeError", "inspectionItem", "inspectionItemPlan",
                    "studentVisit", "teacherExceptionAttendance", "teacherNotAClass", "teacherServeError", "studentErrorLeave", "noMemberStudentNum", "total"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, result);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=teacherDefaultSalary-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "运营预警导出")
    @RequestMapping("export/teacherCourseStatistics")
    @PreAuthorize("@pcs.hasPermissions('export/teacherCourseStatistics')")
    public void teacherServeInfo(TeacherCourseStatisticsQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            throw new BizException("用户信息获取失败");
        }
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        PageInfo<TeacherCourseStatistics> result = teacherCourseStatisticsService.queryPageDetail(queryInfo);
        if (CollectionUtils.isEmpty(result.getRows())) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();

        try {
            String[] header = {"月份", "分部", "老师", "专业", "乐团节数", "VIP结束", "网管节数",
                    "预计乐团课酬", "预计VIP课酬", "预计网管课酬", "预计课酬合计", "平均上课时长"};
            String[] body = {"monthStr", "organName", "realName", "subjectListStr", "musicCourseNum", "vipCourseNum", "practiceCourseNum",
                    "expectMusicCourseSalary", "expectVipCourseSalary", "expectPracticeCourseSalary", "expectTotalSalary", "averageClassMinutes"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, result.getRows());
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=teacherDefaultSalary-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "首页历史异常统计导出")
    @RequestMapping("export/exportIndexHistoryErrData")
    @PreAuthorize("@pcs.hasPermissions('export/exportIndexHistoryErrData')")
    public void exportIndexHistoryErrData(IndexErrRecordQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            throw new BizException("用户信息获取失败");
        }
        queryInfo.setOrganIds(organizationService.getEmployeeOrgan(sysUser.getId(), queryInfo.getOrganIds(), sysUser.getIsSuperAdmin()));
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<IndexErrorDataExportDto> result = indexErrDataRecordService.queryRecord(queryInfo).getRows();
        if (CollectionUtils.isEmpty(result)) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();

        try {
            String[] header = {"日期", "分部", "乐团主管", "乐团巡查事项异常", "剩余乐团巡查事项异常", "乐团巡查任务未提交", "剩余乐团巡查任务未提交",
                    "课程考勤异常", "剩余课程考勤异常", "课程异常", "剩余课程异常"};
            String[] body = {"generateTime", "organName", "dealUserName", "musicPatrolItem", "musicPatrolItemSurplus", "inspectionItemPlan", "inspectionItemPlanSurplus",
                    "teacherExceptionAttendance", "teacherExceptionAttendanceSurplus", "teacherNotAClass", "teacherNotAClassSurplus"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, result);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=teacherDefaultSalary-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @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("用户信息获取失败");
        }
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<Teacher> rows = teacherService.queryPageDetail(queryInfo).getRows();
        if (CollectionUtils.isEmpty(rows)) {
            throw new BizException("没有可导出的记录");
        }
        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");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "人力资源导出")
    @RequestMapping("export/employeeInfo")
    @PreAuthorize("@pcs.hasPermissions('export/employeeInfo')")
    public void exportEmployeeInfo(EmployeeInfoQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<EmployeeInfo> rows = employeeInfoService.queryPage(queryInfo).getRows();
        if (CollectionUtils.isEmpty(rows)) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {"编号", "姓名", "手机号", "微信",
                    "声部", "所在城市", "工作意向", "信息来源", "下次沟通时间", "入职时间",
                    "职位", "分部", "人员状态", "证件号码", "年龄", "性别",
                    "银行卡", "开户行", "紧急联系人", "紧急联系人关系", "紧急联系人电话", "最后一次操作时间",
                    "HRBP", "离职时间"
            };
            String[] body = {"id", "realName", "mobileNo", "wechatNo", "subjectName", "liveCity", "intentionCity",
                    "sourceFrom", "nextVisitDateStr", "entryDateStr", "position.msg", "organName", "status.desc",
                    "idCard", "age", "gender?'男':'女'", "bankCardNo", "bankAddress", "emergencyContactName",
                    "emergencyContactRelation", "emergencyContactPhone", "updateTime", "hrbpName", "resignationDateStr"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=employeeInfo-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "分部下教师关联的会员数据导出")
    @RequestMapping("export/organTeacherMemberStudentData")
    @PreAuthorize("@pcs.hasPermissions('export/organTeacherMemberStudentData')")
    public void exportEmployeeInfo(TeacherServeQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<TeacherStudentDataDto> rows = teacherService.queryMemberStudentData(queryInfo).getRows();
        if (CollectionUtils.isEmpty(rows)) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {"老师编号", "老师姓名", "学员总数", "使用人数", "使用人数比", "付费学员数量", "会员占比"};
            String[] body = {"teacherId", "teacherName", "totalStudentNum", "cloudStudyUseStudentNum", "cloudStudyUseStudentDuty+\"%\"",
                    "vipStudentNum", "vipStudentDuty+\"%\""};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=employeeInfo-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "分部云教练学员数据预览导出")
    @RequestMapping("export/organStudentOverView")
    @PreAuthorize("@pcs.hasPermissions('export/organStudentOverView')")
    public void organStudentOverView(OrganCloudStudyStudentDataQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            throw new BizException("用户信息获取失败");
        }
        String organIds = organizationService.getEmployeeOrgan(sysUser.getId(), "", sysUser.getIsSuperAdmin());
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        if (StringUtils.isEmpty(organIds)) {
            throw new BizException("没有可导出的记录");
        }
        List<Integer> collect = Arrays.stream(organIds.split(",")).mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());
        List<Integer> ids = collect.stream().filter(id -> !OrganizationService.EXCLUDE_ORGAN_IDS.contains(id)).collect(Collectors.toList());
        if (ids == null || ids.size() == 0) {
            throw new BizException("没有可导出的记录");
        }
        List<EduOrganStudentDataDto> rows = studentService.queryOrganStudentOverView(ids, queryInfo).getRows();
        if (CollectionUtils.isEmpty(rows)) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {"排名", "分部", "学员总数", "目标人数", "活跃人数", "使用人数", "新增使用人数", "使用比例", "付费会员数", "付费会员占比"};
            String[] body = {"index", "organName", "totalStudentNum", "targetNum", "cloudStudyLivelyStudentNum", "cloudStudyUseStudentNum", "newCloudStudyStudentNum",
                    "cloudStudyUseStudentDuty+\"%\"", "vipStudentNum", "vipStudentDuty+\"%\""};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=employeeInfo-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "分部云教练学员数据详情导出")
    @RequestMapping("export/cloudStudyStudentOverView")
    @PreAuthorize("@pcs.hasPermissions('export/cloudStudyStudentOverView')")
    public void cloudStudyStudentOverView(OrganCloudStudyStudentDataQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            throw new BizException("用户信息获取失败");
        }
        String organIds = organizationService.getEmployeeOrgan(sysUser.getId(), "", sysUser.getIsSuperAdmin());
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        if (StringUtils.isEmpty(organIds)) {
            throw new BizException("没有可导出的记录");
        }
        List<Integer> collect = Arrays.stream(organIds.split(",")).mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());
        List<Integer> ids = collect.stream().filter(id -> !OrganizationService.EXCLUDE_ORGAN_IDS.contains(id)).collect(Collectors.toList());
        if (ids == null || ids.size() == 0) {
            throw new BizException("没有可导出的记录");
        }
        List<EduOrganStudentDataDto> rows = indexService.organStudentOverView(ids, queryInfo).getRows();
        if (CollectionUtils.isEmpty(rows)) {
            throw new BizException("没有可导出的记录");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {"排名", "分部", "学员总数", "活跃人数", "活跃人数比", "当日使用人数", "当日新增使用人数", "使用人数占比", "付费会员数量", "付费会员占比", "新增付费会员"};
            String[] body = {"index", "organName", "totalStudentNum", "cloudStudyLivelyStudentNum", "cloudStudyLivelyStudentDuty+\"%\"",
                    "cloudStudyUseStudentNum", "newCloudStudyStudentNum", "cloudStudyUseStudentDuty+\"%\"", "vipStudentNum", "vipStudentDuty+\"%\"", "newMemberStudentNum"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=employeeInfo-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "分部云教练学员训练数据导出")
    @RequestMapping("export/cloudStudyStudentTrainData")
    @PreAuthorize("@pcs.hasPermissions('export/cloudStudyStudentTrainData')")
    public void cloudStudyStudentTrainData(StudentQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            throw new BizException("用户信息获取失败");
        }
        queryInfo.setPage(1);
        queryInfo.setRows(49999);

        List<EduOrganStudentListExportDto> rows = ((PageInfo<EduOrganStudentListExportDto>) studentService.exportOrganStudentData(queryInfo).getDetail()).getRows();
        if (CollectionUtils.isEmpty(rows)) {
            throw new BizException("没有可导出的记录");
        }
        for (EduOrganStudentListExportDto row : rows) {
            row.setCloudStudyUseTime(Math.round(row.getCloudStudyUseTime()));
            row.setCloudStudyUseAvgTime(Math.round(row.getCloudStudyUseAvgTime()));
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {"学员编号", "学员", "年级", "班级", "手机号", "是否新用户", "是否激活", "训练总时长", "连续训练天数", "乐团", "乐团主管", "所属学校", "指导老师", "声部", "是否有小课",
                    "训练次数", "训练天数", "训练平均时长", "会员有效期", "是否服务", "是否运营", "是否云教练活动目标学员", "活动消费金额", "关心包", "加油包", "未上课数", "vip课剩余课时", "网管课剩余课时"};
            String[] body = {"studentId", "studentName", "currentGradeNum", "currentClass", "phone", "newUser?\"是\":\"否\"", "enable?\"是\":\"否\"",
                    "cloudStudyUseTime+\"分钟\"", "cloudStudyRunningDays+\"天\"", "musicGroupNames", "educationName", "schoolNames",
                    "teacherName", "subjectName", "hasVipGroup>0?\"是\":\"否\"", "cloudStudyUseNum+\"次\"", "cloudStudyUseDays+\"天\"",
                    "cloudStudyUseAvgTime+\"分钟\"", "membershipEndTime", "serviceTag>0?\"是\":\"否\"", "operatingTag>0?\"是\":\"否\"", "countFlag == null?'否':countFlag == 1?'是':'否'", "activeAmount",
                    "carePackage>0?carePackage>1?\"已使用\":\"可用\":\"不可用\"", "comeOnPackage>0?comeOnPackage>1?\"已使用\":\"可用\":\"不可用\"",
                    "notStartCourseNum", "notStartVipCourseNum", "notStartPracticeCourseNum"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=employeeInfo-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "分部云教练活动统计数据导出")
    @RequestMapping("export/countCloudTeacherActive")
    @PreAuthorize("@pcs.hasPermissions('export/countCloudTeacherActive')")
    public void countCloudTeacherActive(CloudTeacherActiveQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            throw new BizException("用户信息获取失败");
        }
        String organIds = organizationService.getEmployeeOrgan(sysUser.getId(), "", sysUser.getIsSuperAdmin());
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        if (StringUtils.isEmpty(organIds)) {
            throw new BizException("没有可导出的记录");
        }
        List<Integer> collect = Arrays.stream(organIds.split(",")).mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());
        List<Integer> ids = collect.stream().filter(id -> !OrganizationService.EXCLUDE_ORGAN_IDS.contains(id)).collect(Collectors.toList());
        if (ids == null || ids.size() == 0) {
            throw new BizException("没有可导出的记录");
        }
        Object object = studentService.countCloudTeacherActive(ids, queryInfo).get("resultList");
        if (object == null) {
            throw new BizException("没有可导出的记录");
        }
        List<CloudTeacherActiveTargetDto> rows = (List<CloudTeacherActiveTargetDto>) object;

        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {"分部", "购买人数", "购买金额", "目标金额", "人均购买金额", "目标人数", "目标达成率"};
            String[] body = {"organName", "buyNum", "buyAmount", "targetAmount", "avgBuyAmount",
                    "targetNum", "targetFinishScale"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=employeeInfo-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "云教练活动统计详情")
    @RequestMapping("export/countCloudTeacherActiveDetail")
    @PreAuthorize("@pcs.hasPermissions('export/countCloudTeacherActiveDetail')")
    public void countCloudTeacherActiveDetail(CloudTeacherActiveQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            throw new BizException("用户信息获取失败");
        }
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<CloudTeacherActiveTargetDetailDto> rows = studentService.countCloudTeacherActiveDetail(queryInfo).getRows();
        if (CollectionUtils.isEmpty(rows)) {
            throw new BizException("没有可导出的记录");
        }
        //获取分部年级列表
        Map<Integer, String> gradeList = organizationService.getGradeList(Integer.parseInt(queryInfo.getOrganIds()));
        for (CloudTeacherActiveTargetDetailDto row : rows) {
            if (StringUtils.isNotEmpty(row.getCurrentGradeNum())) {
                String grade = gradeList.get(Integer.parseInt(row.getCurrentGradeNum()));
                if (StringUtils.isNotEmpty(grade)) {
                    row.setCurrentGradeNum(grade);
                }
            }
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {"学员编号", "学员", "合作单位", "乐团", "乐团模式", "声部", "年级", "指导老师", "购买套餐", "购买金额"};
            String[] body = {"userId", "username", "cooperationName", "musicGroupName", "chargeType",
                    "subjectName", "currentGradeNum", "teacherName", "remark", "amount"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=employeeInfo-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "启蒙课问卷导出")
    @RequestMapping("export/musicEnlightenmentQuestionnaires")
    @PreAuthorize("@pcs.hasPermissions('export/musicEnlightenmentQuestionnaires')")
    public void musicEnlightenmentQuestionnaires(MusicEnlightenmentQuestionnaireQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        PageInfo<MusicEnlightenmentQuestionnaire> practiceGroupReviews = musicEnlightenmentQuestionnaireService.queryPage(queryInfo);
        if (practiceGroupReviews.getTotal() <= 0) {
            return;
        }
        OutputStream outputStream = response.getOutputStream();
        try {
//            for (MusicEnlightenmentQuestionnaire row : practiceGroupReviews.getRows()) {
//                if(Objects.isNull(row.getSubjectName())){
//                    row.setSubjectName("无");
//                }
//            }
            String[] header = {"学员姓名", "联系电话", "年级", "班级", "老师推荐专业", "是否在学习某件乐器", "目前所学乐器", "报名参加管乐团家长会了解相关情况", "备注"};
            String[] body = {"userName", "phone", "currentGrade", "currentClass", "subjectName == null?'无':subjectName", "musicalInstrumentsLearning?'是':'否'",
                    "musicalInstrumentsName", "joinParentMeeting?'是':'否'", "remark"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, practiceGroupReviews.getRows());
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "服务指标导出")
    @RequestMapping("export/exercisesSituation")
    @PreAuthorize("@pcs.hasPermissions('export/exercisesSituation')")
    public void exportExercisesSituation(TeacherServeQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        List<TeacherServeDto> list = studentExtracurricularExercisesSituationService.queryTeacherPerformanceIndicator(queryInfo);
        if (list.size() <= 0) {
            return;
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {"分部", "老师编号", "老师姓名", "预计安排(人次)", "实际安排(人次)", "布置率(%)", "提交人数", "点评次数", "点评率(%)", "及时点评次数", "及时点评率(%)"};
            String[] body = {"organName", "teacherId", "teacherName", "expectExercisesNum", "actualExercisesNum",
                    "100 * actualExercisesNum / expectExercisesNum", "exercisesReplyNum", "exercisesMessageNum",
                    "100 * exercisesMessageNum / exercisesReplyNum", "exercisesMessageTimelyNum", "100 * exercisesMessageTimelyNum / exercisesReplyNum"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, list);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=teacherPerformanceIndicator-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @Resource
    private TempBuyFreeLiveTheoryCourseDao tempBuyFreeLiveTheoryCourseDao;

    @ApiOperation(value = "直播临时活动--学员购买导出")
    @ApiImplicitParams({
            @ApiImplicitParam(
                    name = "liveGoodsId",
                    value = "直播商品id",
                    paramType = "query", dataType = "int", required = true
            ),
            @ApiImplicitParam(
                    name = "liveId",
                    value = "直播id",
                    paramType = "query", dataType = "String"
            )
    })
    @GetMapping("export/exportBuyFreeLiveTheoryCourseList")
    @PreAuthorize("@pcs.hasPermissions('export/exportBuyFreeLiveTheoryCourseList')")
    public void exportBuyFreeLiveTheoryCourseList(TempBuyFreeLiveTheoryCourse tempBuyFreeLiveTheoryCourse, HttpServletResponse response) throws IOException {
        List<TempBuyFreeLiveTheoryCourse> list = tempBuyFreeLiveTheoryCourseDao.list(tempBuyFreeLiveTheoryCourse);
        if (CollectionUtils.isEmpty(list)) {
            throw new BizException("没有可导出的记录");
        }

        list.stream().forEach(o -> {
            String recommendLevel = o.getRecommendLevel();
            if (StringUtils.isEmpty(recommendLevel)) {
                return;
            }
            LevelEnum levelEnum = LevelEnum.valueOf(recommendLevel);
            if (null != levelEnum) {
                o.setRecommendLevel(levelEnum.getMsg());
            }
        });

        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {
                    "ID", "用户ID", "购买学生姓名", "老师推荐级别（一级/二级/三级）"};
            String[] body = {"id", "userId", "studentName", "recommendLevel"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, list);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=BuyFreeLiveTheoryCourse-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @Autowired
    private SysMusicScoreService sysMusicScoreService;

    @ApiOperation(value = "教学伴奏--列表导出")
    @GetMapping("export/exportMusicScoreList")
    @PreAuthorize("@pcs.hasPermissions('export/exportMusicScoreList')")
    public void exportMusicScoreList(SysExamSongQueryInfo queryInfo, HttpServletResponse response) throws IOException {
        List<SysMusicScore> list = sysMusicScoreService.queryMusicScoreAll(queryInfo);
        if (CollectionUtils.isEmpty(list)) {
            throw new BizException("没有可导出的记录");
        }

        list.stream().forEach(o -> {
            ExamSongTypeEnum type = o.getType();
            if (null != type) {
                o.setTypeName(type.getMsg());
            }
            String rankIds = o.getRankIds();
            if (StringUtils.isNotEmpty(rankIds) && rankIds.trim().equals("1")) {
                o.setRankIds("收费");
            } else {
                o.setRankIds("免费");
            }
            if (null != o.getIsOpenMetronome() && o.getIsOpenMetronome()) {
                o.setOpenMetronomeName("播放");
            } else {
                o.setOpenMetronomeName("不播放");
            }
            String accompaniment = "含节拍器:" + (StringUtils.isEmpty(o.getAccompanimentMetronomeUrl()) ? "否" : "是") + " 不含节拍器:" +
                    (StringUtils.isEmpty(o.getAccompanimentUrl()) ? "否" : "是");
            o.setMuseScoreMemo(accompaniment);
            o.setShowName(o.getShowFlag() == 1 ? "启用" : "停用");
        });

        OutputStream outputStream = response.getOutputStream();
        try {
            String[] header = {
                    "编号", "名称", "所属声部", "类型", "分类", "是否收费", "节拍器", "是否上传伴奏", "伴奏状态", "上传人", "上传时间"};
            String[] body = {"id", "name", "subjectName", "typeName", "categoriesName", "rankIds", "openMetronomeName", "museScoreMemo", "showName", "createUserName", "createTime"};
            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, list);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment;filename=BuyFreeLiveTheoryCourse-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }

    @ApiOperation(value = "直播间人员列表导出")
    @PostMapping("export/liveBroadcastRoomMember")
    @PreAuthorize("@pcs.hasPermissions('export/liveBroadcastRoomMember')")
    public void exportLiveBroadcastRoomMember(HttpServletResponse response, LiveBroadcastRoomMemberQueryInfo queryInfo) throws IOException {
        queryInfo.setPage(1);
        queryInfo.setRows(49999);
        Map<String, Object> params = new HashMap<String, Object>();
        MapUtil.populateMap(params, queryInfo);
        List<ImLiveBroadcastRoomMemberVo> rows = imLiveBroadcastRoomMemberService.queryRoomMember(params).getRows();
        if (rows.size() < 1) {
            throw new BizException("没有可导出数据");
        }
        OutputStream outputStream = response.getOutputStream();
        try {
            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"直播间编号", "直播间标题", "主讲人", "学生编号", "学生姓名",
                    "手机号", "声部", "所在分部", "所在乐团", "加入时间", "观看时长（分钟）"}, new String[]{
                    "roomUid", "roomTitle", "speakerName", "studentId", "studentName", "phone", "subName",
                    "organName", "musicGroupName", "joinTime"
                    , "totalViewTime"}, rows);
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attac:wq" +
                    "hment;filename=liveroomMember-" + DateUtil.getDate(new Date()) + ".xls");

            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();
                }
            }
        }
    }
}
