| | |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | // 设置背景 |
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | // style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | // style.setFillForegroundColor(columnConfig.dataBackgroundColor().getIndex()); |
| | | // 字体 |
| | | Font font = workbook.createFont(); |
| | |
| | | throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void exportUnionApplyDetailDo (UnionApply data, String sheetName, OutputStream os) { |
| | | SXSSFWorkbook sxssfWorkbook; |
| | | try { |
| | |
| | | try { |
| | | sxssfWorkbook = new SXSSFWorkbook(); |
| | | Sheet sheet = sxssfWorkbook.createSheet(sheetName); |
| | | for (int i = 0; i < 8; i++) { |
| | | sheet.setColumnWidth(i, ((i==3|| i== 4|| i== 5 ||i== 6 || i==7)?16:8) * 2 * 256); |
| | | for (int i = 0; i < 9; i++) { |
| | | sheet.setColumnWidth(i, ((i==3|| i== 4|| i== 5 ||i== 6 || i==7|| i==8 || i==9)?16:8) * 2 * 256); |
| | | } |
| | | sheet.createFreezePane(0, 1); |
| | | sheet.addMergedRegion(new CellRangeAddress(0 ,0,0,7)); |
| | | sheet.addMergedRegion(new CellRangeAddress(0 ,0,0,8)); |
| | | Row title = sheet.createRow(0); |
| | | title.setHeight((short) 2000); |
| | | Cell c = title.createCell(0); |
| | | c.setCellValue(sheetName); |
| | | configFirstCell(sxssfWorkbook,c); |
| | | for (int i = 0; i < 8; i++) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if(i>0){ |
| | | title.createCell(i).setCellValue(""); |
| | | } |
| | |
| | | configDataCell(sxssfWorkbook,header2.getCell(i)); |
| | | } |
| | | |
| | | |
| | | Row header3 = sheet.createRow(3); |
| | | header3.createCell(0).setCellValue("被保险人"); |
| | | header3.createCell(1).setCellValue(data.getCompanyNames()); |
| | |
| | | sheet.addMergedRegion(new CellRangeAddress(3 ,3,1,8)); |
| | | |
| | | |
| | | 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("原派遣单位"); |
| | | header4.createCell(6).setCellValue("原所所属工种"); |
| | | header4.createCell(7).setCellValue("更改后派遣单位"); |
| | | header4.createCell(8).setCellValue("更改后所属工种"); |
| | | for (int i = 0; i < 9; i++) { |
| | | configFirstCell(sxssfWorkbook,header4.getCell(i)); |
| | | } |
| | | |
| | | List<ApplyChagneDetail> otherChangeDetailList = data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.TWO)).collect(Collectors.toList()); |
| | | |
| | | Integer row = 4; |
| | | Integer row = 3; |
| | | |
| | | if(CollectionUtils.isNotEmpty(otherChangeDetailList)){ |
| | | row = row + 1; |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public void exportUnionChangeDetail(UnionChange model, HttpServletResponse response) { |
| | | try { |
| | | String fileName = "加减保详情单"; |
| | | if(model.getType().equals(Constants.ONE)){ |
| | | fileName = "更换派遣单位详情单"; |
| | | } |
| | | String encodeFileName = URLEncoder.encode(fileName +"_"+model.getShopName(), 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); |
| | | if(model.getType().equals(Constants.ZERO)){ |
| | | this.exportUnionChangeAddDetailDo(model,"加减保申请表", response.getOutputStream()); |
| | | }else{ |
| | | this.exportUnionChangeDuDetailDo(model,"更换派遣单位申请表", response.getOutputStream()); |
| | | } |
| | | |
| | | } catch (IOException e) { |
| | | throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e); |
| | | } |
| | | } |
| | | |
| | | public void exportUnionChangeAddDetailDo (UnionChange data, String sheetName, OutputStream os) { |
| | | SXSSFWorkbook sxssfWorkbook; |
| | | try { |
| | | sxssfWorkbook = new SXSSFWorkbook(); |
| | | Sheet sheet = sxssfWorkbook.createSheet(sheetName); |
| | | for (int i = 0; i < 8; i++) { |
| | | sheet.setColumnWidth(i, ((i==3|| i==4|| i== 5 )?16:8) * 2 * 256); |
| | | } |
| | | sheet.createFreezePane(0, 1); |
| | | sheet.addMergedRegion(new CellRangeAddress(0 ,0,0,7)); |
| | | Row title = sheet.createRow(0); |
| | | title.setHeight((short) 2000); |
| | | for (int i = 0; i < 8; i++) { |
| | | title.createCell(i).setCellValue(i==0?sheetName:""); |
| | | configTitleCell(sxssfWorkbook,title.getCell(i)); |
| | | } |
| | | 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("加保人数"); |
| | | header1.createCell(6).setCellValue("减保人数"); |
| | | header1.createCell(7).setCellValue("期望批单生效期"); |
| | | for (int i = 0; i < 8; i++) { |
| | | configFirstCell(sxssfWorkbook,header1.getCell(i)); |
| | | } |
| | | |
| | | Row header2 = sheet.createRow(2); |
| | | header2.createCell(0).setCellValue(data.getShopName()); |
| | | header2.createCell(1).setCellValue(data.getSolutionsName()); |
| | | header2.createCell(2).setCellValue(data.getApplyCode()); |
| | | header2.createCell(3).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getStartTime())); |
| | | header2.createCell(4).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getEndTime())); |
| | | header2.createCell(5).setCellValue(data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.ZERO)).collect(Collectors.toList()).size()); |
| | | header2.createCell(6).setCellValue(data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.ONE)).collect(Collectors.toList()).size()); |
| | | header2.createCell(7).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getValidTime())); |
| | | for (int i = 0; i < 8; i++) { |
| | | configDataCell(sxssfWorkbook, header2.getCell(i)); |
| | | } |
| | | |
| | | Row header3 = sheet.createRow(3); |
| | | header3.createCell(0).setCellValue("被保险人"); |
| | | header3.createCell(1).setCellValue(data.getCompanyNames()); |
| | | header3.createCell(2).setCellValue(""); |
| | | header3.createCell(3).setCellValue(""); |
| | | header3.createCell(4).setCellValue(""); |
| | | header3.createCell(5).setCellValue(""); |
| | | header3.createCell(6).setCellValue(""); |
| | | header3.createCell(7).setCellValue(""); |
| | | for (int i = 0; i < 8; i++) { |
| | | configFirstCell(sxssfWorkbook,header3.getCell(i)); |
| | | } |
| | | sheet.addMergedRegion(new CellRangeAddress(3 ,3,1,7)); |
| | | |
| | | Integer row = 4; |
| | | List<ApplyChagneDetail> addChangeDetailList = data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.ZERO)).collect(Collectors.toList()); |
| | | if(CollectionUtils.isNotEmpty(addChangeDetailList)){ |
| | | Row header4 = sheet.createRow(row); |
| | | header4.createCell(0).setCellValue("加保人员"); |
| | | for (int i = 0; i < 8; i++) { |
| | | configFirstCell(sxssfWorkbook, header4.getCell(i)); |
| | | } |
| | | sheet.addMergedRegion(new CellRangeAddress(row ,row,0,7)); |
| | | row = row + 1; |
| | | Row header5 = sheet.createRow(row); |
| | | header5.createCell(0).setCellValue("序号"); |
| | | header5.createCell(1).setCellValue("员工姓名"); |
| | | header5.createCell(2).setCellValue("性别"); |
| | | header5.createCell(3).setCellValue("身份证号"); |
| | | header5.createCell(4).setCellValue("被保险人"); |
| | | header5.createCell(5).setCellValue("派遣单位"); |
| | | header5.createCell(6).setCellValue(""); |
| | | header5.createCell(7).setCellValue("所属工种"); |
| | | for (int i = 0; i < 8; i++) { |
| | | configFirstCell(sxssfWorkbook,header5.getCell(i)); |
| | | } |
| | | sheet.addMergedRegion(new CellRangeAddress(row ,row,5,6)); |
| | | for (int rowIndex = 0; rowIndex < addChangeDetailList.size(); rowIndex++) { |
| | | row = row + 1 ; |
| | | Row header6 = sheet.createRow(row); |
| | | ApplyChagneDetail applyChagneDetail = addChangeDetailList.get(rowIndex); |
| | | header6.createCell(0).setCellValue(rowIndex + 1); |
| | | header6.createCell(1).setCellValue(applyChagneDetail.getMemberName()); |
| | | header6.createCell(2).setCellValue(Constants.equalsInteger(applyChagneDetail.getSex(),0)?"男":(Constants.equalsInteger(applyChagneDetail.getSex(),1)?"女":"-")); |
| | | header6.createCell(3).setCellValue(applyChagneDetail.getIdcardNo()); |
| | | header6.createCell(4).setCellValue(applyChagneDetail.getCompanyName()); |
| | | header6.createCell(5).setCellValue(applyChagneDetail.getDuName()); |
| | | header6.createCell(6).setCellValue(""); |
| | | header6.createCell(7).setCellValue(applyChagneDetail.getWorkTypeName()); |
| | | for (int i = 0; i < 8; i++) { |
| | | configFirstCell(sxssfWorkbook,header6.getCell(i)); |
| | | } |
| | | sheet.addMergedRegion(new CellRangeAddress(row ,row,5,6)); |
| | | } |
| | | } |
| | | |
| | | List<ApplyChagneDetail> reduceChangeDetailList = data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.ONE)).collect(Collectors.toList()); |
| | | row = row + 1; |
| | | if(CollectionUtils.isNotEmpty(reduceChangeDetailList)){ |
| | | Row header4 = sheet.createRow(row); |
| | | header4.createCell(0).setCellValue("减保人员"); |
| | | for (int i = 0; i < 8; i++) { |
| | | configFirstCell(sxssfWorkbook, header4.getCell(i)); |
| | | } |
| | | sheet.addMergedRegion(new CellRangeAddress(row ,row,0,7)); |
| | | |
| | | row = row + 1; |
| | | Row header5 = sheet.createRow(row); |
| | | header5.createCell(0).setCellValue("序号"); |
| | | header5.createCell(1).setCellValue("员工姓名"); |
| | | header5.createCell(2).setCellValue("性别"); |
| | | header5.createCell(3).setCellValue("身份证号"); |
| | | header5.createCell(4).setCellValue("被保险人"); |
| | | header5.createCell(5).setCellValue("派遣单位"); |
| | | header5.createCell(6).setCellValue(""); |
| | | header5.createCell(7).setCellValue("所属工种"); |
| | | for (int i = 0; i < 8; i++) { |
| | | configFirstCell(sxssfWorkbook,header5.getCell(i)); |
| | | } |
| | | sheet.addMergedRegion(new CellRangeAddress(row ,row,5,6)); |
| | | |
| | | row = row + 1 ; |
| | | for (int rowIndex = 0; rowIndex < reduceChangeDetailList.size(); rowIndex++) { |
| | | row = row + rowIndex; |
| | | Row header6 = sheet.createRow(row); |
| | | ApplyChagneDetail applyChagneDetail = reduceChangeDetailList.get(rowIndex); |
| | | header6.createCell(0).setCellValue(rowIndex + 1); |
| | | header6.createCell(1).setCellValue(applyChagneDetail.getMemberName()); |
| | | header6.createCell(2).setCellValue(Constants.equalsInteger(applyChagneDetail.getSex(),0)?"男":(Constants.equalsInteger(applyChagneDetail.getSex(),1)?"女":"-")); |
| | | header6.createCell(3).setCellValue(applyChagneDetail.getIdcardNo()); |
| | | header6.createCell(4).setCellValue(applyChagneDetail.getCompanyName()); |
| | | header6.createCell(5).setCellValue(applyChagneDetail.getDuName()); |
| | | header6.createCell(6).setCellValue(""); |
| | | header6.createCell(7).setCellValue(applyChagneDetail.getWorkTypeName()); |
| | | for (int i = 0; i < 8; i++) { |
| | | configFirstCell(sxssfWorkbook,header6.getCell(i)); |
| | | } |
| | | sheet.addMergedRegion(new CellRangeAddress(row ,row,5,6)); |
| | | } |
| | | } |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public void exportUnionChangeDuDetailDo (UnionChange data, String sheetName, OutputStream os) { |
| | | SXSSFWorkbook sxssfWorkbook; |
| | | try { |
| | | sxssfWorkbook = new SXSSFWorkbook(); |
| | | Sheet sheet = sxssfWorkbook.createSheet(sheetName); |
| | | for (int i = 0; i < 9; i++) { |
| | | sheet.setColumnWidth(i, ((i==3|| i== 4|| i== 5 ||i== 6 || i==7|| i==8 || i==9)?16:8) * 2 * 256); |
| | | } |
| | | sheet.createFreezePane(0, 1); |
| | | sheet.addMergedRegion(new CellRangeAddress(0 ,0,0,8)); |
| | | Row title = sheet.createRow(0); |
| | | title.setHeight((short) 2000); |
| | | Cell c = title.createCell(0); |
| | | c.setCellValue(sheetName); |
| | | configFirstCell(sxssfWorkbook,c); |
| | | for (int i = 0; i < 9; i++) { |
| | | if(i>0){ |
| | | title.createCell(i).setCellValue(""); |
| | | } |
| | | configTitleCell(sxssfWorkbook,title.getCell(i)); |
| | | } |
| | | 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("保险生效起期"); |
| | | header1.createCell(6).setCellValue("保险生效止期"); |
| | | header1.createCell(7).setCellValue("换厂人数"); |
| | | header1.createCell(8).setCellValue("期望批单生效期"); |
| | | for (int i = 0; i < 9; i++) { |
| | | configFirstCell(sxssfWorkbook,header1.getCell(i)); |
| | | } |
| | | sheet.addMergedRegion(new CellRangeAddress(1 ,1,1,3)); |
| | | |
| | | Row header2 = sheet.createRow(2); |
| | | header2.createCell(0).setCellValue(data.getShopName()); |
| | | header2.createCell(1).setCellValue(data.getSolutionsName()); |
| | | header2.createCell(2).setCellValue(""); |
| | | header2.createCell(3).setCellValue(""); |
| | | header2.createCell(4).setCellValue(data.getApplyCode()); |
| | | header2.createCell(5).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getStartTime())); |
| | | header2.createCell(6).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getEndTime())); |
| | | header2.createCell(7).setCellValue(data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.TWO)).collect(Collectors.toList()).size()); |
| | | header2.createCell(8).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getApplyStartTime())); |
| | | sheet.addMergedRegion(new CellRangeAddress(2 ,2,1,3)); |
| | | for (int i = 0; i < 9; i++) { |
| | | configDataCell(sxssfWorkbook,header2.getCell(i)); |
| | | } |
| | | |
| | | Row header3 = sheet.createRow(3); |
| | | header3.createCell(0).setCellValue("被保险人"); |
| | | header3.createCell(1).setCellValue(data.getCompanyNames()); |
| | | header3.createCell(2).setCellValue(""); |
| | | header3.createCell(3).setCellValue(""); |
| | | header3.createCell(4).setCellValue(""); |
| | | header3.createCell(5).setCellValue(""); |
| | | header3.createCell(6).setCellValue(""); |
| | | header3.createCell(7).setCellValue(""); |
| | | header3.createCell(8).setCellValue(""); |
| | | for (int i = 0; i < 9; i++) { |
| | | configFirstCell(sxssfWorkbook,header3.getCell(i)); |
| | | } |
| | | sheet.addMergedRegion(new CellRangeAddress(3 ,3,1,8)); |
| | | |
| | | |
| | | |
| | | List<ApplyChagneDetail> otherChangeDetailList = data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.TWO)).collect(Collectors.toList()); |
| | | |
| | | Integer row = 3; |
| | | |
| | | if(CollectionUtils.isNotEmpty(otherChangeDetailList)){ |
| | | row = row + 1; |
| | | Row header5 = sheet.createRow(row); |
| | | header5.createCell(0).setCellValue("序号"); |
| | | header5.createCell(1).setCellValue("员工姓名"); |
| | | header5.createCell(2).setCellValue("性别"); |
| | | header5.createCell(3).setCellValue("身份证号"); |
| | | header5.createCell(4).setCellValue("被保险人"); |
| | | header5.createCell(5).setCellValue("原派遣单位"); |
| | | header5.createCell(6).setCellValue("原所属工种"); |
| | | header5.createCell(7).setCellValue("更改后派遣单位"); |
| | | header5.createCell(8).setCellValue("更改后所属工种"); |
| | | for (int i = 0; i < 9; i++) { |
| | | configFirstCell(sxssfWorkbook,header5.getCell(i)); |
| | | } |
| | | for (int rowIndex = 0; rowIndex < otherChangeDetailList.size(); rowIndex++) { |
| | | row = row + 1; |
| | | Row header6 = sheet.createRow(row); |
| | | ApplyChagneDetail applyChagneDetail = otherChangeDetailList.get(rowIndex); |
| | | header6.createCell(0).setCellValue(rowIndex + 1); |
| | | header6.createCell(1).setCellValue(applyChagneDetail.getMemberName()); |
| | | header6.createCell(2).setCellValue(Constants.equalsInteger(applyChagneDetail.getSex(),0)?"男":(Constants.equalsInteger(applyChagneDetail.getSex(),1)?"女":"-")); |
| | | header6.createCell(3).setCellValue(applyChagneDetail.getIdcardNo()); |
| | | header6.createCell(4).setCellValue(applyChagneDetail.getCompanyName()); |
| | | header6.createCell(5).setCellValue(applyChagneDetail.getOldDuName()); |
| | | header6.createCell(6).setCellValue(applyChagneDetail.getOldWorkTypeName()); |
| | | header6.createCell(7).setCellValue(applyChagneDetail.getDuName()); |
| | | header6.createCell(8).setCellValue(applyChagneDetail.getWorkTypeName()); |
| | | for (int i = 0; i < 9; i++) { |
| | | configFirstCell(sxssfWorkbook,header6.getCell(i)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |