|
|
@ -1,8 +1,6 @@ |
|
|
|
package com.hnac.hzims.ticket.twoTicket.service.impl; |
|
|
|
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.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; |
|
|
|
import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; |
|
|
|
import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService; |
|
|
|
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 com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
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.api.R; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
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.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
@ -60,10 +70,21 @@ public class CensServiceImpl implements CensService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取权限区域机构
|
|
|
|
// 获取权限区域机构
|
|
|
|
List<Dept> depts = this.authArea(); |
|
|
|
List<Dept> depts; |
|
|
|
if(CollectionUtil.isEmpty(depts)){ |
|
|
|
if(ObjectUtil.isEmpty(param.getDeptId())){ |
|
|
|
return new ArrayList<>(); |
|
|
|
// 获取权限区域机构
|
|
|
|
|
|
|
|
depts = this.authArea(); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(depts)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
R<Dept> result = sysClient.getDept(param.getDeptId()); |
|
|
|
|
|
|
|
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
depts = Collections.singletonList(result.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 操作票查询
|
|
|
|
// 操作票查询
|
|
|
|
QueryWrapper wrapper = new QueryWrapper(); |
|
|
|
QueryWrapper wrapper = new QueryWrapper(); |
|
|
|
if(!StringUtil.isEmpty(param.getFlowTaskName())){ |
|
|
|
if(!StringUtil.isEmpty(param.getFlowTaskName())){ |
|
|
@ -135,11 +156,19 @@ public class CensServiceImpl implements CensService { |
|
|
|
if(!StringUtil.isEmpty(param.getState()) && param.getState().equals(1)){ |
|
|
|
if(!StringUtil.isEmpty(param.getState()) && param.getState().equals(1)){ |
|
|
|
param.setFlowTaskName("结束"); |
|
|
|
param.setFlowTaskName("结束"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<Dept> depts; |
|
|
|
// 获取权限区域机构
|
|
|
|
if(ObjectUtil.isEmpty(param.getDeptId())){ |
|
|
|
List<Dept> depts = this.authArea(); |
|
|
|
// 获取权限区域机构
|
|
|
|
if(CollectionUtil.isEmpty(depts)){ |
|
|
|
depts = this.authArea(); |
|
|
|
return new ArrayList<>(); |
|
|
|
if(CollectionUtil.isEmpty(depts)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
R<Dept> result = sysClient.getDept(param.getDeptId()); |
|
|
|
|
|
|
|
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
depts = Collections.singletonList(result.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 操作票查询
|
|
|
|
// 操作票查询
|
|
|
@ -180,11 +209,417 @@ public class CensServiceImpl implements CensService { |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
cens.setWorkCount(works.stream().filter(work->work.getCreateDept().equals(dept.getId()) && DateUtil.format(work.getCreateTime(),"yyyy-MM").equals(strMon)).count()); |
|
|
|
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); |
|
|
|
censs.add(cens); |
|
|
|
} |
|
|
|
} |
|
|
|
censYear.setCenss(censs); |
|
|
|
censYear.setCenss(censs.stream().sorted(Comparator.comparing(CensVo::getMon)).collect(Collectors.toList())); |
|
|
|
return censYear; |
|
|
|
return censYear; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 两票统计导出 |
|
|
|
|
|
|
|
* @param response |
|
|
|
|
|
|
|
* @param param |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void 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<CensVo> 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(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 首行表头样式 |
|
|
|
|
|
|
|
* @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<CensVo> 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 + 1); |
|
|
|
|
|
|
|
// 单位
|
|
|
|
|
|
|
|
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 void 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<CensYearVo> censYears = this.censYear(param); |
|
|
|
|
|
|
|
if (!CollectionUtil.isEmpty(censYears)) { |
|
|
|
|
|
|
|
// 数据填充
|
|
|
|
|
|
|
|
this.setYearWorkData(hssWB, sheet, censYears); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 下载导出
|
|
|
|
|
|
|
|
String filename = param.getYear() + "年度两票统计报表"; |
|
|
|
|
|
|
|
// 设置头信息
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 两票年首行表头设置 |
|
|
|
|
|
|
|
* @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(2); |
|
|
|
|
|
|
|
header_row_1_cell_3.setCellValue("1月"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_4 = row_1.getCell(4); |
|
|
|
|
|
|
|
header_row_1_cell_4.setCellValue("2月"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_5 = row_1.getCell(6); |
|
|
|
|
|
|
|
header_row_1_cell_5.setCellValue("3月"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_6 = row_1.getCell(8); |
|
|
|
|
|
|
|
header_row_1_cell_6.setCellValue("4月"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_7 = row_1.getCell(10); |
|
|
|
|
|
|
|
header_row_1_cell_7.setCellValue("5月"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_8 = row_1.getCell(12); |
|
|
|
|
|
|
|
header_row_1_cell_8.setCellValue("6月"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_9 = row_1.getCell(14); |
|
|
|
|
|
|
|
header_row_1_cell_9.setCellValue("7月"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_10 = row_1.getCell(16); |
|
|
|
|
|
|
|
header_row_1_cell_10.setCellValue("8月"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_11 = row_1.getCell(18); |
|
|
|
|
|
|
|
header_row_1_cell_11.setCellValue("9月"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_12 = row_1.getCell(20); |
|
|
|
|
|
|
|
header_row_1_cell_12.setCellValue("10月"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_13 = row_1.getCell(22); |
|
|
|
|
|
|
|
header_row_1_cell_13.setCellValue("11月"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_14 = row_1.getCell(24); |
|
|
|
|
|
|
|
header_row_1_cell_14.setCellValue("12月"); |
|
|
|
|
|
|
|
HSSFCell header_row_1_cell_15 = row_1.getCell(26); |
|
|
|
|
|
|
|
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<CensYearVo> 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 + 1); |
|
|
|
|
|
|
|
// 单位
|
|
|
|
|
|
|
|
HSSFCell header_row_cell_1 = row.getCell(1); |
|
|
|
|
|
|
|
header_row_cell_1.setCellValue(censYear.getDeptName()); |
|
|
|
|
|
|
|
List<CensVo> censs = censYear.getCenss(); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(censs)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int workSum = 0,operateSum = 0; |
|
|
|
|
|
|
|
for(int mon = 0; mon < 12; mon ++){ |
|
|
|
|
|
|
|
CensVo cens = censs.get(mon); |
|
|
|
|
|
|
|
// 工作票数量
|
|
|
|
|
|
|
|
HSSFCell work_cell = row.getCell(2 * (mon + 1)); |
|
|
|
|
|
|
|
work_cell.setCellValue(cens.getWorkCount()); |
|
|
|
|
|
|
|
workSum += cens.getWorkCount(); |
|
|
|
|
|
|
|
// 操作票数量
|
|
|
|
|
|
|
|
HSSFCell operate_cell = row.getCell(2 * (mon + 1) + 1); |
|
|
|
|
|
|
|
operate_cell.setCellValue(cens.getOperateCount()); |
|
|
|
|
|
|
|
operateSum += cens.getOperateCount(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 总计
|
|
|
|
|
|
|
|
HSSFCell work_sum_cell = row.getCell(26); |
|
|
|
|
|
|
|
work_sum_cell.setCellValue(workSum); |
|
|
|
|
|
|
|
HSSFCell operate_sum_cell = row.getCell(27); |
|
|
|
|
|
|
|
operate_sum_cell.setCellValue(operateSum); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |