Commit 131b8ff9 authored by dahai's avatar dahai

push

parent c7bd42f0
...@@ -62,36 +62,37 @@ public class ExportExcelApi { ...@@ -62,36 +62,37 @@ public class ExportExcelApi {
* 导出交接单 * 导出交接单
*/ */
@RequestMapping("printReceiptExcelData") @RequestMapping("printReceiptExcelData")
public byte[] printReceiptExcelData(@RequestBody String list, HttpServletResponse response) { public List<Map<String, Object>> printReceiptExcelData(@RequestBody String list, HttpServletResponse response) {
JSONObject jsonObject = JSONObject.fromObject(list); JSONObject jsonObject = JSONObject.fromObject(list);
JSONArray jsonArray = JSONArray.fromObject(jsonObject.get("list")); JSONArray jsonArray = JSONArray.fromObject(jsonObject.get("list"));
String startDate = jsonObject.get("startDate").toString(); String startDate = jsonObject.get("startDate").toString();
String endDate = jsonObject.get("endDate").toString(); String endDate = jsonObject.get("endDate").toString();
String type = jsonObject.get("type").toString(); String type = jsonObject.get("type").toString();
List<Map<String, Object>> mapList = receiptService.selectReceiptList(jsonArray, replaceDate(startDate),replaceDate(endDate), Long.valueOf(type)); List<Map<String, Object>> mapList = receiptService.selectReceiptList(jsonArray, replaceDate(startDate),replaceDate(endDate), Long.valueOf(type));
response.setContentType("application/x-download"); // response.setContentType("application/x-download");
response.setCharacterEncoding("UTF-8"); // response.setCharacterEncoding("UTF-8");
String dateTime = DateFormatUtils.format(new Date(), "yyyy_MM_dd"); // String dateTime = DateFormatUtils.format(new Date(), "yyyy_MM_dd");
// //使用Servlet实现文件下载的时候,避免浏览器自动打开文件 //// //使用Servlet实现文件下载的时候,避免浏览器自动打开文件
String fout = null; // String fout = null;
fout = ExportExcel.exportReceiptExcelDate(mapList); // fout = ExportExcel.exportReceiptExcelDate(mapList);
String outFile = dateTime + ""; // String outFile = dateTime + "";
//
try { // try {
FileInputStream fis = new FileInputStream(new File(fout)); // FileInputStream fis = new FileInputStream(new File(fout));
byte[] b = new byte[fis.available()]; // byte[] b = new byte[fis.available()];
fis.read(b); // fis.read(b);
fis.close(); // fis.close();
response.setCharacterEncoding("utf-8"); // response.setCharacterEncoding("utf-8");
response.setContentType("application/octet-stream"); // response.setContentType("application/octet-stream");
response.addHeader("Content-Disposition", "attachment;" + new String(outFile.getBytes(), "iso-8859-1") + ".xls"); // response.addHeader("Content-Disposition", "attachment;" + new String(outFile.getBytes(), "iso-8859-1") + ".xls");
return b; // return b;
} catch (FileNotFoundException e) { // } catch (FileNotFoundException e) {
e.printStackTrace(); // e.printStackTrace();
} catch (IOException e) { // } catch (IOException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
return null; // return null;
return mapList;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment