From 70b696453471193b024058d1c219845aea09e634 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 2 Jan 2024 20:06:01 +0800 Subject: [PATCH] =?UTF-8?q?#=E4=B8=A4=E7=A5=A8=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AreaMonthReportServiceImpl.java | 2 +- .../twoTicket/controller/CensController.java | 19 +- .../ticket/twoTicket/service/CensService.java | 6 + .../twoTicket/service/impl/CensServiceImpl.java | 454 ++++++++++++++++++++- 4 files changed, 466 insertions(+), 15 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java index 9eb0b6d..88ba200 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java @@ -244,7 +244,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { ServletOutputStream outputStream; try { //设置xlsx格式 - response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8")); + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xls", "UTF-8")); //创建一个输出流 outputStream = response.getOutputStream(); //写入数据 diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/CensController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/CensController.java index 2d38e41..380f113 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/CensController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/CensController.java @@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; import java.util.List; @@ -32,10 +33,24 @@ public class CensController { return R.data(censService.cens(param)); } + @GetMapping ("/censExport") + @ApiOperation("两票统计导出") + @ApiOperationSupport(order = 2) + public R censExport(HttpServletResponse response,CensParamVo param) { + return censService.censExport(response,param); + } + @PostMapping("/censYear") - @ApiOperation("两票统计") - @ApiOperationSupport(order = 1) + @ApiOperation("两票年度统计") + @ApiOperationSupport(order = 3) public R> censYear(@RequestBody CensYearParamVo param) { return R.data(censService.censYear(param)); } + + @GetMapping ("/censYearExport") + @ApiOperation("两票年度统计导出") + @ApiOperationSupport(order = 4) + public R censYearExport(HttpServletResponse response,CensYearParamVo param) { + return censService.censYearExport(response,param); + } } \ No newline at end of file diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/CensService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/CensService.java index fdc8219..d3cd6c2 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/CensService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/CensService.java @@ -4,7 +4,9 @@ import com.hnac.hzims.ticket.standardTicket.vo.CensParamVo; import com.hnac.hzims.ticket.standardTicket.vo.CensVo; import com.hnac.hzims.ticket.standardTicket.vo.CensYearParamVo; import com.hnac.hzims.ticket.standardTicket.vo.CensYearVo; +import org.springblade.core.tool.api.R; +import javax.servlet.http.HttpServletResponse; import java.util.List; /** @@ -15,4 +17,8 @@ public interface CensService { List cens(CensParamVo param); List censYear(CensYearParamVo param); + + R censExport(HttpServletResponse response, CensParamVo param); + + R censYearExport(HttpServletResponse response, CensYearParamVo param); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/CensServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/CensServiceImpl.java index 2c23142..0c571a0 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/CensServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/CensServiceImpl.java @@ -1,8 +1,6 @@ package com.hnac.hzims.ticket.twoTicket.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService; @@ -15,14 +13,26 @@ import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.FillPatternType; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.util.CellRangeAddress; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; import org.springframework.stereotype.Service; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; import java.util.*; import java.util.stream.Collectors; @@ -60,10 +70,21 @@ public class CensServiceImpl implements CensService { } // 获取权限区域机构 - List depts = this.authArea(); - if(CollectionUtil.isEmpty(depts)){ - return new ArrayList<>(); + List depts; + if(ObjectUtil.isEmpty(param.getDeptId())){ + // 获取权限区域机构 + depts = this.authArea(); + if(CollectionUtil.isEmpty(depts)){ + return new ArrayList<>(); + } + }else{ + R result = sysClient.getDept(param.getDeptId()); + if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + depts = Collections.singletonList(result.getData()); } + // 操作票查询 QueryWrapper wrapper = new QueryWrapper(); if(!StringUtil.isEmpty(param.getFlowTaskName())){ @@ -135,11 +156,19 @@ public class CensServiceImpl implements CensService { if(!StringUtil.isEmpty(param.getState()) && param.getState().equals(1)){ param.setFlowTaskName("结束"); } - - // 获取权限区域机构 - List depts = this.authArea(); - if(CollectionUtil.isEmpty(depts)){ - return new ArrayList<>(); + List depts; + if(ObjectUtil.isEmpty(param.getDeptId())){ + // 获取权限区域机构 + depts = this.authArea(); + if(CollectionUtil.isEmpty(depts)){ + return new ArrayList<>(); + } + }else{ + R result = sysClient.getDept(param.getDeptId()); + if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + depts = Collections.singletonList(result.getData()); } // 操作票查询 @@ -180,11 +209,412 @@ public class CensServiceImpl implements CensService { }else{ cens.setWorkCount(works.stream().filter(work->work.getCreateDept().equals(dept.getId()) && DateUtil.format(work.getCreateTime(),"yyyy-MM").equals(strMon)).count()); } - cens.setWorkTaskCount((long)new Random().nextInt(10)); censs.add(cens); } - censYear.setCenss(censs); + censYear.setCenss(censs.stream().sorted(Comparator.comparing(CensVo::getMon)).collect(Collectors.toList())); return censYear; }).collect(Collectors.toList()); } + + /** + * 两票统计导出 + * @param response + * @param param + */ + @Override + public R censExport(HttpServletResponse response, CensParamVo param) { + // 创建Excel文件 + HSSFWorkbook hssWB = new HSSFWorkbook(); + // 添加sheet页 + HSSFSheet sheet = hssWB.createSheet("两票统计报表"); + // 行高 + sheet.setDefaultRowHeight((short) (20 * 25)); + // 列宽 + sheet.setDefaultColumnWidth(20); + this.setFirstHeader(hssWB, sheet); + // 第二行/三行 表头格式设置 + this.setWorkHeader(hssWB, sheet); + List censs = this.cens(param); + if (!CollectionUtil.isEmpty(censs)) { + // 数据填充 + this.setWorkData(hssWB, sheet, censs); + } + + // 下载导出 + String filename = "两票统计报表"; + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + ServletOutputStream outputStream; + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xls", "UTF-8")); + //创建一个输出流 + outputStream = response.getOutputStream(); + //写入数据 + hssWB.write(outputStream); + // 关闭 + outputStream.close(); + hssWB.close(); + } catch (IOException e) { + e.printStackTrace(); + } + return R.data("success"); + } + + /** + * 首行表头样式 + * @param hssWB + * @param sheet + */ + private void setFirstHeader(HSSFWorkbook hssWB, HSSFSheet sheet) { + // 第一行 + HSSFRow fisrtRow = sheet.createRow(0); + this.setTitileStyle(hssWB, fisrtRow, 4, true); + // 第一个单元格 + HSSFCell headCell = fisrtRow.getCell(0); + headCell.setCellValue("两票统计报表"); + // 首行合并情况 + CellRangeAddress region1 = new CellRangeAddress(0, 0, (short) 0, (short) 4); + sheet.addMergedRegion(region1); + } + + /** + * 年度统计首行表头样式 + * @param hssWB + * @param sheet + */ + private void setYearFirstHeader(HSSFWorkbook hssWB, HSSFSheet sheet) { + // 第一行 + HSSFRow fisrtRow = sheet.createRow(0); + this.setTitileStyle(hssWB, fisrtRow, 27, true); + // 第一个单元格 + HSSFCell headCell = fisrtRow.getCell(0); + headCell.setCellValue("两票年度统计报表"); + // 首行合并情况 + CellRangeAddress region1 = new CellRangeAddress(0, 0, (short) 0, (short) 27); + sheet.addMergedRegion(region1); + } + + /** + * 表头格式设置 + * + * @param hssWB + * @param sheet + */ + private void setWorkHeader(HSSFWorkbook hssWB, HSSFSheet sheet) { + // 创建行 + HSSFRow row_1 = sheet.createRow(1); + this.setTitileStyle(hssWB, row_1, 4, true); + // 第一行 + HSSFCell header_row_1_cell_1 = row_1.getCell(0); + header_row_1_cell_1.setCellValue("序号"); + HSSFCell header_row_1_cell_2 = row_1.getCell(1); + header_row_1_cell_2.setCellValue("单位"); + HSSFCell header_row_1_cell_3 = row_1.getCell(2); + header_row_1_cell_3.setCellValue("工作票数量"); + HSSFCell header_row_1_cell_4 = row_1.getCell(3); + header_row_1_cell_4.setCellValue("操作票数量"); + HSSFCell header_row_1_cell_5 = row_1.getCell(4); + header_row_1_cell_5.setCellValue("工作任务数量"); + } + + /** + * 设置Titile单元格样式 + * + * @param hssWB + * @param row + * @param len + */ + private void setTitileStyle(HSSFWorkbook hssWB, HSSFRow row, int len, boolean isHead) { + HSSFCellStyle cellStyle = getHeadStyle(hssWB, isHead); + for (int i = 0; i <= len; i++) { + HSSFCell hssfcell = row.createCell(i); + hssfcell.setCellStyle(cellStyle); + } + } + + /** + * 获取表头样式 + * + * @param hssWB + * @return + */ + private HSSFCellStyle getHeadStyle(HSSFWorkbook hssWB, boolean isHead) { + HSSFCellStyle headStyle = hssWB.createCellStyle(); + //边框 + headStyle.setBorderLeft(BorderStyle.THIN); + headStyle.setBorderRight(BorderStyle.THIN); + headStyle.setBorderTop(BorderStyle.THIN); + headStyle.setBorderBottom(BorderStyle.THIN); + //居中: + headStyle.setAlignment(HorizontalAlignment.CENTER); // 居中 + headStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 + //字体: + HSSFFont font = hssWB.createFont(); + font.setFontName("黑体"); + if (isHead) { + //设置字体大小 + font.setFontHeightInPoints((short) 12); + //背景颜色 + headStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.SKY_BLUE.getIndex()); + } else { + //设置字体大小 + font.setFontHeightInPoints((short) 8); + //背景颜色 + headStyle.setFillPattern(FillPatternType.NO_FILL); + headStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex()); + } + //字体格式 + + headStyle.setFont(font); + return headStyle; + } + + /** + * 表格数据填充 + * + * @param hssWB + * @param sheet + * @param censs + */ + private void setWorkData(HSSFWorkbook hssWB, HSSFSheet sheet, List censs) { + int size = censs.size(); + for (int i = 0; i < size; i++) { + HSSFRow row = sheet.createRow(i + 2); + this.setTitileStyle(hssWB, row, 19, false); + CensVo cens = censs.get(i); + // 序号 + HSSFCell header_row_cell_0 = row.getCell(0); + header_row_cell_0.setCellValue(i); + // 单位 + HSSFCell header_row_cell_1 = row.getCell(1); + header_row_cell_1.setCellValue(cens.getDeptName()); + // 工作票数量 + HSSFCell header_row_cell_2 = row.getCell(2); + header_row_cell_2.setCellValue(cens.getWorkCount()); + // 操作票数量 + HSSFCell header_row_cell_3 = row.getCell(3); + header_row_cell_3.setCellValue(cens.getOperateCount()); + // 工作任务数量 + HSSFCell header_row_cell_4 = row.getCell(4); + header_row_cell_4.setCellValue(cens.getWorkTaskCount()); + } + } + + /** + * 两票年度统计导出 + * @param response + * @param param + */ + @Override + public R censYearExport(HttpServletResponse response, CensYearParamVo param) { + if(StringUtil.isEmpty(param.getYear())){ + param.setYear(DateUtil.format(new Date(),"yyyy")); + } + // 创建Excel文件 + HSSFWorkbook hssWB = new HSSFWorkbook(); + // 添加sheet页 + HSSFSheet sheet = hssWB.createSheet("两票" + param.getYear() + "年度统计报表"); + // 行高 + sheet.setDefaultRowHeight((short) (20 * 25)); + // 列宽 + sheet.setDefaultColumnWidth(20); + this.setYearFirstHeader(hssWB, sheet); + // 第二行/三行 表头格式设置 + this.setYearWorkHeader(hssWB, sheet); + List censYears = this.censYear(param); + if (!CollectionUtil.isEmpty(censYears)) { + // 数据填充 + this.setYearWorkData(hssWB, sheet, censYears); + } + + // 下载导出 + String filename = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME) + "年度两票统计报表"; + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + ServletOutputStream outputStream; + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xls", "UTF-8")); + //创建一个输出流 + outputStream = response.getOutputStream(); + //写入数据 + hssWB.write(outputStream); + // 关闭 + outputStream.close(); + hssWB.close(); + } catch (IOException e) { + e.printStackTrace(); + } + return R.data("success"); + } + + /** + * 两票年首行表头设置 + * @param hssWB + * @param sheet + */ + private void setYearWorkHeader(HSSFWorkbook hssWB, HSSFSheet sheet) { + // 创建行 + HSSFRow row_1 = sheet.createRow(1); + this.setTitileStyle(hssWB, row_1, 27, true); + // 第一行 + HSSFCell header_row_1_cell_1 = row_1.getCell(0); + header_row_1_cell_1.setCellValue("序号"); + HSSFCell header_row_1_cell_2 = row_1.getCell(1); + header_row_1_cell_2.setCellValue("单位"); + HSSFCell header_row_1_cell_3 = row_1.getCell(3); + header_row_1_cell_3.setCellValue("1月"); + HSSFCell header_row_1_cell_4 = row_1.getCell(5); + header_row_1_cell_4.setCellValue("2月"); + HSSFCell header_row_1_cell_5 = row_1.getCell(7); + header_row_1_cell_5.setCellValue("3月"); + HSSFCell header_row_1_cell_6 = row_1.getCell(9); + header_row_1_cell_6.setCellValue("4月"); + HSSFCell header_row_1_cell_7 = row_1.getCell(11); + header_row_1_cell_7.setCellValue("5月"); + HSSFCell header_row_1_cell_8 = row_1.getCell(13); + header_row_1_cell_8.setCellValue("6月"); + HSSFCell header_row_1_cell_9 = row_1.getCell(15); + header_row_1_cell_9.setCellValue("7月"); + HSSFCell header_row_1_cell_10 = row_1.getCell(17); + header_row_1_cell_10.setCellValue("8月"); + HSSFCell header_row_1_cell_11 = row_1.getCell(19); + header_row_1_cell_11.setCellValue("9月"); + HSSFCell header_row_1_cell_12 = row_1.getCell(21); + header_row_1_cell_12.setCellValue("10月"); + HSSFCell header_row_1_cell_13 = row_1.getCell(23); + header_row_1_cell_13.setCellValue("11月"); + HSSFCell header_row_1_cell_14 = row_1.getCell(25); + header_row_1_cell_14.setCellValue("12月"); + HSSFCell header_row_1_cell_15 = row_1.getCell(27); + header_row_1_cell_15.setCellValue("总计"); + + // 第二行 + HSSFRow row_2 = sheet.createRow(2); + this.setTitileStyle(hssWB, row_2, 27, true); + HSSFCell header_row_2_cell_1 = row_2.getCell(2); + header_row_2_cell_1.setCellValue("工作票"); + HSSFCell header_row_2_cell_2 = row_2.getCell(3); + header_row_2_cell_2.setCellValue("操作票"); + HSSFCell header_row_2_cell_3 = row_2.getCell(4); + header_row_2_cell_3.setCellValue("工作票"); + HSSFCell header_row_2_cell_4 = row_2.getCell(5); + header_row_2_cell_4.setCellValue("操作票"); + HSSFCell header_row_2_cell_5 = row_2.getCell(6); + header_row_2_cell_5.setCellValue("工作票"); + HSSFCell header_row_2_cell_6 = row_2.getCell(7); + header_row_2_cell_6.setCellValue("操作票"); + HSSFCell header_row_2_cell_7 = row_2.getCell(8); + header_row_2_cell_7.setCellValue("工作票"); + HSSFCell header_row_2_cell_8 = row_2.getCell(9); + header_row_2_cell_8.setCellValue("操作票"); + HSSFCell header_row_2_cell_9 = row_2.getCell(10); + header_row_2_cell_9.setCellValue("工作票"); + HSSFCell header_row_2_cell_10 = row_2.getCell(11); + header_row_2_cell_10.setCellValue("操作票"); + HSSFCell header_row_2_cell_11 = row_2.getCell(12); + header_row_2_cell_11.setCellValue("工作票"); + HSSFCell header_row_2_cell_12 = row_2.getCell(13); + header_row_2_cell_12.setCellValue("操作票"); + HSSFCell header_row_2_cell_13 = row_2.getCell(14); + header_row_2_cell_13.setCellValue("工作票"); + HSSFCell header_row_2_cell_14 = row_2.getCell(15); + header_row_2_cell_14.setCellValue("操作票"); + HSSFCell header_row_2_cell_15 = row_2.getCell(16); + header_row_2_cell_15.setCellValue("工作票"); + HSSFCell header_row_2_cell_16 = row_2.getCell(17); + header_row_2_cell_16.setCellValue("操作票"); + HSSFCell header_row_2_cell_17 = row_2.getCell(18); + header_row_2_cell_17.setCellValue("工作票"); + HSSFCell header_row_2_cell_18 = row_2.getCell(19); + header_row_2_cell_18.setCellValue("操作票"); + HSSFCell header_row_2_cell_19 = row_2.getCell(20); + header_row_2_cell_19.setCellValue("工作票"); + HSSFCell header_row_2_cell_20 = row_2.getCell(21); + header_row_2_cell_20.setCellValue("操作票"); + HSSFCell header_row_2_cell_21 = row_2.getCell(22); + header_row_2_cell_21.setCellValue("工作票"); + HSSFCell header_row_2_cell_22 = row_2.getCell(23); + header_row_2_cell_22.setCellValue("操作票"); + HSSFCell header_row_2_cell_23 = row_2.getCell(24); + header_row_2_cell_23.setCellValue("工作票"); + HSSFCell header_row_2_cell_24 = row_2.getCell(25); + header_row_2_cell_24.setCellValue("操作票"); + HSSFCell header_row_2_cell_25 = row_2.getCell(26); + header_row_2_cell_25.setCellValue("工作票"); + HSSFCell header_row_2_cell_26 = row_2.getCell(27); + header_row_2_cell_26.setCellValue("操作票"); + + // 表头一:合并情况 + CellRangeAddress header_region_1 = new CellRangeAddress((short) 1, (short) 2, (short) 0, (short) 0); + CellRangeAddress header_region_2 = new CellRangeAddress((short) 1, (short) 2, (short) 1, (short) 1); + CellRangeAddress header_region_3 = new CellRangeAddress((short) 1, (short) 1, (short) 2, (short) 3); + CellRangeAddress header_region_4 = new CellRangeAddress((short) 1, (short) 1, (short) 4, (short) 5); + CellRangeAddress header_region_5 = new CellRangeAddress((short) 1, (short) 1, (short) 6, (short) 7); + CellRangeAddress header_region_6 = new CellRangeAddress((short) 1, (short) 1, (short) 8, (short) 9); + CellRangeAddress header_region_7 = new CellRangeAddress((short) 1, (short) 1, (short) 10, (short) 11); + CellRangeAddress header_region_8 = new CellRangeAddress((short) 1, (short) 1, (short) 12, (short) 13); + CellRangeAddress header_region_9 = new CellRangeAddress((short) 1, (short) 1, (short) 14, (short) 15); + CellRangeAddress header_region_10 = new CellRangeAddress((short) 1, (short) 1, (short) 16, (short) 17); + CellRangeAddress header_region_11 = new CellRangeAddress((short) 1, (short) 1, (short) 18, (short) 19); + CellRangeAddress header_region_12 = new CellRangeAddress((short) 1, (short) 1, (short) 20, (short) 21); + CellRangeAddress header_region_13 = new CellRangeAddress((short) 1, (short) 1, (short) 22, (short) 23); + CellRangeAddress header_region_14 = new CellRangeAddress((short) 1, (short) 1, (short) 24, (short) 25); + CellRangeAddress header_region_15 = new CellRangeAddress((short) 1, (short) 1, (short) 26, (short) 27); + sheet.addMergedRegion(header_region_1); + sheet.addMergedRegion(header_region_2); + sheet.addMergedRegion(header_region_3); + sheet.addMergedRegion(header_region_4); + sheet.addMergedRegion(header_region_5); + sheet.addMergedRegion(header_region_6); + sheet.addMergedRegion(header_region_7); + sheet.addMergedRegion(header_region_8); + sheet.addMergedRegion(header_region_9); + sheet.addMergedRegion(header_region_10); + sheet.addMergedRegion(header_region_11); + sheet.addMergedRegion(header_region_12); + sheet.addMergedRegion(header_region_13); + sheet.addMergedRegion(header_region_14); + sheet.addMergedRegion(header_region_15); + } + + /** + * 年度数据设置 + * @param hssWB + * @param sheet + * @param censYears + */ + private void setYearWorkData(HSSFWorkbook hssWB, HSSFSheet sheet, List censYears) { + int size = censYears.size(); + for (int i = 0; i < size; i++) { + HSSFRow row = sheet.createRow(i + 3); + this.setTitileStyle(hssWB, row, 27, false); + CensYearVo censYear = censYears.get(i); + // 序号 + HSSFCell header_row_cell_0 = row.getCell(0); + header_row_cell_0.setCellValue(i); + // 单位 + HSSFCell header_row_cell_1 = row.getCell(1); + header_row_cell_1.setCellValue(censYear.getDeptName()); + List censs = censYear.getCenss(); + if(CollectionUtil.isEmpty(censs)){ + return; + } + for(int mon = 0; mon < 12; mon ++){ + CensVo cens = censs.get(mon); + // 工作票数量 + HSSFCell work_cell = row.getCell(3 + mon); + work_cell.setCellValue(cens.getWorkCount()); + // 操作票数量 + HSSFCell operate_cell = row.getCell(3 + mon + 1); + work_cell.setCellValue(cens.getOperateCount()); + } + } + } + + } \ No newline at end of file