From 02bc3bfe47e3d5311a0bb041c94e70a34b1ca73c Mon Sep 17 00:00:00 2001 From: k94314517 <8417338+k94314517@user.noreply.gitee.com> Date: 星期二, 09 四月 2024 09:03:01 +0800 Subject: [PATCH] git ch --- server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java | 517 +++++++++++++++++++++++++++++--------------------------- 1 files changed, 266 insertions(+), 251 deletions(-) diff --git a/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java b/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java index a371437..d975fbd 100644 --- a/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java +++ b/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java @@ -1395,7 +1395,7 @@ sheet.createFreezePane(0, 1); sheet.addMergedRegion(new CellRangeAddress(0 ,0,0,8)); Row title = sheet.createRow(0); - title.setHeight((short) 2000); + title.setHeight((short) 1000); Cell c = title.createCell(0); c.setCellValue(sheetName); configFirstCell(sxssfWorkbook,c); @@ -1407,49 +1407,56 @@ } Row header1 = sheet.createRow(1); header1.createCell(0).setCellValue("鎶曚繚浜�"); - header1.createCell(1).setCellValue("淇濋櫓鏂规"); - header1.createCell(2).setCellValue(""); - header1.createCell(3).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("鏈熸湜鎵瑰崟鐢熸晥鏈�"); + + sheet.addMergedRegion(new CellRangeAddress(1 ,1,0,1)); + sheet.addMergedRegion(new CellRangeAddress(1 ,1,2,3)); + 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(1).setCellValue(""); + header2.createCell(2).setCellValue(data.getSolutionsName()); 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)); +// sheet.addMergedRegion(new CellRangeAddress(2 ,2,1,3)); + + sheet.addMergedRegion(new CellRangeAddress(2 ,2,0,1)); + sheet.addMergedRegion(new CellRangeAddress(2 ,2,2,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(1).setCellValue(""); + header3.createCell(2).setCellValue(data.getCompanyNames()); 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++) { + for (int i = 0; i < 2; i++) { configFirstCell(sxssfWorkbook,header3.getCell(i)); } - sheet.addMergedRegion(new CellRangeAddress(3 ,3,1,8)); - + for (int i = 2; i < 9; i++) { + configDataCell(sxssfWorkbook,header3.getCell(i)); + } + sheet.addMergedRegion(new CellRangeAddress(3 ,3,0,1)); + sheet.addMergedRegion(new CellRangeAddress(3 ,3,2,8)); List<ApplyChagneDetail> otherChangeDetailList = data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.TWO)).collect(Collectors.toList()); @@ -1485,10 +1492,10 @@ header6.createCell(7).setCellValue(applyChagneDetail.getDuName()); header6.createCell(8).setCellValue(applyChagneDetail.getWorkTypeName()); for (int i = 0; i < 9; i++) { - configFirstCell(sxssfWorkbook,header6.getCell(i)); - } + configDataCell(sxssfWorkbook,header6.getCell(i)); + } } - } + } int rowIndex = row + 1 ; Row header6= sheet.createRow(rowIndex); header6.createCell(0).setCellValue("鎶曚繚浼佷笟鐢虫槑:\n" + @@ -1549,225 +1556,8 @@ try { sxssfWorkbook = new SXSSFWorkbook(); Sheet sheet = sxssfWorkbook.createSheet(sheetName); - for (int i = 0; i < 12; i++) { - sheet.setColumnWidth(i, ((i==3|| i==4|| i== 5 || i==9||i==10|| i==11)?16:8) * 2 * 256); - } - sheet.createFreezePane(0, 1); - sheet.addMergedRegion(new CellRangeAddress(0 ,0,0,11)); - Row title = sheet.createRow(0); - title.setHeight((short) 2000); - for (int i = 0; i < 12; 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)); - } - } - - int rowIndex = row + 1; - Row header6= sheet.createRow(rowIndex); - header6.createCell(0).setCellValue("鎶曚繚浼佷笟鐢虫槑:\n" + - "1銆佸湪鐢宠涔︿笂濉啓鐨勪竴鍒囧唴瀹瑰睘瀹烇紝鍚﹀垯鏈紒涓氭壙鎷呬竴鍒囨硶寰嬭矗浠汇�俓n" + - "2銆佺敱浜庡彉鏇村彈鐩婁汉浜х敓鐨勬硶寰嬬籂绾锋湰浼佷笟鎰挎壙鎷呬竴鍒囨硶寰嬭矗浠汇�俓n" + - "3銆佹湰鐢宠琛ㄧ殑绛剧珷涓烘湰浼佷笟浜茶嚜绛剧讲锛屽鐢辨浜х敓鐨勬硶寰嬬籂绾锋湰浼佷笟鎰挎壙鎷呬竴鍒囨硶寰嬭矗浠汇�俓n"); - for (int i = 1; i < 8; i++) { - header6.createCell(i).setCellValue(""); - } - for (int i =0; i < 8; i++) { - if(i>0){ - header6.createCell(i).setCellValue(""); - } - configInfoCell(sxssfWorkbook,header6.getCell(i),HorizontalAlignment.LEFT); - } - header6.setHeight((short) 2000); - sheet.addMergedRegion(new CellRangeAddress(rowIndex ,rowIndex,0,11)); - Row header7= sheet.createRow(rowIndex+1); - header7.setHeight((short) 3000); - header7.createCell(0).setCellValue("鎶曚繚浜虹绔� 锛� \n \n \n" +"鏃ユ湡锛� 骞� 鏈� 鏃� "); - for (int i =0; i < 8; i++) { - if(i>0){ - header7.createCell(i).setCellValue(""); - } - configInfoCell(sxssfWorkbook,header7.getCell(i),HorizontalAlignment.RIGHT); - } - sheet.addMergedRegion(new CellRangeAddress(rowIndex+1 ,rowIndex+1,0,11)); - - //涓存椂缂撳啿鍖� - ByteArrayOutputStream out = new ByteArrayOutputStream(); - //鍒涘缓涓存椂鏂囦欢 - sxssfWorkbook.write(out); - byte [] bookByteAry = out.toByteArray(); - InputStream in = new ByteArrayInputStream(bookByteAry); - String tempExcel = saveIsToFile(in); - String tempPdf =System.getProperty("java.io.tmpdir")+File.separator+UUID.randomUUID().toString()+".pdf"; -// ExcelToPdfTool.excelToPdf(in,tempPdf);//杞琍DF - ExcelToPdfTool.excelToPdf(tempExcel,tempPdf);//杞琍DF - File f = new File(tempPdf); - if(f!=null && f.isFile() && f.length()>0){ - return tempPdf; - } - } catch (Exception e) { - e.printStackTrace(); - // throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e); - } - 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.setColumnWidth(i, ((i==0|| i==1|| i== 3|| i== 4|| i== 7)?16:8) * 2 * 256); } sheet.createFreezePane(0, 1); sheet.addMergedRegion(new CellRangeAddress(0 ,0,0,7)); @@ -1898,6 +1688,224 @@ header6.createCell(6).setCellValue(""); header6.createCell(7).setCellValue(applyChagneDetail.getWorkTypeName()); for (int i = 0; i < 8; i++) { + configDataCell(sxssfWorkbook,header6.getCell(i)); + } + sheet.addMergedRegion(new CellRangeAddress(row ,row,5,6)); + } + } + + int rowIndex = row + 1; + Row header6= sheet.createRow(rowIndex); + header6.createCell(0).setCellValue("鎶曚繚浼佷笟鐢虫槑:\n" + + "1銆佸湪鐢宠涔︿笂濉啓鐨勪竴鍒囧唴瀹瑰睘瀹烇紝鍚﹀垯鏈紒涓氭壙鎷呬竴鍒囨硶寰嬭矗浠汇�俓n" + + "2銆佺敱浜庡彉鏇村彈鐩婁汉浜х敓鐨勬硶寰嬬籂绾锋湰浼佷笟鎰挎壙鎷呬竴鍒囨硶寰嬭矗浠汇�俓n" + + "3銆佹湰鐢宠琛ㄧ殑绛剧珷涓烘湰浼佷笟浜茶嚜绛剧讲锛屽鐢辨浜х敓鐨勬硶寰嬬籂绾锋湰浼佷笟鎰挎壙鎷呬竴鍒囨硶寰嬭矗浠汇�俓n"); + for (int i = 1; i < 8; i++) { + header6.createCell(i).setCellValue(""); + } + for (int i =0; i < 8; i++) { + if(i>0){ + header6.createCell(i).setCellValue(""); + } + configInfoCell(sxssfWorkbook,header6.getCell(i),HorizontalAlignment.LEFT); + } + header6.setHeight((short) 2000); + sheet.addMergedRegion(new CellRangeAddress(rowIndex ,rowIndex,0,7)); + Row header7= sheet.createRow(rowIndex+1); + header7.setHeight((short) 3000); + header7.createCell(0).setCellValue("鎶曚繚浜虹绔� 锛� \n \n \n" +"鏃ユ湡锛� 骞� 鏈� 鏃� "); + for (int i =0; i < 8; i++) { + if(i>0){ + header7.createCell(i).setCellValue(""); + } + configInfoCell(sxssfWorkbook,header7.getCell(i),HorizontalAlignment.RIGHT); + } + sheet.addMergedRegion(new CellRangeAddress(rowIndex+1 ,rowIndex+1,0,7)); + + //涓存椂缂撳啿鍖� + ByteArrayOutputStream out = new ByteArrayOutputStream(); + //鍒涘缓涓存椂鏂囦欢 + sxssfWorkbook.write(out); + byte [] bookByteAry = out.toByteArray(); + InputStream in = new ByteArrayInputStream(bookByteAry); + String tempExcel = saveIsToFile(in); + String tempPdf =System.getProperty("java.io.tmpdir")+File.separator+UUID.randomUUID().toString()+".pdf"; +// ExcelToPdfTool.excelToPdf(in,tempPdf);//杞琍DF + ExcelToPdfTool.excelToPdf(tempExcel,tempPdf);//杞琍DF + File f = new File(tempPdf); + if(f!=null && f.isFile() && f.length()>0){ + return tempPdf; + } + } catch (Exception e) { + e.printStackTrace(); + // throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e); + } + 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) 1000); + 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.getApplyStartTime())); + 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(""); + configFirstCell(sxssfWorkbook,header3.getCell(0)); + for (int i = 1; i < 8; i++) { + configDataCell(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++) { + configDataCell(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)); @@ -1930,7 +1938,7 @@ sheet.createFreezePane(0, 1); sheet.addMergedRegion(new CellRangeAddress(0 ,0,0,8)); Row title = sheet.createRow(0); - title.setHeight((short) 2000); + title.setHeight((short) 1000); Cell c = title.createCell(0); c.setCellValue(sheetName); configFirstCell(sxssfWorkbook,c); @@ -1942,49 +1950,56 @@ } Row header1 = sheet.createRow(1); header1.createCell(0).setCellValue("鎶曚繚浜�"); - header1.createCell(1).setCellValue("淇濋櫓鏂规"); - header1.createCell(2).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("鏈熸湜鎵瑰崟鐢熸晥鏈�"); + + sheet.addMergedRegion(new CellRangeAddress(1 ,1,0,1)); + sheet.addMergedRegion(new CellRangeAddress(1 ,1,2,3)); + 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(1).setCellValue(""); + header2.createCell(2).setCellValue(data.getSolutionsName()); 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)); +// sheet.addMergedRegion(new CellRangeAddress(2 ,2,1,3)); + + sheet.addMergedRegion(new CellRangeAddress(2 ,2,0,1)); + sheet.addMergedRegion(new CellRangeAddress(2 ,2,2,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(1).setCellValue(""); + header3.createCell(2).setCellValue(data.getCompanyNames()); 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++) { + for (int i = 0; i < 2; i++) { configFirstCell(sxssfWorkbook,header3.getCell(i)); } - sheet.addMergedRegion(new CellRangeAddress(3 ,3,1,8)); - + for (int i = 2; i < 9; i++) { + configDataCell(sxssfWorkbook,header3.getCell(i)); + } + sheet.addMergedRegion(new CellRangeAddress(3 ,3,0,1)); + sheet.addMergedRegion(new CellRangeAddress(3 ,3,2,8)); List<ApplyChagneDetail> otherChangeDetailList = data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.TWO)).collect(Collectors.toList()); @@ -2020,7 +2035,7 @@ header6.createCell(7).setCellValue(applyChagneDetail.getDuName()); header6.createCell(8).setCellValue(applyChagneDetail.getWorkTypeName()); for (int i = 0; i < 9; i++) { - configFirstCell(sxssfWorkbook,header6.getCell(i)); + configDataCell(sxssfWorkbook,header6.getCell(i)); } } } -- Gitblit v1.9.3