1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| @ApiOperation(value = "生成拾物报表", notes = "生成拾物报表") @GetMapping("/create/pick/reportForm") public String createPickReportForm( HttpServletResponse response, @ApiParam(name = "type", value = "统计类型 1-年度报表 2-月度报表 3-季度报表", required = true) @PathParam("type") Integer type, @ApiParam(name = "reportFormType", value = "报表类型 1-领取比例 2-滞留时间", required = true) @PathParam("reportFormType") Integer reportFormType, @ApiParam(name = "year", value = "年份,如:2019") @PathParam("year") String year, @ApiParam(name = "month", value = "月份,如:2019-01") @PathParam("month") String month, @ApiParam(name = "quarter", value = "季度 1-春季(01,02,03) 2-夏季(04,05,06) 3-秋季(07,08,09) 4-冬季(10,11,12)") @PathParam("quarter") Integer quarter) { log.info("ReportFormRest.createPickReportForm()---生成拾物报表"); try { String reportFormName = reportFormType==1?"拾物领取比例":"拾物滞留时间"; String fileName = "拾物领取报表.xls"; ReportFormExportParamVO param = new ReportFormExportParamVO(); param.setType(type); if(type == 1) { param.setYear(year); fileName = year+"年"+reportFormName+"年度报表"+".xls"; }else if(type == 2) { param.setMonth(month); fileName = month.replace("-", "年")+"月"+reportFormName+"月度报表"+".xls"; }else if(type == 3) { String[] strs = null; String quarterName = null; QuarterEnum[] quarterEnums = BusEnums.QuarterEnum.values(); for(QuarterEnum quarterEnum : quarterEnums) { if(quarterEnum.getCode() == quarter) { strs = quarterEnum.getQuarter(); quarterName = quarterEnum.getValue(); param.setQuarterName(quarterName); break; } } List<String> quarters = new ArrayList<>(); for(String str : strs) { quarters.add(str); } param.setYear(year); param.setQuarters(quarters); fileName = year+"年"+quarterName+reportFormName+"季度报表"+".xls"; } response.setContentType("application/force-download"); response.addHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(fileName, "UTF-8")); OutputStream outputStream = new BufferedOutputStream(response.getOutputStream()); if(reportFormType != null && reportFormType == 1) { reportFormService.exportPickReportForm(param, outputStream, false); }else if(reportFormType != null && reportFormType == 2) { reportFormService.exportRetentionTimePickReportForm(param, outputStream, false); } outputStream.flush(); outputStream.close(); } catch (Exception e) { log.error("生成拾物报表出错。error={}", e); return "{}"; } return "{}"; }
|