|  |  | 
 |  |  |  | 
 |  |  | import com.doumee.core.constants.ResponseStatus; | 
 |  |  | import com.doumee.core.exception.BusinessException; | 
 |  |  | import com.doumee.core.utils.Constants; | 
 |  |  | import com.doumee.dao.business.model.ApplyDetail; | 
 |  |  | import com.doumee.dao.business.model.InsuranceApply; | 
 |  |  | import lombok.AllArgsConstructor; | 
 |  |  | import lombok.Data; | 
 |  |  | import org.apache.commons.lang3.StringUtils; | 
 |  |  | 
 |  |  |         return stringValue; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void exportApplyDetail(InsuranceApply model, HttpServletResponse response) { | 
 |  |  |         try { | 
 |  |  |             String encodeFileName = URLEncoder.encode("投保详情单_"+model.getCompanyName()+"_"+model.getSolutionsName(), Charset.forName("UTF-8").toString()) + ".xlsx"; | 
 |  |  |             response.setHeader("Content-Disposition","attachment;filename=" + encodeFileName); | 
 |  |  |             response.setContentType("application/octet-stream"); | 
 |  |  |             response.setHeader("eva-opera-type", "download"); | 
 |  |  |             response.setHeader("eva-download-filename", encodeFileName); | 
 |  |  |             this.exportApplyDetailDo(model,"投保申请表", response.getOutputStream()); | 
 |  |  |         } catch (IOException e) { | 
 |  |  |             throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 导出到指定输出流 | 
 |  |  |      * @param data 数据 | 
 |  |  |      * @param sheetName Sheet名称 | 
 |  |  |      * @param os 输出流 | 
 |  |  |      */ | 
 |  |  |     public void exportApplyDetailDo (InsuranceApply data, String sheetName, OutputStream os) { | 
 |  |  |         SXSSFWorkbook sxssfWorkbook; | 
 |  |  |         try { | 
 |  |  |             sxssfWorkbook = new SXSSFWorkbook(); | 
 |  |  |             Sheet sheet = sxssfWorkbook.createSheet(sheetName); | 
 |  |  |             sheet.createFreezePane(0, 1); | 
 |  |  |             sheet.addMergedRegion(new CellRangeAddress(0   ,0,0,6)); | 
 |  |  |             Row title = sheet.createRow(0); | 
 |  |  |             title.setHeight((short) 1000); | 
 |  |  |             Cell c = title.createCell(0); | 
 |  |  |             c.setCellValue(sheetName); | 
 |  |  |             configFirstCell(sxssfWorkbook,c); | 
 |  |  |             Row header1 = sheet.createRow(1); | 
 |  |  |             header1.createCell(0).setCellValue("投保企业"); | 
 |  |  |             header1.createCell(1).setCellValue("保险方案"); | 
 |  |  |             header1.createCell(2).setCellValue("保险生效起期"); | 
 |  |  |             header1.createCell(3).setCellValue("保险生效止期"); | 
 |  |  |             header1.createCell(4).setCellValue("投保人数"); | 
 |  |  |             header1.createCell(5).setCellValue("总费用(元)"); | 
 |  |  |             Row header2 = sheet.createRow(2); | 
 |  |  |             header2.createCell(0).setCellValue(data.getCompanyName()); | 
 |  |  |             header2.createCell(1).setCellValue(data.getSolutionsName()); | 
 |  |  |             header2.createCell(2).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getStartTime())); | 
 |  |  |             header2.createCell(3).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getEndTime())); | 
 |  |  |             header2.createCell(4).setCellValue(data.getInsureNum()); | 
 |  |  |             header2.createCell(5).setCellValue(Constants.formatBigdecimal2Float(data.getFee()).toString()); | 
 |  |  |             //空白行 | 
 |  |  |             Row header3 = sheet.createRow(3); | 
 |  |  |             sheet.addMergedRegion(new CellRangeAddress(3  ,3,0,6)); | 
 |  |  |  | 
 |  |  |             Row header4 = sheet.createRow(4); | 
 |  |  |             header4.createCell(0).setCellValue("序号"); | 
 |  |  |             header4.createCell(1).setCellValue("员工姓名"); | 
 |  |  |             header4.createCell(2).setCellValue("性别"); | 
 |  |  |             header4.createCell(3).setCellValue("身份证号"); | 
 |  |  |             header4.createCell(4).setCellValue("派遣单位"); | 
 |  |  |             header4.createCell(5).setCellValue("所属工种"); | 
 |  |  |             if(data.getApplyDetailList()!=null) | 
 |  |  |             // 创建数据记录 | 
 |  |  |             for (int rowIndex = 0; rowIndex < data.getApplyDetailList().size(); rowIndex++) { | 
 |  |  |                 ApplyDetail d = data.getApplyDetailList().get(rowIndex); | 
 |  |  |                 Row header5 = sheet.createRow(rowIndex + 4); | 
 |  |  |                 header5.createCell(0).setCellValue(rowIndex+1); | 
 |  |  |                 header5.createCell(1).setCellValue(StringUtils.defaultString(d.getMemberName(),"")); | 
 |  |  |                 header5.createCell(2).setCellValue(Constants.equalsInteger(d.getSex(),0)?"男":(Constants.equalsInteger(d.getSex(),1)?"女":"-")); | 
 |  |  |                 header5.createCell(3).setCellValue(StringUtils.defaultString(d.getIdcardNo(),"")); | 
 |  |  |                 header5.createCell(4).setCellValue(StringUtils.defaultString(d.getDuName(),"")); | 
 |  |  |                 header5.createCell(5).setCellValue(StringUtils.defaultString(d.getWorkTypeName(),"")); | 
 |  |  |             } | 
 |  |  |             sxssfWorkbook.write(os); | 
 |  |  |             os.close(); | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e); | 
 |  |  |         } finally { | 
 |  |  |             if (os != null) { | 
 |  |  |                 try { | 
 |  |  |                     os.close(); | 
 |  |  |                 } catch (IOException e) { | 
 |  |  |                     e.printStackTrace(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Data | 
 |  |  |     @AllArgsConstructor | 
 |  |  |     private static class ColumnInfo { |