配置统计Excel调整为后台导出
This commit is contained in:
@@ -264,15 +264,15 @@ public class ExcelCsv {
|
|||||||
* @param <E>
|
* @param <E>
|
||||||
* @return list 数据列表
|
* @return list 数据列表
|
||||||
*/
|
*/
|
||||||
public static <E> Map<String, List<String>> setDataList(Properties msgProp, Map<String,List> dataMap, Map<Object,Object> map){
|
public static <E> Map<String,List<List<String>>> setDataList(Properties msgProp, Map<String,List> dataMap, Map<Object,Object> map){
|
||||||
Map<String, List<String>> dataList=new HashMap<String, List<String>>();
|
Map<String,List<List<String>>> dataList=new HashMap<String, List<List<String>>>();
|
||||||
Set<String> keyList=dataMap.keySet();
|
Set<String> keyList=dataMap.keySet();
|
||||||
for (String key : keyList) {
|
for (String key : keyList) {
|
||||||
List<E> list=dataMap.get(key);
|
List<E> list=dataMap.get(key);
|
||||||
List<String> listT=new ArrayList<String>();
|
List<List<String>> listT=new ArrayList<List<String>>();
|
||||||
for (E e : list){
|
for (E e : list){
|
||||||
int colunm = 0;
|
int colunm = 0;
|
||||||
StringBuilder sb = new StringBuilder();
|
List<String> lisb=new ArrayList<String>();
|
||||||
for (Object[] os : annotationMap.get(key)){
|
for (Object[] os : annotationMap.get(key)){
|
||||||
ExcelField ef = (ExcelField)os[0];
|
ExcelField ef = (ExcelField)os[0];
|
||||||
Object val = null;
|
Object val = null;
|
||||||
@@ -332,16 +332,17 @@ public class ExcelCsv {
|
|||||||
log.error("Get entity value failed",ex);
|
log.error("Get entity value failed",ex);
|
||||||
val = "";
|
val = "";
|
||||||
}
|
}
|
||||||
sb.append(val + "┆~");
|
lisb.add(String.valueOf(val));
|
||||||
}
|
}
|
||||||
listT.add(String.valueOf(sb));
|
listT.add(lisb);
|
||||||
|
//listT.add(String.valueOf(sb));
|
||||||
}
|
}
|
||||||
dataList.put(key, listT);
|
dataList.put(key, listT);
|
||||||
}
|
}
|
||||||
return dataList;
|
return dataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void writeCSVFile(HttpServletResponse response,List<String> titleList,Map<String, List<String>> headMap, Map<String, List<String>> dataMap,String fileName,
|
public static <T> void writeCSVFile(HttpServletResponse response,List<String> titleList,Map<String, List<String>> headMap, Map<String,List<List<String>>> dataMap,String fileName,
|
||||||
String titleTime,Properties msgProp) {
|
String titleTime,Properties msgProp) {
|
||||||
try {
|
try {
|
||||||
// 写入临时文件
|
// 写入临时文件
|
||||||
@@ -369,9 +370,9 @@ public class ExcelCsv {
|
|||||||
// 写入文件头部
|
// 写入文件头部
|
||||||
writeHead(heads, cs);
|
writeHead(heads, cs);
|
||||||
//获取文件内容
|
//获取文件内容
|
||||||
List<String> datas=dataMap.get(titleList.get(i));
|
List<List<String>> datas=dataMap.get(titleList.get(i));
|
||||||
// 写入文件内容
|
// 写入文件内容
|
||||||
for (String row : datas) {
|
for (List<String> row: datas) {
|
||||||
writeRow(row, cs);
|
writeRow(row, cs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -421,12 +422,11 @@ public class ExcelCsv {
|
|||||||
csvWriter.newLine();
|
csvWriter.newLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> void writeRow(String data, BufferedWriter csvWriter) throws Exception {
|
private static <T> void writeRow(List<String> data, BufferedWriter csvWriter) throws Exception {
|
||||||
// 写入文件内容
|
// 写入文件内容
|
||||||
//Html 解码
|
//Html 解码
|
||||||
data = Encodes.unescapeHtml(data.toString());
|
for (String tag : data) {
|
||||||
String [] datas=data.split("┆~");
|
tag = Encodes.unescapeHtml(tag.toString());
|
||||||
for (String tag : datas) {
|
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
if("null".equals(tag.trim())){
|
if("null".equals(tag.trim())){
|
||||||
tag=null;
|
tag=null;
|
||||||
|
|||||||
@@ -2273,8 +2273,7 @@ public class BaseController {
|
|||||||
}
|
}
|
||||||
String titleTime=noExportMap.get("timeRange");
|
String titleTime=noExportMap.get("timeRange");
|
||||||
Map<String, List<String>> headMap=ExcelCsv.ExcelCsvHeader(msgProp, titleList, noExportMap, classMap, 1);
|
Map<String, List<String>> headMap=ExcelCsv.ExcelCsvHeader(msgProp, titleList, noExportMap, classMap, 1);
|
||||||
Map<String, List<String>> dataList=ExcelCsv.setDataList(msgProp, dataMap, map);
|
Map<String,List<List<String>>> dataList=ExcelCsv.setDataList(msgProp, dataMap, map);
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
ExcelCsv.writeCSVFile(response,titleList,headMap,dataList,fileName,titleTime,msgProp);
|
ExcelCsv.writeCSVFile(response,titleList,headMap,dataList,fileName,titleTime,msgProp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ function toPage(pageNo, pageSize, funcParam) {
|
|||||||
$('tbody').children().css('display', 'none');
|
$('tbody').children().css('display', 'none');
|
||||||
//显示元素
|
//显示元素
|
||||||
$('tbody').children().slice((pageNo-1)*pageSize, pageNo*pageSize).css('display', '');
|
$('tbody').children().slice((pageNo-1)*pageSize, pageNo*pageSize).css('display', '');
|
||||||
totaltb(pageNo,pageSize);
|
showTotal();
|
||||||
}
|
}
|
||||||
|
|
||||||
//底部跳页按钮
|
//底部跳页按钮
|
||||||
|
|||||||
@@ -249,6 +249,73 @@
|
|||||||
append: null
|
append: null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getTitl(tableMark){
|
||||||
|
var tb=document.getElementsByName(tableMark)[0];
|
||||||
|
var rows = tb.rows;
|
||||||
|
var cells = tb.cells;
|
||||||
|
var colums = tb.rows[0].cells.length;
|
||||||
|
$("."+tableMark+" .count").empty();
|
||||||
|
$("."+tableMark+" .count").append("<td><spring:message code='report_total' /></td>");
|
||||||
|
for(var j = 1; j < colums; j++){
|
||||||
|
var sum = 0;
|
||||||
|
for(var i = 1;i<rows.length-1;i++){
|
||||||
|
var a = parseInt(rows[i].cells[j].innerHTML.trim());
|
||||||
|
sum = sum + a;
|
||||||
|
}
|
||||||
|
$("."+tableMark+" .count").append("<td>"+sum+"</td>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getExport(tableId,url,titleName){
|
||||||
|
loading('<spring:message code="onloading"/>');
|
||||||
|
getTitl(tableId);
|
||||||
|
var tb=document.getElementsByName(tableId);
|
||||||
|
var rows=tb[0].rows;
|
||||||
|
var list=new Array();
|
||||||
|
list.splice(0,list.length);
|
||||||
|
var column=[]; //获取标题
|
||||||
|
var index=[];//获取数据列下标
|
||||||
|
var num=0;
|
||||||
|
$("table[name='"+tableId+"']").find("tr th").each(function(){
|
||||||
|
if($(this).is(":visible")){
|
||||||
|
column.push($(this).text().trim());
|
||||||
|
index.push(num);
|
||||||
|
}
|
||||||
|
num++;
|
||||||
|
});
|
||||||
|
for(var i=1 ; i<rows.length;i++){
|
||||||
|
var rowMap=[];
|
||||||
|
for (var j = 0; j <index.length ; j++) {
|
||||||
|
var n=index[j];
|
||||||
|
if(rows[i].cells[n]!=null){
|
||||||
|
if(rows[i].cells[n].innerText.indexOf("...") !=-1){
|
||||||
|
if(rows[i].cells[n].title.length > 20){
|
||||||
|
rowMap.push(rows[i].cells[n].title);
|
||||||
|
}else{
|
||||||
|
rowMap.push(rows[i].cells[n].innerText);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
rowMap.push(rows[i].cells[n].innerText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list[i-1]=rowMap;
|
||||||
|
}
|
||||||
|
var menuName = $("#menuName").val();
|
||||||
|
var fileName = menuName + "_" + getNowFormatDate();
|
||||||
|
var pztitle =$("#"+titleName).text();
|
||||||
|
var map={};
|
||||||
|
map.heard=column;
|
||||||
|
map.book=list;
|
||||||
|
map.titleTime=pztitle;
|
||||||
|
map.titleCode="config_service_statistics";
|
||||||
|
var exports=JSON.stringify(map);
|
||||||
|
aJaxImportPost(url,{"exports":exports});
|
||||||
|
$("."+tableId+" .count").empty();
|
||||||
|
closeTip();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<title>index</title>
|
<title>index</title>
|
||||||
@@ -260,9 +327,7 @@
|
|||||||
<form id="searchForm" action="${ctx}/configure/statistics/configureStateStatistics" >
|
<form id="searchForm" action="${ctx}/configure/statistics/configureStateStatistics" >
|
||||||
<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
|
<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
|
||||||
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
|
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
|
||||||
<font size="4"><i class="fa fa-cogs"> <spring:message code="letter_statistics_info"/>
|
<font size="4"><i class="fa fa-cogs" id="pzTitle"> <spring:message code="letter_statistics_info"/> [<spring:message code="statistic_time"/>:${requestStatisticTime }]</i>
|
||||||
[<spring:message code="statistic_time"/>:${requestStatisticTime }]
|
|
||||||
</i>
|
|
||||||
</font>
|
</font>
|
||||||
<a style="color:#333333" href="javascript:page(${page.pageNo},${page.pageSize});" class="icon-refresh"> </a>
|
<a style="color:#333333" href="javascript:page(${page.pageNo},${page.pageSize});" class="icon-refresh"> </a>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
@@ -272,7 +337,7 @@
|
|||||||
<i class="fa fa-angle-down"></i>
|
<i class="fa fa-angle-down"></i>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu pull-right" style="min-width: 110px;" >
|
<ul class="dropdown-menu pull-right" style="min-width: 110px;" >
|
||||||
<li><a href="javascript:;" class="export-btn" data-export-type="xlsx" data-export-table="cfgMenuTable"><i class="fa fa-download"> <spring:message code="Excel"/></i></a></li>
|
<li><a href="javascript:;" onclick="getExport('cfgMenuTable','${ctx}/export/ajaxExport','pzTitle')" data-export-table="cfgMenuTable" ><i class="fa fa-download"> <spring:message code="Excel"/></i></a></li>
|
||||||
<li><a href="javascript:;" class="export-btn" data-export-type="csv" data-export-table="cfgMenuTable"><i class="fa fa-download"> <spring:message code="CSV"/></i></a></li>
|
<li><a href="javascript:;" class="export-btn" data-export-type="csv" data-export-table="cfgMenuTable"><i class="fa fa-download"> <spring:message code="CSV"/></i></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -329,8 +394,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="statisticsStatus" class="statisticsStatus">
|
<div id="statisticsStatus" class="statisticsStatus">
|
||||||
<font size="4">
|
<font size="4">
|
||||||
<i class="fa fa-cogs"> <spring:message code="configure_statistics_info"/>
|
<i class="fa fa-cogs" id="statusTitle"><spring:message code="configure_statistics_info"/> [<spring:message code="statistic_time"/>:${configStatisticTime }]</i>
|
||||||
[<spring:message code="statistic_time"/>:${configStatisticTime }]</i>
|
|
||||||
</font>
|
</font>
|
||||||
<a style="color:#333333" href="javascript:page(${page.pageNo},${page.pageSize});" class="icon-refresh "> </a>
|
<a style="color:#333333" href="javascript:page(${page.pageNo},${page.pageSize});" class="icon-refresh "> </a>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
@@ -340,7 +404,7 @@
|
|||||||
<i class="fa fa-angle-down"></i>
|
<i class="fa fa-angle-down"></i>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu pull-right" style="min-width: 110px;" >
|
<ul class="dropdown-menu pull-right" style="min-width: 110px;" >
|
||||||
<li><a href="javascript:;" class="export-btn" data-export-type="xlsx" data-export-table="statisticsStatusTable"><i class="fa fa-download"> <spring:message code="Excel"/></i></a></li>
|
<li><a href="javascript:;" onclick="getExport('statisticsStatusTable','${ctx}/export/ajaxExport','statusTitle')" data-export-table="statisticsStatusTable"><i class="fa fa-download"> <spring:message code="Excel"/></i></a></li>
|
||||||
<li><a href="javascript:;" class="export-btn" data-export-type="csv" data-export-table="statisticsStatusTable"><i class="fa fa-download"> <spring:message code="CSV"/></i></a></li>
|
<li><a href="javascript:;" class="export-btn" data-export-type="csv" data-export-table="statisticsStatusTable"><i class="fa fa-download"> <spring:message code="CSV"/></i></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ $(document).ready(function() {
|
|||||||
var lipx=Number(li/6);
|
var lipx=Number(li/6);
|
||||||
lipx=lipx-3;
|
lipx=lipx-3;
|
||||||
$(".lireport").css({'width':lipx+'px','text-overflow':'ellipsis','overflow':'hidden'});
|
$(".lireport").css({'width':lipx+'px','text-overflow':'ellipsis','overflow':'hidden'});
|
||||||
|
totaltb(1,-1);
|
||||||
});
|
});
|
||||||
function getExportHead(){
|
function getExportHead(){
|
||||||
// 报表导出 文件增加表头
|
// 报表导出 文件增加表头
|
||||||
@@ -372,6 +372,13 @@ function customColumnClick(){
|
|||||||
$('#total').html(trtotal);
|
$('#total').html(trtotal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function showTotal(){
|
||||||
|
if($("#total")!=null){
|
||||||
|
$("#total").show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
window.onload=function (){
|
window.onload=function (){
|
||||||
setTimeout(function (){
|
setTimeout(function (){
|
||||||
var height=document.documentElement.clientHeight;
|
var height=document.documentElement.clientHeight;
|
||||||
@@ -477,7 +484,7 @@ function customColumnClick(){
|
|||||||
var column=[]; //获取标题
|
var column=[]; //获取标题
|
||||||
var index=[];//获取数据列下标
|
var index=[];//获取数据列下标
|
||||||
var num=0;
|
var num=0;
|
||||||
$("#"+tableId+" thead tr th").each(function(){
|
$("#"+tableId).find("tr th").each(function(){
|
||||||
if($(this).is(":visible")){
|
if($(this).is(":visible")){
|
||||||
column.push($(this).text().trim());
|
column.push($(this).text().trim());
|
||||||
index.push(num);
|
index.push(num);
|
||||||
|
|||||||
Reference in New Issue
Block a user