use of com.itrus.portal.utils.ExcelFileGenerator in project portal by ixinportal.
the class BillReceiptController method excelExport2.
// 导出已开票的Excel
@RequestMapping(value = "/excel2")
public String excelExport2(@RequestParam(value = "billNo", required = false) String billNo, @RequestParam(value = "projectName", required = false) String projectName, @RequestParam(value = "enterpriseName", required = false) String enterpriseName, @RequestParam(value = "queryDate12", required = false) Date queryDate12, @RequestParam(value = "queryDate22", required = false) Date queryDate22, @RequestParam(value = "queryDate3", required = false) Date queryDate3, @RequestParam(value = "queryDate4", required = false) Date queryDate4, @RequestParam(value = "queryDate5", required = false) Date queryDate5, @RequestParam(value = "queryDate6", required = false) Date queryDate6, @RequestParam(value = "type", required = false) String type, @RequestParam(value = "idNo", required = false) String idNo, HttpServletRequest request, HttpServletResponse response) {
Map param = new HashMap();
// 管理员项目权限
Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
param.put("hasProjects", Arrays.asList(projectsOfAdmin));
if (org.apache.commons.lang3.StringUtils.isNotEmpty(billNo)) {
param.put("billNo2", "%" + billNo + "%");
}
param.put("type2", type);
if (org.apache.commons.lang3.StringUtils.isNotEmpty(idNo)) {
param.put("idNo2", "%" + idNo + "%");
}
if (org.apache.commons.lang3.StringUtils.isNotEmpty(projectName)) {
param.put("projectName2", "%" + projectName + "%");
}
if (org.apache.commons.lang3.StringUtils.isNotEmpty(enterpriseName)) {
param.put("enterpriseName2", "%" + enterpriseName + "%");
}
param.put("queryDate12", queryDate12);
param.put("queryDate22", queryDate22);
param.put("queryDate3", queryDate3);
param.put("queryDate4", queryDate4);
param.put("queryDate5", queryDate5);
param.put("queryDate6", queryDate6);
List<Map> billexall = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByBillReceipt2", param);
ArrayList<String> fieldName = billReceiptService.excelFieldName2();
ArrayList<ArrayList<String>> fieldDatas = billReceiptService.excelFieldData2(billexall);
ExcelFileGenerator generator = new ExcelFileGenerator(fieldName, fieldDatas);
try {
// 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
response.reset();
String filename = "已开票信息" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + // 设置下载时客户端Excel的名称,此处需要用到encodeFilename()方法来转换编码,否则中文会被过滤掉
".xls";
filename = generator.encodeFilename(filename, request);
response.setHeader("Content-disposition", "attachment;filename=" + filename);
response.setCharacterEncoding("utf-8");
// 由于导出格式是excel的文件,设置导出文件的响应头部信息
response.setContentType("application/vnd.ms-excel");
// 生成excel,传递输出流
// 用response对象获取输出流
OutputStream os = response.getOutputStream();
generator.expordExcel(os);
// 清理刷新缓冲区,将缓存中的数据将数据导出excel
os.flush();
// 关闭os
if (os != null) {
os.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.itrus.portal.utils.ExcelFileGenerator in project portal by ixinportal.
the class BillReceiptController method exceldzfpExport.
// 导出电票Excel
@RequestMapping(value = "/exceldzfp")
public String exceldzfpExport(@RequestParam(value = "billNo", required = false) String billNo, @RequestParam(value = "projectName", required = false) String projectName, @RequestParam(value = "enterpriseName", required = false) String enterpriseName, @RequestParam(value = "cost", required = false) Integer cost, @RequestParam(value = "queryDate1", required = false) Date queryDate1, @RequestParam(value = "queryDate2", required = false) Date queryDate2, HttpServletRequest request, HttpServletResponse response) {
Map param = new HashMap();
// 管理员项目权限
Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
param.put("hasProjects", Arrays.asList(projectsOfAdmin));
if (org.apache.commons.lang3.StringUtils.isNotEmpty(billNo)) {
param.put("billNo", "%" + billNo + "%");
}
if (org.apache.commons.lang3.StringUtils.isNotEmpty(projectName)) {
param.put("projectName", "%" + projectName + "%");
}
if (org.apache.commons.lang3.StringUtils.isNotEmpty(enterpriseName)) {
param.put("enterpriseName", "%" + enterpriseName + "%");
}
param.put("queryDate1", queryDate1);
param.put("queryDate2", queryDate2);
List<Map> billexall = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByBillEreceipt", param);
ArrayList<String> fieldName = billReceiptService.excelFieldName();
ArrayList<ArrayList<String>> fieldDatas = billReceiptService.exceldzfpFieldData(billexall);
ExcelFileGenerator generator = new ExcelFileGenerator(fieldName, fieldDatas);
try {
// 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
response.reset();
String filename = "凭证电票开票信息" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + // 设置下载时客户端Excel的名称,此处需要用到encodeFilename()方法来转换编码,否则中文会被过滤掉
".xls";
filename = generator.encodeFilename(filename, request);
response.setHeader("Content-disposition", "attachment;filename=" + filename);
response.setCharacterEncoding("utf-8");
// 由于导出格式是excel的文件,设置导出文件的响应头部信息
response.setContentType("application/vnd.ms-excel");
// 生成excel,传递输出流
// 用response对象获取输出流
OutputStream os = response.getOutputStream();
generator.expordExcel(os);
// 清理刷新缓冲区,将缓存中的数据将数据导出excel
os.flush();
// 关闭os
if (os != null) {
os.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.itrus.portal.utils.ExcelFileGenerator in project portal by ixinportal.
the class QueryBillController method excelExport.
// 导出Excel
@RequestMapping(value = "/excel")
public String excelExport(@RequestParam(value = "sn", required = false) String sn, @RequestParam(value = "projectname", required = false) String projectname, @RequestParam(value = "entname", required = false) String entname, @RequestParam(value = "cost", required = false) Integer cost, @RequestParam(value = "queryDate1", required = false) Date queryDate1, @RequestParam(value = "queryDate2", required = false) Date queryDate2, @RequestParam(value = "type1", required = false) Integer type1, @RequestParam(value = "name", required = false) String name, @RequestParam(value = "phone", required = false) String phone, @RequestParam(value = "status", required = false) Integer status, HttpServletRequest request, HttpServletResponse response) {
Map param = new HashMap();
// 管理员项目权限
Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
param.put("hasProjects", Arrays.asList(projectsOfAdmin));
if (StringUtils.isNotEmpty(sn)) {
param.put("sn", "%" + sn + "%");
}
param.put("queryDate1", queryDate1);
param.put("queryDate2", queryDate2);
if (StringUtils.isNotEmpty(projectname)) {
param.put("projectname", "%" + projectname + "%");
}
if (StringUtils.isNotEmpty(entname)) {
param.put("entname", "%" + entname + "%");
}
param.put("type", type1);
if (StringUtils.isNotEmpty(name)) {
param.put("name", "%" + name + "%");
}
if (StringUtils.isNotEmpty(phone)) {
param.put("phone", "%" + phone + "%");
}
param.put("status", status);
param.put("desc", 1);
List<Map> billexall = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByCondition", param);
ArrayList<String> fieldName = billservice.excelFildName();
ArrayList<ArrayList<String>> fieldDatas = billservice.excelFildData(billexall);
ExcelFileGenerator generator = new ExcelFileGenerator(fieldName, fieldDatas);
try {
// 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
response.reset();
// 设置下载时客户端Excel的名称,此处需要用到encodeFilename()方法来转换编码,否则中文会被过滤掉
String filename = "用户信息" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".xls";
filename = generator.encodeFilename(filename, request);
response.setHeader("Content-disposition", "attachment;filename=" + filename);
response.setCharacterEncoding("utf-8");
// 由于导出格式是excel的文件,设置导出文件的响应头部信息
response.setContentType("application/vnd.ms-excel");
// 生成excel,传递输出流
// 用response对象获取输出流
OutputStream os = response.getOutputStream();
generator.expordExcel(os);
// 清理刷新缓冲区,将缓存中的数据将数据导出excel
os.flush();
// 关闭os
if (os != null) {
os.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.itrus.portal.utils.ExcelFileGenerator in project portal by ixinportal.
the class SignStatsController method excelExport.
// 导出Excel
@RequestMapping(value = "/excel")
public String excelExport(@RequestParam(value = "cycle_sel", required = false) Integer cycle, @RequestParam(value = "projectName", required = false) Long projectName, @RequestParam(value = "year1_sel", required = false) Integer year1, @RequestParam(value = "year2_sel", required = false) Integer year2, Model uiModel, HttpServletRequest request, HttpServletResponse response) throws Exception {
Map param = new HashMap();
Map param2 = new HashMap();
Integer year3 = null;
if (year1 != null) {
year3 = year1;
}
List<Map<Integer, Integer>> list = new ArrayList<Map<Integer, Integer>>();
java.util.Date nowdate = new java.util.Date();
String[] monthList = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
String[] seasonList = { "S1", "S2", "S3", "S4" };
String month = null;
String season = null;
String year = null;
Calendar calendar = Calendar.getInstance();
Calendar calendar2 = Calendar.getInstance();
String projectName1 = null;
if (null != cycle && cycle == 12) {
while (year1 <= year2) {
for (int j = 0; j <= 11; j++) {
calendar.set(Calendar.YEAR, year1);
calendar.set(Calendar.MONTH, j);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
// calendar.add(Calendar.MILLISECOND, -1);
Date dt1 = calendar.getTime();
calendar2.set(Calendar.YEAR, year1);
calendar2.set(Calendar.MONTH, j + 1);
calendar2.set(Calendar.DAY_OF_MONTH, 1);
calendar2.set(Calendar.HOUR_OF_DAY, 0);
calendar2.set(Calendar.MINUTE, 0);
calendar2.set(Calendar.SECOND, 0);
calendar2.set(Calendar.MILLISECOND, 0);
// calendar2.add(Calendar.MILLISECOND, -1);
Date dt2 = calendar2.getTime();
if (projectName != null && projectName != 0) {
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectName);
projectName1 = project.getName();
param.put("projectName", projectName);
}
param2.put("projectName", projectName);
if (dt2.before(nowdate)) {
month = year1 + "-" + monthList[j];
param2.put("month", month);
SignStatsRecord ssr = sqlSession.selectOne("com.itrus.portal.db.SignStatsRecordMapper.selectByMonth1", param2);
if (null != ssr) {
Integer count = ssr.getCount1();
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.SignRecordMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
SignStatsRecord ssr2 = new SignStatsRecord();
ssr2.setMonth1(month);
ssr2.setProjectId(projectName);
ssr2.setCount1(count);
ssr2.setCreateTime(new Date());
sqlSession.insert("com.itrus.portal.db.SignStatsRecordMapper.insert", ssr2);
}
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.SignRecordMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
}
}
year1++;
}
}
if (null != cycle && cycle == 4) {
while (year1 <= year2) {
for (int j = 0; j <= 9; j = j + 3) {
calendar.set(Calendar.YEAR, year1);
calendar.set(Calendar.MONTH, j);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
// calendar.add(Calendar.MILLISECOND, -1);
Date dt1 = calendar.getTime();
calendar2.set(Calendar.YEAR, year1);
calendar2.set(Calendar.MONTH, j + 3);
calendar2.set(Calendar.DAY_OF_MONTH, 1);
calendar2.set(Calendar.HOUR_OF_DAY, 0);
calendar2.set(Calendar.MINUTE, 0);
calendar2.set(Calendar.SECOND, 0);
calendar2.set(Calendar.MILLISECOND, 0);
// calendar2.add(Calendar.MILLISECOND, -1);
Date dt2 = calendar2.getTime();
if (projectName != null && projectName != 0) {
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectName);
projectName1 = project.getName();
param.put("projectName", projectName);
}
param2.put("projectName", projectName);
if (dt2.before(nowdate)) {
season = year1 + "-" + seasonList[j / 3];
param2.put("season", season);
SignStatsRecord ssr = sqlSession.selectOne("com.itrus.portal.db.SignStatsRecordMapper.selectBySeason1", param2);
if (null != ssr) {
Integer count = ssr.getCount1();
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.SignRecordMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
SignStatsRecord ssr2 = new SignStatsRecord();
ssr2.setSeason1(season);
ssr2.setProjectId(projectName);
ssr2.setCount1(count);
ssr2.setCreateTime(new Date());
sqlSession.insert("com.itrus.portal.db.SignStatsRecordMapper.insert", ssr2);
}
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.SignRecordMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
}
}
year1++;
}
}
if (null != cycle && cycle == 1) {
while (year1 <= year2) {
calendar.set(Calendar.YEAR, year1);
calendar.set(Calendar.MONTH, 0);
calendar.set(Calendar.DATE, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
// calendar.add(Calendar.MILLISECOND, -1);
Date dt1 = calendar.getTime();
calendar2.set(Calendar.YEAR, year1 + 1);
calendar2.set(Calendar.MONTH, 0);
calendar2.set(Calendar.DAY_OF_MONTH, 1);
calendar2.set(Calendar.HOUR_OF_DAY, 0);
calendar2.set(Calendar.MINUTE, 0);
calendar2.set(Calendar.SECOND, 0);
calendar2.set(Calendar.MILLISECOND, 0);
// calendar2.add(Calendar.MILLISECOND, -1);
Date dt2 = calendar2.getTime();
if (projectName != null && projectName != 0) {
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectName);
projectName1 = project.getName();
param.put("projectName", projectName);
}
param2.put("projectName", projectName);
if (dt2.before(nowdate)) {
year = year1 + "Y";
param2.put("year", year);
SignStatsRecord ssr = sqlSession.selectOne("com.itrus.portal.db.SignStatsRecordMapper.selectByYear1", param2);
if (null != ssr) {
Integer count = ssr.getCount1();
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.SignRecordMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
SignStatsRecord ssr2 = new SignStatsRecord();
ssr2.setYear1(year);
ssr2.setProjectId(projectName);
ssr2.setCount1(count);
ssr2.setCreateTime(new Date());
sqlSession.insert("com.itrus.portal.db.SignStatsRecordMapper.insert", ssr2);
}
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.SignRecordMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
}
year1++;
}
}
if (null == projectName || 0 == projectName) {
projectName1 = "所有项目";
}
ArrayList<String> fieldName = signStatsService.excelFieldName();
ArrayList<ArrayList<String>> fieldDatas = signStatsService.excelFieldData(list, projectName1, cycle);
ExcelFileGenerator generator = new ExcelFileGenerator(fieldName, fieldDatas);
try {
// 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
response.reset();
String filename = "签名统计信息" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + // 设置下载时客户端Excel的名称,此处需要用到encodeFilename()方法来转换编码,否则中文会被过滤掉
".xls";
filename = generator.encodeFilename(filename, request);
response.setHeader("Content-disposition", "attachment;filename=" + filename);
response.setCharacterEncoding("utf-8");
// 由于导出格式是excel的文件,设置导出文件的响应头部信息
response.setContentType("application/vnd.ms-excel");
// 生成excel,传递输出流
// 用response对象获取输出流
OutputStream os = response.getOutputStream();
generator.expordExcel(os);
// 清理刷新缓冲区,将缓存中的数据将数据导出excel
os.flush();
// 关闭os
if (os != null) {
os.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.itrus.portal.utils.ExcelFileGenerator in project portal by ixinportal.
the class StatisticsdepositaryController method excelExport.
/**
* 存证统计导出
* @param servicePlatformName
* @param Statistics
* @param year1
* @param year2
* @param page
* @param size
* @param serviceName
* @param type
* @param serviceClientName
* @param uiModel
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping(value = "/excel")
public String excelExport(@RequestParam(value = "servicePlatformName", required = false) String servicePlatformName, @RequestParam(value = "Statistics", required = false) Integer Statistics, @RequestParam(value = "year1", required = false) Integer year1, @RequestParam(value = "year2", required = false) Integer year2, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "serviceName", required = false) String serviceName, @RequestParam(value = "type", required = false) String type, @RequestParam(value = "serviceClientName", required = false) String serviceClientName, Model uiModel, HttpServletRequest request, HttpServletResponse response) throws Exception {
Map param = new HashMap();
Integer year3 = null;
if (year1 != null) {
year3 = year1;
}
List<Map<Integer, Integer>> list = new ArrayList<Map<Integer, Integer>>();
java.util.Date nowdate = new java.util.Date();
String[] monthList = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
String[] seasonList = { "S1", "S2", "S3", "S4" };
String month = null;
String season = null;
String year = null;
Calendar calendar = Calendar.getInstance();
Calendar calendar2 = Calendar.getInstance();
if (null != Statistics && Statistics == 12) {
while (year1 <= year2) {
for (int j = 0; j <= 11; j++) {
calendar.set(Calendar.YEAR, year1);
calendar.set(Calendar.MONTH, j);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date dt1 = calendar.getTime();
calendar2.set(Calendar.YEAR, year1);
calendar2.set(Calendar.MONTH, j + 1);
calendar2.set(Calendar.DAY_OF_MONTH, 1);
calendar2.set(Calendar.HOUR_OF_DAY, 0);
calendar2.set(Calendar.MINUTE, 0);
calendar2.set(Calendar.SECOND, 0);
calendar2.set(Calendar.MILLISECOND, 0);
Date dt2 = calendar2.getTime();
if (StringUtils.isNotEmpty(servicePlatformName) && !"0".equals(servicePlatformName)) {
param.put("servicePlatformName", servicePlatformName);
}
if (StringUtils.isNotEmpty(serviceName)) {
param.put("serviceName", "%" + serviceName + "%");
}
if (type != null && !"0".equals(type)) {
param.put("type", type);
}
if (serviceClientName != null && !"0".equals(serviceClientName)) {
param.put("serviceClientName", serviceClientName);
}
month = year1 + "-" + monthList[j];
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = basicInformationimpl.selectcount(param);
int sum = 0;
System.out.println("count=" + count);
if (count != 0) {
sum = basicInformationimpl.selectsize(param);
}
System.out.println("sum=" + sum);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(1, year1);
map.put(2, count);
map.put(3, sum);
list.add(map);
}
year1++;
}
}
if (null != Statistics && Statistics == 4) {
while (year1 <= year2) {
for (int j = 0; j <= 9; j = j + 3) {
calendar.set(Calendar.YEAR, year1);
calendar.set(Calendar.MONTH, j);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date dt1 = calendar.getTime();
calendar2.set(Calendar.YEAR, year1);
calendar2.set(Calendar.MONTH, j + 3);
calendar2.set(Calendar.DAY_OF_MONTH, 1);
calendar2.set(Calendar.HOUR_OF_DAY, 0);
calendar2.set(Calendar.MINUTE, 0);
calendar2.set(Calendar.SECOND, 0);
calendar2.set(Calendar.MILLISECOND, 0);
Date dt2 = calendar2.getTime();
if (StringUtils.isNotEmpty(servicePlatformName) && !"0".equals(servicePlatformName)) {
param.put("serviceRequestPlatform", servicePlatformName);
}
if (serviceName != null && !"0".equals(serviceName)) {
param.put("serviceName", "%" + serviceName + "%");
}
if (type != null && !"0".equals(type)) {
param.put("type", type);
}
if (serviceClientName != null && !"0".equals(serviceClientName)) {
param.put("serviceClientName", serviceClientName);
}
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = basicInformationimpl.selectcount(param);
int sum = 0;
System.out.println("count=" + count);
if (count != 0) {
sum = basicInformationimpl.selectsize(param);
}
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(1, year1);
map.put(2, count);
map.put(3, sum);
list.add(map);
}
year1++;
}
}
if (null != Statistics && Statistics == 1) {
while (year1 <= year2) {
calendar.set(Calendar.YEAR, year1);
calendar.set(Calendar.MONTH, 0);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date dt1 = calendar.getTime();
calendar2.set(Calendar.YEAR, year1 + 1);
calendar2.set(Calendar.MONTH, 0);
calendar2.set(Calendar.DAY_OF_MONTH, 1);
calendar2.set(Calendar.HOUR_OF_DAY, 0);
calendar2.set(Calendar.MINUTE, 0);
calendar2.set(Calendar.SECOND, 0);
calendar2.set(Calendar.MILLISECOND, 0);
Date dt2 = calendar2.getTime();
if (StringUtils.isNotEmpty(servicePlatformName) && !"0".equals(servicePlatformName)) {
param.put("serviceRequestPlatform", servicePlatformName);
}
if (serviceName != null && !"0".equals(serviceName)) {
param.put("serviceName", "%" + serviceName + "%");
}
if (type != null && !"0".equals(type)) {
param.put("type", type);
}
if (serviceClientName != null && !"0".equals(serviceClientName)) {
param.put("serviceClientName", serviceClientName);
}
year = year + "Y";
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = basicInformationimpl.selectcount(param);
int sum = 0;
System.out.println("count=" + count);
if (count != 0) {
sum = basicInformationimpl.selectsize(param);
}
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(1, year1);
map.put(2, count);
map.put(3, sum);
list.add(map);
year1++;
}
}
/* List appservice = applicationInfoService.selectByExample(new ApplicationInfoExample());
uiModel.addAttribute("appservice", appservice);*/
List<EvidenceBasicInformation> basicinfo = basicInformationimpl.selectList();
uiModel.addAttribute("basicinfo", basicinfo);
if (null == servicePlatformName || "0".equals(servicePlatformName)) {
servicePlatformName = "所有应用";
}
uiModel.addAttribute("list", list);
// System.out.println(list);
uiModel.addAttribute("year1", year3);
uiModel.addAttribute("serviceRequestPlatform", servicePlatformName);
uiModel.addAttribute("year2", year2);
uiModel.addAttribute("Statistics", Statistics);
uiModel.addAttribute("serviceName", serviceName);
uiModel.addAttribute("type", type);
uiModel.addAttribute("serviceClientName", serviceClientName);
ArrayList<String> fieldName = statisticsdepositary.excelFieldName();
ArrayList<ArrayList<String>> fieldDatas = statisticsdepositary.excelFieldData(list, servicePlatformName, serviceName, type, serviceClientName, Statistics);
ExcelFileGenerator generator = new ExcelFileGenerator(fieldName, fieldDatas);
try {
// 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
response.reset();
// 设置下载时客户端Excel的名称,此处需要用到encodeFilename()方法来转换编码,否则中文会被过滤掉
String filename = "存证服务统计信息" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".xls";
filename = generator.encodeFilename(filename, request);
response.setHeader("Content-disposition", "attachment;filename=" + filename);
response.setCharacterEncoding("utf-8");
// 由于导出格式是excel的文件,设置导出文件的响应头部信息
response.setContentType("application/vnd.ms-excel");
// 生成excel,传递输出流
// 用response对象获取输出流
OutputStream os = response.getOutputStream();
generator.expordExcel(os);
// 清理刷新缓冲区,将缓存中的数据将数据导出excel
os.flush();
// 关闭os
if (os != null) {
os.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Aggregations