|  | @@ -0,0 +1,137 @@
 | 
	
		
			
				|  |  | +package com.ym.mec.web.controller;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.MusicGroupDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dto.StudentApplyDetailDto;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dto.TeacherSalaryDto;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.Goods;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.MusicGroup;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.page.CourseScheduleTeacherSalaryQueryInfo;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.page.StudentRegistrationQueryInfo;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.CourseScheduleTeacherSalaryService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.MusicGroupService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.StudentRegistrationService;
 | 
	
		
			
				|  |  | +import com.ym.mec.common.controller.BaseController;
 | 
	
		
			
				|  |  | +import com.ym.mec.common.exception.BizException;
 | 
	
		
			
				|  |  | +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.poi.hssf.usermodel.HSSFWorkbook;
 | 
	
		
			
				|  |  | +import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.http.MediaType;
 | 
	
		
			
				|  |  | +import org.springframework.security.access.prepost.PreAuthorize;
 | 
	
		
			
				|  |  | +import org.springframework.stereotype.Controller;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.GetMapping;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.PostMapping;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.RequestMapping;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  | +import java.io.IOException;
 | 
	
		
			
				|  |  | +import java.io.OutputStream;
 | 
	
		
			
				|  |  | +import java.util.Date;
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@RequestMapping
 | 
	
		
			
				|  |  | +@Api(tags = "数据导出服务")
 | 
	
		
			
				|  |  | +@Controller
 | 
	
		
			
				|  |  | +public class ExportController extends BaseController {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private StudentRegistrationService studentRegistrationService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @ApiOperation(value = "导出乐器采购清单")
 | 
	
		
			
				|  |  | +    @GetMapping("order/musicalListExport")
 | 
	
		
			
				|  |  | +    @PreAuthorize("@pcs.hasPermissions('order/musicalListExport')")
 | 
	
		
			
				|  |  | +    @ApiImplicitParams({@ApiImplicitParam(name = "musicGroupId", value = "乐团id", required = true, dataType = "String")})
 | 
	
		
			
				|  |  | +    public void musicalListExport(HttpServletResponse response,String musicGroupId){
 | 
	
		
			
				|  |  | +        List<Goods> musicalList = studentPaymentOrderDetailService.getMusicalList(musicGroupId);
 | 
	
		
			
				|  |  | +        if(musicalList == null || musicalList.size() < 1){
 | 
	
		
			
				|  |  | +            throw new BizException("数据为空");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        OutputStream outputStream = null;
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            HSSFWorkbook workbook = POIUtil.exportExcel(new String[] { "分部","乐团", "声部", "商品名称", "数量"}, new String[] {
 | 
	
		
			
				|  |  | +                    "brief","memo", "currentGrade", "currentClass", "gender", "isAllowAdjust.msg"}, musicalList);
 | 
	
		
			
				|  |  | +            response.setContentType("application/msexcel");
 | 
	
		
			
				|  |  | +            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) {
 | 
	
		
			
				|  |  | +        List<StudentApplyDetailDto> studentApplyDetail = studentRegistrationService.queryStudentDetailPage(queryInfo).getRows();
 | 
	
		
			
				|  |  | +        if(studentApplyDetail == null || studentApplyDetail.size() < 1){
 | 
	
		
			
				|  |  | +            throw new BizException("数据为空");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        OutputStream outputStream = null;
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            HSSFWorkbook workbook = POIUtil.exportExcel(new String[] { "学生姓名","家长姓名", "年级", "班级", "性别", "服从调剂","报名专业", "实际专业","联系电话", "学员缴费状态", "乐器购买方式"}, new String[] {
 | 
	
		
			
				|  |  | +                    "studentName","parentsName", "currentGrade", "currentClass", "gender", "isAllowAdjust.msg", "subjectName", "actualSubjectName", "parentsPhone","paymentStatus","kitGroupPurchaseTypeEnum.msg"}, studentApplyDetail);
 | 
	
		
			
				|  |  | +            response.setContentType("application/msexcel");
 | 
	
		
			
				|  |  | +            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("courseScheduleTeacherSalary/export")
 | 
	
		
			
				|  |  | +    @PreAuthorize("@pcs.hasPermissions('courseScheduleTeacherSalary/export')")
 | 
	
		
			
				|  |  | +    public void export(CourseScheduleTeacherSalaryQueryInfo queryInfo, HttpServletResponse response) {
 | 
	
		
			
				|  |  | +        List<TeacherSalaryDto> teacherSalaries = courseScheduleTeacherSalaryService.querySalaries(queryInfo).getRows();
 | 
	
		
			
				|  |  | +        OutputStream ouputStream = null;
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            HSSFWorkbook workbook = POIUtil.exportExcel(new String[] { "用户编号","用户名", "手机号", "课程类型", "实际薪水", "补助", "结算时间", "教师角色"}, new String[] {
 | 
	
		
			
				|  |  | +                    "userId","username", "phone", "type.msg", "name", "actualSalary", "subsidy", "settlementTime", "teacherRole.msg"}, teacherSalaries);
 | 
	
		
			
				|  |  | +            response.setContentType("application/msexcel");
 | 
	
		
			
				|  |  | +            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();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +}
 |