|
|
package com.nmgs.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
//import com.nmgs.entity.GreenTraffic;
|
|
|
//import com.nmgs.mapper.check.CheckResultMapper;
|
|
|
import com.nmgs.entity.GreenTraffic;
|
|
|
import com.nmgs.mapper.green.GreenTrafficCheckMapper;
|
|
|
import com.nmgs.mapper.green.GreenTrafficCheckPicMapper;
|
|
|
import com.nmgs.mapper.green.GreenTrafficCheckResultMapper;
|
|
|
import com.nmgs.mapper.green.GreenTrafficMapper;
|
|
|
import com.nmgs.service.IGreenTrafficExportExcelService;
|
|
|
import com.nmgs.util.PropertiesUtil;
|
|
|
import com.nmgs.util.ReadExcel;
|
|
|
import org.apache.commons.codec.Charsets;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.Executor;
|
|
|
|
|
|
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class GreenTrafficExportExcelServiceImpl implements IGreenTrafficExportExcelService {
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private GreenTrafficMapper greenTrafficMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private GreenTrafficCheckMapper greenTrafficCheckMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private GreenTrafficCheckPicMapper greenTrafficCheckPicMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private GreenTrafficCheckResultMapper greenTrafficCheckResultMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private Executor greenTrafficThreadPool;
|
|
|
|
|
|
// @Autowired
|
|
|
// private CheckResultMapper checkResultMapper;
|
|
|
|
|
|
|
|
|
public static Logger logger = LoggerFactory.getLogger(GreenTrafficExportExcelServiceImpl.class);
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 盟市、收费站统计
|
|
|
* @param searchForm
|
|
|
* @param response
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Override
|
|
|
public void exportstaUnionCollectionExcle(String searchForm, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
|
|
|
//设置导出文件名称
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
Date date = new Date();
|
|
|
|
|
|
|
|
|
StringBuilder filename = new StringBuilder();
|
|
|
//定义一个标题数组
|
|
|
List<String> title = new ArrayList<>();
|
|
|
int arrayIndex = 0;
|
|
|
|
|
|
HashMap<String,Object> paramsMap = new HashMap<>();
|
|
|
|
|
|
//如果传进来的参数有值,拼接参数
|
|
|
|
|
|
if(null != searchForm && !"".equals(searchForm)){
|
|
|
paramsMap = JSON.parseObject(searchForm, HashMap.class);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//定义查询列,根据params条件动态拼接
|
|
|
StringBuilder selectColumn = new StringBuilder(" sum( 1 ) AS greenCount," +
|
|
|
"sum( green.CASH ) AS fee," +
|
|
|
"sum( green.INCASH + green.PAYCASH ) AS actualFee," +
|
|
|
"sum( green.CASH - ( green.INCASH + green.PAYCASH ) ) AS derateFee ");
|
|
|
|
|
|
|
|
|
StringBuilder group = new StringBuilder();
|
|
|
StringBuilder order = new StringBuilder(" order by "+paramsMap.get("orderColumn")+" "+paramsMap.get("orderType"));
|
|
|
|
|
|
//从配置文件中读取数据库连接类型
|
|
|
paramsMap.put("DBTYPE", PropertiesUtil.getValue("DBType"));
|
|
|
|
|
|
//设置分页
|
|
|
Integer pageNum = (Integer) paramsMap.get("pageNum");
|
|
|
Integer pageSize = (Integer) paramsMap.get("pageSize");
|
|
|
Page<Map<String, Object>> page = new Page<>(pageNum,50000);
|
|
|
|
|
|
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
|
|
Object value = entry.getValue();
|
|
|
|
|
|
if("unionCollection".equals(value)){
|
|
|
|
|
|
//拼接查询列
|
|
|
selectColumn.append(" ,sta.REGIONNAME as REGIONNAME ");
|
|
|
|
|
|
//拼接分组条件
|
|
|
if(group.toString().equals("")){
|
|
|
group = new StringBuilder("group by sta.REGIONNAME ");
|
|
|
}else{
|
|
|
group.append(" ,sta.REGIONNAME ");
|
|
|
}
|
|
|
title.add("盟市");
|
|
|
if(filename.length() == 0){
|
|
|
filename = new StringBuilder("盟市");
|
|
|
}else{
|
|
|
filename.append(",盟市");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if("staCollection".equals(value)){
|
|
|
//拼接查询列
|
|
|
selectColumn.append(" ,sta.STANAME as staName,green.STANO ");
|
|
|
|
|
|
//拼接分组条件
|
|
|
if(group.toString().equals("")){
|
|
|
group = new StringBuilder("group by green.STANO,sta.STANAME ");
|
|
|
}else{
|
|
|
group.append(" ,green.STANO,sta.STANAME ");
|
|
|
}
|
|
|
title.add("收费站");
|
|
|
if(filename.length() == 0){
|
|
|
filename = new StringBuilder("收费站");
|
|
|
}else{
|
|
|
filename.append(",收费站");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//设置文件名
|
|
|
filename.append("绿通车数据统计").append(simpleDateFormat.format(date)).append(".xlsx");
|
|
|
|
|
|
|
|
|
paramsMap.put("selectColumn", selectColumn.toString());
|
|
|
logger.info("selectColumn=========="+selectColumn);
|
|
|
paramsMap.put("group", group.toString());
|
|
|
logger.info("group=========="+group);
|
|
|
paramsMap.put("order", order.toString());
|
|
|
logger.info("order=========="+order);
|
|
|
page = greenTrafficMapper.getStaSubComCollectionData(page,paramsMap);
|
|
|
|
|
|
|
|
|
//创建一个Excel表格
|
|
|
Workbook wb = new XSSFWorkbook();
|
|
|
|
|
|
|
|
|
//创建sheet页面
|
|
|
Sheet sheet = wb.createSheet("绿通");
|
|
|
|
|
|
|
|
|
//如果没有数据,返回一个空的Excel
|
|
|
List<Map<String, Object>> records = page.getRecords();
|
|
|
if(null == records){
|
|
|
//导出Excel
|
|
|
writeToExcel(response,wb, filename.toString());
|
|
|
}
|
|
|
|
|
|
title.add("绿通车数量");
|
|
|
title.add("应收金额(元)");
|
|
|
title.add("实收金额(元)");
|
|
|
title.add("减免金额(元)");
|
|
|
|
|
|
|
|
|
//定义内容数据
|
|
|
List<String[]> rowValues = new ArrayList<>();
|
|
|
|
|
|
|
|
|
for (Map<String, Object> result : records) {
|
|
|
String[] rowValue = new String[title.size()];
|
|
|
for(int j = 0 ; j < title.size() ; j++){
|
|
|
if(title.get(j).equals("盟市")){
|
|
|
rowValue[j] = (String) result.get("REGIONNAME");
|
|
|
}
|
|
|
if(title.get(j).equals("收费站")){
|
|
|
rowValue[j] = (String) result.get("STANAME");
|
|
|
}
|
|
|
if(title.get(j).equals("绿通车数量")){
|
|
|
rowValue[j] = ((BigDecimal) result.get("GREENCOUNT")).toString();
|
|
|
}
|
|
|
if(title.get(j).equals("应收金额(元)")){
|
|
|
rowValue[j] = ((BigDecimal) result.get("FEE")).toString();
|
|
|
}
|
|
|
if(title.get(j).equals("实收金额(元)")){
|
|
|
rowValue[j] = ((BigDecimal) result.get("ACTUALFEE")).toString();
|
|
|
}
|
|
|
if(title.get(j).equals("减免金额(元)")){
|
|
|
rowValue[j] = ((BigDecimal) result.get("DERATEFEE")).toString();
|
|
|
}
|
|
|
}
|
|
|
rowValues.add(rowValue);
|
|
|
}
|
|
|
|
|
|
//设置标题单元格式
|
|
|
CellStyle cellStyleTitle = wb.createCellStyle();
|
|
|
cellStyleTitle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//设置背景色
|
|
|
cellStyleTitle.setFillPattern((short) 1);//必须设置 否则无效
|
|
|
//设置水平垂直居中
|
|
|
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
cellStyleTitle.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
// 设置边框样式
|
|
|
cellStyleTitle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
//定义标题内容
|
|
|
Row currentRow = sheet.createRow(0);
|
|
|
// 往Excel表格中添加标题的数据
|
|
|
for (int j = 0; j < title.size(); j++) {
|
|
|
// 设置列宽
|
|
|
sheet.setColumnWidth(j, 4100);
|
|
|
Cell cell = currentRow.createCell(j);
|
|
|
cell.setCellStyle(cellStyleTitle);
|
|
|
//每个单元格的值目前做 String 处理
|
|
|
//cell.setCellType(CellType.STRING);
|
|
|
cell.setCellValue(title.get(j));
|
|
|
}
|
|
|
|
|
|
|
|
|
//设置内容单元格式
|
|
|
CellStyle cellStyleValue = wb.createCellStyle();
|
|
|
//设置水平垂直居中
|
|
|
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
// 设置边框样式
|
|
|
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
//往Excel表格中添加具体数据
|
|
|
for (int i = 0; i < rowValues.size(); i++) {
|
|
|
Row Row = sheet.createRow((i+1));
|
|
|
for (int j = 0; j < title.size(); j++) {
|
|
|
// 设置列宽
|
|
|
sheet.setColumnWidth(j, 4100);
|
|
|
Cell cell = Row.createCell(j);
|
|
|
cell.setCellStyle(cellStyleValue);
|
|
|
//每个单元格的值目前做 String 处理
|
|
|
//cell.setCellType(CellType.STRING);
|
|
|
cell.setCellValue(rowValues.get(i)[j]);
|
|
|
}
|
|
|
}
|
|
|
//导出Excel
|
|
|
writeToExcel(response,wb, filename.toString());
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void exportstaCollectionExcle(String searchForm, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
//设置导出文件名称
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
Date date = new Date();
|
|
|
|
|
|
//如果传进来的参数有值,拼接参数
|
|
|
HashMap<String,Object> paramsMap = new HashMap<>();
|
|
|
if(null != searchForm && !"".equals(searchForm)){
|
|
|
paramsMap = JSON.parseObject(searchForm, HashMap.class);
|
|
|
}
|
|
|
|
|
|
|
|
|
//获取数据
|
|
|
//从配置文件中读取数据库连接类型
|
|
|
paramsMap.put("DBTYPE", PropertiesUtil.getValue("DBType"));
|
|
|
//设置分页
|
|
|
Integer pageNum = (Integer) paramsMap.get("pageNum");
|
|
|
//Integer pageSize = (Integer) paramsMap.get("pageSize");
|
|
|
Page<Map<String, Object>> page = new Page<>(pageNum,50000);
|
|
|
|
|
|
//设置排序条件
|
|
|
StringBuilder order = new StringBuilder(" order by "+paramsMap.get("orderColumn")+" "+paramsMap.get("orderType"));
|
|
|
paramsMap.put("order", order.toString());
|
|
|
logger.info("order=========="+order);
|
|
|
|
|
|
page = greenTrafficMapper.getStaDetilCollection(page, paramsMap);
|
|
|
|
|
|
|
|
|
|
|
|
//定义文件名称
|
|
|
StringBuilder filename = new StringBuilder();
|
|
|
filename.append("收费站本省跨省绿通车数据统计").append(simpleDateFormat.format(date)).append(".xlsx");
|
|
|
|
|
|
|
|
|
//读取模版文件
|
|
|
//创建Excel工作薄
|
|
|
//2. 通过POI将数据写入到Excel文件中
|
|
|
InputStream in = this.getClass().getClassLoader().getResourceAsStream("excel/staGreenCollectionExcelmod.xlsx");
|
|
|
Workbook work = ReadExcel.getWorkbook(in,"staGreenCollectionExcelmod.xlsx");
|
|
|
|
|
|
|
|
|
//如果没有数据,返回一个空的Excel
|
|
|
List<Map<String, Object>> records = page.getRecords();
|
|
|
if(null == records){
|
|
|
//导出Excel
|
|
|
writeToExcel(response,work, filename.toString());
|
|
|
}
|
|
|
|
|
|
//获取sheet页面
|
|
|
Sheet sheet = work.getSheet("绿通");
|
|
|
|
|
|
|
|
|
|
|
|
//设置内容单元格式
|
|
|
CellStyle cellStyleValue = work.createCellStyle();
|
|
|
//设置水平垂直居中
|
|
|
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
// 设置边框样式
|
|
|
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
|
|
|
//设置金额的格式
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.00");
|
|
|
|
|
|
//定义数据在Excel中的开始行数
|
|
|
int row = 2;
|
|
|
|
|
|
|
|
|
//往Excel表格中添加具体数据
|
|
|
for (int i = 0; i < records.size(); i++) {
|
|
|
// 合并第row行的前三列(A到C)
|
|
|
//sheet.addMergedRegion(new CellRangeAddress(row, row, 0, 2));
|
|
|
Row Row = sheet.createRow(row);
|
|
|
for (int j = 0; j < 10; j++) {
|
|
|
// 设置列宽
|
|
|
//sheet.setColumnWidth(j, 4100);
|
|
|
Cell cell = Row.createCell(j);
|
|
|
cell.setCellStyle(cellStyleValue);
|
|
|
//每个单元格的值目前做 String 处理
|
|
|
//cell.setCellType(CellType.STRING);
|
|
|
if(j == 0){cell.setCellValue((String) records.get(i).get("SUBCOMNAME"));}
|
|
|
if(j == 1){cell.setCellValue(records.get(i).get("REGIONNAME").toString());}
|
|
|
if(j == 2){cell.setCellValue(records.get(i).get("ROADNAME").toString());}
|
|
|
if(j == 3){cell.setCellValue(records.get(i).get("STANAME").toString());}
|
|
|
if(j == 4){cell.setCellValue(((BigDecimal) records.get(i).get("GREENCOUNT")).toString());}
|
|
|
if(j == 5){cell.setCellValue(((BigDecimal)records.get(i).get("DERATEFEETOTAL")).setScale(2, RoundingMode.HALF_UP).toString());}
|
|
|
if(j == 6){cell.setCellValue(((BigDecimal) records.get(i).get("PROVINCETOTAL")).toString());}
|
|
|
//if(j == 7){cell.setCellValue(((BigDecimal) records.get(i).get("PROVINCEDERATEFEE")).toString());}
|
|
|
if(j == 7){cell.setCellValue(((BigDecimal)records.get(i).get("PROVINCEDERATEFEE")).setScale(2, RoundingMode.HALF_UP).toString());}
|
|
|
if(j == 8){cell.setCellValue(((BigDecimal) records.get(i).get("OTHERPROVINCETOTAL")).toString());}
|
|
|
//if(j == 9){cell.setCellValue(((BigDecimal) records.get(i).get("OTHERPROVINCEDERATEFEE")).toString());}
|
|
|
if(j == 9){cell.setCellValue(((BigDecimal)records.get(i).get("OTHERPROVINCEDERATEFEE")).setScale(2, RoundingMode.HALF_UP).toString());}
|
|
|
}
|
|
|
row++;
|
|
|
}
|
|
|
|
|
|
//导出Excel
|
|
|
writeToExcel(response,work, filename.toString());
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 盟市货物统计Excel导出
|
|
|
* @param searchForm
|
|
|
* @param response
|
|
|
*/
|
|
|
@Override
|
|
|
public void exportUnionFreightCollectionExcle(String searchForm, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
//设置导出文件名称
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
Date date = new Date();
|
|
|
|
|
|
|
|
|
StringBuilder filename = new StringBuilder();
|
|
|
//定义一个标题数组
|
|
|
List<String> title = new ArrayList<>();
|
|
|
int arrayIndex = 0;
|
|
|
|
|
|
HashMap<String,Object> paramsMap = new HashMap<>();
|
|
|
|
|
|
//如果传进来的参数有值,拼接参数
|
|
|
|
|
|
if(null != searchForm && !"".equals(searchForm)){
|
|
|
paramsMap = JSON.parseObject(searchForm, HashMap.class);
|
|
|
}
|
|
|
|
|
|
//根据类型查询类型名称
|
|
|
//String typeName = greenTrafficMapper.getFreightTypeNameBYFreightTypes((Integer)paramsMap.get("freightTypeQuery"));
|
|
|
|
|
|
|
|
|
//设置文件名
|
|
|
filename.append("货物绿通车统计").append(simpleDateFormat.format(date)).append(".xlsx");
|
|
|
|
|
|
|
|
|
//从配置文件中读取数据库连接类型
|
|
|
paramsMap.put("DBTYPE", PropertiesUtil.getValue("DBType"));
|
|
|
//设置分页
|
|
|
Integer pageNum = (Integer) paramsMap.get("pageNum");
|
|
|
//Integer pageSize = (Integer) paramsMap.get("pageSize");
|
|
|
Page<Map<String, Object>> page = new Page<>(pageNum,50000);
|
|
|
|
|
|
//设置排序条件
|
|
|
StringBuilder order = new StringBuilder(" order by "+paramsMap.get("orderColumn")+" "+paramsMap.get("orderType"));
|
|
|
paramsMap.put("order", order.toString());
|
|
|
logger.info("order=========="+order);
|
|
|
|
|
|
page = greenTrafficMapper.getStaFigthTypeCollection(page,paramsMap);
|
|
|
|
|
|
|
|
|
|
|
|
//创建一个Excel表格
|
|
|
Workbook wb = new XSSFWorkbook();
|
|
|
|
|
|
|
|
|
//创建sheet页面
|
|
|
Sheet sheet = wb.createSheet("绿通");
|
|
|
|
|
|
|
|
|
//如果没有数据,返回一个空的Excel
|
|
|
List<Map<String, Object>> records = page.getRecords();
|
|
|
if(null == records){
|
|
|
//导出Excel
|
|
|
writeToExcel(response,wb, filename.toString());
|
|
|
}
|
|
|
|
|
|
|
|
|
title.add("货物类型");
|
|
|
title.add("货物绿通车数量");
|
|
|
|
|
|
|
|
|
//定义内容数据
|
|
|
List<String[]> rowValues = new ArrayList<>();
|
|
|
|
|
|
|
|
|
for (Map<String, Object> result : records) {
|
|
|
String[] rowValue = new String[title.size()];
|
|
|
for(int j = 0 ; j < title.size() ; j++){
|
|
|
if(title.get(j).equals("货物类型")){
|
|
|
rowValue[j] = (String) result.get("TEXT");
|
|
|
}
|
|
|
if(title.get(j).equals("货物绿通车数量")){
|
|
|
rowValue[j] = ((BigDecimal) result.get("REGIONFREIGHTCOUNT")).toString();
|
|
|
}
|
|
|
}
|
|
|
rowValues.add(rowValue);
|
|
|
}
|
|
|
|
|
|
//设置标题单元格式
|
|
|
CellStyle cellStyleTitle = wb.createCellStyle();
|
|
|
cellStyleTitle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//设置背景色
|
|
|
cellStyleTitle.setFillPattern((short) 1);//必须设置 否则无效
|
|
|
//设置水平垂直居中
|
|
|
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
cellStyleTitle.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
// 设置边框样式
|
|
|
cellStyleTitle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
//定义标题内容
|
|
|
Row currentRow = sheet.createRow(0);
|
|
|
// 往Excel表格中添加标题的数据
|
|
|
for (int j = 0; j < title.size(); j++) {
|
|
|
// 设置列宽
|
|
|
sheet.setColumnWidth(j, 6000);
|
|
|
Cell cell = currentRow.createCell(j);
|
|
|
cell.setCellStyle(cellStyleTitle);
|
|
|
//每个单元格的值目前做 String 处理
|
|
|
//cell.setCellType(CellType.STRING);
|
|
|
cell.setCellValue(title.get(j));
|
|
|
}
|
|
|
|
|
|
|
|
|
//设置内容单元格式
|
|
|
CellStyle cellStyleValue = wb.createCellStyle();
|
|
|
//设置水平垂直居中
|
|
|
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
// 设置边框样式
|
|
|
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
//往Excel表格中添加具体数据
|
|
|
for (int i = 0; i < rowValues.size(); i++) {
|
|
|
Row Row = sheet.createRow((i+1));
|
|
|
for (int j = 0; j < title.size(); j++) {
|
|
|
// 设置列宽
|
|
|
sheet.setColumnWidth(j, 4100);
|
|
|
Cell cell = Row.createCell(j);
|
|
|
cell.setCellStyle(cellStyleValue);
|
|
|
//每个单元格的值目前做 String 处理
|
|
|
//cell.setCellType(CellType.STRING);
|
|
|
cell.setCellValue(rowValues.get(i)[j]);
|
|
|
}
|
|
|
}
|
|
|
//导出Excel
|
|
|
writeToExcel(response,wb, filename.toString());
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void exportSingleTrackExcle(String searchForm, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
|
|
|
//设置导出文件名称
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
Date date = new Date();
|
|
|
String filename = "单车轨迹查验-" + simpleDateFormat.format(date) + ".xlsx";
|
|
|
|
|
|
HashMap<String, Object> paramsMap = new HashMap<>();
|
|
|
|
|
|
//如果传进来的参数有值,拼接参数
|
|
|
|
|
|
if (null != searchForm && !"".equals(searchForm)) {
|
|
|
paramsMap = JSON.parseObject(searchForm, HashMap.class);
|
|
|
}
|
|
|
|
|
|
//根据条件查询绿通数据
|
|
|
//从配置文件中读取数据库连接类型
|
|
|
paramsMap.put("DBTYPE", PropertiesUtil.getValue("DBType"));
|
|
|
//设置分页
|
|
|
Integer pageNum = (Integer) paramsMap.get("pageNum");
|
|
|
Integer pageSize = (Integer) paramsMap.get("pageSize");
|
|
|
//设置数据条数,不超过五万条
|
|
|
Page<Map<String,Object>> page = new Page<>(pageNum, 50000);
|
|
|
page = greenTrafficMapper.getSingleCarTrack(page, paramsMap);
|
|
|
|
|
|
|
|
|
|
|
|
//创建一个Excel表格
|
|
|
Workbook wb = new XSSFWorkbook();
|
|
|
|
|
|
|
|
|
//创建sheet页面
|
|
|
Sheet sheet = wb.createSheet("绿通");
|
|
|
|
|
|
|
|
|
//如果没有数据,返回一个空的Excel
|
|
|
List<Map<String, Object>> singleCarTrack = page.getRecords();
|
|
|
if (null == singleCarTrack) {
|
|
|
//导出Excel
|
|
|
writeToExcel(response, wb, filename);
|
|
|
}
|
|
|
|
|
|
//定义一个标题数组
|
|
|
String[] title = {"入口在", "出口站", "车道操作时间", "车牌号", "出口车种", "绿通车货物类型", "入口车种", "入口称重", "应收金额(元)",
|
|
|
"实收金额(元)", "减免金额(元)"};
|
|
|
|
|
|
//设置金额的格式
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.00");
|
|
|
|
|
|
//设置统计时间日期格式
|
|
|
SimpleDateFormat simpleDateFormatClassData = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
SimpleDateFormat simpleDateFormatDt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
//定义内容数据
|
|
|
List<String[]> rowValues = new ArrayList<>();
|
|
|
for (Map<String, Object> result : singleCarTrack) {
|
|
|
String[] rowValue = new String[title.length];
|
|
|
for(int j = 0 ; j < title.length ; j++){
|
|
|
if(title[j].equals("入口在")){
|
|
|
rowValue[j] = (String) result.get("ENTOLLSTATIONNAME");
|
|
|
}
|
|
|
if(title[j].equals("出口站")){
|
|
|
rowValue[j] = (String) result.get("EXTOLLSTATIONNAME");
|
|
|
}
|
|
|
if(title[j].equals("车道操作时间")){
|
|
|
rowValue[j] = simpleDateFormatDt.format(((Timestamp) result.get("DT")));
|
|
|
}
|
|
|
if(title[j].equals("车牌号")){
|
|
|
rowValue[j] = ((String) result.get("ACARNO")).toString();
|
|
|
}
|
|
|
if(title[j].equals("出口车种")){
|
|
|
rowValue[j] = ((String) result.get("OUTKINDNAME")).toString();
|
|
|
}
|
|
|
if(title[j].equals("绿通车货物类型")){
|
|
|
rowValue[j] = result.get("FREIGHTTYPENAME") != null ?((String) result.get("FREIGHTTYPENAME")).toString():"";
|
|
|
}
|
|
|
if(title[j].equals("入口车种")){
|
|
|
rowValue[j] = ((String) result.get("INKINDNAME")).toString();
|
|
|
}
|
|
|
if(title[j].equals("入口称重")){
|
|
|
rowValue[j] = ((BigDecimal) result.get("ININWEIGHT")).toString();
|
|
|
}
|
|
|
|
|
|
BigDecimal cash = (BigDecimal) result.get("CASH");
|
|
|
BigDecimal inCash = (BigDecimal) result.get("INCASH");
|
|
|
BigDecimal payCash = (BigDecimal) result.get("PAYCASH");
|
|
|
|
|
|
if(title[j].equals("应收金额(元)")){
|
|
|
rowValue[j] = cash.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
}
|
|
|
if(title[j].equals("实收金额(元)")){
|
|
|
rowValue[j] = inCash.add(payCash).setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
}
|
|
|
if(title[j].equals("减免金额(元)")){
|
|
|
rowValue[j] = cash.subtract(inCash.add(payCash)).setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
}
|
|
|
}
|
|
|
rowValues.add(rowValue);
|
|
|
}
|
|
|
|
|
|
//设置标题单元格式
|
|
|
CellStyle cellStyleTitle = wb.createCellStyle();
|
|
|
cellStyleTitle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//设置背景色
|
|
|
cellStyleTitle.setFillPattern((short) 1);//必须设置 否则无效
|
|
|
//设置水平垂直居中
|
|
|
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
cellStyleTitle.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
// 设置边框样式
|
|
|
cellStyleTitle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
//定义标题内容
|
|
|
Row currentRow = sheet.createRow(0);
|
|
|
// 往Excel表格中添加标题的数据
|
|
|
for (int j = 0; j < title.length; j++) {
|
|
|
// 设置列宽
|
|
|
sheet.setColumnWidth(j, 4100);
|
|
|
Cell cell = currentRow.createCell(j);
|
|
|
cell.setCellStyle(cellStyleTitle);
|
|
|
//每个单元格的值目前做 String 处理
|
|
|
//cell.setCellType(CellType.STRING);
|
|
|
cell.setCellValue(title[j]);
|
|
|
}
|
|
|
|
|
|
|
|
|
//设置内容单元格式
|
|
|
CellStyle cellStyleValue = wb.createCellStyle();
|
|
|
//设置水平垂直居中
|
|
|
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
// 设置边框样式
|
|
|
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
//往Excel表格中添加具体数据
|
|
|
for (int i = 0; i < rowValues.size(); i++) {
|
|
|
Row Row = sheet.createRow((i + 1));
|
|
|
for (int j = 0; j < title.length; j++) {
|
|
|
// 设置列宽
|
|
|
sheet.setColumnWidth(j, 4100);
|
|
|
Cell cell = Row.createCell(j);
|
|
|
cell.setCellStyle(cellStyleValue);
|
|
|
//每个单元格的值目前做 String 处理
|
|
|
//cell.setCellType(CellType.STRING);
|
|
|
cell.setCellValue(rowValues.get(i)[j]);
|
|
|
}
|
|
|
}
|
|
|
//导出Excel
|
|
|
writeToExcel(response, wb, filename);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void exportUnionTotalExcle(String searchForm, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
//设置导出文件名称
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
Date date = new Date();
|
|
|
String filename = "盟市绿通数据统计-" + simpleDateFormat.format(date) + ".xlsx";
|
|
|
|
|
|
HashMap<String, Object> paramsMap = new HashMap<>();
|
|
|
|
|
|
//如果传进来的参数有值,拼接参数
|
|
|
|
|
|
if (null != searchForm && !"".equals(searchForm)) {
|
|
|
paramsMap = JSON.parseObject(searchForm, HashMap.class);
|
|
|
}
|
|
|
|
|
|
//根据条件查询绿通数据
|
|
|
//从配置文件中读取数据库连接类型
|
|
|
paramsMap.put("DBTYPE", PropertiesUtil.getValue("DBType"));
|
|
|
//设置分页
|
|
|
Integer pageNum = (Integer) paramsMap.get("pageNum");
|
|
|
//Integer pageSize = (Integer) paramsMap.get("pageSize");
|
|
|
//设置数据条数,不超过五万条
|
|
|
Page<GreenTraffic> page = new Page<>(pageNum, 50000);
|
|
|
List<Map<String, Object>> maps = greenTrafficMapper.getGreenTrafficListGroupByUnionName(paramsMap);
|
|
|
|
|
|
|
|
|
|
|
|
//创建一个Excel表格
|
|
|
Workbook wb = new XSSFWorkbook();
|
|
|
|
|
|
|
|
|
//创建sheet页面
|
|
|
Sheet sheet = wb.createSheet("绿通");
|
|
|
|
|
|
|
|
|
//如果没有数据,返回一个空的Excel
|
|
|
//List<GreenTraffic> records = page.getRecords();
|
|
|
if (null == maps) {
|
|
|
//导出Excel
|
|
|
writeToExcel(response, wb, filename);
|
|
|
}
|
|
|
|
|
|
//定义一个标题数组
|
|
|
String[] title = {"盟市", "绿通车数量", "减免金额(元)"};
|
|
|
|
|
|
//设置金额的格式
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.00");
|
|
|
//设置统计时间日期格式
|
|
|
SimpleDateFormat simpleDateFormatClassData = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
SimpleDateFormat simpleDateFormatDt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
//定义内容数据
|
|
|
List<String[]> rowValues = new ArrayList<>();
|
|
|
for (Map<String, Object> greenTraffic : maps) {
|
|
|
String[] rowValue = {
|
|
|
null == greenTraffic.get("REGIONNAME") ? "" : greenTraffic.get("REGIONNAME").toString(),
|
|
|
null == greenTraffic.get("COUNTNUM") ? "" : ((BigDecimal)greenTraffic.get("COUNTNUM")).toString(),
|
|
|
null == greenTraffic.get("DERATEFEETOTAL") ? "" : ((BigDecimal)greenTraffic.get("DERATEFEETOTAL")).setScale(2, RoundingMode.HALF_UP).toString(),
|
|
|
};
|
|
|
rowValues.add(rowValue);
|
|
|
}
|
|
|
|
|
|
//设置标题单元格式
|
|
|
CellStyle cellStyleTitle = wb.createCellStyle();
|
|
|
cellStyleTitle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//设置背景色
|
|
|
cellStyleTitle.setFillPattern((short) 1);//必须设置 否则无效
|
|
|
//设置水平垂直居中
|
|
|
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
cellStyleTitle.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
// 设置边框样式
|
|
|
cellStyleTitle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
//定义标题内容
|
|
|
Row currentRow = sheet.createRow(0);
|
|
|
// 往Excel表格中添加标题的数据
|
|
|
for (int j = 0; j < title.length; j++) {
|
|
|
// 设置列宽
|
|
|
sheet.setColumnWidth(j, 4100);
|
|
|
Cell cell = currentRow.createCell(j);
|
|
|
cell.setCellStyle(cellStyleTitle);
|
|
|
//每个单元格的值目前做 String 处理
|
|
|
//cell.setCellType(CellType.STRING);
|
|
|
cell.setCellValue(title[j]);
|
|
|
}
|
|
|
|
|
|
|
|
|
//设置内容单元格式
|
|
|
CellStyle cellStyleValue = wb.createCellStyle();
|
|
|
//设置水平垂直居中
|
|
|
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
// 设置边框样式
|
|
|
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
//往Excel表格中添加具体数据
|
|
|
for (int i = 0; i < rowValues.size(); i++) {
|
|
|
Row Row = sheet.createRow((i + 1));
|
|
|
for (int j = 0; j < title.length; j++) {
|
|
|
// 设置列宽
|
|
|
sheet.setColumnWidth(j, 4100);
|
|
|
Cell cell = Row.createCell(j);
|
|
|
cell.setCellStyle(cellStyleValue);
|
|
|
//每个单元格的值目前做 String 处理
|
|
|
//cell.setCellType(CellType.STRING);
|
|
|
cell.setCellValue(rowValues.get(i)[j]);
|
|
|
}
|
|
|
}
|
|
|
//导出Excel
|
|
|
writeToExcel(response, wb, filename);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void exportSubComTotalExcle(String searchForm, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
//设置导出文件名称
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
Date date = new Date();
|
|
|
String filename = "分公司绿通数据统计-" + simpleDateFormat.format(date) + ".xlsx";
|
|
|
|
|
|
HashMap<String, Object> paramsMap = new HashMap<>();
|
|
|
|
|
|
//如果传进来的参数有值,拼接参数
|
|
|
|
|
|
if (null != searchForm && !"".equals(searchForm)) {
|
|
|
paramsMap = JSON.parseObject(searchForm, HashMap.class);
|
|
|
}
|
|
|
|
|
|
//根据条件查询绿通数据
|
|
|
//从配置文件中读取数据库连接类型
|
|
|
paramsMap.put("DBTYPE", PropertiesUtil.getValue("DBType"));
|
|
|
//设置分页
|
|
|
Integer pageNum = (Integer) paramsMap.get("pageNum");
|
|
|
//Integer pageSize = (Integer) paramsMap.get("pageSize");
|
|
|
//设置数据条数,不超过五万条
|
|
|
Page<GreenTraffic> page = new Page<>(pageNum, 50000);
|
|
|
List<Map<String, Object>> maps = greenTrafficMapper.getGreenTrafficListGroupBySubCom(paramsMap);
|
|
|
|
|
|
|
|
|
|
|
|
//创建一个Excel表格
|
|
|
Workbook wb = new XSSFWorkbook();
|
|
|
|
|
|
|
|
|
//创建sheet页面
|
|
|
Sheet sheet = wb.createSheet("绿通");
|
|
|
|
|
|
|
|
|
//如果没有数据,返回一个空的Excel
|
|
|
//List<GreenTraffic> records = page.getRecords();
|
|
|
if (null == maps) {
|
|
|
//导出Excel
|
|
|
writeToExcel(response, wb, filename);
|
|
|
}
|
|
|
|
|
|
|
|
|
//定义一个标题数组
|
|
|
String[] title = {"分公司", "绿通车数量", "减免金额(元)"};
|
|
|
|
|
|
//设置金额的格式
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.00");
|
|
|
//设置统计时间日期格式
|
|
|
SimpleDateFormat simpleDateFormatClassData = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
SimpleDateFormat simpleDateFormatDt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
//定义内容数据
|
|
|
List<String[]> rowValues = new ArrayList<>();
|
|
|
for (Map<String, Object> greenTraffic : maps) {
|
|
|
String[] rowValue = {
|
|
|
null == greenTraffic.get("SUBCOMNAME") ? "" : greenTraffic.get("SUBCOMNAME").toString(),
|
|
|
null == greenTraffic.get("COUNTNUM") ? "" : ((BigDecimal)greenTraffic.get("COUNTNUM")).toString(),
|
|
|
null == greenTraffic.get("DERATEFEETOTAL") ? "" : ((BigDecimal)greenTraffic.get("DERATEFEETOTAL")).setScale(2, RoundingMode.HALF_UP).toString(),
|
|
|
};
|
|
|
rowValues.add(rowValue);
|
|
|
}
|
|
|
|
|
|
//设置标题单元格式
|
|
|
CellStyle cellStyleTitle = wb.createCellStyle();
|
|
|
cellStyleTitle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//设置背景色
|
|
|
cellStyleTitle.setFillPattern((short) 1);//必须设置 否则无效
|
|
|
//设置水平垂直居中
|
|
|
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
cellStyleTitle.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
// 设置边框样式
|
|
|
cellStyleTitle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleTitle.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
//定义标题内容
|
|
|
Row currentRow = sheet.createRow(0);
|
|
|
// 往Excel表格中添加标题的数据
|
|
|
for (int j = 0; j < title.length; j++) {
|
|
|
// 设置列宽
|
|
|
sheet.setColumnWidth(j, 4100);
|
|
|
Cell cell = currentRow.createCell(j);
|
|
|
cell.setCellStyle(cellStyleTitle);
|
|
|
//每个单元格的值目前做 String 处理
|
|
|
//cell.setCellType(CellType.STRING);
|
|
|
cell.setCellValue(title[j]);
|
|
|
}
|
|
|
|
|
|
|
|
|
//设置内容单元格式
|
|
|
CellStyle cellStyleValue = wb.createCellStyle();
|
|
|
//设置水平垂直居中
|
|
|
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
// 设置边框样式
|
|
|
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
//往Excel表格中添加具体数据
|
|
|
for (int i = 0; i < rowValues.size(); i++) {
|
|
|
Row Row = sheet.createRow((i + 1));
|
|
|
for (int j = 0; j < title.length; j++) {
|
|
|
// 设置列宽
|
|
|
sheet.setColumnWidth(j, 4100);
|
|
|
Cell cell = Row.createCell(j);
|
|
|
cell.setCellStyle(cellStyleValue);
|
|
|
//每个单元格的值目前做 String 处理
|
|
|
//cell.setCellType(CellType.STRING);
|
|
|
cell.setCellValue(rowValues.get(i)[j]);
|
|
|
}
|
|
|
}
|
|
|
//导出Excel
|
|
|
writeToExcel(response, wb, filename);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 把Excel写到response里,返回前端
|
|
|
* @param response
|
|
|
* @param wb
|
|
|
* @param fileName
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void writeToExcel(HttpServletResponse response, Workbook wb, String fileName) throws Exception {
|
|
|
OutputStream os = null;
|
|
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
response.setCharacterEncoding(Charsets.UTF_8.name());
|
|
|
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
|
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; filename=%s", new String(URLEncoder.encode(fileName, Charsets.UTF_8.name())
|
|
|
.getBytes(Charsets.UTF_8), Charsets.ISO_8859_1)));
|
|
|
os = response.getOutputStream();
|
|
|
wb.write(os);
|
|
|
os.flush();
|
|
|
}
|
|
|
}
|