|  | @@ -1,17 +1,23 @@
 | 
	
		
			
				|  |  |  package com.ym.mec.web.controller;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.MusicGroupDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dto.StudentPreRegistrationDto;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.*;
 | 
	
		
			
				|  |  | +import com.ym.mec.common.page.PageInfo;
 | 
	
		
			
				|  |  | +import com.ym.mec.util.date.DateUtil;
 | 
	
		
			
				|  |  | +import com.ym.mec.util.excel.POIUtil;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiImplicitParam;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiImplicitParams;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.io.IOException;
 | 
	
		
			
				|  |  | +import java.io.OutputStream;
 | 
	
		
			
				|  |  |  import java.util.Date;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  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.web.bind.annotation.GetMapping;
 | 
	
	
		
			
				|  | @@ -34,6 +40,8 @@ import com.ym.mec.biz.service.StudentRegistrationService;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.controller.BaseController;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.HttpResponseResult;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  @RequestMapping("studentRegistration")
 | 
	
		
			
				|  |  |  @Api(tags = "学生报名信息服务")
 | 
	
		
			
				|  |  |  @RestController
 | 
	
	
		
			
				|  | @@ -230,4 +238,52 @@ public class StudentRegistrationController extends BaseController {
 | 
	
		
			
				|  |  |          return succeed(studentRegistrationService.getMusicGroupStuReBack(musicGroupId));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @ApiOperation(value = "乐团预报名列表分页查询")
 | 
	
		
			
				|  |  | +    @GetMapping("/preRegisterExport")
 | 
	
		
			
				|  |  | +    @PreAuthorize("@pcs.hasPermissions('studentRegistration/preRegisterExport')")
 | 
	
		
			
				|  |  | +    public void queryPreApplyList(StudentPreRegistrationQueryInfo queryInfo, HttpServletResponse response) throws Exception {
 | 
	
		
			
				|  |  | +        queryInfo.setPage(1);
 | 
	
		
			
				|  |  | +        queryInfo.setRows(49999);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        PageInfo<StudentPreRegistrationDto> studentPreRegistration = studentPreRegistrationService.queryListForPage(queryInfo);
 | 
	
		
			
				|  |  | +        if (studentPreRegistration.getTotal() <= 0) {
 | 
	
		
			
				|  |  | +            response.setStatus(200);
 | 
	
		
			
				|  |  | +            response.setContentType("Content-Type: application/json;charset=UTF-8");
 | 
	
		
			
				|  |  | +            response.getOutputStream().write("{\"data\": null, \"code\": 500, \"status\": false, \"msg\": \"没有可导出的记录\"}".getBytes());
 | 
	
		
			
				|  |  | +            response.flushBuffer();
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for (StudentPreRegistrationDto row : studentPreRegistration.getRows()) {
 | 
	
		
			
				|  |  | +            if (row.getKitPurchaseMethod().equals("OWNED")) {
 | 
	
		
			
				|  |  | +                row.setKitPurchaseMethod("自行准备");
 | 
	
		
			
				|  |  | +            } else if (row.getKitPurchaseMethod().equals("GROUP")) {
 | 
	
		
			
				|  |  | +                row.setKitPurchaseMethod("团购");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            row.setCurrentGrade(row.getCurrentGrade() + row.getCurrentClass());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        OutputStream outputStream = response.getOutputStream();
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            String[] header = {"学员编号", "学员姓名", "性别", "联系电话", "年级班级", "选报声部1", "选报声部2", "是否服从调剂", "乐器准备方式"};
 | 
	
		
			
				|  |  | +            String[] body = {"userId", "userName", "gender ? '男' : '女'", "phone", "currentGrade", "subjectFirstName", "subjectSecondName", "isAllowAdjust ? '是' : '否'", "kitPurchaseMethod"};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, studentPreRegistration.getRows());
 | 
	
		
			
				|  |  | +            response.setContentType("application/octet-stream");
 | 
	
		
			
				|  |  | +            response.setHeader("Content-Disposition", "attachment;filename=pre-register-" + DateUtil.getDate(new Date()) + ".xls");
 | 
	
		
			
				|  |  | +            response.flushBuffer();
 | 
	
		
			
				|  |  | +            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();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |