|
@@ -16,9 +16,12 @@ import com.ym.mec.biz.service.TempDirectorTrainingCampService;
|
|
|
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.util.date.DateUtil;
|
|
|
+import com.ym.mec.util.excel.POIUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.joda.time.DateTime;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -26,8 +29,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.text.MessageFormat;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Api(tags = "乐队指导训练营活动")
|
|
@@ -58,9 +65,9 @@ public class TempDirectorTrainingCampDetailController extends BaseController {
|
|
|
|
|
|
@ApiOperation(value = "导出")
|
|
|
@PostMapping("/export")
|
|
|
- public HttpResponseResult<TempDirectorTrainingCampDetailWrapper.DownloadInfo> export(@RequestBody TempDirectorTrainingCampDetailWrapper.TempDirectorTrainingCampDetailQuery queryInfo){
|
|
|
+ public void export(HttpServletResponse response, @RequestBody TempDirectorTrainingCampDetailWrapper.TempDirectorTrainingCampDetailQuery queryInfo) throws IOException {
|
|
|
if (queryInfo.getTempDirectorTrainingCampId()==null) {
|
|
|
- return failed("训练营编号不能为空");
|
|
|
+ throw new BizException("训练营编号不能为空");
|
|
|
}
|
|
|
TempDirectorTrainingCamp trainingCamp = tempDirectorTrainingCampService.lambdaQuery()
|
|
|
.eq(TempDirectorTrainingCamp::getId, queryInfo.getTempDirectorTrainingCampId())
|
|
@@ -72,10 +79,33 @@ public class TempDirectorTrainingCampDetailController extends BaseController {
|
|
|
IPage<TempDirectorTrainingCampDetailWrapper.TempDirectorTrainingCampDetail> tempDirectorTrainingCampIPage = tempDirectorTrainingCampDetailService.queryPage(new Page<>(1,-1), queryInfo);
|
|
|
List<TempDirectorTrainingCampDetailWrapper.TempDirectorTrainingCampDetail> records = tempDirectorTrainingCampIPage.getRecords();
|
|
|
if (records.size()==0) {
|
|
|
- return failed("没有可导出数据");
|
|
|
+ throw new BizException("没有可导出数据");
|
|
|
+ }
|
|
|
+ OutputStream outputStream = response.getOutputStream();
|
|
|
+ try {
|
|
|
+ HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"姓名", "联系电话", "身份证号", "所在城市", "缴费状态", "缴费金额", "缴费时间", "目前从事职业"
|
|
|
+ , "第一主专业", "之前乐队指导学习基础", "目标效果", "需求或建议"}, new String[]{
|
|
|
+ "username", "mobile", "cardNo", "cityInfo", "paymentStatusName", "paymentAmount", "paymentDateStr",
|
|
|
+ "job", "subjectName", "study"
|
|
|
+ , "studyTarget", "suggestion"}, records);
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- TempDirectorTrainingCampDetailWrapper.DownloadInfo downloadInfo = generateExportExcelFile(records, TempDirectorTrainingCampDetailWrapper.TempDirectorTrainingCampDetail.class, trainingCamp.getName()+"导出", trainingCamp.getName()+"导出");
|
|
|
- return succeed(downloadInfo);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "统计")
|