实时报表CSV导出调整为后台

This commit is contained in:
leijun
2019-01-04 18:53:18 +08:00
parent 19bb8a916e
commit 8e53249325
4 changed files with 105 additions and 14 deletions

View File

@@ -2291,7 +2291,22 @@ public class BaseController {
fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");
}
new ExportExcel(msgProp.getProperty(code, code),code,titleTime, headerList).ajaxDataList(dataList, code).write(response, fileName).dispose();
}
public void _ajaxCsv(HttpServletRequest request, HttpServletResponse response,
String code,String titleTime,List<String> headerList, List<List<String>> dataList)
throws Exception{
Properties msgProp = getMsgProp();
String fileName = msgProp.getProperty(code, code) + "_" + DateUtils.getDate("yyyyMMddHHmmss")
+ ".csv";
fileName = fileName.replaceAll(" ", "_");
if (request.getHeader("User-Agent").toUpperCase().indexOf("MSIE") > 0) {
fileName = URLEncoder.encode(fileName, "UTF-8");
} else {
fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");
}
ExcelCsv.ajaxCSVFile(response,headerList,dataList,fileName,titleTime,msgProp);
}
public String initLogMap(BaseLogEntity log,String title){

View File

@@ -34,6 +34,27 @@ public class ExportController extends BaseController {
}
_ajaxExport(request,response,titleCode, titleTime, heard, list);
}
@RequestMapping(value = "ajaxCsv")
public void ajaxCsv(String exports,HttpServletRequest request,HttpServletResponse response) throws Exception{
JSONObject jsonObject = JSONObject.fromObject(StringEscapeUtils.unescapeHtml(exports));
Map<String,Object> map=JSONObject.fromObject(jsonObject);
List<List<String>> list=(List<List<String >>) map.get("book");
List<String> heard=(List<String>) map.get("heard");
String titleTime=String.valueOf(map.get("titleTime"));
String titleCode=String.valueOf(map.get("titleCode"));
if(!StringUtil.isEmpty(titleTime)){
if(titleTime.contains("\"")){
titleTime = titleTime.replaceAll("\"", "").trim();
}
if(titleTime.startsWith("[")){
titleTime = titleTime.substring(1, titleTime.length()-1);
}
}
_ajaxCsv(request,response,titleCode, titleTime, heard, list);
}
}